EDFilter.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_EDFilter_h
2 #define art_Framework_Core_EDFilter_h
3 
4 // ======================================================================
5 //
6 // EDFilter - The base class of all "modules" used to control the flow of
7 // processing in a processing path. Filters can also insert products
8 // into the event. These products should be informational products about
9 // the filter decision.
10 //
11 // ======================================================================
12 
21 #include "fhiclcpp/ParameterSet.h"
22 
23 #include <memory>
24 #include <string>
25 
26 // ----------------------------------------------------------------------
27 
28 namespace art {
29 
30  class EDFilter : public ProducerBase, public Consumer, public EngineCreator {
31  public:
32  static constexpr bool Pass{true};
33  static constexpr bool Fail{false};
34 
35  template <typename T>
36  friend class WorkerT;
39 
40  virtual ~EDFilter() = default;
41 
42  template <typename PROD, BranchType B = InEvent>
43  ProductID getProductID(std::string const& instanceName = {}) const;
44 
45  template <typename UserConfig>
47 
48  protected:
49  // The returned pointer will be null unless the this is currently
50  // executing its event loop function ('filter').
52 
53  private:
55 
57  void doBeginJob();
58  void doEndJob();
59  bool doBeginRun(RunPrincipal& rp, CPC_exempt_ptr cpc);
60  bool doEndRun(RunPrincipal& rp, CPC_exempt_ptr cpc);
67 
69  workerType() const
70  {
71  return "WorkerT<EDFilter>";
72  }
73 
74  virtual bool filter(Event&) = 0;
75  virtual void
77  {}
78  virtual void
80  {}
81  virtual bool
83  {
84  return true;
85  }
86  virtual bool
88  {
89  return true;
90  }
91  virtual bool
93  {
94  return true;
95  }
96  virtual bool
98  {
99  return true;
100  }
101  virtual void
103  {}
104  virtual void
106  {}
107  virtual void
109  {}
110  virtual void
112  {}
113 
114  void
116  {
118  // Since the module description in the Consumer base class is
119  // owned by pointer, we must give it the owned object of this
120  // class--i.e. moduleDescription_, not md.
122  }
123 
126  bool checkPutProducts_{true};
127  }; // EDFilter
128 
129  template <typename PROD, BranchType B>
130  inline ProductID
131  EDFilter::getProductID(std::string const& instanceName) const
132  {
133  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
134  instanceName);
135  }
136 
137 } // art
138 
139 // ======================================================================
140 
141 #endif /* art_Framework_Core_EDFilter_h */
142 
143 // Local Variables:
144 // mode: c++
145 // End:
virtual void endJob()
Definition: EDFilter.h:79
bool doEvent(EventPrincipal &ep, CPC_exempt_ptr cpc, CountingStatistics &)
void doRespondToCloseInputFile(FileBlock const &fb)
virtual void respondToOpenOutputFiles(FileBlock const &)
Definition: EDFilter.h:108
ModuleDescription moduleDescription_
Definition: EDFilter.h:124
ProductID getProductID(std::string const &instanceName={}) const
Definition: EDFilter.h:131
void doRespondToOpenInputFile(FileBlock const &fb)
static constexpr bool Pass
Definition: EDFilter.h:32
std::string workerType() const
Definition: EDFilter.h:69
void setModuleDescription(ModuleDescription const &md)
Definition: EDFilter.h:115
void doRespondToOpenOutputFiles(FileBlock const &fb)
CurrentProcessingContext const * currentContext() const
virtual bool filter(Event &)=0
virtual void respondToCloseInputFile(FileBlock const &)
Definition: EDFilter.h:105
virtual bool endSubRun(SubRun &)
Definition: EDFilter.h:97
Definition: Run.h:31
bool checkPutProducts_
Definition: EDFilter.h:126
bool doEndSubRun(SubRunPrincipal &srp, CPC_exempt_ptr cpc)
CPC_exempt_ptr current_context_
Definition: EDFilter.h:125
void setModuleDescription(ModuleDescription const &md)
static constexpr bool Fail
Definition: EDFilter.h:33
bool doEndRun(RunPrincipal &rp, CPC_exempt_ptr cpc)
virtual void respondToCloseOutputFiles(FileBlock const &)
Definition: EDFilter.h:111
virtual ~EDFilter()=default
void doBeginJob()
virtual bool beginSubRun(SubRun &)
Definition: EDFilter.h:92
virtual bool beginRun(Run &)
Definition: EDFilter.h:82
virtual void respondToOpenInputFile(FileBlock const &)
Definition: EDFilter.h:102
void doRespondToCloseOutputFiles(FileBlock const &fb)
virtual bool endRun(Run &)
Definition: EDFilter.h:87
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
virtual void beginJob()
Definition: EDFilter.h:76
bool doBeginSubRun(SubRunPrincipal &srp, CPC_exempt_ptr cpc)
bool doBeginRun(RunPrincipal &rp, CPC_exempt_ptr cpc)
enum BeamMode string