Changeset 706 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 03/27/01 16:05:54 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MReadTree.cc
r666 r706 18 18 19 19 #include <TFile.h> 20 #include <T Tree.h>20 #include <TChain.h> 21 21 #include <TObjArray.h> 22 22 23 23 #include "MLog.h" 24 #include "MLogManip.h" 25 24 26 #include "MTime.h" 25 27 #include "MParList.h" … … 27 29 ClassImp(MReadTree) 28 30 29 MReadTree::MReadTree(const char * fname, const char *tname,31 MReadTree::MReadTree(const char *tname, const char *fname, 30 32 const char *name, const char *title) 31 33 { … … 36 38 // open the input stream 37 39 // 38 fFileName = fname; 39 fTreeName = tname; 40 fChain = new TChain(tname); 41 42 if (fname) 43 fChain->Add(fname); 44 } 45 46 MReadTree::~MReadTree() 47 { 48 delete fChain; 49 } 50 51 /*Int_t*/ void MReadTree::AddFile(const char *fname) 52 { 53 // 54 // FIXME! A check is missing whether the file already exists or not. 55 // 56 // 57 // returns the number of file which were added 58 // 59 /*return root >3.0*/ fChain->Add(fname); 40 60 } 41 61 … … 45 65 // open file and check if file is really open 46 66 // 47 fFile = new TFile(fFileName, "READ");48 49 if (!fFile->IsOpen())50 {51 *fLog << "MReadTree::PreProcess: ERROR: Cannot open file '";52 *fLog << fFileName << "'" << endl;53 return kFALSE;54 }55 56 //57 // try to get the tree and check if it was found58 //59 fTree = (TTree*)fFile->Get(fTreeName);60 if (!fTree)61 {62 *fLog << "MReadTree::PreProcess: ERROR: Cannot open tree '";63 *fLog << fTreeName << "'" << endl;64 return kFALSE;65 }66 67 67 68 // 68 69 // get number of events in this tree 69 70 // 70 fNumEntries = (UInt_t)fTree->GetEntries(); 71 fNumEntries = (UInt_t)fChain->GetEntries(); 72 73 if (!fNumEntries) 74 { 75 *fLog << dbginf << "No Entries found in chain (file/s)." << endl; 76 return kFALSE; 77 } 71 78 72 79 // … … 78 85 // output logging information 79 86 // 80 *fLog << "File: '" << fFileName << "' Tree: '" << fTreeName; 81 *fLog << "' with " << fNumEntries << " Entries opened." << endl; 87 *fLog << fNumEntries << " Entries found in file(s)." << endl; 82 88 83 89 // … … 85 91 // create the Iterator to loop over all branches 86 92 // 87 TIter Next(f Tree->GetListOfBranches());93 TIter Next(fChain->GetListOfBranches()); 88 94 TBranch *branch=NULL; 89 95 … … 102 108 // 103 109 MParContainer *pcont = pList->FindCreateObj(name); 110 104 111 105 112 if (!pcont) … … 134 141 // get entry 135 142 // 136 f Tree->GetEntry(fNumEntry );143 fChain->GetEntry(fNumEntry ); 137 144 138 145 fNumEntry ++ ; … … 146 153 // Close File 147 154 // 148 fFile->Close();155 //fFile->Close(); 149 156 150 157 return kTRUE; … … 156 163 // Get the Event with the current EventNumber fNumEntry 157 164 // 158 f Tree->GetEntry(fNumEntry);165 fChain->GetEntry(fNumEntry); 159 166 160 167 return kTRUE;
Note:
See TracChangeset
for help on using the changeset viewer.