LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::MixOp< PROD, OPROD > Class Template Reference

#include "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 232 of file MixOp.h.

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

233 {
234  return branchType_;
235 }
BranchType const branchType_
Definition: MixOp.h:75
void art::MixOpBase::configureStreamers ( cet::exempt_ptr< BranchIDLists const >  branchIDLists)
protectedinherited

Definition at line 9 of file MixOpBase.cc.

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

11 {
12  // Make sure the schema evolution is ready for ProductID
13  configureProductIDStreamer(branchIDLists);
14  // Make sure we don't have a ProductGetter set.
15  configureRefCoreStreamer();
16 }
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_, and art::errors::ProductNotFound.

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
Definition: TypeID.cc:33
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_.

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, art::MixOp< PROD, OPROD >::inProducts_, art::errors::LogicError, art::MixOp< PROD, OPROD >::mixFunc_, art::MixOp< PROD, OPROD >::outputInstanceLabel_, art::MixOp< PROD, OPROD >::outputProduct_, 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
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Float_t e
Definition: plot.C:34
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 evd::details::end(), art::InEvent, art::ProductMetaData::instance(), art::errors::LogicError, art::MixOp< PROD, OPROD >::moduleLabel_, art::MixOp< PROD, OPROD >::outputInstanceLabel_, art::MixOp< PROD, OPROD >::outputProduct_, art::MixOp< PROD, OPROD >::processName_, and art::ProductMetaData::productList().

179 {
180  art::ProductID result;
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
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
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 art::RootBranchInfo::branch(), art::MixOp< PROD, OPROD >::branchInfo_, art::MixOpBase::configureStreamers(), e, 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  } else { // Already have one: find and use.
223  auto pit = cbegin(inProducts_);
224  std::advance(pit, std::distance(b, fit));
225  inProducts_.emplace_back(*pit);
226  }
227  }
228 }
void configureStreamers(cet::exempt_ptr< BranchIDLists const > branchIDLists)
Definition: MixOpBase.cc:9
SpecProdList inProducts_
Definition: MixOp.h:69
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
RootBranchInfo branchInfo_
Definition: MixOp.h:72
TBranch const * branch() const
Float_t e
Definition: plot.C:34

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: