CMS 3D CMS Logo

ProducingModuleAdaptor.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_stream_ProducingModuleAdaptor_h
2 #define FWCore_Framework_stream_ProducingModuleAdaptor_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : ProducingModuleAdaptor
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Fri, 02 Aug 2013 18:09:18 GMT
19 //
20 
21 // system include files
22 
23 // user include files
35 // forward declarations
36 
37 namespace edm {
39  namespace stream {
40 
41  template <typename T, typename M, typename B>
42  class ProducingModuleAdaptor : public B {
43  public:
45  m_runs.resize(1);
46  m_lumis.resize(1);
47  m_runSummaries.resize(1);
48  m_lumiSummaries.resize(1);
49  typename T::GlobalCache const* dummy = nullptr;
50  m_global = impl::makeGlobal<T>(iPSet, dummy);
51  typename T::InputProcessBlockCache const* dummyInputProcessBlockCacheImpl = nullptr;
52  m_inputProcessBlocks = impl::makeInputProcessBlockCacheImpl(dummyInputProcessBlockCacheImpl);
53  }
54  ProducingModuleAdaptor(const ProducingModuleAdaptor&) = delete; // stop default
55  const ProducingModuleAdaptor& operator=(const ProducingModuleAdaptor&) = delete; // stop default
56  ~ProducingModuleAdaptor() override { this->deleteModulesEarly(); }
57 
58  static void fillDescriptions(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); }
59  static void prevalidate(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); }
60 
61  bool wantsProcessBlocks() const noexcept final {
62  return T::HasAbility::kWatchProcessBlock or T::HasAbility::kBeginProcessBlockProducer or
63  T::HasAbility::kEndProcessBlockProducer;
64  }
65  bool wantsInputProcessBlocks() const noexcept final { return T::HasAbility::kInputProcessBlockCache; }
66  bool wantsGlobalRuns() const noexcept final {
67  return T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache or T::HasAbility::kBeginRunProducer or
68  T::HasAbility::kEndRunProducer;
69  }
70  bool wantsStreamRuns() const noexcept final { return T::HasAbility::kWatchRuns; }
71 
72  bool wantsGlobalLuminosityBlocks() const noexcept final {
73  return T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or
74  T::HasAbility::kBeginLuminosityBlockProducer or T::HasAbility::kEndLuminosityBlockProducer;
75  }
76  bool wantsStreamLuminosityBlocks() const noexcept final { return T::HasAbility::kWatchLuminosityBlocks; }
77 
78  bool hasAcquire() const noexcept final { return T::HasAbility::kExternalWork; }
79 
80  bool hasAccumulator() const noexcept final { return T::HasAbility::kAccumulator; }
81 
82  private:
96 
97  void setupStreamModules() final {
98  this->createStreamModules([this](unsigned int iStreamModule) -> M* {
99  auto tmp = impl::makeStreamModule<T>(*m_pset, m_global.get());
100  MyGlobal::set(tmp, m_global.get());
102  return tmp;
103  });
104  m_pset = nullptr;
105  }
106 
107  void preallocRuns(unsigned int iNRuns) final {
108  m_runs.resize(iNRuns);
109  m_runSummaries.resize(iNRuns);
110  }
111  void preallocLumis(unsigned int iNLumis) final {
112  m_lumis.resize(iNLumis);
113  m_lumiSummaries.resize(iNLumis);
114  }
115  void doBeginJob() final { MyGlobal::beginJob(m_global.get()); }
116  void doEndJob() final { MyGlobal::endJob(m_global.get()); }
117  void setupRun(M* iProd, RunIndex iIndex) final { MyGlobalRun::set(iProd, m_runs[iIndex].get()); }
118  void streamEndRunSummary(M* iProd, edm::Run const& iRun, edm::EventSetup const& iES) final {
119  auto s = m_runSummaries[iRun.index()].get();
120  std::lock_guard<decltype(m_runSummaryLock)> guard(m_runSummaryLock);
121  MyGlobalRunSummary::streamEndRunSummary(iProd, iRun, iES, s);
122  }
123 
124  void setupLuminosityBlock(M* iProd, LuminosityBlockIndex iIndex) final {
125  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
126  }
129  edm::EventSetup const& iES) final {
130  auto s = m_lumiSummaries[iLumi.index()].get();
131  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
133  }
134 
136  if constexpr (T::HasAbility::kWatchProcessBlock or T::HasAbility::kBeginProcessBlockProducer) {
137  ProcessBlock processBlock(pbp, this->moduleDescription(), mcc, false);
138  ProcessBlock const& cnstProcessBlock = processBlock;
139  processBlock.setConsumer(this->consumer());
140  MyWatchProcessBlock::beginProcessBlock(cnstProcessBlock, m_global.get());
141  if constexpr (T::HasAbility::kBeginProcessBlockProducer) {
142  processBlock.setProducer(this->producer());
143  MyBeginProcessBlockProduce::produce(processBlock, m_global.get());
144  this->commit(processBlock);
145  }
146  }
147  }
148 
150  if constexpr (T::HasAbility::kInputProcessBlockCache) {
151  ProcessBlock processBlock(pbp, this->moduleDescription(), mcc, false);
152  ProcessBlock const& cnstProcessBlock = processBlock;
153  processBlock.setConsumer(this->consumer());
155  }
156  }
157 
158  void doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) final {
159  if constexpr (T::HasAbility::kWatchProcessBlock or T::HasAbility::kEndProcessBlockProducer) {
160  ProcessBlock processBlock(pbp, this->moduleDescription(), mcc, true);
161  ProcessBlock const& cnstProcessBlock = processBlock;
162  processBlock.setConsumer(this->consumer());
163  MyWatchProcessBlock::endProcessBlock(cnstProcessBlock, m_global.get());
164  if constexpr (T::HasAbility::kEndProcessBlockProducer) {
165  processBlock.setProducer(this->producer());
166  MyEndProcessBlockProduce::produce(processBlock, m_global.get());
167  this->commit(processBlock);
168  }
169  }
170  }
171 
172  void doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
173  if constexpr (T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache or T::HasAbility::kBeginRunProducer) {
174  RunPrincipal const& rp = info.principal();
175  Run r(rp, this->moduleDescription(), mcc, false);
176  r.setConsumer(this->consumer());
177  r.setProducer(this->producer());
178  Run const& cnstR = r;
179  RunIndex ri = rp.index();
180  ESParentContext parentC(mcc);
181  const EventSetup c{info,
182  static_cast<unsigned int>(Transition::BeginRun),
183  this->consumer()->esGetTokenIndices(Transition::BeginRun),
184  parentC};
185  MyGlobalRun::beginRun(cnstR, c, m_global.get(), m_runs[ri]);
186  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
188  if constexpr (T::HasAbility::kBeginRunProducer) {
189  MyBeginRunProduce::produce(r, c, &rc);
190  this->commit(r);
191  }
192  }
193  }
194 
195  void doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
196  if constexpr (T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache or T::HasAbility::kEndRunProducer) {
197  RunPrincipal const& rp = info.principal();
198  Run r(rp, this->moduleDescription(), mcc, true);
199  r.setConsumer(this->consumer());
200  r.setProducer(this->producer());
201 
202  RunIndex ri = rp.index();
203  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
204  ESParentContext parentC(mcc);
205  const EventSetup c{info,
206  static_cast<unsigned int>(Transition::EndRun),
207  this->consumer()->esGetTokenIndices(Transition::EndRun),
208  parentC};
210  if constexpr (T::HasAbility::kEndRunProducer) {
211  MyEndRunProduce::produce(r, c, &rc, m_runSummaries[ri].get());
212  this->commit(r);
213  }
214  MyGlobalRun::endRun(r, c, &rc);
215  }
216  }
217 
219  if constexpr (T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or
220  T::HasAbility::kBeginLuminosityBlockProducer) {
221  LuminosityBlockPrincipal const& lbp = info.principal();
222  LuminosityBlock lb(lbp, this->moduleDescription(), mcc, false);
223  lb.setConsumer(this->consumer());
224  lb.setProducer(this->producer());
225  LuminosityBlock const& cnstLb = lb;
226  LuminosityBlockIndex li = lbp.index();
227  RunIndex ri = lbp.runPrincipal().index();
228  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
229  ESParentContext parentC(mcc);
230  const EventSetup c{info,
231  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
232  this->consumer()->esGetTokenIndices(Transition::BeginLuminosityBlock),
233  parentC};
234 
236  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
238  if constexpr (T::HasAbility::kBeginLuminosityBlockProducer) {
240  this->commit(lb);
241  }
242  }
243  }
245  if constexpr (T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or
246  T::HasAbility::kEndLuminosityBlockProducer) {
247  LuminosityBlockPrincipal const& lbp = info.principal();
248  LuminosityBlock lb(lbp, this->moduleDescription(), mcc, true);
249  lb.setConsumer(this->consumer());
250  lb.setProducer(this->producer());
251 
252  LuminosityBlockIndex li = lbp.index();
253  RunIndex ri = lbp.runPrincipal().index();
254  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
255  ESParentContext parentC(mcc);
256  const EventSetup c{info,
257  static_cast<unsigned int>(Transition::EndLuminosityBlock),
258  this->consumer()->esGetTokenIndices(Transition::EndLuminosityBlock),
259  parentC};
261  if constexpr (T::HasAbility::kEndLuminosityBlockProducer) {
263  this->commit(lb);
264  }
266  }
267  }
268 
270 
271  using B::consumer;
272 
273  void selectInputProcessBlocks(ProductRegistry const& productRegistry,
274  ProcessBlockHelperBase const& processBlockHelperBase) final {
276  m_inputProcessBlocks, productRegistry, processBlockHelperBase, *consumer());
277  }
278 
279  // ---------- member data --------------------------------
289  };
290  } // namespace stream
291 } // namespace edm
292 
293 #endif
static void endLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext)
static void beginProcessBlock(edm::ProcessBlock const &iProcessBlock, typename T::GlobalCache *iGC)
static void beginRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::RunSummaryCache > &oCache)
void setProducer(ProducerBase const *iProducer)
Definition: Run.cc:79
void doBeginProcessBlock(ProcessBlockPrincipal const &pbp, ModuleCallingContext const *mcc) final
static const TGPicture * info(bool iBackgroundIsBlack)
void setConsumer(EDConsumerBase const *iConsumer)
std::unique_ptr< G > makeInputProcessBlockCacheImpl(G const *)
Definition: makeGlobal.h:49
static void endRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext)
Definition: APVGainStruct.h:7
impl::choose_unique_ptr< typename T::GlobalCache >::type m_global
void selectInputProcessBlocks(ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase) final
void doEndLuminosityBlock(LumiTransitionInfo const &info, ModuleCallingContext const *mcc) final
static void beginRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::GlobalCache const *iGC, std::shared_ptr< typename T::RunCache const > &oCache)
static void produce(edm::LuminosityBlock &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iRC)
static void produce(edm::LuminosityBlock &, edm::EventSetup const &, typename T::LuminosityBlockContext const *, typename T::LuminosityBlockSummaryCache const *)
void streamEndLuminosityBlockSummary(M *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES) final
RunPrincipal const & runPrincipal() const
bool wantsProcessBlocks() const noexcept final
void doEndProcessBlock(ProcessBlockPrincipal const &pbp, ModuleCallingContext const *mcc) final
static void set(T *iProd, typename impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type const *iCaches, unsigned int iStreamModule)
Definition: callAbilities.h:76
static void selectInputProcessBlocks(typename impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type &iCaches, ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase, EDConsumerBase const &edConsumerBase)
Definition: callAbilities.h:86
void preallocLumis(unsigned int iNLumis) final
impl::choose_mutex< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaryLock
static void clearCaches(typename impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type &iCaches)
static void prevalidate(ConfigurationDescriptions &descriptions)
void streamEndRunSummary(M *iProd, edm::Run const &iRun, edm::EventSetup const &iES) final
static void streamEndRunSummary(B *iProd, edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunSummaryCache *iCache)
const ProducingModuleAdaptor & operator=(const ProducingModuleAdaptor &)=delete
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void doAccessInputProcessBlock(ProcessBlockPrincipal const &pbp, ModuleCallingContext const *mcc) final
static void accessInputProcessBlock(edm::ProcessBlock const &processBlock, typename T::GlobalCache *iGC, typename impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type &iCaches)
Definition: callAbilities.h:94
void doBeginRun(RunTransitionInfo const &info, ModuleCallingContext const *mcc) final
static void set(B *iProd, typename T::RunCache const *iCache)
impl::choose_mutex< typename T::RunSummaryCache >::type m_runSummaryLock
static void produce(edm::ProcessBlock &processBlock, typename T::GlobalCache *globalCache)
static void beginLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::LuminosityBlockCache const > &oCache)
static void beginLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iRC, std::shared_ptr< typename T::LuminosityBlockSummaryCache > &oCache)
static void produce(edm::Run &iRun, edm::EventSetup const &iES, typename T::RunContext const *iRC)
bool wantsInputProcessBlocks() const noexcept final
bool wantsStreamLuminosityBlocks() const noexcept final
bool wantsGlobalLuminosityBlocks() const noexcept final
void setConsumer(EDConsumerBase const *iConsumer)
Definition: ProcessBlock.h:53
void preallocRuns(unsigned int iNRuns) final
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 or
Definition: Activities.doc:12
bool wantsStreamRuns() const noexcept final
impl::choose_shared_vec< typename T::RunSummaryCache >::type m_runSummaries
bool hasAccumulator() const noexcept final
RunIndex index() const
Definition: RunPrincipal.h:56
void doEndRun(RunTransitionInfo const &info, ModuleCallingContext const *mcc) final
impl::choose_shared_vec< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaries
static void set(B *iProd, typename T::LuminosityBlockCache const *iCache)
void setupLuminosityBlock(M *iProd, LuminosityBlockIndex iIndex) final
void setupRun(M *iProd, RunIndex iIndex) final
impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type m_inputProcessBlocks
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setProducer(ProducerBase const *iProducer)
Definition: ProcessBlock.cc:13
static void endJob(typename T::GlobalCache *iCache)
Definition: callAbilities.h:59
static void streamEndLuminosityBlockSummary(B *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES, typename T::LuminosityBlockSummaryCache *iCache)
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext, typename T::RunSummaryCache *iCache)
void setProducer(ProducerBase const *iProducer)
void doBeginLuminosityBlock(LumiTransitionInfo const &info, ModuleCallingContext const *mcc) final
impl::choose_shared_vec< typename T::RunCache const >::type m_runs
HLT enums.
ProducingModuleAdaptor(edm::ParameterSet const &iPSet)
bool wantsGlobalRuns() const noexcept final
LuminosityBlockIndex index() const
static void fillDescriptions(ConfigurationDescriptions &descriptions)
static void produce(edm::Run &, edm::EventSetup const &, typename T::RunContext const *, typename T::RunSummaryCache const *)
impl::choose_shared_vec< typename T::LuminosityBlockCache const >::type m_lumis
static void beginJob(typename T::GlobalCache *iCache)
Definition: callAbilities.h:54
std::vector< std::shared_ptr< T > > type
Definition: dummy_helpers.h:64
bool hasAcquire() const noexcept final
static void globalEndLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext, typename T::LuminosityBlockSummaryCache *iCache)
tmp
align.sh
Definition: createJobs.py:716
static void produce(edm::ProcessBlock &processBlock, typename T::GlobalCache *globalCache)
static void set(B *iProd, typename T::GlobalCache const *iCache)
Definition: callAbilities.h:51
Definition: Run.h:45
static void endProcessBlock(edm::ProcessBlock const &iProcessBlock, typename T::GlobalCache *iGC)