CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::RootTree Class Reference

#include <RootTree.h>

Public Types

using BranchMap = roottree::BranchMap
 
using EntryNumber = roottree::EntryNumber
 

Public Member Functions

void addBranch (BranchDescription const &prod, std::string const &oldBranchName)
 
TBranch * branchEntryInfoBranch () const
 
BranchMap const & branches () const
 
std::vector< std::string > const & branchNames () const
 
BranchType branchType () const
 
TTreeCache * checkTriggerCache (TBranch *branch, EntryNumber entryNumber) const
 
TTreeCache * checkTriggerCacheImpl (TBranch *branch, EntryNumber entryNumber) const
 
void close ()
 
bool current () const
 
bool current (EntryNumber entry) const
 
void dropBranch (std::string const &oldBranchName)
 
EntryNumber const & entries () const
 
EntryNumber const & entryNumber () const
 
EntryNumber const & entryNumberForIndex (unsigned int index) const
 
template<typename T >
void fillAux (T *&pAux)
 
template<typename T >
void fillBranchEntry (TBranch *branch, T *&pbuf)
 
template<typename T >
void fillBranchEntry (TBranch *branch, EntryNumber entryNumber, T *&pbuf)
 
template<typename T >
void fillBranchEntryMeta (TBranch *branch, EntryNumber entryNumber, T *&pbuf)
 
void getEntry (TBranch *branch, EntryNumber entry) const
 
void init (std::string const &productTreeName, unsigned int maxVirtualSize, unsigned int cacheSize)
 
void insertEntryForIndex (unsigned int index)
 
bool isValid () const
 
TTree const * metaTree () const
 
TTree * metaTree ()
 
bool next ()
 
bool nextWithCache ()
 
void numberOfBranchesToAdd (BranchMap::Map::size_type iSize)
 
RootTreeoperator= (RootTree const &)=delete
 
std::string const & processName () const
 
DelayedReaderresetAndGetRootDelayedReader () const
 
void resetTraining ()
 
void rewind ()
 
void rewindToInvalid ()
 
