LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
art::ResultsProducer Class Referenceabstract

#include "ResultsProducer.h"

Inheritance diagram for art::ResultsProducer:
art::ProductRegistryHelper art::Consumer

Public Types

template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::PluginConfig, KeysToIgnore >
 

Public Member Functions

virtual ~ResultsProducer ()=default
 
void doBeginJob ()
 
void doEndJob ()
 
void doBeginSubRun (SubRunPrincipal const &)
 
void doEndSubRun (SubRunPrincipal const &)
 
void doBeginRun (RunPrincipal const &)
 
void doEndRun (RunPrincipal const &)
 
void doEvent (EventPrincipal const &)
 
void doReadResults (ResultsPrincipal const &)
 
void doWriteResults (ResultsPrincipal &)
 
void doClear ()
 
void registerProducts (MasterProductRegistry &mpr, ProductDescriptions &producedProducts, ModuleDescription const &md)
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

template<class P >
void produces (std::string const &instanceName={})
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void setModuleDescription (ModuleDescription const &md)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void beginSubRun (SubRun const &)
 
virtual void endSubRun (SubRun const &)
 
virtual void beginRun (Run const &)
 
virtual void endRun (Run const &)
 
virtual void event (Event const &)
 
virtual void readResults (Results const &)
 
virtual void writeResults (Results &)=0
 
virtual void clear ()=0
 
void productList (ProductList *p)
 
template<typename P , BranchType B = InEvent>
void produces (std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
 
template<typename P , BranchType B>
TypeLabel const & reconstitutes (std::string const &modLabel, std::string const &instanceName={})
 
template<typename P , art::BranchType B>
art::TypeLabel const & reconstitutes (std::string const &emulatedModule, std::string const &instanceName)
 
template<BranchType B>
std::set< TypeLabel > const & expectedProducts () const
 

Private Attributes

cet::exempt_ptr< ModuleDescription const > moduleDescription_ {nullptr}
 

Detailed Description

Definition at line 105 of file ResultsProducer.h.

Member Typedef Documentation

template<typename UserConfig , typename KeysToIgnore = void>
using art::ResultsProducer::Table = ProducerTable<UserConfig, detail::PluginConfig, KeysToIgnore>

Definition at line 114 of file ResultsProducer.h.

Constructor & Destructor Documentation

virtual art::ResultsProducer::~ResultsProducer ( )
virtualdefault

Member Function Documentation

void art::ResultsProducer::beginJob ( )
privatevirtual

Definition at line 17 of file ResultsProducer.cc.

18 {}
void art::ResultsProducer::beginRun ( Run const &  )
privatevirtual

Definition at line 33 of file ResultsProducer.cc.

34 {}
void art::ResultsProducer::beginSubRun ( SubRun const &  )
privatevirtual

Definition at line 25 of file ResultsProducer.cc.

26 {}
virtual void art::ResultsProducer::clear ( )
privatepure virtual
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

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

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

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

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void art::ResultsProducer::doBeginJob ( )
inline

Definition at line 165 of file ResultsProducer.h.

References breakpoints::beginJob(), fhicl::ParameterSetRegistry::get(), and art::Consumer::setModuleDescription().

Referenced by art::RootOutput::beginJob().

166 {
167  assert(moduleDescription_);
168  // Preparing the consumer for the job must be done after the
169  // constructer has been called.
170  auto const& mainID = moduleDescription_->mainParameterSetID();
171  auto const& scheduler_pset =
173  "services.scheduler");
175  prepareForJob(scheduler_pset);
176  beginJob();
177 }
static collection_type const & get() noexcept
void setModuleDescription(ModuleDescription const &md)
Definition: Consumer.cc:83
virtual void beginJob()
void prepareForJob(fhicl::ParameterSet const &pset)
Definition: Consumer.cc:89
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doBeginRun ( RunPrincipal const &  rp)
inline

Definition at line 201 of file ResultsProducer.h.

Referenced by art::RootOutput::beginRun().

