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