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 <array>
15 #include <cassert>
16 
17 // user include files
28 
29 //
30 // constants, enums and typedefs
31 //
32 
33 //
34 // static data member definitions
35 //
36 
37 //
38 // constructors and destructor
39 //
40 namespace edm {
41  namespace stream {
42  template <typename T>
44 
45  template <typename T>
47  for (auto m : m_streamModules) {
48  delete m;
49  }
50  }
51 
52  template <typename T>
54  for (auto m : m_streamModules) {
55  delete m;
56  }
57  m_streamModules.clear();
58  }
59 
60  //
61  // member functions
62  //
63 
64  template <typename T>
66  m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast<T*>(nullptr));
67  setupStreamModules();
68  preallocRuns(iPrealloc.numberOfRuns());
69  preallocLumis(iPrealloc.numberOfLuminosityBlocks());
70  }
71 
72  template <typename T>
74  ProductRegistry* reg) {
75  auto firstMod = m_streamModules[0];
76  if (firstMod->registrationCallback() and m_streamModules.size() > 1) {
77  //we have a callback so we will collect all callbacks and create a new callback which calls them all.
78 
79  std::vector<std::function<void(BranchDescription const&)>> callbacks;
80  callbacks.reserve(m_streamModules.size());
81 
82  for (auto mod : m_streamModules) {
83  callbacks.push_back(mod->registrationCallback());
84  }
85  //Since only the first module will actually do the registration
86  // we will change its callback to call all the callbacks
87  firstMod->callWhenNewProductsRegistered([callbacks](BranchDescription const& iBD) {
88  for (const auto& c : callbacks) {
89  c(iBD);
90  }
91  });
92  }
93  firstMod->registerProducts(firstMod, reg, moduleDescription_);
94  }
95 
96  template <typename T>
98  std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
99  assert(not m_streamModules.empty());
100  m_streamModules[0]->itemsToGet(iType, iIndices);
101  }
102 
103  template <typename T>
105  std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
106  assert(not m_streamModules.empty());
107  m_streamModules[0]->itemsMayGet(iType, iIndices);
108  }
109 
110  template <typename T>
111  std::vector<edm::ProductResolverIndexAndSkipBit> const& ProducingModuleAdaptorBase<T>::itemsToGetFrom(
112  BranchType iType) const {
113  assert(not m_streamModules.empty());
114  return m_streamModules[0]->itemsToGetFrom(iType);
115  }
116 
117  template <typename T>
118  std::vector<ESResolverIndex> const& ProducingModuleAdaptorBase<T>::esGetTokenIndicesVector(
119  edm::Transition iTrans) const {
120  assert(not m_streamModules.empty());
121  return m_streamModules[0]->esGetTokenIndicesVector(iTrans);
122  }
123 
124  template <typename T>
126  edm::Transition iTrans) const {
127  assert(not m_streamModules.empty());
128  return m_streamModules[0]->esGetTokenRecordIndicesVector(iTrans);
129  }
130 
131  template <typename T>
133  std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
134  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
135  ProductRegistry const& preg,
136  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
137  std::string const& processName) const {
138  assert(not m_streamModules.empty());
139  return m_streamModules[0]->modulesWhoseProductsAreConsumed(
140  modules, modulesInPreviousProcesses, preg, labelsToDesc, processName);
141  }
142 
143  template <typename T>
145  for (auto mod : m_streamModules) {
146  mod->convertCurrentProcessAlias(processName);
147  }
148  }
149 
150  template <typename T>
151  std::vector<edm::ConsumesInfo> ProducingModuleAdaptorBase<T>::consumesInfo() const {
152  assert(not m_streamModules.empty());
153  return m_streamModules[0]->consumesInfo();
154  }
155 
156  template <typename T>
158  ProductResolverIndexHelper const& iHelper,
159  bool iPrefetchMayGet) {
160  for (auto mod : m_streamModules) {
161  mod->updateLookup(iType, iHelper, iPrefetchMayGet);
162  }
163  }
164  template <typename T>
166  for (auto mod : m_streamModules) {
167  mod->updateLookup(iPI);
168  }
169  }
170 
171  template <typename T>
173  ModuleToResolverIndicies const& iIndicies,
174  std::string const& moduleLabel) {
175  for (auto mod : m_streamModules) {
176  mod->resolvePutIndicies(iBranchType, iIndicies, moduleLabel);
177  }
178  }
179 
180  template <typename T>
181  std::vector<edm::ProductResolverIndex> const& ProducingModuleAdaptorBase<T>::indiciesForPutProducts(
182  BranchType iBranchType) const {
183  return m_streamModules[0]->indiciesForPutProducts(iBranchType);
184  }
185 
186  template <typename T>
188  return 0;
189  }
190  template <typename T>
192  return 0;
193  }
194  template <typename T>
196  size_t iTransformIndex,
197  EventPrincipal const& iEvent,
199  ModuleCallingContext const* iMCC,
200  ServiceWeakToken const&) {}
201 
202  template <typename T>
204  m_streamModules[id]->beginStream(id);
205  }
206  template <typename T>
208  m_streamModules[id]->endStream();
209  }
210 
211  template <typename T>
213  RunTransitionInfo const& info,
214  ModuleCallingContext const* mcc) {
215  RunPrincipal const& rp = info.principal();
216  auto mod = m_streamModules[id];
217  setupRun(mod, rp.index());
218 
219  Run r(rp, moduleDescription_, mcc, false);
220  r.setConsumer(mod);
221  ESParentContext parentC(mcc);
222  const EventSetup c{
223  info, static_cast<unsigned int>(Transition::BeginRun), mod->esGetTokenIndices(Transition::BeginRun), parentC};
224  mod->beginRun(r, c);
225  }
226 
227  template <typename T>
229  RunTransitionInfo const& info,
230  ModuleCallingContext const* mcc) {
231  auto mod = m_streamModules[id];
232  Run r(info, moduleDescription_, mcc, true);
233  r.setConsumer(mod);
234  ESParentContext parentC(mcc);
235  const EventSetup c{
236  info, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun), parentC};
237  mod->endRun(r, c);
238  streamEndRunSummary(mod, r, c);
239  }
240 
241  template <typename T>
243  LumiTransitionInfo const& info,
244  ModuleCallingContext const* mcc) {
245  LuminosityBlockPrincipal const& lbp = info.principal();
246  auto mod = m_streamModules[id];
247  setupLuminosityBlock(mod, lbp.index());
248 
249  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
250  lb.setConsumer(mod);
251  ESParentContext parentC(mcc);
252  const EventSetup c{info,
253  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
254  mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
255  parentC};
256  mod->beginLuminosityBlock(lb, c);
257  }
258 
259  template <typename T>
261  LumiTransitionInfo const& info,
262  ModuleCallingContext const* mcc) {
263  auto mod = m_streamModules[id];
264  LuminosityBlock lb(info, moduleDescription_, mcc, true);
265  lb.setConsumer(mod);
266  ESParentContext parentC(mcc);
267  const EventSetup c{info,
268  static_cast<unsigned int>(Transition::EndLuminosityBlock),
269  mod->esGetTokenIndices(Transition::EndLuminosityBlock),
270  parentC};
271  mod->endLuminosityBlock(lb, c);
272  streamEndLuminosityBlockSummary(mod, lb, c);
273  }
274 
275  template <typename T>
278  assert(not m_streamModules.empty());
279  auto mod = m_streamModules[0];
280  mod->registerThinnedAssociations(registry, helper);
281  }
282  } // namespace stream
283 } // namespace edm
void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
static const TGPicture * info(bool iBackgroundIsBlack)
void setConsumer(EDConsumerBase const *iConsumer)
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) const
Definition: helper.py:1
unsigned int ProductResolverIndex
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector(edm::Transition iTrans) const
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
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
assert(be >=bs)
void doPreallocate(PreallocationConfiguration const &)
BranchType
Definition: BranchType.h:11
int iEvent
Definition: GenABIO.cc:224
void doTransformAsync(WaitingTaskHolder iTask, size_t iTransformIndex, EventPrincipal const &iEvent, ActivityRegistry *, ModuleCallingContext const *, ServiceWeakToken const &)
size_t transformIndex_(edm::BranchDescription const &iBranch) const
void registerProductsAndCallbacks(ProducingModuleAdaptorBase const *, ProductRegistry *reg)
void doStreamBeginRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Transition
Definition: Transition.h:12
RunIndex index() const
Definition: RunPrincipal.h:56
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
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
void convertCurrentProcessAlias(std::string const &processName)
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
ProductResolverIndex transformPrefetch_(size_t iTransformIndex) const
HLT enums.
LuminosityBlockIndex index() const
std::vector< ConsumesInfo > consumesInfo() const
void doStreamEndRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > > ModuleToResolverIndicies
void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
Definition: Run.h:45
std::vector< ESResolverIndex > const & esGetTokenIndicesVector(edm::Transition iTrans) const