Changeset 1114
- Timestamp:
- 12/14/01 15:17:09 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1108 r1114 1 1 -*-*- END -*-*- 2 3 2001/12/14: Thomas Bretz 4 5 * mbase/MReadMarsFile.[h,cc], mbase/MReadFild.[h,cc]: 6 - corrected handling of ReInit/Notify (at the moment I assume 7 one run per file) 8 - made sure, that we don't get memory leaks when using MReadTree 9 more than once because the pointer to the pointer isn't deleted. 10 - added a small class MChain which enhances TChain by a function to 11 reset fTree. This is used to control when notification are 12 happening 13 14 * mbase/MTask.cc: 15 - reset the number of executions before the preprocessing 16 17 2 18 3 19 2001/12/11: Thomas Bretz -
trunk/MagicSoft/Mars/mbase/MReadMarsFile.cc
r1100 r1114 37 37 38 38 #include "MLog.h" 39 #include "MLogManip.h" 40 41 #include "MParList.h" 42 #include "MTaskList.h" 39 43 40 44 ClassImp(MReadMarsFile); … … 56 60 // 57 61 fRun = new MReadTree("RunHeaders", fname); 62 63 // 64 // This disables the auto scheme. because reading new runheader is done 65 // at a low frequency we don't loose time if we always read all 66 // runheaders 67 // 58 68 fRun->DisableAutoScheme(); 59 69 } … … 98 108 Bool_t MReadMarsFile::Notify() 99 109 { 100 if (GetEventNum() == 0) 101 return kTRUE; 110 // 111 // Try to read the new run headers. If reading the new run header 112 // was successfull call the ReInits 113 // 114 if (fRun->Process()) 115 { 116 *fLog << inf << "MReadMarsFile: Switching to '" << GetFileName() << "' "; 117 *fLog << "(before processing event #" << GetEventNum()-1 << ")" << endl; 102 118 103 *fLog << "MReadMarsFile: Switching to next file '" << GetFileName() << "' ";104 *fLog << "(before Event #" << GetEventNum()-1 << ")" << endl;105 fRun->Process();106 107 MReadTree::Notify();119 fTaskList->ReInit(); 120 //MReadTree::Notify(); 121 } 122 else 123 *fLog << warn << "Warning: Cannot read new runheaders after reading event #" << GetEventNum() << endl; 108 124 109 125 return kTRUE; … … 117 133 Bool_t MReadMarsFile::PreProcess(MParList *pList) 118 134 { 135 fTaskList = (MTaskList*)pList->FindObject("MTaskList"); 136 119 137 if (!fRun->PreProcess(pList)) 120 return kFALSE;121 122 if (!fRun->Process())123 138 return kFALSE; 124 139 125 140 return MReadTree::PreProcess(pList); 126 141 } 127 -
trunk/MagicSoft/Mars/mbase/MReadMarsFile.h
r1035 r1114 6 6 #endif 7 7 8 class MTaskList; 9 8 10 class MReadMarsFile : public MReadTree 9 11 { 10 12 private: 11 13 MReadTree *fRun; 14 MTaskList *fTaskList; //! Tasklist for reinitialization 12 15 13 16 Bool_t Notify(); -
trunk/MagicSoft/Mars/mbase/MReadTree.cc
r1108 r1114 69 69 ClassImp(MReadTree); 70 70 71 class MChain : public TChain 72 { 73 public: 74 MChain() : TChain() {} 75 MChain(const char *name, const char *title="") : TChain(name, title) {} 76 77 void ResetTree() { fTree = 0; } 78 }; 79 71 80 // -------------------------------------------------------------------------- 72 81 // … … 95 104 // open the input stream 96 105 // 97 fChain = new TChain(tname); 98 fChain->SetNotify(this); 106 fChain = new MChain(tname); 99 107 100 108 // root 3.02: … … 149 157 Bool_t MReadTree::Notify() 150 158 { 151 // 152 // FIXME: This is correct! 153 // 154 // fNotify->ForEach(TObject, Notify)(); 155 156 fTaskList->ReInit(); 159 *fLog << inf << "MReadTree: Notify '" << fChain->GetName() << "' "; 160 *fLog << "(before processing event #" << GetEventNum()-1 << ")" << endl; 161 162 //fNotify->Notify(); 157 163 158 164 return kTRUE; … … 347 353 Bool_t MReadTree::PreProcess(MParList *pList) 348 354 { 349 fTaskList = (MTaskList*)pList->FindObject("MTaskList"); 355 // 356 // Make sure, that all the following calls doesn't result in 357 // Notifications. This may be dangerous, because the notified 358 // tasks are not preprocessed. 359 // 360 fChain->SetNotify(NULL); 350 361 351 362 // … … 365 376 *fLog << inf << fNumEntries << " entries found in file(s)." << endl; 366 377 378 *fLog << all << fChain->GetListOfBranches() << endl; 379 367 380 // 368 381 // Get all branches of this tree and … … 373 386 374 387 Int_t num=0; 388 389 390 *fLog << "Start..." << endl; 375 391 // 376 392 // loop over all tasks for processing … … 382 398 // 383 399 const char *bname = branch->GetName(); 400 401 *fLog << all << bname << endl; 384 402 385 403 TString oname(bname); … … 398 416 } 399 417 418 MParContainer *obj = pList->FindCreateObj(oname); 419 420 if (!obj) 421 { 422 // 423 // if class is not existing in the (root) environment 424 // we cannot proceed reading this branch 425 // 426 *fLog << warn << dbginf << "Warning: Class '" << oname << "' not existing in dictionary. Branch skipped." << endl; 427 DisableSubBranches(branch); 428 continue; 429 } 430 400 431 // 401 432 // Create a pointer to the pointer to the object in which the … … 403 434 // object and we get the pointers from there to delete it. 404 435 // 405 MParContainer **pcont 436 MParContainer **pcont= new MParContainer*; 406 437 407 438 // … … 422 453 423 454 // 455 // Check whether a Pointer to a pointer already exists, if 456 // we created one already delete it. 457 // 458 TChainElement *element = (TChainElement*)fChain->GetStatus()->FindObject(bname); 459 if (element) 460 delete (MParContainer**)element->GetBaddress(); 461 462 // 424 463 // here pcont is a pointer the to container in which the data from 425 464 // the actual branch should be stored - enable branch. … … 447 486 if (fProgress) 448 487 fProgress->SetRange(0, fNumEntries); 488 489 // 490 // Now we can start notifying. Reset tree makes sure, that TChain thinks 491 // that the correct file is not yet initialized and reinitilizes it 492 // as soon as the first event is read. This is necessary to call 493 // the notifiers when the first event is read, but after the 494 // PreProcess-function. 495 // 496 fChain->ResetTree(); 497 fChain->SetNotify(this); 449 498 450 499 return kTRUE; … … 501 550 Bool_t MReadTree::Process() 502 551 { 552 // 553 // This is necessary due to a bug in TCHain::LoadTree in root. 554 // 555 if (fNumEntry >= fNumEntries) 556 return kFALSE; 557 503 558 Bool_t rc = fChain->GetEntry(fNumEntry++) != 0; 504 559 -
trunk/MagicSoft/Mars/mbase/MReadTree.h
r1108 r1114 6 6 #endif 7 7 8 class TChain;8 class MChain; 9 9 class TBranch; 10 class MTaskList;11 10 class TGProgressBar; 12 11 … … 14 13 { 15 14 private: 16 TChain *fChain; // Pointer to tree15 MChain *fChain; // Pointer to tree 17 16 18 UInt_t fNumEntry; // Number of actual entry 19 UInt_t fNumEntries; // Number of Events in Tree17 UInt_t fNumEntry; // Number of actual entry in chain 18 UInt_t fNumEntries; // Number of Events in chain 20 19 21 20 Bool_t fBranchChoosing; // Flag for branch choosing method … … 25 24 TList *fNotify; // List of TObjects to notify when switching files 26 25 27 MTaskList *fTaskList; //! Tasklist for reinitialization 26 private: 28 27 TGProgressBar *fProgress; //! Possible display of status 29 28 -
trunk/MagicSoft/Mars/mbase/MTask.cc
r1108 r1114 134 134 Bool_t MTask::CallPreProcess(MParList *plist) 135 135 { 136 fNumExecutions = 0; 137 136 138 if (!PreProcess(plist)) 137 139 return kFALSE;
Note:
See TracChangeset
for help on using the changeset viewer.