CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  template <typename T>
52  for (auto m : m_streamModules) {
53  delete m;
54  }
55  m_streamModules.clear();
56  }
57 
58  //
59  // member functions
60  //
61 
62  template <typename T>
64  m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast<T*>(nullptr));
65  setupStreamModules();
66  preallocLumis(iPrealloc.numberOfLuminosityBlocks());
67  }
68 
69  template <typename T>
71  ProductRegistry* reg) {
72  auto firstMod = m_streamModules[0];
73  if (firstMod->registrationCallback() and m_streamModules.size() > 1) {
74  //we have a callback so we will collect all callbacks and create a new callback which calls them all.
75 
76  std::vector<std::function<void(BranchDescription const&)>> callbacks;
77  callbacks.reserve(m_streamModules.size());
78 
79  for (auto mod : m_streamModules) {
80  callbacks.push_back(mod->registrationCallback());
81  }
82  //Since only the first module will actually do the registration
83  // we will change its callback to call all the callbacks
84  firstMod->callWhenNewProductsRegistered([callbacks](BranchDescription const& iBD) {
85  for (const auto& c : callbacks) {
86  c(iBD);
87  }
88  });
89  }
90  firstMod->registerProducts(firstMod, reg, moduleDescription_);
91  }
92 
93  template <typename T>
95  std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
96  assert(not m_streamModules.empty());
97  m_streamModules[0]->itemsToGet(iType, iIndices);
98  }
99 
100  template <typename T>
102  std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
103  assert(not m_streamModules.empty());
104  m_streamModules[0]->itemsMayGet(iType, iIndices);
105  }
106 
107  template <typename T>
108  std::vector<edm::ProductResolverIndexAndSkipBit> const& ProducingModuleAdaptorBase<T>::itemsToGetFrom(
109  BranchType iType) const {
110  assert(not m_streamModules.empty());
111  return m_streamModules[0]->itemsToGetFrom(iType);
112  }
113 
114  template <typename T>
116  edm::Transition iTrans) const {
117  assert(not m_streamModules.empty());
118  return m_streamModules[0]->esGetTokenIndicesVector(iTrans);
119  }
120 
121  template <typename T>
123  edm::Transition iTrans) const {
124  assert(not m_streamModules.empty());
125  return m_streamModules[0]->esGetTokenRecordIndicesVector(iTrans);
126  }
127 
128  template <typename T>
130  std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
131  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
132  ProductRegistry const& preg,
133  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
134  std::string const& processName) const {
135  assert(not m_streamModules.empty());
136  return m_streamModules[0]->modulesWhoseProductsAreConsumed(
137  modules, modulesInPreviousProcesses, preg, labelsToDesc, processName);
138  }
139 
140  template <typename T>
142  for (auto mod : m_streamModules) {
143  mod->convertCurrentProcessAlias(processName);
144  }
145  }
146 
147  template <typename T>
148  std::vector<edm::ConsumesInfo> ProducingModuleAdaptorBase<T>::consumesInfo() const {
149  assert(not m_streamModules.empty());
150  return m_streamModules[0]->consumesInfo();
151  }
152 
153  template <typename T>
155  ProductResolverIndexHelper const& iHelper,
156  bool iPrefetchMayGet) {
157  for (auto mod : m_streamModules) {
158  mod->updateLookup(iType, iHelper, iPrefetchMayGet);
159  }
160  }
161  template <typename T>
163  for (auto mod : m_streamModules) {
164  mod->updateLookup(iPI);
165  }
166  }
167 
168  template <typename T>
170  ModuleToResolverIndicies const& iIndicies,
171  std::string const& moduleLabel) {
172  for (auto mod : m_streamModules) {
173  mod->resolvePutIndicies(iBranchType, iIndicies, moduleLabel);
174  }
175  }
176 
177  template <typename T>
178  std::vector<edm::ProductResolverIndex> const& ProducingModuleAdaptorBase<T>::indiciesForPutProducts(
179  BranchType iBranchType) const {
180  return m_streamModules[0]->indiciesForPutProducts(iBranchType);
181  }
182 
183  template <typename T>
185  m_streamModules[id]->beginStream(id);
186  }
187  template <typename T>
189  m_streamModules[id]->endStream();
190  }
191 
192  template <typename T>
194  RunTransitionInfo const& info,
195  ModuleCallingContext const* mcc) {
196  RunPrincipal const& rp = info.principal();
197  auto mod = m_streamModules[id];
198  setupRun(mod, rp.index());
199 
200  Run r(rp, moduleDescription_, mcc, false);
201  r.setConsumer(mod);
202  ESParentContext parentC(mcc);
203  const EventSetup c{info,
204  static_cast<unsigned int>(Transition::BeginRun),
205  mod->esGetTokenIndices(Transition::BeginRun),
206  parentC,
207  false};
208  mod->beginRun(r, c);
209  }
210 
211  template <typename T>
213  RunTransitionInfo const& info,
214  ModuleCallingContext const* mcc) {
215  auto mod = m_streamModules[id];
216  Run r(info, moduleDescription_, mcc, true);
217  r.setConsumer(mod);
218  ESParentContext parentC(mcc);
219  const EventSetup c{info,
220  static_cast<unsigned int>(Transition::EndRun),
221  mod->esGetTokenIndices(Transition::EndRun),
222  parentC,
223  false};
224  mod->endRun(r, c);
225  streamEndRunSummary(mod, r, c);
226  }
227 
228  template <typename T>
230  LumiTransitionInfo const& info,
231  ModuleCallingContext const* mcc) {
232  LuminosityBlockPrincipal const& lbp = info.principal();
233  auto mod = m_streamModules[id];
234  setupLuminosityBlock(mod, lbp.index());
235 
236  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
237  lb.setConsumer(mod);
238  ESParentContext parentC(mcc);
239  const EventSetup c{info,
240  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
241  mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
242  parentC,
243  false};
244  mod->beginLuminosityBlock(lb, c);
245  }
246 
247  template <typename T>
249  LumiTransitionInfo const& info,
250  ModuleCallingContext const* mcc) {
251  auto mod = m_streamModules[id];
252  LuminosityBlock lb(info, moduleDescription_, mcc, true);
253  lb.setConsumer(mod);
254  ESParentContext parentC(mcc);
255  const EventSetup c{info,
256  static_cast<unsigned int>(Transition::EndLuminosityBlock),
257  mod->esGetTokenIndices(Transition::EndLuminosityBlock),
258  parentC,
259  false};
260  mod->endLuminosityBlock(lb, c);
261  streamEndLuminosityBlockSummary(mod, lb, c);
262  }
263 
264  template <typename T>
266  ThinnedAssociationsHelper& helper) {
267  assert(not m_streamModules.empty());
268  auto mod = m_streamModules[0];
269  mod->registerThinnedAssociations(registry, helper);
270  }
271  } // namespace stream
272 } // namespace edm
void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
tuple array
Definition: mps_check.py:216
static const TGPicture * info(bool iBackgroundIsBlack)
void setConsumer(EDConsumerBase const *iConsumer)
const edm::EventSetup & c
std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >> ModuleToResolverIndicies
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
uint16_t *__restrict__ id
LuminosityBlockPrincipal & principal()
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
LuminosityBlockIndex index() const
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) 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
std::vector< ConsumesInfo > consumesInfo() const
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::EventIDconst &, edm::Timestampconst & > 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 registerProductsAndCallbacks(ProducingModuleAdaptorBase const *, ProductRegistry *reg)
void doStreamBeginRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
std::vector< ESProxyIndex > const & esGetTokenIndicesVector(edm::Transition iTrans) const
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
Transition
Definition: Transition.h:12
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector(edm::Transition iTrans) const
void convertCurrentProcessAlias(std::string const &processName)
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
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
RunIndex index() const
Definition: RunPrincipal.h:57
void doStreamEndRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
preg
Definition: Schedule.cc:687
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:52
RunPrincipal & principal()
void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
Definition: Run.h:45