CMS 3D CMS Logo

ProducingModuleAdaptorBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_stream_ProducingModuleAdaptorBase_h
2 #define FWCore_Framework_stream_ProducingModuleAdaptorBase_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : ProducingModuleAdaptorBase
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Fri, 02 Aug 2013 18:09:15 GMT
19 //
20 
21 // system include files
22 #include <map>
23 #include <string>
24 #include <vector>
25 #include <unordered_map>
26 
27 // user include files
42 
43 // forward declarations
44 
45 namespace edm {
46  class Event;
47  class ModuleCallingContext;
48  class ModuleProcessName;
49  class ProductResolverIndexHelper;
50  class EDConsumerBase;
51  class PreallocationConfiguration;
52  class ProductResolverIndexAndSkipBit;
53  class ThinnedAssociationsHelper;
54 
55  namespace maker {
56  template <typename T>
57  class ModuleHolderT;
58  }
59 
60  namespace eventsetup {
62  }
63 
64  namespace stream {
65  template <typename T>
66  class ProducingModuleAdaptorBase {
67  public:
68  template <typename U>
69  friend class edm::WorkerT;
70  template <typename U>
72 
74  ProducingModuleAdaptorBase(const ProducingModuleAdaptorBase&) = delete; // stop default
75  const ProducingModuleAdaptorBase& operator=(const ProducingModuleAdaptorBase&) = delete; // stop default
77 
78  // ---------- const member functions ---------------------
79 
80  // ---------- static member functions --------------------
81 
82  // ---------- member functions ---------------------------
84 
85  virtual bool wantsProcessBlocks() const = 0;
86  virtual bool wantsInputProcessBlocks() const = 0;
87  virtual bool wantsGlobalRuns() const = 0;
88  virtual bool wantsGlobalLuminosityBlocks() const = 0;
89  virtual bool hasAcquire() const = 0;
90  virtual bool hasAccumulator() const = 0;
91  bool wantsStreamRuns() const { return true; }
92  bool wantsStreamLuminosityBlocks() const { return true; }
93 
95 
96  void itemsToGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
97  void itemsMayGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
98  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType) const;
99 
100  std::vector<ESProxyIndex> const& esGetTokenIndicesVector(edm::Transition iTrans) const;
101  std::vector<ESRecordIndex> const& esGetTokenRecordIndicesVector(edm::Transition iTrans) const;
102 
103  void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&, bool iPrefetchMayGet);
105 
106  void modulesWhoseProductsAreConsumed(std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
107  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
108  ProductRegistry const& preg,
109  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
110  std::string const& processName) const;
111 
113 
114  std::vector<ConsumesInfo> consumesInfo() const;
115 
117  std::unordered_multimap<std::string, std::tuple<edm::TypeID const*, const char*, edm::ProductResolverIndex>>;
118 
119  void resolvePutIndicies(BranchType iBranchType,
120  ModuleToResolverIndicies const& iIndicies,
121  std::string const& moduleLabel);
122 
123  std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const;
124 
125  protected:
126  template <typename F>
127  void createStreamModules(F iFunc) {
128  for (auto& m : m_streamModules) {
129  m = iFunc();
130  m->setModuleDescriptionPtr(&moduleDescription_);
131  }
132  }
133 
134  void commit(ProcessBlock& iProcessBlock) {
136  }
139  template <typename I>
140  void commit(Event& iEvent, I* iID) {
142  }
143 
144  const EDConsumerBase* consumer() { return m_streamModules[0]; }
145 
146  const ProducerBase* producer() { return m_streamModules[0]; }
147 
148  private:
150  virtual void preallocLumis(unsigned int) {}
151  virtual void setupStreamModules() = 0;
152  virtual void doBeginJob() = 0;
153  virtual void doEndJob() = 0;
154 
155  void doBeginStream(StreamID);
156  void doEndStream(StreamID);
158  virtual void setupRun(T*, RunIndex) = 0;
160  virtual void streamEndRunSummary(T*, edm::Run const&, edm::EventSetup const&) = 0;
161 
163  virtual void setupLuminosityBlock(T*, LuminosityBlockIndex) = 0;
165  virtual void streamEndLuminosityBlockSummary(T*, edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
166 
167  virtual void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
169  virtual void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
170  virtual void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*) = 0;
171  virtual void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*) = 0;
172  virtual void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*) = 0;
173  virtual void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*) = 0;
174 
175  //For now, the following are just dummy implemenations with no ability for users to override
179 
180  // ---------- member data --------------------------------
183 
184  protected:
185  std::vector<T*> m_streamModules;
186  };
187  } // namespace stream
188 } // namespace edm
189 
190 #endif
edm::stream::ProducingModuleAdaptorBase::commit
void commit(Run &iRun)
Definition: ProducingModuleAdaptorBase.h:137
edm::stream::ProducingModuleAdaptorBase::streamEndRunSummary
virtual void streamEndRunSummary(T *, edm::Run const &, edm::EventSetup const &)=0
edm::stream::ProducingModuleAdaptorBase::setupRun
virtual void setupRun(T *, RunIndex)=0
edm::StreamID
Definition: StreamID.h:30
edm::stream::ProducingModuleAdaptorBase::resolvePutIndicies
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
Definition: ProducingModuleAdaptorBase.cc:161
edm::stream::ProducingModuleAdaptorBase::streamEndLuminosityBlockSummary
virtual void streamEndLuminosityBlockSummary(T *, edm::LuminosityBlock const &, edm::EventSetup const &)=0
edm::stream::ProducingModuleAdaptorBase::itemsMayGet
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Definition: ProducingModuleAdaptorBase.cc:93
edm::stream::ProducingModuleAdaptorBase::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, std::string const &processName) const
Definition: ProducingModuleAdaptorBase.cc:121
edm::stream::ProducingModuleAdaptorBase::registerProductsAndCallbacks
void registerProductsAndCallbacks(ProducingModuleAdaptorBase const *, ProductRegistry *reg)
Definition: ProducingModuleAdaptorBase.cc:62
edm::stream::ProducingModuleAdaptorBase::doStreamBeginRun
void doStreamBeginRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:185
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::stream::ProducingModuleAdaptorBase::itemsToGet
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Definition: ProducingModuleAdaptorBase.cc:86
edm::stream::ProducingModuleAdaptorBase::~ProducingModuleAdaptorBase
virtual ~ProducingModuleAdaptorBase()
Definition: ProducingModuleAdaptorBase.cc:44
edm::Run::commit_
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut)
Definition: Run.cc:83
edm::LumiTransitionInfo
Definition: TransitionInfoTypes.h:42
edm::stream::ProducingModuleAdaptorBase::wantsInputProcessBlocks
virtual bool wantsInputProcessBlocks() const =0
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm::stream::ProducingModuleAdaptorBase::ProducingModuleAdaptorBase
ProducingModuleAdaptorBase()
Definition: ProducingModuleAdaptorBase.cc:41
modules
Definition: MuonCleanerBySegments.cc:35
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::stream::ProducingModuleAdaptorBase::moduleDescription_
ModuleDescription moduleDescription_
Definition: ProducingModuleAdaptorBase.h:182
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
edm::stream::ProducingModuleAdaptorBase::updateLookup
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
Definition: ProducingModuleAdaptorBase.cc:146
ProcessBlock.h
ProductResolverIndex.h
edm::stream::ProducingModuleAdaptorBase::m_streamModules
std::vector< T * > m_streamModules
Definition: ProducingModuleAdaptorBase.h:185
edm::stream::ProducingModuleAdaptorBase::doEndJob
virtual void doEndJob()=0
edm::stream::ProducingModuleAdaptorBase::indiciesForPutProducts
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducingModuleAdaptorBase.cc:170
mps_check.array
array
Definition: mps_check.py:216
edm::WorkerT
Definition: Frameworkfwd.h:62
edm::ProductResolverIndexHelper
Definition: ProductResolverIndexHelper.h:89
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
ESIndices.h
edm::InRun
Definition: BranchType.h:11
edm::ProcessBlockPrincipal
Definition: ProcessBlockPrincipal.h:22
edm::BranchType
BranchType
Definition: BranchType.h:11
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::NumBranchTypes
Definition: BranchType.h:11
edm::stream::ProducingModuleAdaptorBase::doRespondToCloseInputFile
void doRespondToCloseInputFile(FileBlock const &fb)
Definition: ProducingModuleAdaptorBase.cc:259
edm::stream::ProducingModuleAdaptorBase::createStreamModules
void createStreamModules(F iFunc)
Definition: ProducingModuleAdaptorBase.h:127
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
edm::ProductRegistry
Definition: ProductRegistry.h:37
ModuleDescription.h
edm::stream::ProducingModuleAdaptorBase::doEndProcessBlock
virtual void doEndProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *)=0
edm::FileBlock
Definition: FileBlock.h:20
edm::stream::ProducingModuleAdaptorBase::wantsGlobalLuminosityBlocks
virtual bool wantsGlobalLuminosityBlocks() const =0
edm::InProcess
Definition: BranchType.h:11
edm::EDConsumerBase
Definition: EDConsumerBase.h:71
edm::LuminosityBlockIndex
Definition: LuminosityBlockIndex.h:33
Exhume::I
const std::complex< double > I
Definition: I.h:8
edm::ProcessBlock::commit_
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut)
Definition: ProcessBlock.cc:27
edm::stream::ProducingModuleAdaptorBase::doAccessInputProcessBlock
virtual void doAccessInputProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *)=0
edm::stream::ProducingModuleAdaptorBase::hasAccumulator
virtual bool hasAccumulator() const =0
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
edm::stream::ProducingModuleAdaptorBase::consumer
const EDConsumerBase * consumer()
Definition: ProducingModuleAdaptorBase.h:144
Run.h
edm::stream::ProducingModuleAdaptorBase::wantsProcessBlocks
virtual bool wantsProcessBlocks() const =0
Event
edm::stream::ProducingModuleAdaptorBase::doPreallocate
void doPreallocate(PreallocationConfiguration const &)
Definition: ProducingModuleAdaptorBase.cc:55
edm::stream::ProducingModuleAdaptorBase::preallocLumis
virtual void preallocLumis(unsigned int)
Definition: ProducingModuleAdaptorBase.h:150
edm::stream::ProducingModuleAdaptorBase::doEndLuminosityBlock
virtual void doEndLuminosityBlock(LumiTransitionInfo const &, ModuleCallingContext const *)=0
edm::InEvent
Definition: BranchType.h:11
edm::maker::ModuleHolderT
Definition: EDAnalyzer.h:25
edm::stream::ProducingModuleAdaptorBase::wantsGlobalRuns
virtual bool wantsGlobalRuns() const =0
edm::stream::ProducingModuleAdaptorBase::hasAcquire
virtual bool hasAcquire() const =0
RunIndex.h
edm::stream::ProducingModuleAdaptorBase::setupStreamModules
virtual void setupStreamModules()=0
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::stream::ProducingModuleAdaptorBase::producer
const ProducerBase * producer()
Definition: ProducingModuleAdaptorBase.h:146
edm::stream::ProducingModuleAdaptorBase::doEndRun
virtual void doEndRun(RunTransitionInfo const &, ModuleCallingContext const *)=0
edm::stream::ProducingModuleAdaptorBase::esGetTokenRecordIndicesVector
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector(edm::Transition iTrans) const
Definition: ProducingModuleAdaptorBase.cc:114
edm::stream::ProducingModuleAdaptorBase::doStreamEndRun
void doStreamEndRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:204
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:37
edm::stream::ProducingModuleAdaptorBase::commit
void commit(LuminosityBlock &iLumi)
Definition: ProducingModuleAdaptorBase.h:138
edm::Transition
Transition
Definition: Transition.h:12
Event.h
edm::InLumi
Definition: BranchType.h:11
edm::LuminosityBlock::commit_
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut)
Definition: LuminosityBlock.cc:77
edm::stream::ProducingModuleAdaptorBase::setupLuminosityBlock
virtual void setupLuminosityBlock(T *, LuminosityBlockIndex)=0
ESRecordsToProxyIndices
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::ProducingModuleAdaptorBase::ModuleToResolverIndicies
std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > > ModuleToResolverIndicies
Definition: ProducingModuleAdaptorBase.h:117
BranchType.h
edm::stream::ProducingModuleAdaptorBase::esGetTokenIndicesVector
std::vector< ESProxyIndex > const & esGetTokenIndicesVector(edm::Transition iTrans) const
Definition: ProducingModuleAdaptorBase.cc:107
edm::stream::ProducingModuleAdaptorBase::wantsStreamRuns
bool wantsStreamRuns() const
Definition: ProducingModuleAdaptorBase.h:91
edm::EventSetup
Definition: EventSetup.h:58
edm::stream::ProducingModuleAdaptorBase
Definition: Event.h:70
edm::stream::ProducingModuleAdaptorBase::doRegisterThinnedAssociations
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
Definition: ProducingModuleAdaptorBase.cc:262
edm::stream::ProducingModuleAdaptorBase::itemsToGetFrom
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) const
Definition: ProducingModuleAdaptorBase.cc:100
edm::stream::ProducingModuleAdaptorBase::setModuleDescription
void setModuleDescription(ModuleDescription const &md)
Definition: ProducingModuleAdaptorBase.h:181
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
edm::PreallocationConfiguration
Definition: PreallocationConfiguration.h:27
edm::stream::ProducingModuleAdaptorBase::wantsStreamLuminosityBlocks
bool wantsStreamLuminosityBlocks() const
Definition: ProducingModuleAdaptorBase.h:92
edm::stream::ProducingModuleAdaptorBase::doStreamEndLuminosityBlock
void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:240
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
edm::stream::ProducingModuleAdaptorBase::doStreamBeginLuminosityBlock
void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:221
ParameterSetfwd.h
edm::stream::ProducingModuleAdaptorBase::commit
void commit(Event &iEvent, I *iID)
Definition: ProducingModuleAdaptorBase.h:140
edm::RunIndex
Definition: RunIndex.h:32
edm::stream::ProducingModuleAdaptorBase::doBeginRun
virtual void doBeginRun(RunTransitionInfo const &, ModuleCallingContext const *)=0
edm::stream::ProducingModuleAdaptorBase::doEndStream
void doEndStream(StreamID)
Definition: ProducingModuleAdaptorBase.cc:180
LuminosityBlockIndex.h
edm::stream::ProducingModuleAdaptorBase::consumesInfo
std::vector< ConsumesInfo > consumesInfo() const
Definition: ProducingModuleAdaptorBase.cc:140
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::ProducerBase
Definition: ProducerBase.h:70
edm::stream::ProducingModuleAdaptorBase::moduleDescription
const ModuleDescription & moduleDescription() const
Definition: ProducingModuleAdaptorBase.h:83
edm::Event
Definition: Event.h:73
edm::stream::ProducingModuleAdaptorBase::doBeginStream
void doBeginStream(StreamID)
Definition: ProducingModuleAdaptorBase.cc:176
edm::stream::ProducingModuleAdaptorBase::doBeginLuminosityBlock
virtual void doBeginLuminosityBlock(LumiTransitionInfo const &, ModuleCallingContext const *)=0
edm::stream::ProducingModuleAdaptorBase::doBeginProcessBlock
virtual void doBeginProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *)=0
ConsumesInfo.h
StreamID.h
edm::stream::ProducingModuleAdaptorBase::doRespondToOpenInputFile
void doRespondToOpenInputFile(FileBlock const &fb)
Definition: ProducingModuleAdaptorBase.cc:257
edm::ProcessBlock
Definition: ProcessBlock.h:36
benchmark_cfg.fb
fb
Definition: benchmark_cfg.py:14
edm::stream::ProducingModuleAdaptorBase::commit
void commit(ProcessBlock &iProcessBlock)
Definition: ProducingModuleAdaptorBase.h:134
edm::stream::ProducingModuleAdaptorBase::operator=
const ProducingModuleAdaptorBase & operator=(const ProducingModuleAdaptorBase &)=delete
edm::stream::ProducingModuleAdaptorBase::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName)
Definition: ProducingModuleAdaptorBase.cc:133
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29
edm::stream::ProducingModuleAdaptorBase::doBeginJob
virtual void doBeginJob()=0