CMS 3D CMS Logo

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