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  }
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 doBeginJob() final { MyGlobal::beginJob(m_global.get()); }
92  void doEndJob() final { MyGlobal::endJob(m_global.get()); }
93  void setupRun(M* iProd, RunIndex iIndex) final { MyGlobalRun::set(iProd, m_runs[iIndex].get()); }
94  void streamEndRunSummary(M* iProd, edm::Run const& iRun, edm::EventSetup const& iES) final {
95  auto s = m_runSummaries[iRun.index()].get();
96  std::lock_guard<decltype(m_runSummaryLock)> guard(m_runSummaryLock);
97  MyGlobalRunSummary::streamEndRunSummary(iProd, iRun, iES, s);
98  }
99 
100  void setupLuminosityBlock(M* iProd, LuminosityBlockIndex iIndex) final {
101  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
102  }
105  edm::EventSetup const& iES) final {
106  auto s = m_lumiSummaries[iLumi.index()].get();
107  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
109  }
110 
111  void doBeginRun(RunPrincipal const& rp, EventSetupImpl const& ci, ModuleCallingContext const* mcc) final {
113  Run r(rp, this->moduleDescription(), mcc, false);
114  r.setConsumer(this->consumer());
115  r.setProducer(this->producer());
116  Run const& cnstR = r;
117  RunIndex ri = rp.index();
118  const EventSetup c{ci,
119  static_cast<unsigned int>(Transition::BeginRun),
120  this->consumer()->esGetTokenIndices(Transition::BeginRun),
121  false};
122  MyGlobalRun::beginRun(cnstR, c, m_global.get(), m_runs[ri]);
123  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
125  if constexpr (T::HasAbility::kBeginRunProducer) {
127  this->commit(r);
128  }
129  }
130  }
131  void doEndRun(RunPrincipal const& rp, EventSetupImpl const& ci, ModuleCallingContext const* mcc) final {
133  Run r(rp, this->moduleDescription(), mcc, true);
134  r.setConsumer(this->consumer());
135  r.setProducer(this->producer());
136 
137  RunIndex ri = rp.index();
138  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
139  const EventSetup c{ci,
140  static_cast<unsigned int>(Transition::EndRun),
141  this->consumer()->esGetTokenIndices(Transition::EndRun),
142  false};
144  if constexpr (T::HasAbility::kEndRunProducer) {
146  this->commit(r);
147  }
148  MyGlobalRun::endRun(r, c, &rc);
149  }
150  }
151 
153  EventSetupImpl const& ci,
154  ModuleCallingContext const* mcc) final {
156  T::HasAbility::kBeginLuminosityBlockProducer) {
157  LuminosityBlock lb(lbp, this->moduleDescription(), mcc, false);
158  lb.setConsumer(this->consumer());
159  lb.setProducer(this->producer());
160  LuminosityBlock const& cnstLb = lb;
161  LuminosityBlockIndex li = lbp.index();
162  RunIndex ri = lbp.runPrincipal().index();
163  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
164  const EventSetup c{ci,
165  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
166  this->consumer()->esGetTokenIndices(Transition::BeginLuminosityBlock),
167  false};
168 
170  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
172  if constexpr (T::HasAbility::kBeginLuminosityBlockProducer) {
174  this->commit(lb);
175  }
176  }
177  }
179  EventSetupImpl const& ci,
180  ModuleCallingContext const* mcc) final {
182  T::HasAbility::kEndLuminosityBlockProducer) {
183  LuminosityBlock lb(lbp, this->moduleDescription(), mcc, true);
184  lb.setConsumer(this->consumer());
185  lb.setProducer(this->producer());
186 
187  LuminosityBlockIndex li = lbp.index();
188  RunIndex ri = lbp.runPrincipal().index();
189  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
190  const EventSetup c{ci,
191  static_cast<unsigned int>(Transition::EndLuminosityBlock),
192  this->consumer()->esGetTokenIndices(Transition::EndLuminosityBlock),
193  false};
195  if constexpr (T::HasAbility::kEndLuminosityBlockProducer) {
197  this->commit(lb);
198  }
200  }
201  }
202 
203  ProducingModuleAdaptor(const ProducingModuleAdaptor&) = delete; // stop default
204 
205  const ProducingModuleAdaptor& operator=(const ProducingModuleAdaptor&) = delete; // stop default
206 
207  // ---------- member data --------------------------------
216  };
217  } // namespace stream
218 } // namespace edm
219 
220 #endif
edm::stream::CallGlobalImpl::endJob
static void endJob(typename T::GlobalCache *iCache)
Definition: callAbilities.h:54
edm::stream::CallGlobalLuminosityBlockImpl
Definition: callAbilities.h:144
edm::stream::CallEndRunProduceImpl::produce
static void produce(edm::Run &, edm::EventSetup const &, typename T::RunContext const *, typename T::RunSummaryCache const *)
Definition: callAbilities.h:248
edm::stream::ProducingModuleAdaptor::hasAccumulator
bool hasAccumulator() const final
Definition: ProducingModuleAdaptor.h:65
edm::stream::ProducingModuleAdaptor::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: ProducingModuleAdaptor.h:51
edm::stream::ProducingModuleAdaptor
Definition: ProducingModuleAdaptor.h:39
edm::stream::ProducingModuleAdaptor::m_lumis
impl::choose_shared_vec< typename T::LuminosityBlockCache const >::type m_lumis
Definition: ProducingModuleAdaptor.h:210
edm::stream::ProducingModuleAdaptor::doEndLuminosityBlock
void doEndLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
Definition: ProducingModuleAdaptor.h:178
edm::EventSetupImpl
Definition: EventSetupImpl.h:44
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::stream::ProducingModuleAdaptor::MyBeginLuminosityBlockProduce
CallBeginLuminosityBlockProduce< T > MyBeginLuminosityBlockProduce
Definition: ProducingModuleAdaptor.h:75
edm::stream::CallGlobalLuminosityBlockSummaryImpl
Definition: callAbilities.h:182
edm::Run
Definition: Run.h:45
edm::stream::ProducingModuleAdaptor::ProducingModuleAdaptor
ProducingModuleAdaptor(edm::ParameterSet const &iPSet)
Definition: ProducingModuleAdaptor.h:41
edm::LuminosityBlock::setProducer
void setProducer(ProducerBase const *iProducer)
Definition: LuminosityBlock.cc:47
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::stream::ProducingModuleAdaptor::~ProducingModuleAdaptor
~ProducingModuleAdaptor() override
Definition: ProducingModuleAdaptor.h:49
edm::stream::CallGlobalRunSummaryImpl::streamEndRunSummary
static void streamEndRunSummary(B *iProd, edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunSummaryCache *iCache)
Definition: callAbilities.h:109
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
edm::stream::ProducingModuleAdaptor::m_runSummaries
impl::choose_shared_vec< typename T::RunSummaryCache >::type m_runSummaries
Definition: ProducingModuleAdaptor.h:211
edm::stream::CallGlobalLuminosityBlockImpl::beginLuminosityBlock
static void beginLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::LuminosityBlockCache const > &oCache)
Definition: callAbilities.h:145
edm::stream::CallGlobalRunSummaryImpl
Definition: callAbilities.h:101
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
edm::stream::impl::choose_shared_vec::type
std::vector< std::shared_ptr< T > > type
Definition: dummy_helpers.h:64
RawToDigi_Repacked_cff.producer
producer
Definition: RawToDigi_Repacked_cff.py:6
edm::stream::ProducingModuleAdaptor::MyEndRunProduce
CallEndRunProduce< T > MyEndRunProduce
Definition: ProducingModuleAdaptor.h:72
edm::stream::CallGlobalImpl::set
static void set(B *iProd, typename T::GlobalCache const *iCache)
Definition: callAbilities.h:46
edm::stream::CallGlobalRunImpl::set
static void set(B *iProd, typename T::RunCache const *iCache)
Definition: callAbilities.h:78
edm::stream::CallEndLuminosityBlockProduceImpl::produce
static void produce(edm::LuminosityBlock &, edm::EventSetup const &, typename T::LuminosityBlockContext const *, typename T::LuminosityBlockSummaryCache const *)
Definition: callAbilities.h:305
edm::module::AbilityBits::kBeginRunProducer
Definition: moduleAbilityEnums.h:57
edm::stream::CallBeginLuminosityBlockProduceImpl
Definition: callAbilities.h:281
callAbilities.h
edm::stream::ProducingModuleAdaptor::doEndRun
void doEndRun(RunPrincipal const &rp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
Definition: ProducingModuleAdaptor.h:131
edm::stream::CallGlobalLuminosityBlockImpl::endLuminosityBlock
static void endLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext)
Definition: callAbilities.h:157
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
watchdog.const
const
Definition: watchdog.py:83
edm::stream::ProducingModuleAdaptor::wantsGlobalLuminosityBlocks
bool wantsGlobalLuminosityBlocks() const final
Definition: ProducingModuleAdaptor.h:58
edm::module::AbilityBits::kEndRunProducer
Definition: moduleAbilityEnums.h:58
makeGlobal.h
edm::stream::CallBeginLuminosityBlockProduceImpl::produce
static void produce(edm::LuminosityBlock &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iRC)
Definition: callAbilities.h:282
edm::stream::ProducingModuleAdaptor::doBeginRun
void doBeginRun(RunPrincipal const &rp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
Definition: ProducingModuleAdaptor.h:111
edm::stream::CallGlobalRunImpl::endRun
static void endRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext)
Definition: callAbilities.h:82
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::stream::CallGlobalImpl::beginJob
static void beginJob(typename T::GlobalCache *iCache)
Definition: callAbilities.h:49
edm::LuminosityBlockIndex
Definition: LuminosityBlockIndex.h:33
edm::stream::CallBeginRunProduceImpl::produce
static void produce(edm::Run &iRun, edm::EventSetup const &iES, typename T::RunContext const *iRC)
Definition: callAbilities.h:230
edm::stream::ProducingModuleAdaptor::MyGlobalRun
CallGlobalRun< T > MyGlobalRun
Definition: ProducingModuleAdaptor.h:69
edm::stream::ProducingModuleAdaptor::MyEndLuminosityBlockProduce
CallEndLuminosityBlockProduce< T > MyEndLuminosityBlockProduce
Definition: ProducingModuleAdaptor.h:76
edm::stream::CallBeginRunProduceImpl
Definition: callAbilities.h:229
edm::stream::CallGlobalLuminosityBlockSummaryImpl::globalEndLuminosityBlock
static void globalEndLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext, typename T::LuminosityBlockSummaryCache *iCache)
Definition: callAbilities.h:197
edm::stream::ProducingModuleAdaptor::streamEndLuminosityBlockSummary
void streamEndLuminosityBlockSummary(M *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES) final
Definition: ProducingModuleAdaptor.h:103
edm::stream::ProducingModuleAdaptor::MyGlobalLuminosityBlock
CallGlobalLuminosityBlock< T > MyGlobalLuminosityBlock
Definition: ProducingModuleAdaptor.h:73
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::stream::ProducingModuleAdaptor::m_runs
impl::choose_shared_vec< typename T::RunCache const >::type m_runs
Definition: ProducingModuleAdaptor.h:209
Run.h
edm::stream::ProducingModuleAdaptor::m_global
impl::choose_unique_ptr< typename T::GlobalCache >::type m_global
Definition: ProducingModuleAdaptor.h:208
edm::stream::ProducingModuleAdaptor::MyGlobalLuminosityBlockSummary
CallGlobalLuminosityBlockSummary< T > MyGlobalLuminosityBlockSummary
Definition: ProducingModuleAdaptor.h:74
edm::stream::CallEndLuminosityBlockProduceImpl
Definition: callAbilities.h:304
edm::Transition::BeginLuminosityBlock
edm::stream::ProducingModuleAdaptor::doBeginJob
void doBeginJob() final
Definition: ProducingModuleAdaptor.h:91
edm::stream::ProducingModuleAdaptor::MyGlobalRunSummary
CallGlobalRunSummary< T > MyGlobalRunSummary
Definition: ProducingModuleAdaptor.h:70
edm::stream::ProducingModuleAdaptor::wantsGlobalRuns
bool wantsGlobalRuns() const final
Definition: ProducingModuleAdaptor.h:54
edm::stream::ProducingModuleAdaptor::prevalidate
static void prevalidate(ConfigurationDescriptions &descriptions)
Definition: ProducingModuleAdaptor.h:52
edm::stream::ProducingModuleAdaptor::streamEndRunSummary
void streamEndRunSummary(M *iProd, edm::Run const &iRun, edm::EventSetup const &iES) final
Definition: ProducingModuleAdaptor.h:94
edm::stream::ProducingModuleAdaptor::MyGlobal
CallGlobal< T > MyGlobal
Definition: ProducingModuleAdaptor.h:68
edm::stream::CallGlobalImpl
Definition: callAbilities.h:44
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::stream::ProducingModuleAdaptor::doEndJob
void doEndJob() final
Definition: ProducingModuleAdaptor.h:92
edm::stream::CallGlobalRunSummaryImpl::beginRun
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:102
es_hardcode_cfi.iLumi
iLumi
Definition: es_hardcode_cfi.py:206
edm::stream::CallEndRunProduceImpl
Definition: callAbilities.h:247
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LuminosityBlock::setConsumer
void setConsumer(EDConsumerBase const *iConsumer)
Definition: LuminosityBlock.cc:26
edm::stream::ProducingModuleAdaptor::MyBeginRunProduce
CallBeginRunProduce< T > MyBeginRunProduce
Definition: ProducingModuleAdaptor.h:71
edm::module::AbilityBits::kRunSummaryCache
Definition: moduleAbilityEnums.h:55
RunPrincipal.h
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:669
edm::stream::ProducingModuleAdaptor::operator=
const ProducingModuleAdaptor & operator=(const ProducingModuleAdaptor &)=delete
edm::stream::CallGlobalRunSummaryImpl::globalEndRun
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext, typename T::RunSummaryCache *iCache)
Definition: callAbilities.h:116
edm::stream::ProducingModuleAdaptor::setupStreamModules
void setupStreamModules() final
Definition: ProducingModuleAdaptor.h:78
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::stream::impl::choose_unique_ptr::type
std::unique_ptr< T > type
Definition: dummy_helpers.h:50
LuminosityBlockPrincipal.h
edm::Run::setProducer
void setProducer(ProducerBase const *iProducer)
Definition: Run.cc:70
edm::stream::ProducingModuleAdaptor::m_runSummaryLock
impl::choose_mutex< typename T::RunSummaryCache >::type m_runSummaryLock
Definition: ProducingModuleAdaptor.h:212
alignCSCRings.r
r
Definition: alignCSCRings.py:93
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
edm::Transition::EndLuminosityBlock
edm::stream::CallGlobalLuminosityBlockImpl::set
static void set(B *iProd, typename T::LuminosityBlockCache const *iCache)
Definition: callAbilities.h:153
ConfigurationDescriptions
edm::module::AbilityBits::kRunCache
Definition: moduleAbilityEnums.h:53
edm::stream::ProducingModuleAdaptor::m_pset
ParameterSet const * m_pset
Definition: ProducingModuleAdaptor.h:215
edm::stream::CallGlobalRunImpl::beginRun
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:70
edm::Transition::BeginRun
edm::module::AbilityBits::kLuminosityBlockSummaryCache
Definition: moduleAbilityEnums.h:56
edm::module::AbilityBits::kLuminosityBlockCache
Definition: moduleAbilityEnums.h:54
EventSetup.h
or
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
edm::RunIndex
Definition: RunIndex.h:32
OfflineOutput_cfi.consumer
consumer
Definition: OfflineOutput_cfi.py:3
edm::stream::ProducingModuleAdaptor::doBeginLuminosityBlock
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
Definition: ProducingModuleAdaptor.h:152
dummy_helpers.h
dummy
Definition: DummySelector.h:38
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::stream::CallGlobalLuminosityBlockSummaryImpl::streamEndLuminosityBlockSummary
static void streamEndLuminosityBlockSummary(B *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES, typename T::LuminosityBlockSummaryCache *iCache)
Definition: callAbilities.h:190
edm::stream::CallGlobalLuminosityBlockSummaryImpl::beginLuminosityBlock
static void beginLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iRC, std::shared_ptr< typename T::LuminosityBlockSummaryCache > &oCache)
Definition: callAbilities.h:183
edm::stream::impl::choose_mutex::type
std::mutex type
Definition: dummy_helpers.h:76
edm::Transition::EndRun
edm::stream::ProducingModuleAdaptor::m_lumiSummaries
impl::choose_shared_vec< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaries
Definition: ProducingModuleAdaptor.h:213
edm::stream::ProducingModuleAdaptor::setupLuminosityBlock
void setupLuminosityBlock(M *iProd, LuminosityBlockIndex iIndex) final
Definition: ProducingModuleAdaptor.h:100
edm::stream::ProducingModuleAdaptor::setupRun
void setupRun(M *iProd, RunIndex iIndex) final
Definition: ProducingModuleAdaptor.h:93
edm::stream::ProducingModuleAdaptor::hasAcquire
bool hasAcquire() const final
Definition: ProducingModuleAdaptor.h:63
edm::stream::CallGlobalRunImpl
Definition: callAbilities.h:69
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29
edm::stream::ProducingModuleAdaptor::preallocLumis
void preallocLumis(unsigned int iNLumis) final
Definition: ProducingModuleAdaptor.h:87
edm::stream::ProducingModuleAdaptor::m_lumiSummaryLock
impl::choose_mutex< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaryLock
Definition: ProducingModuleAdaptor.h:214