#include <RootOutputTree.h>
Public Member Functions | |
template<typename T > | |
void | addAuxiliary (std::string const &branchName, T const *&pAux, int bufSize, bool allowCloning=true) |
template<typename T > | |
void | addAuxiliary (std::string const &branchName, T *&pAux, int bufSize, bool allowCloning=true) |
void | addBranch (std::string const &branchName, std::string const &className, WrapperInterfaceBase const *interface, void const *&pProd, int splitLevel, int basketSize, bool produced) |
bool | checkEntriesInReadBranches (Long64_t expectedNumberOfEntries) const |
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) |
RootOutputTree & | operator= (RootOutputTree const &) |
void | optimizeBaskets (ULong64_t size) |
RootOutputTree (boost::shared_ptr< TFile > filePtr, BranchType const &branchType, int splitLevel, int treeMaxVirtualSize) | |
RootOutputTree (RootOutputTree const &) | |
void | setAutoFlush (Long64_t size) |
void | setEntries () |
TTree * | 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 (std::vector< TBranch * > const &branches) |
Private Attributes | |
std::vector< TBranch * > | auxBranches_ |
std::set< std::string > | clonedReadBranchNames_ |
bool | currentlyFastCloning_ |
bool | fastCloneAuxBranches_ |
boost::shared_ptr< TFile > | filePtr_ |
std::vector< TBranch * > | producedBranches_ |
std::vector< TBranch * > | readBranches_ |
TTree * | tree_ |
std::vector< TBranch * > | unclonedAuxBranches_ |
std::vector< TBranch * > | unclonedReadBranches_ |
Definition at line 25 of file RootOutputTree.h.
data refman pasoursint CMSSW_5_3_10 src IOPool Output src RootOutputTree cc edm::RootOutputTree::RootOutputTree | ( | boost::shared_ptr< TFile > | filePtr, |
BranchType const & | branchType, | ||
int | splitLevel, | ||
int | treeMaxVirtualSize | ||
) |
Definition at line 28 of file RootOutputTree.cc.
References tree_.
: filePtr_(filePtr), tree_(makeTTree(filePtr.get(), BranchTypeToProductTreeName(branchType), splitLevel)), producedBranches_(), readBranches_(), auxBranches_(), unclonedReadBranches_(), clonedReadBranchNames_(), currentlyFastCloning_(), fastCloneAuxBranches_(false) { if(treeMaxVirtualSize >= 0) tree_->SetMaxVirtualSize(treeMaxVirtualSize); }
edm::RootOutputTree::~RootOutputTree | ( | ) | [inline] |
Definition at line 32 of file RootOutputTree.h.
{}
edm::RootOutputTree::RootOutputTree | ( | RootOutputTree const & | ) |
void edm::RootOutputTree::addAuxiliary | ( | std::string const & | branchName, |
T const *& | pAux, | ||
int | bufSize, | ||
bool | allowCloning = true |
||
) | [inline] |
Definition at line 39 of file RootOutputTree.h.
References auxBranches_, edm::bufSize, tree_, and unclonedAuxBranches_.
Referenced by edm::RootOutputFile::RootOutputFile().
{ if(allowCloning) { auxBranches_.push_back(tree_->Branch(branchName.c_str(), &pAux, bufSize, 0)); } else { unclonedAuxBranches_.push_back(tree_->Branch(branchName.c_str(), &pAux, bufSize, 0)); } }
void edm::RootOutputTree::addAuxiliary | ( | std::string const & | branchName, |
T *& | pAux, | ||
int | bufSize, | ||
bool | allowCloning = true |
||
) | [inline] |
Definition at line 49 of file RootOutputTree.h.
References auxBranches_, edm::bufSize, tree_, and unclonedAuxBranches_.
{ if(allowCloning) { auxBranches_.push_back(tree_->Branch(branchName.c_str(), &pAux, bufSize, 0)); } else { unclonedAuxBranches_.push_back(tree_->Branch(branchName.c_str(), &pAux, bufSize, 0)); } }
void edm::RootOutputTree::addBranch | ( | std::string const & | branchName, |
std::string const & | className, | ||
WrapperInterfaceBase const * | interface, | ||
void const *& | pProd, | ||
int | splitLevel, | ||
int | basketSize, | ||
bool | produced | ||
) |
Definition at line 274 of file RootOutputTree.cc.
References edm::WrapperInterfaceBase::deleteProduct(), edm::BranchDescription::invalidBasketSize, edm::BranchDescription::invalidSplitLevel, producedBranches_, readBranches_, dtDQMMerge_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); assert(branch != 0); if(pProd != 0) { // Delete the product that ROOT has allocated. interface->deleteProduct(pProd); pProd = 0; } 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::checkEntriesInReadBranches | ( | Long64_t | expectedNumberOfEntries | ) | const |
Definition at line 142 of file RootOutputTree.cc.
Referenced by edm::RootOutputFile::writeIndexIntoFile().
{ if((*it)->GetEntries() != expectedNumberOfEntries) { return false; } } return true; }
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 false; } } } } 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 302 of file RootOutputTree.cc.
void edm::RootOutputTree::fastCloneTTree | ( | TTree * | in, |
std::string const & | option | ||
) |
Definition at line 152 of file RootOutputTree.cc.
References auxBranches_, Exception, fastCloneAuxBranches_, edm::errors::FatalRootError, prof2calltree::last, tree_, and unclonedAuxBranches_.
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; bool mustRemoveSomeAuxs = false; 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); } mustRemoveSomeAuxs = true; } //Deal with any aux branches which can never be cloned for(std::vector<TBranch *>::const_iterator it = unclonedAuxBranches_.begin(), itEnd = unclonedAuxBranches_.end(); it != itEnd; ++it) { int auxIndex = branches->IndexOf(*it); assert (auxIndex >= 0); auxIndexes.insert(std::make_pair(auxIndex, *it)); branches->RemoveAt(auxIndex); mustRemoveSomeAuxs = true; } if(mustRemoveSomeAuxs) { branches->Compress(); } TTreeCloner cloner(in, tree_, option.c_str(), TTreeCloner::kNoWarnings|TTreeCloner::kIgnoreMissingTopLevel); if(!cloner.IsValid()) { // 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 (" << cloner.GetWarning() << ")\n"; } } tree_->SetEntries(tree_->GetEntries() + in->GetEntries()); Service<RootHandlers> rootHandler; rootHandler->enableErrorHandlerWithoutWarnings(); cloner.Exec(); rootHandler->enableErrorHandler(); if(mustRemoveSomeAuxs) { 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 262 of file RootOutputTree.cc.
References auxBranches_, fastCloneAuxBranches_, fillTTree(), producedBranches_, unclonedAuxBranches_, and unclonedReadBranches_.
{ if(!fastCloneAuxBranches_)fillTTree(auxBranches_); fillTTree(unclonedAuxBranches_); fillTTree(producedBranches_); fillTTree(unclonedReadBranches_); } else { tree_->Fill(); } }
void edm::RootOutputTree::fillTTree | ( | std::vector< TBranch * > const & | branches | ) | [static, private] |
Definition at line 231 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 241 of file RootOutputTree.cc.
References clonedReadBranchNames_, fastCloneAuxBranches_, fastCloneTTree(), readBranches_, tree_, and unclonedReadBranches_.
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()) { clonedReadBranchNames_.insert(std::string((*it)->GetName())); } else { unclonedReadBranches_.push_back(*it); } } Service<JobReport> reportSvc; reportSvc->reportFastClonedBranches(clonedReadBranchNames_, tree_->GetEntries()); } }
RootOutputTree& edm::RootOutputTree::operator= | ( | RootOutputTree const & | ) |
void edm::RootOutputTree::optimizeBaskets | ( | ULong64_t | size | ) | [inline] |
Definition at line 102 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 106 of file RootOutputTree.h.
References tree_.
Referenced by edm::RootOutputFile::RootOutputFile().
void edm::RootOutputTree::setEntries | ( | ) | [inline] |
Definition at line 91 of file RootOutputTree.h.
References tree_.
Referenced by edm::RootOutputFile::respondToCloseInputFile().
TTree* edm::RootOutputTree::tree | ( | ) | const [inline] |
bool edm::RootOutputTree::uncloned | ( | std::string const & | branchName | ) | const [inline] |
Definition at line 96 of file RootOutputTree.h.
References clonedReadBranchNames_.
{ return clonedReadBranchNames_.find(branchName) == clonedReadBranchNames_.end(); }
void edm::RootOutputTree::writeTree | ( | ) | const |
Definition at line 236 of file RootOutputTree.cc.
void edm::RootOutputTree::writeTTree | ( | TTree * | tree | ) | [static] |
Definition at line 222 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 118 of file RootOutputTree.h.
Referenced by addAuxiliary(), fastCloneTTree(), and fillTree().
std::set<std::string> edm::RootOutputTree::clonedReadBranchNames_ [private] |
Definition at line 121 of file RootOutputTree.h.
Referenced by maybeFastCloneTree(), and uncloned().
bool edm::RootOutputTree::currentlyFastCloning_ [private] |
Definition at line 122 of file RootOutputTree.h.
bool edm::RootOutputTree::fastCloneAuxBranches_ [private] |
Definition at line 123 of file RootOutputTree.h.
Referenced by fastCloneTTree(), fillTree(), and maybeFastCloneTree().
boost::shared_ptr<TFile> edm::RootOutputTree::filePtr_ [private] |
Definition at line 114 of file RootOutputTree.h.
std::vector<TBranch*> edm::RootOutputTree::producedBranches_ [private] |
Definition at line 116 of file RootOutputTree.h.
Referenced by addBranch(), and fillTree().
std::vector<TBranch*> edm::RootOutputTree::readBranches_ [private] |
Definition at line 117 of file RootOutputTree.h.
Referenced by addBranch(), and maybeFastCloneTree().
TTree* edm::RootOutputTree::tree_ [private] |
Definition at line 115 of file RootOutputTree.h.
Referenced by addAuxiliary(), addBranch(), fastCloneTTree(), maybeFastCloneTree(), optimizeBaskets(), RootOutputTree(), setAutoFlush(), setEntries(), and tree().
std::vector<TBranch*> edm::RootOutputTree::unclonedAuxBranches_ [private] |
Definition at line 119 of file RootOutputTree.h.
Referenced by addAuxiliary(), fastCloneTTree(), and fillTree().
std::vector<TBranch*> edm::RootOutputTree::unclonedReadBranches_ [private] |
Definition at line 120 of file RootOutputTree.h.
Referenced by fillTree(), and maybeFastCloneTree().