Public Member Functions | Private Attributes | List of all members
gallery::BranchMapReader Class Reference

#include <BranchMapReader.h>

Public Member Functions

void updateFile (TFile *tFile)
 
art::BranchDescription const * productDescription (InfoForTypeLabelInstance const &info, std::string const &process) const
 
art::BranchDescription const * productDescription (art::TypeID const &type, std::string const &label, std::string const &instance, std::string const &process) const
 
art::BranchDescription const * productDescription (art::ProductID const pid) const
 
std::map< art::ProductID, art::BranchDescription > const & productDescriptions () const
 
cet::exempt_ptr< art::BranchIDLists const > branchIDLists () const
 
bool branchInRegistryOfAnyOpenedFile (art::ProductID const &) const
 

Private Attributes

std::unique_ptr< art::BranchIDListsbranchIDLists_
 
std::map< art::ProductID, art::BranchDescriptionproductIDToDescriptionMap_ {}
 
std::set< art::ProductIDallSeenProductIDs_ {}
 

Detailed Description

Definition at line 27 of file BranchMapReader.h.

Member Function Documentation

cet::exempt_ptr< art::BranchIDLists const > gallery::BranchMapReader::branchIDLists ( ) const

Definition at line 124 of file BranchMapReader.cc.

125  {
126  return branchIDLists_.get();
127  }
std::unique_ptr< art::BranchIDLists > branchIDLists_
bool gallery::BranchMapReader::branchInRegistryOfAnyOpenedFile ( art::ProductID const &  productID) const

Definition at line 130 of file BranchMapReader.cc.

132  {
133  return allSeenProductIDs_.find(productID) != allSeenProductIDs_.end();
134  }
std::set< art::ProductID > allSeenProductIDs_
art::BranchDescription const * gallery::BranchMapReader::productDescription ( InfoForTypeLabelInstance const &  info,
std::string const &  process 
) const

Definition at line 82 of file BranchMapReader.cc.

84  {
85  return productDescription(
86  info.type(), info.label(), info.instance(), process);
87  }
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
def process(f, kind)
Definition: search.py:254
art::BranchDescription const * gallery::BranchMapReader::productDescription ( art::TypeID const &  type,
std::string const &  label,
std::string const &  instance,
std::string const &  process 
) const

Definition at line 90 of file BranchMapReader.cc.

94  {
95  auto const fcn = type.friendlyClassName();
96  auto match = [&fcn, &label, &instance, &process](auto const& pr) {
97  auto const& pd = pr.second;
98  return pd.friendlyClassName() == fcn && pd.moduleLabel() == label &&
99  pd.productInstanceName() == instance &&
100  pd.processName() == process;
101  };
102  auto const end = cend(productIDToDescriptionMap_);
103  auto it = std::find_if(cbegin(productIDToDescriptionMap_), end, match);
104  return it == end ? nullptr : &it->second;
105  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
const std::string instance
std::map< art::ProductID, art::BranchDescription > productIDToDescriptionMap_
def process(f, kind)
Definition: search.py:254
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
Definition: StdUtils.h:82
art::BranchDescription const * gallery::BranchMapReader::productDescription ( art::ProductID const  pid) const

Definition at line 108 of file BranchMapReader.cc.

109  {
110  auto bdi = productIDToDescriptionMap_.find(pid);
111  if (bdi == cend(productIDToDescriptionMap_)) {
112  return nullptr;
113  }
114  return &bdi->second;
115  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
std::map< art::ProductID, art::BranchDescription > productIDToDescriptionMap_
std::map< art::ProductID, art::BranchDescription > const & gallery::BranchMapReader::productDescriptions ( ) const

Definition at line 118 of file BranchMapReader.cc.

119  {
121  }
std::map< art::ProductID, art::BranchDescription > productIDToDescriptionMap_
void gallery::BranchMapReader::updateFile ( TFile *  tFile)

Definition at line 20 of file BranchMapReader.cc.

21  {
22 
23  std::unique_ptr<TTree> metaDataTree{
24  tFile->Get<TTree>(art::rootNames::metaDataTreeName().c_str())};
25  if (!metaDataTree) {
27  }
28 
29  auto productRegistry = std::make_unique<art::ProductRegistry>();
30  auto* productRegistryPtr = productRegistry.get();
31  TBranch* productRegistryBranch = metaDataTree->GetBranch(
32  art::rootNames::metaBranchRootName<art::ProductRegistry>());
33  if (productRegistryBranch == nullptr) {
35  art::rootNames::metaBranchRootName<art::ProductRegistry>());
36  }
37  metaDataTree->SetBranchAddress(
38  art::rootNames::metaBranchRootName<art::ProductRegistry>(),
39  &productRegistryPtr);
40 
41  // To support files that contain BranchIDLists
42  branchIDLists_.reset(nullptr);
44  bool hasBranchIDLists{false};
45  if (metaDataTree->GetBranch(
46  art::rootNames::metaBranchRootName<art::BranchIDLists>())) {
47  hasBranchIDLists = true;
48  auto branchIDListsPtr = &branchIDLists;
49  metaDataTree->SetBranchAddress(
50  art::rootNames::metaBranchRootName<art::BranchIDLists>(),
51  &branchIDListsPtr);
52  }
53 
54  metaDataTree->GetEntry(0);
55 
56  // Necessary only for supporting conversion of an old Product ID
57  // schema to the current one
58  if (hasBranchIDLists) {
60  std::make_unique<art::BranchIDLists>(std::move(branchIDLists));
61  metaDataTree->SetBranchAddress(
62  art::rootNames::metaBranchRootName<art::BranchIDLists>(), nullptr);
63  }
64 
66  for (auto const& product : productRegistry->productList_) {
67  art::BranchDescription const& branchDescription = product.second;
68  if (branchDescription.branchType() != art::InEvent)
69  continue;
70  if (!branchDescription.productID().isValid())
71  continue;
72 
73  art::detail::BranchDescriptionStreamer::fluffRootTransients(
74  branchDescription);
75  productIDToDescriptionMap_.emplace(branchDescription.productID(),
76  branchDescription);
77  allSeenProductIDs_.insert(branchDescription.productID());
78  }
79  }
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:18
std::map< art::ProductID, art::BranchDescription > productIDToDescriptionMap_
BranchType branchType() const noexcept
void throwTreeNotFound(std::string const &treeName)
std::string const & metaDataTreeName()
Definition: rootNames.cc:42
def move(depos, offset)
Definition: depos.py:107
constexpr bool isValid() const noexcept
Definition: ProductID.h:34
void throwBranchNotFound(std::string const &branchName)
std::unique_ptr< art::BranchIDLists > branchIDLists_
cet::exempt_ptr< art::BranchIDLists const > branchIDLists() const
std::set< art::ProductID > allSeenProductIDs_
ProductID productID() const noexcept

Member Data Documentation

std::set<art::ProductID> gallery::BranchMapReader::allSeenProductIDs_ {}
private

Definition at line 56 of file BranchMapReader.h.

std::unique_ptr<art::BranchIDLists> gallery::BranchMapReader::branchIDLists_
private
Initial value:
{
nullptr}

Definition at line 52 of file BranchMapReader.h.

std::map<art::ProductID, art::BranchDescription> gallery::BranchMapReader::productIDToDescriptionMap_ {}
private

Definition at line 55 of file BranchMapReader.h.


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