CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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
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<ProductHolderIndexAndSkipBit>& 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<ProductHolderIndexAndSkipBit>& 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::ProductHolderIndexAndSkipBit> const&
103  assert(not m_streamModules.empty());
104  return m_streamModules[0]->itemsToGetFromEvent();
105  }
106 
107  template< typename T>
108  void
110  std::vector<const char*>& oModuleLabels) const {
111  assert(not m_streamModules.empty());
112  return m_streamModules[0]->modulesDependentUpon(iProcessName, oModuleLabels);
113  }
114 
115  template< typename T>
116  void
118  ProductRegistry const& preg,
119  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
120  std::string const& processName) const {
121  assert(not m_streamModules.empty());
122  return m_streamModules[0]->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, processName);
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  ProductHolderIndexHelper const& iHelper) {
136  for(auto mod: m_streamModules) {
137  mod->updateLookup(iType,iHelper);
138  }
139  }
140 
141  template< typename T>
142  void
144 
145  }
146 
147  template< typename T>
148  void
150  m_streamModules[id]->beginStream(id);
151  }
152  template< typename T>
153  void
155  m_streamModules[id]->endStream();
156  }
157 
158  template< typename T>
159  void
161  RunPrincipal& rp,
162  EventSetup const& c,
163  ModuleCallingContext const* mcc)
164  {
165  auto mod = m_streamModules[id];
166  setupRun(mod, rp.index());
167 
168  Run r(rp, moduleDescription_, mcc);
169  r.setConsumer(mod);
170  mod->beginRun(r, c);
171 
172  }
173  template< typename T>
174  void
176  RunPrincipal& rp,
177  EventSetup const& c,
178  ModuleCallingContext const* mcc)
179  {
180  auto mod = m_streamModules[id];
181  Run r(rp, moduleDescription_, mcc);
182  r.setConsumer(mod);
183  mod->endRun(r, c);
184  streamEndRunSummary(mod,r,c);
185  }
186 
187  template< typename T>
188  void
191  EventSetup const& c,
192  ModuleCallingContext const* mcc) {
193  auto mod = m_streamModules[id];
194  setupLuminosityBlock(mod,lbp.index());
195 
196  LuminosityBlock lb(lbp, moduleDescription_, mcc);
197  lb.setConsumer(mod);
198  mod->beginLuminosityBlock(lb, c);
199  }
200 
201  template< typename T>
202  void
205  EventSetup const& c,
206  ModuleCallingContext const* mcc)
207  {
208  auto mod = m_streamModules[id];
209  LuminosityBlock lb(lbp, moduleDescription_, mcc);
210  lb.setConsumer(mod);
211  mod->endLuminosityBlock(lb, c);
212  streamEndLuminosityBlockSummary(mod,lb, c);
213  }
214 
215  template< typename T>
216  void
218  template< typename T>
219  void
221  template< typename T>
222  void
224  for(auto m: m_streamModules) {
225  m->preForkReleaseResources();
226  }
227  }
228  template< typename T>
229  void
230  ProducingModuleAdaptorBase<T>::doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren){
231  for(auto m: m_streamModules) {
232  m->postForkReacquireResources(iChildIndex,iNumberOfChildren);
233  }
234  }
235 
236  template< typename T>
237  void
239  ThinnedAssociationsHelper& helper) {
240  assert(not m_streamModules.empty());
241  auto mod = m_streamModules[0];
242  mod->registerThinnedAssociations(registry, helper);
243  }
244  }
245 }
void setConsumer(EDConsumerBase const *iConsumer)
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
void doStreamEndRun(StreamID id, RunPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
assert(m_qm.get())
LuminosityBlockIndex index() const
void doPreallocate(PreallocationConfiguration const &)
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &c, ModuleCallingContext 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
void itemsToGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
void registerProductsAndCallbacks(ProducingModuleAdaptorBase const *, ProductRegistry *reg)
void doStreamEndLuminosityBlock(StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
void itemsMayGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
RunIndex index() const
Definition: RunPrincipal.h:53
void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &)
void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
std::vector< ProductHolderIndexAndSkipBit > const & itemsToGetFromEvent() const
static Interceptor::Registry registry("Interceptor")
void doStreamBeginRun(StreamID id, RunPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
preg
Definition: Schedule.cc:369
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:50
Definition: Run.h:43
void modulesDependentUpon(const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)