CMS 3D CMS Logo

EDAnalyzerBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_limited_EDAnalyzerBase_h
2 #define FWCore_Framework_limited_EDAnalyzerBase_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : EDAnalyzerBase
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Thu, 18 Jul 2013 11:51:14 GMT
19 //
20 
21 // system include files
22 
23 // user include files
29 
30 // forward declarations
31 
32 namespace edm {
33  class ModuleCallingContext;
34  class PreallocationConfiguration;
35  class StreamID;
36  class ActivityRegistry;
37  class ProductRegistry;
38  class ThinnedAssociationsHelper;
39  class WaitingTask;
40 
41  namespace maker {
42  template <typename T>
43  class ModuleHolderT;
44  }
45 
46  namespace limited {
47 
48  class EDAnalyzerBase : public EDConsumerBase {
49  public:
50  template <typename T>
51  friend class edm::WorkerT;
52  template <typename T>
55 
57  ~EDAnalyzerBase() override;
58 
59  static void fillDescriptions(ConfigurationDescriptions& descriptions);
60  static void prevalidate(ConfigurationDescriptions& descriptions);
61  static const std::string& baseType();
62 
63  // Warning: the returned moduleDescription will be invalid during construction
64  ModuleDescription const& moduleDescription() const { return moduleDescription_; }
65 
66  virtual bool wantsGlobalRuns() const = 0;
67  virtual bool wantsGlobalLuminosityBlocks() const = 0;
68  virtual bool wantsStreamRuns() const = 0;
69  virtual bool wantsStreamLuminosityBlocks() const = 0;
70 
72  callWhenNewProductsRegistered_ = func;
73  }
74 
75  unsigned int concurrencyLimit() const { return queue_.concurrencyLimit(); }
76 
77  LimitedTaskQueue& queue() { return queue_; }
78 
79  private:
80  bool doEvent(EventPrincipal const& ep, EventSetupImpl const& c, ActivityRegistry*, ModuleCallingContext const*);
81  //For now this is a placeholder
82  /*virtual*/ void preActionBeforeRunEventAsync(WaitingTask* iTask,
83  ModuleCallingContext const& iModuleCallingContext,
84  Principal const& iPrincipal) const {}
85 
86  void doPreallocate(PreallocationConfiguration const&);
87  void doBeginJob();
88  void doEndJob();
89 
90  void doBeginStream(StreamID id);
91  void doEndStream(StreamID id);
92  void doStreamBeginRun(StreamID id, RunPrincipal const& ep, EventSetupImpl const& c, ModuleCallingContext const*);
93  void doStreamEndRun(StreamID id, RunPrincipal const& ep, EventSetupImpl const& c, ModuleCallingContext const*);
94  void doStreamBeginLuminosityBlock(StreamID id,
95  LuminosityBlockPrincipal const& ep,
96  EventSetupImpl const& c,
97  ModuleCallingContext const*);
98  void doStreamEndLuminosityBlock(StreamID id,
99  LuminosityBlockPrincipal const& ep,
100  EventSetupImpl const& c,
101  ModuleCallingContext const*);
102 
103  void doBeginRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const*);
104  void doEndRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const*);
105  void doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
106  EventSetupImpl const& c,
107  ModuleCallingContext const*);
108  void doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp,
109  EventSetupImpl const& c,
110  ModuleCallingContext const*);
111 
112  //For now, the following are just dummy implemenations with no ability for users to override
113  void doRespondToOpenInputFile(FileBlock const& fb);
114  void doRespondToCloseInputFile(FileBlock const& fb);
116 
118  std::string workerType() const { return "WorkerT<EDAnalyzer>"; }
119 
120  virtual void analyze(StreamID, Event const&, EventSetup const&) const = 0;
121  virtual void beginJob() {}
122  virtual void endJob() {}
123 
124  virtual void preallocStreams(unsigned int);
125  virtual void preallocLumis(unsigned int);
126  virtual void preallocLumisSummary(unsigned int);
127  virtual void preallocate(PreallocationConfiguration const&);
128  virtual void doBeginStream_(StreamID id);
129  virtual void doEndStream_(StreamID id);
130  virtual void doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c);
131  virtual void doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c);
132  virtual void doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c);
133  virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
134  virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
135  virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
136 
137  virtual void doBeginRun_(Run const& rp, EventSetup const& c);
138  virtual void doBeginRunSummary_(Run const& rp, EventSetup const& c);
139  virtual void doEndRunSummary_(Run const& rp, EventSetup const& c);
140  virtual void doEndRun_(Run const& rp, EventSetup const& c);
141  virtual void doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
142  virtual void doBeginLuminosityBlockSummary_(LuminosityBlock const& rp, EventSetup const& c);
143  virtual void doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c);
144  virtual void doEndLuminosityBlock_(LuminosityBlock const& lb, EventSetup const& c);
145 
146  bool hasAcquire() const { return false; }
147  bool hasAccumulator() const { return false; }
148 
149  void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
151 
152  std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
153 
155  };
156 
157  } // namespace limited
158 } // namespace edm
159 
160 #endif
void registerProductsAndCallbacks(ProductRegistry *iReg) override
Definition: ModuleHolder.h:70
ModuleDescription moduleDescription_
ModuleDescription const & moduleDescription() const
void preActionBeforeRunEventAsync(WaitingTask *iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const
void preallocate(PreallocationConfiguration const &iPrealloc) override
Definition: ModuleHolder.h:68
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
HLT enums.
void setModuleDescription(ModuleDescription const &md)
std::function< void(BranchDescription const &)> callWhenNewProductsRegistered_
std::string workerType() const
Definition: vlib.h:198
LimitedTaskQueue & queue()
Definition: Run.h:45
unsigned int concurrencyLimit() const