Changeset 1080 for trunk/MagicSoft/Mars/mbase/MReadTree.cc
- Timestamp:
- 11/15/01 11:07:21 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MReadTree.cc
r1051 r1080 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de> 19 19 ! 20 20 ! Copyright: MAGIC Software Development, 2000-2001 … … 63 63 64 64 #include "MTime.h" 65 #include "MFilter.h" 65 66 #include "MParList.h" 66 67 #include "MTaskList.h" … … 86 87 fTitle = title ? title : "Task to loop over all events in one single tree"; 87 88 88 fVetoList = new T OrdCollection;89 fVetoList = new TList; 89 90 fVetoList->SetOwner(); 90 91 91 fNotify = new T OrdCollection;92 fNotify = new TList; 92 93 93 94 // … … 96 97 fChain = new TChain(tname); 97 98 fChain->SetNotify(this); 99 100 // root 3.02: 101 // In TChain::Addfile remove the limitation that the file name must contain 102 // the string ".root". ".root" is necessary only in case one wants to specify 103 // a Tree in a subdirectory of a Root file with eg, the format: 98 104 99 105 if (fname) … … 183 189 return; 184 190 185 *fLog << "Branch choosing method enabled (only enabled branches are read)." << endl;191 *fLog << inf << "Branch choosing method enabled (only enabled branches are read)." << endl; 186 192 fChain->SetBranchStatus("*", kFALSE); 187 193 fBranchChoosing = kTRUE; … … 223 229 // 224 230 fChain->SetBranchStatus(name, status); 225 *fLog << (status ? "Enabled" : "Disabled");231 *fLog << inf << (status ? "Enabled" : "Disabled"); 226 232 *fLog << " subbranch '" << name << "'." << endl; 227 233 } … … 231 237 // Set the status of all branches in the list to status. 232 238 // 233 void MReadTree::SetBranchStatus(const T OrdCollection*list, Bool_t status)239 void MReadTree::SetBranchStatus(const TList *list, Bool_t status) 234 240 { 235 241 // … … 247 253 // This is the implementation of the Auto Enabling Scheme. 248 254 // For more information see MTask::AddBranchToList. 249 // This function loops over all tasks in the tasklist and enables 250 // all branches which are requested by the tasks. 251 // 252 // To enable 'unknown' branches which are not in the Branchlist of 255 // This function loops over all tasks and its filters in the tasklist 256 // and enables all branches which are requested by the tasks and its 257 // filters. 258 // 259 // To enable 'unknown' branches which are not in the branchlist of 253 260 // the tasks you can call EnableBranch 254 261 // … … 267 274 if (!tlist) 268 275 { 269 *fLog << "Cannot use auto enabeling scheme for branches. 'MTaskList' not found." << endl;276 *fLog << warn << "Cannot use auto enabeling scheme for branches. 'MTaskList' not found." << endl; 270 277 return; 271 278 } 272 279 273 280 // 274 // Loop over all tasks i n the task list.281 // Loop over all tasks iand its filters n the task list. 275 282 // 276 283 MTask *task; 277 284 TIter NextTask(tlist->GetList()); 278 285 while ((task=(MTask*)NextTask())) 286 { 279 287 SetBranchStatus(task->GetListOfBranches(), kTRUE); 288 const MFilter *filter = task->GetFilter(); 289 290 if (filter) 291 SetBranchStatus(filter->GetListOfBranches(), kTRUE); 292 293 } 280 294 } 281 295 … … 317 331 if (!fNumEntries) 318 332 { 319 *fLog << dbginf << "No entries found in file(s)." << endl;333 *fLog << warn << dbginf << "No entries found in file(s)." << endl; 320 334 return kFALSE; 321 335 } … … 324 338 // output logging information 325 339 // 326 *fLog << fNumEntries << " entries found in file(s)." << endl;340 *fLog << inf << fNumEntries << " entries found in file(s)." << endl; 327 341 328 342 // … … 354 368 if (fVetoList->FindObject(oname)) 355 369 { 356 *fLog << "Master branch " << bname << " has veto... skipped." << endl;370 *fLog << inf << "Master branch " << bname << " has veto... skipped." << endl; 357 371 DisableSubBranches(branch); 358 372 continue; … … 377 391 // we cannot proceed reading this branch 378 392 // 379 *fLog << dbginf << "Warning: Class '" << oname << "' not existing in dictionary. Branch skipped." << endl;393 *fLog << warn << dbginf << "Warning: Class '" << oname << "' not existing in dictionary. Branch skipped." << endl; 380 394 DisableSubBranches(branch); 381 395 continue; … … 387 401 // 388 402 fChain->SetBranchAddress(bname, pcont); 389 *fLog << "Master branch address " << bname << " setup for reading." << endl;403 *fLog << inf << "Master branch address " << bname << " setup for reading." << endl; 390 404 391 405 //*fLog << "Branch " << bname << " autodel: " << (int)branch->IsAutoDelete() << endl; … … 395 409 } 396 410 397 *fLog << "MReadTree setup " << num << " master branches addresses." << endl;411 *fLog << inf << "MReadTree setup " << num << " master branches addresses." << endl; 398 412 399 413 // … … 410 424 411 425 return kTRUE; 426 } 427 428 // -------------------------------------------------------------------------- 429 // 430 // Set the ready to save flag of all containers which branchaddresses are 431 // set for. This is necessary to copy data. 432 // 433 void MReadTree::SetReadyToSave(Bool_t flag) 434 { 435 TIter Next(fChain->GetStatus()); 436 437 TChainElement *element = NULL; 438 while ((element=(TChainElement*)Next())) 439 { 440 // 441 // Check whether the branch is enabled 442 // 443 if (!element->GetStatus()) 444 continue; 445 446 // 447 // Get the pointer to the pointer of the corresponding container 448 // 449 MParContainer **pcont = (MParContainer**)element->GetBaddress(); 450 451 // 452 // Check whether the pointer is not NULL 453 // 454 if (!pcont || !*pcont) 455 continue; 456 457 // 458 // Set the ready to save status of the container. 459 // 460 (*pcont)->SetReadyToSave(flag); 461 } 462 463 // 464 // Set the ready to save status of this task (used?), too 465 // 466 MTask::SetReadyToSave(flag); 412 467 } 413 468 … … 421 476 Bool_t MReadTree::Process() 422 477 { 478 SetReadyToSave(); 423 479 return fChain->GetEntry(fNumEntry++) != 0; 424 480 } … … 430 486 Bool_t MReadTree::GetEvent() 431 487 { 488 SetReadyToSave(); 432 489 return fChain->GetEntry(fNumEntry) != 0; 433 490 } … … 442 499 if (fNumEntry-dec >= fNumEntries) 443 500 { 444 *fLog << "MReadTree::DecEventNum: WARNING - Event " << fNumEntry << "-";501 *fLog << warn << "MReadTree::DecEventNum: WARNING - Event " << fNumEntry << "-"; 445 502 *fLog << dec << "=" << (Int_t)fNumEntry-dec << " out of Range." << endl; 446 503 return kFALSE; … … 460 517 if (fNumEntry+inc >= fNumEntries) 461 518 { 462 *fLog << "MReadTree::IncEventNum: WARNING - Event " << fNumEntry << "+";519 *fLog << warn << "MReadTree::IncEventNum: WARNING - Event " << fNumEntry << "+"; 463 520 *fLog << inc << "=" << (Int_t)fNumEntry+inc << " out of Range." << endl; 464 521 return kFALSE; … … 480 537 if (nr >= fNumEntries) 481 538 { 482 *fLog << "MReadTree::SetEventNum: WARNING - " << nr << " out of Range." << endl;539 *fLog << warn << "MReadTree::SetEventNum: WARNING - " << nr << " out of Range." << endl; 483 540 return kFALSE; 484 541 } … … 522 579 fNotify->Add(obj); 523 580 } 581 582 void MReadTree::Print(Option_t *o) const 583 { 584 *fLog << all << GetDescriptor() << dec << endl; 585 *fLog << setfill('-') << setw(strlen(GetDescriptor())) << "" << endl; 586 *fLog << " Files:" << endl; 587 588 int i = 0; 589 TIter Next(fChain->GetListOfFiles()); 590 TObject *obj = NULL; 591 while ((obj=Next())) 592 *fLog << " " << i++ << ") " << obj->GetName() << endl; 593 594 *fLog << " Entries: " << fNumEntries << endl; 595 *fLog << " Next Entry: " << fNumEntry << endl; 596 }
Note:
See TracChangeset
for help on using the changeset viewer.