LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::ResultsProducer Class Referenceabstract

#include "ResultsProducer.h"

Inheritance diagram for art::ResultsProducer:
art::ModuleBase art::detail::SharedModule art::ProductRegistryHelper

Public Types

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

Public Member Functions

virtual ~ResultsProducer () noexcept=default
 
 ResultsProducer () noexcept(false)
 
void doBeginJob ()
 
void doEndJob ()
 
void doBeginRun (RunPrincipal const &)
 
void doEndRun (RunPrincipal const &)
 
void doBeginSubRun (SubRunPrincipal const &)
 
void doEndSubRun (SubRunPrincipal const &)
 
void doEvent (EventPrincipal const &)
 
void doReadResults (ResultsPrincipal const &)
 
void doWriteResults (ResultsPrincipal &)
 
void doClear ()
 
void registerProducts (ProductDescriptions &producedProducts, ModuleDescription const &md)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< WorkermakeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

template<class P >
void produces (std::string const &instanceName={})
 
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

std::unique_ptr< WorkerdoMakeWorker (WorkerParams const &wp) final
 
virtual void readResults (Results const &)
 
virtual void writeResults (Results &)=0
 
virtual void clear ()=0
 
virtual void beginJob ()
 
virtual void endJob ()
 
virtual void beginRun (Run const &)
 
virtual void endRun (Run const &)
 
virtual void beginSubRun (SubRun const &)
 
virtual void endSubRun (SubRun const &)
 
virtual void event (Event const &)
 
hep::concurrency::SerialTaskQueueChain * serialTaskQueueChain () const
 
std::set< std::string > const & sharedResources () const
 
void createQueues (SharedResources const &resources)
 
template<BranchType BT = InEvent, typename... T>
void serialize (T const &...)
 
template<BranchType , typename... T>
void serialize (T const &...resources)
 
template<BranchType BT = InEvent, typename... T>
void serializeExternal (T const &...)
 
template<BranchType , typename... T>
void serializeExternal (T const &...resources)
 
template<BranchType BT = InEvent>
void async ()
 
void productList (std::unique_ptr< ProductList > p)
 
void fillDescriptions (ModuleDescription const &md)
 
template<typename P , BranchType B>
TypeLabel const & reconstitutes (std::string const &modLabel, std::string const &instanceName={})
 
template<BranchType B>
TypeLabelLookup_t const & expectedProducts () const
 
