CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::RootTree Class Reference

#include <RootTree.h>

Public Types

typedef roottree::BranchMap BranchMap
 
typedef roottree::EntryNumber EntryNumber
 

Public Member Functions

void addBranch (BranchKey const &key, BranchDescription const &prod, std::string const &oldBranchName)
 
TBranch * branchEntryInfoBranch () const
 
BranchMap const & branches () const
 
std::vector< std::string > const & branchNames () const
 
BranchType branchType () const
 
void close ()
 
bool current ()
 
void dropBranch (std::string const &oldBranchName)
 
EntryNumber const & entries () const
 
EntryNumber const & entryNumber () const
 
template<typename T >
void fillAux (T *&pAux)
 
template<typename T >
void fillBranchEntry (TBranch *branch, T *&pbuf)
 
template<typename T >
void fillBranchEntryMeta (TBranch *branch, T *&pbuf)
 
void getEntry (TBranch *branch, EntryNumber entry) const
 
bool isValid () const
 
TTree const * metaTree () const
 
bool next ()
 
RootTreeoperator= (RootTree const &)=delete
 
bool previous ()
 
void resetTraining ()
 
void rewind ()
 
DelayedReaderrootDelayedReader () const
 
 RootTree (boost::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int maxVirtualSize, unsigned int cacheSize, unsigned int learningEntries)
 
 RootTree (RootTree const &)=delete
 
void setEntryNumber (EntryNumber theEntryNumber)
 
void setPresence (BranchDescription const &prod, std::string const &oldBranchName)
 
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_
 
TBranch * branchEntryInfoBranch_
 
boost::shared_ptr< BranchMapbranches_
 
std::vector< std::string > branchNames_
 
BranchType branchType_
 
unsigned int cacheSize_
 
EntryNumber entries_
 
EntryNumber entryNumber_
 
boost::shared_ptr< InputFilefilePtr_
 
TTree * infoTree_
 
unsigned int learningEntries_
 
TTree * metaTree_
 
boost::shared_ptr< TTreeCache > rawTreeCache_
 
std::unique_ptr< DelayedReaderrootDelayedReader_
 
TBranch * statusBranch_
 
EntryNumber switchOverEntry_
 
bool trainNow_
 
TTree * tree_
 
long int treeAutoFlush_
 
boost::shared_ptr< TTreeCache > treeCache_
 

Detailed Description

Definition at line 56 of file RootTree.h.

Member Typedef Documentation

Definition at line 58 of file RootTree.h.

Definition at line 59 of file RootTree.h.

Constructor & Destructor Documentation

edm::RootTree::RootTree ( boost::shared_ptr< InputFile filePtr,
BranchType const &  branchType,
unsigned int  maxVirtualSize,
unsigned int  cacheSize,
unsigned int  learningEntries 
)

Definition at line 27 of file RootTree.cc.

References cacheSize_, setCacheSize(), setTreeMaxVirtualSize(), tree_, and treeAutoFlush_.

