LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::RootBranchInfoList Class Reference

#include "RootBranchInfoList.h"

Public Member Functions

 RootBranchInfoList ()
 
 RootBranchInfoList (TTree *tree)
 
void reset (TTree *tree)
 
template<class PROD >
bool findBranchInfo (InputTag const &tag, RootBranchInfo &rbInfo) const
 
bool findBranchInfo (TypeID const &type, InputTag const &tag, RootBranchInfo &rbInfo) const
 

Private Attributes

std::vector< RootBranchInfodata_
 

Detailed Description

Definition at line 16 of file RootBranchInfoList.h.

Constructor & Destructor Documentation

art::RootBranchInfoList::RootBranchInfoList ( )

Definition at line 11 of file RootBranchInfoList.cc.

11 : data_() {}
std::vector< RootBranchInfo > data_
art::RootBranchInfoList::RootBranchInfoList ( TTree *  tree)
explicit

Definition at line 13 of file RootBranchInfoList.cc.

References reset().

13  : data_()
14 {
15  reset(tree);
16 }
std::vector< RootBranchInfo > data_

Member Function Documentation

template<class PROD >
bool art::RootBranchInfoList::findBranchInfo ( InputTag const &  tag,
RootBranchInfo rbInfo 
) const

Definition at line 35 of file RootBranchInfoList.h.

Referenced by art::MixOp< PROD, OPROD >::initializeBranchInfo().

37 {
38  return findBranchInfo(TypeID{typeid(PROD)}, tag, rbInfo);
39 }
bool findBranchInfo(InputTag const &tag, RootBranchInfo &rbInfo) const
bool art::RootBranchInfoList::findBranchInfo ( TypeID const &  type,
InputTag const &  tag,
RootBranchInfo rbInfo 
) const

Definition at line 42 of file RootBranchInfoList.cc.

References data_, art::TypeID::friendlyClassName(), art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

45 {
46  std::ostringstream pat_s;
47  pat_s << '^' << type.friendlyClassName() << '_' << tag.label() << '_'
48  << tag.instance() << '_';
49  if (tag.process().empty()) {
50  pat_s << ".*";
51  } else {
52  pat_s << tag.process();
53  }
54  pat_s << "\\.$";
55  std::regex const r{pat_s.str()};
56  // data_ is ordered so that the first match is the best.
57  for (auto const& datum : data_) {
58  if (std::regex_match(datum.branchName(), r)) {
59  rbInfo = datum;
60  return true;
61  }
62  }
63  return false;
64 }
std::vector< RootBranchInfo > data_
void art::RootBranchInfoList::reset ( TTree *  tree)

Definition at line 19 of file RootBranchInfoList.cc.

References data_, art::errors::DataCorruption, and art::errors::NullPointerError.

Referenced by RootBranchInfoList().

20 {
21  if (!tree) {
23  << "RootInfoBranchList given null TTree pointer.\n";
24  }
25  TObjArray* branches = tree->GetListOfBranches();
26  size_t nBranches = branches->GetEntriesFast();
27  data_.clear();
28  data_.reserve(nBranches);
29  TIter it(branches, kIterBackward);
30  // Load the list backward, then searches can take place in the forward
31  // direction.
32  while (TBranch* b = dynamic_cast<TBranch*>(it.Next())) {
33  data_.push_back(RootBranchInfo(b));
34  }
35  if (nBranches != data_.size()) {
36  throw Exception(errors::DataCorruption, "RootBranchInfoList")
37  << "Could not read expected number of branches from TTree's list.\n";
38  }
39 }
std::vector< RootBranchInfo > data_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66

Member Data Documentation

std::vector<RootBranchInfo> art::RootBranchInfoList::data_
private

Definition at line 30 of file RootBranchInfoList.h.

Referenced by findBranchInfo(), and reset().


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