Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
art::MixOp< PROD, OPROD > Class Template Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/art/v2_13_00/source/art/Framework/IO/ProductMix/MixOp.h"

Inheritance diagram for art::MixOp< PROD, OPROD >:
art::MixOpBase

Public Member Functions

template<typename FUNC >
 MixOp (InputTag const &inputTag, std::string const &outputInstanceLabel, FUNC mixFunc, bool outputProduct, bool compactMissingProducts, BranchType bt)
 
InputTag const & inputTag () const override
 
TypeID const & inputType () const override
 
std::string const & outputInstanceLabel () const override
 
void mixAndPut (Event &e, PtrRemapper const &remap) const override
 
void initializeBranchInfo (RootBranchInfoList const &rbiList) override
 
ProductID incomingProductID () const override
 
ProductID outgoingProductID () const override
 
void readFromFile (EntryNumberSequence const &seq, cet::exempt_ptr< BranchIDLists const > branchIDLists) override
 
BranchType branchType () const override
 

Protected Member Functions

void configureStreamers (cet::exempt_ptr< BranchIDLists const > branchIDLists)
 

Private Types

using SpecProdList = std::vector< std::shared_ptr< Wrapper< PROD >>>
 

Private Attributes

InputTag const inputTag_
 
TypeID const inputType_
 
std::string const outputInstanceLabel_
 
MixFunc< PROD, OPROD > const mixFunc_
 
SpecProdList inProducts_ {}
 
std::string const processName_
 
std::string const moduleLabel_
 
RootBranchInfo branchInfo_ {}
 
bool const outputProduct_
 
bool const compactMissingProducts_
 
BranchType const branchType_
 

Detailed Description

template<typename PROD, typename OPROD>
class art::MixOp< PROD, OPROD >

Definition at line 28 of file MixOp.h.

Member Typedef Documentation

template<typename PROD , typename OPROD >
using art::MixOp< PROD, OPROD >::SpecProdList = std::vector<std::shared_ptr<Wrapper<PROD>>>
private

Definition at line 63 of file MixOp.h.

Constructor & Destructor Documentation

template<typename PROD , typename OPROD >
template<typename FUNC >
art::MixOp< PROD, OPROD >::MixOp ( InputTag const &  inputTag,
std::string const &  outputInstanceLabel,
FUNC  mixFunc,
bool  outputProduct,
bool  compactMissingProducts,
BranchType  bt 
)

Definition at line 80 of file MixOp.h.

References art::MixOp< PROD, OPROD >::branchType_, art::MixOp< PROD, OPROD >::compactMissingProducts_, art::MixOp< PROD, OPROD >::inputType_, art::MixOp< PROD, OPROD >::mixFunc_, art::MixOp< PROD, OPROD >::moduleLabel_, art::MixOp< PROD, OPROD >::outputInstanceLabel(), art::MixOp< PROD, OPROD >::outputInstanceLabel_, art::MixOp< PROD, OPROD >::outputProduct_, and art::MixOp< PROD, OPROD >::processName_.

87  , inputType_{typeid(PROD)}
89  , mixFunc_{mixFunc}
90  , processName_{ServiceHandle<TriggerNamesService const>{}->getProcessName()}
91  , moduleLabel_{ServiceHandle<CurrentModule const>{}->label()}
92  , outputProduct_{outputProduct}
93  , compactMissingProducts_{compactMissingProducts}
94  , branchType_{bt}
95 {}
MixFunc< PROD, OPROD > const mixFunc_
Definition: MixOp.h:68
BranchType const branchType_
Definition: MixOp.h:75
std::string const moduleLabel_
Definition: MixOp.h:71
InputTag const & inputTag() const override
Definition: MixOp.h:99
std::string const outputInstanceLabel_
Definition: MixOp.h:67
bool const outputProduct_
Definition: MixOp.h:73
InputTag const inputTag_
Definition: MixOp.h:65
bool const compactMissingProducts_
Definition: MixOp.h:74
std::string const processName_
Definition: MixOp.h:70
TypeID const inputType_
Definition: MixOp.h:66
std::string const & outputInstanceLabel() const override
Definition: MixOp.h:113

Member Function Documentation

template<typename PROD , typename OPROD >
art::BranchType art::MixOp< PROD, OPROD >::branchType ( ) const
inlineoverridevirtual

Implements art::MixOpBase.

Definition at line 233 of file MixOp.h.

References art::MixOp< PROD, OPROD >::branchType_.

234 {
235  return branchType_;
236 }
BranchType const branchType_
Definition: MixOp.h:75
void art::MixOpBase::configureStreamers ( cet::exempt_ptr< BranchIDLists const >  branchIDLists)
protectedinherited
template<typename PROD , typename OPROD >
art::ProductID art::MixOp< PROD, OPROD >::incomingProductID ( ) const
overridevirtual

Implements art::MixOpBase.

Definition at line 171 of file MixOp.h.

References art::MixOp< PROD, OPROD >::branchInfo_, and art::RootBranchInfo::branchName().