202 {
203  Run const r{rp, *moduleDescription_, this};
204  beginRun(r);
205 }
virtual void beginRun(Run const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doBeginSubRun ( SubRunPrincipal const &  srp)
inline

Definition at line 187 of file ResultsProducer.h.

Referenced by art::RootOutput::beginSubRun().

188 {
189  SubRun const sr{srp, *moduleDescription_, this};
190  beginSubRun(sr);
191 }
virtual void beginSubRun(SubRun const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doClear ( )
inline

Definition at line 229 of file ResultsProducer.h.

References clear().

Referenced by art::RootOutput::finishEndFile().

230 {
231  clear();
232 }
virtual void clear()=0
void art::ResultsProducer::doEndJob ( )
inline

Definition at line 180 of file ResultsProducer.h.

Referenced by art::RootOutput::endJob().

181 {
182  endJob();
184 }
virtual void endJob()
void showMissingConsumes() const
Definition: Consumer.cc:125
void art::ResultsProducer::doEndRun ( RunPrincipal const &  rp)
inline

Definition at line 208 of file ResultsProducer.h.

Referenced by art::RootOutput::endRun().

209 {
210  Run const r{rp, *moduleDescription_, this};
211  endRun(r);
212 }
virtual void endRun(Run const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doEndSubRun ( SubRunPrincipal const &  srp)
inline

Definition at line 194 of file ResultsProducer.h.

Referenced by art::RootOutput::endSubRun().

195 {
196  SubRun const sr{srp, *moduleDescription_, this};
197  endSubRun(sr);
198 }
virtual void endSubRun(SubRun const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doEvent ( EventPrincipal const &  ep)
inline

Definition at line 215 of file ResultsProducer.h.

References e.

Referenced by art::RootOutput::event().

216 {
217  Event const e{ep, *moduleDescription_, this};
218  event(e);
219 }
virtual void event(Event const &)
Float_t e
Definition: plot.C:34
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doReadResults ( ResultsPrincipal const &  resp)
inline

Definition at line 222 of file ResultsProducer.h.

Referenced by art::RootOutput::readResults().

223 {
224  Results const res{resp, *moduleDescription_, this};
225  readResults(res);
226 }
virtual void readResults(Results const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doWriteResults ( ResultsPrincipal resp)

Definition at line 9 of file ResultsProducer.cc.

References moduleDescription_, and writeResults().

Referenced by art::RootOutput::startEndFile().

10 {
11  Results res{resp, *moduleDescription_, this};
12  writeResults(res);
13  res.commit(resp);
14 }
virtual void writeResults(Results &)=0
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::endJob ( )
privatevirtual

Definition at line 21 of file ResultsProducer.cc.

22 {}
void art::ResultsProducer::endRun ( Run const &  )
privatevirtual

Definition at line 37 of file ResultsProducer.cc.

38 {}
void art::ResultsProducer::endSubRun ( SubRun const &  )
privatevirtual

Definition at line 29 of file ResultsProducer.cc.

30 {}
void art::ResultsProducer::event ( Event const &  )
privatevirtual

Definition at line 41 of file ResultsProducer.cc.

42 {}
template<BranchType B>
std::set<TypeLabel> const& art::ProductRegistryHelper::expectedProducts ( ) const
inlineinherited

Definition at line 111 of file ProductRegistryHelper.h.

References B, and art::ProductRegistryHelper::typeLabelList_.

112  {
113  return typeLabelList_[B];
114  }
Int_t B
Definition: plot.C:25
std::array< std::set< TypeLabel >, NumBranchTypes > typeLabelList_
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

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

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

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

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename P , art::BranchType B>
void art::ProductRegistryHelper::produces ( std::string const &  instanceName = {},
Persistable const  persistable = Persistable::Yes 
)
inlineinherited

Definition at line 141 of file ProductRegistryHelper.h.

References B, art::ProductRegistryHelper::insertOrThrow(), art::No, art::detail::verifyFriendlyClassName(), and art::detail::verifyInstanceName().

Referenced by larg4::LArG4::LArG4(), art::MixHelper::produces(), recob::ChargedSpacePointCollectionCreator::produces(), and art::ProductRegistryHelper::productList().

143 {
144  verifyInstanceName(instanceName);
145  TypeID const productType{typeid(P)};
146  verifyFriendlyClassName(productType.friendlyClassName());
147  bool const isTransient = (persistable == Persistable::No);
149  B,
150  TypeLabel{productType, instanceName, SupportsView<P>::value, isTransient});
151 }
void verifyFriendlyClassName(std::string const &fcn)
Definition: verify_names.cc:16
Int_t B
Definition: plot.C:25
std::string value(boost::any const &)
TypeLabel const & insertOrThrow(BranchType const bt, TypeLabel const &tl)
void verifyInstanceName(std::string const &in)
Definition: verify_names.cc:5
template<class P >
void art::ResultsProducer::produces ( std::string const &  instanceName = {})
inlineprotected

Definition at line 159 of file ResultsProducer.h.

160 {
161  ProductRegistryHelper::produces<P, InResults>(instanceName);
162 }
void art::ProductRegistryHelper::productList ( ProductList p)
inlineinherited
void art::ResultsProducer::readResults ( Results const &  )
privatevirtual

Definition at line 45 of file ResultsProducer.cc.

46 {}
template<typename P , BranchType B>
TypeLabel const& art::ProductRegistryHelper::reconstitutes ( std::string const &  modLabel,
std::string const &  instanceName = {} 
)
inherited
template<typename P , art::BranchType B>
art::TypeLabel const& art::ProductRegistryHelper::reconstitutes ( std::string const &  emulatedModule,
std::string const &  instanceName 
)
inherited

Definition at line 155 of file ProductRegistryHelper.h.

References B, art::ProductRegistryHelper::insertOrThrow(), art::detail::verifyFriendlyClassName(), and art::detail::verifyInstanceName().

157 {
158  verifyModuleLabel(emulatedModule);
159  verifyInstanceName(instanceName);
160  TypeID const productType{typeid(P)};
161  verifyFriendlyClassName(productType.friendlyClassName());
162  return insertOrThrow(
163  B,
164  TypeLabel{
165  productType, instanceName, SupportsView<P>::value, emulatedModule});
166 }
void verifyFriendlyClassName(std::string const &fcn)
Definition: verify_names.cc:16
Int_t B
Definition: plot.C:25
std::string value(boost::any const &)
TypeLabel const & insertOrThrow(BranchType const bt, TypeLabel const &tl)
void verifyInstanceName(std::string const &in)
Definition: verify_names.cc:5
void art::ResultsProducer::registerProducts ( MasterProductRegistry mpr,
ProductDescriptions producedProducts,
ModuleDescription const &  md 
)
inline

Definition at line 128 of file ResultsProducer.h.

References art::ProductRegistryHelper::registerProducts().

Referenced by art::RootOutput::doRegisterProducts().

131  {
132  ProductRegistryHelper::registerProducts(mpr, producedProducts, md);
133  moduleDescription_ = &md;
134  }
void registerProducts(MasterProductRegistry &mpr, ProductDescriptions &productsToRegister, ModuleDescription const &md)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::Consumer::setModuleDescription ( ModuleDescription const &  md)
protectedinherited

Definition at line 83 of file Consumer.cc.

Referenced by doBeginJob(), art::EDProducer::setModuleDescription(), art::EDFilter::setModuleDescription(), and art::EDAnalyzer::setModuleDescription().

84 {
85  moduleDescription_ = &md;
86 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
virtual void art::ResultsProducer::writeResults ( Results )
privatepure virtual

Referenced by doWriteResults().

Member Data Documentation

cet::exempt_ptr<ModuleDescription const> art::ResultsProducer::moduleDescription_ {nullptr}
private

Definition at line 137 of file ResultsProducer.h.

Referenced by doWriteResults().


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