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