CMS 3D CMS Logo

ProducingModuleAdaptorBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/Framework
4 // Class : edm::stream::ProducingModuleAdaptorBase
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: Fri, 02 Aug 2013 21:43:44 GMT
11 //
12 
13 // system include files
14 #include <cassert>
15 
16 // user include files
24 
25 //
26 // constants, enums and typedefs
27 //
28 
29 //
30 // static data member definitions
31 //
32 
33 //
34 // constructors and destructor
35 //
36 namespace edm {
37  namespace stream {
38  template <typename T>
40 
41  template <typename T>
43  for (auto m : m_streamModules) {
44  delete m;
45  }
46  }
47 
48  //
49  // member functions
50  //
51 
52  template <typename T>
54  m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast<T*>(nullptr));
55  setupStreamModules();
56  preallocLumis(iPrealloc.numberOfLuminosityBlocks());
57  }
58 
59  template <typename T>
61  ProductRegistry* reg) {
62  auto firstMod = m_streamModules[0];
63  if (firstMod->registrationCallback() and m_streamModules.size() > 1) {
64  //we have a callback so we will collect all callbacks and create a new callback which calls them all.
65 
66  std::vector<std::function<void(BranchDescription const&)>> callbacks;
67  callbacks.reserve(m_streamModules.size());
68 
69  for (auto mod : m_streamModules) {
70  callbacks.push_back(mod->registrationCallback());
71  }
72  //Since only the first module will actually do the registration
73  // we will change its callback to call all the callbacks
74  firstMod->callWhenNewProductsRegistered([callbacks](BranchDescription const& iBD) {
75  for (auto c : callbacks) {
76  c(iBD);
77  }
78  });
79  }
80  firstMod->registerProducts(firstMod, reg, moduleDescription_);
81  }
82 
83  template <typename T>
85  std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
86  assert(not m_streamModules.empty());
87  m_streamModules[0]->itemsToGet(iType, iIndices);
88  }
89 
90  template <typename T>
92  std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
93  assert(not m_streamModules.empty());
94  m_streamModules[0]->itemsMayGet(iType, iIndices);
95  }
96 
97  template <typename T>
98  std::vector<edm::ProductResolverIndexAndSkipBit> const& ProducingModuleAdaptorBase<T>::itemsToGetFrom(
99  BranchType iType) const {
100  assert(not m_streamModules.empty());
101  return m_streamModules[0]->itemsToGetFrom(iType);
102  }
103 
104  template <typename T>
106  std::vector<ModuleDescription const*>& modules,
107  ProductRegistry const& preg,
108  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
109  std::string const& processName) const {
110  assert(not m_streamModules.empty());
111  return m_streamModules[0]->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, processName);
112  }
113 
114  template <typename T>
116  for (auto mod : m_streamModules) {
117  mod->convertCurrentProcessAlias(processName);
118  }
119  }
120 
121  template <typename T>
122  std::vector<edm::ConsumesInfo> ProducingModuleAdaptorBase<T>::consumesInfo() const {
123  assert(not m_streamModules.empty());
124  return m_streamModules[0]->consumesInfo();
125  }
126 
127  template <typename T>
129  ProductResolverIndexHelper const& iHelper,
130  bool iPrefetchMayGet) {
131  for (auto mod : m_streamModules) {
132  mod->updateLookup(iType, iHelper, iPrefetchMayGet);
133  }
134  }
135  template <typename T>
137  for (auto mod : m_streamModules) {
138  mod->updateLookup(iPI);
139  }
140  }
141 
142  template <typename T>
144  ModuleToResolverIndicies const& iIndicies,
145  std::string const& moduleLabel) {
146  for (auto mod : m_streamModules) {
147  mod->resolvePutIndicies(iBranchType, iIndicies, moduleLabel);
148  }
149  }
150 
151  template <typename T>
152  std::vector<edm::ProductResolverIndex> const& ProducingModuleAdaptorBase<T>::indiciesForPutProducts(
153  BranchType iBranchType) const {
154  return m_streamModules[0]->indiciesForPutProducts(iBranchType);
155  }
156 
157  template <typename T>
159  m_streamModules[id]->beginStream(id);
160  }
161  template <typename T>
163  m_streamModules[id]->endStream();
164  }
165 
166  template <typename T>
168  RunPrincipal const& rp,
169  EventSetupImpl const& ci,
170  ModuleCallingContext const* mcc) {
171  auto mod = m_streamModules[id];
172  setupRun(mod, rp.index());
173 
174  Run r(rp, moduleDescription_, mcc, false);
175  r.setConsumer(mod);
176  const EventSetup c{
177  ci, static_cast<unsigned int>(Transition::BeginRun), mod->esGetTokenIndices(Transition::BeginRun), false};
178  mod->beginRun(r, c);
179  }
180  template <typename T>
182  RunPrincipal const& rp,
183  EventSetupImpl const& ci,
184  ModuleCallingContext const* mcc) {
185  auto mod = m_streamModules[id];
186  Run r(rp, moduleDescription_, mcc, true);
187  r.setConsumer(mod);
188  const EventSetup c{
189  ci, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun), false};
190  mod->endRun(r, c);
191  streamEndRunSummary(mod, r, c);
192  }
193 
194  template <typename T>
196  LuminosityBlockPrincipal const& lbp,
197  EventSetupImpl const& ci,
198  ModuleCallingContext const* mcc) {
199  auto mod = m_streamModules[id];
200  setupLuminosityBlock(mod, lbp.index());
201 
202  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
203  lb.setConsumer(mod);
204  const EventSetup c{ci,
205  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
206  mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
207  false};
208  mod->beginLuminosityBlock(lb, c);
209  }
210 
211  template <typename T>
213  LuminosityBlockPrincipal const& lbp,
214  EventSetupImpl const& ci,
215  ModuleCallingContext const* mcc) {
216  auto mod = m_streamModules[id];
217  LuminosityBlock lb(lbp, moduleDescription_, mcc, true);
218  lb.setConsumer(mod);
219  const EventSetup c{ci,
220  static_cast<unsigned int>(Transition::EndLuminosityBlock),
221  mod->esGetTokenIndices(Transition::EndLuminosityBlock),
222  false};
223  mod->endLuminosityBlock(lb, c);
224  streamEndLuminosityBlockSummary(mod, lb, c);
225  }
226 
227  template <typename T>
229  template <typename T>
231 
232  template <typename T>
235  assert(not m_streamModules.empty());
236  auto mod = m_streamModules[0];
237  mod->registerThinnedAssociations(registry, helper);
238  }
239  } // namespace stream
240 } // namespace edm
edm::StreamID
Definition: StreamID.h:30
edm::stream::ProducingModuleAdaptorBase::resolvePutIndicies
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
Definition: ProducingModuleAdaptorBase.cc:143
edm::stream::ProducingModuleAdaptorBase::doStreamBeginRun
void doStreamBeginRun(StreamID id, RunPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:167
edm::stream::ProducingModuleAdaptorBase::itemsMayGet
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Definition: ProducingModuleAdaptorBase.cc:91
edm::stream::ProducingModuleAdaptorBase::registerProductsAndCallbacks
void registerProductsAndCallbacks(ProducingModuleAdaptorBase const *, ProductRegistry *reg)
Definition: ProducingModuleAdaptorBase.cc:60
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::stream::ProducingModuleAdaptorBase::itemsToGet
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Definition: ProducingModuleAdaptorBase.cc:84
edm::stream::ProducingModuleAdaptorBase::~ProducingModuleAdaptorBase
virtual ~ProducingModuleAdaptorBase()
Definition: ProducingModuleAdaptorBase.cc:42
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:105
edm::EventSetupImpl
Definition: EventSetupImpl.h:44
callbacks
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those callbacks
Definition: Activities.doc:12
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm::stream::ProducingModuleAdaptorBase::ProducingModuleAdaptorBase
ProducingModuleAdaptorBase()
Definition: ProducingModuleAdaptorBase.cc:39
modules
Definition: ZHLTMatchFilter.cc:17
LuminosityBlock.h
ProducingModuleAdaptorBase.h
edm
HLT enums.
Definition: AlignableModifier.h:19
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:128
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
cms::cuda::assert
assert(be >=bs)
edm::stream::ProducingModuleAdaptorBase::indiciesForPutProducts
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducingModuleAdaptorBase.cc:152
PreallocationConfiguration.h
edm::ProductResolverIndexHelper
Definition: ProductResolverIndexHelper.h:89
edm::BranchType
BranchType
Definition: BranchType.h:11
edm::stream::ProducingModuleAdaptorBase::doRespondToCloseInputFile
void doRespondToCloseInputFile(FileBlock const &fb)
Definition: ProducingModuleAdaptorBase.cc:230
edm::ProductRegistry
Definition: ProductRegistry.h:34
edm::FileBlock
Definition: FileBlock.h:20
edm::PreallocationConfiguration::numberOfLuminosityBlocks
unsigned int numberOfLuminosityBlocks() const
Definition: PreallocationConfiguration.h:36
edm::stream::ProducingModuleAdaptorBase::doBeginStream
void doBeginStream(StreamID id)
Definition: ProducingModuleAdaptorBase.cc:158
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
Run.h
edm::stream::ProducingModuleAdaptorBase::doPreallocate
void doPreallocate(PreallocationConfiguration const &)
Definition: ProducingModuleAdaptorBase.cc:53
edm::Transition::BeginLuminosityBlock
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::RunPrincipal::index
RunIndex index() const
Definition: RunPrincipal.h:57
edm::stream::ProducingModuleAdaptorBase::doEndStream
void doEndStream(StreamID id)
Definition: ProducingModuleAdaptorBase.cc:162
edm::ThinnedAssociationsHelper
Definition: ThinnedAssociationsHelper.h:35
edm::LuminosityBlock::setConsumer
void setConsumer(EDConsumerBase const *iConsumer)
Definition: LuminosityBlock.cc:26
RunPrincipal.h
helper
Definition: helper.py:1
edm::stream::ProducingModuleAdaptorBase< EDProducerBase >::ModuleToResolverIndicies
std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > > ModuleToResolverIndicies
Definition: ProducingModuleAdaptorBase.h:107
edm::EventSetup
Definition: EventSetup.h:57
edm::stream::ProducingModuleAdaptorBase
Definition: Event.h:70
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::stream::ProducingModuleAdaptorBase::doRegisterThinnedAssociations
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
Definition: ProducingModuleAdaptorBase.cc:233
edm::stream::ProducingModuleAdaptorBase::itemsToGetFrom
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) const
Definition: ProducingModuleAdaptorBase.cc:98
LuminosityBlockPrincipal.h
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::PreallocationConfiguration
Definition: PreallocationConfiguration.h:27
edm::Transition::EndLuminosityBlock
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
edm::Transition::BeginRun
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
EventSetup.h
edm::PreallocationConfiguration::numberOfStreams
unsigned int numberOfStreams() const
Definition: PreallocationConfiguration.h:35
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:29
edm::stream::ProducingModuleAdaptorBase::consumesInfo
std::vector< ConsumesInfo > consumesInfo() const
Definition: ProducingModuleAdaptorBase.cc:122
edm::BranchDescription
Definition: BranchDescription.h:32
edm::LuminosityBlockPrincipal::index
LuminosityBlockIndex index() const
Definition: LuminosityBlockPrincipal.h:51
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::Transition::EndRun
edm::stream::ProducingModuleAdaptorBase::doRespondToOpenInputFile
void doRespondToOpenInputFile(FileBlock const &fb)
Definition: ProducingModuleAdaptorBase.cc:228
edm::stream::ProducingModuleAdaptorBase::doStreamBeginLuminosityBlock
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:195
edm::stream::ProducingModuleAdaptorBase::doStreamEndRun
void doStreamEndRun(StreamID id, RunPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:181
edm::stream::ProducingModuleAdaptorBase::doStreamEndLuminosityBlock
void doStreamEndLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:212
edm::stream::ProducingModuleAdaptorBase::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName)
Definition: ProducingModuleAdaptorBase.cc:115
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29