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  }
61 
62  template< typename T>
63  void
65  auto firstMod = m_streamModules[0];
66  if(firstMod->registrationCallback() and m_streamModules.size()>1) {
67  //we have a callback so we will collect all callbacks and create a new callback which calls them all.
68 
69  std::vector<std::function<void(BranchDescription const&)>> callbacks;
70  callbacks.reserve(m_streamModules.size());
71 
72  for(auto mod: m_streamModules) {
73  callbacks.push_back(mod->registrationCallback());
74  }
75  //Since only the first module will actually do the registration
76  // we will change its callback to call all the callbacks
77  firstMod->callWhenNewProductsRegistered([callbacks](BranchDescription const& iBD) {
78  for(auto c: callbacks) {
79  c(iBD);
80  }
81  });
82  }
83  firstMod->registerProducts(firstMod,reg,moduleDescription_);
84  }
85 
86  template< typename T>
87  void
88  ProducingModuleAdaptorBase<T>::itemsToGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
89  assert(not m_streamModules.empty());
90  m_streamModules[0]->itemsToGet(iType,iIndices);
91  }
92 
93  template< typename T>
94  void
95  ProducingModuleAdaptorBase<T>::itemsMayGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
96  assert(not m_streamModules.empty());
97  m_streamModules[0]->itemsMayGet(iType,iIndices);
98  }
99 
100  template<typename T>
101  std::vector<edm::ProductResolverIndexAndSkipBit> const&
103  assert(not m_streamModules.empty());
104  return m_streamModules[0]->itemsToGetFrom(iType);
105  }
106 
107  template< typename T>
108  void
110  ProductRegistry const& preg,
111  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
112  std::string const& processName) const {
113  assert(not m_streamModules.empty());
114  return m_streamModules[0]->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, processName);
115  }
116 
117  template< typename T>
118  void
120  for(auto mod: m_streamModules) {
121  mod->convertCurrentProcessAlias(processName);
122  }
123  }
124 
125  template< typename T>
126  std::vector<edm::ConsumesInfo>
128  assert(not m_streamModules.empty());
129  return m_streamModules[0]->consumesInfo();
130  }
131 
132  template< typename T>
133  void
135  ProductResolverIndexHelper const& iHelper,
136  bool iPrefetchMayGet) {
137  for(auto mod: m_streamModules) {
138  mod->updateLookup(iType,iHelper,iPrefetchMayGet);
139  }
140  }
141 
142  template< typename T>
143  void
145  ModuleToResolverIndicies const& iIndicies,
146  std::string const& moduleLabel) {
147  for(auto mod: m_streamModules) {
148  mod->resolvePutIndicies(iBranchType,iIndicies,moduleLabel);
149  }
150  }
151 
152 
153  template< typename T>
154  std::vector<edm::ProductResolverIndex> const&
156  return m_streamModules[0]->indiciesForPutProducts(iBranchType);
157  }
158 
159  template< typename T>
160  void
162 
163  }
164 
165  template< typename T>
166  void
168  m_streamModules[id]->beginStream(id);
169  }
170  template< typename T>
171  void
173  m_streamModules[id]->endStream();
174  }
175 
176  template< typename T>
177  void
179  RunPrincipal const& rp,
180  EventSetup const& c,
181  ModuleCallingContext const* mcc)
182  {
183  auto mod = m_streamModules[id];
184  setupRun(mod, rp.index());
185 
186  Run r(rp, moduleDescription_, mcc);
187  r.setConsumer(mod);
188  mod->beginRun(r, c);
189 
190  }
191  template< typename T>
192  void
194  RunPrincipal const& rp,
195  EventSetup const& c,
196  ModuleCallingContext const* mcc)
197  {
198  auto mod = m_streamModules[id];
199  Run r(rp, moduleDescription_, mcc);
200  r.setConsumer(mod);
201  mod->endRun(r, c);
202  streamEndRunSummary(mod,r,c);
203  }
204 
205  template< typename T>
206  void
208  LuminosityBlockPrincipal const& lbp,
209  EventSetup const& c,
210  ModuleCallingContext const* mcc) {
211  auto mod = m_streamModules[id];
212  setupLuminosityBlock(mod,lbp.index());
213 
214  LuminosityBlock lb(lbp, moduleDescription_, mcc);
215  lb.setConsumer(mod);
216  mod->beginLuminosityBlock(lb, c);
217  }
218 
219  template< typename T>
220  void
222  LuminosityBlockPrincipal const& lbp,
223  EventSetup const& c,
224  ModuleCallingContext const* mcc)
225  {
226  auto mod = m_streamModules[id];
227  LuminosityBlock lb(lbp, moduleDescription_, mcc);
228  lb.setConsumer(mod);
229  mod->endLuminosityBlock(lb, c);
230  streamEndLuminosityBlockSummary(mod,lb, c);
231  }
232 
233  template< typename T>
234  void
236  template< typename T>
237  void
239 
240  template< typename T>
241  void
244  assert(not m_streamModules.empty());
245  auto mod = m_streamModules[0];
246  mod->registerThinnedAssociations(registry, helper);
247  }
248  }
249 }
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