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  virtual ~EDAnalyzer();
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  void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func);
46 
47  private:
48  bool doEvent(EventPrincipal const& ep, EventSetup const& c,
49  ActivityRegistry* act,
50  ModuleCallingContext const* mcc);
51  //Needed by Worker but not something supported
52  void preActionBeforeRunEventAsync(WaitingTask* iTask, ModuleCallingContext const& iModuleCallingContext, Principal const& iPrincipal) const {}
53 
55  void doBeginJob();
56  void doEndJob();
57  bool doBeginRun(RunPrincipal const& rp, EventSetup const& c,
58  ModuleCallingContext const* mcc);
59  bool doEndRun(RunPrincipal const& rp, EventSetup const& c,
60  ModuleCallingContext const* mcc);
61  bool doBeginLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
62  ModuleCallingContext const* mcc);
63  bool doEndLuminosityBlock(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
64  ModuleCallingContext const* mcc);
65  void doRespondToOpenInputFile(FileBlock const& fb);
66  void doRespondToCloseInputFile(FileBlock const& fb);
67  void doPreForkReleaseResources();
68  void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren);
71 
72  void registerProductsAndCallbacks(EDAnalyzer const*, ProductRegistry* reg);
73 
75  return resourceAcquirer_;
76  }
77 
78  virtual void analyze(Event const&, EventSetup const&) = 0;
79  virtual void beginJob(){}
80  virtual void endJob(){}
81  virtual void beginRun(Run const&, EventSetup const&){}
82  virtual void endRun(Run const&, EventSetup const&){}
83  virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&){}
84  virtual void endLuminosityBlock(LuminosityBlock const&, EventSetup const&){}
85  virtual void respondToOpenInputFile(FileBlock const&) {}
86  virtual void respondToCloseInputFile(FileBlock const&) {}
87  virtual void preForkReleaseResources() {}
88  virtual void postForkReacquireResources(unsigned int /*iChildIndex*/, unsigned int /*iNumberOfChildren*/) {}
89 
91  moduleDescription_ = md;
92  }
95 
96  std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
97  };
98 }
99 
100 #endif
virtual void beginJob()
Definition: EDAnalyzer.h:79
virtual void endLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Definition: EDAnalyzer.h:84
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:86
virtual void beginRun(Run const &, EventSetup const &)
Definition: EDAnalyzer.h:81
SharedResourcesAcquirer resourceAcquirer_
Definition: EDAnalyzer.h:94
virtual void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Definition: EDAnalyzer.h:83
virtual void preForkReleaseResources()
Definition: EDAnalyzer.h:87
ModuleDescription const & moduleDescription() const
Definition: EDAnalyzer.h:43
std::function< void(BranchDescription const &)> callWhenNewProductsRegistered_
Definition: EDAnalyzer.h:96
virtual void endJob()
Definition: EDAnalyzer.h:80
void doPreallocate(PreallocationConfiguration const &)
Definition: EDAnalyzer.h:54
ModuleDescription moduleDescription_
Definition: EDAnalyzer.h:93
EDAnalyzer ModuleType
Definition: EDAnalyzer.h:31
virtual void respondToOpenInputFile(FileBlock const &)
Definition: EDAnalyzer.h:85
void preActionBeforeRunEventAsync(WaitingTask *iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const
Definition: EDAnalyzer.h:52
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
Definition: EDAnalyzer.h:69
virtual void endRun(Run const &, EventSetup const &)
Definition: EDAnalyzer.h:82
HLT enums.
SharedResourcesAcquirer & sharedResourcesAcquirer()
Definition: EDAnalyzer.h:74
Definition: Run.h:42
virtual void postForkReacquireResources(unsigned int, unsigned int)
Definition: EDAnalyzer.h:88
void setModuleDescription(ModuleDescription const &md)
Definition: EDAnalyzer.h:90