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 
160  template <typename T>
162  m_streamModules[id]->beginStream(id);
163  }
164  template <typename T>
166  m_streamModules[id]->endStream();
167  }
168 
169  template <typename T>
171  RunPrincipal const& rp,
172  EventSetupImpl const& ci,
173  ModuleCallingContext const* mcc) {
174  auto mod = m_streamModules[id];
175  setupRun(mod, rp.index());
176 
177  Run r(rp, moduleDescription_, mcc, false);
178  r.setConsumer(mod);
179  const EventSetup c{
180  ci, static_cast<unsigned int>(Transition::BeginRun), mod->esGetTokenIndices(Transition::BeginRun), false};
181  mod->beginRun(r, c);
182  }
183  template <typename T>
185  RunPrincipal const& rp,
186  EventSetupImpl const& ci,
187  ModuleCallingContext const* mcc) {
188  auto mod = m_streamModules[id];
189  Run r(rp, moduleDescription_, mcc, true);
190  r.setConsumer(mod);
191  const EventSetup c{
192  ci, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun), false};
193  mod->endRun(r, c);
194  streamEndRunSummary(mod, r, c);
195  }
196 
197  template <typename T>
199  LuminosityBlockPrincipal const& lbp,
200  EventSetupImpl const& ci,
201  ModuleCallingContext const* mcc) {
202  auto mod = m_streamModules[id];
203  setupLuminosityBlock(mod, lbp.index());
204 
205  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
206  lb.setConsumer(mod);
207  const EventSetup c{ci,
208  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
209  mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
210  false};
211  mod->beginLuminosityBlock(lb, c);
212  }
213 
214  template <typename T>
216  LuminosityBlockPrincipal const& lbp,
217  EventSetupImpl const& ci,
218  ModuleCallingContext const* mcc) {
219  auto mod = m_streamModules[id];
220  LuminosityBlock lb(lbp, moduleDescription_, mcc, true);
221  lb.setConsumer(mod);
222  const EventSetup c{ci,
223  static_cast<unsigned int>(Transition::EndLuminosityBlock),
224  mod->esGetTokenIndices(Transition::EndLuminosityBlock),
225  false};
226  mod->endLuminosityBlock(lb, c);
227  streamEndLuminosityBlockSummary(mod, lb, c);
228  }
229 
230  template <typename T>
232  template <typename T>
234 
235  template <typename T>
238  assert(not m_streamModules.empty());
239  auto mod = m_streamModules[0];
240  mod->registerThinnedAssociations(registry, helper);
241  }
242  } // namespace stream
243 } // namespace edm
void doStreamEndRun(StreamID id, RunPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
void setConsumer(EDConsumerBase const *iConsumer)
std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >> ModuleToResolverIndicies
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
Definition: helper.py:1
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
LuminosityBlockIndex index() const
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) const
void doPreallocate(PreallocationConfiguration const &)
BranchType
Definition: BranchType.h:11
std::vector< ConsumesInfo > consumesInfo() const
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
void registerProductsAndCallbacks(ProducingModuleAdaptorBase const *, ProductRegistry *reg)
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
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
void convertCurrentProcessAlias(std::string const &processName)
void doStreamBeginRun(StreamID id, RunPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
RunIndex index() const
Definition: RunPrincipal.h:56
void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
HLT enums.
void doStreamEndLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:51
Definition: Run.h:45