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)};
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{ci, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun)};
192  mod->endRun(r, c);
193  streamEndRunSummary(mod, r, c);
194  }
195 
196  template <typename T>
198  LuminosityBlockPrincipal const& lbp,
199  EventSetupImpl const& ci,
200  ModuleCallingContext const* mcc) {
201  auto mod = m_streamModules[id];
202  setupLuminosityBlock(mod, lbp.index());
203 
204  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
205  lb.setConsumer(mod);
206  const EventSetup c{ci,
207  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
208  mod->esGetTokenIndices(Transition::BeginLuminosityBlock)};
209  mod->beginLuminosityBlock(lb, c);
210  }
211 
212  template <typename T>
214  LuminosityBlockPrincipal const& lbp,
215  EventSetupImpl const& ci,
216  ModuleCallingContext const* mcc) {
217  auto mod = m_streamModules[id];
218  LuminosityBlock lb(lbp, moduleDescription_, mcc, true);
219  lb.setConsumer(mod);
220  const EventSetup c{ci,
221  static_cast<unsigned int>(Transition::EndLuminosityBlock),
222  mod->esGetTokenIndices(Transition::EndLuminosityBlock)};
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
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 *)
static Interceptor::Registry registry("Interceptor")
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