- Timestamp:
- 10/16/01 15:10:43 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/macros/getCollArea.C
r948 r965 24 24 25 25 26 void getCollArea(char *filename = " data/gamma_15_on.root")26 void getCollArea(char *filename = "camera.root") 27 27 { 28 28 // FIXME: Harald, you should tell the people what the result of … … 55 55 // 56 56 MReadTree reader("Events", filename); 57 reader.UseLeaf("fImpact"); 58 reader.UseLeaf("fEnergy"); 59 reader.UseLeaf("fNumFirstLevel"); 57 60 tasklist.AddToList(&reader); 58 61 59 62 MMcCollectionAreaCalc effi; 60 63 tasklist.AddToList(&effi); 64 65 MTask task; 66 tasklist.AddToList(&task); 67 61 68 62 69 // -
trunk/MagicSoft/Mars/mbase/MReadTree.cc
r963 r965 38 38 // MReadTree::SetEventNum after instantiating your MReadTree-object. // 39 39 // // 40 // To make reading much faster (up to a factor of 10 to 20) you can // 41 // ensure that only the data you are really processing is enabled by // 42 // calling MReadTree::UseLeaf. // 43 // // 44 // Later we'll use TChain::SetNotify to notify MReadTree if the TChain // 45 // starts to read a new file. // 46 // // 40 47 ///////////////////////////////////////////////////////////////////////////// 41 48 … … 67 74 // 68 75 MReadTree::MReadTree(const char *tname, const char *fname, 69 const char *name, const char *title) : fNumEntry(0) 76 const char *name, const char *title) 77 : fNumEntry(0), fLeafEnabled(kFALSE) 70 78 { 71 79 *fName = name ? name : "MReadTree"; … … 113 121 // anymore, tree wich are not existing in the first file are never read) 114 122 // 115 /*Int_t*/ void MReadTree::AddFile(const char *fname) 123 // Name may use the wildcarding notation, eg "xxx*.root" means all files 124 // starting with xxx in the current file system directory. 125 // 126 Int_t MReadTree::AddFile(const char *fname) 116 127 { 117 128 // … … 121 132 // returns the number of file which were added 122 133 // 123 /*return root >3.0*/ fChain->Add(fname); 134 return fChain->Add(fname); 135 } 136 137 // -------------------------------------------------------------------------- 138 // 139 // The first time this function is called all leafes/branches are disabled 140 // and the given branch/leaf is enabled. By enabling only the branches you 141 // are processing you can speed up your calculation many times (up to 142 // a factor of 10 or 20) 143 // 144 void MReadTree::UseLeaf(const char *name) 145 { 146 if (!fLeafEnabled) 147 { 148 *fLog << "Leaf choosing method enabled (only enabled leaves are read)." << endl; 149 fChain->SetBranchStatus("*", kFALSE); 150 fLeafEnabled = kTRUE; 151 } 152 153 fChain->SetBranchStatus(name, kTRUE); 124 154 } 125 155 … … 170 200 // Get Name of Branch 171 201 // 172 const char *name 202 const char *name = branch->GetName(); 173 203 174 204 // … … 208 238 // 209 239 fChain->SetBranchAddress(name, pcont); 240 210 241 *fLog << "Branch " << name << " enabled for reading." << endl; 211 242 … … 227 258 Bool_t MReadTree::Process() 228 259 { 229 // 230 // check for end of file 231 // 232 if (fNumEntry>=fNumEntries) 233 return kFALSE; 234 235 // 236 // get entry 237 // 238 fChain->GetEntry(fNumEntry); 239 240 fNumEntry++; 241 242 return kTRUE; 260 return fChain->GetEntry(fNumEntry++, 0) == 0 ? kFALSE : kTRUE; 243 261 } 244 262 … … 249 267 Bool_t MReadTree::GetEvent() 250 268 { 251 fChain->GetEntry(fNumEntry); 252 253 return kTRUE; 269 return fChain->GetEntry(fNumEntry) == 0 ? kFALSE : kTRUE; 254 270 } 255 271 -
trunk/MagicSoft/Mars/mbase/MReadTree.h
r760 r965 21 21 UInt_t fNumEntries; // Number of Events in Tree 22 22 23 Bool_t fLeafEnabled; // Flag whether UseLeaf is called the first time or not 24 23 25 Bool_t HasVeto(const char *name) const; 24 26 … … 30 32 Bool_t Process(); 31 33 32 void AddFile(const char *fname); 33 void VetoBranch(const char *name); 34 Int_t AddFile(const char *fname); 35 void VetoBranch(const char *name); 36 37 void UseLeaf(const char *name); 34 38 35 39 Bool_t GetEvent();
Note:
See TracChangeset
for help on using the changeset viewer.