CMS 3D CMS Logo

WorkerT.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WorkerT_h
2 #define FWCore_Framework_WorkerT_h
3 
4 /*----------------------------------------------------------------------
5 
6 WorkerT: Code common to all workers.
7 
8 ----------------------------------------------------------------------*/
9 
15 
16 #include <map>
17 #include <memory>
18 #include <string>
19 #include <vector>
20 
21 namespace edm {
22 
23  class ModuleCallingContext;
24  class ModuleDescription;
25  class ProductResolverIndexAndSkipBit;
26  class ProductRegistry;
27  class ThinnedAssociationsHelper;
28  class WaitingTaskWithArenaHolder;
29 
30  template<typename T>
31  class WorkerT : public Worker {
32  public:
33  typedef T ModuleType;
35  WorkerT(std::shared_ptr<T>,
36  ModuleDescription const&,
38 
39  ~WorkerT() override;
40 
41  void setModule( std::shared_ptr<T> iModule) {
42  module_ = iModule;
43  resetModuleDescription(&(module_->moduleDescription()));
44  }
45 
46  Types moduleType() const override;
47 
48  bool wantsGlobalRuns() const final;
49  bool wantsGlobalLuminosityBlocks() const final;
50  bool wantsStreamRuns() const final;
51  bool wantsStreamLuminosityBlocks() const final;
52 
55 
56 
57  void updateLookup(BranchType iBranchType,
58  ProductResolverIndexHelper const&) override;
59  void resolvePutIndicies(BranchType iBranchType,
60  std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const& iIndicies) override;
61 
62  template<typename D>
64  template<typename D>
66  template<typename D>
67  void callWorkerStreamBegin(D, StreamID id, RunPrincipal const& rp,
68  EventSetup const& c,
69  ModuleCallingContext const* mcc);
70  template<typename D>
71  void callWorkerStreamEnd(D, StreamID id, RunPrincipal const& rp,
72  EventSetup const& c,
73  ModuleCallingContext const* mcc);
74  template<typename D>
76  EventSetup const& c,
77  ModuleCallingContext const* mcc);
78  template<typename D>
80  EventSetup const& c,
81  ModuleCallingContext const* mcc);
82 
83  protected:
84  T& module() {return *module_;}
85  T const& module() const {return *module_;}
86 
87  private:
88  bool implDo(EventPrincipal const& ep, EventSetup const& c,
89  ModuleCallingContext const* mcc) override;
90 
91  void itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>&) const final;
92  bool implNeedToRunSelection() const final;
93 
94  void implDoAcquire(EventPrincipal const& ep, EventSetup const& c,
95  ModuleCallingContext const* mcc,
96  WaitingTaskWithArenaHolder& holder) final;
97 
99  EventPrincipal const& ep,
100  ModuleCallingContext const* mcc) override;
101  bool implDoBegin(RunPrincipal const& rp, EventSetup const& c,
102  ModuleCallingContext const* mcc) override;
103  bool implDoStreamBegin(StreamID id, RunPrincipal const& rp, EventSetup const& c,
104  ModuleCallingContext const* mcc) override;
105  bool implDoStreamEnd(StreamID id, RunPrincipal const& rp, EventSetup const& c,
106  ModuleCallingContext const* mcc) override;
107  bool implDoEnd(RunPrincipal const& rp, EventSetup const& c,
108  ModuleCallingContext const* mcc) override;
109  bool implDoBegin(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
110  ModuleCallingContext const* mcc) override;
111  bool implDoStreamBegin(StreamID id, LuminosityBlockPrincipal const& lbp, EventSetup const& c,
112  ModuleCallingContext const* mcc) override;
113  bool implDoStreamEnd(StreamID id, LuminosityBlockPrincipal const& lbp, EventSetup const& c,
114  ModuleCallingContext const* mcc) override;
115  bool implDoEnd(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
116  ModuleCallingContext const* mcc) override;
117  void implBeginJob() override;
118  void implEndJob() override;
119  void implBeginStream(StreamID) override;
120  void implEndStream(StreamID) override;
121  void implRespondToOpenInputFile(FileBlock const& fb) override;
122  void implRespondToCloseInputFile(FileBlock const& fb) override;
124  std::string workerType() const override;
126 
127 
128  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
129  ProductRegistry const& preg,
130  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
131  module_->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, module_->moduleDescription().processName());
132  }
133 
135  module_->convertCurrentProcessAlias(processName);
136  }
137 
138  std::vector<ConsumesInfo> consumesInfo() const override {
139  return module_->consumesInfo();
140  }
141 
142  void itemsToGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
143  module_->itemsToGet(branchType, indexes);
144  }
145 
146  void itemsMayGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
147  module_->itemsMayGet(branchType, indexes);
148  }
149 
150  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType iType) const final { return module_->itemsToGetFrom(iType); }
151 
152  std::vector<ProductResolverIndex> const& itemsShouldPutInEvent() const override;
153 
154  void preActionBeforeRunEventAsync(WaitingTask* iTask, ModuleCallingContext const& iModuleCallingContext, Principal const& iPrincipal) const override {
155  module_->preActionBeforeRunEventAsync(iTask,iModuleCallingContext,iPrincipal);
156  }
157 
158  bool hasAcquire() const override {
159  return module_->hasAcquire();
160  }
161 
162  bool hasAccumulator() const override {
163  return module_->hasAccumulator();
164  }
165 
167  };
168 
169 }
170 
171 #endif
bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:416
bool hasAccumulator() const override
Definition: WorkerT.h:162
bool wantsStreamLuminosityBlocks() const final
Definition: WorkerT.cc:147
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:283
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:138
SerialTaskQueue * globalRunsQueue() final
Definition: WorkerT.cc:152
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void callWorkerStreamEnd(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:394
SerialTaskQueue * globalLuminosityBlocksQueue() final
Definition: WorkerT.cc:156
void convertCurrentProcessAlias(std::string const &processName) override
Definition: WorkerT.h:134
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const final
Definition: WorkerT.h:150
void implEndJob() override
Definition: WorkerT.cc:513
bool wantsGlobalRuns() const final
Definition: WorkerT.cc:132
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) override
Definition: WorkerT.cc:645
void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:146
T & module()
Definition: WorkerT.h:84
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:41
bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:404
T const & module() const
Definition: WorkerT.h:85
bool implDo(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:229
BranchType
Definition: BranchType.h:11
Types moduleType() const override
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:166
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:552
bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:286
void preActionBeforeRunEventAsync(WaitingTask *iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
Definition: WorkerT.h:154
bool wantsGlobalLuminosityBlocks() const final
Definition: WorkerT.cc:137
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:535
bool hasAcquire() const override
Definition: WorkerT.h:158
void implBeginStream(StreamID) override
Definition: WorkerT.cc:526
Definition: Types.py:1
void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc) const override
Definition: WorkerT.h:128
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:573
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) override
Definition: WorkerT.cc:701
void callWorkerStreamBegin(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:385
bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:377
~WorkerT() override
Definition: WorkerT.cc:127
T ModuleType
Definition: WorkerT.h:33
WorkerT< T > WorkerType
Definition: WorkerT.h:34
std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:710
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
bool implNeedToRunSelection() const final
Definition: WorkerT.cc:281
void implEndStream(StreamID) override
Definition: WorkerT.cc:542
void implBeginJob() override
Definition: WorkerT.cc:506
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:559
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:519
void implDoAcquire(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc, WaitingTaskWithArenaHolder &holder) final
Definition: WorkerT.cc:237
HLT enums.
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:294
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:566
bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:428
bool wantsStreamRuns() const final
Definition: WorkerT.cc:142
long double T
std::string workerType() const override
Definition: WorkerT.cc:499
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:120
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:142
def branchType(schema, name)
Definition: revisionDML.py:112