31  :
32  filePtr_(filePtr),
33  tree_(dynamic_cast<TTree*>(filePtr_.get() != 0 ? filePtr_->Get(BranchTypeToProductTreeName(branchType).c_str()) : 0)),
34  metaTree_(dynamic_cast<TTree*>(filePtr_.get() != 0 ? filePtr_->Get(BranchTypeToMetaDataTreeName(branchType).c_str()) : 0)),
36  auxBranch_(tree_ ? getAuxiliaryBranch(tree_, branchType_) : 0),
37  treeCache_(),
38  rawTreeCache_(),
39  entries_(tree_ ? tree_->GetEntries() : 0),
40  entryNumber_(-1),
41  branchNames_(),
42  branches_(new BranchMap),
43  trainNow_(false),
44  switchOverEntry_(-1),
45  learningEntries_(learningEntries),
46  cacheSize_(cacheSize),
47  treeAutoFlush_(tree_ ? tree_->GetAutoFlush() : 0),
48  rootDelayedReader_(new RootDelayedReader(*this, filePtr)),
49  branchEntryInfoBranch_(metaTree_ ? getProductProvenanceBranch(metaTree_, branchType_) : (tree_ ? getProductProvenanceBranch(tree_, branchType_) : 0)),
50  infoTree_(dynamic_cast<TTree*>(filePtr_.get() != 0 ? filePtr->Get(BranchTypeToInfoTreeName(branchType).c_str()) : 0)) // backward compatibility
51  {
52  assert(tree_);
53  // On merged files in older releases of ROOT, the autoFlush setting is always negative; we must guess.
54  // TODO: On newer merged files, we should be able to get this from the cluster iterator.
55  if (treeAutoFlush_ < 0) {
56  // The "+1" is here to avoid divide-by-zero in degenerate cases.
57  Long64_t averageEventSizeBytes = tree_->GetZipBytes() / (tree_->GetEntries()+1) + 1;
58  treeAutoFlush_ = cacheSize_/averageEventSizeBytes+1;
59  }
60  setTreeMaxVirtualSize(maxVirtualSize);
61  setCacheSize(cacheSize);
62  }
EntryNumber entryNumber_
Definition: RootTree.h:143
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:140
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
Definition: BranchType.cc:106
unsigned int learningEntries_
Definition: RootTree.h:148
std::vector< std::string > branchNames_
Definition: RootTree.h:144
TTree * tree_
Definition: RootTree.h:133
bool trainNow_
Definition: RootTree.h:146
roottree::BranchMap BranchMap
Definition: RootTree.h:58
TTree * metaTree_
Definition: RootTree.h:134
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:153
EntryNumber entries_
Definition: RootTree.h:142
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:141
void setTreeMaxVirtualSize(int treeMaxVirtualSize)
Definition: RootTree.cc:150
BranchType branchType() const
Definition: RootTree.h:122
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
Definition: BranchType.cc:102
TBranch * auxBranch_
Definition: RootTree.h:136
long int treeAutoFlush_
Definition: RootTree.h:150
std::string const & BranchTypeToInfoTreeName(BranchType const &branchType)
Definition: BranchType.cc:110
boost::shared_ptr< BranchMap > branches_
Definition: RootTree.h:145
void setCacheSize(unsigned int cacheSize)
Definition: RootTree.cc:141
unsigned int cacheSize_
Definition: RootTree.h:149
std::unique_ptr< DelayedReader > rootDelayedReader_
Definition: RootTree.h:151
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:129
EntryNumber switchOverEntry_
Definition: RootTree.h:147
T get(const Candidate &c)
Definition: component.h:56
BranchType branchType_
Definition: RootTree.h:135
TTree * infoTree_
Definition: RootTree.h:155
edm::RootTree::~RootTree ( )

Definition at line 64 of file RootTree.cc.

64  {
65  }
edm::RootTree::RootTree ( RootTree const &  )
delete

Member Function Documentation

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

Definition at line 95 of file RootTree.cc.

References branches_, edm::BranchDescription::branchName(), branchNames_, info, edm::BranchDescription::init(), isValid(), metaTree_, edm::BranchDescription::present(), edm::roottree::BranchInfo::productBranch_, edm::roottree::BranchInfo::provenanceBranch_, and tree_.

97  {
98  assert(isValid());
99  prod.init();
100  //use the translated branch name
101  TBranch* branch = tree_->GetBranch(oldBranchName.c_str());
102  roottree::BranchInfo info = roottree::BranchInfo(ConstBranchDescription(prod));
103  info.productBranch_ = 0;
104  if (prod.present()) {
105  info.productBranch_ = branch;
106  //we want the new branch name for the JobReport
107  branchNames_.push_back(prod.branchName());
108  }
109  TTree* provTree = (metaTree_ != 0 ? metaTree_ : tree_);
110  info.provenanceBranch_ = provTree->GetBranch(oldBranchName.c_str());
111  branches_->insert(std::make_pair(key, info));
112  }
std::vector< std::string > branchNames_
Definition: RootTree.h:144
TTree * tree_
Definition: RootTree.h:133
TTree * metaTree_
Definition: RootTree.h:134
boost::shared_ptr< BranchMap > branches_
Definition: RootTree.h:145
bool isValid() const
Definition: RootTree.cc:68
list key
Definition: combine.py:13
TBranch* edm::RootTree::branchEntryInfoBranch ( ) const
inline
roottree::BranchMap const & edm::RootTree::branches ( ) const