172 {
173  return ProductID{branchInfo_.branchName()};
174 }
std::string const & branchName() const
RootBranchInfo branchInfo_
Definition: MixOp.h:72
template<typename PROD , typename OPROD >
void art::MixOp< PROD, OPROD >::initializeBranchInfo ( RootBranchInfoList const &  rbiList)
overridevirtual

Implements art::MixOpBase.

Definition at line 155 of file MixOp.h.

References art::MixOp< PROD, OPROD >::branchInfo_, art::detail::checkForMissingDictionaries(), art::RootBranchInfoList::findBranchInfo(), art::TypeID::friendlyClassName(), art::MixOp< PROD, OPROD >::inputTag_, art::MixOp< PROD, OPROD >::inputType_, art::errors::ProductNotFound, and gen_hdf5record::types.

157 {
158  if (!branchInfo_List.findBranchInfo(inputType_, inputTag_, branchInfo_)) {
160  << "Unable to find requested product " << inputTag_ << " of type "
161  << inputType_.friendlyClassName() << " in secondary input stream.\n";
162  }
163  // Check dictionaries for input product, not output product: let
164  // output modules take care of that.
165  std::vector<TypeID> const types{TypeID{typeid(PROD)}};
167 }
std::string friendlyClassName() const
InputTag const inputTag_
Definition: MixOp.h:65
TypeID const inputType_
Definition: MixOp.h:66
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
RootBranchInfo branchInfo_
Definition: MixOp.h:72
void checkForMissingDictionaries(std::vector< TypeID > const &types) noexcept( false)
template<typename PROD , typename OPROD >
art::InputTag const & art::MixOp< PROD, OPROD >::inputTag ( ) const
overridevirtual

Implements art::MixOpBase.

Definition at line 99 of file MixOp.h.

References art::MixOp< PROD, OPROD >::inputTag_.

100 {
101  return inputTag_;
102 }
InputTag const inputTag_
Definition: MixOp.h:65
template<typename PROD , typename OPROD >
art::TypeID const & art::MixOp< PROD, OPROD >::inputType ( ) const
overridevirtual

Implements art::MixOpBase.

Definition at line 106 of file MixOp.h.

References art::MixOp< PROD, OPROD >::inputType_, and string.

107 {
108  return inputType_;
109 }
TypeID const inputType_
Definition: MixOp.h:66
template<typename PROD , typename OPROD >
void art::MixOp< PROD, OPROD >::mixAndPut ( Event e,
PtrRemapper const &  remap 
) const
overridevirtual

Implements art::MixOpBase.

Definition at line 120 of file MixOp.h.

References art::MixOp< PROD, OPROD >::compactMissingProducts_, art::errors::DataCorruption, MECModelEnuComparisons::i, art::MixOp< PROD, OPROD >::inProducts_, art::errors::LogicError, art::MixOp< PROD, OPROD >::mixFunc_, art::MixOp< PROD, OPROD >::outputInstanceLabel_, art::MixOp< PROD, OPROD >::outputProduct_, stan::math::prod(), and art::Event::put().

121 {
122  auto rProd = std::make_unique<OPROD>();
123  std::vector<PROD const*> inConverted;
124  inConverted.reserve(inProducts_.size());
125  try {
126  auto const endIter = cend(inProducts_);
127  for (auto i = cbegin(inProducts_); i != endIter; ++i) {
128  auto const prod = (*i)->product();
129  if (prod || !compactMissingProducts_) {
130  inConverted.emplace_back(prod);
131  }
132  }
133  }
134  catch (std::bad_cast const&) {
136  << "Unable to obtain correctly-typed product from wrapper.\n";
137  }
138  if (mixFunc_(inConverted, *rProd, remap)) {
139  if (!outputProduct_) {
141  << "Returned true (output product to be put in event) from a mix "
142  "function\n"
143  << "declared with outputProduct=false.\n";
144  }
145  if (outputInstanceLabel_.empty()) {
146  e.put(std::move(rProd));
147  } else {
148  e.put(std::move(rProd), outputInstanceLabel_);
149  }
150  } // False means don't want this in the event.
151 }
MixFunc< PROD, OPROD > const mixFunc_
Definition: MixOp.h:68
std::string const outputInstanceLabel_
Definition: MixOp.h:67
bool const outputProduct_
Definition: MixOp.h:73
SpecProdList inProducts_
Definition: MixOp.h:69
bool const compactMissingProducts_
Definition: MixOp.h:74
T prod(const std::vector< T > &v)
Definition: prod.hpp:17
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Float_t e
Definition: plot.C:35
template<typename PROD , typename OPROD >
art::ProductID art::MixOp< PROD, OPROD >::outgoingProductID ( ) const
overridevirtual

Implements art::MixOpBase.

Definition at line 178 of file MixOp.h.

