Public Types | Public Member Functions | Private Attributes | List of all members
art::RootInputFile::RootInputTree Class Reference

Public Types

using BranchMap = input::BranchMap
 
using EntryNumber = input::EntryNumber
 
using EntryNumbers = input::EntryNumbers
 

Public Member Functions

 ~RootInputTree ()
 
 RootInputTree (cet::exempt_ptr< TFile >, BranchType, int64_t saveMemoryObjectThreshold, cet::exempt_ptr< RootInputFile >, bool missingOK=false)
 
 RootInputTree (RootInputTree const &)=delete
 
 RootInputTree (RootInputTree &&)=delete
 
RootInputTreeoperator= (RootInputTree const &)=delete
 
RootInputTree && operator= (RootInputTree &&)=delete
 
bool isValid () const
 
EntryNumber entries () const
 
TTree * tree () const
 
TTree * metaTree () const
 
TBranch * auxBranch () const
 
TBranch * productProvenanceBranch () const
 
BranchMap const & branches () const
 
void addBranch (BranchDescription const &)
 
void dropBranch (std::string const &branchName)
 

Private Attributes

TTree * tree_ {nullptr}
 
TTree * metaTree_ {nullptr}
 
TBranch * auxBranch_ {nullptr}
 
TBranch * productProvenanceBranch_ {nullptr}
 
EntryNumber entries_ {0}
 
BranchMap branches_ {}
 

Detailed Description

Definition at line 57 of file RootInputFile.h.

Member Typedef Documentation

Definition at line 59 of file RootInputFile.h.

Definition at line 60 of file RootInputFile.h.

Definition at line 61 of file RootInputFile.h.

Constructor & Destructor Documentation

art::RootInputFile::RootInputTree::~RootInputTree ( )

Definition at line 125 of file RootInputFile.cc.

125 {}
art::RootInputFile::RootInputTree::RootInputTree ( cet::exempt_ptr< TFile >  filePtr,
BranchType  branchType,
int64_t  saveMemoryObjectThreshold,
cet::exempt_ptr< RootInputFile ,
bool  missingOK = false 
)

Definition at line 127 of file RootInputFile.cc.

133  {
134  if (filePtr) {
135  tree_ = static_cast<TTree*>(
136  filePtr->Get(BranchTypeToProductTreeName(branchType).c_str()));
137  metaTree_ = static_cast<TTree*>(
138  filePtr->Get(BranchTypeToMetaDataTreeName(branchType).c_str()));
139  }
140  if (tree_) {
141  auxBranch_ =
142  tree_->GetBranch(BranchTypeToAuxiliaryBranchName(branchType).c_str());
143  entries_ = tree_->GetEntries();
144  }
145  if (metaTree_) {
147  metaTree_->GetBranch(productProvenanceBranchName(branchType).c_str());
148  }
149  if (!missingOK && !isValid()) {
151  << "RootInputTree for branch type " << BranchTypeToString(branchType)
152  << " could not be initialized correctly from input file.\n";
153  }
154  }
std::string const & BranchTypeToProductTreeName(BranchType const bt)
Definition: BranchType.cc:71
std::string const & productProvenanceBranchName(BranchType const bt)
Definition: BranchType.cc:91
std::string const & BranchTypeToMetaDataTreeName(BranchType const bt)
Definition: BranchType.cc:77
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const bt)
Definition: BranchType.cc:83
std::string const & BranchTypeToString(BranchType const bt)
Definition: BranchType.cc:65
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
art::RootInputFile::RootInputTree::RootInputTree ( RootInputTree const &  )
delete
art::RootInputFile::RootInputTree::RootInputTree ( RootInputTree &&  )
delete

Member Function Documentation

void art::RootInputFile::RootInputTree::addBranch ( BranchDescription const &  bd)

Definition at line 202 of file RootInputFile.cc.

