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