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
 
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, T *&pbuf)
 
template<typename T >
void fillBranchEntryMeta (TBranch *branch, EntryNumber entryNumber, T *&pbuf)
 
void getEntry (TBranch *branch, EntryNumber entry) const
 
void insertEntryForIndex (unsigned int index)
 
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 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 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_
 
bool enablePrefetching_
 
bool enableTriggerCache_
 
EntryNumber entries_
 
EntryNumber entryNumber_
 
std::unique_ptr< std::vector
< EntryNumber > > 
entryNumberForIndex_
 
boost::shared_ptr< InputFilefilePtr_
 
TTree * infoTree_
 
unsigned int learningEntries_
 
TTree * metaTree_
 
bool performedSwitchOver_
 
boost::shared_ptr< TTreeCache > rawTreeCache_
 
EntryNumber rawTriggerSwitchOverEntry_
 
boost::shared_ptr< TTreeCache > rawTriggerTreeCache_
 
std::unique_ptr< DelayedReaderrootDelayedReader_
 
TBranch * statusBranch_
 
EntryNumber switchOverEntry_
 
std::unordered_set< TBranch * > trainedSet_
 
bool trainNow_
 
TTree * tree_
 
unsigned long treeAutoFlush_
 
boost::shared_ptr< TTreeCache > treeCache_
 
std::unordered_set< TBranch * > triggerSet_
 
boost::shared_ptr< TTreeCache > triggerTreeCache_
 

Detailed Description

Definition at line 59 of file RootTree.h.

Member Typedef Documentation

Definition at line 61 of file RootTree.h.

Definition at line 62 of file RootTree.h.

Constructor & Destructor Documentation

edm::RootTree::RootTree ( boost::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 28 of file RootTree.cc.

References cacheSize_, learningEntries_, setCacheSize(), setTreeMaxVirtualSize(), trainedSet_, tree_, treeAutoFlush_, and triggerSet_.

35  :
36  filePtr_(filePtr),
37  tree_(dynamic_cast<TTree*>(filePtr_.get() != nullptr ? filePtr_->Get(BranchTypeToProductTreeName(branchType).c_str()) : nullptr)),
38  metaTree_(dynamic_cast<TTree*>(filePtr_.get() != nullptr ? filePtr_->Get(BranchTypeToMetaDataTreeName(branchType).c_str()) : nullptr)),
40  auxBranch_(tree_ ? getAuxiliaryBranch(tree_, branchType_) : nullptr),
41  treeCache_(),
42  rawTreeCache_(),
45  trainedSet_(),
46  triggerSet_(),
47  entries_(tree_ ? tree_->GetEntries() : 0),
48  entryNumber_(-1),
49  entryNumberForIndex_(new std::vector<EntryNumber>(nIndexes, IndexIntoFile::invalidEntry)),
50  branchNames_(),
51  branches_(new BranchMap),
52  trainNow_(false),
53  switchOverEntry_(-1),
55  learningEntries_(learningEntries),
56  cacheSize_(cacheSize),
57  treeAutoFlush_(0),
58  enablePrefetching_(enablePrefetching),
60  rootDelayedReader_(new RootDelayedReader(*this, filePtr, inputType)),
61  branchEntryInfoBranch_(metaTree_ ? getProductProvenanceBranch(metaTree_, branchType_) : (tree_ ? getProductProvenanceBranch(tree_, branchType_) : 0)),
62  infoTree_(dynamic_cast<TTree*>(filePtr_.get() != nullptr ? filePtr->Get(BranchTypeToInfoTreeName(branchType).c_str()) : nullptr)) // backward compatibility
63  {
64  assert(tree_);
65  // On merged files in older releases of ROOT, the autoFlush setting is always negative; we must guess.
66  // TODO: On newer merged files, we should be able to get this from the cluster iterator.
67  long treeAutoFlush = (tree_ ? tree_->GetAutoFlush() : 0);
68  if (treeAutoFlush < 0) {
69  // The "+1" is here to avoid divide-by-zero in degenerate cases.
70  Long64_t averageEventSizeBytes = tree_->GetZipBytes() / (tree_->GetEntries()+1) + 1;
71  treeAutoFlush_ = cacheSize_/averageEventSizeBytes+1;
72  } else {
73  treeAutoFlush_ = treeAutoFlush;
74  }
77  }
78  setTreeMaxVirtualSize(maxVirtualSize);
79  setCacheSize(cacheSize);
80  if (tree_) {
81  Int_t branchCount = tree_->GetListOfBranches()->GetEntriesFast();
82  trainedSet_.reserve(branchCount);
83  triggerSet_.reserve(branchCount);
84  }
85  }
EntryNumber entryNumber_
Definition: RootTree.h:176
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
Definition: BranchType.cc:106
unsigned int learningEntries_
Definition: RootTree.h:184
std::vector< std::string > branchNames_
Definition: RootTree.h:178
TTree * tree_
Definition: RootTree.h:162
bool trainNow_
Definition: RootTree.h:180
EntryNumber rawTriggerSwitchOverEntry_
Definition: RootTree.h:182
roottree::BranchMap BranchMap
Definition: RootTree.h:61
TTree * metaTree_
Definition: RootTree.h:163
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:173
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:193
EntryNumber entries_
Definition: RootTree.h:175
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:170
bool enablePrefetching_
Definition: RootTree.h:189
void setTreeMaxVirtualSize(int treeMaxVirtualSize)
Definition: RootTree.cc:184
boost::shared_ptr< TTreeCache > triggerTreeCache_
Definition: RootTree.h:171
boost::shared_ptr< TTreeCache > rawTriggerTreeCache_
Definition: RootTree.h:172
BranchType branchType() const
Definition: RootTree.h:151
unsigned long treeAutoFlush_
Definition: RootTree.h:186
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
Definition: BranchType.cc:102
TBranch * auxBranch_
Definition: RootTree.h:165
std::string const & BranchTypeToInfoTreeName(BranchType const &branchType)
Definition: BranchType.cc:110
bool enableTriggerCache_
Definition: RootTree.h:190
static EntryNumber_t const invalidEntry
boost::shared_ptr< BranchMap > branches_
Definition: RootTree.h:179
void setCacheSize(unsigned int cacheSize)
Definition: RootTree.cc:174
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
Definition: RootTree.h:177
unsigned int cacheSize_
Definition: RootTree.h:185
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:174
std::unique_ptr< DelayedReader > rootDelayedReader_
Definition: RootTree.h:191
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
EntryNumber switchOverEntry_
Definition: RootTree.h:181
BranchType branchType_
Definition: RootTree.h:164
TTree * infoTree_
Definition: RootTree.h:195
edm::RootTree::~RootTree ( )

