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
26 
27 //
28 // constants, enums and typedefs
29 //
30 
31 //
32 // static data member definitions
33 //
34 
35 //
36 // constructors and destructor
37 //
38 namespace edm {
39  namespace stream {
40  template <typename T>
42 
43  template <typename T>
45  for (auto m : m_streamModules) {
46  delete m;
47  }
48  }
49 
50  //
51  // member functions
52  //
53 
54  template <typename T>
56  m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast<T*>(nullptr));
57  setupStreamModules();
58  preallocLumis(iPrealloc.numberOfLuminosityBlocks());
59  }
60 
61  template <typename T>
63  ProductRegistry* reg) {
64  auto firstMod = m_streamModules[0];
65  if (firstMod->registrationCallback() and m_streamModules.size() > 1) {
66  //we have a callback so we will collect all callbacks and create a new callback which calls them all.
67 
69  callbacks.reserve(m_streamModules.size());
70 
71  for (auto mod : m_streamModules) {
72  callbacks.push_back(mod->registrationCallback());
73  }
74  //Since only the first module will actually do the registration
75  // we will change its callback to call all the callbacks
76  firstMod->callWhenNewProductsRegistered([callbacks](BranchDescription const& iBD) {
77  for (const auto& c : callbacks) {
78  c(iBD);
79  }
80  });
81  }
82  firstMod->registerProducts(firstMod, reg, moduleDescription_);
83  }
84 
85  template <typename T>
87  std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
88  assert(not m_streamModules.empty());
89  m_streamModules[0]->itemsToGet(iType, iIndices);
90  }
91 
92  template <typename T>
94  std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
95  assert(not m_streamModules.empty());
96  m_streamModules[0]->itemsMayGet(iType, iIndices);
97  }
98 
99  template <typename T>
100  std::vector<edm::ProductResolverIndexAndSkipBit> const& ProducingModuleAdaptorBase<T>::itemsToGetFrom(
101  BranchType iType) const {
102  assert(not m_streamModules.empty());
103  return m_streamModules[0]->itemsToGetFrom(iType);
104  }
105 
106  template <typename T>
108  edm::Transition iTrans) const {
109  assert(not m_streamModules.empty());
110  return m_streamModules[0]->esGetTokenIndicesVector(iTrans);
111  }
112 
113  template <typename T>
115  edm::Transition iTrans) const {
116  assert(not m_streamModules.empty());
117  return m_streamModules[0]->esGetTokenRecordIndicesVector(iTrans);
118  }
119 
120  template <typename T>
122  std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
123  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
124  ProductRegistry const& preg,
125  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
126  std::string const& processName) const {
127  assert(not m_streamModules.empty());
128  return m_streamModules[0]->modulesWhoseProductsAreConsumed(
129  modules, modulesInPreviousProcesses, preg, labelsToDesc, processName);
130  }
131 
132  template <typename T>
134  for (auto mod : m_streamModules) {
135  mod->convertCurrentProcessAlias(processName);
136  }
137  }
138 
139  template <typename T>
140  std::vector<edm::ConsumesInfo> ProducingModuleAdaptorBase<T>::consumesInfo() const {
141  assert(not m_streamModules.empty());
142  return m_streamModules[0]->consumesInfo();
143  }
144 
145  template <typename T>
147  ProductResolverIndexHelper const& iHelper,
148  bool iPrefetchMayGet) {
149  for (auto mod : m_streamModules) {
150  mod->updateLookup(iType, iHelper, iPrefetchMayGet);
151  }
152  }
153  template <typename T>
155  for (auto mod : m_streamModules) {
156  mod->updateLookup(iPI);
157  }
158  }
159 
160  template <typename T>
162  ModuleToResolverIndicies const& iIndicies,
163  std::string const& moduleLabel) {
164  for (auto mod : m_streamModules) {
165  mod->resolvePutIndicies(iBranchType, iIndicies, moduleLabel);
166  }
167  }
168 
169  template <typename T>
170  std::vector<edm::ProductResolverIndex> const& ProducingModuleAdaptorBase<T>::indiciesForPutProducts(
171  BranchType iBranchType) const {
172  return m_streamModules[0]->indiciesForPutProducts(iBranchType);
173  }
174 
175  template <typename T>
177  m_streamModules[id]->beginStream(id);
178  }
179  template <typename T>
181  m_streamModules[id]->endStream();
182  }
183 
184  template <typename T>
186  RunTransitionInfo const& info,
187  ModuleCallingContext const* mcc) {
188  RunPrincipal const& rp = info.principal();
189  auto mod = m_streamModules[id];
190  setupRun(mod, rp.index());
191 
192  Run r(rp, moduleDescription_, mcc, false);
193  r.setConsumer(mod);
194  ESParentContext parentC(mcc);
195  const EventSetup c{info,
196  static_cast<unsigned int>(Transition::BeginRun),
197  mod->esGetTokenIndices(Transition::BeginRun),
198  parentC,
199  false};
200  mod->beginRun(r, c);
201  }
202 
203  template <typename T>
205  RunTransitionInfo const& info,
206  ModuleCallingContext const* mcc) {
207  auto mod = m_streamModules[id];
208  Run r(info, moduleDescription_, mcc, true);
209  r.setConsumer(mod);
210  ESParentContext parentC(mcc);
211  const EventSetup c{info,
212  static_cast<unsigned int>(Transition::EndRun),
213  mod->esGetTokenIndices(Transition::EndRun),
214  parentC,
215  false};
216  mod->endRun(r, c);
217  streamEndRunSummary(mod, r, c);
218  }
219 
220  template <typename T>
222  LumiTransitionInfo const& info,
223  ModuleCallingContext const* mcc) {
224  LuminosityBlockPrincipal const& lbp = info.principal();
225  auto mod = m_streamModules[id];
226  setupLuminosityBlock(mod, lbp.index());
227 
228  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
229  lb.setConsumer(mod);
230  ESParentContext parentC(mcc);
231  const EventSetup c{info,
232  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
233  mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
234  parentC,
235  false};
236  mod->beginLuminosityBlock(lb, c);
237  }
238 
239  template <typename T>
241  LumiTransitionInfo const& info,
242  ModuleCallingContext const* mcc) {
243  auto mod = m_streamModules[id];
244  LuminosityBlock lb(info, moduleDescription_, mcc, true);
245  lb.setConsumer(mod);
246  ESParentContext parentC(mcc);
247  const EventSetup c{info,
248  static_cast<unsigned int>(Transition::EndLuminosityBlock),
249  mod->esGetTokenIndices(Transition::EndLuminosityBlock),
250  parentC,
251  false};
252  mod->endLuminosityBlock(lb, c);
253  streamEndLuminosityBlockSummary(mod, lb, c);
254  }
255 
256  template <typename T>
258  template <typename T>
260 
261  template <typename T>
264  assert(not m_streamModules.empty());
265  auto mod = m_streamModules[0];
266  mod->registerThinnedAssociations(registry, helper);
267  }
268  } // namespace stream
269 } // 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:161
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::LumiTransitionInfo
Definition: TransitionInfoTypes.h:42
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:41
modules
Definition: MuonCleanerBySegments.cc:35
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:146
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)
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
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
PreallocationConfiguration.h
edm::ProductResolverIndexHelper
Definition: ProductResolverIndexHelper.h:89
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
edm::BranchType
BranchType
Definition: BranchType.h:11
edm::NumBranchTypes
Definition: BranchType.h:11
edm::stream::ProducingModuleAdaptorBase::doRespondToCloseInputFile
void doRespondToCloseInputFile(FileBlock const &fb)
Definition: ProducingModuleAdaptorBase.cc:259
edm::ProductRegistry
Definition: ProductRegistry.h:37
edm::FileBlock
Definition: FileBlock.h:20
edm::PreallocationConfiguration::numberOfLuminosityBlocks
unsigned int numberOfLuminosityBlocks() const
Definition: PreallocationConfiguration.h:36
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:55
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::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::Transition
Transition
Definition: Transition.h:12
ESParentContext.h
edm::LuminosityBlock::setConsumer
void setConsumer(EDConsumerBase const *iConsumer)
Definition: LuminosityBlock.cc:34
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:117
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::ProducingModuleAdaptorBase::esGetTokenIndicesVector
std::vector< ESProxyIndex > const & esGetTokenIndicesVector(edm::Transition iTrans) const
Definition: ProducingModuleAdaptorBase.cc:107
edm::EventSetup
Definition: EventSetup.h:58
edm::ESParentContext
Definition: ESParentContext.h:21
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
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
edm::stream::ProducingModuleAdaptorBase::doStreamEndLuminosityBlock
void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:240
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
edm::Transition::BeginRun
edm::stream::ProducingModuleAdaptorBase::doStreamBeginLuminosityBlock
void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
Definition: ProducingModuleAdaptorBase.cc:221
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
EventSetup.h
edm::stream::ProducingModuleAdaptorBase::doEndStream
void doEndStream(StreamID)
Definition: ProducingModuleAdaptorBase.cc:180
edm::PreallocationConfiguration::numberOfStreams
unsigned int numberOfStreams() const
Definition: PreallocationConfiguration.h:35
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
edm::stream::ProducingModuleAdaptorBase::consumesInfo
std::vector< ConsumesInfo > consumesInfo() const
Definition: ProducingModuleAdaptorBase.cc:140
edm::BranchDescription
Definition: BranchDescription.h:32
TransitionInfoTypes.h
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
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
edm::stream::ProducingModuleAdaptorBase::doBeginStream
void doBeginStream(StreamID)
Definition: ProducingModuleAdaptorBase.cc:176
edm::Transition::EndRun
edm::stream::ProducingModuleAdaptorBase::doRespondToOpenInputFile
void doRespondToOpenInputFile(FileBlock const &fb)
Definition: ProducingModuleAdaptorBase.cc:257
edm::stream::ProducingModuleAdaptorBase::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName)
Definition: ProducingModuleAdaptorBase.cc:133
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29