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
23 
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructors and destructor
34 //
35 namespace edm {
36  namespace stream {
37  template< typename T>
39  {
40  }
41 
42  template< typename T>
44  {
45  for(auto m: m_streamModules) {
46  delete m;
47  }
48  }
49 
50  //
51  // member functions
52  //
53 
54  template< typename T>
55  void
57  m_streamModules.resize(iPrealloc.numberOfStreams(),
58  static_cast<T*>(nullptr));
59  setupStreamModules();
60  preallocLumis(iPrealloc.numberOfLuminosityBlocks());
61  }
62 
63 
64  template< typename T>
65  void
67  auto firstMod = m_streamModules[0];
68  if(firstMod->registrationCallback() and m_streamModules.size()>1) {
69  //we have a callback so we will collect all callbacks and create a new callback which calls them all.
70 
71  std::vector<std::function<void(BranchDescription const&)>> callbacks;
72  callbacks.reserve(m_streamModules.size());
73 
74  for(auto mod: m_streamModules) {
75  callbacks.push_back(mod->registrationCallback());
76  }
77  //Since only the first module will actually do the registration
78  // we will change its callback to call all the callbacks
79  firstMod->callWhenNewProductsRegistered([callbacks](BranchDescription const& iBD) {
80  for(auto c: callbacks) {
81  c(iBD);
82  }
83  });
84  }
85  firstMod->registerProducts(firstMod,reg,moduleDescription_);
86  }
87 
88  template< typename T>
89  void
90  ProducingModuleAdaptorBase<T>::itemsToGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
91  assert(not m_streamModules.empty());
92  m_streamModules[0]->itemsToGet(iType,iIndices);
93  }
94 
95  template< typename T>
96  void
97  ProducingModuleAdaptorBase<T>::itemsMayGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
98  assert(not m_streamModules.empty());
99  m_streamModules[0]->itemsMayGet(iType,iIndices);
100  }
101 
102  template<typename T>
103  std::vector<edm::ProductResolverIndexAndSkipBit> const&
105  assert(not m_streamModules.empty());
106  return m_streamModules[0]->itemsToGetFrom(iType);
107  }
108 
109  template< typename T>
110  void
112  ProductRegistry const& preg,
113  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
114  std::string const& processName) const {
115  assert(not m_streamModules.empty());
116  return m_streamModules[0]->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, processName);
117  }
118 
119  template< typename T>
120  void
122  for(auto mod: m_streamModules) {
123  mod->convertCurrentProcessAlias(processName);
124  }
125  }
126 
127  template< typename T>
128  std::vector<edm::ConsumesInfo>
130  assert(not m_streamModules.empty());
131  return m_streamModules[0]->consumesInfo();
132  }
133 
134  template< typename T>
135  void
137  ProductResolverIndexHelper const& iHelper,
138  bool iPrefetchMayGet) {
139  for(auto mod: m_streamModules) {
140  mod->updateLookup(iType,iHelper,iPrefetchMayGet);
141  }
142  }
143 
144  template< typename T>
145  void
147  ModuleToResolverIndicies const& iIndicies,
148  std::string const& moduleLabel) {
149  for(auto mod: m_streamModules) {
150  mod->resolvePutIndicies(iBranchType,iIndicies,moduleLabel);
151  }
152  }
153 
154 
155  template< typename T>
156  std::vector<edm::ProductResolverIndex> const&
158  return m_streamModules[0]->indiciesForPutProducts(iBranchType);
159  }
160 
161  template< typename T>
162  void
164 
165  }
166 
167  template< typename T>
168  void
170  m_streamModules[id]->beginStream(id);
171  }
172  template< typename T>
173  void
175  m_streamModules[id]->endStream();
176  }
177 
178  template< typename T>
179  void
181  RunPrincipal const& rp,
182  EventSetup const& c,
183  ModuleCallingContext const* mcc)
184  {
185  auto mod = m_streamModules[id];
186  setupRun(mod, rp.index());
187 
188  Run r(rp, moduleDescription_, mcc, false);
189  r.setConsumer(mod);
190  mod->beginRun(r, c);
191 
192  }
193  template< typename T>
194  void
196  RunPrincipal const& rp,
197  EventSetup const& c,
198  ModuleCallingContext const* mcc)
199  {
200  auto mod = m_streamModules[id];
201  Run r(rp, moduleDescription_, mcc, true);
202  r.setConsumer(mod);
203  mod->endRun(r, c);
204  streamEndRunSummary(mod,r,c);
205  }
206 
207  template< typename T>
208  void
210  LuminosityBlockPrincipal const& lbp,
211  EventSetup const& c,
212  ModuleCallingContext const* mcc) {
213  auto mod = m_streamModules[id];
214  setupLuminosityBlock(mod,lbp.index());
215 
216  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
217  lb.setConsumer(mod);
218  mod->beginLuminosityBlock(lb, c);
219  }
220 
221  template< typename T>
222  void
224  LuminosityBlockPrincipal const& lbp,
225  EventSetup const& c,
226  ModuleCallingContext const* mcc)
227  {
228  auto mod = m_streamModules[id];
229  LuminosityBlock lb(lbp, moduleDescription_, mcc, true);
230  lb.setConsumer(mod);
231  mod->endLuminosityBlock(lb, c);
232  streamEndLuminosityBlockSummary(mod,lb, c);
233  }
234 
235  template< typename T>
236  void
238  template< typename T>
239  void
241 
242  template< typename T>
243  void
246  assert(not m_streamModules.empty());
247  auto mod = m_streamModules[0];
248  mod->registerThinnedAssociations(registry, helper);
249  }
250  }
251 }
void doStreamBeginRun(StreamID id, RunPrincipal const &ep, EventSetup 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
void doStreamEndLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetup const &c, ModuleCallingContext 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 doStreamEndRun(StreamID id, RunPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
void convertCurrentProcessAlias(std::string const &processName)
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
RunIndex index() const
Definition: RunPrincipal.h:53
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.
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:50
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
Definition: Run.h:43