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 
16 
17 #include <map>
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 namespace edm {
23 
24  class ModuleCallingContext;
25  class ModuleProcessName;
26  class ProductResolverIndexAndSkipBit;
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>, ModuleDescription const&, ExceptionToActionTable const* actions);
36 
37  ~WorkerT() override;
38 
39  void setModule(std::shared_ptr<T> iModule) {
40  module_ = iModule;
41  resetModuleDescription(&(module_->moduleDescription()));
42  }
43 
44  Types moduleType() const override;
45 
46  bool wantsProcessBlocks() const final;
47  bool wantsInputProcessBlocks() const final;
48  bool wantsGlobalRuns() const final;
50  bool wantsStreamRuns() const final;
52 
55 
56  void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) final;
57  void updateLookup(eventsetup::ESRecordsToProxyIndices const&) final;
58  void resolvePutIndicies(
59  BranchType iBranchType,
60  std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
61  iIndicies) final;
62 
63  template <typename D>
65  template <typename D>
67  template <typename D>
69  template <typename D>
71  template <typename D>
73  template <typename D>
75 
76  protected:
77  T& module() { return *module_; }
78  T const& module() const { return *module_; }
79 
80  private:
81  void doClearModule() override { get_underlying_safe(module_).reset(); }
82 
83  bool implDo(EventTransitionInfo const&, ModuleCallingContext const*) override;
84 
85  void itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>&) const final;
86  bool implNeedToRunSelection() const final;
87 
89 
102  void implBeginJob() override;
103  void implEndJob() override;
104  void implBeginStream(StreamID) override;
105  void implEndStream(StreamID) override;
109  std::string workerType() const override;
110  TaskQueueAdaptor serializeRunModule() override;
111 
114  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
115  ProductRegistry const& preg,
116  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
117  module_->modulesWhoseProductsAreConsumed(
118  modules, modulesInPreviousProcesses, preg, labelsToDesc, module_->moduleDescription().processName());
119  }
120 
122  module_->convertCurrentProcessAlias(processName);
123  }
124 
125  std::vector<ConsumesInfo> consumesInfo() const override { return module_->consumesInfo(); }
126 
127  void itemsToGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
128  module_->itemsToGet(branchType, indexes);
129  }
130 
131  void itemsMayGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
132  module_->itemsMayGet(branchType, indexes);
133  }
134 
135  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType iType) const final {
136  return module_->itemsToGetFrom(iType);
137  }
138 
139  std::vector<ESProxyIndex> const& esItemsToGetFrom(Transition iTransition) const override {
140  return module_->esGetTokenIndicesVector(iTransition);
141  }
142  std::vector<ESRecordIndex> const& esRecordsToGetFrom(Transition iTransition) const override {
143  return module_->esGetTokenRecordIndicesVector(iTransition);
144  }
145 
146  std::vector<ProductResolverIndex> const& itemsShouldPutInEvent() const override;
147 
149  ModuleCallingContext const& iModuleCallingContext,
150  Principal const& iPrincipal) const override {
151  module_->preActionBeforeRunEventAsync(iTask, iModuleCallingContext, iPrincipal);
152  }
153 
154  bool hasAcquire() const override { return module_->hasAcquire(); }
155 
156  bool hasAccumulator() const override { return module_->hasAccumulator(); }
157 
159  };
160 
161 } // namespace edm
162 
163 #endif
edm::EventTransitionInfo
Definition: TransitionInfoTypes.h:26
edm::StreamID
Definition: StreamID.h:30
edm::ProductResolverIndex
unsigned int ProductResolverIndex
Definition: ProductResolverIndex.h:8
edm::WorkerT::globalLuminosityBlocksQueue
SerialTaskQueue * globalLuminosityBlocksQueue() final
Definition: WorkerT.cc:153
edm::WorkerT::updateLookup
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) final
Definition: WorkerT.cc:626
edm::WorkerT::implDo
bool implDo(EventTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:215
edm::LumiTransitionInfo
Definition: TransitionInfoTypes.h:42
propagate_const.h
edm::WorkerT::implDoBegin
bool implDoBegin(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:336
modules
Definition: MuonCleanerBySegments.cc:35
edm::WorkerT::globalRunsQueue
SerialTaskQueue * globalRunsQueue() final
Definition: WorkerT.cc:149
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::WorkerT::esItemsToGetFrom
std::vector< ESProxyIndex > const & esItemsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:139
edm::WorkerT::itemsToGetFrom
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const final
Definition: WorkerT.h:135
edm::Worker::resetModuleDescription
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:339
edm::WorkerT::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName) override
Definition: WorkerT.h:121
edm::Principal
Definition: Principal.h:56
edm::SerialTaskQueue
Definition: SerialTaskQueue.h:67
mps_check.array
array
Definition: mps_check.py:216
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
edm::WorkerT::callWorkerStreamEnd
void callWorkerStreamEnd(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:352
edm::WorkerT
Definition: Frameworkfwd.h:62
edm::ProductResolverIndexHelper
Definition: ProductResolverIndexHelper.h:89
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
watchdog.const
const
Definition: watchdog.py:83
edm::WorkerT::workerType
std::string workerType() const override
Definition: WorkerT.cc:437
edm::ProcessBlockPrincipal
Definition: ProcessBlockPrincipal.h:22
edm::WorkerT::itemsToGet
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:127
edm::BranchType
BranchType
Definition: BranchType.h:11
edm::WorkerT::wantsInputProcessBlocks
bool wantsInputProcessBlocks() const final
Definition: WorkerT.cc:124
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::WorkerT::implDoAccessInputProcessBlock
bool implDoAccessInputProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:324
edm::NumBranchTypes
Definition: BranchType.h:11
edm::WorkerT::esRecordsToGetFrom
std::vector< ESRecordIndex > const & esRecordsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:142
edm::WorkerT::hasAcquire
bool hasAcquire() const override
Definition: WorkerT.h:154
edm::ProductRegistry
Definition: ProductRegistry.h:37
edm::FileBlock
Definition: FileBlock.h:20
edm::WorkerT::setModule
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:39
edm::WorkerT::implNeedToRunSelection
bool implNeedToRunSelection() const final
Definition: WorkerT.cc:255
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
edm::propagate_const
Definition: propagate_const.h:32
edm::WorkerT::wantsStreamLuminosityBlocks
bool wantsStreamLuminosityBlocks() const final
Definition: WorkerT.cc:144
edm::WorkerT::consumesInfo
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:125
edm::WorkerT::module_
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:158
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::WorkerT::resolvePutIndicies
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) final
Definition: WorkerT.cc:684
edm::WorkerT::implDoPrePrefetchSelection
bool implDoPrePrefetchSelection(StreamID, EventPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:260
edm::WorkerT::ModuleType
T ModuleType
Definition: WorkerT.h:33
edm::WorkerT::wantsGlobalRuns
bool wantsGlobalRuns() const final
Definition: WorkerT.cc:129
edm::WorkerT::moduleType
Types moduleType() const override
edm::WorkerT::implDoEnd
bool implDoEnd(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:379
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::WorkerT::WorkerType
WorkerT< T > WorkerType
Definition: WorkerT.h:34
edm::WorkerT::implRegisterThinnedAssociations
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:488
edm::WorkerT::implEndStream
void implEndStream(StreamID) override
Definition: WorkerT.cc:471
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:37
edm::Transition
Transition
Definition: Transition.h:12
edm::WorkerT::implDoStreamBegin
bool implDoStreamBegin(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:357
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
edm::WorkerT::itemsShouldPutInEvent
std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:692
edm::WorkerT::wantsProcessBlocks
bool wantsProcessBlocks() const final
Definition: WorkerT.cc:119
edm::WorkerT::callWorkerStreamBegin
void callWorkerStreamBegin(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:343
ESRecordsToProxyIndices
edm::WorkerT::callWorkerBeginStream
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:453
edm::WorkerT::implDoStreamEnd
bool implDoStreamEnd(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:369
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::WorkerT::module
T const & module() const
Definition: WorkerT.h:78
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
edm::ExceptionToActionTable
Definition: ExceptionActions.h:16
edm::WorkerT::doClearModule
void doClearModule() override
Definition: WorkerT.h:81
edm::WorkerT::implDoBeginProcessBlock
bool implDoBeginProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:318
edm::WorkerT::wantsStreamRuns
bool wantsStreamRuns() const final
Definition: WorkerT.cc:139
edm::WorkerT::itemsToGetForSelection
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:266
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
Types
Definition: Types.py:1
edm::WorkerT::implBeginJob
void implBeginJob() override
Definition: WorkerT.cc:442
edm::WorkerT::implRespondToOpenInputFile
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:478
edm::WorkerT::wantsGlobalLuminosityBlocks
bool wantsGlobalLuminosityBlocks() const final
Definition: WorkerT.cc:134
funct::D
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
WorkerParams.h
edm::TypeID
Definition: TypeID.h:22
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
edm::WorkerT::preActionBeforeRunEventAsync
void preActionBeforeRunEventAsync(WaitingTaskHolder iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
Definition: WorkerT.h:148
edm::WorkerT::serializeRunModule
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:494
Worker.h
edm::WorkerT::callWorkerEndStream
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:466
edm::WorkerT::modulesWhoseProductsAreConsumed
void modulesWhoseProductsAreConsumed(std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modules, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc) const override
Definition: WorkerT.h:112
edm::ModuleProcessName
Definition: ModuleProcessName.h:12
edm::WorkerT::implBeginStream
void implBeginStream(StreamID) override
Definition: WorkerT.cc:458
edm::WorkerT::hasAccumulator
bool hasAccumulator() const override
Definition: WorkerT.h:156
actions
roAction_t actions[nactions]
Definition: GenABIO.cc:181
TransitionInfoTypes.h
edm::WorkerT::implDoAcquire
void implDoAcquire(EventTransitionInfo const &, ModuleCallingContext const *, WaitingTaskWithArenaHolder &) final
Definition: WorkerT.cc:222
genParticles_cff.map
map
Definition: genParticles_cff.py:11
edm::WorkerT::module
T & module()
Definition: WorkerT.h:77
ConsumesInfo.h
edm::WorkerT::itemsMayGet
void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:131
edm::WorkerT::implRespondToCloseInputFile
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:483
edm::WorkerT::WorkerT
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:110
benchmark_cfg.fb
fb
Definition: benchmark_cfg.py:14
edm::WorkerT::~WorkerT
~WorkerT() override
Definition: WorkerT.cc:116
edm::WorkerT::implEndJob
void implEndJob() override
Definition: WorkerT.cc:447
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29
edm::WorkerT::implDoEndProcessBlock
bool implDoEndProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:330