Changeset 1030 for trunk/MagicSoft/Mars/mbase/MReadTree.cc
- Timestamp:
- 11/05/01 10:35:36 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note:
See TracChangeset
for help on using the changeset viewer.