LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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:
54  using CPC_exempt_ptr = cet::exempt_ptr<CurrentProcessingContext const>;
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 
68  std::string
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  {
117  moduleDescription_ = md;
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 &)
Definition: EDFilter.cc:18
void doRespondToCloseInputFile(FileBlock const &fb)
Definition: EDFilter.cc:102
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)
Definition: EDFilter.cc:96
CurrentProcessingContext const * currentContext() const
Definition: EDFilter.cc:120
static constexpr bool Pass
Definition: EDFilter.h:32
void doEndJob()
Definition: EDFilter.cc:49
std::string workerType() const
Definition: EDFilter.h:69
void setModuleDescription(ModuleDescription const &md)
Definition: EDFilter.h:115
void doRespondToOpenOutputFiles(FileBlock const &fb)
Definition: EDFilter.cc:108
virtual bool filter(Event &)=0
virtual void respondToCloseInputFile(FileBlock const &)
Definition: EDFilter.h:105
virtual bool endSubRun(SubRun &)
Definition: EDFilter.h:97
cet::exempt_ptr< CurrentProcessingContext const > CPC_exempt_ptr
Definition: EDFilter.h:54
Definition: Run.h:30
bool checkPutProducts_
Definition: EDFilter.h:126
bool doEndSubRun(SubRunPrincipal &srp, CPC_exempt_ptr cpc)
Definition: EDFilter.cc:86
CPC_exempt_ptr current_context_
Definition: EDFilter.h:125
TFile fb("Li6.root")
void setModuleDescription(ModuleDescription const &md)
Definition: Consumer.cc:83
static constexpr bool Fail
Definition: EDFilter.h:33
bool doEndRun(RunPrincipal &rp, CPC_exempt_ptr cpc)
Definition: EDFilter.cc:66
virtual void respondToCloseOutputFiles(FileBlock const &)
Definition: EDFilter.h:111
virtual ~EDFilter()=default
void doBeginJob()
Definition: EDFilter.cc:32
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)
Definition: EDFilter.cc:114
virtual bool endRun(Run &)
Definition: EDFilter.h:87
HLT enums.
virtual void beginJob()
Definition: EDFilter.h:76
bool doBeginSubRun(SubRunPrincipal &srp, CPC_exempt_ptr cpc)
Definition: EDFilter.cc:76
bool doBeginRun(RunPrincipal &rp, CPC_exempt_ptr cpc)
Definition: EDFilter.cc:56