Definition at line 87 of file RootTree.cc.

87  {
88  }
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 129 of file RootTree.cc.

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

131  {
132  assert(isValid());
133  //use the translated branch name
134  TBranch* branch = tree_->GetBranch(oldBranchName.c_str());
135  roottree::BranchInfo info = roottree::BranchInfo(BranchDescription(prod));
136  info.productBranch_ = nullptr;
137  if (prod.present()) {
138  info.productBranch_ = branch;
139  //we want the new branch name for the JobReport
140  branchNames_.push_back(prod.branchName());
141  }
142  TTree* provTree = (metaTree_ != nullptr ? metaTree_ : tree_);
143  info.provenanceBranch_ = provTree->GetBranch(oldBranchName.c_str());
144  branches_->insert(std::make_pair(key, info));
145  }
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< std::string > branchNames_
Definition: RootTree.h:178
TTree * tree_
Definition: RootTree.h:162
TTree * metaTree_
Definition: RootTree.h:163
boost::shared_ptr< BranchMap > branches_
Definition: RootTree.h:179
bool isValid() const
Definition: RootTree.cc:103
list key
Definition: combine.py:13
TBranch* edm::RootTree::branchEntryInfoBranch ( ) const
inline
roottree::BranchMap const & edm::RootTree::branches ( ) const

Definition at line 171 of file RootTree.cc.

References branches_.

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

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

Definition at line 96 of file RootTree.h.

References branchNames_.

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

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

Definition at line 151 of file RootTree.h.

References branchType_.

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

151 {return branchType_;}
BranchType branchType_
Definition: RootTree.h:164
TTreeCache * edm::RootTree::checkTriggerCache ( TBranch *  branch,
EntryNumber  entryNumber 
) const
inline

Definition at line 221 of file RootTree.cc.

References checkTriggerCacheImpl(), enableTriggerCache_, NULL, trainedSet_, and treeCache_.

Referenced by selectCache().

