@@ -410,6 +410,23 @@ namespace edm {
410410 return treeCache_.get ();
411411 }
412412 }
413+ TTreeCache* RootTree::getAuxCache (TBranch* auxBranch) const {
414+ if (not auxCache_ and cacheSize_ > 0 ) {
415+ tree_->SetCacheSize (1 * 1024 * 1024 );
416+ auxCache_.reset (dynamic_cast <TTreeCache*>(filePtr_->GetCacheRead (tree_)));
417+ if (auxCache_) {
418+ auxCache_->SetEnablePrefetching (enablePrefetching_);
419+ auxCache_->SetEnablePrefetching (false );
420+ filePtr_->SetCacheRead (nullptr , tree_);
421+ auxCache_->SetLearnEntries (0 );
422+ auxCache_->StartLearningPhase ();
423+ auxCache_->SetEntryRange (0 , tree_->GetEntries ());
424+ auxCache_->AddBranch (auxBranch->GetName (), kTRUE );
425+ auxCache_->StopLearningPhase ();
426+ }
427+ }
428+ return auxCache_.get ();
429+ }
413430
414431 void RootTree::getEntryForAllBranches () const {
415432 filePtr_->SetCacheRead (rawTreeCache_.get (), tree_);
@@ -420,8 +437,11 @@ namespace edm {
420437 }
421438
422439 void RootTree::getEntry (TBranch* branch, EntryNumber entryNumber) const {
440+ getEntryUsingCache (branch, entryNumber, selectCache (branch, entryNumber));
441+ }
442+
443+ inline void RootTree::getEntryUsingCache (TBranch* branch, EntryNumber entryNumber, TTreeCache* cache) const {
423444 try {
424- TTreeCache* cache = selectCache (branch, entryNumber);
425445 filePtr_->SetCacheRead (cache, tree_);
426446 branch->GetEntry (entryNumber);
427447 filePtr_->SetCacheRead (nullptr , tree_);
@@ -529,6 +549,7 @@ namespace edm {
529549 rawTreeCache_.reset ();
530550 triggerTreeCache_.reset ();
531551 rawTriggerTreeCache_.reset ();
552+ auxCache_.reset ();
532553 // We give up our shared ownership of the TFile itself.
533554 filePtr_.reset ();
534555 }
0 commit comments