Changeset 7115 for trunk/MagicSoft/Mars/mfileio
- Timestamp:
- 05/31/05 11:53:09 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mfileio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfileio/MReadReports.cc
r6499 r7115 165 165 // To be done: A flag(?) telling whether the headers can be skipped. 166 166 // 167 void MReadReports::AddTree(const char *tree, const char *time, Bool_t master)167 void MReadReports::AddTree(const char *tree, const char *time, Type_t master) 168 168 { 169 169 /* … … 176 176 */ 177 177 178 if (master && TestBit(kHasMaster))178 if (master==kMaster && TestBit(kHasMaster)) 179 179 { 180 180 *fLog << warn << GetDescriptor() << " already has a master tree... ignored." << endl; 181 master = k FALSE;182 } 183 184 MReadTree *t = master ? new MReadMarsFile(tree) : new MReadTree(tree);181 master = kStandard; 182 } 183 184 MReadTree *t = master==kMaster ? new MReadMarsFile(tree) : new MReadTree(tree); 185 185 t->SetName(tree); 186 186 t->SetTitle(time?time:""); 187 if (master )187 if (master==kMaster) 188 188 SetBit(kHasMaster); 189 if (master==kRequired) 190 t->SetBit(kIsRequired); 189 191 190 192 if (!fEnableAutoScheme) … … 219 221 220 222 return n; 223 } 224 225 // -------------------------------------------------------------------------- 226 // 227 // Count the number of required trees and store the number if fNumRequired. 228 // Reset the kIsProcessed bit. 229 // 230 void MReadReports::ForceRequired() 231 { 232 fNumRequired = 0; 233 234 TIter Next(fTrees->GetList()); 235 TObject *o=0; 236 while ((o=Next())) 237 if (o->TestBit(kIsRequired)) 238 { 239 o->ResetBit(kIsProcessed); 240 fNumRequired++; 241 } 242 243 *fLog << dbg << "Number of required trees: " << fNumRequired << endl; 221 244 } 222 245 … … 297 320 fPosEntry.Set(i); 298 321 322 // Force that with the next call to Process the required events are read 323 ForceRequired(); 324 //fFirstReInit=kTRUE; 325 326 // Preprocess all tasks in fTrees 299 327 return fTrees->CallPreProcess(plist); 328 } 329 330 // -------------------------------------------------------------------------- 331 // 332 // If this is not the first ReInit after PreProcess force the required 333 // trees to be read first (call FirstRequired()) 334 // 335 /* 336 Bool_t MReadReports::ReInit(MParList *plist) 337 { 338 if (!fFirstReInit) 339 ForceRequired(); 340 fFirstReInit=kFALSE; 341 return kTRUE; 342 } 343 */ 344 345 // -------------------------------------------------------------------------- 346 // 347 // Return the number of the tree which is the next one to be read. 348 // The condition for this decision is the time-stamp. 349 // 350 Int_t MReadReports::FindNextTime() 351 { 352 TIter NextC(fChains); 353 TChain *c=0; 354 355 Int_t nmin=0; 356 MTime tmin(**GetTime((TChain*)NextC())); 357 358 Int_t i=0; 359 360 while ((c=(TChain*)NextC())) 361 { 362 MTime &t = **GetTime(c); 363 i++; 364 365 if (t >= tmin) 366 continue; 367 368 tmin = t; 369 nmin = i; 370 } 371 return nmin; 372 } 373 374 // -------------------------------------------------------------------------- 375 // 376 // Return the number of the tree which is the next one to be read. 377 // The condition for this decision kIsRequired but not kIsProcessed is set. 378 // 379 Int_t MReadReports::FindNextRequired() 380 { 381 Int_t n = 0; 382 383 TIter Next(fTrees->GetList()); 384 TObject *o=0; 385 while ((o=Next())) 386 { 387 if (o->TestBit(kIsRequired) && !o->TestBit(kIsProcessed)) 388 { 389 o->SetBit(kIsProcessed); 390 fNumRequired--; 391 *fLog << dbg << "Reading from tree " << n << " " << o->GetName() << endl; 392 return n; 393 } 394 n++; 395 } 396 397 return -1; 300 398 } 301 399 … … 312 410 // -------------------------------------------------------------------------- 313 411 // 314 // Do not use if fChains->GetSize()==0 !!!315 //316 Int_t MReadReports::FindNextTime()317 {318 Int_t i=0;319 320 TIter NextC(fChains);321 TChain *c=0;322 323 Int_t nmin=0;324 MTime tmin(**GetTime((TChain*)NextC()));325 326 while ((c=(TChain*)NextC()))327 {328 MTime &t = **GetTime(c);329 i++;330 331 if (t >= tmin)332 continue;333 334 tmin = t;335 nmin = i;336 }337 return nmin;338 }339 340 /*341 Bool_t MReadReports::Notify()342 {343 Bool_t same = kTRUE;344 for (int i=1; i<fPosTree.GetSize(); i++)345 if (fPosTree[i]!=fPosTree[0])346 {347 same = kFALSE;348 break;349 }350 351 Int_t tn = chain->GetTreeNumber();352 353 Bool_t read=kFALSE;354 if (fPosTree[nmin] != tn)355 {356 fPosTree[nmin] = tn;357 read = kTRUE;358 }359 360 if (!same || !read)361 return kTRUE;362 363 364 *fLog << dbg << "Read Run Headers!" << endl;365 366 return kTRUE;367 }368 */369 370 // --------------------------------------------------------------------------371 //372 412 // Check which is the next tree to read from. Read an event from this tree. 373 413 // Sets the StreamId accordingly. … … 377 417 while (fChains->GetSize()) 378 418 { 379 const Int_t nmin=FindNextTime(); 419 const Int_t nmin=FindNext(); 420 if (nmin<0) 421 { 422 *fLog << err << "MReadReports::Process: ERROR - Determination of next tree failed... abort." << endl; 423 return kERROR; 424 } 380 425 381 426 TChain *chain = (TChain*)fChains->At(nmin); -
trunk/MagicSoft/Mars/mfileio/MReadReports.h
r6499 r7115 17 17 class MReadReports : public MRead 18 18 { 19 public: 20 enum Type_t { 21 kStandard, 22 kMaster, 23 kRequired 24 }; 25 19 26 private: 20 27 MTaskList *fTrees; // Hold the trees which are scheduled for reading … … 25 32 26 33 Bool_t fEnableAutoScheme; 34 Int_t fNumRequired; 35 //Bool_t fFirstReInit; 27 36 37 void ForceRequired(); 28 38 MTime** GetTime(TChain *c) const; 29 39 Int_t FindNextTime(); 40 Int_t FindNextRequired(); 41 Int_t FindNext() { return fNumRequired==0 ? FindNextTime() : FindNextRequired(); } 30 42 31 43 UInt_t GetEntries(); 32 44 TString GetFullFileName() const; 33 45 46 //Bool_t ReInit(MParList *plist); 34 47 Int_t PreProcess(MParList *plist); 35 48 Int_t Process(); … … 37 50 38 51 enum { 39 kHasMaster = BIT(14) 52 kHasMaster = BIT(14), 53 kIsRequired = BIT(22), 54 kIsProcessed = BIT(23) 40 55 }; 41 56 … … 44 59 ~MReadReports(); 45 60 46 void AddTree(const char *tree, const char *time=NULL, Bool_t master=kFALSE);47 void AddTree(const char *tree, Bool_t master)61 void AddTree(const char *tree, const char *time=NULL, Type_t master=kStandard); 62 void AddTree(const char *tree, Type_t master) 48 63 { 49 64 AddTree(tree, NULL, master); -
trunk/MagicSoft/Mars/mfileio/MReadTree.h
r6499 r7115 31 31 32 32 enum { kChainWasChanged = BIT(14) }; 33 // MReadReports::kIsRequired = BIT(22) 34 // MReadReports::kIsProcessed = BIT(23) 33 35 34 36 private: … … 47 49 48 50 enum { kIsOwner = BIT(14) }; 51 // MReadReports::kIsRequired = BIT(22) 52 // MReadReports::kIsProcessed = BIT(23) 49 53 50 54 public:
Note:
See TracChangeset
for help on using the changeset viewer.