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]->itemsToGetFromEvent();
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  std::vector<edm::ConsumesInfo>
120  assert(not m_streamModules.empty());
121  return m_streamModules[0]->consumesInfo();
122  }
123 
124  template< typename T>
125  void
127  ProductResolverIndexHelper const& iHelper,
128  bool iPrefetchMayGet) {
129  for(auto mod: m_streamModules) {
130  mod->updateLookup(iType,iHelper,iPrefetchMayGet);
131  }
132  }
133 
134  template< typename T>
135  void
137  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
138  std::string const& moduleLabel) {
139  m_streamModules[0]->resolvePutIndicies(iBranchType,iIndicies,moduleLabel);
140  }
141 
142 
143  template< typename T>
144  std::vector<edm::ProductResolverIndex> const&
146  return m_streamModules[0]->indiciesForPutProducts(iBranchType);
147  }
148 
149  template< typename T>
150  void
152 
153  }
154 
155  template< typename T>
156  void
158  m_streamModules[id]->beginStream(id);
159  }
160  template< typename T>
161  void
163  m_streamModules[id]->endStream();
164  }
165 
166  template< typename T>
167  void
169  RunPrincipal const& rp,
170  EventSetup const& c,
171  ModuleCallingContext const* mcc)
172  {
173  auto mod = m_streamModules[id];
174  setupRun(mod, rp.index());
175 
176  Run r(rp, moduleDescription_, mcc);
177  r.setConsumer(mod);
178  mod->beginRun(r, c);
179 
180  }
181  template< typename T>
182  void
184  RunPrincipal const& rp,
185  EventSetup const& c,
186  ModuleCallingContext const* mcc)
187  {
188  auto mod = m_streamModules[id];
189  Run r(rp, moduleDescription_, mcc);
190  r.setConsumer(mod);
191  mod->endRun(r, c);
192  streamEndRunSummary(mod,r,c);
193  }
194 
195  template< typename T>
196  void
198  LuminosityBlockPrincipal const& lbp,
199  EventSetup const& c,
200  ModuleCallingContext const* mcc) {
201  auto mod = m_streamModules[id];
202  setupLuminosityBlock(mod,lbp.index());
203 
204  LuminosityBlock lb(lbp, moduleDescription_, mcc);
205  lb.setConsumer(mod);
206  mod->beginLuminosityBlock(lb, c);
207  }
208 
209  template< typename T>
210  void
212  LuminosityBlockPrincipal const& lbp,
213  EventSetup const& c,
214  ModuleCallingContext const* mcc)
215  {
216  auto mod = m_streamModules[id];
217  LuminosityBlock lb(lbp, moduleDescription_, mcc);
218  lb.setConsumer(mod);
219  mod->endLuminosityBlock(lb, c);
220  streamEndLuminosityBlockSummary(mod,lb, c);
221  }
222 
223  template< typename T>
224  void
226  template< typename T>
227  void
229  template< typename T>
230  void
232  for(auto m: m_streamModules) {
233  m->preForkReleaseResources();
234  }
235  }
236  template< typename T>
237  void
238  ProducingModuleAdaptorBase<T>::doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren){
239  for(auto m: m_streamModules) {
240  m->postForkReacquireResources(iChildIndex,iNumberOfChildren);
241  }
242  }
243 
244  template< typename T>
245  void
248  assert(not m_streamModules.empty());
249  auto mod = m_streamModules[0];
250  mod->registerThinnedAssociations(registry, helper);
251  }
252  }
253 }
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
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
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent() const
void doStreamEndRun(StreamID id, RunPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
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
void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)