References febshutoff_auto::end, art::InEvent, art::ProductMetaData::instance(), findDuplicateFiles::key, art::errors::LogicError, art::MixOp< PROD, OPROD >::moduleLabel_, art::MixOp< PROD, OPROD >::outputInstanceLabel_, art::MixOp< PROD, OPROD >::outputProduct_, art::MixOp< PROD, OPROD >::processName_, art::ProductMetaData::productList(), and fillBadChanDBTables::result.

179 {
181  if (outputProduct_) {
182  TypeID const outputType{typeid(OPROD)};
183  BranchKey const key{outputType.friendlyClassName(),
184  moduleLabel_,
186  processName_,
187  art::InEvent}; // Outgoing product must be InEvent.
188  auto I = ProductMetaData::instance().productList().find(key);
189  if (I == ProductMetaData::instance().productList().end()) {
191  << "MixOp unable to find branch id for a product ("
192  << outputType.className() << ") that should have been registered!\n";
193  }
194  result = I->second.productID();
195  }
196  return result;
197 }
std::string const moduleLabel_
Definition: MixOp.h:71
std::string const outputInstanceLabel_
Definition: MixOp.h:67
static ProductMetaData const & instance()
bool const outputProduct_
Definition: MixOp.h:73
std::string const processName_
Definition: MixOp.h:70
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProductList const & productList() const
template<typename PROD , typename OPROD >
std::string const & art::MixOp< PROD, OPROD >::outputInstanceLabel ( ) const
overridevirtual

Implements art::MixOpBase.

Definition at line 113 of file MixOp.h.

References art::MixOp< PROD, OPROD >::outputInstanceLabel_.

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

114 {
115  return outputInstanceLabel_;
116 }
std::string const outputInstanceLabel_
Definition: MixOp.h:67
template<typename PROD , typename OPROD >
void art::MixOp< PROD, OPROD >::readFromFile ( EntryNumberSequence const &  seq,
cet::exempt_ptr< BranchIDLists const >  branchIDLists 
)
overridevirtual

Implements art::MixOpBase.

Definition at line 201 of file MixOp.h.

References b, art::RootBranchInfo::branch(), art::MixOp< PROD, OPROD >::branchInfo_, art::MixOpBase::configureStreamers(), distance(), e, MECModelEnuComparisons::i, art::MixOp< PROD, OPROD >::inProducts_, and art::errors::LogicError.

204 {
205  inProducts_.clear();
206  inProducts_.reserve(seq.size());
207  if (branchInfo_.branch() == nullptr) {
208  throw Exception(errors::LogicError) << "Branch not initialized for read.\n";
209  }
210  configureStreamers(branchIDLists);
211 
212  // Assume the sequence is ordered per
213  // MixHelper::generateEventSequence.
214  auto const b = seq.cbegin(), e = seq.cend();
215  for (auto i = b; i != e; ++i) {
216  auto fit = std::find(b, i, *i);
217  if (fit == i) { // Need new product.
218  inProducts_.emplace_back(new Wrapper<PROD>);
219  Wrapper<PROD>* wp = inProducts_.back().get();
220  branchInfo_.branch()->SetAddress(&wp);
221  branchInfo_.branch()->GetEntry(*i);
222  branchInfo_.branch()->ResetAddress();
223  } else { // Already have one: find and use.
224  auto pit = cbegin(inProducts_);
225  std::advance(pit, std::distance(b, fit));
226  inProducts_.emplace_back(*pit);
227  }
228  }
229 }
void configureStreamers(cet::exempt_ptr< BranchIDLists const > branchIDLists)
unsigned distance(const T &t1, const T &t2)
SpecProdList inProducts_
Definition: MixOp.h:69
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
RootBranchInfo branchInfo_
Definition: MixOp.h:72
const hit & b
Definition: hits.cxx:21
TBranch const * branch() const
Float_t e
Definition: plot.C:35

Member Data Documentation

template<typename PROD , typename OPROD >
RootBranchInfo art::MixOp< PROD, OPROD >::branchInfo_ {}
private
template<typename PROD , typename OPROD >
BranchType const art::MixOp< PROD, OPROD >::branchType_
private
template<typename PROD , typename OPROD >
bool const art::MixOp< PROD, OPROD >::compactMissingProducts_
private
template<typename PROD , typename OPROD >
SpecProdList art::MixOp< PROD, OPROD >::inProducts_ {}
private
template<typename PROD , typename OPROD >
InputTag const art::MixOp< PROD, OPROD >::inputTag_
private
template<typename PROD , typename OPROD >
TypeID const art::MixOp< PROD, OPROD >::inputType_
private
template<typename PROD , typename OPROD >
MixFunc<PROD, OPROD> const art::MixOp< PROD, OPROD >::mixFunc_
private
template<typename PROD , typename OPROD >
std::string const art::MixOp< PROD, OPROD >::moduleLabel_
private
template<typename PROD , typename OPROD >
std::string const art::MixOp< PROD, OPROD >::outputInstanceLabel_
private
template<typename PROD , typename OPROD >
bool const art::MixOp< PROD, OPROD >::outputProduct_
private
template<typename PROD , typename OPROD >
std::string const art::MixOp< PROD, OPROD >::processName_
private

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