Changeset 19535
- Timestamp:
- 06/03/19 15:55:18 (5 years ago)
- Location:
- trunk/Mars/mcorsika
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcorsika/MCorsikaRead.cc
r19344 r19535 43 43 44 44 #include <TSystem.h> 45 #include <TPRegexp.h> 46 #include <TObjString.h> 45 47 46 48 #include "MLog.h" … … 100 102 : fRunHeader(0), fEvtHeader(0), fEvent(0), fTelescopeIdx(-1), fArrayIdx(-1), 101 103 fForceMode(kFALSE), fFileNames(0), fNumFile(0), fNumEvents(0), 102 fNumTotalEvents(0), fInFormat(0), fParList(0), fNumTelescopes(1), f ReadState(0)104 fNumTotalEvents(0), fInFormat(0), fParList(0), fNumTelescopes(1), fNumTelescope(0), fReadState(0) 103 105 { 104 106 fName = name ? name : "MRead"; … … 195 197 196 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) 204 { 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 the " << telid << "-th telescope." << endl; 211 212 *fLog << inf << "Telescope #" << telid << " [X/Y/Z (R)]: "; 213 *fLog << fTelescopeX[telid-1] << "/"; 214 *fLog << fTelescopeY[telid-1] << "/"; 215 *fLog << fTelescopeZ[telid-1] << " (R=" << fTelescopeR[telid-1] << ")" << endl; 216 217 fNumTelescope = telid; 218 } 219 delete res; 220 197 221 198 222 if (fDisplay) … … 583 607 Float_t xArrOff, yArrOff; 584 608 fEvtHeader->GetArrayOffset(arrayIdx, xArrOff, yArrOff); 585 fEvtHeader->SetTelescopeOffset(arrayIdx, 609 fEvtHeader->SetTelescopeOffset(arrayIdx, 586 610 xArrOff + fTelescopeY[telIdx], 587 611 yArrOff - fTelescopeX[telIdx] ); … … 605 629 fEvtHeader->ResetNumReuse(); 606 630 fEvtHeader->InitXY(); 631 if (fNumTelescope>0) 632 { 633 // Here, the impact has opposite sign -- I don't understand why 634 fEvtHeader->SetXY(+fTelescopeY[fNumTelescope-1]-fEvtHeader->GetX(), 635 -fTelescopeX[fNumTelescope-1]-fEvtHeader->GetY()); 636 } 607 637 fBlockType = 1109; // save corsika events 608 638 continue; … … 640 670 641 671 case 1109: // save corsika events 642 fEvtHeader->InitXY(); 672 fEvtHeader->InitXY(); 673 if (fNumTelescope>0) 674 { 675 // Here, the impact has opposite sign -- I don't understand why 676 fEvtHeader->SetXY(+fTelescopeY[fNumTelescope-1]-fEvtHeader->GetX(), 677 -fTelescopeX[fNumTelescope-1]-fEvtHeader->GetY()); 678 } 643 679 status = fEvent->ReadCorsikaEvt(fRawEvemtBuffer, 644 680 fBlockLength == MCorsikaFormat::kBlockLengthRaw/21 - 4 ? 7 : 8, … … 726 762 //*fLog << fRunHeader->GetNumReuse() << "*" << fNumEvents << "=" << n << ")." << endl; 727 763 728 729 764 return kTRUE; 730 765 } 731 766 767 Int_t MCorsikaRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 768 { 769 Bool_t rc = kFALSE; 770 if (IsEnvDefined(env, prefix, "TelescopeIndex", print)) 771 { 772 rc = kTRUE; 773 fNumTelescope = GetEnvValue(env, prefix, "TelescopeIndex", 0); 774 775 fTelescopeX.Set(1); 776 fTelescopeY.Set(1); 777 fNumTelescope = 1; 778 779 if (IsEnvDefined(env, prefix, "TelescopeX", print)) 780 fTelescopeX[0] = GetEnvValue(env, prefix, "TelescopeX", 0.); 781 if (IsEnvDefined(env, prefix, "TelescopeY", print)) 782 fTelescopeY[0] = GetEnvValue(env, prefix, "TelescopeY", 0.); 783 784 *fLog << all << "Telescope #" << setw(4) << fNumTelescope << " [X/Y]: "; 785 *fLog << setw(7) << fTelescopeX[0] << "/"; 786 *fLog << setw(7) << fTelescopeY[0] << endl; 787 } 788 789 // Read telescope positions from corsika input card 790 if (IsEnvDefined(env, prefix, "CorsikaInputCard", print)) 791 { 792 rc = kTRUE; 793 TString fname = GetEnvValue(env, prefix, "CorsikaInputCard", ""); 794 795 gSystem->ExpandPathName(fname); 796 797 // Is file accessible 798 if (gSystem->AccessPathName(fname, kFileExists)) 799 return kERROR; 800 801 *fLog << inf2 << "Reading Telecope positions from " << fname << ":" << endl; 802 803 TPRegexp regexp("\\s*TELESCOPE" 804 "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)" 805 "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)" 806 "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)" 807 "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)" 808 "\\s+([0-9]+)\\s*"); 809 810 ifstream fin(fname); 811 812 813 TString buf; 814 while (1) 815 { 816 buf.ReadLine(fin); 817 if (!fin) 818 break; 819 820 const TObjArray *res = regexp.MatchS(buf); 821 if (res->GetLast()==9) 822 { 823 const UInt_t idx = atoi(res->At(9)->GetName()); 824 if (idx==0) 825 { 826 *fLog << warn << "Telescope with index 0 ignored." << endl; 827 delete res; 828 continue; 829 } 830 if (idx>=fNumTelescopes) 831 { 832 fTelescopeX.Set(idx); 833 fTelescopeY.Set(idx); 834 fTelescopeZ.Set(idx); 835 fTelescopeR.Set(idx); 836 fNumTelescopes = idx; 837 } 838 839 fTelescopeX[idx-1] = atof(res->At(1)->GetName()); 840 fTelescopeY[idx-1] = atof(res->At(3)->GetName()); 841 fTelescopeZ[idx-1] = atof(res->At(5)->GetName()); 842 fTelescopeR[idx-1] = atof(res->At(7)->GetName()); 843 } 844 delete res; 845 } 846 847 848 for (int i=0; i<fNumTelescopes; i++) 849 { 850 *fLog << all << "Telescope #" << setw(4) << i+1 << " [X/Y/Z (R)]: "; 851 *fLog << setw(7) << fTelescopeX[i] << "/"; 852 *fLog << setw(7) << fTelescopeY[i] << "/"; 853 *fLog << setw(7) << fTelescopeZ[i] << " (R=" << setw(4) << fTelescopeR[i] << ")" << endl; 854 } 855 } 856 857 return rc; 858 } 859 -
trunk/Mars/mcorsika/MCorsikaRead.h
r10165 r19535 93 93 UInt_t GetEntries() { return fNumTotalEvents/*/fInterleave*/; } 94 94 95 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); 96 95 97 ClassDef(MCorsikaRead, 0) // Task to read the raw data binary file 96 98 };
Note:
See TracChangeset
for help on using the changeset viewer.