![]() |
![]() |
#include <RootOutputTree.h>
Public Member Functions | |
template<typename T > | |
void | addAuxiliary (std::string const &branchName, T const *&pAux, int bufSize) |
template<typename T > | |
void | addAuxiliary (std::string const &branchName, T *&pAux, int bufSize) |
void | addBranch (std::string const &branchName, std::string const &className, void const *&pProd, int splitLevel, int basketSize, bool produced) |
bool | checkIfFastClonable (TTree *inputTree) const |
bool | checkSplitLevelsAndBasketSizes (TTree *inputTree) const |
void | close () |
void | fastCloneTTree (TTree *in, std::string const &option) |
void | fillTree () const |
bool | isValid () const |
void | maybeFastCloneTree (bool canFastClone, bool canFastCloneAux, TTree *tree, std::string const &option) |
void | optimizeBaskets (ULong64_t size) |
RootOutputTree (boost::shared_ptr< TFile > filePtr, BranchType const &branchType, int bufSize, int splitLevel, int treeMaxVirtualSize) | |
void | setAutoFlush (Long64_t size) |
void | setEntries () |
TTree *const | tree () const |
bool | uncloned (std::string const &branchName) const |
void | writeTree () const |
~RootOutputTree () | |
Static Public Member Functions | |
static TTree * | assignTTree (TFile *file, TTree *tree) |
static TTree * | makeTTree (TFile *filePtr, std::string const &name, int splitLevel) |
static void | writeTTree (TTree *tree) |
Static Private Member Functions | |
static void | fillTTree (TTree *tree, std::vector< TBranch * > const &branches) |
Private Attributes | |
std::vector< TBranch * > | auxBranches_ |
bool | currentlyFastCloning_ |
bool | fastCloneAuxBranches_ |
boost::shared_ptr< TFile > | filePtr_ |
std::vector< TBranch * > | producedBranches_ |
std::vector< TBranch * > | readBranches_ |
TTree * | tree_ |
std::vector< TBranch * > | unclonedReadBranches_ |
std::set< std::string > | unclonedReadBranchNames_ |
Definition at line 25 of file RootOutputTree.h.
data doxygen doxygen gen CMSSW_4_2_8 src IOPool Output src RootOutputTree cc edm::RootOutputTree::RootOutputTree | ( | boost::shared_ptr< TFile > | filePtr, |
BranchType const & | branchType, | ||
int | bufSize, | ||
int | splitLevel, | ||
int | treeMaxVirtualSize | ||
) |
Definition at line 27 of file RootOutputTree.cc.
References tree_.
: filePtr_(filePtr), tree_(makeTTree(filePtr.get(), BranchTypeToProductTreeName(branchType), splitLevel)), producedBranches_(), readBranches_(), auxBranches_(), unclonedReadBranches_(), unclonedReadBranchNames_(), currentlyFastCloning_(), fastCloneAuxBranches_(false) { if(treeMaxVirtualSize >= 0) tree_->SetMaxVirtualSize(treeMaxVirtualSize); }
edm::RootOutputTree::~RootOutputTree | ( | ) | [inline] |
Definition at line 33 of file RootOutputTree.h.
{}
void edm::RootOutputTree::addAuxiliary | ( | std::string const & | branchName, |
T const *& | pAux, | ||
int | bufSize | ||
) | [inline] |
Definition at line 37 of file RootOutputTree.h.
References auxBranches_, and tree_.
Referenced by edm::RootOutputFile::RootOutputFile().
{ auxBranches_.push_back(tree_->Branch(branchName.c_str(), &pAux, bufSize, 0)); }
void edm::RootOutputTree::addAuxiliary | ( | std::string const & | branchName, |
T *& | pAux, | ||
int | bufSize | ||
) | [inline] |
Definition at line 43 of file RootOutputTree.h.
References auxBranches_, and tree_.
{ auxBranches_.push_back(tree_->Branch(branchName.c_str(), &pAux, bufSize, 0)); }
void edm::RootOutputTree::addBranch | ( | std::string const & | branchName, |
std::string const & | className, | ||
void const *& | pProd, | ||
int | splitLevel, | ||
int | basketSize, | ||
bool | produced | ||
) |
Definition at line 255 of file RootOutputTree.cc.
References edm::BranchDescription::invalidBasketSize, edm::BranchDescription::invalidSplitLevel, producedBranches_, readBranches_, filterRecHits_cfg::splitLevel, and tree_.
Referenced by edm::RootOutputFile::RootOutputFile().
{ assert(splitLevel != BranchDescription::invalidSplitLevel); assert(basketSize != BranchDescription::invalidBasketSize); TBranch* branch = tree_->Branch(branchName.c_str(), className.c_str(), &pProd, basketSize, splitLevel); if(produced) { producedBranches_.push_back(branch); } else { readBranches_.push_back(branch); } }
TTree * edm::RootOutputTree::assignTTree | ( | TFile * | file, |
TTree * | tree | ||
) | [static] |
Definition at line 47 of file RootOutputTree.cc.
bool edm::RootOutputTree::checkIfFastClonable | ( | TTree * | inputTree | ) | const |
Definition at line 120 of file RootOutputTree.cc.
Referenced by edm::RootOutputFile::beginInputFile().
{ TBranchElement* outputBranch = dynamic_cast<TBranchElement*>(*it); if(outputBranch != 0) { TBranchElement* inputBranch = dynamic_cast<TBranchElement*>(inputTree->GetBranch(outputBranch->GetName())); if(inputBranch != 0) { // We have a matching top level branch. Do the recursive check on subbranches. if(!checkMatchingBranches(inputBranch, outputBranch)) { LogInfo("FastCloning") << "Fast Cloning disabled because a data member has been added to split branch: " << inputBranch->GetName() << "\n."; } } } } return true; }
bool edm::RootOutputTree::checkSplitLevelsAndBasketSizes | ( | TTree * | inputTree | ) | const |
Definition at line 68 of file RootOutputTree.cc.
Referenced by edm::RootOutputFile::beginInputFile().
{ TBranch* outputBranch = *it; if(outputBranch != 0) { TBranch* inputBranch = inputTree->GetBranch(outputBranch->GetName()); if(inputBranch != 0) { if(inputBranch->GetSplitLevel() != outputBranch->GetSplitLevel() || inputBranch->GetBasketSize() != outputBranch->GetBasketSize()) { return false; } } } } return true; }
void edm::RootOutputTree::close | ( | void | ) |
Definition at line 276 of file RootOutputTree.cc.
void edm::RootOutputTree::fastCloneTTree | ( | TTree * | in, |
std::string const & | option | ||
) |
Definition at line 142 of file RootOutputTree.cc.
References auxBranches_, Exception, fastCloneAuxBranches_, edm::errors::FatalRootError, prof2calltree::last, and tree_.
Referenced by maybeFastCloneTree().
{ TObjArray* branches = tree_->GetListOfBranches(); // If any products were produced (not just event products), the EventAuxiliary will be modified. // In that case, don't fast copy auxiliary branches. Remove them, and add back after fast copying. std::map<Int_t, TBranch *> auxIndexes; if (!fastCloneAuxBranches_) { for (std::vector<TBranch *>::const_iterator it = auxBranches_.begin(), itEnd = auxBranches_.end(); it != itEnd; ++it) { int auxIndex = branches->IndexOf(*it); assert (auxIndex >= 0); auxIndexes.insert(std::make_pair(auxIndex, *it)); branches->RemoveAt(auxIndex); } branches->Compress(); } #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0) TTreeCloner cloner(in, tree_, option.c_str(), TTreeCloner::kNoWarnings|TTreeCloner::kIgnoreMissingTopLevel); #else TTreeCloner cloner(in, tree_, option.c_str()); #endif if(!cloner.IsValid()) { #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0) // Let's check why static const char* okerror = "One of the export branch"; if ( strncmp(cloner.GetWarning(),okerror,strlen(okerror)) == 0 ) { // That's fine we will handle it; } else { throw edm::Exception(errors::FatalRootError) << "invalid TTreeCloner\n"; } #else throw edm::Exception(errors::FatalRootError) << "invalid TTreeCloner\n"; #endif } tree_->SetEntries(tree_->GetEntries() + in->GetEntries()); Service<RootHandlers> rootHandler; rootHandler->enableErrorHandlerWithoutWarnings(); cloner.Exec(); rootHandler->enableErrorHandler(); if (!fastCloneAuxBranches_) { for (std::map<Int_t, TBranch *>::const_iterator it = auxIndexes.begin(), itEnd = auxIndexes.end(); it != itEnd; ++it) { // Add the auxiliary branches back after fast copying the rest of the tree. Int_t last = branches->GetLast(); if (last >= 0) { branches->AddAtAndExpand(branches->At(last), last+1); for(Int_t ind = last-1; ind >= it->first; --ind) { branches->AddAt(branches->At(ind), ind+1); }; branches->AddAt(it->second, it->first); } else { branches->Add(it->second); } } } } }
void edm::RootOutputTree::fillTree | ( | ) | const |
Definition at line 244 of file RootOutputTree.cc.
References auxBranches_, fastCloneAuxBranches_, fillTTree(), producedBranches_, tree_, and unclonedReadBranches_.
{ if (!fastCloneAuxBranches_)fillTTree(tree_, auxBranches_); fillTTree(tree_, producedBranches_); fillTTree(tree_, unclonedReadBranches_); } else { tree_->Fill(); } }
void edm::RootOutputTree::fillTTree | ( | TTree * | tree, |
std::vector< TBranch * > const & | branches | ||
) | [static, private] |
Definition at line 216 of file RootOutputTree.cc.
Referenced by fillTree().
bool edm::RootOutputTree::isValid | ( | ) | const |
TTree * edm::RootOutputTree::makeTTree | ( | TFile * | filePtr, |
std::string const & | name, | ||
int | splitLevel | ||
) | [static] |
Definition at line 56 of file RootOutputTree.cc.
Referenced by edm::RootOutputFile::RootOutputFile().
void edm::RootOutputTree::maybeFastCloneTree | ( | bool | canFastClone, |
bool | canFastCloneAux, | ||
TTree * | tree, | ||
std::string const & | option | ||
) |
Definition at line 226 of file RootOutputTree.cc.
References fastCloneAuxBranches_, fastCloneTTree(), readBranches_, tree_, unclonedReadBranches_, and unclonedReadBranchNames_.
Referenced by edm::RootOutputFile::beginInputFile().
{ fastCloneAuxBranches_ = canFastCloneAux; fastCloneTTree(tree, option); for(std::vector<TBranch*>::const_iterator it = readBranches_.begin(), itEnd = readBranches_.end(); it != itEnd; ++it) { if((*it)->GetEntries() != tree_->GetEntries()) { unclonedReadBranches_.push_back(*it); unclonedReadBranchNames_.insert(std::string((*it)->GetName())); } } } }
void edm::RootOutputTree::optimizeBaskets | ( | ULong64_t | size | ) | [inline] |
Definition at line 89 of file RootOutputTree.h.
References tree_.
Referenced by edm::RootOutputFile::writeLuminosityBlock(), and edm::RootOutputFile::writeRun().
void edm::RootOutputTree::setAutoFlush | ( | Long64_t | size | ) | [inline] |
Definition at line 93 of file RootOutputTree.h.
References tree_.
Referenced by edm::RootOutputFile::RootOutputFile().
void edm::RootOutputTree::setEntries | ( | ) | [inline] |
Definition at line 78 of file RootOutputTree.h.
References tree_.
Referenced by edm::RootOutputFile::respondToCloseInputFile().
TTree* const edm::RootOutputTree::tree | ( | ) | const [inline] |
bool edm::RootOutputTree::uncloned | ( | std::string const & | branchName | ) | const [inline] |
Definition at line 83 of file RootOutputTree.h.
References unclonedReadBranchNames_.
{ return unclonedReadBranchNames_.find(branchName) != unclonedReadBranchNames_.end(); }
void edm::RootOutputTree::writeTree | ( | ) | const |
Definition at line 221 of file RootOutputTree.cc.
void edm::RootOutputTree::writeTTree | ( | TTree * | tree | ) | [static] |
Definition at line 207 of file RootOutputTree.cc.
Referenced by edm::RootOutputFile::finishEndFile().
{ tree->SetEntries(-1); } setRefCoreStreamer(true); tree->AutoSave("FlushBaskets"); }
std::vector<TBranch*> edm::RootOutputTree::auxBranches_ [private] |
Definition at line 105 of file RootOutputTree.h.
Referenced by addAuxiliary(), fastCloneTTree(), and fillTree().
bool edm::RootOutputTree::currentlyFastCloning_ [private] |
Definition at line 108 of file RootOutputTree.h.
bool edm::RootOutputTree::fastCloneAuxBranches_ [private] |
Definition at line 109 of file RootOutputTree.h.
Referenced by fastCloneTTree(), fillTree(), and maybeFastCloneTree().
boost::shared_ptr<TFile> edm::RootOutputTree::filePtr_ [private] |
Definition at line 101 of file RootOutputTree.h.
std::vector<TBranch*> edm::RootOutputTree::producedBranches_ [private] |
Definition at line 103 of file RootOutputTree.h.
Referenced by addBranch(), and fillTree().
std::vector<TBranch*> edm::RootOutputTree::readBranches_ [private] |
Definition at line 104 of file RootOutputTree.h.
Referenced by addBranch(), and maybeFastCloneTree().
TTree* edm::RootOutputTree::tree_ [private] |
Definition at line 102 of file RootOutputTree.h.
Referenced by addAuxiliary(), addBranch(), fastCloneTTree(), fillTree(), maybeFastCloneTree(), optimizeBaskets(), RootOutputTree(), setAutoFlush(), setEntries(), and tree().
std::vector<TBranch*> edm::RootOutputTree::unclonedReadBranches_ [private] |
Definition at line 106 of file RootOutputTree.h.
Referenced by fillTree(), and maybeFastCloneTree().
std::set<std::string> edm::RootOutputTree::unclonedReadBranchNames_ [private] |
Definition at line 107 of file RootOutputTree.h.
Referenced by maybeFastCloneTree(), and uncloned().