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 
15 // user include files
22 
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
34 namespace edm {
35  namespace stream {
36  template< typename T>
38  {
39  }
40 
41  template< typename T>
43  {
44  for(auto m: m_streamModules) {
45  delete m;
46  }
47  }
48 
49  //
50  // member functions
51  //
52 
53  template< typename T>
54  void
56  m_streamModules.resize(iPrealloc.numberOfStreams(),
57  static_cast<T*>(nullptr));
58  setupStreamModules();
59  }
60 
61  template< typename T>
62  void
64  auto firstMod = m_streamModules[0];
65  if(firstMod->registrationCallback() and m_streamModules.size()>1) {
66  //we have a callback so we will collect all callbacks and create a new callback which calls them all.
67 
68  std::vector<std::function<void(BranchDescription const&)>> callbacks;
69  callbacks.reserve(m_streamModules.size());
70 
71  for(auto mod: m_streamModules) {
72  callbacks.push_back(mod->registrationCallback());
73  }
74  //Since only the first module will actually do the registration
75  // we will change its callback to call all the callbacks
76  firstMod->callWhenNewProductsRegistered([callbacks](BranchDescription const& iBD) {
77  for(auto c: callbacks) {
78  c(iBD);
79  }
80  });
81  }
82  firstMod->registerProducts(firstMod,reg,moduleDescription_);
83  }
84 
85  template< typename T>
86  void
87  ProducingModuleAdaptorBase<T>::itemsToGet(BranchType iType, std::vector<ProductHolderIndexAndSkipBit>& iIndices) const {
88  assert(not m_streamModules.empty());
89  m_streamModules[0]->itemsToGet(iType,iIndices);
90  }
91 
92  template< typename T>
93  void
94  ProducingModuleAdaptorBase<T>::itemsMayGet(BranchType iType, std::vector<ProductHolderIndexAndSkipBit>& iIndices) const {
95  assert(not m_streamModules.empty());
96  m_streamModules[0]->itemsMayGet(iType,iIndices);
97  }
98 
99  template<typename T>
100  std::vector<edm::ProductHolderIndexAndSkipBit> const&
102  assert(not m_streamModules.empty());
103  return m_streamModules[0]->itemsToGetFromEvent();
104  }
105 
106  template< typename T>
107  void
109  std::vector<const char*>& oModuleLabels) const {
110  assert(not m_streamModules.empty());
111  return m_streamModules[0]->modulesDependentUpon(iProcessName, oModuleLabels);
112  }
113 
114  template< typename T>
115  void
117  ProductHolderIndexHelper const& iHelper) {
118  for(auto mod: m_streamModules) {
119  mod->updateLookup(iType,iHelper);
120  }
121  }
122 
123  template< typename T>
124  void
126 
127  }
128 
129  template< typename T>
130  void
132  m_streamModules[id]->beginStream(id);
133  }
134  template< typename T>
135  void
137  m_streamModules[id]->endStream();
138  }
139 
140  template< typename T>
141  void
143  RunPrincipal& rp,
144  EventSetup const& c,
145  ModuleCallingContext const* mcc)
146  {
147  auto mod = m_streamModules[id];
148  setupRun(mod, rp.index());
149 
150  Run r(rp, moduleDescription_, mcc);
151  r.setConsumer(mod);
152  mod->beginRun(r, c);
153 
154  }
155  template< typename T>
156  void
158  RunPrincipal& rp,
159  EventSetup const& c,
160  ModuleCallingContext const* mcc)
161  {
162  auto mod = m_streamModules[id];
163  Run r(rp, moduleDescription_, mcc);
164  r.setConsumer(mod);
165  mod->endRun(r, c);
166  streamEndRunSummary(mod,r,c);
167  }
168 
169  template< typename T>
170  void
173  EventSetup const& c,
174  ModuleCallingContext const* mcc) {
175  auto mod = m_streamModules[id];
176  setupLuminosityBlock(mod,lbp.index());
177 
178  LuminosityBlock lb(lbp, moduleDescription_, mcc);
179  lb.setConsumer(mod);
180  mod->beginLuminosityBlock(lb, c);
181  }
182 
183  template< typename T>
184  void
187  EventSetup const& c,
188  ModuleCallingContext const* mcc)
189  {
190  auto mod = m_streamModules[id];
191  LuminosityBlock lb(lbp, moduleDescription_, mcc);
192  lb.setConsumer(mod);
193  mod->endLuminosityBlock(lb, c);
194  streamEndLuminosityBlockSummary(mod,lb, c);
195  }
196 
197  template< typename T>
198  void
200  template< typename T>
201  void
203  template< typename T>
204  void
206  for(auto m: m_streamModules) {
207  m->preForkReleaseResources();
208  }
209  }
210  template< typename T>
211  void
212  ProducingModuleAdaptorBase<T>::doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren){
213  for(auto m: m_streamModules) {
214  m->postForkReacquireResources(iChildIndex,iNumberOfChildren);
215  }
216  }
217 
218  template< typename T>
219  void
221  ThinnedAssociationsHelper& helper) {
222  assert(not m_streamModules.empty());
223  auto mod = m_streamModules[0];
224  mod->registerThinnedAssociations(registry, helper);
225  }
226  }
227 }
void setConsumer(EDConsumerBase const *iConsumer)
void doRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &)
void doStreamEndRun(StreamID id, RunPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
LuminosityBlockIndex index() const
void doPreallocate(PreallocationConfiguration const &)
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
BranchType
Definition: BranchType.h:11
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 &)
std::vector< ProductHolderIndexAndSkipBit > const & itemsToGetFromEvent() const
static Interceptor::Registry registry("Interceptor")
void doStreamBeginRun(StreamID id, RunPrincipal &ep, EventSetup const &c, ModuleCallingContext const *)
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:48
Definition: Run.h:41
void modulesDependentUpon(const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)