Changeset 1668 for trunk/MagicSoft/Mars/mfileio
- Timestamp:
- 11/25/02 09:12:47 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mfileio
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc
r1583 r1668 127 127 const char *name = file->GetName(); 128 128 129 fIn = new ifstream(gSystem->ExpandPathName(name)); 129 const char *expname = gSystem->ExpandPathName(name); 130 fIn = new ifstream(expname); 131 delete [] expname; 130 132 131 133 const Bool_t noexist = !(*fIn); -
trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
r1666 r1668 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de> 19 ! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de) 18 ! Author(s): Thomas Bretz 11/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 20 19 ! 21 ! Copyright: MAGIC Software Development, 2000-200 120 ! Copyright: MAGIC Software Development, 2000-2002 22 21 ! 23 22 ! … … 29 28 // 30 29 // Reads a output file of the CT1 preproc. 30 // 31 // Implements usage of a selector (see MRead) Use such a filter to skip 32 // events before reading! But never use a filter which needs read data 33 // as input... 31 34 // 32 35 // Input Containers: … … 58 61 #include "MLogManip.h" 59 62 63 #include "MTime.h" 64 #include "MFilter.h" 65 60 66 #include "MParList.h" 61 67 #include "MCerPhotEvt.h" … … 112 118 void MCT1ReadPreProc::AddFile(const char *txt) 113 119 { 114 const TString fname = gSystem->ExpandPathName(txt); 120 const char *name = gSystem->ExpandPathName(txt); 121 TString fname(name); 122 delete [] name; 115 123 116 124 if (!CheckHeader(fname)) … … 502 510 // open the file which is the first one in the chain 503 511 // 504 const TString name = file->GetName(); 505 const TString fname = gSystem->ExpandPathName(name); 512 const TString name = file->GetName(); 513 514 const char *expname = gSystem->ExpandPathName(name); 515 const TString fname(expname); 516 delete [] expname; 506 517 507 518 // … … 648 659 649 660 // 661 // look for the time class in the plist 662 // 663 fTime = (MTime*)pList->FindCreateObj("MTime"); 664 if (!fTime) 665 return kFALSE; 666 667 // 650 668 // look for the pedestal class in the plist 651 669 // … … 685 703 fNumRuns = 0; 686 704 687 return kTRUE;705 return GetSelector() ? GetSelector()->CallPreProcess(pList) : kTRUE; 688 706 } 689 707 … … 695 713 void MCT1ReadPreProc::ProcessEvent(const struct eventrecord &event) 696 714 { 715 // int isecs_since_midday; // seconds passed since midday before sunset (JD of run start) 716 // int isecfrac_200ns; // fractional part of isecs_since_midday 717 fTime->SetTime(event.isecfrac_200ns, event.isecs_since_midday); 718 fTime->SetReadyToSave(); 719 697 720 /* 698 721 --- USEFULL? NEEDED? --- 699 int isecs_since_midday; // seconds passed since midday before sunset (JD of run start)700 int isecfrac_200ns; // fractional part of isecs_since_midday701 722 short snot_ok_flags; // the bits in these two bytes are flags for additional information on the event: Everything OK =: all Bits = 0 702 723 … … 862 883 return kFALSE; 863 884 885 // 886 // Check for a selector. If one is given and returns kFALSE 887 // skip this event. 888 // 889 if (GetSelector()) 890 { 891 // 892 // Make sure selector is processed 893 // 894 if (!GetSelector()->CallProcess()) 895 { 896 *fLog << err << dbginf << "Processing Selector failed." << endl; 897 return kFALSE; 898 } 899 900 // 901 // Skip Event 902 // 903 if (!GetSelector()->IsExpressionTrue()) 904 { 905 fIn->seekg(sizeof(struct eventrecord), ios::cur); 906 907 fNumEvents++; 908 fNumEventsInRun++; 909 910 return kCONTINUE; 911 } 912 } 913 864 914 // event data to be read from the file 865 915 struct eventrecord event; … … 890 940 } 891 941 892 return kTRUE;893 } 942 return GetSelector() ? GetSelector()->CallPostProcess() : kTRUE; 943 } -
trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h
r1664 r1668 7 7 8 8 class TList; 9 class MTime; 9 10 class MMcEvt; 10 11 class MMcTrig; … … 27 28 MCerPhotEvt *fNphot; // the data container for all data. 28 29 MPedestalCam *fPedest; // ct1 pedestals 30 MTime *fTime; // event time 29 31 MMcEvt *fMcEvt; // monte carlo data container for MC files 30 32 MMcTrig *fMcTrig; // mc data container for trigger information … … 52 54 void ProcessEvent(const struct eventrecord &event); 53 55 56 Bool_t PreProcess(MParList *pList); 57 Bool_t Process(); 58 Bool_t PostProcess(); 59 54 60 public: 55 61 MCT1ReadPreProc(const char *filename=NULL, … … 61 67 void AddFile(const char *fname); 62 68 63 Bool_t PreProcess(MParList *pList);64 Bool_t Process();65 Bool_t PostProcess();66 67 69 UInt_t GetEntries() { return fEntries; } 68 70 -
trunk/MagicSoft/Mars/mfileio/MRead.cc
r1600 r1668 29 29 // Base class for all reading tasks // 30 30 // // 31 // You can set a selector. Depending on the impelementation in the derived // 32 // class it can be used to skip events, if the filter return kFALSE. // 33 // Make sure that the selector (filter) doesn't need information which // 34 // doesn't exist before reading an event! // 35 // // 31 36 ///////////////////////////////////////////////////////////////////////////// 32 37 #include "MRead.h" -
trunk/MagicSoft/Mars/mfileio/MRead.h
r1600 r1668 6 6 #endif 7 7 8 class MFilter; 9 8 10 class MRead : public MTask 9 11 { 12 private: 13 MFilter *fSelector; 14 10 15 public: 16 MRead() : fSelector(NULL) {} 11 17 12 18 virtual UInt_t GetEntries() = 0; 19 20 void SetSelector(MFilter *f) { fSelector = f; } 21 MFilter *GetSelector() { return fSelector; } 13 22 14 23 ClassDef(MRead, 0) // Base class for a reading task -
trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc
r1667 r1668 98 98 // chains -1 is returned, otherwise the number of files which were added. 99 99 // 100 Int_t MReadMarsFile::AddFile(const char *fname )100 Int_t MReadMarsFile::AddFile(const char *fname, Int_t entries) 101 101 { 102 102 // … … 107 107 // 108 108 Int_t n1 = fRun->AddFile(fname); 109 Int_t n2 = MReadTree::AddFile(fname );109 Int_t n2 = MReadTree::AddFile(fname, entries); 110 110 111 111 return n1 != n2 ? -1 : n1; -
trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h
r1664 r1668 24 24 ~MReadMarsFile(); 25 25 26 Int_t AddFile(const char *fname );26 Int_t AddFile(const char *fname, Int_t entries=-1); 27 27 28 28 ClassDef(MReadMarsFile, 1) // Reads a tree from file(s) and the information from the 'RunHeader'-tree -
trunk/MagicSoft/Mars/mfileio/MReadTree.cc
r1664 r1668 191 191 // AddFile returns the number of files added to the chain. 192 192 // 193 Int_t MReadTree::AddFile(const char *fname) 194 { 193 // For more information see TChain::Add 194 // 195 Int_t MReadTree::AddFile(const char *fname, Int_t entries) 196 { 197 #if ROOT_VERSION_CODE < ROOT_VERSION(3,03,01) 198 // 199 // This is a workaround to get rid of crashed if the file doesn't 200 // exist due to non initialized TFile::fProcessIDs 201 // 202 // (Code taken from TFile::TFile 203 // 204 const char *name; 205 206 TString newname; 207 208 if ((name = gSystem->ExpandPathName(fname))) 209 { 210 newname = name; 211 delete [] name; 212 } 213 214 if (newname.IsNull()) 215 { 216 *fLog << err << dbginf << "Error expanding path " << fname << "." << endl; 217 return 0; 218 } 219 220 if (gSystem->AccessPathName(newname, kFileExists)) 221 { 222 *fLog << err << "ERROR - File '" << fname << "' does not exist." << endl; 223 return 0; 224 } 225 226 fname = newname.Data(); 227 #endif 228 195 229 // 196 230 // FIXME! A check is missing whether the file already exists or not. 197 231 // 198 // 199 // returns the number of file which were added 200 // 201 202 const Int_t numfiles = fChain->Add(fname); 232 const Int_t numfiles = fChain->Add(fname, entries); 203 233 204 234 if (numfiles>0) … … 208 238 } 209 239 240 /* 241 // -------------------------------------------------------------------------- 242 // 243 // 244 Int_t MReadTree::AddFile(const TChainElement &obj) 245 { 246 return AddFile(obj.GetTitle(), obj.GetEntries()); 247 } 248 */ 249 210 250 // -------------------------------------------------------------------------- 211 251 // … … 216 256 Int_t MReadTree::AddFiles(const MReadTree &read) 217 257 { 218 Int_t rc = 0; 219 220 TIter Next(read.fChain->GetListOfFiles()); 221 TObject *obj = NULL; 222 while ((obj=Next())) 223 rc += AddFile(obj->GetTitle()); 258 const Int_t rc = fChain->Add(read.fChain); 224 259 225 260 if (rc>0) 226 261 SetBit(kChainWasChanged); 262 263 /* 264 Int_t rc = 0; 265 266 TIter Next(read.fChain->GetListOfFiles()); 267 TObject *obj = NULL; 268 while ((obj=Next())) 269 rc += AddFile(*(TChainElement*)obj); 270 */ 227 271 228 272 return rc; … … 241 285 return; 242 286 243 *fLog << inf << GetDescriptor() << ": Branch choosing methodenabled (only enabled branches are read)." << endl;287 *fLog << inf << GetDescriptor() << ": Branch choosing enabled (only enabled branches are read)." << endl; 244 288 fChain->SetBranchStatus("*", kFALSE); 245 289 fBranchChoosing = kTRUE; … … 255 299 void MReadTree::EnableBranch(const char *name) 256 300 { 301 if (fChain->GetListOfFiles()->GetEntries()==0) 302 { 303 *fLog << err << "Chain contains no file... Branch '"; 304 *fLog << name << "' ignored." << endl; 305 return; 306 } 307 257 308 EnableBranchChoosing(); 258 309 … … 449 500 // root environment) the branch is skipped and an error message is printed 450 501 // out. 502 // If a selector is specified it is preprocessed after the 503 // MReadTree::PreProcess 451 504 // 452 505 Bool_t MReadTree::PreProcess(MParList *pList) … … 576 629 fChain->SetNotify(this); 577 630 578 return kTRUE;631 return GetSelector() ? GetSelector()->CallPreProcess(pList) : kTRUE; 579 632 } 580 633 … … 626 679 // (Remark: The position can also be set by some member functions 627 680 // If the end of the file is reached the Eventloop is stopped. 681 // In case an event selector is given its value is checked before 682 // reading the event. If it returns kAFLSE the event is skipped. 628 683 // 629 684 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06) … … 658 713 #endif 659 714 660 Bool_t rc = fChain->GetEntry(fNumEntry++) != 0; 715 if (GetSelector()) 716 { 717 // 718 // Make sure selector is processed 719 // 720 if (!GetSelector()->CallProcess()) 721 { 722 *fLog << err << dbginf << "Processing Selector failed." << endl; 723 return kFALSE; 724 } 725 726 // 727 // Skip Event 728 // 729 if (!GetSelector()->IsExpressionTrue()) 730 { 731 fNumEntry++; 732 return kCONTINUE; 733 } 734 } 735 736 const Bool_t rc = fChain->GetEntry(fNumEntry++) != 0; 661 737 662 738 if (rc) … … 664 740 665 741 return rc; 742 } 743 744 // -------------------------------------------------------------------------- 745 // 746 // If a selector is given the selector is post processed 747 // 748 Bool_t MReadTree::PostProcess() 749 { 750 return GetSelector() ? GetSelector()->CallPostProcess() : kTRUE; 666 751 } 667 752 -
trunk/MagicSoft/Mars/mfileio/MReadTree.h
r1600 r1668 64 64 virtual void Print(Option_t *opt="") const; 65 65 66 virtual Int_t AddFile(const char *fname );66 virtual Int_t AddFile(const char *fname, Int_t entries=-1); 67 67 virtual Int_t AddFiles(const MReadTree &read); 68 68 69 69 virtual Bool_t PreProcess(MParList *pList); 70 70 virtual Bool_t Process(); 71 virtual Bool_t PostProcess(); 71 72 72 73 virtual Bool_t Notify();
Note:
See TracChangeset
for help on using the changeset viewer.