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::string const& iModuleLabel,
111  bool iPrint,
112  std::vector<char const*>& oModuleLabels) const {
113  assert(not m_streamModules.empty());
114  return m_streamModules[0]->modulesDependentUpon(iProcessName, iModuleLabel, iPrint, oModuleLabels);
115  }
116 
117  template< typename T>
118  void
120  ProductRegistry const& preg,
121  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
122  std::string const& processName) const {
123  assert(not m_streamModules.empty());
124  return m_streamModules[0]->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, processName);
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  ProductHolderIndexHelper const& iHelper) {
138  for(auto mod: m_streamModules) {
139  mod->updateLookup(iType,iHelper);
140  }
141  }
142 
143  template< typename T>
144  void
146 
147  }
148 
149  template< typename T>
150  void
152  m_streamModules[id]->beginStream(id);
153  }
154  template< typename T>
155  void
157  m_streamModules[id]->endStream();
158  }
159 
160  template< typename T>
161  void
163  RunPrincipal const& rp,
164  EventSetup const& c,
165  ModuleCallingContext const* mcc)
166  {
167  auto mod = m_streamModules[id];
168  setupRun(mod, rp.index());
169 
170  Run r(rp, moduleDescription_, mcc);
171  r.setConsumer(mod);
172  mod->beginRun(r, c);
173 
174  }
175  template< typename T>
176  void
178  RunPrincipal const& rp,
179  EventSetup const& c,
180  ModuleCallingContext const* mcc)
181  {
182  auto mod = m_streamModules[id];
183  Run r(rp, moduleDescription_, mcc);
184  r.setConsumer(mod);
185  mod->endRun(r, c);
186  streamEndRunSummary(mod,r,c);
187  }
188 
189  template< typename T>
190  void
192  LuminosityBlockPrincipal const& lbp,
193  EventSetup const& c,
194  ModuleCallingContext const* mcc) {
195  auto mod = m_streamModules[id];
196  setupLuminosityBlock(mod,lbp.index());
197 
198  LuminosityBlock lb(lbp, moduleDescription_, mcc);
199  lb.setConsumer(mod);
200  mod->beginLuminosityBlock(lb, c);
201  }
202 
203  template< typename T>
204  void
206  LuminosityBlockPrincipal const& lbp,
207  EventSetup const& c,
208  ModuleCallingContext const* mcc)
209  {
210  auto mod = m_streamModules[id];
211  LuminosityBlock lb(lbp, moduleDescription_, mcc);
212  lb.setConsumer(mod);
213  mod->endLuminosityBlock(lb, c);
214  streamEndLuminosityBlockSummary(mod,lb, c);
215  }
216 
217  template< typename T>
218  void
220  template< typename T>
221  void
223  template< typename T>
224  void
226  for(auto m: m_streamModules) {
227  m->preForkReleaseResources();
228  }
229  }
230  template< typename T>
231  void
232  ProducingModuleAdaptorBase<T>::doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren){
233  for(auto m: m_streamModules) {
234  m->postForkReacquireResources(iChildIndex,iNumberOfChildren);
235  }
236  }
237 
238  template< typename T>
239  void
241  ThinnedAssociationsHelper& helper) {
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 &)
assert(m_qm.get())
LuminosityBlockIndex index() const
void modulesDependentUpon(std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) 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 *)
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 doStreamEndRun(StreamID id, RunPrincipal const &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")
preg
Definition: Schedule.cc:374
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
void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)