template<typename P , BranchType B = InEvent>
void produces (std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
 
ProducesCollectorproducesCollector () noexcept
 

Detailed Description

Definition at line 93 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 102 of file ResultsProducer.h.

Constructor & Destructor Documentation

virtual art::ResultsProducer::~ResultsProducer ( )
virtualdefaultnoexcept
art::ResultsProducer::ResultsProducer ( )
noexcept

Member Function Documentation

template<BranchType BT = InEvent>
void art::detail::SharedModule::async ( )
inlineprotectedinherited

Definition at line 38 of file SharedModule.h.

References art::detail::SharedModule::asyncDeclared_, art::detail::SharedModule::implicit_serialize(), art::InEvent, and art::detail::SharedModule::serialize_for().

39  {
40  static_assert(
41  BT == InEvent,
42  "async is currently supported only for the 'InEvent' level.");
43  asyncDeclared_ = true;
44  }
void art::ResultsProducer::beginJob ( )
privatevirtual

Definition at line 124 of file ResultsProducer.cc.

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

Definition at line 132 of file ResultsProducer.cc.

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

Definition at line 140 of file ResultsProducer.cc.

141  {}
virtual void art::ResultsProducer::clear ( )
privatepure virtual
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::SharedModule::createQueues ( SharedResources const &  resources)
inherited

Definition at line 34 of file SharedModule.cc.

References art::detail::SharedModule::asyncDeclared_, util::cbegin(), util::cend(), art::detail::SharedModule::chain_, art::detail::SharedResources::createQueues(), e, util::empty(), art::errors::LogicError, and art::detail::SharedModule::resourceNames_.

Referenced by art::OutputModule::doBeginJob(), art::SharedFilter::setupQueues(), art::SharedProducer::setupQueues(), art::SharedAnalyzer::setupQueues(), art::EDFilter::setupQueues(), art::EDProducer::setupQueues(), and art::EDAnalyzer::setupQueues().

35  {
37  "An error occurred while processing scheduling options for a "
38  "module.\n"};
39  if (asyncDeclared_) {
40  if (empty(resourceNames_)) {
41  return;
42  }
43  throw e
44  << "async<art::InEvent>() cannot be called in combination with any "
45  "serialize<art::InEvent>(...) calls.\n";
46  }
47 
48  if (empty(resourceNames_)) {
49  throw e << "Either 'async<art::InEvent>()' or "
50  "'serialize<art::InEvent>(...)'\n"
51  "must be called in a shared module's constructor.\n";
52  }
53  std::vector<std::string> const names(cbegin(resourceNames_),
55  auto queues = resources.createQueues(names);
56  chain_ = std::make_unique<SerialTaskQueueChain>(queues);
57  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
std::set< std::string > resourceNames_
Definition: SharedModule.h:76
std::unique_ptr< hep::concurrency::SerialTaskQueueChain > chain_
Definition: SharedModule.h:78
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
Definition: StdUtils.h:85
Float_t e
Definition: plot.C:35
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
void art::ResultsProducer::doBeginJob ( )

Definition at line 48 of file ResultsProducer.cc.

References breakpoints::beginJob().

49  {
50  // If results producers ever become eligible for multi-threaded
51  // execution, the serial task queues will need to be setup here.
52  beginJob();
53  }
virtual void beginJob()
void art::ResultsProducer::doBeginRun ( RunPrincipal const &  rp)

Definition at line 62 of file ResultsProducer.cc.

References art::RunPrincipal::makeRun().

63  {
64  ModuleContext const mc{moduleDescription()};
65  beginRun(rp.makeRun(mc));
66  }
virtual void beginRun(Run const &)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ResultsProducer::doBeginSubRun ( SubRunPrincipal const &  srp)

Definition at line 76 of file ResultsProducer.cc.

References art::SubRunPrincipal::makeSubRun().

77  {
78  ModuleContext const mc{moduleDescription()};
79  beginSubRun(srp.makeSubRun(mc));
80  }
virtual void beginSubRun(SubRun const &)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ResultsProducer::doClear ( )

Definition at line 113 of file ResultsProducer.cc.

References clear().

114  {
115  clear();
116  }
virtual void clear()=0
void art::ResultsProducer::doEndJob ( )

Definition at line 56 of file ResultsProducer.cc.

57  {
58  endJob();
59  }
void art::ResultsProducer::doEndRun ( RunPrincipal const &  rp)

Definition at line 69 of file ResultsProducer.cc.

References art::RunPrincipal::makeRun().

70  {
71  ModuleContext const mc{moduleDescription()};
72  endRun(rp.makeRun(mc));
73  }
virtual void endRun(Run const &)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ResultsProducer::doEndSubRun ( SubRunPrincipal const &  srp)

Definition at line 83 of file ResultsProducer.cc.

References art::SubRunPrincipal::makeSubRun().

84  {
85  ModuleContext const mc{moduleDescription()};
86  endSubRun(srp.makeSubRun(mc));
87  }
virtual void endSubRun(SubRun const &)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ResultsProducer::doEvent ( EventPrincipal const &  ep)

Definition at line 90 of file ResultsProducer.cc.

References art::EventPrincipal::makeEvent().

91  {
92  ModuleContext const mc{moduleDescription()};
93  event(ep.makeEvent(mc));
94  }
virtual void event(Event const &)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::unique_ptr< Worker > art::ResultsProducer::doMakeWorker ( WorkerParams const &  wp)
finalprivatevirtual

Implements art::ModuleBase.

Definition at line 27 of file ResultsProducer.cc.

References art::errors::LogicError.

28  {
30  << "Cannot call ResultsProducer::doMakeWorker\n";
31  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void art::ResultsProducer::doReadResults ( ResultsPrincipal const &  resp)

Definition at line 97 of file ResultsProducer.cc.

References art::ResultsPrincipal::makeResults().

98  {
99  ModuleContext const mc{moduleDescription()};
100  readResults(resp.makeResults(mc));
101  }
virtual void readResults(Results const &)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ResultsProducer::doWriteResults ( ResultsPrincipal resp)

Definition at line 104 of file ResultsProducer.cc.

References art::ResultsPrincipal::makeResults().

105  {
106  ModuleContext const mc{moduleDescription()};
107  auto res = resp.makeResults(mc);
108  writeResults(res);
109  res.commitProducts();
110  }
virtual void writeResults(Results &)=0
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ResultsProducer::endJob ( )
privatevirtual

Definition at line 128 of file ResultsProducer.cc.

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

Definition at line 136 of file ResultsProducer.cc.

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

Definition at line 144 of file ResultsProducer.cc.

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

Definition at line 148 of file ResultsProducer.cc.

149  {}
template<BranchType B>
TypeLabelLookup_t const & art::ProductRegistryHelper::expectedProducts ( ) const
inlineinherited

Definition at line 93 of file ProductRegistryHelper.h.

Referenced by art::ProductRegistryHelper::registerProducts().

94  {
95  return collector_.expectedProducts(B);
96  }
TypeLabelLookup_t const & expectedProducts(BranchType) const
void art::ProductRegistryHelper::fillDescriptions ( ModuleDescription const &  md)
inherited
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
template<typename P , art::BranchType B>
void art::ProductRegistryHelper::produces ( std::string const &  instanceName = {},
Persistable const  persistable = Persistable::Yes 
)
inlineinherited

Definition at line 100 of file ProductRegistryHelper.h.

References art::errors::ProductRegistrationFailure, and art::reconstitutes.

Referenced by larg4::LArG4::LArG4(), trkf::PMAlgTrackMaker::PMAlgTrackMaker(), trkf::PMAlgTrajFitter::PMAlgTrajFitter(), and trkf::Track3DKalmanHit::Track3DKalmanHit().

102  {
105  "An error occurred while registering a product.\n"}
106  << "The following product was registered with 'produces' when\n"
107  "'reconstitutes' should have been called instead.\n"
108  << " Branch type: " << B << '\n'
109  << " Class name: " << cet::demangle_symbol(typeid(P).name()) << '\n'
110  << " Instance name: '" << instanceName << "'\n";
111  }
112  collector_.produces<P, B>(instanceName, persistable);
113  }
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<class P >
void art::ResultsProducer::produces ( std::string const &  instanceName = {})
inlineprotected

Definition at line 150 of file ResultsProducer.h.

151 {
152  ProductRegistryHelper::produces<P, InResults>(instanceName);
153 }
void art::ProductRegistryHelper::productList ( std::unique_ptr< ProductList p)
inlineinherited

Definition at line 52 of file ProductRegistryHelper.h.

References art::produces, art::reconstitutes, and art::Yes.

53  {
54  productList_ = std::move(p);
55  }
std::unique_ptr< ProductList const > productList_
void art::ResultsProducer::readResults ( Results const &  )
privatevirtual

Definition at line 120 of file ResultsProducer.cc.

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

Definition at line 117 of file ProductRegistryHelper.h.

References art::produces, and art::errors::ProductRegistrationFailure.

Referenced by lris::LArRawInputDriver::LArRawInputDriver(), lris::LArRawInputDriverJP250L::LArRawInputDriverJP250L(), lris::LArRawInputDriverLongBo::LArRawInputDriverLongBo(), lris::LArRawInputDriverShortBo::LArRawInputDriverShortBo(), and fluxr::PPFXFluxReader::PPFXFluxReader().

119  {
122  "An error occurred while registering a product.\n"}
123  << "The following product was registered with 'reconstitutes' when\n"
124  "'produces' should have been called instead.\n"
125  << " Branch type: " << B << '\n'
126  << " Class name: " << cet::demangle_symbol(typeid(P).name()) << '\n'
127  << " Emulated module name: '" << emulatedModule << "'\n"
128  << " Instance name: '" << instanceName << "'\n";
129  }
130  return collector_.reconstitutes<P, B>(emulatedModule, instanceName);
131  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
void art::ResultsProducer::registerProducts ( ProductDescriptions producedProducts,
ModuleDescription const &  md 
)

