CMS 3D CMS Logo

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