DelayedReaderrootDelayedReader () const
 
 RootTree (std::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int nIndexes, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
 
 RootTree (std::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int nIndexes, unsigned int maxVirtualSize, unsigned int cacheSize, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
 
 RootTree (std::shared_ptr< InputFile > filePtr, BranchType const &branchType, std::string const &processName, unsigned int nIndexes, unsigned int maxVirtualSize, unsigned int cacheSize, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
 
 RootTree (RootTree const &)=delete
 
TTreeCache * selectCache (TBranch *branch, EntryNumber entryNumber) const
 
void setEntryNumber (EntryNumber theEntryNumber)
 
void setPresence (BranchDescription &prod, std::string const &oldBranchName)
 
void setSignals (signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
 
bool skipEntries (unsigned int &offset)
 
void trainCache (char const *branchNames)
 
TTree const * tree () const
 
TTree * tree ()
 
 ~RootTree ()
 

Private Member Functions

void setCacheSize (unsigned int cacheSize)
 
void setTreeMaxVirtualSize (int treeMaxVirtualSize)
 
void startTraining ()
 
void stopTraining ()
 

Private Attributes

TBranch * auxBranch_ = nullptr
 
TBranch * branchEntryInfoBranch_ = nullptr
 
BranchMap branches_
 
std::vector< std::string > branchNames_
 
BranchType branchType_
 
unsigned int cacheSize_ = 0
 
bool enablePrefetching_
 
bool enableTriggerCache_
 
EntryNumber entries_ = 0
 
EntryNumber entryNumber_ = IndexIntoFile::invalidEntry
 
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
 
std::shared_ptr< InputFilefilePtr_
 
TTree * infoTree_ = nullptr
 
unsigned int learningEntries_
 
TTree * metaTree_ = nullptr
 
bool performedSwitchOver_ = false
 
std::string processName_
 
std::shared_ptr< TTreeCache > rawTreeCache_
 
EntryNumber rawTriggerSwitchOverEntry_ = -1
 
std::shared_ptr< TTreeCache > rawTriggerTreeCache_
 
std::unique_ptr< RootDelayedReaderrootDelayedReader_
 
EntryNumber switchOverEntry_ = -1
 
std::unordered_set< TBranch * > trainedSet_
 
bool trainNow_ = false
 
TTree * tree_ = nullptr
 
unsigned long treeAutoFlush_ = 0
 
std::shared_ptr< TTreeCache > treeCache_
 
std::unordered_set< TBranch * > triggerSet_
 
std::shared_ptr< TTreeCache > triggerTreeCache_
 

Detailed Description

Definition at line 79 of file RootTree.h.

Member Typedef Documentation

◆ BranchMap

Definition at line 81 of file RootTree.h.

◆ EntryNumber

Definition at line 82 of file RootTree.h.

Constructor & Destructor Documentation

◆ RootTree() [1/4]

edm::RootTree::RootTree ( std::shared_ptr< InputFile filePtr,
BranchType const &  branchType,
unsigned int  nIndexes,
unsigned int  learningEntries,
bool  enablePrefetching,
InputType  inputType 
)

Definition at line 30 of file RootTree.cc.

36  : filePtr_(filePtr),
38  entryNumberForIndex_(std::make_unique<std::vector<EntryNumber>>(nIndexes, IndexIntoFile::invalidEntry)),
39  learningEntries_(learningEntries),
40  enablePrefetching_(enablePrefetching),
42  rootDelayedReader_(std::make_unique<RootDelayedReader>(*this, filePtr, inputType)) {}
unsigned int learningEntries_
Definition: RootTree.h:225
bool enablePrefetching_
Definition: RootTree.h:230
std::unique_ptr< RootDelayedReader > rootDelayedReader_
Definition: RootTree.h:232
bool enableTriggerCache_
Definition: RootTree.h:231
static constexpr EntryNumber_t invalidEntry
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
BranchType branchType() const
Definition: RootTree.h:184
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
Definition: RootTree.h:218
BranchType branchType_
Definition: RootTree.h:203

◆ RootTree() [2/4]

edm::RootTree::RootTree ( std::shared_ptr< InputFile filePtr,
BranchType const &  branchType,
unsigned int  nIndexes,
unsigned int  maxVirtualSize,
unsigned int  cacheSize,
unsigned int  learningEntries,
bool  enablePrefetching,
InputType  inputType 
)

Definition at line 45 of file RootTree.cc.

References auxBranch_, branchEntryInfoBranch_, branchType(), branchType_, edm::BranchTypeToInfoTreeName(), edm::BranchTypeToMetaDataTreeName(), edm::BranchTypeToProductTreeName(), filePtr_, infoTree_, init(), metaTree_, and tree_.

53  : RootTree(filePtr, branchType, nIndexes, learningEntries, enablePrefetching, inputType) {
54  init(BranchTypeToProductTreeName(branchType), maxVirtualSize, cacheSize);
55  metaTree_ = dynamic_cast<TTree*>(filePtr_->Get(BranchTypeToMetaDataTreeName(branchType).c_str()));
56  auxBranch_ = getAuxiliaryBranch(tree_, branchType_);
58  metaTree_ ? getProductProvenanceBranch(metaTree_, branchType_) : getProductProvenanceBranch(tree_, branchType_);
59  infoTree_ =
60  dynamic_cast<TTree*>(filePtr->Get(BranchTypeToInfoTreeName(branchType).c_str())); // backward compatibility
61  }
TTree * tree_
Definition: RootTree.h:201
TTree * metaTree_
Definition: RootTree.h:202
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:234
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
Definition: BranchType.cc:105
void init(std::string const &productTreeName, unsigned int maxVirtualSize, unsigned int cacheSize)
Definition: RootTree.cc:78
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
Definition: BranchType.cc:95
TBranch * auxBranch_
Definition: RootTree.h:205
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
std::string const & BranchTypeToInfoTreeName(BranchType const &branchType)
Definition: BranchType.cc:111
RootTree(std::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int nIndexes, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
Definition: RootTree.cc:30
BranchType branchType() const
Definition: RootTree.h:184
BranchType branchType_
Definition: RootTree.h:203
TTree * infoTree_
Definition: RootTree.h:236

◆ RootTree() [3/4]

edm::RootTree::RootTree ( std::shared_ptr< InputFile filePtr,
BranchType const &  branchType,
std::string const &  processName,
unsigned int  nIndexes,
unsigned int  maxVirtualSize,
unsigned int  cacheSize,
unsigned int  learningEntries,
bool  enablePrefetching,
InputType  inputType 
)

Definition at line 64 of file RootTree.cc.

References branchType(), edm::BranchTypeToProductTreeName(), init(), processName(), and processName_.

73  : RootTree(filePtr, branchType, nIndexes, learningEntries, enablePrefetching, inputType) {
75  init(BranchTypeToProductTreeName(branchType, processName), maxVirtualSize, cacheSize);
76  }
std::string const & processName() const
Definition: RootTree.h:185
std::string processName_
Definition: RootTree.h:204
void init(std::string const &productTreeName, unsigned int maxVirtualSize, unsigned int cacheSize)
Definition: RootTree.cc:78
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
Definition: BranchType.cc:95
RootTree(std::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int nIndexes, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
Definition: RootTree.cc:30
BranchType branchType() const
Definition: RootTree.h:184

◆ ~RootTree()

edm::RootTree::~RootTree ( )

Definition at line 111 of file RootTree.cc.

111 {}

◆ RootTree() [4/4]

edm::RootTree::RootTree ( RootTree const &  )
delete

Member Function Documentation

◆ addBranch()

void edm::RootTree::addBranch ( BranchDescription const &  prod,
std::string const &  oldBranchName 
)

Definition at line 156 of file RootTree.cc.

References cms::cuda::assert(), MicroEventContent_cff::branch, branches_, branchNames_, info(), edm::roottree::BranchMap::insert(), isValid(), dumpMFGeometry_cfg::prod, and tree_.

156  {
157  assert(isValid());
158  //use the translated branch name
159  TBranch* branch = tree_->GetBranch(oldBranchName.c_str());
160  roottree::BranchInfo info = roottree::BranchInfo(prod);
161  info.productBranch_ = nullptr;
162  if (prod.present()) {
163  info.productBranch_ = branch;
164  //we want the new branch name for the JobReport
165  branchNames_.push_back(prod.branchName());
166  }
167  branches_.insert(prod.branchID(), info);
168  }
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< std::string > branchNames_
Definition: RootTree.h:219
TTree * tree_
Definition: RootTree.h:201
BranchMap branches_
Definition: RootTree.h:220
bool isValid() const
Definition: RootTree.cc:123
assert(be >=bs)
void insert(edm::BranchID const &iKey, BranchInfo const &iInfo)
Definition: RootTree.h:58

◆ branchEntryInfoBranch()

TBranch* edm::RootTree::branchEntryInfoBranch ( ) const
inline

Definition at line 176 of file RootTree.h.

References branchEntryInfoBranch_.

Referenced by edm::FullProvenanceReader::readProvenance().

176 { return branchEntryInfoBranch_; }
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:234

◆ branches()

roottree::BranchMap const & edm::RootTree::branches ( ) const

Definition at line 194 of file RootTree.cc.

References branches_.

Referenced by edm::RootDelayedReader::branches(), checkTriggerCacheImpl(), and trainCache().

194 { return branches_; }
BranchMap branches_
Definition: RootTree.h:220

◆ branchNames()

std::vector<std::string> const& edm::RootTree::branchNames ( ) const
inline

Definition at line 137 of file RootTree.h.

References branchNames_.

Referenced by edm::RootFile::reportOpened(), and trainCache().

137 { return branchNames_; }
std::vector< std::string > branchNames_
Definition: RootTree.h:219

◆ branchType()

BranchType edm::RootTree::branchType ( ) const
inline

Definition at line 184 of file RootTree.h.

References branchType_.

Referenced by edm::RootDelayedReader::getProduct_(), and RootTree().

184 { return branchType_; }
BranchType branchType_
Definition: RootTree.h:203

◆ checkTriggerCache()

TTreeCache * edm::RootTree::checkTriggerCache ( TBranch *  branch,
EntryNumber  entryNumber 
) const
inline

Definition at line 273 of file RootTree.cc.

References MicroEventContent_cff::branch, checkTriggerCacheImpl(), enableTriggerCache_, entryNumber(), trainedSet_, and treeCache_.

Referenced by selectCache().

273  {
274  if (!treeCache_->IsAsyncReading() && enableTriggerCache_ && (trainedSet_.find(branch) == trainedSet_.end())) {
276  } else {
277  return nullptr;
278  }
279  }
EntryNumber const & entryNumber() const
Definition: RootTree.h:132
std::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:209
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:214
bool enableTriggerCache_
Definition: RootTree.h:231
TTreeCache * checkTriggerCacheImpl(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:283

◆ checkTriggerCacheImpl()

TTreeCache * edm::RootTree::checkTriggerCacheImpl ( TBranch *  branch,
EntryNumber  entryNumber 
) const

Definition at line 283 of file RootTree.cc.

References cms::cuda::assert(), MicroEventContent_cff::branch, branches(), entryNumber(), entryNumber_, filePtr_, mps_fire::i, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, performedSwitchOver_, rawTriggerSwitchOverEntry_, rawTriggerTreeCache_, trainedSet_, tree_, triggerSet_, and triggerTreeCache_.

Referenced by checkTriggerCache().

283  {
284  // This branch is not going to be in the cache.
285  // Assume this is a "trigger pattern".
286  // Always make sure the branch is added to the trigger set.
287  if (triggerSet_.find(branch) == triggerSet_.end()) {
288  triggerSet_.insert(branch);
289  if (triggerTreeCache_.get()) {
290  triggerTreeCache_->AddBranch(branch, kTRUE);
291  }
292  }
293 
294  if (rawTriggerSwitchOverEntry_ < 0) {
295  // The trigger has never fired before. Take everything not in the
296  // trainedSet and load it from disk
297 
298  // Calculate the end of the next cluster; triggers in the next cluster
299  // will use the triggerCache, not the rawTriggerCache.
300  //
301  // Guarantee that rawTriggerSwitchOverEntry_ is positive (non-zero) after completion
302  // of this if-block.
303  TTree::TClusterIterator clusterIter = tree_->GetClusterIterator(entryNumber);
305  rawTriggerSwitchOverEntry_ = clusterIter();
306  }
307 
308  // ROOT will automatically expand the cache to fit one cluster; hence, we use
309  // 5 MB as the cache size below
310  tree_->SetCacheSize(static_cast<Long64_t>(5 * 1024 * 1024));
311  rawTriggerTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
313  rawTriggerTreeCache_->SetEnablePrefetching(false);
314  TObjArray* branches = tree_->GetListOfBranches();
315  int branchCount = branches->GetEntriesFast();
316 
317  // Train the rawTriggerCache to have everything not in the regular cache.
318  rawTriggerTreeCache_->SetLearnEntries(0);
320  for (int i = 0; i < branchCount; i++) {
321  TBranch* tmp_branch = (TBranch*)branches->UncheckedAt(i);
322  if (trainedSet_.find(tmp_branch) != trainedSet_.end()) {
323  continue;
324  }
325  rawTriggerTreeCache_->AddBranch(tmp_branch, kTRUE);
326  }
327  performedSwitchOver_ = false;
328  rawTriggerTreeCache_->StopLearningPhase();
329  filePtr_->SetCacheRead(nullptr);
330 
331  return rawTriggerTreeCache_.get();
333  // The raw trigger has fired and it contents are valid.
334  return rawTriggerTreeCache_.get();
335  } else if (rawTriggerSwitchOverEntry_ > 0) {
336  // The raw trigger has fired, but we are out of the cache. Use the
337  // triggerCache instead.
338  if (!performedSwitchOver_) {
339  rawTriggerTreeCache_.reset();
340  performedSwitchOver_ = true;
341 
342  // Train the triggerCache
343  tree_->SetCacheSize(static_cast<Long64_t>(5 * 1024 * 1024));
344  triggerTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
345  triggerTreeCache_->SetEnablePrefetching(false);
346  triggerTreeCache_->SetLearnEntries(0);
347  triggerTreeCache_->SetEntryRange(entryNumber, tree_->GetEntries());
348  for (std::unordered_set<TBranch*>::const_iterator it = triggerSet_.begin(), itEnd = triggerSet_.end();
349  it != itEnd;
350  it++) {
351  triggerTreeCache_->AddBranch(*it, kTRUE);
352  }
353  triggerTreeCache_->StopLearningPhase();
354  filePtr_->SetCacheRead(nullptr);
355  }
356  return triggerTreeCache_.get();
357  }
358 
359  // By construction, this case should be impossible.
360  assert(false);
361  return nullptr;
362  }
EntryNumber entryNumber_
Definition: RootTree.h:217
std::shared_ptr< TTreeCache > rawTriggerTreeCache_
Definition: RootTree.h:213
EntryNumber const & entryNumber() const
Definition: RootTree.h:132
TTree * tree_
Definition: RootTree.h:201
EntryNumber rawTriggerSwitchOverEntry_
Definition: RootTree.h:223
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:214
assert(be >=bs)
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
BranchMap const & branches() const
Definition: RootTree.cc:194
bool performedSwitchOver_
Definition: RootTree.h:224
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:215
std::shared_ptr< TTreeCache > triggerTreeCache_
Definition: RootTree.h:212

◆ close()

void edm::RootTree::close ( void  )

Definition at line 469 of file RootTree.cc.

References auxBranch_, branchEntryInfoBranch_, filePtr_, infoTree_, metaTree_, rawTreeCache_, rawTriggerTreeCache_, tree_, treeCache_, and triggerTreeCache_.

Referenced by esMonitoring.AsyncLineReaderMixin::handle_close(), and esMonitoring.FDJsonServer::handle_close().

469  {
470  // The TFile is about to be closed, and destructed.
471  // Just to play it safe, zero all pointers to quantities that are owned by the TFile.
473  tree_ = metaTree_ = infoTree_ = nullptr;
474  // We own the treeCache_.
475  // We make sure the treeCache_ is detached from the file,
476  // so that ROOT does not also delete it.
477  filePtr_->SetCacheRead(nullptr);
478  // We *must* delete the TTreeCache here because the TFilePrefetch object
479  // references the TFile. If TFile is closed, before the TTreeCache is
480  // deleted, the TFilePrefetch may continue to do TFile operations, causing
481  // deadlocks or exceptions.
482  treeCache_.reset();
483  rawTreeCache_.reset();
484  triggerTreeCache_.reset();
485  rawTriggerTreeCache_.reset();
486  // We give up our shared ownership of the TFile itself.
487  filePtr_.reset();
488  }
std::shared_ptr< TTreeCache > rawTriggerTreeCache_
Definition: RootTree.h:213
std::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:209
TTree * tree_
Definition: RootTree.h:201
TTree * metaTree_
Definition: RootTree.h:202
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:234
TBranch * auxBranch_
Definition: RootTree.h:205
std::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:210
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
std::shared_ptr< TTreeCache > triggerTreeCache_
Definition: RootTree.h:212
TTree * infoTree_
Definition: RootTree.h:236

◆ current() [1/2]

bool edm::RootTree::current ( ) const
inline

Definition at line 126 of file RootTree.h.

Referenced by edm::RootFile::readCurrentEvent(), edm::RootFile::readLuminosityBlockAuxiliary_(), and edm::RootFile::readRunAuxiliary_().

126 { return entryNumber_ < entries_ && entryNumber_ >= 0; }

◆ current() [2/2]

bool edm::RootTree::current ( EntryNumber  entry) const
inline

Definition at line 127 of file RootTree.h.

127 { return entry < entries_ && entry >= 0; }

◆ dropBranch()

void edm::RootTree::dropBranch ( std::string const &  oldBranchName)

Definition at line 170 of file RootTree.cc.

References beamvalidation::br, MicroEventContent_cff::branch, entries(), mps_fire::i, and tree_.

170  {
171  //use the translated branch name
172  TBranch* branch = tree_->GetBranch(oldBranchName.c_str());
173  if (branch != nullptr) {
174  TObjArray* leaves = tree_->GetListOfLeaves();
175  int entries = leaves->GetEntries();
176  for (int i = 0; i < entries; ++i) {
177  TLeaf* leaf = (TLeaf*)(*leaves)[i];
178  if (leaf == nullptr)
179  continue;
180  TBranch* br = leaf->GetBranch();
181  if (br == nullptr)
182  continue;
183  if (br->GetMother() == branch) {
184  leaves->Remove(leaf);
185  }
186  }
187  leaves->Compress();
188  tree_->GetListOfBranches()->Remove(branch);
189  tree_->GetListOfBranches()->Compress();
190  delete branch;
191  }
192  }
TTree * tree_
Definition: RootTree.h:201
EntryNumber const & entries() const
Definition: RootTree.h:134

◆ entries()

EntryNumber const& edm::RootTree::entries ( ) const
inline

Definition at line 134 of file RootTree.h.

References entries_.

Referenced by dropBranch(), edm::RootFile::fillIndexIntoFile(), edm::RootFile::setIfFastClonable(), and edm::RootFile::validateFile().

134 { return entries_; }
EntryNumber entries_
Definition: RootTree.h:216

◆ entryNumber()

EntryNumber const& edm::RootTree::entryNumber ( ) const
inline

◆ entryNumberForIndex()

RootTree::EntryNumber const & edm::RootTree::entryNumberForIndex ( unsigned int  index) const

Definition at line 113 of file RootTree.cc.

References cms::cuda::assert(), and entryNumberForIndex_.

Referenced by edm::RootDelayedReader::getProduct_(), and edm::FullProvenanceReader::readProvenance().

113  {
114  assert(index < entryNumberForIndex_->size());
115  return (*entryNumberForIndex_)[index];
116  }
size
Write out results.
assert(be >=bs)
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
Definition: RootTree.h:218

◆ fillAux()

template<typename T >
void edm::RootTree::fillAux ( T *&  pAux)
inline

Definition at line 141 of file RootTree.h.

References auxBranch_, entryNumber_, and getEntry().

Referenced by edm::RootFile::fillLumiAuxiliary(), edm::RootFile::fillRunAuxiliary(), edm::RootFile::fillThisEventAuxiliary(), and edm::RootFileEventFinder::getEventNumberOfEntry().

141  {
142  auxBranch_->SetAddress(&pAux);
144  }
EntryNumber entryNumber_
Definition: RootTree.h:217
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:382
TBranch * auxBranch_
Definition: RootTree.h:205

◆ fillBranchEntry() [1/2]

template<typename T >
void edm::RootTree::fillBranchEntry ( TBranch *  branch,
T *&  pbuf 
)
inline

Definition at line 147 of file RootTree.h.

References MicroEventContent_cff::branch, entryNumber_, and getEntry().

Referenced by edm::RootFile::fillEventHistory(), and edm::RootFile::fillEventToProcessBlockIndexes().

147  {
148  branch->SetAddress(&pbuf);
150  }
EntryNumber entryNumber_
Definition: RootTree.h:217
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:382

◆ fillBranchEntry() [2/2]

template<typename T >
void edm::RootTree::fillBranchEntry ( TBranch *  branch,
EntryNumber  entryNumber,
T *&  pbuf 
)
inline

Definition at line 164 of file RootTree.h.

References MicroEventContent_cff::branch, entryNumber(), and getEntry().

164  {
165  branch->SetAddress(&pbuf);
167  }
EntryNumber const & entryNumber() const
Definition: RootTree.h:132
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:382

◆ fillBranchEntryMeta()

template<typename T >
void edm::RootTree::fillBranchEntryMeta ( TBranch *  branch,
EntryNumber  entryNumber,
T *&  pbuf 
)
inline

Definition at line 153 of file RootTree.h.

References MicroEventContent_cff::branch, entryNumber(), edm::roottree::getEntry(), and metaTree_.

Referenced by edm::FullProvenanceReader::readProvenance().

153  {
154  if (metaTree_ != nullptr) {
155  // Metadata was in separate tree. Not cached.
156  branch->SetAddress(&pbuf);
158  } else {
159  fillBranchEntry<T>(branch, entryNumber, pbuf);
160  }
161  }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:527
EntryNumber const & entryNumber() const
Definition: RootTree.h:132
TTree * metaTree_
Definition: RootTree.h:202

◆ getEntry()

void edm::RootTree::getEntry ( TBranch *  branch,
EntryNumber  entry 
) const

Definition at line 382 of file RootTree.cc.

References MicroEventContent_cff::branch, utilities::cache(), MillePedeFileConverter_cfg::e, entryNumber(), cppFunctionSkipper::exception, filePtr_, edm::errors::FileReadError, selectCache(), AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

Referenced by fillAux(), fillBranchEntry(), and edm::RootDelayedReader::getProduct_().

382  {
383  try {
384  TTreeCache* cache = selectCache(branch, entryNumber);
385  filePtr_->SetCacheRead(cache);
386  branch->GetEntry(entryNumber);
387  filePtr_->SetCacheRead(nullptr);
388  } catch (cms::Exception const& e) {
389  // We make sure the treeCache_ is detached from the file,
390  // so that ROOT does not also delete it.
391  filePtr_->SetCacheRead(nullptr);
393  t.addContext(std::string("Reading branch ") + branch->GetName());
394  throw t;
395  } catch (std::exception const& e) {
396  filePtr_->SetCacheRead(nullptr);
398  t << e.what();
399  t.addContext(std::string("Reading branch ") + branch->GetName());
400  throw t;
401  } catch (...) {
402  filePtr_->SetCacheRead(nullptr);
404  t << "An exception of unknown type was thrown.";
405  t.addContext(std::string("Reading branch ") + branch->GetName());
406  throw t;
407  }
408  }
EntryNumber const & entryNumber() const
Definition: RootTree.h:132
TTreeCache * selectCache(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:364
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
def cache(function)
Definition: utilities.py:3

◆ init()

void edm::RootTree::init ( std::string const &  productTreeName,
unsigned int  maxVirtualSize,
unsigned int  cacheSize 
)

Definition at line 78 of file RootTree.cc.

References branchType_, entries_, Exception, filePtr_, edm::InEvent, learningEntries_, setCacheSize(), setTreeMaxVirtualSize(), trainedSet_, tree_, treeAutoFlush_, and triggerSet_.

Referenced by RootTree().

78  {
79  if (filePtr_.get() != nullptr) {
80  tree_ = dynamic_cast<TTree*>(filePtr_->Get(productTreeName.c_str()));
81  }
82  if (not tree_) {
83  throw cms::Exception("WrongFileFormat")
84  << "The ROOT file does not contain a TTree named " << productTreeName
85  << "\n This is either not an edm ROOT file or is one that has been corrupted.";
86  }
87  entries_ = tree_->GetEntries();
88 
89  // On merged files in older releases of ROOT, the autoFlush setting is always negative; we must guess.
90  // TODO: On newer merged files, we should be able to get this from the cluster iterator.
91  long treeAutoFlush = tree_->GetAutoFlush();
92  if (treeAutoFlush < 0) {
93  // The "+1" is here to avoid divide-by-zero in degenerate cases.
94  Long64_t averageEventSizeBytes = tree_->GetZipBytes() / (tree_->GetEntries() + 1) + 1;
95  treeAutoFlush_ = cacheSize / averageEventSizeBytes + 1;
96  } else {
97  treeAutoFlush_ = treeAutoFlush;
98  }
101  }
102  setTreeMaxVirtualSize(maxVirtualSize);
103  setCacheSize(cacheSize);
104  if (branchType_ == InEvent) {
105  Int_t branchCount = tree_->GetListOfBranches()->GetEntriesFast();
106  trainedSet_.reserve(branchCount);
107  triggerSet_.reserve(branchCount);
108  }
109  }
unsigned int learningEntries_
Definition: RootTree.h:225
TTree * tree_
Definition: RootTree.h:201
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:214
EntryNumber entries_
Definition: RootTree.h:216
void setTreeMaxVirtualSize(int treeMaxVirtualSize)
Definition: RootTree.cc:206
unsigned long treeAutoFlush_
Definition: RootTree.h:227
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
void setCacheSize(unsigned int cacheSize)
Definition: RootTree.cc:196
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:215
BranchType branchType_
Definition: RootTree.h:203

◆ insertEntryForIndex()

void edm::RootTree::insertEntryForIndex ( unsigned int  index)

Definition at line 118 of file RootTree.cc.

References cms::cuda::assert(), and entryNumber().

Referenced by edm::RootFile::readCurrentEvent(), edm::RootFile::readLuminosityBlock_(), edm::RootFile::readProcessBlock_(), and edm::RootFile::readRun_().

118  {
119  assert(index < entryNumberForIndex_->size());
120  (*entryNumberForIndex_)[index] = entryNumber();
121  }
size
Write out results.
EntryNumber const & entryNumber() const
Definition: RootTree.h:132
assert(be >=bs)

◆ isValid()

bool edm::RootTree::isValid ( void  ) const

Definition at line 123 of file RootTree.cc.

References auxBranch_, branchEntryInfoBranch_, branchType_, entries_, infoTree_, edm::InProcess, metaTree_, and tree_.

Referenced by ntupleDataFormat._Object::_checkIsValid(), addBranch(), edm::RootFile::fillIndexIntoFile(), edm::RootFile::readLuminosityBlock_(), edm::RootFile::readLuminosityBlockAuxiliary_(), edm::RootFile::readRun_(), edm::RootFile::readRunAuxiliary_(), core.AutoHandle.AutoHandle::ReallyLoad(), setPresence(), and edm::RootFile::validateFile().

123  {
124  // ProcessBlock
125  if (branchType_ == InProcess) {
126  return tree_ != nullptr;
127  }
128  // Run/Lumi/Event
129  if (metaTree_ == nullptr || metaTree_->GetNbranches() == 0) {
130  return tree_ != nullptr && auxBranch_ != nullptr;
131  }
132  // Backward compatibility for Run/Lumi/Event
133  if (tree_ != nullptr && auxBranch_ != nullptr && metaTree_ != nullptr) { // backward compatibility
134  if (branchEntryInfoBranch_ != nullptr || infoTree_ != nullptr)
135  return true; // backward compatibility
136  return (entries_ == metaTree_->GetEntries() &&
137  tree_->GetNbranches() <= metaTree_->GetNbranches() + 1); // backward compatibility
138  } // backward compatibility
139  return false;
140  }
TTree * tree_
Definition: RootTree.h:201
TTree * metaTree_
Definition: RootTree.h:202
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:234
EntryNumber entries_
Definition: RootTree.h:216
TBranch * auxBranch_
Definition: RootTree.h:205
BranchType branchType_
Definition: RootTree.h:203
TTree * infoTree_
Definition: RootTree.h:236

◆ metaTree() [1/2]

TTree const* edm::RootTree::metaTree ( ) const
inline

Definition at line 171 of file RootTree.h.

References metaTree_.

Referenced by edm::RootFile::createFileBlock(), and edm::RootFile::updateFileBlock().

171 { return metaTree_; }
TTree * metaTree_
Definition: RootTree.h:202

◆ metaTree() [2/2]

TTree* edm::RootTree::metaTree ( )
inline

Definition at line 172 of file RootTree.h.

References metaTree_.

172 { return metaTree_; }
TTree * metaTree_
Definition: RootTree.h:202

◆ next()

bool edm::RootTree::next ( void  )
inline

Definition at line 124 of file RootTree.h.

References entries_, and entryNumber_.

Referenced by edm::RootFile::fillIndexIntoFile(), and edm::RootFile::initializeDuplicateChecker().

124 { return ++entryNumber_ < entries_; }
EntryNumber entryNumber_
Definition: RootTree.h:217
EntryNumber entries_
Definition: RootTree.h:216

◆ nextWithCache()

bool edm::RootTree::nextWithCache ( )

Definition at line 211 of file RootTree.cc.

References entries_, entryNumber_, and setEntryNumber().

Referenced by edm::RootFile::nextEventEntry().

211  {
212  bool returnValue = ++entryNumber_ < entries_;
213  if (returnValue) {
215  }
216  return returnValue;
217  }
EntryNumber entryNumber_
Definition: RootTree.h:217
EntryNumber entries_
Definition: RootTree.h:216
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:219

◆ numberOfBranchesToAdd()

void edm::RootTree::numberOfBranchesToAdd ( BranchMap::Map::size_type  iSize)
inline

Definition at line 118 of file RootTree.h.

References branches_, and edm::roottree::BranchMap::reserve().

118 { branches_.reserve(iSize); }
BranchMap branches_
Definition: RootTree.h:220
void reserve(Map::size_type iSize)
Definition: RootTree.h:57

◆ operator=()

RootTree& edm::RootTree::operator= ( RootTree const &  )
delete

◆ processName()

std::string const& edm::RootTree::processName ( ) const
inline

Definition at line 185 of file RootTree.h.

References processName_.

Referenced by edm::RootFile::readProcessBlock_(), and RootTree().

185 { return processName_; }
std::string processName_
Definition: RootTree.h:204

◆ resetAndGetRootDelayedReader()

DelayedReader * edm::RootTree::resetAndGetRootDelayedReader ( ) const

Definition at line 142 of file RootTree.cc.

References rootDelayedReader_.

Referenced by edm::RootFile::readCurrentEvent(), edm::RootFile::readLuminosityBlock_(), edm::RootFile::readProcessBlock_(), and edm::RootFile::readRun_().

142  {
143  rootDelayedReader_->reset();
144  return rootDelayedReader_.get();
145  }
std::unique_ptr< RootDelayedReader > rootDelayedReader_
Definition: RootTree.h:232

◆ resetTraining()

void edm::RootTree::resetTraining ( )
inline

Definition at line 182 of file RootTree.h.

References trainNow_.

Referenced by edm::RootFile::RootFile().

182 { trainNow_ = true; }
bool trainNow_
Definition: RootTree.h:221

◆ rewind()

void edm::RootTree::rewind ( )
inline

Definition at line 128 of file RootTree.h.

References entryNumber_.

Referenced by edm::RootFile::rewind().

128 { entryNumber_ = 0; }
EntryNumber entryNumber_
Definition: RootTree.h:217

◆ rewindToInvalid()

void edm::RootTree::rewindToInvalid ( )
inline

Definition at line 129 of file RootTree.h.

References entryNumber_, and edm::IndexIntoFile::invalidEntry.

EntryNumber entryNumber_
Definition: RootTree.h:217
static constexpr EntryNumber_t invalidEntry

◆ rootDelayedReader()

DelayedReader * edm::RootTree::rootDelayedReader ( ) const

Definition at line 147 of file RootTree.cc.

References rootDelayedReader_.

147 { return rootDelayedReader_.get(); }
std::unique_ptr< RootDelayedReader > rootDelayedReader_
Definition: RootTree.h:232

◆ selectCache()

TTreeCache * edm::RootTree::selectCache ( TBranch *  branch,
EntryNumber  entryNumber 
) const
inline

Definition at line 364 of file RootTree.cc.

References MicroEventContent_cff::branch, checkTriggerCache(), entryNumber(), rawTreeCache_, trainedSet_, and treeCache_.

Referenced by getEntry().

364  {
365  TTreeCache* triggerCache = nullptr;
366  if (!treeCache_) {
367  return nullptr;
368  } else if (treeCache_->IsLearning() && rawTreeCache_) {
369  treeCache_->AddBranch(branch, kTRUE);
370  trainedSet_.insert(branch);
371  return rawTreeCache_.get();
372  } else if ((triggerCache = checkTriggerCache(branch, entryNumber))) {
373  // A NULL return value from checkTriggerCache indicates the trigger cache case
374  // does not apply, and we should continue below.
375  return triggerCache;
376  } else {
377  // The "normal" TTreeCache case.
378  return treeCache_.get();
379  }
380  }
TTreeCache * checkTriggerCache(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:273
EntryNumber const & entryNumber() const
Definition: RootTree.h:132
std::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:209
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:214
std::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:210

◆ setCacheSize()

void edm::RootTree::setCacheSize ( unsigned int  cacheSize)
private

Definition at line 196 of file RootTree.cc.

References cacheSize_, enablePrefetching_, filePtr_, rawTreeCache_, tree_, and treeCache_.

Referenced by init().

196  {
197  cacheSize_ = cacheSize;
198  tree_->SetCacheSize(static_cast<Long64_t>(cacheSize));
199  treeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
200  if (treeCache_)
201  treeCache_->SetEnablePrefetching(enablePrefetching_);
202  filePtr_->SetCacheRead(nullptr);
203  rawTreeCache_.reset();
204  }
std::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:209
TTree * tree_
Definition: RootTree.h:201
bool enablePrefetching_
Definition: RootTree.h:230
std::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:210
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
unsigned int cacheSize_
Definition: RootTree.h:226

◆ setEntryNumber()

void edm::RootTree::setEntryNumber ( EntryNumber  theEntryNumber)

Definition at line 219 of file RootTree.cc.

References entries_, entryNumber_, filePtr_, performedSwitchOver_, rawTreeCache_, rawTriggerSwitchOverEntry_, rawTriggerTreeCache_, startTraining(), stopTraining(), switchOverEntry_, trainedSet_, trainNow_, tree_, treeAutoFlush_, treeCache_, triggerSet_, and triggerTreeCache_.

Referenced by edm::RootFile::fillEventAuxiliary(), edm::RootFile::fillIndexIntoFile(), edm::RootFileEventFinder::getEventNumberOfEntry(), edm::RootFile::initializeDuplicateChecker(), nextWithCache(), edm::RootFile::readLuminosityBlock_(), edm::RootFile::readLuminosityBlockAuxiliary_(), edm::RootFile::readRunAuxiliary_(), edm::RootFile::setAtEventEntry(), edm::RootFile::setEntryAtEvent(), edm::RootFile::setEntryAtLumi(), and edm::RootFile::setEntryAtRun().

219  {
220  filePtr_->SetCacheRead(treeCache_.get());
221 
222  // Detect a backward skip. If the skip is sufficiently large, we roll the dice and reset the treeCache.
223  // This will cause some amount of over-reading: we pre-fetch all the events in some prior cluster.
224  // However, because reading one event in the cluster is supposed to be equivalent to reading all events in the cluster,
225  // we're not incurring additional over-reading - we're just doing it more efficiently.
226  // NOTE: Constructor guarantees treeAutoFlush_ is positive, even if TTree->GetAutoFlush() is negative.
227  if (theEntryNumber < entryNumber_ and theEntryNumber >= 0) {
228  //We started reading the file near the end, now we need to correct for the learning length
229  if (switchOverEntry_ > tree_->GetEntries()) {
230  switchOverEntry_ = switchOverEntry_ - tree_->GetEntries();
231  if (rawTreeCache_) {
232  rawTreeCache_->SetEntryRange(theEntryNumber, switchOverEntry_);
233  rawTreeCache_->FillBuffer();
234  }
235  }
237  //We are using the triggerTreeCache_ not the rawTriggerTreeCache_.
238  //The triggerTreeCache was originally told to start from an entry further in the file.
239  triggerTreeCache_->SetEntryRange(theEntryNumber, tree_->GetEntries());
240  } else if (rawTriggerTreeCache_) {
241  //move the switch point to the end of the cluster holding theEntryNumber
243  TTree::TClusterIterator clusterIter = tree_->GetClusterIterator(theEntryNumber);
244  while ((rawTriggerSwitchOverEntry_ < theEntryNumber) || (rawTriggerSwitchOverEntry_ <= 0)) {
245  rawTriggerSwitchOverEntry_ = clusterIter();
246  }
247  rawTriggerTreeCache_->SetEntryRange(theEntryNumber, rawTriggerSwitchOverEntry_);
248  }
249  }
250  if ((theEntryNumber < static_cast<EntryNumber>(entryNumber_ - treeAutoFlush_)) && (treeCache_) &&
251  (!treeCache_->IsLearning()) && (entries_ > 0) && (switchOverEntry_ >= 0)) {
252  treeCache_->SetEntryRange(theEntryNumber, entries_);
253  treeCache_->FillBuffer();
254  }
255 
256  entryNumber_ = theEntryNumber;
257  tree_->LoadTree(entryNumber_);
258  filePtr_->SetCacheRead(nullptr);
259  if (treeCache_ && trainNow_ && entryNumber_ >= 0) {
260  startTraining();
261  trainNow_ = false;
262  trainedSet_.clear();
263  triggerSet_.clear();
265  }
266  if (treeCache_ && treeCache_->IsLearning() && switchOverEntry_ >= 0 && entryNumber_ >= switchOverEntry_) {
267  stopTraining();
268  }
269  }
EntryNumber entryNumber_
Definition: RootTree.h:217
std::shared_ptr< TTreeCache > rawTriggerTreeCache_
Definition: RootTree.h:213
std::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:209
TTree * tree_
Definition: RootTree.h:201
bool trainNow_
Definition: RootTree.h:221
EntryNumber rawTriggerSwitchOverEntry_
Definition: RootTree.h:223
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:214
void stopTraining()
Definition: RootTree.cc:462
EntryNumber entries_
Definition: RootTree.h:216
unsigned long treeAutoFlush_
Definition: RootTree.h:227
std::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:210
void startTraining()
Definition: RootTree.cc:425
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
bool performedSwitchOver_
Definition: RootTree.h:224
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:215
EntryNumber switchOverEntry_
Definition: RootTree.h:222
std::shared_ptr< TTreeCache > triggerTreeCache_
Definition: RootTree.h:212

◆ setPresence()

void edm::RootTree::setPresence ( BranchDescription prod,
std::string const &  oldBranchName 
)

Definition at line 149 of file RootTree.cc.

References cms::cuda::assert(), isValid(), dumpMFGeometry_cfg::prod, and tree_.

149  {
150  assert(isValid());
151  if (tree_->GetBranch(oldBranchName.c_str()) == nullptr) {
152  prod.setDropped(true);
153  }
154  }
TTree * tree_
Definition: RootTree.h:201
bool isValid() const
Definition: RootTree.cc:123
assert(be >=bs)

◆ setSignals()

void edm::RootTree::setSignals ( signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *  preEventReadSource,
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *  postEventReadSource 
)

Definition at line 520 of file RootTree.cc.

References rootDelayedReader_.

Referenced by edm::RootFile::setSignals().

522  {
523  rootDelayedReader_->setSignals(preEventReadSource, postEventReadSource);
524  }
std::unique_ptr< RootDelayedReader > rootDelayedReader_
Definition: RootTree.h:232

◆ setTreeMaxVirtualSize()

void edm::RootTree::setTreeMaxVirtualSize ( int  treeMaxVirtualSize)
private

Definition at line 206 of file RootTree.cc.

References tree_.

Referenced by init().

206  {
207  if (treeMaxVirtualSize >= 0)
208  tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
209  }
TTree * tree_
Definition: RootTree.h:201

◆ skipEntries()

bool edm::RootTree::skipEntries ( unsigned int &  offset)

Definition at line 410 of file RootTree.cc.

References entries_, entryNumber_, and hltrates_dqm_sourceclient-live_cfg::offset.

Referenced by edm::RootFile::skipEntries().

410  {
411  entryNumber_ += offset;
412  bool retval = (entryNumber_ < entries_);
413  if (retval) {
414  offset = 0;
415  } else {
416  // Not enough entries in the file to skip.
417  // The +1 is needed because entryNumber_ is -1 at the initialization of the tree, not 0.
418  long long overshoot = entryNumber_ + 1 - entries_;
420  offset = overshoot;
421  }
422  return retval;
423  }
EntryNumber entryNumber_
Definition: RootTree.h:217
EntryNumber entries_
Definition: RootTree.h:216

◆ startTraining()

void edm::RootTree::startTraining ( )
private

Definition at line 425 of file RootTree.cc.

References cms::cuda::assert(), edm::poolNames::branchListIndexesBranchName(), branchType_, edm::BranchTypeToAuxiliaryBranchName(), cacheSize_, entryNumber_, filePtr_, edm::InEvent, learningEntries_, rawTreeCache_, switchOverEntry_, trainedSet_, tree_, treeCache_, and triggerSet_.

Referenced by setEntryNumber().

425  {
426  if (cacheSize_ == 0) {
427  return;
428  }
432  treeCache_->SetLearnEntries(learningEntries_);
433  tree_->SetCacheSize(static_cast<Long64_t>(cacheSize_));
434  rawTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
435  rawTreeCache_->SetEnablePrefetching(false);
436  filePtr_->SetCacheRead(nullptr);
437  rawTreeCache_->SetLearnEntries(0);
439  auto rawStart = entryNumber_;
440  auto rawEnd = switchOverEntry_;
441  auto treeStart = switchOverEntry_;
442  if (switchOverEntry_ >= tree_->GetEntries()) {
443  treeStart = switchOverEntry_ - tree_->GetEntries();
444  rawEnd = tree_->GetEntries();
445  }
446  rawTreeCache_->StartLearningPhase();
447  rawTreeCache_->SetEntryRange(rawStart, rawEnd);
448  rawTreeCache_->AddBranch("*", kTRUE);
449  rawTreeCache_->StopLearningPhase();
450  treeCache_->StartLearningPhase();
451  treeCache_->SetEntryRange(treeStart, tree_->GetEntries());
452  // Make sure that 'branchListIndexes' branch exist in input file
453  if (filePtr_->Get(poolNames::branchListIndexesBranchName().c_str()) != nullptr) {
454  treeCache_->AddBranch(poolNames::branchListIndexesBranchName().c_str(), kTRUE);
455  }
456  treeCache_->AddBranch(BranchTypeToAuxiliaryBranchName(branchType_).c_str(), kTRUE);
457  trainedSet_.clear();
458  triggerSet_.clear();
459  assert(treeCache_->GetTree() == tree_);
460  }
EntryNumber entryNumber_
Definition: RootTree.h:217
unsigned int learningEntries_
Definition: RootTree.h:225
std::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:209
TTree * tree_
Definition: RootTree.h:201
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:214
assert(be >=bs)
std::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:210
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
unsigned int cacheSize_
Definition: RootTree.h:226
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:215
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:212
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:116
EntryNumber switchOverEntry_
Definition: RootTree.h:222
BranchType branchType_
Definition: RootTree.h:203

◆ stopTraining()

void edm::RootTree::stopTraining ( )
private

Definition at line 462 of file RootTree.cc.

References filePtr_, rawTreeCache_, and treeCache_.

Referenced by setEntryNumber().

462  {
463  filePtr_->SetCacheRead(treeCache_.get());
464  treeCache_->StopLearningPhase();
465  filePtr_->SetCacheRead(nullptr);
466  rawTreeCache_.reset();
467  }
std::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:209
std::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:210
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197

◆ trainCache()

void edm::RootTree::trainCache ( char const *  branchNames)

Definition at line 490 of file RootTree.cc.

References cms::cuda::assert(), MicroEventContent_cff::branch, branches(), branchNames(), branchType_, cacheSize_, filePtr_, mps_fire::i, edm::InEvent, trainedSet_, tree_, and treeCache_.

Referenced by edm::RootFile::RootFile().

490  {
491  if (cacheSize_ == 0) {
492  return;
493  }
494  tree_->LoadTree(0);
496  filePtr_->SetCacheRead(treeCache_.get());
497  treeCache_->StartLearningPhase();
498  treeCache_->SetEntryRange(0, tree_->GetEntries());
499  treeCache_->AddBranch(branchNames, kTRUE);
500  treeCache_->StopLearningPhase();
501  assert(treeCache_->GetTree() == tree_);
502  // We own the treeCache_.
503  // We make sure the treeCache_ is detached from the file,
504  // so that ROOT does not also delete it.
505  filePtr_->SetCacheRead(nullptr);
506 
507  if (branchType_ == InEvent) {
508  // Must also manually add things to the trained set.
509  TObjArray* branches = tree_->GetListOfBranches();
510  int branchCount = branches->GetEntriesFast();
511  for (int i = 0; i < branchCount; i++) {
512  TBranch* branch = (TBranch*)branches->UncheckedAt(i);
513  if ((branchNames[0] == '*') || (strcmp(branchNames, branch->GetName()) == 0)) {
514  trainedSet_.insert(branch);
515  }
516  }
517  }
518  }
std::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:209
TTree * tree_
Definition: RootTree.h:201
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:214
assert(be >=bs)
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
BranchMap const & branches() const
Definition: RootTree.cc:194
unsigned int cacheSize_
Definition: RootTree.h:226
BranchType branchType_
Definition: RootTree.h:203
std::vector< std::string > const & branchNames() const
Definition: RootTree.h:137

◆ tree() [1/2]

TTree const* edm::RootTree::tree ( ) const
inline

◆ tree() [2/2]

TTree* edm::RootTree::tree ( )
inline

Member Data Documentation

◆ auxBranch_

TBranch* edm::RootTree::auxBranch_ = nullptr
private

Definition at line 205 of file RootTree.h.

Referenced by close(), fillAux(), isValid(), and RootTree().

◆ branchEntryInfoBranch_

TBranch* edm::RootTree::branchEntryInfoBranch_ = nullptr
private

Definition at line 234 of file RootTree.h.

Referenced by branchEntryInfoBranch(), close(), isValid(), and RootTree().

◆ branches_

BranchMap edm::RootTree::branches_
private

Definition at line 220 of file RootTree.h.

Referenced by addBranch(), branches(), and numberOfBranchesToAdd().

◆ branchNames_

std::vector<std::string> edm::RootTree::branchNames_
private

Definition at line 219 of file RootTree.h.

Referenced by addBranch(), and branchNames().

◆ branchType_

BranchType edm::RootTree::branchType_
private

Definition at line 203 of file RootTree.h.

Referenced by branchType(), init(), isValid(), RootTree(), startTraining(), and trainCache().

◆ cacheSize_

unsigned int edm::RootTree::cacheSize_ = 0
private

Definition at line 226 of file RootTree.h.

Referenced by setCacheSize(), startTraining(), and trainCache().

◆ enablePrefetching_

bool edm::RootTree::enablePrefetching_
private

Definition at line 230 of file RootTree.h.

Referenced by setCacheSize().

◆ enableTriggerCache_

bool edm::RootTree::enableTriggerCache_
private

Definition at line 231 of file RootTree.h.

Referenced by checkTriggerCache().

◆ entries_

EntryNumber edm::RootTree::entries_ = 0
private

Definition at line 216 of file RootTree.h.

Referenced by entries(), init(), isValid(), next(), nextWithCache(), setEntryNumber(), and skipEntries().

◆ entryNumber_

EntryNumber edm::RootTree::entryNumber_ = IndexIntoFile::invalidEntry
private

◆ entryNumberForIndex_

std::unique_ptr<std::vector<EntryNumber> > edm::RootTree::entryNumberForIndex_
private

Definition at line 218 of file RootTree.h.

Referenced by entryNumberForIndex().

◆ filePtr_

std::shared_ptr<InputFile> edm::RootTree::filePtr_
private

◆ infoTree_

TTree* edm::RootTree::infoTree_ = nullptr
private

Definition at line 236 of file RootTree.h.

Referenced by close(), isValid(), and RootTree().

◆ learningEntries_

unsigned int edm::RootTree::learningEntries_
private

Definition at line 225 of file RootTree.h.

Referenced by init(), and startTraining().

◆ metaTree_

TTree* edm::RootTree::metaTree_ = nullptr
private

Definition at line 202 of file RootTree.h.

Referenced by close(), fillBranchEntryMeta(), isValid(), metaTree(), and RootTree().

◆ performedSwitchOver_

bool edm::RootTree::performedSwitchOver_ = false
mutableprivate

Definition at line 224 of file RootTree.h.

Referenced by checkTriggerCacheImpl(), and setEntryNumber().

◆ processName_

std::string edm::RootTree::processName_
private

Definition at line 204 of file RootTree.h.

Referenced by processName(), and RootTree().

◆ rawTreeCache_

std::shared_ptr<TTreeCache> edm::RootTree::rawTreeCache_
private

◆ rawTriggerSwitchOverEntry_

EntryNumber edm::RootTree::rawTriggerSwitchOverEntry_ = -1
mutableprivate

Definition at line 223 of file RootTree.h.

Referenced by checkTriggerCacheImpl(), and setEntryNumber().

◆ rawTriggerTreeCache_

std::shared_ptr<TTreeCache> edm::RootTree::rawTriggerTreeCache_
mutableprivate

Definition at line 213 of file RootTree.h.

Referenced by checkTriggerCacheImpl(), close(), and setEntryNumber().

◆ rootDelayedReader_

std::unique_ptr<RootDelayedReader> edm::RootTree::rootDelayedReader_
private

Definition at line 232 of file RootTree.h.

Referenced by resetAndGetRootDelayedReader(), rootDelayedReader(), and setSignals().

◆ switchOverEntry_

EntryNumber edm::RootTree::switchOverEntry_ = -1
private

Definition at line 222 of file RootTree.h.

Referenced by setEntryNumber(), and startTraining().

◆ trainedSet_

std::unordered_set<TBranch*> edm::RootTree::trainedSet_
mutableprivate

◆ trainNow_

bool edm::RootTree::trainNow_ = false
private

Definition at line 221 of file RootTree.h.

Referenced by resetTraining(), and setEntryNumber().

◆ tree_

TTree* edm::RootTree::tree_ = nullptr
private

◆ treeAutoFlush_

unsigned long edm::RootTree::treeAutoFlush_ = 0
private

Definition at line 227 of file RootTree.h.

Referenced by init(), and setEntryNumber().

◆ treeCache_

std::shared_ptr<TTreeCache> edm::RootTree::treeCache_
private

◆ triggerSet_

std::unordered_set<TBranch*> edm::RootTree::triggerSet_
mutableprivate

Definition at line 215 of file RootTree.h.

Referenced by checkTriggerCacheImpl(), init(), setEntryNumber(), and startTraining().

◆ triggerTreeCache_

std::shared_ptr<TTreeCache> edm::RootTree::triggerTreeCache_
mutableprivate

Definition at line 212 of file RootTree.h.

Referenced by checkTriggerCacheImpl(), close(), and setEntryNumber().