221  {
222  if (!treeCache_->IsAsyncReading() && enableTriggerCache_ && (trainedSet_.find(branch) == trainedSet_.end())) {
223  return checkTriggerCacheImpl(branch, entryNumber);
224  } else {
225  return NULL;
226  }
227  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:173
#define NULL
Definition: scimark2.h:8
TTreeCache * checkTriggerCacheImpl(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:232
EntryNumber const & entryNumber() const
Definition: RootTree.h:91
bool enableTriggerCache_
Definition: RootTree.h:190
TTreeCache * edm::RootTree::checkTriggerCacheImpl ( TBranch *  branch,
EntryNumber  entryNumber 
) const

Definition at line 232 of file RootTree.cc.

References branches(), entryNumber_, filePtr_, i, NULL, performedSwitchOver_, rawTriggerSwitchOverEntry_, rawTriggerTreeCache_, trainedSet_, tree_, triggerSet_, and triggerTreeCache_.

Referenced by checkTriggerCache().

232  {
233  // This branch is not going to be in the cache.
234  // Assume this is a "trigger pattern".
235  // Always make sure the branch is added to the trigger set.
236  if (triggerSet_.find(branch) == triggerSet_.end()) {
237  triggerSet_.insert(branch);
238  if (triggerTreeCache_.get()) { triggerTreeCache_->AddBranch(branch, kTRUE); }
239  }
240 
241  if (rawTriggerSwitchOverEntry_ < 0) {
242  // The trigger has never fired before. Take everything not in the
243  // trainedSet and load it from disk
244 
245  // Calculate the end of the next cluster; triggers in the next cluster
246  // will use the triggerCache, not the rawTriggerCache.
247  TTree::TClusterIterator clusterIter = tree_->GetClusterIterator(entryNumber);
249  rawTriggerSwitchOverEntry_ = clusterIter();
250  }
251 
252  // ROOT will automatically expand the cache to fit one cluster; hence, we use
253  // 5 MB as the cache size below
254  tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
255  rawTriggerTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
256  if(rawTriggerTreeCache_) rawTriggerTreeCache_->SetEnablePrefetching(false);
257  TObjArray *branches = tree_->GetListOfBranches();
258  int branchCount = branches->GetEntriesFast();
259 
260  // Train the rawTriggerCache to have everything not in the regular cache.
261  rawTriggerTreeCache_->SetLearnEntries(0);
263  for (int i=0;i<branchCount;i++) {
264  TBranch *tmp_branch = (TBranch*)branches->UncheckedAt(i);
265  if (trainedSet_.find(tmp_branch) != trainedSet_.end()) {
266  continue;
267  }
268  rawTriggerTreeCache_->AddBranch(tmp_branch, kTRUE);
269  }
270  performedSwitchOver_ = false;
271  rawTriggerTreeCache_->StopLearningPhase();
272  filePtr_->SetCacheRead(0);
273 
274  return rawTriggerTreeCache_.get();
276  // The raw trigger has fired and it contents are valid.
277  return rawTriggerTreeCache_.get();
278  } else if (rawTriggerSwitchOverEntry_ > 0) {
279  // The raw trigger has fired, but we are out of the cache. Use the
280  // triggerCache instead.
281  if (!performedSwitchOver_) {
282  rawTriggerTreeCache_.reset();
283  performedSwitchOver_ = true;
284 
285  // Train the triggerCache
286  tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
287  triggerTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
288  triggerTreeCache_->SetEnablePrefetching(false);
289  triggerTreeCache_->SetLearnEntries(0);
290  triggerTreeCache_->SetEntryRange(entryNumber, tree_->GetEntries());
291  for(std::unordered_set<TBranch*>::const_iterator it = triggerSet_.begin(), itEnd = triggerSet_.end();
292  it != itEnd;
293  it++)
294  {
295  triggerTreeCache_->AddBranch(*it, kTRUE);
296  }
297  triggerTreeCache_->StopLearningPhase();
298  filePtr_->SetCacheRead(0);
299  }
300  return triggerTreeCache_.get();
302  // The raw trigger has fired and it contents are valid.
303  return rawTriggerTreeCache_.get();
304  } else if (rawTriggerSwitchOverEntry_ > 0) {
305  // The raw trigger has fired, but we are out of the cache. Use the
306  // triggerCache instead.
307  if (!performedSwitchOver_) {
308  rawTriggerTreeCache_.reset();
309  performedSwitchOver_ = true;
310 
311  // Train the triggerCache
312  tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
313  triggerTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
314  triggerTreeCache_->SetEnablePrefetching(false);
315  triggerTreeCache_->SetLearnEntries(0);
316  triggerTreeCache_->SetEntryRange(entryNumber, tree_->GetEntries());
317  for(std::unordered_set<TBranch*>::const_iterator it = triggerSet_.begin(), itEnd = triggerSet_.end();
318  it != itEnd;
319  it++)
320  {
321  triggerTreeCache_->AddBranch(*it, kTRUE);
322  }
323  triggerTreeCache_->StopLearningPhase();
324  filePtr_->SetCacheRead(0);
325  }
326  return triggerTreeCache_.get();
327  }
328 
329  // By construction, this case should be impossible.
330  assert (false);
331  return NULL;
332  }
EntryNumber entryNumber_
Definition: RootTree.h:176
int i
Definition: DBlmapReader.cc:9
TTree * tree_
Definition: RootTree.h:162
EntryNumber rawTriggerSwitchOverEntry_
Definition: RootTree.h:182
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:173
#define NULL
Definition: scimark2.h:8
boost::shared_ptr< TTreeCache > triggerTreeCache_
Definition: RootTree.h:171
boost::shared_ptr< TTreeCache > rawTriggerTreeCache_
Definition: RootTree.h:172
EntryNumber const & entryNumber() const
Definition: RootTree.h:91
bool performedSwitchOver_
Definition: RootTree.h:183
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:174
BranchMap const & branches() const
Definition: RootTree.cc:171
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
void edm::RootTree::close ( void  )

Definition at line 407 of file RootTree.cc.

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

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

407  {
408  // The TFile is about to be closed, and destructed.
409  // Just to play it safe, zero all pointers to quantities that are owned by the TFile.
411  tree_ = metaTree_ = infoTree_ = nullptr;
412  // We own the treeCache_.
413  // We make sure the treeCache_ is detached from the file,
414  // so that ROOT does not also delete it.
415  filePtr_->SetCacheRead(0);
416  // We *must* delete the TTreeCache here because the TFilePrefetch object
417  // references the TFile. If TFile is closed, before the TTreeCache is
418  // deleted, the TFilePrefetch may continue to do TFile operations, causing
419  // deadlocks or exceptions.
420  treeCache_.reset();
421  rawTreeCache_.reset();
422  triggerTreeCache_.reset();
423  rawTriggerTreeCache_.reset();
424  // We give up our shared ownership of the TFile itself.
425  filePtr_.reset();
426  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
TTree * tree_
Definition: RootTree.h:162
TTree * metaTree_
Definition: RootTree.h:163
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:193
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:170
boost::shared_ptr< TTreeCache > triggerTreeCache_
Definition: RootTree.h:171
boost::shared_ptr< TTreeCache > rawTriggerTreeCache_
Definition: RootTree.h:172
TBranch * auxBranch_
Definition: RootTree.h:165
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
TTree * infoTree_
Definition: RootTree.h:195
bool edm::RootTree::current ( ) const
inline

Definition at line 87 of file RootTree.h.

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

87 {return entryNumber_ < entries_ && entryNumber_ >= 0;}
bool edm::RootTree::current ( EntryNumber  entry) const
inline

Definition at line 88 of file RootTree.h.

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

Definition at line 148 of file RootTree.cc.

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

148  {
149  //use the translated branch name
150  TBranch* branch = tree_->GetBranch(oldBranchName.c_str());
151  if (branch != nullptr) {
152  TObjArray* leaves = tree_->GetListOfLeaves();
153  int entries = leaves->GetEntries();
154  for (int i = 0; i < entries; ++i) {
155  TLeaf* leaf = (TLeaf*)(*leaves)[i];
156  if (leaf == nullptr) continue;
157  TBranch* br = leaf->GetBranch();
158  if (br == nullptr) continue;
159  if (br->GetMother() == branch) {
160  leaves->Remove(leaf);
161  }
162  }
163  leaves->Compress();
164  tree_->GetListOfBranches()->Remove(branch);
165  tree_->GetListOfBranches()->Compress();
166  delete branch;
167  }
168  }
int i
Definition: DBlmapReader.cc:9
TTree * tree_
Definition: RootTree.h:162
EntryNumber const & entries() const
Definition: RootTree.h:93
tuple leaf
Definition: Node.py:62
EntryNumber const& edm::RootTree::entries ( ) const
inline

Definition at line 93 of file RootTree.h.

References entries_.

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

93 {return entries_;}
EntryNumber entries_
Definition: RootTree.h:175
EntryNumber const& edm::RootTree::entryNumber ( ) const
inline
RootTree::EntryNumber const & edm::RootTree::entryNumberForIndex ( unsigned int  index) const

Definition at line 91 of file RootTree.cc.

References entryNumberForIndex_, getHLTprescales::index, and findQualityFiles::size.

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

91  {
92  assert(index < entryNumberForIndex_->size());
93  return (*entryNumberForIndex_)[index];
94  }
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
Definition: RootTree.h:177
tuple size
Write out results.
template<typename T >
void edm::RootTree::fillAux ( T *&  pAux)
inline

Definition at line 99 of file RootTree.h.

References auxBranch_, entryNumber_, and getEntry().

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

99  {
100  auxBranch_->SetAddress(&pAux);
102  }
EntryNumber entryNumber_
Definition: RootTree.h:176
TBranch * auxBranch_
Definition: RootTree.h:165
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:354
template<typename T >
void edm::RootTree::fillBranchEntry ( TBranch *  branch,
T *&  pbuf 
)
inline

Definition at line 115 of file RootTree.h.

References entryNumber_, and getEntry().

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

115  {
116  branch->SetAddress(&pbuf);
117  getEntry(branch, entryNumber_);
118  }
EntryNumber entryNumber_
Definition: RootTree.h:176
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:354
template<typename T >
void edm::RootTree::fillBranchEntry ( TBranch *  branch,
EntryNumber  entryNumber,
T *&  pbuf 
)
inline

Definition at line 132 of file RootTree.h.

References getEntry().

132  {
133  branch->SetAddress(&pbuf);
134  getEntry(branch, entryNumber);
135  }
EntryNumber const & entryNumber() const
Definition: RootTree.h:91
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:354
template<typename T >
void edm::RootTree::fillBranchEntryMeta ( TBranch *  branch,
T *&  pbuf 
)
inline

Definition at line 104 of file RootTree.h.

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

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

104  {
105  if (metaTree_ != 0) {
106  // Metadata was in separate tree. Not cached.
107  branch->SetAddress(&pbuf);
109  } else {
110  fillBranchEntry<T>(branch, pbuf);
111  }
112  }
EntryNumber entryNumber_
Definition: RootTree.h:176
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:460
TTree * metaTree_
Definition: RootTree.h:163
template<typename T >
void edm::RootTree::fillBranchEntryMeta ( TBranch *  branch,
EntryNumber  entryNumber,
T *&  pbuf 
)
inline

Definition at line 121 of file RootTree.h.

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

121  {
122  if (metaTree_ != 0) {
123  // Metadata was in separate tree. Not cached.
124  branch->SetAddress(&pbuf);
126  } else {
127  fillBranchEntry<T>(branch, entryNumber, pbuf);
128  }
129  }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:460
TTree * metaTree_
Definition: RootTree.h:163
EntryNumber const & entryNumber() const
Definition: RootTree.h:91
void edm::RootTree::getEntry ( TBranch *  branch,
EntryNumber  entry 
) const

Definition at line 354 of file RootTree.cc.

References cms::Exception::addContext(), alignCSCRings::e, filePtr_, edm::errors::FileReadError, selectCache(), AlCaHLTBitMon_QueryRunRegistry::string, and lumiQTWidget::t.

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

354  {
355  try {
356  TTreeCache * cache = selectCache(branch, entryNumber);
357  filePtr_->SetCacheRead(cache);
358  branch->GetEntry(entryNumber);
359  filePtr_->SetCacheRead(0);
360  } catch(cms::Exception const& e) {
361  // We make sure the treeCache_ is detached from the file,
362  // so that ROOT does not also delete it.
363  filePtr_->SetCacheRead(0);
365  t.addContext(std::string("Reading branch ")+branch->GetName());
366  throw t;
367  }
368  }
TTreeCache * selectCache(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:335
EntryNumber const & entryNumber() const
Definition: RootTree.h:91
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
void edm::RootTree::insertEntryForIndex ( unsigned int  index)

Definition at line 97 of file RootTree.cc.

References entryNumber(), getHLTprescales::index, and findQualityFiles::size.

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

97  {
98  assert(index < entryNumberForIndex_->size());
99  (*entryNumberForIndex_)[index] = entryNumber();
100  }
EntryNumber const & entryNumber() const
Definition: RootTree.h:91
tuple size
Write out results.
bool edm::RootTree::isValid ( void  ) const

Definition at line 103 of file RootTree.cc.

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

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

103  {
104  if (metaTree_ == nullptr || metaTree_->GetNbranches() == 0) {
105  return tree_ != nullptr && auxBranch_ != nullptr;
106  }
107  if (tree_ != nullptr && auxBranch_ != nullptr && metaTree_ != nullptr) { // backward compatibility
108  if (branchEntryInfoBranch_ != nullptr || infoTree_ != nullptr) return true; // backward compatibility
109  return (entries_ == metaTree_->GetEntries() && tree_->GetNbranches() <= metaTree_->GetNbranches() + 1); // backward compatibility
110  } // backward compatibility
111  return false;
112  }
TTree * tree_
Definition: RootTree.h:162
TTree * metaTree_
Definition: RootTree.h:163
TBranch * branchEntryInfoBranch_
Definition: RootTree.h:193
EntryNumber entries_
Definition: RootTree.h:175
TBranch * auxBranch_
Definition: RootTree.h:165
TTree * infoTree_
Definition: RootTree.h:195
TTree const* edm::RootTree::metaTree ( ) const
inline

Definition at line 139 of file RootTree.h.

References metaTree_.

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

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

Definition at line 86 of file RootTree.h.

References entryNumber_.

Referenced by BeautifulSoup.PageElement::_invert().

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

Definition at line 149 of file RootTree.h.

References trainNow_.

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

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

Definition at line 89 of file RootTree.h.

References entryNumber_.

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

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

Definition at line 115 of file RootTree.cc.

References rootDelayedReader_.

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

115  {
116  rootDelayedReader_->reset();
117  return rootDelayedReader_.get();
118  }
std::unique_ptr< DelayedReader > rootDelayedReader_
Definition: RootTree.h:191
TTreeCache * edm::RootTree::selectCache ( TBranch *  branch,
EntryNumber  entryNumber 
) const
inline

Definition at line 335 of file RootTree.cc.

References checkTriggerCache(), NULL, rawTreeCache_, trainedSet_, and treeCache_.

Referenced by getEntry().

335  {
336  TTreeCache *triggerCache = NULL;
337  if (!treeCache_) {
338  return NULL;
339  } else if (treeCache_->IsLearning() && rawTreeCache_) {
340  treeCache_->AddBranch(branch, kTRUE);
341  trainedSet_.insert(branch);
342  return rawTreeCache_.get();
343  } else if ((triggerCache = checkTriggerCache(branch, entryNumber))) {
344  // A NULL return value from checkTriggerCache indicates the trigger cache case
345  // does not apply, and we should continue below.
346  return triggerCache;
347  } else {
348  // The "normal" TTreeCache case.
349  return treeCache_.get();
350  }
351  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
TTreeCache * checkTriggerCache(TBranch *branch, EntryNumber entryNumber) const
Definition: RootTree.cc:221
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:173
#define NULL
Definition: scimark2.h:8
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:170
EntryNumber const & entryNumber() const
Definition: RootTree.h:91
void edm::RootTree::setCacheSize ( unsigned int  cacheSize)
private

Definition at line 174 of file RootTree.cc.

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

Referenced by RootTree().

174  {
175  cacheSize_ = cacheSize;
176  tree_->SetCacheSize(static_cast<Long64_t>(cacheSize));
177  treeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead()));
178  if(treeCache_) treeCache_->SetEnablePrefetching(enablePrefetching_);
179  filePtr_->SetCacheRead(0);
180  rawTreeCache_.reset();
181  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
TTree * tree_
Definition: RootTree.h:162
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:170
bool enablePrefetching_
Definition: RootTree.h:189
unsigned int cacheSize_
Definition: RootTree.h:185
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
void edm::RootTree::setEntryNumber ( EntryNumber  theEntryNumber)

Definition at line 189 of file RootTree.cc.

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

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

189  {
190  filePtr_->SetCacheRead(treeCache_.get());
191 
192  // Detect a backward skip. If the skip is sufficiently large, we roll the dice and reset the treeCache.
193  // This will cause some amount of over-reading: we pre-fetch all the events in some prior cluster.
194  // However, because reading one event in the cluster is supposed to be equivalent to reading all events in the cluster,
195  // we're not incurring additional over-reading - we're just doing it more efficiently.
196  // NOTE: Constructor guarantees treeAutoFlush_ is positive, even if TTree->GetAutoFlush() is negative.
197  if ((theEntryNumber < static_cast<EntryNumber>(entryNumber_-treeAutoFlush_)) &&
198  (treeCache_) && (!treeCache_->IsLearning()) && (entries_ > 0) && (switchOverEntry_ >= 0)) {
199  treeCache_->SetEntryRange(theEntryNumber, entries_);
200  treeCache_->FillBuffer();
201  }
202 
203  entryNumber_ = theEntryNumber;
204  tree_->LoadTree(entryNumber_);
205  filePtr_->SetCacheRead(0);
206  if(treeCache_ && trainNow_ && entryNumber_ >= 0) {
207  startTraining();
208  trainNow_ = false;
209  trainedSet_.clear();
210  triggerSet_.clear();
212  }
213  if (treeCache_ && treeCache_->IsLearning() && switchOverEntry_ >= 0 && entryNumber_ >= switchOverEntry_) {
214  stopTraining();
215  }
216  }
EntryNumber entryNumber_
Definition: RootTree.h:176
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
TTree * tree_
Definition: RootTree.h:162
bool trainNow_
Definition: RootTree.h:180
EntryNumber rawTriggerSwitchOverEntry_
Definition: RootTree.h:182
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:173
void stopTraining()
Definition: RootTree.cc:399
EntryNumber entries_
Definition: RootTree.h:175
unsigned long treeAutoFlush_
Definition: RootTree.h:186
void startTraining()
Definition: RootTree.cc:371
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:174
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
EntryNumber switchOverEntry_
Definition: RootTree.h:181
void edm::RootTree::setPresence ( BranchDescription prod,
std::string const &  oldBranchName 
)

Definition at line 121 of file RootTree.cc.

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

121  {
122  assert(isValid());
123  if(tree_->GetBranch(oldBranchName.c_str()) == nullptr){
124  prod.setDropped(true);
125  }
126  }
TTree * tree_
Definition: RootTree.h:162
bool isValid() const
Definition: RootTree.cc:103
void edm::RootTree::setTreeMaxVirtualSize ( int  treeMaxVirtualSize)
private

Definition at line 184 of file RootTree.cc.

References tree_.

Referenced by RootTree().

184  {
185  if (treeMaxVirtualSize >= 0) tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
186  }
TTree * tree_
Definition: RootTree.h:162
void edm::RootTree::startTraining ( )
private

Definition at line 371 of file RootTree.cc.

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

Referenced by setEntryNumber().

371  {
372  if (cacheSize_ == 0) {
373  return;
374  }
375  assert(treeCache_);
376  assert(branchType_ == InEvent);
377  assert(!rawTreeCache_);
378  treeCache_->SetLearnEntries(learningEntries_);
379  tree_->SetCacheSize(static_cast<Long64_t>(cacheSize_));
380  rawTreeCache_.reset(dynamic_cast<TTreeCache *>(filePtr_->GetCacheRead()));
381  rawTreeCache_->SetEnablePrefetching(false);
382  filePtr_->SetCacheRead(0);
383  rawTreeCache_->SetLearnEntries(0);
385  rawTreeCache_->StartLearningPhase();
387  rawTreeCache_->AddBranch("*", kTRUE);
388  rawTreeCache_->StopLearningPhase();
389  treeCache_->StartLearningPhase();
390  treeCache_->SetEntryRange(switchOverEntry_, tree_->GetEntries());
391  treeCache_->AddBranch(poolNames::branchListIndexesBranchName().c_str(), kTRUE);
392  treeCache_->AddBranch(BranchTypeToAuxiliaryBranchName(branchType_).c_str(), kTRUE);
393  trainedSet_.clear();
394  triggerSet_.clear();
395  assert(treeCache_->GetTree() == tree_);
396  }
EntryNumber entryNumber_
Definition: RootTree.h:176
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:114
unsigned int learningEntries_
Definition: RootTree.h:184
TTree * tree_
Definition: RootTree.h:162
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:173
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:170
unsigned int cacheSize_
Definition: RootTree.h:185
std::unordered_set< TBranch * > triggerSet_
Definition: RootTree.h:174
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:241
EntryNumber switchOverEntry_
Definition: RootTree.h:181
BranchType branchType_
Definition: RootTree.h:164
void edm::RootTree::stopTraining ( )
private

Definition at line 399 of file RootTree.cc.

References filePtr_, rawTreeCache_, and treeCache_.

Referenced by setEntryNumber().

399  {
400  filePtr_->SetCacheRead(treeCache_.get());
401  treeCache_->StopLearningPhase();
402  filePtr_->SetCacheRead(0);
403  rawTreeCache_.reset();
404  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
boost::shared_ptr< TTreeCache > rawTreeCache_
Definition: RootTree.h:170
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
void edm::RootTree::trainCache ( char const *  branchNames)

Definition at line 429 of file RootTree.cc.

References branches(), cacheSize_, filePtr_, i, trainedSet_, tree_, and treeCache_.

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

429  {
430  if (cacheSize_ == 0) {
431  return;
432  }
433  tree_->LoadTree(0);
434  assert(treeCache_);
435  filePtr_->SetCacheRead(treeCache_.get());
436  treeCache_->StartLearningPhase();
437  treeCache_->SetEntryRange(0, tree_->GetEntries());
438  treeCache_->AddBranch(branchNames, kTRUE);
439  treeCache_->StopLearningPhase();
440  assert(treeCache_->GetTree() == tree_);
441  // We own the treeCache_.
442  // We make sure the treeCache_ is detached from the file,
443  // so that ROOT does not also delete it.
444  filePtr_->SetCacheRead(0);
445 
446  // Must also manually add things to the trained set.
447  TObjArray *branches = tree_->GetListOfBranches();
448  int branchCount = branches->GetEntriesFast();
449  for (int i=0;i<branchCount;i++) {
450  TBranch *branch = (TBranch*)branches->UncheckedAt(i);
451  if ((branchNames[0] == '*') || (strcmp(branchNames, branch->GetName()) == 0)) {
452  trainedSet_.insert(branch);
453  }
454  }
455 
456  }
boost::shared_ptr< TTreeCache > treeCache_
Definition: RootTree.h:169
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > const & branchNames() const
Definition: RootTree.h:96
TTree * tree_
Definition: RootTree.h:162
std::unordered_set< TBranch * > trainedSet_
Definition: RootTree.h:173
unsigned int cacheSize_
Definition: RootTree.h:185
BranchMap const & branches() const
Definition: RootTree.cc:171
boost::shared_ptr< InputFile > filePtr_
Definition: RootTree.h:158
TTree const* edm::RootTree::tree ( ) const
inline
TTree* edm::RootTree::tree ( )
inline

Definition at line 138 of file RootTree.h.

References tree_.

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

138 {return tree_;}
TTree * tree_
Definition: RootTree.h:162

Member Data Documentation

TBranch* edm::RootTree::auxBranch_
private

Definition at line 165 of file RootTree.h.

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

TBranch* edm::RootTree::branchEntryInfoBranch_
private

Definition at line 193 of file RootTree.h.

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

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

Definition at line 179 of file RootTree.h.

Referenced by addBranch(), and branches().

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

Definition at line 178 of file RootTree.h.

Referenced by addBranch(), and branchNames().

BranchType edm::RootTree::branchType_
private

Definition at line 164 of file RootTree.h.

Referenced by branchType(), and startTraining().

unsigned int edm::RootTree::cacheSize_
private

Definition at line 185 of file RootTree.h.

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

bool edm::RootTree::enablePrefetching_
private

Definition at line 189 of file RootTree.h.

Referenced by setCacheSize().

bool edm::RootTree::enableTriggerCache_
private

Definition at line 190 of file RootTree.h.

Referenced by checkTriggerCache().

EntryNumber edm::RootTree::entries_
private

Definition at line 175 of file RootTree.h.

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

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

Definition at line 177 of file RootTree.h.

Referenced by entryNumberForIndex().

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

Definition at line 195 of file RootTree.h.

Referenced by close(), and isValid().

unsigned int edm::RootTree::learningEntries_
private

Definition at line 184 of file RootTree.h.

Referenced by RootTree(), and startTraining().

TTree* edm::RootTree::metaTree_
private

Definition at line 163 of file RootTree.h.

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

bool edm::RootTree::performedSwitchOver_
mutableprivate

Definition at line 183 of file RootTree.h.

Referenced by checkTriggerCacheImpl().

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

Definition at line 170 of file RootTree.h.

Referenced by close(), selectCache(), setCacheSize(), startTraining(), and stopTraining().

EntryNumber edm::RootTree::rawTriggerSwitchOverEntry_
mutableprivate

Definition at line 182 of file RootTree.h.

Referenced by checkTriggerCacheImpl(), and setEntryNumber().

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

Definition at line 172 of file RootTree.h.

Referenced by checkTriggerCacheImpl(), and close().

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

Definition at line 191 of file RootTree.h.

Referenced by rootDelayedReader().

TBranch* edm::RootTree::statusBranch_
private

Definition at line 196 of file RootTree.h.

EntryNumber edm::RootTree::switchOverEntry_
private

Definition at line 181 of file RootTree.h.

Referenced by setEntryNumber(), and startTraining().

std::unordered_set<TBranch*> edm::RootTree::trainedSet_
mutableprivate
bool edm::RootTree::trainNow_
private

Definition at line 180 of file RootTree.h.

Referenced by resetTraining(), and setEntryNumber().

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

Definition at line 186 of file RootTree.h.

Referenced by RootTree(), and setEntryNumber().

boost::shared_ptr<TTreeCache> edm::RootTree::treeCache_
private
std::unordered_set<TBranch*> edm::RootTree::triggerSet_
mutableprivate

Definition at line 174 of file RootTree.h.

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

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

Definition at line 171 of file RootTree.h.

Referenced by checkTriggerCacheImpl(), and close().