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  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
146  std::string const& moduleLabel) {
147  m_streamModules[0]->resolvePutIndicies(iBranchType,iIndicies,moduleLabel);
148  }
149 
150 
151  template< typename T>
152  std::vector<edm::ProductResolverIndex> const&
154  return m_streamModules[0]->indiciesForPutProducts(iBranchType);
155  }
156 
157  template< typename T>
158  void
160 
161  }
162 
163  template< typename T>
164  void
166  m_streamModules[id]->beginStream(id);
167  }
168  template< typename T>
169  void
171  m_streamModules[id]->endStream();
172  }
173 
174  template< typename T>
175  void
177  RunPrincipal const& rp,
178  EventSetup const& c,
179  ModuleCallingContext const* mcc)
180  {
181  auto mod = m_streamModules[id];
182  setupRun(mod, rp.index());
183 
184  Run r(rp, moduleDescription_, mcc);
185  r.setConsumer(mod);
186  mod->beginRun(r, c);
187 
188  }
189  template< typename T>
190  void
192  RunPrincipal const& rp,
193  EventSetup const& c,
194  ModuleCallingContext const* mcc)
195  {
196  auto mod = m_streamModules[id];
197  Run r(rp, moduleDescription_, mcc);
198  r.setConsumer(mod);
199  mod->endRun(r, c);
200  streamEndRunSummary(mod,r,c);
201  }
202 
203  template< typename T>
204  void
206  LuminosityBlockPrincipal const& lbp,
207  EventSetup const& c,
208  ModuleCallingContext const* mcc) {
209  auto mod = m_streamModules[id];
210  setupLuminosityBlock(mod,lbp.index());
211 
212  LuminosityBlock lb(lbp, moduleDescription_, mcc);
213  lb.setConsumer(mod);
214  mod->beginLuminosityBlock(lb, c);
215  }
216 
217  template< typename T>
218  void
220  LuminosityBlockPrincipal const& lbp,
221  EventSetup const& c,
222  ModuleCallingContext const* mcc)
223  {
224  auto mod = m_streamModules[id];
225  LuminosityBlock lb(lbp, moduleDescription_, mcc);
226  lb.setConsumer(mod);
227  mod->endLuminosityBlock(lb, c);
228  streamEndLuminosityBlockSummary(mod,lb, c);
229  }
230 
231  template< typename T>
232  void
234  template< typename T>
235  void
237 
238  template< typename T>
239  void
242  assert(not m_streamModules.empty());
243  auto mod = m_streamModules[0];
244  mod->registerThinnedAssociations(registry, helper);
245  }
246  }
247 }
void doStreamBeginRun(StreamID id, RunPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
void setConsumer(EDConsumerBase const *iConsumer)
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
Definition: helper.py:1
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
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)
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:49
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
Definition: Run.h:42