8 #include "TTreeIndex.h"
9 #include "TTreeCache.h"
22 TBranch* getProductProvenanceBranch(TTree* tree,
BranchType const& branchType) {
29 unsigned int maxVirtualSize,
30 unsigned int cacheSize,
31 unsigned int learningEntries,
32 bool enablePrefetching) :
36 branchType_(branchType),
37 auxBranch_(tree_ ? getAuxiliaryBranch(tree_, branchType_) : 0),
41 rawTriggerTreeCache_(),
44 entries_(tree_ ? tree_->GetEntries() : 0),
50 rawTriggerSwitchOverEntry_(-1),
51 learningEntries_(learningEntries),
52 cacheSize_(cacheSize),
54 enablePrefetching_(enablePrefetching),
55 enableTriggerCache_(branchType_ ==
InEvent),
57 branchEntryInfoBranch_(metaTree_ ? getProductProvenanceBranch(metaTree_, branchType_) : (tree_ ? getProductProvenanceBranch(tree_, branchType_) : 0)),
63 long treeAutoFlush = (
tree_ ?
tree_->GetAutoFlush() : 0);
64 if (treeAutoFlush < 0) {
66 Long64_t averageEventSizeBytes =
tree_->GetZipBytes() / (
tree_->GetEntries()+1) + 1;
77 Int_t branchCount =
tree_->GetListOfBranches()->GetEntriesFast();
108 if(
tree_->GetBranch(oldBranchName.c_str()) == 0){
120 TBranch* branch =
tree_->GetBranch(oldBranchName.c_str());
130 branches_->insert(std::make_pair(key, info));
136 TBranch* branch =
tree_->GetBranch(oldBranchName.c_str());
138 TObjArray* leaves =
tree_->GetListOfLeaves();
139 int entries = leaves->GetEntries();
141 TLeaf*
leaf = (TLeaf*)(*leaves)[
i];
142 if (leaf == 0)
continue;
143 TBranch*
br = leaf->GetBranch();
144 if (br == 0)
continue;
145 if (br->GetMother() == branch) {
146 leaves->Remove(leaf);
150 tree_->GetListOfBranches()->Remove(branch);
151 tree_->GetListOfBranches()->Compress();
162 tree_->SetCacheSize(static_cast<Long64_t>(cacheSize));
171 if (treeMaxVirtualSize >= 0)
tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
233 TTree::TClusterIterator clusterIter =
tree_->GetClusterIterator(entryNumber);
240 tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
244 int branchCount = branches->GetEntriesFast();
249 for (
int i=0;
i<branchCount;
i++) {
250 TBranch *tmp_branch = (TBranch*)branches->UncheckedAt(
i);
272 tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
298 tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
322 TTreeCache *triggerCache =
NULL;
342 TTreeCache * cache =
selectCache(branch, entryNumber);
344 branch->GetEntry(entryNumber);
434 int branchCount = branches->GetEntriesFast();
435 for (
int i=0;
i<branchCount;
i++) {
436 TBranch *branch = (TBranch*)branches->UncheckedAt(
i);
437 if ((branchNames[0] ==
'*') || (strcmp(branchNames, branch->GetName()) == 0)) {
449 n = branch->GetEntry(entryNumber);
461 n = tree->GetEntry(entryNumber);
469 std::unique_ptr<TTreeCache>
472 tree->SetCacheSize(cacheSize);
473 std::unique_ptr<TTreeCache> treeCache(dynamic_cast<TTreeCache*>(file.
GetCacheRead()));
474 if (0 != treeCache.get()) {
475 treeCache->StartLearningPhase();
476 treeCache->SetEntryRange(0, tree->GetEntries());
477 treeCache->AddBranch(branchNames, kTRUE);
478 treeCache->StopLearningPhase();
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
boost::shared_ptr< TTreeCache > treeCache_
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
unsigned int learningEntries_
TTreeCache * checkTriggerCache(TBranch *branch, EntryNumber entryNumber) const
void addBranch(BranchKey const &key, BranchDescription const &prod, std::string const &oldBranchName)
void dropBranch(std::string const &oldBranchName)
std::vector< std::string > branchNames_
void setPresence(BranchDescription const &prod, std::string const &oldBranchName)
std::string & branchName() const
EntryNumber rawTriggerSwitchOverEntry_
roottree::BranchMap BranchMap
EntryNumber const & entries() const
RootTree(boost::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int maxVirtualSize, unsigned int cacheSize, unsigned int learningEntries, bool enablePrefetching)
std::unordered_set< TBranch * > trainedSet_
TBranch * branchEntryInfoBranch_
boost::shared_ptr< TTreeCache > rawTreeCache_
void trainCache(char const *branchNames)
void setTreeMaxVirtualSize(int treeMaxVirtualSize)
std::map< BranchKey const, BranchInfo > BranchMap
boost::shared_ptr< TTreeCache > triggerTreeCache_
boost::shared_ptr< TTreeCache > rawTriggerTreeCache_
TTreeCache * selectCache(TBranch *branch, EntryNumber entryNumber) const
unsigned long treeAutoFlush_
std::string const & BranchTypeToBranchEntryInfoBranchName(BranchType const &branchType)
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
TTreeCache * checkTriggerCacheImpl(TBranch *branch, EntryNumber entryNumber) const
std::string const & BranchTypeToInfoTreeName(BranchType const &branchType)
TBranch * provenanceBranch_
DelayedReader * rootDelayedReader() const
void getEntry(TBranch *branch, EntryNumber entry) const
boost::shared_ptr< BranchMap > branches_
void addContext(std::string const &context)
void setCacheSize(unsigned int cacheSize)
bool performedSwitchOver_
std::unordered_set< TBranch * > triggerSet_
std::string const & BranchTypeToAuxBranchName(BranchType const &branchType)
BranchMap const & branches() const
std::unique_ptr< DelayedReader > rootDelayedReader_
boost::shared_ptr< InputFile > filePtr_
std::string const & branchListIndexesBranchName()
std::unique_ptr< TTreeCache > trainCache(TTree *tree, InputFile &file, unsigned int cacheSize, char const *branchNames)
EntryNumber switchOverEntry_
T get(const Candidate &c)
void setEntryNumber(EntryNumber theEntryNumber)
roottree::EntryNumber EntryNumber