#include <IOPool/Input/src/RootTree.h>
Public Types | |
typedef input::BranchMap | BranchMap |
typedef input::EntryNumber | EntryNumber |
Public Member Functions | |
void | addBranch (BranchKey const &key, BranchDescription const &prod, std::string const &oldBranchName) |
BranchMap const & | branches () const |
std::vector< std::string > const & | branchNames () const |
bool | current () |
void | dropBranch (std::string const &oldBranchName) |
EntryNumber const & | entries () const |
EntryNumber const & | entryNumber () const |
template<typename T> | |
void | fillAux (T *&pAux) const |
template<typename T> | |
void | fillGroups (T &item) |
void | fillStatus () |
bool | isValid () const |
template<typename T> | |
boost::shared_ptr< BranchMapper > | makeBranchMapper () const |
boost::shared_ptr< DelayedReader > | makeDelayedReader () const |
TTree const * | metaTree () const |
bool | next () |
bool | previous () |
std::vector< ProductStatus > const & | productStatuses () const |
void | rewind () |
RootTree (boost::shared_ptr< TFile > filePtr, BranchType const &branchType) | |
void | setCacheSize (unsigned int cacheSize) const |
void | setEntryNumber (EntryNumber theEntryNumber) |
void | setPresence (BranchDescription const &prod) |
void | setTreeMaxVirtualSize (int treeMaxVirtualSize) |
TTree const * | tree () const |
~RootTree () | |
Private Attributes | |
TBranch *const | auxBranch_ |
TBranch *const | branchEntryInfoBranch_ |
boost::shared_ptr< BranchMap > | branches_ |
std::vector< std::string > | branchNames_ |
BranchType | branchType_ |
EntryNumber | entries_ |
EntryNumber | entryNumber_ |
boost::shared_ptr< TFile > | filePtr_ |
TTree *const | infoTree_ |
TTree *const | metaTree_ |
std::vector< ProductStatus > * | pProductStatuses_ |
std::vector< ProductStatus > | productStatuses_ |
TBranch *const | statusBranch_ |
TTree *const | tree_ |
Definition at line 29 of file RootTree.h.
Definition at line 31 of file RootTree.h.
Definition at line 32 of file RootTree.h.
edm::RootTree::RootTree | ( | boost::shared_ptr< TFile > | filePtr, | |
BranchType const & | branchType | |||
) |
Definition at line 34 of file RootTree.cc.
00034 : 00035 filePtr_(filePtr), 00036 tree_(dynamic_cast<TTree *>(filePtr_.get() != 0 ? filePtr->Get(BranchTypeToProductTreeName(branchType).c_str()) : 0)), 00037 metaTree_(dynamic_cast<TTree *>(filePtr_.get() != 0 ? filePtr->Get(BranchTypeToMetaDataTreeName(branchType).c_str()) : 0)), 00038 branchType_(branchType), 00039 auxBranch_(tree_ ? getAuxiliaryBranch(tree_, branchType_) : 0), 00040 branchEntryInfoBranch_(metaTree_ ? getEventEntryInfoBranch(metaTree_, branchType_) : 0), 00041 entries_(tree_ ? tree_->GetEntries() : 0), 00042 entryNumber_(-1), 00043 branchNames_(), 00044 branches_(new BranchMap), 00045 productStatuses_(), 00046 pProductStatuses_(&productStatuses_), 00047 infoTree_(dynamic_cast<TTree *>(filePtr_.get() != 0 ? filePtr->Get(BranchTypeToInfoTreeName(branchType).c_str()) : 0)), 00048 statusBranch_(infoTree_ ? getStatusBranch(infoTree_, branchType_) : 0) 00049 { }
edm::RootTree::~RootTree | ( | ) | [inline] |
void edm::RootTree::addBranch | ( | BranchKey const & | key, | |
BranchDescription const & | prod, | |||
std::string const & | oldBranchName | |||
) |
Definition at line 71 of file RootTree.cc.
References branches_, edm::BranchDescription::branchName(), branchNames_, info, edm::BranchDescription::init(), isValid(), metaTree_, edm::BranchDescription::present(), edm::input::BranchInfo::productBranch_, edm::input::BranchInfo::provenanceBranch_, and tree_.
00073 { 00074 assert(isValid()); 00075 prod.init(); 00076 //use the translated branch name 00077 TBranch * branch = tree_->GetBranch(oldBranchName.c_str()); 00078 assert (prod.present() == (branch != 0)); 00079 input::BranchInfo info = input::BranchInfo(ConstBranchDescription(prod)); 00080 info.productBranch_ = 0; 00081 if (prod.present()) { 00082 info.productBranch_ = branch; 00083 //we want the new branch name for the JobReport 00084 branchNames_.push_back(prod.branchName()); 00085 } 00086 info.provenanceBranch_ = metaTree_->GetBranch(oldBranchName.c_str()); 00087 branches_->insert(std::make_pair(key, info)); 00088 }
BranchMap const& edm::RootTree::branches | ( | ) | const [inline] |
Definition at line 65 of file RootTree.h.
References branches_.
Referenced by edm::RootFile::makeBranchMapper().
00065 {return *branches_;}
std::vector<std::string> const& edm::RootTree::branchNames | ( | ) | const [inline] |
Definition at line 49 of file RootTree.h.
References branchNames_.
Referenced by edm::RootFile::reportOpened().
00049 {return branchNames_;}
void edm::RootTree::dropBranch | ( | std::string const & | oldBranchName | ) |
Definition at line 91 of file RootTree.cc.
References entries(), i, python::Node::leaf, and tree_.
00091 { 00092 //use the translated branch name 00093 TBranch * branch = tree_->GetBranch(oldBranchName.c_str()); 00094 if (branch != 0) { 00095 TObjArray * leaves = tree_->GetListOfLeaves(); 00096 int entries = leaves->GetEntries(); 00097 for (int i = 0; i < entries; ++i) { 00098 TLeaf *leaf = (TLeaf *)(*leaves)[i]; 00099 if (leaf == 0) continue; 00100 TBranch* br = leaf->GetBranch(); 00101 if (br == 0) continue; 00102 if (br->GetMother() == branch) { 00103 leaves->Remove(leaf); 00104 } 00105 } 00106 leaves->Compress(); 00107 tree_->GetListOfBranches()->Remove(branch); 00108 tree_->GetListOfBranches()->Compress(); 00109 delete branch; 00110 } 00111 }
EntryNumber const& edm::RootTree::entries | ( | ) | const [inline] |
Definition at line 47 of file RootTree.h.
References entries_.
Referenced by dropBranch(), and edm::RootFile::setIfFastClonable().
00047 {return entries_;}
EntryNumber const& edm::RootTree::entryNumber | ( | ) | const [inline] |
Definition at line 46 of file RootTree.h.
References entryNumber_.
Referenced by edm::RootFile::fillFileIndex(), edm::RootFile::fillHistory(), and edm::RootFile::makeBranchMapper().
00046 {return entryNumber_;}
void edm::RootTree::fillAux | ( | T *& | pAux | ) | const [inline] |
Definition at line 57 of file RootTree.h.
References auxBranch_, entryNumber_, and edm::input::getEntry().
Referenced by edm::RootFile::fillEventAuxiliary(), edm::RootFile::fillLumiAuxiliary(), and edm::RootFile::fillRunAuxiliary().
00057 { 00058 auxBranch_->SetAddress(&pAux); 00059 input::getEntry(auxBranch_, entryNumber_); 00060 }
void edm::RootTree::fillGroups | ( | T & | item | ) | [inline] |
Definition at line 98 of file RootTree.h.
References branches_, and metaTree_.
Referenced by edm::RootFile::readCurrentEvent(), edm::RootFile::readLumi(), and edm::RootFile::readRun().
00098 { 00099 if (metaTree_ == 0 || metaTree_->GetNbranches() == 0) return; 00100 // Loop over provenance 00101 for (BranchMap::const_iterator pit = branches_->begin(), pitEnd = branches_->end(); pit != pitEnd; ++pit) { 00102 item.addGroup(pit->second.branchDescription_); 00103 } 00104 }
void edm::RootTree::fillStatus | ( | ) | [inline] |
Definition at line 69 of file RootTree.h.
References entryNumber_, edm::input::getEntry(), pProductStatuses_, and statusBranch_.
Referenced by edm::RootFile::makeBranchMapper().
00069 { 00070 statusBranch_->SetAddress(&pProductStatuses_); 00071 input::getEntry(statusBranch_, entryNumber_); 00072 }
Definition at line 52 of file RootTree.cc.
References auxBranch_, branchEntryInfoBranch_, entries_, metaTree_, statusBranch_, and tree_.
Referenced by addBranch(), edm::RootFile::fillFileIndex(), edm::RootFile::readLumi(), edm::RootFile::readRun(), setPresence(), and edm::RootFile::validateFile().
00052 { 00053 if (metaTree_ == 0 || metaTree_->GetNbranches() == 0) { 00054 return tree_ != 0 && auxBranch_ != 0 && tree_->GetNbranches() == 1; 00055 } 00056 if (tree_ != 0 && auxBranch_ != 0 && metaTree_ != 0) { 00057 if (branchEntryInfoBranch_ != 0 || statusBranch_ != 0) return true; 00058 return (entries_ == metaTree_->GetEntries() && tree_->GetNbranches() <= metaTree_->GetNbranches() + 1); 00059 } 00060 return false; 00061 }
boost::shared_ptr< BranchMapper > edm::RootTree::makeBranchMapper | ( | ) | const [inline] |
Definition at line 108 of file RootTree.h.
References branchEntryInfoBranch_, and entryNumber_.
Referenced by edm::RootFile::makeBranchMapper().
00108 { 00109 assert (branchEntryInfoBranch_); 00110 boost::shared_ptr<BranchMapper> mapper(new BranchMapperWithReader<T>(branchEntryInfoBranch_, entryNumber_)); 00111 return mapper; 00112 }
boost::shared_ptr< DelayedReader > edm::RootTree::makeDelayedReader | ( | ) | const |
Definition at line 114 of file RootTree.cc.
References branches_, entryNumber_, and filePtr_.
Referenced by edm::RootFile::readCurrentEvent(), edm::RootFile::readLumi(), and edm::RootFile::readRun().
00114 { 00115 boost::shared_ptr<DelayedReader> store(new RootDelayedReader(entryNumber_, branches_, filePtr_)); 00116 return store; 00117 }
TTree const* edm::RootTree::metaTree | ( | ) | const [inline] |
Definition at line 62 of file RootTree.h.
References metaTree_.
Referenced by edm::RootFile::createFileBlock().
00062 {return metaTree_;}
Definition at line 42 of file RootTree.h.
References entries_, and entryNumber_.
Referenced by edm::RootFile::fillFileIndex(), edm::RootFile::initializeDuplicateChecker(), edm::RootFile::nextEventEntry(), edm::RootFile::readLumi(), and edm::RootFile::readRun().
00042 {return ++entryNumber_ < entries_;}
bool edm::RootTree::previous | ( | ) | [inline] |
Definition at line 43 of file RootTree.h.
References entryNumber_.
Referenced by edm::RootFile::readLumi(), and edm::RootFile::readRun().
00043 {return --entryNumber_ >= 0;}
std::vector<ProductStatus> const& edm::RootTree::productStatuses | ( | ) | const [inline] |
Definition at line 66 of file RootTree.h.
References productStatuses_.
Referenced by edm::RootFile::makeBranchMapper().
00066 {return productStatuses_;}
Definition at line 45 of file RootTree.h.
References entryNumber_.
Referenced by edm::RootFile::rewind().
00045 {entryNumber_ = 0;}
Definition at line 120 of file RootTree.cc.
References tree_.
Referenced by edm::RootFile::RootFile().
00120 { 00121 tree_->SetCacheSize(static_cast<Long64_t>(cacheSize)); 00122 }
void edm::RootTree::setEntryNumber | ( | EntryNumber | theEntryNumber | ) |
Definition at line 130 of file RootTree.cc.
References branches_, e, entryNumber_, filePtr_, i, tc, and tree_.
Referenced by edm::RootFile::fillFileIndex(), edm::RootFile::initializeDuplicateChecker(), edm::RootFile::readEvent(), edm::RootFile::readLumi(), edm::RootFile::readRun(), edm::RootFile::setAtEventEntry(), edm::RootFile::setEntryAtEvent(), edm::RootFile::setEntryAtLumi(), and edm::RootFile::setEntryAtRun().
00130 { 00131 if (TTreeCache *tc = dynamic_cast<TTreeCache *>(filePtr_->GetCacheRead())) { 00132 if (theEntryNumber >= 0 && tc->GetOwner() == tree_ && tc->IsLearning()) { 00133 tc->SetLearnEntries(1); 00134 tc->SetEntryRange(0, tree_->GetEntries()); 00135 for (BranchMap::const_iterator i = branches_->begin(), e = branches_->end(); i != e; ++i) { 00136 if (i->second.productBranch_) { 00137 tc->AddBranch(i->second.productBranch_, kTRUE); 00138 } 00139 } 00140 tc->StopLearningPhase(); 00141 } 00142 } 00143 00144 entryNumber_ = theEntryNumber; 00145 tree_->LoadTree(theEntryNumber); 00146 }
void edm::RootTree::setPresence | ( | BranchDescription const & | prod | ) |
Definition at line 64 of file RootTree.cc.
References edm::BranchDescription::branchName(), edm::BranchDescription::init(), isValid(), edm::BranchDescription::setPresent(), and tree_.
00064 { 00065 assert(isValid()); 00066 prod.init(); 00067 prod.setPresent(tree_->GetBranch(prod.branchName().c_str()) != 0); 00068 }
Definition at line 125 of file RootTree.cc.
References tree_.
Referenced by edm::RootFile::RootFile().
00125 { 00126 if (treeMaxVirtualSize >= 0) tree_->SetMaxVirtualSize(static_cast<Long64_t>(treeMaxVirtualSize)); 00127 }
TTree const* edm::RootTree::tree | ( | ) | const [inline] |
Definition at line 61 of file RootTree.h.
References tree_.
Referenced by edm::RootFile::createFileBlock().
00061 {return tree_;}
TBranch* const edm::RootTree::auxBranch_ [private] |
TBranch* const edm::RootTree::branchEntryInfoBranch_ [private] |
boost::shared_ptr<BranchMap> edm::RootTree::branches_ [private] |
Definition at line 87 of file RootTree.h.
Referenced by addBranch(), branches(), fillGroups(), makeDelayedReader(), and setEntryNumber().
std::vector<std::string> edm::RootTree::branchNames_ [private] |
BranchType edm::RootTree::branchType_ [private] |
Definition at line 81 of file RootTree.h.
EntryNumber edm::RootTree::entries_ [private] |
EntryNumber edm::RootTree::entryNumber_ [private] |
Definition at line 85 of file RootTree.h.
Referenced by entryNumber(), fillAux(), fillStatus(), makeBranchMapper(), makeDelayedReader(), next(), previous(), rewind(), and setEntryNumber().
boost::shared_ptr<TFile> edm::RootTree::filePtr_ [private] |
TTree* const edm::RootTree::infoTree_ [private] |
Definition at line 92 of file RootTree.h.
TTree* const edm::RootTree::metaTree_ [private] |
Definition at line 80 of file RootTree.h.
Referenced by addBranch(), fillGroups(), isValid(), and metaTree().
std::vector<ProductStatus>* edm::RootTree::pProductStatuses_ [private] |
std::vector<ProductStatus> edm::RootTree::productStatuses_ [private] |
TBranch* const edm::RootTree::statusBranch_ [private] |
TTree* const edm::RootTree::tree_ [private] |
Definition at line 79 of file RootTree.h.
Referenced by addBranch(), dropBranch(), isValid(), setCacheSize(), setEntryNumber(), setPresence(), setTreeMaxVirtualSize(), and tree().