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
32 // forward declarations
33 
34 namespace edm {
36  namespace stream {
37 
38  template <typename T, typename M, typename B>
39  class ProducingModuleAdaptor : public B {
40  public:
42  m_runs.resize(1);
43  m_lumis.resize(1);
44  m_runSummaries.resize(1);
45  m_lumiSummaries.resize(1);
46  typename T::GlobalCache const* dummy = nullptr;
47  m_global = impl::makeGlobal<T>(iPSet, dummy);
48  }
50 
51  static void fillDescriptions(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); }
52  static void prevalidate(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); }
53 
54  bool wantsGlobalRuns() const final {
57  }
58  bool wantsGlobalLuminosityBlocks() const final {
60  T::HasAbility::kBeginLuminosityBlockProducer or T::HasAbility::kEndLuminosityBlockProducer;
61  }
62 
63  bool hasAcquire() const final { return T::HasAbility::kExternalWork; }
64 
65  bool hasAccumulator() const final { return T::HasAbility::kAccumulator; }
66 
67  private:
77 
78  void setupStreamModules() final {
79  this->createStreamModules([this]() -> M* {
80  auto tmp = impl::makeStreamModule<T>(*m_pset, m_global.get());
81  MyGlobal::set(tmp, m_global.get());
82  return tmp;
83  });
84  m_pset = nullptr;
85  }
86 
87  void preallocLumis(unsigned int iNLumis) final {
88  m_lumis.resize(iNLumis);
89  m_lumiSummaries.resize(iNLumis);
90  }
91  void doEndJob() final { MyGlobal::endJob(m_global.get()); }
92  void setupRun(M* iProd, RunIndex iIndex) final { MyGlobalRun::set(iProd, m_runs[iIndex].get()); }
93  void streamEndRunSummary(M* iProd, edm::Run const& iRun, edm::EventSetup const& iES) final {
94  auto s = m_runSummaries[iRun.index()].get();
95  std::lock_guard<decltype(m_runSummaryLock)> guard(m_runSummaryLock);
96  MyGlobalRunSummary::streamEndRunSummary(iProd, iRun, iES, s);
97  }
98 
99  void setupLuminosityBlock(M* iProd, LuminosityBlockIndex iIndex) final {
100  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
101  }
103  edm::LuminosityBlock const& iLumi,
104  edm::EventSetup const& iES) final {
105  auto s = m_lumiSummaries[iLumi.index()].get();
106  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
108  }
109 
110  void doBeginRun(RunPrincipal const& rp, EventSetupImpl const& ci, ModuleCallingContext const* mcc) final {
112  Run r(rp, this->moduleDescription(), mcc, false);
113  r.setConsumer(this->consumer());
114  r.setProducer(this->producer());
115  Run const& cnstR = r;
116  RunIndex ri = rp.index();
117  const EventSetup c{ci,
118  static_cast<unsigned int>(Transition::BeginRun),
119  this->consumer()->esGetTokenIndices(Transition::BeginRun)};
120  MyGlobalRun::beginRun(cnstR, c, m_global.get(), m_runs[ri]);
121  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
123  if constexpr (T::HasAbility::kBeginRunProducer) {
124  MyBeginRunProduce::produce(r, c, &rc);
125  this->commit(r);
126  }
127  }
128  }
129  void doEndRun(RunPrincipal const& rp, EventSetupImpl const& ci, ModuleCallingContext const* mcc) final {
131  Run r(rp, this->moduleDescription(), mcc, true);
132  r.setConsumer(this->consumer());
133  r.setProducer(this->producer());
134 
135  RunIndex ri = rp.index();
136  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
137  const EventSetup c{ci,
138  static_cast<unsigned int>(Transition::EndRun),
139  this->consumer()->esGetTokenIndices(Transition::EndRun)};
140  if constexpr (T::HasAbility::kEndRunProducer) {
141  MyEndRunProduce::produce(r, c, &rc, m_runSummaries[ri].get());
142  this->commit(r);
143  }
145  MyGlobalRun::endRun(r, c, &rc);
146  }
147  }
148 
150  EventSetupImpl const& ci,
151  ModuleCallingContext const* mcc) final {
153  T::HasAbility::kBeginLuminosityBlockProducer) {
154  LuminosityBlock lb(lbp, this->moduleDescription(), mcc, false);
155  lb.setConsumer(this->consumer());
156  lb.setProducer(this->producer());
157  LuminosityBlock const& cnstLb = lb;
158  LuminosityBlockIndex li = lbp.index();
159  RunIndex ri = lbp.runPrincipal().index();
160  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
161  const EventSetup c{ci,
162  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
163  this->consumer()->esGetTokenIndices(Transition::BeginLuminosityBlock)};
164 
166  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
168  if constexpr (T::HasAbility::kBeginLuminosityBlockProducer) {
170  this->commit(lb);
171  }
172  }
173  }
175  EventSetupImpl const& ci,
176  ModuleCallingContext const* mcc) final {
178  T::HasAbility::kEndLuminosityBlockProducer) {
179  LuminosityBlock lb(lbp, this->moduleDescription(), mcc, true);
180  lb.setConsumer(this->consumer());
181  lb.setProducer(this->producer());
182 
183  LuminosityBlockIndex li = lbp.index();
184  RunIndex ri = lbp.runPrincipal().index();
185  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
186  const EventSetup c{ci,
187  static_cast<unsigned int>(Transition::EndLuminosityBlock),
188  this->consumer()->esGetTokenIndices(Transition::EndLuminosityBlock)};
189  if constexpr (T::HasAbility::kEndLuminosityBlockProducer) {
191  this->commit(lb);
192  }
195  }
196  }
197 
198  ProducingModuleAdaptor(const ProducingModuleAdaptor&) = delete; // stop default
199 
200  const ProducingModuleAdaptor& operator=(const ProducingModuleAdaptor&) = delete; // stop default
201 
202  // ---------- member data --------------------------------
211  };
212  } // namespace stream
213 } // namespace edm
214 
215 #endif
static void endLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext)
static void beginRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::RunSummaryCache > &oCache)
Definition: callAbilities.h:88
void setProducer(ProducerBase const *iProducer)
Definition: Run.cc:70
void setConsumer(EDConsumerBase const *iConsumer)
static void endRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext)
Definition: callAbilities.h:68
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
impl::choose_unique_ptr< typename T::GlobalCache >::type m_global
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
void preallocLumis(unsigned int iNLumis) final
impl::choose_mutex< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaryLock
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)
Definition: callAbilities.h:95
const ProducingModuleAdaptor & operator=(const ProducingModuleAdaptor &)=delete
static void beginRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::GlobalCache const *iGC, std::shared_ptr< typename T::RunCache const > &oCache)
Definition: callAbilities.h:56
void doEndLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
static void set(B *iProd, typename T::RunCache const *iCache)
Definition: callAbilities.h:64
impl::choose_mutex< typename T::RunSummaryCache >::type m_runSummaryLock
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)
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
void doEndRun(RunPrincipal const &rp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
impl::choose_shared_vec< typename T::RunSummaryCache >::type m_runSummaries
void doBeginRun(RunPrincipal const &rp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
static const std::string B
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
CallGlobalLuminosityBlockSummary< T > MyGlobalLuminosityBlockSummary
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void endJob(typename T::GlobalCache *iCache)
Definition: callAbilities.h:41
static void streamEndLuminosityBlockSummary(B *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES, typename T::LuminosityBlockSummaryCache *iCache)
CallEndLuminosityBlockProduce< T > MyEndLuminosityBlockProduce
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)
CallGlobalLuminosityBlock< T > MyGlobalLuminosityBlock
impl::choose_shared_vec< typename T::RunCache const >::type m_runs
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
ProducingModuleAdaptor(edm::ParameterSet const &iPSet)
CallBeginRunProduce< T > MyBeginRunProduce
CallGlobalRunSummary< T > MyGlobalRunSummary
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
std::vector< std::shared_ptr< T > > type
Definition: dummy_helpers.h:64
CallBeginLuminosityBlockProduce< T > MyBeginLuminosityBlockProduce
static void globalEndLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext, typename T::LuminosityBlockSummaryCache *iCache)
static void beginLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::LuminosityBlockCache const > &oCache)
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:51
#define constexpr
static void set(B *iProd, typename T::GlobalCache const *iCache)
Definition: callAbilities.h:38
Definition: Run.h:45