#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 () |
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 () |
RootTree & | operator= (RootTree const &) |
bool | previous () |
void | resetTraining () |
void | rewind () |
DelayedReader * | rootDelayedReader () const |
RootTree (boost::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int maxVirtualSize, unsigned int cacheSize, unsigned int learningEntries, bool enablePrefetching) | |
RootTree (RootTree const &) | |
TTreeCache * | selectCache (TBranch *branch, EntryNumber entryNumber) const |
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< BranchMap > | branches_ |
std::vector< std::string > | branchNames_ |
BranchType | branchType_ |
unsigned int | cacheSize_ |
bool | enablePrefetching_ |
bool | enableTriggerCache_ |
EntryNumber | entries_ |
EntryNumber | entryNumber_ |
boost::shared_ptr< InputFile > | filePtr_ |
TTree * | infoTree_ |
unsigned int | learningEntries_ |
TTree * | metaTree_ |
bool | performedSwitchOver_ |
boost::shared_ptr< TTreeCache > | rawTreeCache_ |
EntryNumber | rawTriggerSwitchOverEntry_ |
boost::shared_ptr< TTreeCache > | rawTriggerTreeCache_ |
std::unique_ptr< DelayedReader > | rootDelayedReader_ |
TBranch * | statusBranch_ |
EntryNumber | switchOverEntry_ |
std::unordered_set< TBranch * > | trainedSet_ |
bool | trainNow_ |
TTree * | tree_ |
long int | treeAutoFlush_ |
boost::shared_ptr< TTreeCache > | treeCache_ |
std::unordered_set< TBranch * > | triggerSet_ |
boost::shared_ptr< TTreeCache > | triggerTreeCache_ |
Definition at line 57 of file RootTree.h.
Definition at line 59 of file RootTree.h.
Definition at line 60 of file RootTree.h.
edm::RootTree::RootTree | ( | boost::shared_ptr< InputFile > | filePtr, |
BranchType const & | branchType, | ||
unsigned int | maxVirtualSize, | ||
unsigned int | cacheSize, | ||
unsigned int | learningEntries, | ||
bool | enablePrefetching | ||
) |
Definition at line 27 of file RootTree.cc.
References cacheSize_, learningEntries_, setCacheSize(), setTreeMaxVirtualSize(), trainedSet_, tree_, treeAutoFlush_, and triggerSet_.
: filePtr_(filePtr), tree_(dynamic_cast<TTree*>(filePtr_.get() != 0 ? filePtr_->Get(BranchTypeToProductTreeName(branchType).c_str()) : 0)), metaTree_(dynamic_cast<TTree*>(filePtr_.get() != 0 ? filePtr_->Get(BranchTypeToMetaDataTreeName(branchType).c_str()) : 0)), branchType_(branchType), auxBranch_(tree_ ? getAuxiliaryBranch(tree_, branchType_) : 0), treeCache_(), rawTreeCache_(), triggerTreeCache_(), rawTriggerTreeCache_(), trainedSet_(), triggerSet_(), entries_(tree_ ? tree_->GetEntries() : 0), entryNumber_(-1), branchNames_(), branches_(new BranchMap), trainNow_(false), switchOverEntry_(-1), rawTriggerSwitchOverEntry_(-1), learningEntries_(learningEntries), cacheSize_(cacheSize), treeAutoFlush_(tree_ ? tree_->GetAutoFlush() : 0), enablePrefetching_(enablePrefetching), enableTriggerCache_(branchType_ == InEvent), rootDelayedReader_(new RootDelayedReader(*this, filePtr)), branchEntryInfoBranch_(metaTree_ ? getProductProvenanceBranch(metaTree_, branchType_) : (tree_ ? getProductProvenanceBranch(tree_, branchType_) : 0)), infoTree_(dynamic_cast<TTree*>(filePtr_.get() != 0 ? filePtr->Get(BranchTypeToInfoTreeName(branchType).c_str()) : 0)) // backward compatibility { assert(tree_); // On merged files in older releases of ROOT, the autoFlush setting is always negative; we must guess. // TODO: On newer merged files, we should be able to get this from the cluster iterator. if (treeAutoFlush_ < 0) { // The "+1" is here to avoid divide-by-zero in degenerate cases. Long64_t averageEventSizeBytes = tree_->GetZipBytes() / (tree_->GetEntries()+1) + 1; treeAutoFlush_ = cacheSize_/averageEventSizeBytes+1; } if (treeAutoFlush_ < learningEntries_) { learningEntries_ = treeAutoFlush_; } setTreeMaxVirtualSize(maxVirtualSize); setCacheSize(cacheSize); if (tree_) { Int_t branchCount = tree_->GetListOfBranches()->GetEntriesFast(); trainedSet_.reserve(branchCount); triggerSet_.reserve(branchCount); } }
edm::RootTree::~RootTree | ( | ) |
Definition at line 80 of file RootTree.cc.
{ }
edm::RootTree::RootTree | ( | RootTree const & | ) |
void edm::RootTree::addBranch | ( | BranchKey const & | key, |
BranchDescription const & | prod, | ||
std::string const & | oldBranchName | ||
) |
Definition at line 111 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_.
{ assert(isValid()); prod.init(); //use the translated branch name TBranch* branch = tree_->GetBranch(oldBranchName.c_str()); roottree::BranchInfo info = roottree::BranchInfo(ConstBranchDescription(prod)); info.productBranch_ = 0; if (prod.present()) { info.productBranch_ = branch; //we want the new branch name for the JobReport branchNames_.push_back(prod.branchName()); } TTree* provTree = (metaTree_ != 0 ? metaTree_ : tree_); info.provenanceBranch_ = provTree->GetBranch(oldBranchName.c_str()); branches_->insert(std::make_pair(key, info)); }
TBranch* edm::RootTree::branchEntryInfoBranch | ( | ) | const [inline] |
Definition at line 119 of file RootTree.h.
References branchEntryInfoBranch_.
{return branchEntryInfoBranch_;}
roottree::BranchMap const & edm::RootTree::branches | ( | ) | const |
Definition at line 154 of file RootTree.cc.
References branches_.
Referenced by edm::RootDelayedReader::branches(), checkTriggerCacheImpl(), and trainCache().
{return *branches_;}
std::vector<std::string> const& edm::RootTree::branchNames | ( | ) | const [inline] |
BranchType edm::RootTree::branchType | ( | ) | const [inline] |
Definition at line 127 of file RootTree.h.
References branchType_.
Referenced by edm::ReducedProvenanceReader::ReducedProvenanceReader().
{return branchType_;}
TTreeCache * edm::RootTree::checkTriggerCache | ( | TBranch * | branch, |
EntryNumber | entryNumber | ||
) | const [inline] |
Definition at line 204 of file RootTree.cc.
References checkTriggerCacheImpl(), enableTriggerCache_, NULL, trainedSet_, and treeCache_.
Referenced by selectCache().
{ if (!treeCache_->IsAsyncReading() && enableTriggerCache_ && (trainedSet_.find(branch) == trainedSet_.end())) { return checkTriggerCacheImpl(branch, entryNumber); } else { return NULL; } }
TTreeCache * edm::RootTree::checkTriggerCacheImpl | ( | TBranch * | branch, |
EntryNumber | entryNumber | ||
) | const |
Definition at line 215 of file RootTree.cc.
References branches(), entryNumber_, filePtr_, i, NULL, performedSwitchOver_, rawTriggerSwitchOverEntry_, rawTriggerTreeCache_, trainedSet_, tree_, triggerSet_, and triggerTreeCache_.
Referenced by checkTriggerCache().
{ // This branch is not going to be in the cache. // Assume this is a "trigger pattern". // Always make sure the branch is added to the trigger set. if (triggerSet_.find(branch) == triggerSet_.end()) { triggerSet_.insert(branch); if (triggerTreeCache_.get()) { triggerTreeCache_->AddBranch(branch, kTRUE); } } if (rawTriggerSwitchOverEntry_ < 0) { // The trigger has never fired before. Take everything not in the // trainedSet and load it from disk // Calculate the end of the next cluster; triggers in the next cluster // will use the triggerCache, not the rawTriggerCache. TTree::TClusterIterator clusterIter = tree_->GetClusterIterator(entryNumber); while (rawTriggerSwitchOverEntry_ < entryNumber) { rawTriggerSwitchOverEntry_ = clusterIter(); } // ROOT will automatically expand the cache to fit one cluster; hence, we use // 5 MB as the cache size below tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024)); rawTriggerTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead())); if(rawTriggerTreeCache_) rawTriggerTreeCache_->SetEnablePrefetching(false); TObjArray *branches = tree_->GetListOfBranches(); int branchCount = branches->GetEntriesFast(); // Train the rawTriggerCache to have everything not in the regular cache. rawTriggerTreeCache_->SetLearnEntries(0); rawTriggerTreeCache_->SetEntryRange(entryNumber, rawTriggerSwitchOverEntry_); for (int i=0;i<branchCount;i++) { TBranch *tmp_branch = (TBranch*)branches->UncheckedAt(i); if (trainedSet_.find(tmp_branch) != trainedSet_.end()) { continue; } rawTriggerTreeCache_->AddBranch(tmp_branch, kTRUE); } performedSwitchOver_ = false; rawTriggerTreeCache_->StopLearningPhase(); filePtr_->SetCacheRead(0); return rawTriggerTreeCache_.get(); } else if (entryNumber_ < rawTriggerSwitchOverEntry_) { // The raw trigger has fired and it contents are valid. return rawTriggerTreeCache_.get(); } else if (rawTriggerSwitchOverEntry_ > 0) { // The raw trigger has fired, but we are out of the cache. Use the // triggerCache instead. if (!performedSwitchOver_) { rawTriggerTreeCache_.reset(); performedSwitchOver_ = true; // Train the triggerCache tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024)); triggerTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead())); triggerTreeCache_->SetEnablePrefetching(false); triggerTreeCache_->SetLearnEntries(0); triggerTreeCache_->SetEntryRange(entryNumber, tree_->GetEntries()); for(std::unordered_set<TBranch*>::const_iterator it = triggerSet_.begin(), itEnd = triggerSet_.end(); it != itEnd; it++) { triggerTreeCache_->AddBranch(*it, kTRUE); } triggerTreeCache_->StopLearningPhase(); filePtr_->SetCacheRead(0); } return triggerTreeCache_.get(); } else if (entryNumber_ < rawTriggerSwitchOverEntry_) { // The raw trigger has fired and it contents are valid. return rawTriggerTreeCache_.get(); } else if (rawTriggerSwitchOverEntry_ > 0) { // The raw trigger has fired, but we are out of the cache. Use the // triggerCache instead. if (!performedSwitchOver_) { rawTriggerTreeCache_.reset(); performedSwitchOver_ = true; // Train the triggerCache tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024)); triggerTreeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead())); triggerTreeCache_->SetEnablePrefetching(false); triggerTreeCache_->SetLearnEntries(0); triggerTreeCache_->SetEntryRange(entryNumber, tree_->GetEntries()); for(std::unordered_set<TBranch*>::const_iterator it = triggerSet_.begin(), itEnd = triggerSet_.end(); it != itEnd; it++) { triggerTreeCache_->AddBranch(*it, kTRUE); } triggerTreeCache_->StopLearningPhase(); filePtr_->SetCacheRead(0); } return triggerTreeCache_.get(); } // By construction, this case should be impossible. assert (false); return NULL; }
void edm::RootTree::close | ( | void | ) |
Definition at line 390 of file RootTree.cc.
References auxBranch_, branchEntryInfoBranch_, filePtr_, infoTree_, metaTree_, rawTreeCache_, rawTriggerTreeCache_, tree_, treeCache_, and triggerTreeCache_.
{ // The TFile is about to be closed, and destructed. // Just to play it safe, zero all pointers to quantities that are owned by the TFile. auxBranch_ = branchEntryInfoBranch_ = 0; tree_ = metaTree_ = infoTree_ = 0; // We own the treeCache_. // We make sure the treeCache_ is detached from the file, // so that ROOT does not also delete it. filePtr_->SetCacheRead(0); // We *must* delete the TTreeCache here because the TFilePrefetch object // references the TFile. If TFile is closed, before the TTreeCache is // deleted, the TFilePrefetch may continue to do TFile operations, causing // deadlocks or exceptions. treeCache_.reset(); rawTreeCache_.reset(); triggerTreeCache_.reset(); rawTriggerTreeCache_.reset(); // We give up our shared ownership of the TFile itself. filePtr_.reset(); }
bool edm::RootTree::current | ( | ) | [inline] |
Definition at line 83 of file RootTree.h.
Referenced by edm::RootFile::readLuminosityBlockAuxiliary_(), and edm::RootFile::readRunAuxiliary_().
{return entryNumber_ < entries_ && entryNumber_ >= 0;}
void edm::RootTree::dropBranch | ( | std::string const & | oldBranchName | ) |
Definition at line 131 of file RootTree.cc.
References beamvalidation::br, entries(), i, python::Node::leaf, and tree_.
{ //use the translated branch name TBranch* branch = tree_->GetBranch(oldBranchName.c_str()); if (branch != 0) { TObjArray* leaves = tree_->GetListOfLeaves(); int entries = leaves->GetEntries(); for (int i = 0; i < entries; ++i) { TLeaf* leaf = (TLeaf*)(*leaves)[i]; if (leaf == 0) continue; TBranch* br = leaf->GetBranch(); if (br == 0) continue; if (br->GetMother() == branch) { leaves->Remove(leaf); } } leaves->Compress(); tree_->GetListOfBranches()->Remove(branch); tree_->GetListOfBranches()->Compress(); delete branch; } }
EntryNumber const& edm::RootTree::entries | ( | ) | const [inline] |
Definition at line 87 of file RootTree.h.
References entries_.
Referenced by dropBranch().
{return entries_;}
EntryNumber const& edm::RootTree::entryNumber | ( | ) | const [inline] |
Definition at line 86 of file RootTree.h.
References entryNumber_.
Referenced by edm::RootDelayedReader::entryNumber(), edm::RootFile::readLuminosityBlockAuxiliary_(), and edm::RootFile::readRunAuxiliary_().
{return entryNumber_;}
void edm::RootTree::fillAux | ( | T *& | pAux | ) | [inline] |
Definition at line 92 of file RootTree.h.
References auxBranch_, entryNumber_, and getEntry().
{ auxBranch_->SetAddress(&pAux); getEntry(auxBranch_, entryNumber_); }
void edm::RootTree::fillBranchEntry | ( | TBranch * | branch, |
T *& | pbuf | ||
) | [inline] |
Definition at line 108 of file RootTree.h.
References entryNumber_, and getEntry().
{ branch->SetAddress(&pbuf); getEntry(branch, entryNumber_); }
void edm::RootTree::fillBranchEntryMeta | ( | TBranch * | branch, |
T *& | pbuf | ||
) | [inline] |
Definition at line 97 of file RootTree.h.
References entryNumber_, getEntry(), and metaTree_.
{ if (metaTree_ != 0) { // Metadata was in separate tree. Not cached. branch->SetAddress(&pbuf); roottree::getEntry(branch, entryNumber_); } else { fillBranchEntry<T>(branch, pbuf); } }
void edm::RootTree::getEntry | ( | TBranch * | branch, |
EntryNumber | entry | ||
) | const |
Definition at line 337 of file RootTree.cc.
References cms::Exception::addContext(), tests::test_CacheProxy::cache, alignCSCRings::e, filePtr_, edm::errors::FileReadError, selectCache(), AlCaHLTBitMon_QueryRunRegistry::string, and lumiQTWidget::t.
Referenced by fillAux(), fillBranchEntry(), and fillBranchEntryMeta().
{ try { TTreeCache * cache = selectCache(branch, entryNumber); filePtr_->SetCacheRead(cache); branch->GetEntry(entryNumber); filePtr_->SetCacheRead(0); } catch(cms::Exception const& e) { // We make sure the treeCache_ is detached from the file, // so that ROOT does not also delete it. filePtr_->SetCacheRead(0); Exception t(errors::FileReadError, "", e); t.addContext(std::string("Reading branch ")+branch->GetName()); throw t; } }
bool edm::RootTree::isValid | ( | void | ) | const |
Definition at line 84 of file RootTree.cc.
References auxBranch_, branchEntryInfoBranch_, entries_, infoTree_, metaTree_, and tree_.
Referenced by addBranch(), and setPresence().
{ if (metaTree_ == 0 || metaTree_->GetNbranches() == 0) { return tree_ != 0 && auxBranch_ != 0; } if (tree_ != 0 && auxBranch_ != 0 && metaTree_ != 0) { // backward compatibility if (branchEntryInfoBranch_ != 0 || infoTree_ != 0) return true; // backward compatibility return (entries_ == metaTree_->GetEntries() && tree_->GetNbranches() <= metaTree_->GetNbranches() + 1); // backward compatibility } // backward compatibility return false; }
TTree const* edm::RootTree::metaTree | ( | ) | const [inline] |
bool edm::RootTree::next | ( | void | ) | [inline] |
Definition at line 81 of file RootTree.h.
References entries_, and entryNumber_.
Referenced by edm::RootFile::initializeDuplicateChecker(), and edm::RootFile::nextEventEntry().
{return ++entryNumber_ < entries_;}
bool edm::RootTree::previous | ( | ) | [inline] |
void edm::RootTree::resetTraining | ( | ) | [inline] |
Definition at line 125 of file RootTree.h.
References trainNow_.
Referenced by edm::RootFile::RootFile().
{trainNow_ = true;}
void edm::RootTree::rewind | ( | ) | [inline] |
Definition at line 84 of file RootTree.h.
References entryNumber_.
Referenced by edm::RootFile::rewind().
{entryNumber_ = 0;}
DelayedReader * edm::RootTree::rootDelayedReader | ( | ) | const |
Definition at line 96 of file RootTree.cc.
References rootDelayedReader_.
{ rootDelayedReader_->reset(); return rootDelayedReader_.get(); }
TTreeCache * edm::RootTree::selectCache | ( | TBranch * | branch, |
EntryNumber | entryNumber | ||
) | const [inline] |
Definition at line 318 of file RootTree.cc.
References checkTriggerCache(), NULL, rawTreeCache_, trainedSet_, and treeCache_.
Referenced by getEntry().
{ TTreeCache *triggerCache = NULL; if (!treeCache_) { return NULL; } else if (treeCache_->IsLearning() && rawTreeCache_) { treeCache_->AddBranch(branch, kTRUE); trainedSet_.insert(branch); return rawTreeCache_.get(); } else if ((triggerCache = checkTriggerCache(branch, entryNumber))) { // A NULL return value from checkTriggerCache indicates the trigger cache case // does not apply, and we should continue below. return triggerCache; } else { // The "normal" TTreeCache case. return treeCache_.get(); } }
void edm::RootTree::setCacheSize | ( | unsigned int | cacheSize | ) | [private] |
Definition at line 157 of file RootTree.cc.
References cacheSize_, enablePrefetching_, filePtr_, rawTreeCache_, tree_, and treeCache_.
Referenced by RootTree().
{ cacheSize_ = cacheSize; tree_->SetCacheSize(static_cast<Long64_t>(cacheSize)); treeCache_.reset(dynamic_cast<TTreeCache*>(filePtr_->GetCacheRead())); if(treeCache_) treeCache_->SetEnablePrefetching(enablePrefetching_); filePtr_->SetCacheRead(0); rawTreeCache_.reset(); }
void edm::RootTree::setEntryNumber | ( | EntryNumber | theEntryNumber | ) |
Definition at line 172 of file RootTree.cc.
References entries_, entryNumber_, filePtr_, rawTriggerSwitchOverEntry_, startTraining(), stopTraining(), switchOverEntry_, trainedSet_, trainNow_, tree_, treeAutoFlush_, treeCache_, and triggerSet_.
Referenced by edm::RootFile::initializeDuplicateChecker(), edm::RootFile::readLuminosityBlockAuxiliary_(), edm::RootFile::readRunAuxiliary_(), and edm::RootFile::skipEvents().
{ filePtr_->SetCacheRead(treeCache_.get()); // Detect a backward skip. If the skip is sufficiently large, we roll the dice and reset the treeCache. // This will cause some amount of over-reading: we pre-fetch all the events in some prior cluster. // However, because reading one event in the cluster is supposed to be equivalent to reading all events in the cluster, // we're not incurring additional over-reading - we're just doing it more efficiently. // NOTE: Constructor guarantees treeAutoFlush_ is positive, even if TTree->GetAutoFlush() is negative. if ((theEntryNumber < static_cast<EntryNumber>(entryNumber_-treeAutoFlush_)) && (treeCache_) && (!treeCache_->IsLearning()) && (entries_ > 0) && (switchOverEntry_ >= 0)) { treeCache_->SetEntryRange(theEntryNumber, entries_); treeCache_->FillBuffer(); } entryNumber_ = theEntryNumber; tree_->LoadTree(entryNumber_); filePtr_->SetCacheRead(0); if(treeCache_ && trainNow_ && entryNumber_ >= 0) { startTraining(); trainNow_ = false; trainedSet_.clear(); triggerSet_.clear(); rawTriggerSwitchOverEntry_ = -1; } if (treeCache_ && treeCache_->IsLearning() && switchOverEntry_ >= 0 && entryNumber_ >= switchOverEntry_) { stopTraining(); } }
void edm::RootTree::setPresence | ( | BranchDescription const & | prod, |
std::string const & | oldBranchName | ||
) |
Definition at line 102 of file RootTree.cc.
References edm::BranchDescription::init(), isValid(), edm::BranchDescription::setDropped(), and tree_.
void edm::RootTree::setTreeMaxVirtualSize | ( | int | treeMaxVirtualSize | ) | [private] |
Definition at line 167 of file RootTree.cc.
References tree_.
Referenced by RootTree().
{ if (treeMaxVirtualSize >= 0) tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize)); }
void edm::RootTree::startTraining | ( | ) | [private] |
Definition at line 354 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().
{ if (cacheSize_ == 0) { return; } assert(treeCache_); assert(branchType_ == InEvent); assert(!rawTreeCache_); treeCache_->SetLearnEntries(learningEntries_); tree_->SetCacheSize(static_cast<Long64_t>(cacheSize_)); rawTreeCache_.reset(dynamic_cast<TTreeCache *>(filePtr_->GetCacheRead())); rawTreeCache_->SetEnablePrefetching(false); filePtr_->SetCacheRead(0); rawTreeCache_->SetLearnEntries(0); switchOverEntry_ = entryNumber_ + learningEntries_; rawTreeCache_->StartLearningPhase(); rawTreeCache_->SetEntryRange(entryNumber_, switchOverEntry_); rawTreeCache_->AddBranch("*", kTRUE); rawTreeCache_->StopLearningPhase(); treeCache_->StartLearningPhase(); treeCache_->SetEntryRange(switchOverEntry_, tree_->GetEntries()); treeCache_->AddBranch(poolNames::branchListIndexesBranchName().c_str(), kTRUE); treeCache_->AddBranch(BranchTypeToAuxiliaryBranchName(branchType_).c_str(), kTRUE); trainedSet_.clear(); triggerSet_.clear(); assert(treeCache_->GetTree() == tree_); }
void edm::RootTree::stopTraining | ( | ) | [private] |
Definition at line 382 of file RootTree.cc.
References filePtr_, rawTreeCache_, and treeCache_.
Referenced by setEntryNumber().
{ filePtr_->SetCacheRead(treeCache_.get()); treeCache_->StopLearningPhase(); filePtr_->SetCacheRead(0); rawTreeCache_.reset(); }
void edm::RootTree::trainCache | ( | char const * | branchNames | ) |
Definition at line 412 of file RootTree.cc.
References branches(), cacheSize_, filePtr_, i, trainedSet_, tree_, and treeCache_.
Referenced by edm::RootFile::RootFile().
{ if (cacheSize_ == 0) { return; } tree_->LoadTree(0); assert(treeCache_); filePtr_->SetCacheRead(treeCache_.get()); treeCache_->StartLearningPhase(); treeCache_->SetEntryRange(0, tree_->GetEntries()); treeCache_->AddBranch(branchNames, kTRUE); treeCache_->StopLearningPhase(); assert(treeCache_->GetTree() == tree_); // We own the treeCache_. // We make sure the treeCache_ is detached from the file, // so that ROOT does not also delete it. filePtr_->SetCacheRead(0); // Must also manually add things to the trained set. TObjArray *branches = tree_->GetListOfBranches(); int branchCount = branches->GetEntriesFast(); for (int i=0;i<branchCount;i++) { TBranch *branch = (TBranch*)branches->UncheckedAt(i); if ((branchNames[0] == '*') || (strcmp(branchNames, branch->GetName()) == 0)) { trainedSet_.insert(branch); } } }
TTree const* edm::RootTree::tree | ( | ) | const [inline] |
Definition at line 113 of file RootTree.h.
References tree_.
Referenced by edm::ReducedProvenanceReader::ReducedProvenanceReader().
{return tree_;}
TTree* edm::RootTree::tree | ( | ) | [inline] |
TBranch* edm::RootTree::auxBranch_ [private] |
Definition at line 141 of file RootTree.h.
TBranch* edm::RootTree::branchEntryInfoBranch_ [private] |
Definition at line 168 of file RootTree.h.
Referenced by branchEntryInfoBranch(), close(), and isValid().
boost::shared_ptr<BranchMap> edm::RootTree::branches_ [private] |
Definition at line 154 of file RootTree.h.
Referenced by addBranch(), and branches().
std::vector<std::string> edm::RootTree::branchNames_ [private] |
Definition at line 153 of file RootTree.h.
Referenced by addBranch(), and branchNames().
BranchType edm::RootTree::branchType_ [private] |
Definition at line 140 of file RootTree.h.
Referenced by branchType(), and startTraining().
unsigned int edm::RootTree::cacheSize_ [private] |
Definition at line 160 of file RootTree.h.
Referenced by RootTree(), setCacheSize(), startTraining(), and trainCache().
bool edm::RootTree::enablePrefetching_ [private] |
Definition at line 164 of file RootTree.h.
Referenced by setCacheSize().
bool edm::RootTree::enableTriggerCache_ [private] |
Definition at line 165 of file RootTree.h.
Referenced by checkTriggerCache().
EntryNumber edm::RootTree::entries_ [private] |
Definition at line 151 of file RootTree.h.
Referenced by entries(), isValid(), next(), and setEntryNumber().
EntryNumber edm::RootTree::entryNumber_ [private] |
Definition at line 152 of file RootTree.h.
Referenced by checkTriggerCacheImpl(), entryNumber(), fillAux(), fillBranchEntry(), fillBranchEntryMeta(), next(), previous(), rewind(), setEntryNumber(), and startTraining().
boost::shared_ptr<InputFile> edm::RootTree::filePtr_ [private] |
Definition at line 134 of file RootTree.h.
Referenced by checkTriggerCacheImpl(), close(), getEntry(), setCacheSize(), setEntryNumber(), startTraining(), stopTraining(), and trainCache().
TTree* edm::RootTree::infoTree_ [private] |
Definition at line 170 of file RootTree.h.
unsigned int edm::RootTree::learningEntries_ [private] |
Definition at line 159 of file RootTree.h.
Referenced by RootTree(), and startTraining().
TTree* edm::RootTree::metaTree_ [private] |
Definition at line 139 of file RootTree.h.
Referenced by addBranch(), close(), fillBranchEntryMeta(), isValid(), and metaTree().
bool edm::RootTree::performedSwitchOver_ [mutable, private] |
Definition at line 158 of file RootTree.h.
Referenced by checkTriggerCacheImpl().
boost::shared_ptr<TTreeCache> edm::RootTree::rawTreeCache_ [private] |
Definition at line 146 of file RootTree.h.
Referenced by close(), selectCache(), setCacheSize(), startTraining(), and stopTraining().
EntryNumber edm::RootTree::rawTriggerSwitchOverEntry_ [mutable, private] |
Definition at line 157 of file RootTree.h.
Referenced by checkTriggerCacheImpl(), and setEntryNumber().
boost::shared_ptr<TTreeCache> edm::RootTree::rawTriggerTreeCache_ [mutable, private] |
Definition at line 148 of file RootTree.h.
Referenced by checkTriggerCacheImpl(), and close().
std::unique_ptr<DelayedReader> edm::RootTree::rootDelayedReader_ [private] |
Definition at line 166 of file RootTree.h.
Referenced by rootDelayedReader().
TBranch* edm::RootTree::statusBranch_ [private] |
Definition at line 171 of file RootTree.h.
EntryNumber edm::RootTree::switchOverEntry_ [private] |
Definition at line 156 of file RootTree.h.
Referenced by setEntryNumber(), and startTraining().
std::unordered_set<TBranch*> edm::RootTree::trainedSet_ [mutable, private] |
Definition at line 149 of file RootTree.h.
Referenced by checkTriggerCache(), checkTriggerCacheImpl(), RootTree(), selectCache(), setEntryNumber(), startTraining(), and trainCache().
bool edm::RootTree::trainNow_ [private] |
Definition at line 155 of file RootTree.h.
Referenced by resetTraining(), and setEntryNumber().
TTree* edm::RootTree::tree_ [private] |
Definition at line 138 of file RootTree.h.
Referenced by addBranch(), checkTriggerCacheImpl(), close(), dropBranch(), isValid(), RootTree(), setCacheSize(), setEntryNumber(), setPresence(), setTreeMaxVirtualSize(), startTraining(), trainCache(), and tree().
long int edm::RootTree::treeAutoFlush_ [private] |
Definition at line 161 of file RootTree.h.
Referenced by RootTree(), and setEntryNumber().
boost::shared_ptr<TTreeCache> edm::RootTree::treeCache_ [private] |
Definition at line 145 of file RootTree.h.
Referenced by checkTriggerCache(), close(), selectCache(), setCacheSize(), setEntryNumber(), startTraining(), stopTraining(), and trainCache().
std::unordered_set<TBranch*> edm::RootTree::triggerSet_ [mutable, private] |
Definition at line 150 of file RootTree.h.
Referenced by checkTriggerCacheImpl(), RootTree(), setEntryNumber(), and startTraining().
boost::shared_ptr<TTreeCache> edm::RootTree::triggerTreeCache_ [mutable, private] |
Definition at line 147 of file RootTree.h.
Referenced by checkTriggerCacheImpl(), and close().