CMS 3D CMS Logo

WorkerT.cc
Go to the documentation of this file.
3 
16 
20 
21 #include <type_traits>
22 
23 namespace edm{
24  namespace workerimpl {
25  template<typename T>
27  static bool constexpr value = false;
28  };
29 
30  template<>
32  static bool constexpr value = true;
33  };
34 
35  template<>
37  static bool constexpr value = true;
38  };
39 
40  template<>
42  static bool constexpr value = true;
43  };
44 
45  template<>
47  static bool constexpr value = true;
48  };
49 
50  template<>
52  static bool constexpr value = true;
53  };
54 
55  template<>
57  static bool constexpr value = true;
58  };
59 
60  struct DoNothing {
61  template< typename... T>
62  inline void operator()(const T&...) {}
63  };
64 
65  template<typename T>
66  struct DoBeginStream {
67  inline void operator()(WorkerT<T>* iWorker, StreamID id) {
68  iWorker->callWorkerBeginStream(0,id);
69  }
70  };
71 
72  template<typename T>
73  struct DoEndStream {
74  inline void operator()(WorkerT<T>* iWorker, StreamID id) {
75  iWorker->callWorkerEndStream(0,id);
76  }
77  };
78 
79  template<typename T, typename P>
81  inline void operator() (WorkerT<T>* iWorker, StreamID id, P const& rp,
82  EventSetup const& c,
83  ModuleCallingContext const* mcc) {
84  iWorker->callWorkerStreamBegin(0,id,rp,c, mcc);
85  }
86  };
87 
88  template<typename T, typename P>
90  inline void operator() (WorkerT<T>* iWorker, StreamID id, P const& rp,
91  EventSetup const& c,
92  ModuleCallingContext const* mcc) {
93  iWorker->callWorkerStreamEnd(0,id,rp,c, mcc);
94  }
95  };
96  }
97 
98  template<typename T>
99  inline
100  WorkerT<T>::WorkerT(std::shared_ptr<T> ed, ModuleDescription const& md, ExceptionToActionTable const* actions) :
101  Worker(md, actions),
102  module_(ed) {
103  assert(module_ != 0);
104  }
105 
106  template<typename T>
108  }
109 
110  template<typename T>
111  inline
112  bool
114  std::shared_ptr<Worker> sentry(this,[&ep](Worker* obj) {obj->postDoEvent(ep);});
115  return module_->doEvent(ep, c, activityRegistry(), mcc);
116  }
117 
118  template<typename T>
119  inline
120  bool
122  EventPrincipal const& ep,
123  ModuleCallingContext const* mcc) {
124  return true;
125  }
126 
127  template<>
128  inline
129  bool
131  EventPrincipal const& ep,
132  ModuleCallingContext const* mcc) {
133  return module_->prePrefetchSelection(id,ep,mcc);
134  }
135 
136  template<>
137  inline
138  bool
140  EventPrincipal const& ep,
141  ModuleCallingContext const* mcc) {
142  return module_->prePrefetchSelection(id,ep,mcc);
143  }
144 
145  template<>
146  inline
147  bool
149  EventPrincipal const& ep,
150  ModuleCallingContext const* mcc) {
151  return module_->prePrefetchSelection(id,ep,mcc);
152  }
153 
154  template<typename T>
155  inline
156  bool
158  module_->doBeginRun(rp, c, mcc);
159  return true;
160  }
161 
162  template<typename T>
163  template<typename D>
164  void
166  EventSetup const& c,
167  ModuleCallingContext const* mcc) {
168  module_->doStreamBeginRun(id, rp, c, mcc);
169  }
170 
171  template<typename T>
172  template<typename D>
173  void
175  EventSetup const& c,
176  ModuleCallingContext const* mcc) {
177  module_->doStreamEndRun(id, rp, c, mcc);
178  }
179 
180 
181  template<typename T>
182  inline
183  bool
185  ModuleCallingContext const* mcc) {
188  workerimpl::DoNothing> might_call;
189  might_call(this,id,rp,c, mcc);
190  return true;
191  }
192 
193  template<typename T>
194  inline
195  bool
197  ModuleCallingContext const* mcc) {
200  workerimpl::DoNothing> might_call;
201  might_call(this,id,rp,c, mcc);
202  return true;
203  }
204 
205  template<typename T>
206  inline
207  bool
209  ModuleCallingContext const* mcc) {
210  module_->doEndRun(rp, c, mcc);
211  return true;
212  }
213 
214  template<typename T>
215  inline
216  bool
218  ModuleCallingContext const* mcc) {
219  module_->doBeginLuminosityBlock(lbp, c, mcc);
220  return true;
221  }
222 
223  template<typename T>
224  template<typename D>
225  void
227  EventSetup const& c,
228  ModuleCallingContext const* mcc) {
229  module_->doStreamBeginLuminosityBlock(id, rp, c, mcc);
230  }
231 
232  template<typename T>
233  template<typename D>
234  void
236  EventSetup const& c,
237  ModuleCallingContext const* mcc) {
238  module_->doStreamEndLuminosityBlock(id, rp, c, mcc);
239  }
240 
241 
242  template<typename T>
243  inline
244  bool
246  ModuleCallingContext const* mcc) {
249  workerimpl::DoNothing> might_call;
250  might_call(this,id,lbp,c, mcc);
251  return true;
252  }
253 
254  template<typename T>
255  inline
256  bool
258  ModuleCallingContext const* mcc) {
261  workerimpl::DoNothing> might_call;
262  might_call(this,id,lbp,c,mcc);
263 
264  return true;
265  }
266 
267  template<typename T>
268  inline
269  bool
271  ModuleCallingContext const* mcc) {
272  module_->doEndLuminosityBlock(lbp, c, mcc);
273  return true;
274  }
275 
276  template<typename T>
277  inline
280  return module_->workerType();
281  }
282 
283  template<typename T>
284  inline
285  void
287  module_->doBeginJob();
288  }
289 
290  template<typename T>
291  inline
292  void
294  module_->doEndJob();
295  }
296 
297  template<typename T>
298  template<typename D>
300  module_->doBeginStream(id);
301  }
302 
303  template<typename T>
304  inline
305  void
309  workerimpl::DoNothing> might_call;
310  might_call(this,id);
311  }
312 
313  template<typename T>
314  template<typename D>
316  module_->doEndStream(id);
317  }
318 
319  template<typename T>
320  inline
321  void
325  workerimpl::DoNothing> might_call;
326  might_call(this,id);
327  }
328 
329  template<typename T>
330  inline
331  void
333  module_->doRespondToOpenInputFile(fb);
334  }
335 
336  template<typename T>
337  inline
338  void
340  module_->doRespondToCloseInputFile(fb);
341  }
342 
343  template<typename T>
344  inline
345  void
348  module_->doRegisterThinnedAssociations(registry, helper);
349  }
350 
351  template<typename T>
352  inline
354  return nullptr;
355  }
357  return &(module_->sharedResourcesAcquirer().serialQueueChain());
358  }
360  return &(module_->sharedResourcesAcquirer().serialQueueChain());
361  }
363  return &(module_->sharedResourcesAcquirer().serialQueueChain());
364  }
366  return &(module_->sharedResourcesAcquirer().serialQueueChain());
367  }
369  return &(module_->sharedResourcesAcquirer().serialQueueChain());
370  }
372  return &(module_->sharedResourcesAcquirer().serialQueueChain());
373  }
375  return &(module_->sharedResourcesAcquirer().serialQueueChain());
376  }
378  return &(module_->sharedResourcesAcquirer().serialQueueChain());
379  }
380 
381 
382  namespace {
383  template <typename T> bool mustPrefetchMayGet();
384 
385  template<> bool mustPrefetchMayGet<EDAnalyzer>() { return true;}
386  template<> bool mustPrefetchMayGet<EDProducer>() { return true;}
387  template<> bool mustPrefetchMayGet<EDFilter>() { return true;}
388  template<> bool mustPrefetchMayGet<OutputModule>() { return true;}
389 
390  template<> bool mustPrefetchMayGet<edm::one::EDProducerBase>() { return true;}
391  template<> bool mustPrefetchMayGet<edm::one::EDFilterBase>() { return true;}
392  template<> bool mustPrefetchMayGet<edm::one::EDAnalyzerBase>() { return true;}
393  template<> bool mustPrefetchMayGet<edm::one::OutputModuleBase>() { return true;}
394 
395  template<> bool mustPrefetchMayGet<edm::global::EDProducerBase>() { return true;}
396  template<> bool mustPrefetchMayGet<edm::global::EDFilterBase>() { return true;}
397  template<> bool mustPrefetchMayGet<edm::global::EDAnalyzerBase>() { return true;}
398  template<> bool mustPrefetchMayGet<edm::global::OutputModuleBase>() { return true;}
399 
400  template<> bool mustPrefetchMayGet<edm::stream::EDProducerAdaptorBase>() { return true;}
401  template<> bool mustPrefetchMayGet<edm::stream::EDFilterAdaptorBase>() { return true;}
402  template<> bool mustPrefetchMayGet<edm::stream::EDAnalyzerAdaptorBase>() { return true;}
403 
404  }
405 
406 
407  template<typename T>
409  ProductResolverIndexHelper const& iHelper) {
410  module_->updateLookup(iBranchType,iHelper,mustPrefetchMayGet<T>());
411  }
412 
413  namespace {
414  void resolvePutIndiciesImpl(void*,
415  BranchType iBranchType,
416  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
417  std::string const& iModuleLabel) {
418  //Do nothing
419  }
420 
421  void resolvePutIndiciesImpl(ProducerBase* iProd,
422  BranchType iBranchType,
423  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
424  std::string const& iModuleLabel) {
425  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
426  }
427 
428  void resolvePutIndiciesImpl(edm::stream::EDProducerAdaptorBase* iProd,
429  BranchType iBranchType,
430  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
431  std::string const& iModuleLabel) {
432  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
433  }
434  void resolvePutIndiciesImpl(edm::stream::EDFilterAdaptorBase* iProd,
435  BranchType iBranchType,
436  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies,
437  std::string const& iModuleLabel) {
438  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
439  }
440 
441  std::vector<ProductResolverIndex> s_emptyIndexList;
442 
443  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(void const*) {
444  return s_emptyIndexList;
445  }
446 
447  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(ProducerBase const* iProd) {
448  return iProd->indiciesForPutProducts(edm::InEvent);
449  }
450 
451  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(edm::stream::EDProducerAdaptorBase const* iProd) {
452  return iProd->indiciesForPutProducts(edm::InEvent);
453  }
454 
455  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(edm::stream::EDFilterAdaptorBase const* iProd) {
456  return iProd->indiciesForPutProducts(edm::InEvent);
457  }
458 
459  }
460 
461  template<typename T>
463  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies) {
464  resolvePutIndiciesImpl(&module(), iBranchType,iIndicies, description().moduleLabel());
465  }
466 
467 
468  template<typename T>
469  std::vector<ProductResolverIndex> const&
471  return itemsShouldPutInEventImpl(&module());
472  }
473 
474 
475  template<>
477  template<>
479  template<>
481  template<>
483  template<>
485  template<>
487  template<>
489  template<>
491 
492  template<>
494  template<>
496  template<>
498  template<>
500 
501 
502  template<>
504  template<>
506  template<>
508 
509  //Explicitly instantiate our needed templates to avoid having the compiler
510  // instantiate them in all of our libraries
511  template class WorkerT<EDProducer>;
512  template class WorkerT<EDFilter>;
513  template class WorkerT<EDAnalyzer>;
514  template class WorkerT<OutputModule>;
515  template class WorkerT<one::EDProducerBase>;
516  template class WorkerT<one::EDFilterBase>;
517  template class WorkerT<one::EDAnalyzerBase>;
518  template class WorkerT<one::OutputModuleBase>;
519  template class WorkerT<global::EDProducerBase>;
520  template class WorkerT<global::EDFilterBase>;
521  template class WorkerT<global::EDAnalyzerBase>;
522  template class WorkerT<global::OutputModuleBase>;
526 }
virtual bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:196
static const char module_[]
ModuleDescription const & description() const
Definition: Worker.h:138
Definition: helper.py:1
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void callWorkerStreamEnd(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:174
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
virtual void implEndJob() override
Definition: WorkerT.cc:293
virtual void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) override
Definition: WorkerT.cc:408
T & module()
Definition: WorkerT.h:74
virtual bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:184
ActivityRegistry * activityRegistry()
Definition: Worker.h:214
virtual bool implDo(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:113
virtual ~WorkerT()
Definition: WorkerT.cc:107
#define constexpr
BranchType
Definition: BranchType.h:11
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:141
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducerBase.h:79
virtual void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:332
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
virtual bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:121
virtual SerialTaskQueueChain * serializeRunModule() override
Definition: WorkerT.cc:353
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
Definition: ProducerBase.cc:85
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:315
void operator()(WorkerT< T > *iWorker, StreamID id)
Definition: WorkerT.cc:67
void operator()(const T &...)
Definition: WorkerT.cc:62
virtual void implBeginStream(StreamID) override
Definition: WorkerT.cc:306
Definition: value.py:1
void operator()(WorkerT< T > *iWorker, StreamID id)
Definition: WorkerT.cc:74
void callWorkerStreamBegin(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:165
virtual bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:157
virtual std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:470
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
virtual void implEndStream(StreamID) override
Definition: WorkerT.cc:322
virtual void implBeginJob() override
Definition: WorkerT.cc:286
virtual void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:339
std::pair< OmniClusterRef, TrackingParticleRef > P
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:299
HLT enums.
void postDoEvent(EventPrincipal const &)
Definition: Worker.cc:331
virtual void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:346
virtual bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:208
static Interceptor::Registry registry("Interceptor")
long double T
virtual std::string workerType() const override
Definition: WorkerT.cc:279
virtual void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies) override
Definition: WorkerT.cc:462
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:100
virtual Types moduleType() const override