8 #include "TTreeCache.h"
15 TBranch* getAuxiliaryBranch(TTree*
tree,
BranchType const& branchType) {
17 if (branch ==
nullptr) {
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),
42 rootDelayedReader_(std::make_unique<
RootDelayedReader>(*this, filePtr, inputType)) {}
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();
126 return tree_ !=
nullptr;
151 if (
tree_->GetBranch(oldBranchName.c_str()) ==
nullptr) {
159 TBranch* branch =
tree_->GetBranch(oldBranchName.c_str());
172 TBranch* branch =
tree_->GetBranch(oldBranchName.c_str());
173 if (branch !=
nullptr) {
174 TObjArray* leaves =
tree_->GetListOfLeaves();
175 int entries = leaves->GetEntries();
177 TLeaf* leaf = (TLeaf*)(*leaves)[
i];
180 TBranch*
br = leaf->GetBranch();
183 if (br->GetMother() == branch) {
184 leaves->Remove(leaf);
188 tree_->GetListOfBranches()->Remove(branch);
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) {
239 triggerTreeCache_->SetEntryRange(theEntryNumber,
tree_->GetEntries());
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;
386 branch->GetEntry(entryNumber);
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++) {
512 TBranch* branch = (TBranch*)branches->UncheckedAt(
i);
513 if ((branchNames[0] ==
'*') || (strcmp(branchNames, branch->GetName()) == 0)) {
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());
557 treeCache->AddBranch(branchNames, kTRUE);
558 treeCache->StopLearningPhase();
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
std::string const & branchName() const
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
unsigned int learningEntries_
TTreeCache * checkTriggerCache(TBranch *branch, EntryNumber entryNumber) const
roottree::EntryNumber EntryNumber
std::shared_ptr< TTreeCache > rawTriggerTreeCache_
void dropBranch(std::string const &oldBranchName)
std::vector< std::string > branchNames_
std::shared_ptr< TTreeCache > treeCache_
EntryNumber rawTriggerSwitchOverEntry_
EntryNumber const & entries() const
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_
TBranch * branchEntryInfoBranch_
void setPresence(BranchDescription &prod, std::string const &oldBranchName)
void trainCache(char const *branchNames)
std::unique_ptr< RootDelayedReader > rootDelayedReader_
void setTreeMaxVirtualSize(int treeMaxVirtualSize)
void init(std::string const &productTreeName, unsigned int maxVirtualSize, unsigned int cacheSize)
void insertEntryForIndex(unsigned int index)
DelayedReader * resetAndGetRootDelayedReader() const
TTreeCache * selectCache(TBranch *branch, EntryNumber entryNumber) const
char const * what() const noexceptoverride
unsigned long treeAutoFlush_
void addBranch(BranchDescription const &prod, std::string const &oldBranchName)
BranchID const & branchID() const
std::string const & BranchTypeToBranchEntryInfoBranchName(BranchType const &branchType)
void setDropped(bool isDropped)
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
TTreeCache * checkTriggerCacheImpl(TBranch *branch, EntryNumber entryNumber) const
EntryNumber const & entryNumber() const
std::string const & BranchTypeToInfoTreeName(BranchType const &branchType)
DelayedReader * rootDelayedReader() const
EntryNumber const & entryNumberForIndex(unsigned int index) const
std::string const & processName() const
std::shared_ptr< TTreeCache > rawTreeCache_
void getEntry(TBranch *branch, EntryNumber entry) const
void insert(edm::BranchID const &iKey, BranchInfo const &iInfo)
void addContext(std::string const &context)
IndexIntoFile::EntryNumber_t EntryNumber
std::shared_ptr< InputFile > filePtr_
void setCacheSize(unsigned int cacheSize)
bool performedSwitchOver_
RootTree(std::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int nIndexes, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
bool skipEntries(unsigned int &offset)
std::unordered_set< TBranch * > triggerSet_
std::string const & BranchTypeToAuxBranchName(BranchType const &branchType)
BranchMap const & branches() const
std::string const & branchListIndexesBranchName()
std::unique_ptr< TTreeCache > trainCache(TTree *tree, InputFile &file, unsigned int cacheSize, char const *branchNames)
EntryNumber switchOverEntry_
std::shared_ptr< TTreeCache > triggerTreeCache_
tuple size
Write out results.
void setEntryNumber(EntryNumber theEntryNumber)