Changeset 2607 for trunk/MagicSoft/Mars/mfileio
- Timestamp:
- 12/05/03 16:06:34 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mfileio
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc
r2206 r2607 190 190 //MReadTree::Notify(); 191 191 192 *fLog << err << "ERROR - ReInit of '" << tlist->Get Name() << "' failed." << endl;192 *fLog << err << "ERROR - ReInit of '" << tlist->GetDescriptor() << "' failed." << endl; 193 193 return kFALSE; 194 194 } -
trunk/MagicSoft/Mars/mfileio/MReadReports.cc
r2604 r2607 70 70 #include "MTime.h" 71 71 #include "MParList.h" 72 #include "MReadTree.h"73 72 #include "MTaskList.h" 73 74 #include "MReadMarsFile.h" 74 75 75 76 ClassImp(MReadReports); … … 124 125 // name in time. 125 126 // 126 // All calls to AddTree _must_ be beforethe calls to AddFile!127 // 128 void MReadReports::AddTree(const char *tree, const char *time )127 // All calls to AddTree _must_ be BEFORE the calls to AddFile! 128 // 129 void MReadReports::AddTree(const char *tree, const char *time, Bool_t master) 129 130 { 130 131 /* … … 136 137 } 137 138 */ 138 MReadTree *t = new MReadTree(tree); 139 140 if (master && TestBit(kHasMaster)) 141 { 142 *fLog << warn << GetDescriptor() << " already has a master tree... ignored." << endl; 143 master = kFALSE; 144 } 145 146 MReadTree *t = master ? new MReadMarsFile(tree) : new MReadTree(tree); 139 147 t->SetName(tree); 140 148 t->SetTitle(time?time:""); 149 if (master) 150 t->SetBit(kHasMaster); 141 151 142 152 if (!fEnableAutoScheme) … … 154 164 // Schedule a file or several files (using widcards) for reading. 155 165 // 156 // All calls to AddTree _must_ be beforethe calls to AddFile!166 // All calls to AddTree _must_ be BEFORE the calls to AddFile! 157 167 // 158 168 Int_t MReadReports::AddFile(const char *fname, Int_t entries) … … 188 198 while ((tree=(MReadTree*)NextT())) 189 199 { 200 if (((TChain*)tree->fChain)->GetListOfFiles()->GetEntries()==0) 201 { 202 *fLog << warn << "No files for Tree " << tree->GetName() << "... skipped." << endl; 203 continue; 204 } 205 190 206 TString tn(tree->GetTitle()); 191 207 if (tn.IsNull()) … … 224 240 } 225 241 226 fPos .Set(i);242 fPosEntry.Set(i); 227 243 228 244 return fTrees->CallPreProcess(plist); … … 241 257 // -------------------------------------------------------------------------- 242 258 // 259 // Do not use if fChains->GetSize()==0 !!! 260 // 261 Int_t MReadReports::FindNextTime() 262 { 263 Int_t i=0; 264 265 TIter NextC(fChains); 266 TChain *c=0; 267 268 Int_t nmin=0; 269 MTime tmin(**GetTime((TChain*)NextC())); 270 271 while ((c=(TChain*)NextC())) 272 { 273 MTime &t = **GetTime(c); 274 i++; 275 276 if (t >= tmin) 277 continue; 278 279 tmin = t; 280 nmin = i; 281 } 282 return nmin; 283 } 284 285 /* 286 Bool_t MReadReports::Notify() 287 { 288 Bool_t same = kTRUE; 289 for (int i=1; i<fPosTree.GetSize(); i++) 290 if (fPosTree[i]!=fPosTree[0]) 291 { 292 same = kFALSE; 293 break; 294 } 295 296 Int_t tn = chain->GetTreeNumber(); 297 298 Bool_t read=kFALSE; 299 if (fPosTree[nmin] != tn) 300 { 301 fPosTree[nmin] = tn; 302 read = kTRUE; 303 } 304 305 if (!same || !read) 306 return kTRUE; 307 308 309 *fLog << dbg << "Read Run Headers!" << endl; 310 311 return kTRUE; 312 } 313 */ 314 315 // -------------------------------------------------------------------------- 316 // 243 317 // Check which is the next tree to read from. Read an event from this tree. 244 318 // Sets the StreamId accordingly. … … 248 322 while (fChains->GetSize()) 249 323 { 250 Int_t i=0; 251 252 MTime tmin; 253 254 Int_t nmin=0; 255 256 TIter NextC(fChains); 257 TChain *c=0; 258 while ((c=(TChain*)NextC())) 324 const Int_t nmin=FindNextTime(); 325 326 TChain *chain = (TChain*)fChains->At(nmin); 327 328 //Int_t before = chain->GetTreeNumber(); 329 if (chain->GetEntry(++fPosEntry[nmin])>0) 259 330 { 260 MTime &t = **GetTime(c); 261 262 if (i==0) 263 tmin = t; 264 265 if (t < tmin) 331 MTask *task = (MTask*)fTrees->GetList()->At(nmin); 332 333 if (task->CallProcess()) 266 334 { 267 tmin = t;268 nmin = i;335 fList->SetStreamId(task->GetName()); 336 return kTRUE; 269 337 } 270 i++;271 }272 273 TChain *chain = (TChain*)fChains->At(nmin);274 275 chain->GetEntry(++fPos[nmin]);276 277 // FIXME: Use Stream ID and call CallProcess() ?278 Bool_t rc = ((MTask*)fTrees->GetList()->At(nmin))->CallProcess();279 if (rc)280 {281 fList->SetStreamId(fTrees->GetList()->At(nmin)->GetName());282 return kTRUE;283 338 } 284 339 -
trunk/MagicSoft/Mars/mfileio/MReadReports.h
r2604 r2607 17 17 { 18 18 private: 19 MTaskList *fTrees; // Hold the trees which are scheduled for reading20 TList *fChains; // Hold TChains to read the times in advance19 MTaskList *fTrees; // Hold the trees which are scheduled for reading 20 TList *fChains; // Hold TChains to read the times in advance 21 21 22 TArrayL fPos; // Store the position in each tree/chain 22 TArrayL fPosEntry; // Store the position in each tree/chain 23 TArrayL fPosTree; // Number of Tree in file. 23 24 24 MTask *fList; // pointer to the task list to set the stream id25 MTask *fList; // pointer to the task list to set the stream id 25 26 26 27 Bool_t fEnableAutoScheme; 27 28 28 29 MTime** GetTime(TChain *c) const; 30 Int_t FindNextTime(); 29 31 30 32 UInt_t GetEntries() { return 0; } … … 34 36 Int_t PostProcess(); 35 37 38 //Bool_t Notify(); 39 40 enum { 41 //MReadTree::kChainWasChanged = BIT(14) 42 kHasMaster = BIT(15) 43 }; 44 36 45 public: 37 46 MReadReports(); 38 47 ~MReadReports(); 39 48 40 void AddTree(const char *tree, const char *time=NULL); 49 void AddTree(const char *tree, const char *time=NULL, Bool_t master=kFALSE); 50 void AddTree(const char *tree, Bool_t master) 51 { 52 AddTree(tree, NULL, master); 53 } 41 54 Int_t AddFile(const char *fname, Int_t entries=-1); 42 55 void AddToBranchList(const char *name); … … 44 57 void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const; 45 58 46 void EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; } 59 void EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; } // Must be called BEFORE AddTree! 47 60 48 61 ClassDef(MReadReports, 0) // Reads events and reports from a root file ordered in time -
trunk/MagicSoft/Mars/mfileio/MReadTree.cc
r2532 r2607 192 192 continue; 193 193 194 *fLog << err << "ERROR - File corrupt tion detected:" << endl;194 *fLog << err << "ERROR - File corruption detected:" << endl; 195 195 *fLog << " Due to several circumstances (such at a bug in MReadTree or wrong" << endl; 196 196 *fLog << " usage of the file UPDATE mode) you may have produced a file in which" << endl; … … 232 232 *fLog << GetNumEntry()-1 << ")" << endl; 233 233 234 //fNotify->Notify(); 234 if (!fNotify) 235 return kTRUE; 236 237 TIter Next(fNotify); 238 TObject *o=NULL; 239 while ((o=Next())) 240 if (!o->Notify()) 241 { 242 *fLog << err << "Calling Notify() for object " << o->GetName() << " failed... abort." << endl; 243 return kFALSE; 244 } 235 245 236 246 return kTRUE;
Note:
See TracChangeset
for help on using the changeset viewer.