Changeset 19848 for trunk/Mars/mcorsika/MCorsikaRead.cc
- Timestamp:
- 11/01/19 14:18:10 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcorsika/MCorsikaRead.cc
r19696 r19848 167 167 // This opens the next file in the list and deletes its name from the list. 168 168 // 169 Int_t MCorsikaRead::OpenNextFile(Bool_t print )169 Int_t MCorsikaRead::OpenNextFile(Bool_t print, Bool_t telrequired) 170 170 { 171 171 … … 196 196 return kERROR; 197 197 198 *fLog << inf << "Open file: '" << name << "'" << endl; 199 200 // Check if thsi is a single telescope from a CORSIKA telescope array 201 // This is indicated by the -telXXX attached to the filename 202 TObjArray *res = TPRegexp("(.*/)?cer([0-9]+)-tel([0-9]+)").MatchS(name, "i"); 203 if (res->GetLast()==3) 198 *fLog << (telrequired?inf:all) << "Open file: '" << name << "'" << endl; 199 200 if (telrequired) 204 201 { 205 const TString match = res->At(0)->GetName(); 206 const TString path = res->At(1)->GetName(); 207 const UInt_t runid = atoi(res->At(2)->GetName()); 208 const UInt_t telid = atoi(res->At(3)->GetName()); 209 210 *fLog << inf2 << "Run " << runid << " detected to be for telescope #" << telid << endl; 211 212 if (telid>=fNumTelescopes) 202 // Check if thsi is a single telescope from a CORSIKA telescope array 203 // This is indicated by the -telXXX attached to the filename 204 TObjArray *res = TPRegexp("(.*/)?cer([0-9]+)-tel([0-9]+)").MatchS(name, "i"); 205 if (res->GetLast()==3) 213 206 { 214 *fLog << err << "Position of telescope " << telid << " not defined." << endl; 215 return kERROR; 207 const TString match = res->At(0)->GetName(); 208 const TString path = res->At(1)->GetName(); 209 const UInt_t runid = atoi(res->At(2)->GetName()); 210 const UInt_t telid = atoi(res->At(3)->GetName()); 211 212 *fLog << inf2 << "Run " << runid << " detected to be for telescope #" << telid << endl; 213 214 if (telid>=fNumTelescopes) 215 { 216 *fLog << err << "Position of telescope " << telid << " not defined." << endl; 217 return kERROR; 218 } 219 220 *fLog << inf << "Telescope #" << telid << " [X/Y/Z (R)]: "; 221 *fLog << fTelescopeX[telid] << "/"; 222 *fLog << fTelescopeY[telid] << "/"; 223 *fLog << fTelescopeZ[telid] << " (R=" << fTelescopeR[telid] << ")" << endl; 224 225 fNumTelescope = telid+1; 216 226 } 217 218 *fLog << inf << "Telescope #" << telid << " [X/Y/Z (R)]: "; 219 *fLog << fTelescopeX[telid] << "/"; 220 *fLog << fTelescopeY[telid] << "/"; 221 *fLog << fTelescopeZ[telid] << " (R=" << fTelescopeR[telid] << ")" << endl; 222 223 fNumTelescope = telid+1; 227 delete res; 224 228 } 225 delete res;226 227 229 228 230 if (fDisplay) … … 288 290 fNumTotalEvents = 0; 289 291 292 MCorsikaRunHeader runheader; 293 290 294 Bool_t rc = kTRUE; 291 295 292 296 while (1) 293 297 { 294 switch (OpenNextFile(kFALSE ))298 switch (OpenNextFile(kFALSE, kFALSE)) 295 299 { 296 300 case kFALSE: … … 310 314 { 311 315 if (blockType == 1200) 312 status = fRunHeader->ReadEvt(fInFormat, blockLength / sizeof(Float_t));316 status = runheader.ReadEvt(fInFormat, blockLength / sizeof(Float_t)); 313 317 314 318 else if(blockType == 1201) … … 319 323 vector<Float_t> buffer(blockLength / sizeof(Float_t)); 320 324 status = fInFormat->Read(buffer.data(), blockLength); 321 status = fRunHeader->ReadEventHeader(buffer.data());325 status = runheader.ReadEventHeader(buffer.data()); 322 326 break; 323 327 } … … 325 329 fInFormat->Seek(blockLength); 326 330 } 327 331 328 332 if (status != kTRUE) 329 333 return status; … … 331 335 if (!fInFormat->SeekEvtEnd()) 332 336 { 333 *fLog << (fForceMode?warn:err) << "E rror:RUNE section not found in file." << endl;337 *fLog << (fForceMode?warn:err) << "ERROR - RUNE section not found in file." << endl; 334 338 if (!fForceMode) 335 339 return fForceMode ? kTRUE : kFALSE; 336 340 } 337 341 338 if (! fRunHeader->ReadEvtEnd(fInFormat, kTRUE))342 if (!runheader.ReadEvtEnd(fInFormat, kTRUE)) 339 343 { 340 *fLog << (fForceMode?warn:err) << "E rror:Reading RUNE section failed." << endl;344 *fLog << (fForceMode?warn:err) << "ERROR - Reading RUNE section failed." << endl; 341 345 if (!fForceMode) 342 346 return kFALSE; 343 347 } 344 348 345 fNumTotalEvents += fRunHeader->GetNumEvents()*fRunHeader->GetNumReuse()*349 fNumTotalEvents += runheader.GetNumEvents()*runheader.GetNumReuse()* 346 350 (fTelescopeIdx<0 && fNumTelescope==0 ? fNumTelescopes : 1); 347 351 continue; … … 806 810 *fLog << inf2 << "Reading Telecope positions from " << fname << ":" << endl; 807 811 808 TPRegexp regexp("\\s*TELESCOPE"809 "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"810 "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"811 "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"812 "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"813 "\\s+([0-9]+)\\s*");814 815 812 ifstream fin(fname); 816 813 … … 823 820 break; 824 821 825 const TObjArray *res = regexp.MatchS(buf); 826 if (res->GetLast()==9) 822 buf = buf.Strip(TString::kBoth); 823 if (buf(0, 9)!="TELESCOPE") 824 continue; 825 826 float x, y, z, r; 827 int idx; 828 if (sscanf(buf.Data()+9, "%f %f %f %f %d", &x, &y, &z, &r, &idx)!=5) 829 continue; 830 831 if (idx>=fNumTelescopes) 827 832 { 828 const UInt_t idx = atoi(res->At(9)->GetName()); 829 if (idx>=fNumTelescopes) 830 { 831 fNumTelescopes = idx+1; 832 fTelescopeX.Set(fNumTelescopes); 833 fTelescopeY.Set(fNumTelescopes); 834 fTelescopeZ.Set(fNumTelescopes); 835 fTelescopeR.Set(fNumTelescopes); 836 } 837 838 fTelescopeX[idx] = atof(res->At(1)->GetName()); 839 fTelescopeY[idx] = atof(res->At(3)->GetName()); 840 fTelescopeZ[idx] = atof(res->At(5)->GetName()); 841 fTelescopeR[idx] = atof(res->At(7)->GetName()); 833 fNumTelescopes = idx+1; 834 fTelescopeX.Set(fNumTelescopes); 835 fTelescopeY.Set(fNumTelescopes); 836 fTelescopeZ.Set(fNumTelescopes); 837 fTelescopeR.Set(fNumTelescopes); 842 838 } 843 delete res; 839 840 fTelescopeX[idx] = x; 841 fTelescopeY[idx] = y; 842 fTelescopeZ[idx] = z; 843 fTelescopeR[idx] = r; 844 844 } 845 845
Note:
See TracChangeset
for help on using the changeset viewer.