Definition at line 138 of file RootTree.cc.

References branches_.

Referenced by edm::RootDelayedReader::branches().

138 {return *branches_;}
boost::shared_ptr< BranchMap > branches_
Definition: RootTree.h:145
std::vector<std::string> const& edm::RootTree::branchNames ( ) const
inline

Definition at line 87 of file RootTree.h.

References branchNames_.

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

87 {return branchNames_;}
std::vector< std::string > branchNames_
Definition: RootTree.h:144
BranchType edm::RootTree::branchType ( ) const
inline

Definition at line 122 of file RootTree.h.

References branchType_.

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

122 {return branchType_;}
BranchType branchType_
Definition: RootTree.h:135
void edm::RootTree::close ( void  )

Definition at line 239 of file RootTree.cc.

References auxBranch_, branchEntryInfoBranch_, filePtr_, infoTree_, metaTree_, and tree_.

Referenced by lumiQTWidget.ApplicationWindow::fileQuit(), Vispa.Gui.BoxContentDialog.BoxContentDialog::keyPressEvent(), and Vispa.Gui.FindDialog.FindDialog::keyPressEvent().

239  {
240  // The TFile is about to be closed, and destructed.
241  // Just to play it safe, zero all pointers to quantities that are owned by the TFile.
243  tree_ = metaTree_ = infoTree_ = 0;
244  // We own the treeCache_.
245  // We make sure the treeCache_ is detached from the file,
246  // so that ROOT does not also delete it.
247  filePtr_->SetCacheRead(0);
248  // We give up our shared ownership of the TFile itself.
249  filePtr_.reset();
250  }
TTree * tree_
Definition: RootTree.h:133
TTree * metaTree_
Definition: RootTree.h:134
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:153
TBranch * auxBranch_
Definition: RootTree.h:136
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:129
TTree * infoTree_
Definition: RootTree.h:155
bool edm::RootTree::current ( )
inline

Definition at line 81 of file RootTree.h.

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

81 {return entryNumber_ < entries_ && entryNumber_ >= 0;}
void edm::RootTree::dropBranch ( std::string const &  oldBranchName)

Definition at line 115 of file RootTree.cc.

References scaleCards::br, entries(), i, python.Node::leaf, and tree_.

115  {
116  //use the translated branch name
117  TBranch* branch = tree_->GetBranch(oldBranchName.c_str());
118  if (branch != 0) {
119  TObjArray* leaves = tree_->GetListOfLeaves();
120  int entries = leaves->GetEntries();
121  for (int i = 0; i < entries; ++i) {
122  TLeaf* leaf = (TLeaf*)(*leaves)[i];
123  if (leaf == 0) continue;
124  TBranch* br = leaf->GetBranch();
125  if (br == 0) continue;
126  if (br->GetMother() == branch) {
127  leaves->Remove(leaf);
128  }
129  }
130  leaves->Compress();
131  tree_->GetListOfBranches()->Remove(branch);
132  tree_->GetListOfBranches()->Compress();
133  delete branch;
134  }
135  }
int i
Definition: DBlmapReader.cc:9
TTree * tree_
Definition: RootTree.h:133
EntryNumber const & entries() const
Definition: RootTree.h:85
tuple br
Definition: scaleCards.py:54
tuple leaf
Definition: Node.py:62
EntryNumber const& edm::RootTree::entries ( ) const
inline

Definition at line 85 of file RootTree.h.

References entries_.

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

