8 #include "TTreeCache.h" 15 TBranch* getAuxiliaryBranch(TTree*
tree,
BranchType const& branchType) {
22 TBranch* getProductProvenanceBranch(TTree*
tree,
BranchType const& branchType) {
32 unsigned int nIndexes,
33 unsigned int learningEntries,
34 bool enablePrefetching,
37 branchType_(branchType),
39 learningEntries_(learningEntries),
40 enablePrefetching_(enablePrefetching),
41 enableTriggerCache_(branchType_ ==
InEvent),
47 unsigned int nIndexes,
48 unsigned int maxVirtualSize,
49 unsigned int cacheSize,
50 unsigned int learningEntries,
51 bool enablePrefetching,
53 :
RootTree(filePtr, branchType, nIndexes, learningEntries, enablePrefetching, inputType) {
67 unsigned int nIndexes,
68 unsigned int maxVirtualSize,
69 unsigned int cacheSize,
70 unsigned int learningEntries,
71 bool enablePrefetching,
73 :
RootTree(filePtr, branchType, nIndexes, learningEntries, enablePrefetching, inputType) {
80 tree_ =
dynamic_cast<TTree*
>(
filePtr_->Get(productTreeName.c_str()));
84 <<
"The ROOT file does not contain a TTree named " << productTreeName
85 <<
"\n This is either not an edm ROOT file or is one that has been corrupted.";
91 long treeAutoFlush =
tree_->GetAutoFlush();
92 if (treeAutoFlush < 0) {
94 Long64_t averageEventSizeBytes =
tree_->GetZipBytes() / (
tree_->GetEntries() + 1) + 1;
105 Int_t branchCount =
tree_->GetListOfBranches()->GetEntriesFast();
114 assert(index < entryNumberForIndex_->size());
119 assert(index < entryNumberForIndex_->size());
126 return tree_ !=
nullptr;
151 if (
tree_->GetBranch(oldBranchName.c_str()) ==
nullptr) {
152 prod.setDropped(
true);
159 TBranch*
branch =
tree_->GetBranch(oldBranchName.c_str());
161 info.productBranch_ =
nullptr;
162 if (
prod.present()) {
172 TBranch*
branch =
tree_->GetBranch(oldBranchName.c_str());
174 TObjArray* leaves =
tree_->GetListOfLeaves();
175 int entries = leaves->GetEntries();
177 TLeaf* leaf = (TLeaf*)(*leaves)[
i];
180 TBranch*
br = leaf->GetBranch();
184 leaves->Remove(leaf);
189 tree_->GetListOfBranches()->Compress();
198 tree_->SetCacheSize(static_cast<Long64_t>(cacheSize));
207 if (treeMaxVirtualSize >= 0)
208 tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
227 if (theEntryNumber < entryNumber_ and theEntryNumber >= 0) {
243 TTree::TClusterIterator clusterIter =
tree_->GetClusterIterator(theEntryNumber);
303 TTree::TClusterIterator clusterIter =
tree_->GetClusterIterator(
entryNumber);
310 tree_->SetCacheSize(static_cast<Long64_t>(5 * 1024 * 1024));
315 int branchCount =
branches->GetEntriesFast();
320 for (
int i = 0;
i < branchCount;
i++) {
321 TBranch* tmp_branch = (TBranch*)
branches->UncheckedAt(
i);
343 tree_->SetCacheSize(static_cast<Long64_t>(5 * 1024 * 1024));
365 TTreeCache* triggerCache =
nullptr;
404 t <<
"An exception of unknown type was thrown.";
444 rawEnd =
tree_->GetEntries();
510 int branchCount =
branches->GetEntriesFast();
511 for (
int i = 0;
i < branchCount;
i++) {
530 n =
branch->GetEntry(entryNumber);
540 n =
tree->GetEntry(entryNumber);
549 unsigned int cacheSize,
552 tree->SetCacheSize(cacheSize);
553 std::unique_ptr<TTreeCache> treeCache(dynamic_cast<TTreeCache*>(
file.GetCacheRead()));
554 if (
nullptr != treeCache.get()) {
555 treeCache->StartLearningPhase();
556 treeCache->SetEntryRange(0,
tree->GetEntries());
558 treeCache->StopLearningPhase();
563 file.SetCacheRead(
nullptr);
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
TTreeCache * checkTriggerCache(TBranch *branch, EntryNumber entryNumber) const
std::string const & processName() const
unsigned int learningEntries_
roottree::EntryNumber EntryNumber
std::shared_ptr< TTreeCache > rawTriggerTreeCache_
void dropBranch(std::string const &oldBranchName)
std::vector< std::string > branchNames_
EntryNumber const & entryNumber() const
EntryNumber const & entryNumberForIndex(unsigned int index) const
std::string const & BranchTypeToBranchEntryInfoBranchName(BranchType const &branchType)
std::shared_ptr< TTreeCache > treeCache_
EntryNumber rawTriggerSwitchOverEntry_
void setSignals(signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
std::unordered_set< TBranch * > trainedSet_
std::string const & BranchTypeToAuxBranchName(BranchType const &branchType)
TBranch * branchEntryInfoBranch_
void setPresence(BranchDescription &prod, std::string const &oldBranchName)
void trainCache(char const *branchNames)
DelayedReader * rootDelayedReader() const
std::unique_ptr< RootDelayedReader > rootDelayedReader_
void setTreeMaxVirtualSize(int treeMaxVirtualSize)
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
void getEntry(TBranch *branch, EntryNumber entry) const
void init(std::string const &productTreeName, unsigned int maxVirtualSize, unsigned int cacheSize)
void insertEntryForIndex(unsigned int index)
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
TTreeCache * selectCache(TBranch *branch, EntryNumber entryNumber) const
EntryNumber const & entries() const
unsigned long treeAutoFlush_
void addBranch(BranchDescription const &prod, std::string const &oldBranchName)
std::shared_ptr< TTreeCache > rawTreeCache_
void insert(edm::BranchID const &iKey, BranchInfo const &iInfo)
IndexIntoFile::EntryNumber_t EntryNumber
std::shared_ptr< InputFile > filePtr_
void setCacheSize(unsigned int cacheSize)
std::string const & BranchTypeToInfoTreeName(BranchType const &branchType)
BranchMap const & branches() const
bool performedSwitchOver_
RootTree(std::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int nIndexes, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
BranchType branchType() const
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
bool skipEntries(unsigned int &offset)
std::unordered_set< TBranch * > triggerSet_
std::string const & branchListIndexesBranchName()
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
std::unique_ptr< TTreeCache > trainCache(TTree *tree, InputFile &file, unsigned int cacheSize, char const *branchNames)
DelayedReader * resetAndGetRootDelayedReader() const
TTreeCache * checkTriggerCacheImpl(TBranch *branch, EntryNumber entryNumber) const
EntryNumber switchOverEntry_
std::shared_ptr< TTreeCache > triggerTreeCache_
void setEntryNumber(EntryNumber theEntryNumber)
std::vector< std::string > const & branchNames() const