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,
37 tree_(dynamic_cast<TTree*>(
39 metaTree_(dynamic_cast<TTree*>(
41 branchType_(branchType),
42 auxBranch_(tree_ ? getAuxiliaryBranch(tree_, branchType_) :
nullptr),
46 rawTriggerTreeCache_(),
49 entries_(tree_ ? tree_->GetEntries() : 0),
73 <<
"\n This is either not an edm ROOT file or is one that has been corrupted.";
77 long treeAutoFlush = (tree_ ? tree_->GetAutoFlush() : 0);
78 if (treeAutoFlush < 0) {
80 Long64_t averageEventSizeBytes = tree_->GetZipBytes() / (tree_->GetEntries() + 1) + 1;
91 Int_t branchCount = tree_->GetListOfBranches()->GetEntriesFast();
100 assert(index < entryNumberForIndex_->
size());
105 assert(index < entryNumberForIndex_->
size());
131 if (
tree_->GetBranch(oldBranchName.c_str()) ==
nullptr) {
139 TBranch* branch =
tree_->GetBranch(oldBranchName.c_str());
154 TBranch* branch =
tree_->GetBranch(oldBranchName.c_str());
155 if (branch !=
nullptr) {
156 TObjArray* leaves =
tree_->GetListOfLeaves();
157 int entries = leaves->GetEntries();
159 TLeaf* leaf = (TLeaf*)(*leaves)[
i];
162 TBranch*
br = leaf->GetBranch();
165 if (br->GetMother() ==
branch) {
166 leaves->Remove(leaf);
170 tree_->GetListOfBranches()->Remove(branch);
171 tree_->GetListOfBranches()->Compress();
180 tree_->SetCacheSize(static_cast<Long64_t>(cacheSize));
189 if (treeMaxVirtualSize >= 0)
190 tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize));
209 if (theEntryNumber < entryNumber_ and theEntryNumber >= 0) {
221 triggerTreeCache_->SetEntryRange(theEntryNumber,
tree_->GetEntries());
225 TTree::TClusterIterator clusterIter =
tree_->GetClusterIterator(theEntryNumber);
285 TTree::TClusterIterator clusterIter =
tree_->GetClusterIterator(entryNumber);
292 tree_->SetCacheSize(static_cast<Long64_t>(5 * 1024 * 1024));
297 int branchCount = branches->GetEntriesFast();
302 for (
int i = 0;
i < branchCount;
i++) {
303 TBranch* tmp_branch = (TBranch*)branches->UncheckedAt(
i);
325 tree_->SetCacheSize(static_cast<Long64_t>(5 * 1024 * 1024));
347 TTreeCache* triggerCache =
nullptr;
368 branch->GetEntry(entryNumber);
414 rawEnd =
tree_->GetEntries();
479 int branchCount = branches->GetEntriesFast();
480 for (
int i = 0;
i < branchCount;
i++) {
481 TBranch* branch = (TBranch*)branches->UncheckedAt(
i);
482 if ((branchNames[0] ==
'*') || (strcmp(branchNames, branch->GetName()) == 0)) {
498 n = branch->GetEntry(entryNumber);
508 n = tree->GetEntry(entryNumber);
517 unsigned int cacheSize,
520 tree->SetCacheSize(cacheSize);
521 std::unique_ptr<TTreeCache> treeCache(dynamic_cast<TTreeCache*>(file.
GetCacheRead()));
522 if (
nullptr != treeCache.get()) {
523 treeCache->StartLearningPhase();
524 treeCache->SetEntryRange(0, tree->GetEntries());
525 treeCache->AddBranch(branchNames, kTRUE);
526 treeCache->StopLearningPhase();
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
std::shared_ptr< TTreeCache > rawTriggerTreeCache_
void dropBranch(std::string const &oldBranchName)
std::vector< std::string > branchNames_
std::vector< std::string > const & branchNames() const
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 insertEntryForIndex(unsigned int index)
DelayedReader * resetAndGetRootDelayedReader() const
TTreeCache * selectCache(TBranch *branch, EntryNumber entryNumber) const
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)
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
std::shared_ptr< TTreeCache > rawTreeCache_
T const & get(Event const &event, InputTag const &tag)(false)
void getEntry(TBranch *branch, EntryNumber entry) const
void insert(edm::BranchID const &iKey, BranchInfo const &iInfo)
void addContext(std::string const &context)
std::shared_ptr< InputFile > filePtr_
void setCacheSize(unsigned int cacheSize)
bool performedSwitchOver_
std::unique_ptr< std::vector< EntryNumber > > entryNumberForIndex_
bool skipEntries(unsigned int &offset)
std::unordered_set< TBranch * > triggerSet_
RootTree(std::shared_ptr< InputFile > filePtr, BranchType const &branchType, unsigned int nIndexes, unsigned int maxVirtualSize, unsigned int cacheSize, unsigned int learningEntries, bool enablePrefetching, InputType inputType)
std::string const & BranchTypeToAuxBranchName(BranchType const &branchType)
BranchMap const & branches() const
std::string const & branchListIndexesBranchName()
EntryNumber switchOverEntry_
std::shared_ptr< TTreeCache > triggerTreeCache_
def branchType(schema, name)
void setEntryNumber(EntryNumber theEntryNumber)
roottree::EntryNumber EntryNumber