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();
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;
432 rawEnd =
tree_->GetEntries();
498 int branchCount =
branches->GetEntriesFast();
499 for (
int i = 0;
i < branchCount;
i++) {
518 n =
branch->GetEntry(entryNumber);
528 n =
tree->GetEntry(entryNumber);
537 unsigned int cacheSize,
538 char const* branchNames) {
540 tree->SetCacheSize(cacheSize);
541 std::unique_ptr<TTreeCache> treeCache(dynamic_cast<TTreeCache*>(
file.GetCacheRead()));
542 if (
nullptr != treeCache.get()) {
543 treeCache->StartLearningPhase();
544 treeCache->SetEntryRange(0,
tree->GetEntries());
545 treeCache->AddBranch(branchNames, kTRUE);
546 treeCache->StopLearningPhase();
551 file.SetCacheRead(
nullptr);