203  {
204  assert(isValid());
205  TBranch* branch = tree_->GetBranch(bd.branchName().c_str());
206  assert(bd.present() == (branch != nullptr));
207  assert(bd.dropped() == (branch == nullptr));
208  input::BranchInfo info{bd, branch};
209  branches_.emplace(bd.productID(), std::move(info));
210  }
TBranch * art::RootInputFile::RootInputTree::auxBranch ( ) const

Definition at line 157 of file RootInputFile.cc.

158  {
159  return auxBranch_;
160  }
RootInputFile::RootInputTree::BranchMap const & art::RootInputFile::RootInputTree::branches ( ) const

Definition at line 181 of file RootInputFile.cc.

182  {
183  return branches_;
184  }
void art::RootInputFile::RootInputTree::dropBranch ( std::string const &  branchName)

Definition at line 213 of file RootInputFile.cc.

214  {
215  TBranch* branch = tree_->GetBranch(branchName.c_str());
216  if (branch == nullptr) {
217  return;
218  }
219  TObjArray* leaves = tree_->GetListOfLeaves();
220  if (leaves == nullptr) {
221  return;
222  }
223  int entries = leaves->GetEntries();
224  for (int i = 0; i < entries; ++i) {
225  TLeaf* leaf = reinterpret_cast<TLeaf*>((*leaves)[i]);
226  if (leaf == nullptr) {
227  continue;
228  }
229  TBranch* br = leaf->GetBranch();
230  if (br == nullptr) {
231  continue;
232  }
233  if (br->GetMother() == branch) {
234  leaves->Remove(leaf);
235  }
236  }
237  leaves->Compress();
238  tree_->GetListOfBranches()->Remove(branch);
239  tree_->GetListOfBranches()->Compress();
240  delete branch;
241  branch = nullptr;
242  }
RootInputFile::RootInputTree::EntryNumber art::RootInputFile::RootInputTree::entries ( ) const

Definition at line 163 of file RootInputFile.cc.

164  {
165  return entries_;
166  }
bool art::RootInputFile::RootInputTree::isValid ( ) const

Definition at line 193 of file RootInputFile.cc.

194  {
195  if ((metaTree_ == nullptr) || (metaTree_->GetNbranches() == 0)) {
196  return tree_ && auxBranch_ && (tree_->GetNbranches() == 1);
197  }
199  }
TTree * art::RootInputFile::RootInputTree::metaTree ( ) const

Definition at line 175 of file RootInputFile.cc.

176  {
177  return metaTree_;
178  }
RootInputTree& art::RootInputFile::RootInputTree::operator= ( RootInputTree const &  )
delete
RootInputTree&& art::RootInputFile::RootInputTree::operator= ( RootInputTree &&  )
delete
TBranch * art::RootInputFile::RootInputTree::productProvenanceBranch ( ) const

Definition at line 187 of file RootInputFile.cc.

188  {
190  }
TTree * art::RootInputFile::RootInputTree::tree ( ) const

Definition at line 169 of file RootInputFile.cc.

170  {
171  return tree_;
172  }

Member Data Documentation

TBranch* art::RootInputFile::RootInputTree::auxBranch_ {nullptr}
private

Definition at line 89 of file RootInputFile.h.

BranchMap art::RootInputFile::RootInputTree::branches_ {}
private

Definition at line 92 of file RootInputFile.h.

EntryNumber art::RootInputFile::RootInputTree::entries_ {0}
private

Definition at line 91 of file RootInputFile.h.

TTree* art::RootInputFile::RootInputTree::metaTree_ {nullptr}
private

Definition at line 88 of file RootInputFile.h.

TBranch* art::RootInputFile::RootInputTree::productProvenanceBranch_ {nullptr}
private

Definition at line 90 of file RootInputFile.h.

TTree* art::RootInputFile::RootInputTree::tree_ {nullptr}
private

Definition at line 87 of file RootInputFile.h.


The documentation for this class was generated from the following files: