Changeset 1030 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 11/05/01 10:35:36 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r1003 r1030 87 87 { 88 88 89 MParContainer *named = (MParContainer*)TObject::Clone( newname);89 MParContainer *named = (MParContainer*)TObject::Clone(); 90 90 if (newname && strlen(newname)) named->SetName(newname); 91 91 return named; -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r1014 r1030 98 98 MParContainer(const MParContainer &named); 99 99 MParContainer& operator=(const MParContainer& rhs); 100 virtual ~MParContainer() {} 100 101 101 void SetLogStream(MLog *lg) { fLog = lg; } 102 virtual TObject *Clone(const char *newname="") const; 103 virtual Int_t Compare(const TObject *obj) const; 104 virtual void Copy(TObject &named); 105 virtual void FillBuffer(char *&buffer); 102 106 103 virtual TObject *Clone(const char *newname="") const; 104 virtual Int_t Compare(const TObject *obj) const; 105 virtual void Copy(TObject &named); 106 virtual void FillBuffer(char *&buffer); 107 virtual const char *GetName() const { return fName.Data(); } 108 virtual const char *GetTitle() const { return fTitle.Data(); } 109 virtual ULong_t Hash() { return fName.Hash(); } 110 virtual Bool_t IsSortable() const { return kTRUE; } 111 virtual void SetName(const char *name); // *MENU* 112 virtual void SetObject(const char *name, const char *title); 113 virtual void SetTitle(const char *title=""); // *MENU* 114 virtual void ls(Option_t *option="") const; 115 virtual void Print(Option_t *option="") const; 116 virtual Int_t Sizeof() const; 107 virtual const char *GetName() const { return fName.Data(); } 108 virtual const char *GetTitle() const { return fTitle.Data(); } 109 virtual ULong_t Hash() { return fName.Hash(); } 110 virtual Bool_t IsSortable() const { return kTRUE; } 117 111 118 virtual void Reset() { } 112 virtual void SetName(const char *name); // *MENU* 113 virtual void SetObject(const char *name, const char *title); 114 virtual void SetTitle(const char *title=""); // *MENU* 115 virtual void ls(Option_t *option="") const; 116 virtual void Print(Option_t *option="") const; 117 virtual Int_t Sizeof() const; 119 118 119 virtual void SetLogStream(MLog *lg) { fLog = lg; } 120 virtual void Reset() { } 120 121 virtual Bool_t IsReadyToSave() { return fReadyToSave; } 121 122 virtual void SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; } -
trunk/MagicSoft/Mars/mbase/MParList.h
r1014 r1030 24 24 { 25 25 private: 26 TOrdCollection *fContainer; // Collection of Parameter and Data Containers26 TOrdCollection *fContainer; // Collection of Parameter and Data Containers 27 27 TOrdCollection *fAutodelete; // All what this list contains is deleted in the destructor 28 28 … … 36 36 MParList(MParList &ts); 37 37 38 ~MParList();38 virtual ~MParList(); 39 39 40 40 Bool_t AddToList(MParContainer *obj, MParContainer *where = NULL); -
trunk/MagicSoft/Mars/mbase/MReadTree.cc
r1020 r1030 78 78 MReadTree::MReadTree(const char *tname, const char *fname, 79 79 const char *name, const char *title) 80 : fNumEntry(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE) 80 : fNumEntry(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE), fProgress(NULL) 81 81 { 82 82 fName = name ? name : "MReadTree"; … … 165 165 // -------------------------------------------------------------------------- 166 166 // 167 // This is the implementation of the Auto Enabling Scheme. 168 // For more information see MTask::AddBranchToList. 169 // This function loops over all tasks in the tasklist and enables 170 // all branches which are requested by the tasks. 171 // 172 // To enable 'unknown' branches which are not in the Branchlist of 173 // the tasks you can call EnableBranch 167 // Checks whether a branch with the given name exists in the chain 168 // and sets the branch status of this branch corresponding to status. 169 // 170 void MReadTree::SetBranchStatus(TObject *branch, Bool_t status) 171 { 172 // 173 // Get branch name 174 // 175 const char *name = branch->GetName(); 176 177 // 178 // Check whether this branch really exists 179 // 180 if (!fChain->GetBranch(name)) 181 return; 182 183 // 184 // Set the branch status 185 // 186 fChain->SetBranchStatus(name, status); 187 *fLog << (status ? "Enabled" : "Disabled"); 188 *fLog << " subbranch '" << name << "'." << endl; 189 } 190 191 // -------------------------------------------------------------------------- 192 // 193 // Set the status of all branches in the list to status. 194 // 195 void MReadTree::SetBranchStatus(const TOrdCollection *list, Bool_t status) 196 { 197 // 198 // Loop over all subbranches in this master branch 199 // 200 TIter Next(list); 201 202 TObject *obj; 203 while ((obj=Next())) 204 SetBranchStatus(obj, status); 205 } 206 207 // -------------------------------------------------------------------------- 208 // 209 // This is the implementation of the Auto Enabling Scheme. 210 // For more information see MTask::AddBranchToList. 211 // This function loops over all tasks in the tasklist and enables 212 // all branches which are requested by the tasks. 213 // 214 // To enable 'unknown' branches which are not in the Branchlist of 215 // the tasks you can call EnableBranch 174 216 // 175 217 void MReadTree::EnableBranches(MParList *plist) 176 218 { 177 //178 // if auto enabling is off reject the request179 //180 if (!fAutoEnable)181 return;182 183 219 // 184 220 // check whether branch choosing must be switched on … … 198 234 199 235 // 200 // Loo over all tasks in the task list.236 // Loop over all tasks in the task list. 201 237 // 202 238 MTask *task; 203 239 TIter NextTask(tlist->GetList()); 204 240 while ((task=(MTask*)NextTask())) 205 { 206 // 207 // Loop over all branches of this task 208 // 209 TNamed *branch; 210 TIter NextBranch(task->GetListOfBranches()); 211 while ((branch=(TNamed*)NextBranch())) 212 { 213 // 214 // Get branch name to enable and enable the branch 215 // 216 const char *name = branch->GetName(); 217 218 *fLog << "Enabeling '" << name << "'." << endl; 219 220 fChain->SetBranchStatus(name, kTRUE); 221 } 222 } 241 SetBranchStatus(task->GetListOfBranches(), kTRUE); 242 } 243 244 // -------------------------------------------------------------------------- 245 // 246 // The disables all subbranches of the given master branch. 247 // 248 void MReadTree::DisableSubBranches(TBranch *branch) 249 { 250 // 251 // This is not necessary, it would work without. But the output 252 // may confuse the user... 253 // 254 if (fAutoEnable || fBranchChoosing) 255 return; 256 257 SetBranchStatus(branch->GetListOfBranches(), kFALSE); 223 258 } 224 259 … … 244 279 if (!fNumEntries) 245 280 { 246 *fLog << dbginf << "No entries found in chain (file/s)." << endl;281 *fLog << dbginf << "No entries found in file(s)." << endl; 247 282 return kFALSE; 248 283 } … … 276 311 if (fVetoList->FindObject(name)) 277 312 { 278 *fLog << "Branch " << name << " has veto... skipped." << endl; 313 *fLog << "Master branch " << name << " has veto... skipped." << endl; 314 DisableSubBranches(branch); 279 315 continue; 280 316 } … … 299 335 // 300 336 *fLog << dbginf << "Warning: Class '" << name << "' not existing in dictionary. Branch skipped." << endl; 337 DisableSubBranches(branch); 301 338 continue; 302 339 } … … 308 345 fChain->SetBranchAddress(name, pcont); 309 346 310 *fLog << " Branch" << name << " setup for reading." << endl;347 *fLog << "Master branch address " << name << " setup for reading." << endl; 311 348 312 349 num++; 313 350 } 314 351 315 *fLog << "MReadTree setup " << num << " branches." << endl; 316 317 EnableBranches(pList); 318 352 *fLog << "MReadTree setup " << num << " master branches addresses." << endl; 353 354 // 355 // If auto enabling scheme isn't disabled, do auto enabling 356 // 357 if (fAutoEnable) 358 EnableBranches(pList); 359 360 // 361 // If a progress bar is given set its range. 362 // 319 363 if (fProgress) 320 364 fProgress->SetRange(0, fNumEntries); … … 351 395 Bool_t MReadTree::DecEventNum(UInt_t dec) 352 396 { 353 //! 354 //! this function makes Process() read the event one (or more) before 355 //! the actual position (event) in the tree 356 //! 357 if (fNumEntry < dec/*+1*/) 358 { 359 *fLog << "MReadTree::SetPrevEvent: WARNING: " << fNumEntry/*-1*/ << "-" << dec << " out of Range." << endl; 397 if (fNumEntry-dec >= fNumEntries) 398 { 399 *fLog << "MReadTree::DecEventNum: WARNING - Event " << fNumEntry << "-"; 400 *fLog << dec << "=" << (Int_t)fNumEntry-dec << " out of Range." << endl; 360 401 return kFALSE; 361 402 } 362 403 363 fNumEntry -= dec /*+1*/;404 fNumEntry -= dec; 364 405 return kTRUE; 365 406 } … … 372 413 Bool_t MReadTree::IncEventNum(UInt_t inc) 373 414 { 374 //! 375 //! this function makes Process() read the next (or more) after 376 //! the actual position (event) in the tree 377 //! (Be careful: IncEventNum() or IncEventNum(1) does not chenge anything 378 //! in the standard behaviour of the task) 379 //! 380 if (fNumEntry+inc/*-1*/ >= fNumEntries) 381 { 382 *fLog << "MReadTree::SkipEvents: WARNING: " << fNumEntry/*-1*/ << "+" << inc << " out of Range." << endl; 415 if (fNumEntry+inc >= fNumEntries) 416 { 417 *fLog << "MReadTree::IncEventNum: WARNING - Event " << fNumEntry << "+"; 418 *fLog << inc << "=" << (Int_t)fNumEntry+inc << " out of Range." << endl; 383 419 return kFALSE; 384 420 } 385 421 386 fNumEntry += inc /*-1*/;422 fNumEntry += inc; 387 423 return kTRUE; 388 424 } … … 390 426 // -------------------------------------------------------------------------- 391 427 // 392 // this function makes Process() read event number nr next428 // This function makes Process() read event number nr next 393 429 // 394 430 // Remark: You can use this function after instatiating you MReadTree-object … … 397 433 Bool_t MReadTree::SetEventNum(UInt_t nr) 398 434 { 399 if (nr >=fNumEntries)400 { 401 *fLog << "MReadTree::SetEventNum: WARNING :" << nr << " out of Range." << endl;435 if (nr >= fNumEntries) 436 { 437 *fLog << "MReadTree::SetEventNum: WARNING - " << nr << " out of Range." << endl; 402 438 return kFALSE; 403 439 } … … 409 445 // -------------------------------------------------------------------------- 410 446 // 411 // If you don't want that an object is created for this branch 412 // and/or the branch address is set in the Preprocessing of 413 // MReadTree use VetoBranch. This saves mainly memory space. 447 // For the branch with the given name: 448 // 1) no object is automatically created 449 // 2) the branch address for this branch is not set 450 // (because we lack the object, see 1) 451 // 3) The whole branch (exactly: all its subbranches) are disabled 452 // this means are not read in memory by TTree:GetEntry 414 453 // 415 454 void MReadTree::VetoBranch(const char *name) -
trunk/MagicSoft/Mars/mbase/MReadTree.h
r1020 r1030 7 7 8 8 class TChain; 9 class TBranch; 9 10 class TGProgressBar; 10 11 … … 22 23 TOrdCollection *fVetoList; // List of Branches which are not allowed to get enabled 23 24 24 TGProgressBar *fProgress;// Possible display of status25 TGProgressBar *fProgress; // Possible display of status 25 26 27 void SetBranchStatus(const TOrdCollection *list, Bool_t status); 28 void SetBranchStatus(TObject *branch, Bool_t status); 29 30 void DisableSubBranches(TBranch *b); 26 31 void EnableBranches(MParList *plist); 27 32 void EnableBranchChoosing(); 28 33 34 Bool_t PreProcess(MParList *pList); 35 Bool_t Process(); 36 29 37 public: 30 38 MReadTree(const char *treename, const char *filename=NULL, const char *name=NULL, const char *title=NULL); 31 39 ~MReadTree(); 32 40 33 Bool_t PreProcess(MParList *pList); 34 Bool_t Process(); 41 Int_t AddFile(const char *fname); 42 void DisableAutoScheme() { fAutoEnable = kFALSE; } 43 void EnableBranch(const char *name); 44 void VetoBranch(const char *name); 35 45 36 46 void SetProgressBar(TGProgressBar *bar) { fProgress = bar; } 37 38 Int_t AddFile(const char *fname);39 void VetoBranch(const char *name);40 41 void EnableBranch(const char *name);42 47 43 48 Bool_t GetEvent(); … … 50 55 UInt_t GetEntries() const { return fNumEntries; } 51 56 52 void DisableAutoScheme() { fAutoEnable = kFALSE; } 53 54 ClassDef(MReadTree, 0) // Reads one tree 57 ClassDef(MReadTree, 0) // Reads a tree from file(s) 55 58 }; 56 59
Note:
See TracChangeset
for help on using the changeset viewer.