@@ -26,11 +26,14 @@ namespace edm {
2626 return branch;
2727 }
2828
29- std::unique_ptr<RootDelayedReaderBase> makeRootDelayedReader (
30- RootTree const & tree, std::shared_ptr<InputFile> filePtr, InputType inputType, unsigned int nIndexes, bool promptRead) {
31- if (promptRead) {
32- return std::make_unique<RootPromptReadDelayedReader>(tree, filePtr, inputType, nIndexes);
33- }
29+ std::unique_ptr<RootDelayedReaderBase> makeRootDelayedReader (RootTree const & tree,
30+ std::shared_ptr<InputFile> filePtr,
31+ InputType inputType,
32+ unsigned int nIndexes,
33+ bool promptRead) {
34+ if (promptRead) {
35+ return std::make_unique<RootPromptReadDelayedReader>(tree, filePtr, inputType, nIndexes);
36+ }
3437 return std::make_unique<RootDelayedReader>(tree, filePtr, inputType);
3538 }
3639 } // namespace
@@ -50,6 +53,7 @@ namespace edm {
5053 learningEntries_(learningEntries),
5154 enablePrefetching_(enablePrefetching),
5255 enableTriggerCache_(branchType_ == InEvent),
56+ promptRead_(promptRead),
5357 rootDelayedReader_(makeRootDelayedReader(*this , filePtr, inputType, nIndexes, promptRead)) {}
5458
5559 // Used for Event/Lumi/Run RootTrees
@@ -59,7 +63,8 @@ namespace edm {
5963 Options const & options,
6064 unsigned int learningEntries,
6165 InputType inputType)
62- : RootTree(filePtr, branchType, nIndexes, learningEntries, options.enablePrefetching, options.promptReading, inputType) {
66+ : RootTree(
67+ filePtr, branchType, nIndexes, learningEntries, options.enablePrefetching, options.promptReading, inputType) {
6368 init (BranchTypeToProductTreeName (branchType), options.treeMaxVirtualSize , options.treeCacheSize );
6469 metaTree_ = dynamic_cast <TTree*>(filePtr_->Get (BranchTypeToMetaDataTreeName (branchType).c_str ()));
6570 auxBranch_ = getAuxiliaryBranch (tree_, branchType_);
@@ -77,7 +82,8 @@ namespace edm {
7782 Options const & options,
7883 unsigned int learningEntries,
7984 InputType inputType)
80- : RootTree(filePtr, branchType, nIndexes, learningEntries, options.enablePrefetching, options.promptReading, inputType) {
85+ : RootTree(
86+ filePtr, branchType, nIndexes, learningEntries, options.enablePrefetching, options.promptReading, inputType) {
8187 processName_ = processName;
8288 init (BranchTypeToProductTreeName (branchType, processName), options.treeMaxVirtualSize , options.treeCacheSize );
8389 }
@@ -285,7 +291,8 @@ namespace edm {
285291 triggerSet_.clear ();
286292 rawTriggerSwitchOverEntry_ = -1 ;
287293 }
288- if (treeCache_ && treeCache_->IsLearning () && switchOverEntry_ >= 0 && entryNumber_ >= switchOverEntry_) {
294+ if (not promptRead_ && treeCache_ && treeCache_->IsLearning () && switchOverEntry_ >= 0 &&
295+ entryNumber_ >= switchOverEntry_) {
289296 stopTraining ();
290297 }
291298 }
@@ -385,6 +392,9 @@ namespace edm {
385392
386393 inline TTreeCache* RootTree::selectCache (TBranch* branch, EntryNumber entryNumber) const {
387394 TTreeCache* triggerCache = nullptr ;
395+ if (promptRead_) {
396+ return rawTreeCache_.get ();
397+ }
388398 if (!treeCache_) {
389399 return nullptr ;
390400 } else if (treeCache_->IsLearning () && rawTreeCache_) {
@@ -404,14 +414,11 @@ namespace edm {
404414 void RootTree::getEntryForAllBranches () const {
405415 filePtr_->SetCacheRead (rawTreeCache_.get ());
406416 auto ptr = filePtr_.get ();
407- auto cleanup = [ptr](TTreeCache* cache) {
408- ptr->SetCacheRead (nullptr );
409- };
417+ auto cleanup = [ptr](TTreeCache* cache) { ptr->SetCacheRead (nullptr ); };
410418 std::unique_ptr<TTreeCache, decltype (cleanup)> cacheGuard (rawTreeCache_.get (), cleanup);
411419 tree_->GetEntry (entryNumber_);
412420 }
413421
414-
415422 void RootTree::getEntry (TBranch* branch, EntryNumber entryNumber) const {
416423 try {
417424 TTreeCache* cache = selectCache (branch, entryNumber);
@@ -468,7 +475,11 @@ namespace edm {
468475 rawTreeCache_->SetEnablePrefetching (false );
469476 filePtr_->SetCacheRead (nullptr );
470477 rawTreeCache_->SetLearnEntries (0 );
471- switchOverEntry_ = entryNumber_ + learningEntries_;
478+ if (promptRead_) {
479+ switchOverEntry_ = entries_;
480+ } else {
481+ switchOverEntry_ = entryNumber_ + learningEntries_;
482+ }
472483 auto rawStart = entryNumber_;
473484 auto rawEnd = switchOverEntry_;
474485 auto treeStart = switchOverEntry_;
0 commit comments