8 #include "TTreeIndex.h"
9 #include "TTreeCache.h"
17 TBranch* getAuxiliaryBranch(TTree*
tree,
BranchType const& branchType) {
24 TBranch* getProductProvenanceBranch(TTree*
tree,
BranchType const& branchType) {
31 unsigned int nIndexes,
32 unsigned int maxVirtualSize,
33 unsigned int cacheSize,
34 unsigned int learningEntries,
35 bool enablePrefetching,
38 tree_(dynamic_cast<TTree*>(
40 metaTree_(dynamic_cast<TTree*>(
42 branchType_(branchType),
43 auxBranch_(tree_ ? getAuxiliaryBranch(tree_, branchType_) : nullptr),
47 rawTriggerTreeCache_(),
50 entries_(tree_ ? tree_->GetEntries() : 0),
57 rawTriggerSwitchOverEntry_(-1),
58 performedSwitchOver_{
false},
59 learningEntries_(learningEntries),
60 cacheSize_(cacheSize),
62 enablePrefetching_(enablePrefetching),
63 enableTriggerCache_(branchType_ ==
InEvent),
64 rootDelayedReader_(
new RootDelayedReader(*
this, filePtr, inputType)),
65 branchEntryInfoBranch_(metaTree_ ? getProductProvenanceBranch(metaTree_, branchType_)
66 : (tree_ ? getProductProvenanceBranch(tree_, branchType_) :
nullptr)),
67 infoTree_(dynamic_cast<TTree*>(filePtr_.get() !=
nullptr
74 <<
"\n This is either not an edm ROOT file or is one that has been corrupted.";
78 long treeAutoFlush = (tree_ ? tree_->GetAutoFlush() : 0);
79 if (treeAutoFlush < 0) {
81 Long64_t averageEventSizeBytes = tree_->GetZipBytes() / (tree_->GetEntries() + 1) + 1;
82 treeAutoFlush_ = cacheSize_ / averageEventSizeBytes + 1;
84 treeAutoFlush_ = treeAutoFlush;
86 if (treeAutoFlush_ < learningEntries_) {
87 learningEntries_ = treeAutoFlush_;
89 setTreeMaxVirtualSize(maxVirtualSize);
90 setCacheSize(cacheSize);
92 Int_t branchCount = tree_->GetListOfBranches()->GetEntriesFast();
93 trainedSet_.reserve(branchCount);
94 triggerSet_.reserve(branchCount);
132 if (
tree_->GetBranch(oldBranchName.c_str()) ==
nullptr) {
133 prod.setDropped(
true);
140 TBranch*
branch =
tree_->GetBranch(oldBranchName.c_str());
142 info.productBranch_ =
nullptr;
143 if (
prod.present()) {
149 info.provenanceBranch_ = provTree->GetBranch(oldBranchName.c_str());
155 TBranch*
branch =
tree_->GetBranch(oldBranchName.c_str());
157 TObjArray* leaves =
tree_->GetListOfLeaves();
158 int entries = leaves->GetEntries();
160 TLeaf* leaf = (TLeaf*)(*leaves)[
i];
163 TBranch*
br = leaf->GetBranch();
167 leaves->Remove(leaf);
172 tree_->GetListOfBranches()->Compress();
181 tree_->SetCacheSize(static_cast<Long64_t>(cacheSize));
190 if (treeMaxVirtualSize >= 0)
191 tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
210 if (theEntryNumber < entryNumber_ and theEntryNumber >= 0) {
226 TTree::TClusterIterator clusterIter =
tree_->GetClusterIterator(theEntryNumber);
286 TTree::TClusterIterator clusterIter =
tree_->GetClusterIterator(
entryNumber);
293 tree_->SetCacheSize(static_cast<Long64_t>(5 * 1024 * 1024));
298 int branchCount =
branches->GetEntriesFast();
303 for (
int i = 0;
i < branchCount;
i++) {
304 TBranch* tmp_branch = (TBranch*)
branches->UncheckedAt(
i);
326 tree_->SetCacheSize(static_cast<Long64_t>(5 * 1024 * 1024));
348 TTreeCache* triggerCache =
nullptr;
415 rawEnd =
tree_->GetEntries();
480 int branchCount =
branches->GetEntriesFast();
481 for (
int i = 0;
i < branchCount;
i++) {
499 n =
branch->GetEntry(entryNumber);
509 n =
tree->GetEntry(entryNumber);
518 unsigned int cacheSize,
519 char const* branchNames) {
521 tree->SetCacheSize(cacheSize);
522 std::unique_ptr<TTreeCache> treeCache(dynamic_cast<TTreeCache*>(
file.GetCacheRead()));
523 if (
nullptr != treeCache.get()) {
524 treeCache->StartLearningPhase();
525 treeCache->SetEntryRange(0,
tree->GetEntries());
526 treeCache->AddBranch(branchNames, kTRUE);
527 treeCache->StopLearningPhase();
532 file.SetCacheRead(
nullptr);