85 {return entries_;}
EntryNumber entries_
Definition: RootTree.h:142
EntryNumber const& edm::RootTree::entryNumber ( ) const
inline
template<typename T >
void edm::RootTree::fillAux ( T *&  pAux)
inline

Definition at line 90 of file RootTree.h.

References auxBranch_, entryNumber_, and getEntry().

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

90  {
91  auxBranch_->SetAddress(&pAux);
93  }
EntryNumber entryNumber_
Definition: RootTree.h:143
TBranch * auxBranch_
Definition: RootTree.h:136
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:182
template<typename T >
void edm::RootTree::fillBranchEntry ( TBranch *  branch,
T *&  pbuf 
)
inline

Definition at line 106 of file RootTree.h.

References entryNumber_, and getEntry().

Referenced by edm::RootFile::fillHistory(), and edm::ReducedProvenanceReader::readProvenance().

106  {
107  branch->SetAddress(&pbuf);
108  getEntry(branch, entryNumber_);
109  }
EntryNumber entryNumber_
Definition: RootTree.h:143
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:182
template<typename T >
void edm::RootTree::fillBranchEntryMeta ( TBranch *  branch,
T *&  pbuf 
)
inline

Definition at line 95 of file RootTree.h.

References entryNumber_, edm::roottree::getEntry(), and metaTree_.

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

95  {
96  if (metaTree_ != 0) {
97  // Metadata was in separate tree. Not cached.
98  branch->SetAddress(&pbuf);
100  } else {
101  fillBranchEntry<T>(branch, pbuf);
102  }
103  }
EntryNumber entryNumber_
Definition: RootTree.h:143
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:273
TTree * metaTree_
Definition: RootTree.h:134
void edm::RootTree::getEntry ( TBranch *  branch,
EntryNumber  entry 
) const

Definition at line 182 of file RootTree.cc.

References cms::Exception::addContext(), alignCSCRings::e, filePtr_, edm::errors::FileReadError, rawTreeCache_, lumiQTWidget::t, and treeCache_.

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

