LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
EDProducer.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_EDProducer_h
2 #define art_Framework_Core_EDProducer_h
3 
4 // ======================================================================
5 //
6 // EDProducer - The base class of "modules" whose main purpose is to
7 // insert new EDProducts into an Event.
8 //
9 // ======================================================================
10 
19 #include "fhiclcpp/ParameterSet.h"
20 
21 #include <memory>
22 #include <string>
23 
24 // ----------------------------------------------------------------------
25 
26 namespace art {
27 
28  class EDProducer : public ProducerBase,
29  public Consumer,
30  public EngineCreator {
31  public:
32  template <typename T>
33  friend class WorkerT;
36 
37  virtual ~EDProducer() = default;
38 
39  template <typename PROD, BranchType B = InEvent>
40  ProductID getProductID(std::string const& instanceName = {}) const;
41 
42  template <typename UserConfig, typename KeysToIgnore = void>
44 
45  protected:
46  // The returned pointer will be null unless the this is currently
47  // executing its event loop function ('produce').
49 
50  private:
51  using CPC_exempt_ptr = cet::exempt_ptr<CurrentProcessingContext const>;
52 
54  void doBeginJob();
55  void doEndJob();
56  bool doBeginRun(RunPrincipal& rp, CPC_exempt_ptr cpc);
57  bool doEndRun(RunPrincipal& rp, CPC_exempt_ptr cpc);
64 
65  std::string
66  workerType() const
67  {
68  return "WorkerT<EDProducer>";
69  }
70 
71  virtual void produce(Event&) = 0;
72  virtual void
74  {}
75  virtual void
77  {}
78 
79  virtual void
81  {}
82  virtual void
84  {}
85  virtual void
87  {}
88  virtual void
90  {}
91 
92  virtual void
94  {}
95  virtual void
97  {}
98  virtual void
100  {}
101  virtual void
103  {}
104 
105  void
107  {
108  moduleDescription_ = md;
109  // Since the module description in the Consumer base class is
110  // owned by pointer, we must give it the owned object of this
111  // class--i.e. moduleDescription_, not md.
113  }
114 
117  bool checkPutProducts_{true};
118  std::set<TypeLabel> missingConsumes_{};
119  }; // EDProducer
120 
121  template <typename PROD, BranchType B>
122  inline ProductID
123  EDProducer::getProductID(std::string const& instanceName) const
124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
128 } // art
129 
130  // ======================================================================
131 
132 #endif /* art_Framework_Core_EDProducer_h */
133 
134 // Local Variables:
135 // mode: c++
136 // End:
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
void doBeginJob()
Definition: EDProducer.cc:32
virtual void beginJob()
Definition: EDProducer.h:73
virtual void endRun(Run &)
Definition: EDProducer.h:86
void doRespondToCloseInputFile(FileBlock const &fb)
Definition: EDProducer.cc:102
virtual void endSubRun(SubRun &)
Definition: EDProducer.h:89
virtual void respondToCloseInputFile(FileBlock const &)
Definition: EDProducer.h:96
std::set< TypeLabel > missingConsumes_
Definition: EDProducer.h:118
std::string workerType() const
Definition: EDProducer.h:66
ProductID getProductID(std::string const &instanceName={}) const
Definition: EDProducer.h:123
cet::exempt_ptr< CurrentProcessingContext const > CPC_exempt_ptr
Definition: EDProducer.h:51
bool doEvent(EventPrincipal &ep, CPC_exempt_ptr cpcp, CountingStatistics &)
Definition: EDProducer.cc:18
bool doEndRun(RunPrincipal &rp, CPC_exempt_ptr cpc)
Definition: EDProducer.cc:66
Definition: Run.h:30
bool checkPutProducts_
Definition: EDProducer.h:117
virtual void beginSubRun(SubRun &)
Definition: EDProducer.h:83
virtual void beginRun(Run &)
Definition: EDProducer.h:80
bool doEndSubRun(SubRunPrincipal &srp, CPC_exempt_ptr cpc)
Definition: EDProducer.cc:86
bool doBeginRun(RunPrincipal &rp, CPC_exempt_ptr cpc)
Definition: EDProducer.cc:56
virtual void endJob()
Definition: EDProducer.h:76
virtual void respondToCloseOutputFiles(FileBlock const &)
Definition: EDProducer.h:102
TFile fb("Li6.root")
void setModuleDescription(ModuleDescription const &md)
Definition: Consumer.cc:83
virtual void respondToOpenOutputFiles(FileBlock const &)
Definition: EDProducer.h:99
void setModuleDescription(ModuleDescription const &md)
Definition: EDProducer.h:106
bool doBeginSubRun(SubRunPrincipal &srp, CPC_exempt_ptr cpc)
Definition: EDProducer.cc:76
CurrentProcessingContext const * currentContext() const
Definition: EDProducer.cc:120
virtual ~EDProducer()=default
void doRespondToOpenOutputFiles(FileBlock const &fb)
Definition: EDProducer.cc:108
void doRespondToCloseOutputFiles(FileBlock const &fb)
Definition: EDProducer.cc:114
HLT enums.
virtual void respondToOpenInputFile(FileBlock const &)
Definition: EDProducer.h:93
void doRespondToOpenInputFile(FileBlock const &fb)
Definition: EDProducer.cc:96
virtual void produce(Event &)=0