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 ProductResolverIndexHelper;
49  class EDConsumerBase;
50  class PreallocationConfiguration;
51  class ProductResolverIndexAndSkipBit;
52  class ThinnedAssociationsHelper;
53 
54  namespace maker {
55  template <typename T>
56  class ModuleHolderT;
57  }
58 
59  namespace eventsetup {
61  }
62 
63  namespace stream {
64  template <typename T>
65  class ProducingModuleAdaptorBase {
66  public:
67  template <typename U>
68  friend class edm::WorkerT;
69  template <typename U>
71 
73  ProducingModuleAdaptorBase(const ProducingModuleAdaptorBase&) = delete; // stop default
74  const ProducingModuleAdaptorBase& operator=(const ProducingModuleAdaptorBase&) = delete; // stop default
76 
77  // ---------- const member functions ---------------------
78 
79  // ---------- static member functions --------------------
80 
81  // ---------- member functions ---------------------------
83 
84  virtual bool wantsProcessBlocks() const = 0;
85  virtual bool wantsInputProcessBlocks() const = 0;
86  virtual bool wantsGlobalRuns() const = 0;
87  virtual bool wantsGlobalLuminosityBlocks() const = 0;
88  virtual bool hasAcquire() const = 0;
89  virtual bool hasAccumulator() const = 0;
90  bool wantsStreamRuns() const { return true; }
91  bool wantsStreamLuminosityBlocks() const { return true; }
92 
94 
95  void itemsToGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
96  void itemsMayGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
97  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType) const;
98 
99  std::vector<ESProxyIndex> const& esGetTokenIndicesVector(edm::Transition iTrans) const;
100  std::vector<ESRecordIndex> const& esGetTokenRecordIndicesVector(edm::Transition iTrans) const;
101 
102  void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&, bool iPrefetchMayGet);
104 
105  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
106  ProductRegistry const& preg,
107  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
108  std::string const& processName) const;
109 
111 
112  std::vector<ConsumesInfo> consumesInfo() const;
113 
115  std::unordered_multimap<std::string, std::tuple<edm::TypeID const*, const char*, edm::ProductResolverIndex>>;
116 
117  void resolvePutIndicies(BranchType iBranchType,
118  ModuleToResolverIndicies const& iIndicies,
119  std::string const& moduleLabel);
120 
121  std::vector<edm::ProductResolverIndex> const& indiciesForPutProducts(BranchType iBranchType) const;
122 
123  protected:
124  template <typename F>
125  void createStreamModules(F iFunc) {
126  for (auto& m : m_streamModules) {
127  m = iFunc();
128  m->setModuleDescriptionPtr(&moduleDescription_);
129  }
130  }
131 
132  void commit(ProcessBlock& iProcessBlock) {
134  }
137  template <typename I>
138  void commit(Event& iEvent, I* iID) {
140  }
141 
142  const EDConsumerBase* consumer() { return m_streamModules[0]; }
143 
144  const ProducerBase* producer() { return m_streamModules[0]; }
145 
146  private:
148  virtual void preallocLumis(unsigned int) {}
149  virtual void setupStreamModules() = 0;
150  virtual void doBeginJob() = 0;
151  virtual void doEndJob() = 0;
152 
153  void doBeginStream(StreamID);
154  void doEndStream(StreamID);
156  virtual void setupRun(T*, RunIndex) = 0;
158  virtual void streamEndRunSummary(T*, edm::Run const&, edm::EventSetup const&) = 0;
159 
161  virtual void setupLuminosityBlock(T*, LuminosityBlockIndex) = 0;
163  virtual void streamEndLuminosityBlockSummary(T*, edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
164 
165  virtual void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
167  virtual void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
168  virtual void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*) = 0;
169  virtual void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*) = 0;
170  virtual void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*) = 0;
171  virtual void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*) = 0;
172 
173  //For now, the following are just dummy implemenations with no ability for users to override
177 
178  // ---------- member data --------------------------------
181 
182  protected:
183  std::vector<T*> m_streamModules;
184  };
185  } // namespace stream
186 } // namespace edm
187 
188 #endif
edm::stream::ProducingModuleAdaptorBase::commit
void commit(Run &iRun)
Definition: ProducingModuleAdaptorBase.h:135
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:158
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:92
edm::stream::ProducingModuleAdaptorBase::registerProductsAndCallbacks
void registerProductsAndCallbacks(ProducingModuleAdaptorBase const *, ProductRegistry *reg)
Definition: ProducingModuleAdaptorBase.cc:61
edm::stream::ProducingModuleAdaptorBase::doStreamBeginRun
void doStreamBeginRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:182
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::stream::ProducingModuleAdaptorBase::itemsToGet
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Definition: ProducingModuleAdaptorBase.cc:85
edm::stream::ProducingModuleAdaptorBase::~ProducingModuleAdaptorBase
virtual ~ProducingModuleAdaptorBase()
Definition: ProducingModuleAdaptorBase.cc:43
edm::Run::commit_
void commit_(std::vector< edm::ProductResolverIndex > const &iShouldPut)
Definition: Run.cc:80
edm::stream::ProducingModuleAdaptorBase::modulesWhoseProductsAreConsumed
void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
Definition: ProducingModuleAdaptorBase.cc:120
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:40
modules
Definition: ZHLTMatchFilter.cc:17
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::stream::ProducingModuleAdaptorBase::moduleDescription_
ModuleDescription moduleDescription_
Definition: ProducingModuleAdaptorBase.h:180
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:143
ProcessBlock.h
ProductResolverIndex.h
edm::stream::ProducingModuleAdaptorBase::m_streamModules
std::vector< T * > m_streamModules
Definition: ProducingModuleAdaptorBase.h:183
edm::stream::ProducingModuleAdaptorBase::doEndJob
virtual void doEndJob()=0
edm::stream::ProducingModuleAdaptorBase::indiciesForPutProducts
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducingModuleAdaptorBase.cc:167
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::stream::ProducingModuleAdaptorBase::doRespondToCloseInputFile
void doRespondToCloseInputFile(FileBlock const &fb)
Definition: ProducingModuleAdaptorBase.cc:244
edm::stream::ProducingModuleAdaptorBase::createStreamModules
void createStreamModules(F iFunc)
Definition: ProducingModuleAdaptorBase.h:125
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:70
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:26
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:142
Run.h
edm::stream::ProducingModuleAdaptorBase::wantsProcessBlocks
virtual bool wantsProcessBlocks() const =0
Event
edm::stream::ProducingModuleAdaptorBase::doPreallocate
void doPreallocate(PreallocationConfiguration const &)
Definition: ProducingModuleAdaptorBase.cc:54
edm::stream::ProducingModuleAdaptorBase::preallocLumis
virtual void preallocLumis(unsigned int)
Definition: ProducingModuleAdaptorBase.h:148
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:144
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:113
edm::stream::ProducingModuleAdaptorBase::doStreamEndRun
void doStreamEndRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:197
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:37
edm::stream::ProducingModuleAdaptorBase::commit
void commit(LuminosityBlock &iLumi)
Definition: ProducingModuleAdaptorBase.h:136
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:72
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:115
BranchType.h
edm::stream::ProducingModuleAdaptorBase::esGetTokenIndicesVector
std::vector< ESProxyIndex > const & esGetTokenIndicesVector(edm::Transition iTrans) const
Definition: ProducingModuleAdaptorBase.cc:106
edm::stream::ProducingModuleAdaptorBase::wantsStreamRuns
bool wantsStreamRuns() const
Definition: ProducingModuleAdaptorBase.h:90
edm::EventSetup
Definition: EventSetup.h:57
edm::stream::ProducingModuleAdaptorBase
Definition: Event.h:70
edm::stream::ProducingModuleAdaptorBase::doRegisterThinnedAssociations
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
Definition: ProducingModuleAdaptorBase.cc:247
edm::stream::ProducingModuleAdaptorBase::itemsToGetFrom
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) const
Definition: ProducingModuleAdaptorBase.cc:99
edm::stream::ProducingModuleAdaptorBase::setModuleDescription
void setModuleDescription(ModuleDescription const &md)
Definition: ProducingModuleAdaptorBase.h:179
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:91
edm::stream::ProducingModuleAdaptorBase::doStreamEndLuminosityBlock
void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:227
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
edm::stream::ProducingModuleAdaptorBase::doStreamBeginLuminosityBlock
void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:210
ParameterSetfwd.h
edm::stream::ProducingModuleAdaptorBase::commit
void commit(Event &iEvent, I *iID)
Definition: ProducingModuleAdaptorBase.h:138
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:177
LuminosityBlockIndex.h
edm::stream::ProducingModuleAdaptorBase::consumesInfo
std::vector< ConsumesInfo > consumesInfo() const
Definition: ProducingModuleAdaptorBase.cc:137
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:82
edm::Event
Definition: Event.h:73
edm::stream::ProducingModuleAdaptorBase::doBeginStream
void doBeginStream(StreamID)
Definition: ProducingModuleAdaptorBase.cc:173
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:242
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:132
edm::stream::ProducingModuleAdaptorBase::operator=
const ProducingModuleAdaptorBase & operator=(const ProducingModuleAdaptorBase &)=delete
edm::stream::ProducingModuleAdaptorBase::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName)
Definition: ProducingModuleAdaptorBase.cc:130
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29
edm::stream::ProducingModuleAdaptorBase::doBeginJob
virtual void doBeginJob()=0