182  {
183  try {
184  if (!treeCache_) {
185  filePtr_->SetCacheRead(0);
186  branch->GetEntry(entryNumber);
187  } else if (treeCache_->IsLearning() && rawTreeCache_) {
188  treeCache_->AddBranch(branch, kTRUE);
189  filePtr_->SetCacheRead(rawTreeCache_.get());
190  branch->GetEntry(entryNumber);
191  filePtr_->SetCacheRead(0);
192  } else {
193  filePtr_->SetCacheRead(treeCache_.get());
194  branch->GetEntry(entryNumber);
195  filePtr_->SetCacheRead(0);
196  }
197  } catch(cms::Exception const& e) {
198  // We make sure the treeCache_ is detached from the file,
199  // so that ROOT does not also delete it.
200  filePtr_->SetCacheRead(0);
202  t.addContext(std::string("Reading branch ")+branch->GetName());
203  throw t;
204  }
205  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:140
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:141
EntryNumber const & entryNumber() const
Definition: RootTree.h:84
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:129
bool edm::RootTree::isValid ( void  ) const

Definition at line 68 of file RootTree.cc.

References auxBranch_, branchEntryInfoBranch_, entries_, infoTree_, metaTree_, and tree_.

Referenced by addBranch(), edm::RootFile::fillIndexIntoFile(), edm::RootFile::readLumi(), edm::RootFile::readLuminosityBlockAuxiliary_(), edm::RootFile::readRun_(), edm::RootFile::readRunAuxiliary_(), setPresence(), and edm::RootFile::validateFile().

68  {
69  if (metaTree_ == 0 || metaTree_->GetNbranches() == 0) {
70  return tree_ != 0 && auxBranch_ != 0;
71  }
72  if (tree_ != 0 && auxBranch_ != 0 && metaTree_ != 0) { // backward compatibility
73  if (branchEntryInfoBranch_ != 0 || infoTree_ != 0) return true; // backward compatibility
74  return (entries_ == metaTree_->GetEntries() && tree_->GetNbranches() <= metaTree_->GetNbranches() + 1); // backward compatibility
75  } // backward compatibility
76  return false;
77  }
TTree * tree_
Definition: RootTree.h:133
TTree * metaTree_
Definition: RootTree.h:134
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:153
EntryNumber entries_
Definition: RootTree.h:142
TBranch * auxBranch_
Definition: RootTree.h:136
TTree * infoTree_
Definition: RootTree.h:155
TTree const* edm::RootTree::metaTree ( ) const
inline

Definition at line 113 of file RootTree.h.

References metaTree_.

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

113 {return metaTree_;}
TTree * metaTree_
Definition: RootTree.h:134
bool edm::RootTree::next ( void  )
inline
RootTree& edm::RootTree::operator= ( RootTree const &  )
delete
bool edm::RootTree::previous ( )
inline

Definition at line 80 of file RootTree.h.

References entryNumber_.

Referenced by BeautifulSoup.PageElement::_invert().

80 {return --entryNumber_ >= 0;}
EntryNumber entryNumber_
Definition: RootTree.h:143
void edm::RootTree::resetTraining ( )
inline

Definition at line 120 of file RootTree.h.

References trainNow_.

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

120 {trainNow_ = true;}
bool trainNow_
Definition: RootTree.h:146
void edm::RootTree::rewind ( )
inline

Definition at line 82 of file RootTree.h.

References entryNumber_.

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

82 {entryNumber_ = 0;}
EntryNumber entryNumber_
Definition: RootTree.h:143
DelayedReader * edm::RootTree::rootDelayedReader ( ) const

Definition at line 80 of file RootTree.cc.

References rootDelayedReader_.

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

80  {
81  rootDelayedReader_->reset();
82  return rootDelayedReader_.get();
83  }
std::unique_ptr< DelayedReader > rootDelayedReader_
Definition: RootTree.h:151
void edm::RootTree::setCacheSize ( unsigned int  cacheSize)
private

Definition at line 141 of file RootTree.cc.

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

Referenced by RootTree().

141  {
142  cacheSize_ = cacheSize;
143  tree_->SetCacheSize(static_cast<Long64_t>(cacheSize));
144  treeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
145  filePtr_->SetCacheRead(0);
146  rawTreeCache_.reset();
147  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:140
TTree * tree_
Definition: RootTree.h:133
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:141
unsigned int cacheSize_
Definition: RootTree.h:149
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:129
void edm::RootTree::setEntryNumber ( EntryNumber  theEntryNumber)

Definition at line 155 of file RootTree.cc.

References entries_, entryNumber_, filePtr_, startTraining(), stopTraining(), switchOverEntry_, trainNow_, tree_, treeAutoFlush_, and treeCache_.

Referenced by edm::RootFile::fillEventAuxiliary(), edm::RootFile::fillIndexIntoFile(), edm::RootFileEventFinder::getEventNumberOfEntry(), edm::RootFile::initializeDuplicateChecker(), edm::RootFile::readEvent(), edm::RootFile::readLumi(), edm::RootFile::readLuminosityBlockAuxiliary_(), edm::RootFile::readRunAuxiliary_(), edm::RootFile::setAtEventEntry(), edm::RootFile::setEntryAtEvent(), edm::RootFile::setEntryAtLumi(), edm::RootFile::setEntryAtNextEventInLumi(), edm::RootFile::setEntryAtRun(), and edm::RootFile::skipEvents().

155  {
156  filePtr_->SetCacheRead(treeCache_.get());
157 
158  // Detect a backward skip. If the skip is sufficiently large, we roll the dice and reset the treeCache.
159  // This will cause some amount of over-reading: we pre-fetch all the events in some prior cluster.
160  // However, because reading one event in the cluster is supposed to be equivalent to reading all events in the cluster,
161  // we're not incurring additional over-reading - we're just doing it more efficiently.
162  // NOTE: Constructor guarantees treeAutoFlush_ is positive, even if TTree->GetAutoFlush() is negative.
163  if ((theEntryNumber < static_cast<EntryNumber>(entryNumber_-treeAutoFlush_)) &&
164  (treeCache_) && (!treeCache_->IsLearning()) && (entries_ > 0) && (switchOverEntry_ >= 0)) {
165  treeCache_->SetEntryRange(theEntryNumber, entries_);
166  treeCache_->FillBuffer();
167  }
168 
169  entryNumber_ = theEntryNumber;
170  tree_->LoadTree(entryNumber_);
171  filePtr_->SetCacheRead(0);
172  if(treeCache_ && trainNow_ && entryNumber_ >= 0) {
173  startTraining();
174  trainNow_ = false;
175  }
176  if (treeCache_ && treeCache_->IsLearning() && switchOverEntry_ >= 0 && entryNumber_ >= switchOverEntry_) {
177  stopTraining();
178  }
179  }
EntryNumber entryNumber_
Definition: RootTree.h:143
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:140
TTree * tree_
Definition: RootTree.h:133
bool trainNow_
Definition: RootTree.h:146
void stopTraining()
Definition: RootTree.cc:232
EntryNumber entries_
Definition: RootTree.h:142
long int treeAutoFlush_
Definition: RootTree.h:150
void startTraining()
Definition: RootTree.cc:208
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:129
EntryNumber switchOverEntry_
Definition: RootTree.h:147
void edm::RootTree::setPresence ( BranchDescription const &  prod,
std::string const &  oldBranchName 
)

Definition at line 86 of file RootTree.cc.

References edm::BranchDescription::init(), isValid(), edm::BranchDescription::setDropped(), and tree_.

86  {
87  assert(isValid());
88  prod.init();
89  if(tree_->GetBranch(oldBranchName.c_str()) == 0){
90  prod.setDropped();
91  }
92  }
TTree * tree_
Definition: RootTree.h:133
bool isValid() const
Definition: RootTree.cc:68
void edm::RootTree::setTreeMaxVirtualSize ( int  treeMaxVirtualSize)
private

Definition at line 150 of file RootTree.cc.

References tree_.

Referenced by RootTree().

150  {
151  if (treeMaxVirtualSize >= 0) tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
152  }
TTree * tree_
Definition: RootTree.h:133
void edm::RootTree::startTraining ( )
private

Definition at line 208 of file RootTree.cc.

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

Referenced by setEntryNumber().

208  {
209  if (cacheSize_ == 0) {
210  return;
211  }
212  assert(treeCache_ && treeCache_->GetOwner() == tree_);
213  assert(branchType_ == InEvent);
214  assert(!rawTreeCache_);
215  treeCache_->SetLearnEntries(learningEntries_);
216  tree_->SetCacheSize(static_cast<Long64_t>(cacheSize_));
217  rawTreeCache_.reset(dynamic_cast<TTreeCache *>(filePtr_->GetCacheRead()));
218  filePtr_->SetCacheRead(0);
219  rawTreeCache_->SetLearnEntries(0);
221  rawTreeCache_->StartLearningPhase();
223  rawTreeCache_->AddBranch("*", kTRUE);
224  rawTreeCache_->StopLearningPhase();
225  treeCache_->StartLearningPhase();
226  treeCache_->SetEntryRange(switchOverEntry_, tree_->GetEntries());
227  treeCache_->AddBranch(poolNames::branchListIndexesBranchName().c_str(), kTRUE);
228  treeCache_->AddBranch(BranchTypeToAuxiliaryBranchName(branchType_).c_str(), kTRUE);
229  }
EntryNumber entryNumber_
Definition: RootTree.h:143
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:140
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:114
unsigned int learningEntries_
Definition: RootTree.h:148
TTree * tree_
Definition: RootTree.h:133
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:141
unsigned int cacheSize_
Definition: RootTree.h:149
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:129
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:241
EntryNumber switchOverEntry_
Definition: RootTree.h:147
BranchType branchType_
Definition: RootTree.h:135
void edm::RootTree::stopTraining ( )
private

Definition at line 232 of file RootTree.cc.

References filePtr_, rawTreeCache_, and treeCache_.

Referenced by setEntryNumber().

232  {
233  filePtr_->SetCacheRead(treeCache_.get());
234  treeCache_->StopLearningPhase();
235  rawTreeCache_.reset();
236  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:140
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:141
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:129
void edm::RootTree::trainCache ( char const *  branchNames)

Definition at line 253 of file RootTree.cc.

References cacheSize_, filePtr_, tree_, and treeCache_.

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

253  {
254  if (cacheSize_ == 0) {
255  return;
256  }
257  tree_->LoadTree(0);
258  assert(treeCache_);
259  filePtr_->SetCacheRead(treeCache_.get());
260  assert(treeCache_->GetOwner() == tree_);
261  treeCache_->StartLearningPhase();
262  treeCache_->SetEntryRange(0, tree_->GetEntries());
263  treeCache_->AddBranch(branchNames, kTRUE);
264  treeCache_->StopLearningPhase();
265  // We own the treeCache_.
266  // We make sure the treeCache_ is detached from the file,
267  // so that ROOT does not also delete it.
268  filePtr_->SetCacheRead(0);
269  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:140
std::vector< std::string > const & branchNames() const
Definition: RootTree.h:87
TTree * tree_
Definition: RootTree.h:133
unsigned int cacheSize_
Definition: RootTree.h:149
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:129
TTree const* edm::RootTree::tree ( ) const
inline
TTree* edm::RootTree::tree ( )
inline

Definition at line 112 of file RootTree.h.

References tree_.

Referenced by python.cmstools.EventTree::SetAlias().

112 {return tree_;}
TTree * tree_
Definition: RootTree.h:133

Member Data Documentation

TBranch* edm::RootTree::auxBranch_
private

Definition at line 136 of file RootTree.h.

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

TBranch* edm::RootTree::branchEntryInfoBranch_
private

Definition at line 153 of file RootTree.h.

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

boost::shared_ptr<BranchMap> edm::RootTree::branches_
private

Definition at line 145 of file RootTree.h.

Referenced by addBranch(), and branches().

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

Definition at line 144 of file RootTree.h.

Referenced by addBranch(), and branchNames().

BranchType edm::RootTree::branchType_
private

Definition at line 135 of file RootTree.h.

Referenced by branchType(), and startTraining().

unsigned int edm::RootTree::cacheSize_
private

Definition at line 149 of file RootTree.h.

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

EntryNumber edm::RootTree::entries_
private

Definition at line 142 of file RootTree.h.

Referenced by entries(), isValid(), next(), and setEntryNumber().

EntryNumber edm::RootTree::entryNumber_
private
boost::shared_ptr<InputFile> edm::RootTree::filePtr_
private
TTree* edm::RootTree::infoTree_
private

Definition at line 155 of file RootTree.h.

Referenced by close(), and isValid().

unsigned int edm::RootTree::learningEntries_
private

Definition at line 148 of file RootTree.h.

Referenced by startTraining().

TTree* edm::RootTree::metaTree_
private

Definition at line 134 of file RootTree.h.

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

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

Definition at line 141 of file RootTree.h.

Referenced by getEntry(), setCacheSize(), startTraining(), and stopTraining().

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

Definition at line 151 of file RootTree.h.

Referenced by rootDelayedReader().

TBranch* edm::RootTree::statusBranch_
private

Definition at line 156 of file RootTree.h.

EntryNumber edm::RootTree::switchOverEntry_
private

Definition at line 147 of file RootTree.h.

Referenced by setEntryNumber(), and startTraining().

bool edm::RootTree::trainNow_
private

Definition at line 146 of file RootTree.h.

Referenced by resetTraining(), and setEntryNumber().

TTree* edm::RootTree::tree_
private
long int edm::RootTree::treeAutoFlush_
private

Definition at line 150 of file RootTree.h.

Referenced by RootTree(), and setEntryNumber().

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