CMS 3D CMS Logo

RootTree.cc
Go to the documentation of this file.
1 #include "RootTree.h"
2 #include "RootDelayedReader.h"
6 #include "InputFile.h"
7 #include "TTree.h"
8 #include "TTreeCache.h"
9 #include "TLeaf.h"
10 
11 #include <cassert>
12 
13 namespace edm {
14  namespace {
15  TBranch* getAuxiliaryBranch(TTree* tree, BranchType const& branchType) {
16  TBranch* branch = tree->GetBranch(BranchTypeToAuxiliaryBranchName(branchType).c_str());
17  if (branch == nullptr) {
18  branch = tree->GetBranch(BranchTypeToAuxBranchName(branchType).c_str());
19  }
20  return branch;
21  }
22  TBranch* getProductProvenanceBranch(TTree* tree, BranchType const& branchType) {
23  TBranch* branch = tree->GetBranch(BranchTypeToBranchEntryInfoBranchName(branchType).c_str());
24  return branch;
25  }
26  } // namespace
27 
28  // Used for all RootTrees
29  // All the other constructors delegate to this one
30  RootTree::RootTree(std::shared_ptr<InputFile> filePtr,
31  BranchType const& branchType,
32  unsigned int nIndexes,
33  unsigned int learningEntries,
34  bool enablePrefetching,
35  InputType inputType)
36  : filePtr_(filePtr),
37  branchType_(branchType),
38  entryNumberForIndex_(std::make_unique<std::vector<EntryNumber>>(nIndexes, IndexIntoFile::invalidEntry)),
39  learningEntries_(learningEntries),
40  enablePrefetching_(enablePrefetching),
41  enableTriggerCache_(branchType_ == InEvent),
42  rootDelayedReader_(std::make_unique<RootDelayedReader>(*this, filePtr, inputType)) {}
43 
44  // Used for Event/Lumi/Run RootTrees
45  RootTree::RootTree(std::shared_ptr<InputFile> filePtr,
46  BranchType const& branchType,
47  unsigned int nIndexes,
48  unsigned int maxVirtualSize,
49  unsigned int cacheSize,
50  unsigned int learningEntries,
51  bool enablePrefetching,
52  InputType inputType)
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  }
62 
63  // Used for ProcessBlock RootTrees
64  RootTree::RootTree(std::shared_ptr<InputFile> filePtr,
65  BranchType const& branchType,
66  std::string const& processName,
67  unsigned int nIndexes,
68  unsigned int maxVirtualSize,
69  unsigned int cacheSize,
70  unsigned int learningEntries,
71  bool enablePrefetching,
72  InputType inputType)
73  : RootTree(filePtr, branchType, nIndexes, learningEntries, enablePrefetching, inputType) {
75  init(BranchTypeToProductTreeName(branchType, processName), maxVirtualSize, cacheSize);
76  }
77 
78  void RootTree::init(std::string const& productTreeName, unsigned int maxVirtualSize, unsigned int cacheSize) {
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  }
110 
112 
114  assert(index < entryNumberForIndex_->size());
115  return (*entryNumberForIndex_)[index];
116  }
117 
119  assert(index < entryNumberForIndex_->size());
120  (*entryNumberForIndex_)[index] = entryNumber();
121  }
122 
123  bool RootTree::isValid() const {
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  }
141 
143  rootDelayedReader_->reset();
144  return rootDelayedReader_.get();
145  }
146 
148 
150  assert(isValid());
151  if (tree_->GetBranch(oldBranchName.c_str()) == nullptr) {
152  prod.setDropped(true);
153  }
154  }
155 
156  void RootTree::addBranch(BranchDescription const& prod, std::string const& oldBranchName) {
157  assert(isValid());
158  //use the translated branch name
159  TBranch* branch = tree_->GetBranch(oldBranchName.c_str());
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  }
169 
170  void RootTree::dropBranch(std::string const& oldBranchName) {
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  }
193 
195 
196  void RootTree::setCacheSize(unsigned int cacheSize) {
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  }
205 
206  void RootTree::setTreeMaxVirtualSize(int treeMaxVirtualSize) {
207  if (treeMaxVirtualSize >= 0)
208  tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
209  }
210 
212  bool returnValue = ++entryNumber_ < entries_;
213  if (returnValue) {
215  }
216  return returnValue;
217  }
218 
219  void RootTree::setEntryNumber(EntryNumber theEntryNumber) {
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  }
270 
271  // The actual implementation is done below; it's split in this strange
272  // manner in order to keep a by-definition-rare code path out of the instruction cache.
273  inline TTreeCache* RootTree::checkTriggerCache(TBranch* branch, EntryNumber entryNumber) const {
274  if (!treeCache_->IsAsyncReading() && enableTriggerCache_ && (trainedSet_.find(branch) == trainedSet_.end())) {
276  } else {
277  return nullptr;
278  }
279  }
280 
281  // See comments in the header. If this function is called, we already know
282  // the trigger cache is active and it was a cache miss for the regular cache.
283  TTreeCache* RootTree::checkTriggerCacheImpl(TBranch* branch, EntryNumber entryNumber) const {
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  }
363 
364  inline TTreeCache* RootTree::selectCache(TBranch* branch, EntryNumber entryNumber) const {
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  }
381 
382  void RootTree::getEntry(TBranch* branch, EntryNumber entryNumber) const {
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  }
409 
410  bool RootTree::skipEntries(unsigned int& offset) {
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  }
424 
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  }
461 
463  filePtr_->SetCacheRead(treeCache_.get());
464  treeCache_->StopLearningPhase();
465  filePtr_->SetCacheRead(nullptr);
466  rawTreeCache_.reset();
467  }
468 
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  }
489 
490  void RootTree::trainCache(char const* branchNames) {
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  }
519 
521  signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* preEventReadSource,
522  signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* postEventReadSource) {
523  rootDelayedReader_->setSignals(preEventReadSource, postEventReadSource);
524  }
525 
526  namespace roottree {
527  Int_t getEntry(TBranch* branch, EntryNumber entryNumber) {
528  Int_t n = 0;
529  try {
530  n = branch->GetEntry(entryNumber);
531  } catch (cms::Exception const& e) {
532  throw Exception(errors::FileReadError, "", e);
533  }
534  return n;
535  }
536 
537  Int_t getEntry(TTree* tree, EntryNumber entryNumber) {
538  Int_t n = 0;
539  try {
540  n = tree->GetEntry(entryNumber);
541  } catch (cms::Exception const& e) {
542  throw Exception(errors::FileReadError, "", e);
543  }
544  return n;
545  }
546 
547  std::unique_ptr<TTreeCache> trainCache(TTree* tree,
548  InputFile& file,
549  unsigned int cacheSize,
550  char const* branchNames) {
551  tree->LoadTree(0);
552  tree->SetCacheSize(cacheSize);
553  std::unique_ptr<TTreeCache> treeCache(dynamic_cast<TTreeCache*>(file.GetCacheRead()));
554  if (nullptr != treeCache.get()) {
555  treeCache->StartLearningPhase();
556  treeCache->SetEntryRange(0, tree->GetEntries());
557  treeCache->AddBranch(branchNames, kTRUE);
558  treeCache->StopLearningPhase();
559  }
560  // We own the treeCache_.
561  // We make sure the treeCache_ is detached from the file,
562  // so that ROOT does not also delete it.
563  file.SetCacheRead(nullptr);
564  return treeCache;
565  }
566  } // namespace roottree
567 } // namespace edm
EntryNumber entryNumber_
Definition: RootTree.h:217
size
Write out results.
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:527
TTreeCache * checkTriggerCache(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:273
std::string const & processName() const
Definition: RootTree.h:185
unsigned int learningEntries_
Definition: RootTree.h:225
InputType
Definition: InputType.h:5
static const TGPicture * info(bool iBackgroundIsBlack)
roottree::EntryNumber EntryNumber
Definition: RootTree.h:82
std::shared_ptr< TTreeCache > rawTriggerTreeCache_
Definition: RootTree.h:213
void dropBranch(std::string const &oldBranchName)
Definition: RootTree.cc:170
std::vector< std::string > branchNames_
Definition: RootTree.h:219
EntryNumber const & entryNumber() const
Definition: RootTree.h:132
EntryNumber const & entryNumberForIndex(unsigned int index) const
Definition: RootTree.cc:113
std::string const & BranchTypeToBranchEntryInfoBranchName(BranchType const &branchType)
Definition: BranchType.cc:134
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
BranchMap branches_
Definition: RootTree.h:220
void setSignals(signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
Definition: RootTree.cc:520
TTree * metaTree_
Definition: RootTree.h:202
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:214
void stopTraining()
Definition: RootTree.cc:462
bool isValid() const
Definition: RootTree.cc:123
std::string const & BranchTypeToAuxBranchName(BranchType const &branchType)
Definition: BranchType.cc:122
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:234
void setPresence(BranchDescription &prod, std::string const &oldBranchName)
Definition: RootTree.cc:149
EntryNumber entries_
Definition: RootTree.h:216
bool enablePrefetching_
Definition: RootTree.h:230
assert(be >=bs)
void trainCache(char const *branchNames)
Definition: RootTree.cc:490
DelayedReader * rootDelayedReader() const
Definition: RootTree.cc:147
std::unique_ptr< RootDelayedReader > rootDelayedReader_
Definition: RootTree.h:232
void setTreeMaxVirtualSize(int treeMaxVirtualSize)
Definition: RootTree.cc:206
BranchType
Definition: BranchType.h:11
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
Definition: BranchType.cc:105
std::string processName_
Definition: RootTree.h:204
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:382
void init(std::string const &productTreeName, unsigned int maxVirtualSize, unsigned int cacheSize)
Definition: RootTree.cc:78
void insertEntryForIndex(unsigned int index)
Definition: RootTree.cc:118
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
Definition: BranchType.cc:95
TTreeCache * selectCache(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:364
EntryNumber const & entries() const
Definition: RootTree.h:134
unsigned long treeAutoFlush_
Definition: RootTree.h:227
void addBranch(BranchDescription const &prod, std::string const &oldBranchName)
Definition: RootTree.cc:156
TBranch * auxBranch_
Definition: RootTree.h:205
bool enableTriggerCache_
Definition: RootTree.h:231
std::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:210
void close()
Definition: RootTree.cc:469
void insert(edm::BranchID const &iKey, BranchInfo const &iInfo)
Definition: RootTree.h:58
void startTraining()
Definition: RootTree.cc:425
IndexIntoFile::EntryNumber_t EntryNumber
Definition: RootTree.h:42
std::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:197
void setCacheSize(unsigned int cacheSize)
Definition: RootTree.cc:196
std::string const & BranchTypeToInfoTreeName(BranchType const &branchType)
Definition: BranchType.cc:111
BranchMap const & branches() const
Definition: RootTree.cc:194
bool performedSwitchOver_
Definition: RootTree.h:224
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
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
Definition: RootTree.h:218
HLT enums.
unsigned int cacheSize_
Definition: RootTree.h:226
def cache(function)
Definition: utilities.py:3
bool skipEntries(unsigned int &offset)
Definition: RootTree.cc:410
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:215
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:212
bool nextWithCache()
Definition: RootTree.cc:211
Definition: tree.py:1
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:116
std::unique_ptr< TTreeCache > trainCache(TTree *tree, InputFile &file, unsigned int cacheSize, char const *branchNames)
Definition: RootTree.cc:547
branchNames
Definition: haddnano.py:54
DelayedReader * resetAndGetRootDelayedReader() const
Definition: RootTree.cc:142
TTreeCache * checkTriggerCacheImpl(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:283
EntryNumber switchOverEntry_
Definition: RootTree.h:222
std::shared_ptr< TTreeCache > triggerTreeCache_
Definition: RootTree.h:212
BranchType branchType_
Definition: RootTree.h:203
TTree * infoTree_
Definition: RootTree.h:236
void setEntryNumber(EntryNumber theEntryNumber)
Definition: RootTree.cc:219
std::vector< std::string > const & branchNames() const
Definition: RootTree.h:137