CMS 3D CMS Logo

EDAnalyzer.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_EDAnalyzer_h
2 #define FWCore_Framework_EDAnalyzer_h
3 
10 
11 #include <string>
12 
13 // EDAnalyzer is the base class for all analyzer "modules".
14 
15 namespace edm {
16 
17  class ModuleCallingContext;
18  class PreallocationConfiguration;
19  class ActivityRegistry;
20  class ProductRegistry;
21  class ThinnedAssociationsHelper;
22  class WaitingTask;
23 
24  namespace maker {
25  template <typename T>
27  }
28 
29  class EDAnalyzer : public EDConsumerBase {
30  public:
31  template <typename T>
32  friend class maker::ModuleHolderT;
33  template <typename T>
34  friend class WorkerT;
36 
37  EDAnalyzer();
38  ~EDAnalyzer() override;
39 
40  std::string workerType() const { return "WorkerT<EDAnalyzer>"; }
41 
42  static void fillDescriptions(ConfigurationDescriptions& descriptions);
43  static const std::string& baseType();
44  static void prevalidate(ConfigurationDescriptions&);
45 
46  // Warning: the returned moduleDescription will be invalid during construction
47  ModuleDescription const& moduleDescription() const { return moduleDescription_; }
48 
49  static bool wantsGlobalRuns() { return true; }
50  static bool wantsGlobalLuminosityBlocks() { return true; }
51  static bool wantsStreamRuns() { return false; }
52  static bool wantsStreamLuminosityBlocks() { return false; };
53 
54  void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func);
55 
56  SerialTaskQueue* globalRunsQueue() { return &runQueue_; }
57  SerialTaskQueue* globalLuminosityBlocksQueue() { return &luminosityBlockQueue_; }
58 
59  private:
60  bool doEvent(EventPrincipal const& ep,
61  EventSetupImpl const& c,
62  ActivityRegistry* act,
63  ModuleCallingContext const* mcc);
64  //Needed by Worker but not something supported
66  ModuleCallingContext const& iModuleCallingContext,
67  Principal const& iPrincipal) const {}
68 
70  void doBeginJob();
71  void doEndJob();
72  bool doBeginRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
73  bool doEndRun(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
74  bool doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp,
75  EventSetupImpl const& c,
76  ModuleCallingContext const* mcc);
77  bool doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp,
78  EventSetupImpl const& c,
79  ModuleCallingContext const* mcc);
80  void doRespondToOpenInputFile(FileBlock const& fb);
81  void doRespondToCloseInputFile(FileBlock const& fb);
83 
84  void registerProductsAndCallbacks(EDAnalyzer const*, ProductRegistry* reg);
85 
86  SharedResourcesAcquirer& sharedResourcesAcquirer() { return resourceAcquirer_; }
87 
88  virtual void analyze(Event const&, EventSetup const&) = 0;
89  virtual void beginJob() {}
90  virtual void endJob() {}
91  virtual void beginRun(Run const&, EventSetup const&) {}
92  virtual void endRun(Run const&, EventSetup const&) {}
93  virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&) {}
94  virtual void endLuminosityBlock(LuminosityBlock const&, EventSetup const&) {}
95  virtual void respondToOpenInputFile(FileBlock const&) {}
96  virtual void respondToCloseInputFile(FileBlock const&) {}
97 
98  bool hasAcquire() const { return false; }
99  bool hasAccumulator() const { return false; }
100 
101  void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
104 
107 
108  std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
109  };
110 } // namespace edm
111 
112 #endif
virtual void beginJob()
Definition: EDAnalyzer.h:89
virtual void endLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Definition: EDAnalyzer.h:94
std::string workerType() const
Definition: EDAnalyzer.h:40
virtual void respondToCloseInputFile(FileBlock const &)
Definition: EDAnalyzer.h:96
virtual void beginRun(Run const &, EventSetup const &)
Definition: EDAnalyzer.h:91
SharedResourcesAcquirer resourceAcquirer_
Definition: EDAnalyzer.h:103
virtual void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Definition: EDAnalyzer.h:93
SerialTaskQueue runQueue_
Definition: EDAnalyzer.h:105
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
ModuleDescription const & moduleDescription() const
Definition: EDAnalyzer.h:47
std::function< void(BranchDescription const &)> callWhenNewProductsRegistered_
Definition: EDAnalyzer.h:108
virtual void endJob()
Definition: EDAnalyzer.h:90
void doPreallocate(PreallocationConfiguration const &)
Definition: EDAnalyzer.h:69
ModuleDescription moduleDescription_
Definition: EDAnalyzer.h:102
EDAnalyzer ModuleType
Definition: EDAnalyzer.h:35
SerialTaskQueue * globalLuminosityBlocksQueue()
Definition: EDAnalyzer.h:57
SerialTaskQueue * globalRunsQueue()
Definition: EDAnalyzer.h:56
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static bool wantsStreamLuminosityBlocks()
Definition: EDAnalyzer.h:52
virtual void respondToOpenInputFile(FileBlock const &)
Definition: EDAnalyzer.h:95
void preActionBeforeRunEventAsync(WaitingTask *iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const
Definition: EDAnalyzer.h:65
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
Definition: EDAnalyzer.h:82
bool hasAcquire() const
Definition: EDAnalyzer.h:98
bool hasAccumulator() const
Definition: EDAnalyzer.h:99
static bool wantsGlobalLuminosityBlocks()
Definition: EDAnalyzer.h:50
virtual void endRun(Run const &, EventSetup const &)
Definition: EDAnalyzer.h:92
HLT enums.
SerialTaskQueue luminosityBlockQueue_
Definition: EDAnalyzer.h:106
static bool wantsGlobalRuns()
Definition: EDAnalyzer.h:49
static bool wantsStreamRuns()
Definition: EDAnalyzer.h:51
SharedResourcesAcquirer & sharedResourcesAcquirer()
Definition: EDAnalyzer.h:86
Definition: Run.h:45
void setModuleDescription(ModuleDescription const &md)
Definition: EDAnalyzer.h:101