Definition at line 40 of file ResultsProducer.cc.

42  {
43  ProductRegistryHelper::registerProducts(productsToProduce, md);
45  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
void setModuleDescription(ModuleDescription const &)
Definition: ModuleBase.cc:31
template<BranchType BT = InEvent, typename... T>
void art::detail::SharedModule::serialize ( T const &  ...)
protectedinherited
template<BranchType , typename... T>
void art::detail::SharedModule::serialize ( T const &...  resources)
inherited

Definition at line 83 of file SharedModule.h.

References art::detail::SharedModule::serialize_for_resource().

84  {
85  serialize_for_resource(resources...);
86  }
void serialize_for_resource(T const &...t)
Definition: SharedModule.h:52
template<BranchType BT = InEvent, typename... T>
void art::detail::SharedModule::serializeExternal ( T const &  ...)
protectedinherited
template<BranchType , typename... T>
void art::detail::SharedModule::serializeExternal ( T const &...  resources)
inherited

Definition at line 90 of file SharedModule.h.

References art::detail::SharedModule::serialize_for_external_resource().

91  {
92  serialize_for_external_resource(resources...);
93  }
void serialize_for_external_resource(T const &...t)
Definition: SharedModule.h:65
SerialTaskQueueChain * art::detail::SharedModule::serialTaskQueueChain ( ) const
inherited

Definition at line 22 of file SharedModule.cc.

References art::detail::SharedModule::chain_.

23  {
24  return chain_.get();
25  }
std::unique_ptr< hep::concurrency::SerialTaskQueueChain > chain_
Definition: SharedModule.h:78
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
std::set< std::string > const & art::detail::SharedModule::sharedResources ( ) const
inherited

Definition at line 28 of file SharedModule.cc.

References art::detail::SharedModule::resourceNames_.

29  {
30  return resourceNames_;
31  }
std::set< std::string > resourceNames_
Definition: SharedModule.h:76
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)
virtual void art::ResultsProducer::writeResults ( Results )
privatepure virtual

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