8 #include "TTreeIndex.h"
9 #include "TTreeCache.h"
18 if (branch ==
nullptr) {
23 TBranch* getProductProvenanceBranch(TTree* tree,
BranchType const& branchType) {
30 unsigned int nIndexes,
31 unsigned int maxVirtualSize,
32 unsigned int cacheSize,
33 unsigned int learningEntries,
34 bool enablePrefetching,
39 branchType_(branchType),
40 auxBranch_(tree_ ? getAuxiliaryBranch(tree_, branchType_) :
nullptr),
44 rawTriggerTreeCache_(),
47 entries_(tree_ ? tree_->GetEntries() : 0),
54 rawTriggerSwitchOverEntry_(-1),
55 learningEntries_(learningEntries),
56 cacheSize_(cacheSize),
58 enablePrefetching_(enablePrefetching),
59 enableTriggerCache_(branchType_ ==
InEvent),
61 branchEntryInfoBranch_(metaTree_ ? getProductProvenanceBranch(metaTree_, branchType_) : (tree_ ? getProductProvenanceBranch(tree_, branchType_) : 0)),
67 long treeAutoFlush = (
tree_ ?
tree_->GetAutoFlush() : 0);
68 if (treeAutoFlush < 0) {
70 Long64_t averageEventSizeBytes =
tree_->GetZipBytes() / (
tree_->GetEntries()+1) + 1;
81 Int_t branchCount =
tree_->GetListOfBranches()->GetEntriesFast();
92 assert(index < entryNumberForIndex_->
size());
98 assert(index < entryNumberForIndex_->
size());
123 if(
tree_->GetBranch(oldBranchName.c_str()) ==
nullptr){
134 TBranch* branch =
tree_->GetBranch(oldBranchName.c_str());
144 branches_->insert(std::make_pair(key, info));
150 TBranch* branch =
tree_->GetBranch(oldBranchName.c_str());
151 if (branch !=
nullptr) {
152 TObjArray* leaves =
tree_->GetListOfLeaves();
153 int entries = leaves->GetEntries();
155 TLeaf*
leaf = (TLeaf*)(*leaves)[
i];
156 if (leaf ==
nullptr)
continue;
157 TBranch*
br = leaf->GetBranch();
158 if (br ==
nullptr)
continue;
159 if (br->GetMother() == branch) {
160 leaves->Remove(leaf);
164 tree_->GetListOfBranches()->Remove(branch);
165 tree_->GetListOfBranches()->Compress();
176 tree_->SetCacheSize(static_cast<Long64_t>(cacheSize));
185 if (treeMaxVirtualSize >= 0)
tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
247 TTree::TClusterIterator clusterIter =
tree_->GetClusterIterator(entryNumber);
254 tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
258 int branchCount = branches->GetEntriesFast();
263 for (
int i=0;
i<branchCount;
i++) {
264 TBranch *tmp_branch = (TBranch*)branches->UncheckedAt(
i);
286 tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
312 tree_->SetCacheSize(static_cast<Long64_t>(5*1024*1024));
336 TTreeCache *triggerCache =
NULL;
356 TTreeCache * cache =
selectCache(branch, entryNumber);
358 branch->GetEntry(entryNumber);
448 int branchCount = branches->GetEntriesFast();
449 for (
int i=0;
i<branchCount;
i++) {
450 TBranch *branch = (TBranch*)branches->UncheckedAt(
i);
451 if ((branchNames[0] ==
'*') || (strcmp(branchNames, branch->GetName()) == 0)) {
463 n = branch->GetEntry(entryNumber);
475 n = tree->GetEntry(entryNumber);
483 std::unique_ptr<TTreeCache>
486 tree->SetCacheSize(cacheSize);
487 std::unique_ptr<TTreeCache> treeCache(dynamic_cast<TTreeCache*>(file.
GetCacheRead()));
488 if (
nullptr != treeCache.get()) {
489 treeCache->StartLearningPhase();
490 treeCache->SetEntryRange(0, tree->GetEntries());
491 treeCache->AddBranch(branchNames, kTRUE);
492 treeCache->StopLearningPhase();
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
boost::shared_ptr< TTreeCache > treeCache_
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
void addBranch(BranchKey const &key, BranchDescription const &prod, std::string const &oldBranchName)
void dropBranch(std::string const &oldBranchName)
RootTree(boost::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int nIndexes, unsigned int maxVirtualSize, unsigned int cacheSize, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
std::vector< std::string > branchNames_
EntryNumber rawTriggerSwitchOverEntry_
roottree::BranchMap BranchMap
EntryNumber const & entries() const
std::unordered_set< TBranch * > trainedSet_
TBranch * branchEntryInfoBranch_
void setPresence(BranchDescription &prod, std::string const &oldBranchName)
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_
void insertEntryForIndex(unsigned int index)
TTreeCache * selectCache(TBranch *branch, EntryNumber entryNumber) const
unsigned long treeAutoFlush_
std::string const & BranchTypeToBranchEntryInfoBranchName(BranchType const &branchType)
void setDropped(bool isDropped)
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
IndexIntoFile::EntryNumber_t EntryNumber
TTreeCache * checkTriggerCacheImpl(TBranch *branch, EntryNumber entryNumber) const
EntryNumber const & entryNumber() const
std::string const & BranchTypeToInfoTreeName(BranchType const &branchType)
TBranch * provenanceBranch_
DelayedReader * rootDelayedReader() const
EntryNumber const & entryNumberForIndex(unsigned int index) 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::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
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()
volatile std::atomic< bool > shutdown_flag false
std::unique_ptr< TTreeCache > trainCache(TTree *tree, InputFile &file, unsigned int cacheSize, char const *branchNames)
EntryNumber switchOverEntry_
tuple size
Write out results.
T get(const Candidate &c)
void setEntryNumber(EntryNumber theEntryNumber)
roottree::EntryNumber EntryNumber