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
31 // forward declarations
32 
33 namespace edm {
35  namespace stream {
36 
37  template<typename T, typename M, typename B>
38  class ProducingModuleAdaptor : public B
39  {
40 
41  public:
43  m_pset(&iPSet)
44  {
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  }
53  }
54 
55  static void fillDescriptions(ConfigurationDescriptions& descriptions) {
56  T::fillDescriptions(descriptions);
57  }
58  static void prevalidate(ConfigurationDescriptions& descriptions) {
59  T::prevalidate(descriptions);
60  }
61 
62  bool wantsGlobalRuns() const final {
69  T::HasAbility::kBeginLuminosityBlockProducer or
70  T::HasAbility::kEndLuminosityBlockProducer;}
71 
72  bool hasAcquire() const final {
73  return T::HasAbility::kExternalWork;
74  }
75 
76  bool hasAccumulator() const final {
77  return T::HasAbility::kAccumulator;
78  }
79 
80  private:
90 
91  void setupStreamModules() final {
92  this->createStreamModules([this] () -> M* {
93  auto tmp = impl::makeStreamModule<T>(*m_pset,m_global.get());
94  MyGlobal::set(tmp,m_global.get());
95  return tmp;
96  });
97  m_pset= nullptr;
98  }
99 
100  void preallocLumis(unsigned int iNLumis) final {
101  m_lumis.resize(iNLumis);
102  m_lumiSummaries.resize(iNLumis);
103  }
104  void doEndJob() final {
105  MyGlobal::endJob(m_global.get());
106  }
107  void setupRun(M* iProd, RunIndex iIndex) final {
108  MyGlobalRun::set(iProd, m_runs[iIndex].get());
109  }
110  void streamEndRunSummary(M* iProd,
111  edm::Run const& iRun,
112  edm::EventSetup const& iES) final {
113  auto s = m_runSummaries[iRun.index()].get();
114  std::lock_guard<decltype(m_runSummaryLock)> guard(m_runSummaryLock);
116  }
117 
118  void setupLuminosityBlock(M* iProd, LuminosityBlockIndex iIndex) final
119  {
120  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
121  }
123  edm::LuminosityBlock const& iLumi,
124  edm::EventSetup const& iES) final {
125  auto s = m_lumiSummaries[iLumi.index()].get();
126  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
128  }
129 
130  void doBeginRun(RunPrincipal const& rp,
131  EventSetup const& c,
132  ModuleCallingContext const* mcc) final {
134  Run r(rp, this->moduleDescription(), mcc, false);
135  r.setConsumer(this->consumer());
136  r.setProducer(this->producer());
137  Run const& cnstR = r;
138  RunIndex ri = rp.index();
139  MyGlobalRun::beginRun(cnstR,c,m_global.get(),m_runs[ri]);
140  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
142  if(T::HasAbility::kBeginRunProducer) {
144  this->commit(r);
145  }
146  }
147  }
148  void doEndRun(RunPrincipal const& rp,
149  EventSetup const& c,
150  ModuleCallingContext const* mcc) final
151  {
153 
154  Run r(rp, this->moduleDescription(), mcc, true);
155  r.setConsumer(this->consumer());
156  r.setProducer(this->producer());
157 
158  RunIndex ri = rp.index();
159  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
160  if(T::HasAbility::kEndRunProducer) {
161  MyEndRunProduce::produce(r,c,&rc,m_runSummaries[ri].get());
162  this->commit(r);
163  }
165  MyGlobalRun::endRun(r,c,&rc);
166  }
167  }
168 
170  ModuleCallingContext const* mcc) final
171  {
172  if(T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or T::HasAbility::kBeginLuminosityBlockProducer) {
173  LuminosityBlock lb(lbp, this->moduleDescription(), mcc, false);
174  lb.setConsumer(this->consumer());
175  lb.setProducer(this->producer());
176  LuminosityBlock const& cnstLb = lb;
177  LuminosityBlockIndex li = lbp.index();
178  RunIndex ri = lbp.runPrincipal().index();
179  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
181  typename T::LuminosityBlockContext lc(m_lumis[li].get(),m_runs[ri].get(),m_global.get());
183  if(T::HasAbility::kBeginLuminosityBlockProducer) {
185  this->commit(lb);
186  }
187  }
188 
189  }
191  EventSetup const& c,
192  ModuleCallingContext const* mcc) final {
193  if(T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or T::HasAbility::kEndLuminosityBlockProducer) {
194 
195  LuminosityBlock lb(lbp, this->moduleDescription(), mcc, true);
196  lb.setConsumer(this->consumer());
197  lb.setProducer(this->producer());
198 
199  LuminosityBlockIndex li = lbp.index();
200  RunIndex ri = lbp.runPrincipal().index();
201  typename T::LuminosityBlockContext lc(m_lumis[li].get(),m_runs[ri].get(),m_global.get());
202  if(T::HasAbility::kEndLuminosityBlockProducer) {
204  this->commit(lb);
205  }
208  }
209  }
210 
211  ProducingModuleAdaptor(const ProducingModuleAdaptor&) = delete; // stop default
212 
213  const ProducingModuleAdaptor& operator=(const ProducingModuleAdaptor&) = delete; // stop default
214 
215  // ---------- member data --------------------------------
224  };
225  }
226 }
227 
228 #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)
void setProducer(ProducerBase const *iProducer)
Definition: Run.cc:79
void setConsumer(EDConsumerBase const *iConsumer)
static void endRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext)
Definition: callAbilities.h:72
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)
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:60
void doBeginRun(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) final
static void set(B *iProd, typename T::RunCache const *iCache)
Definition: callAbilities.h:68
impl::choose_mutex< typename T::RunSummaryCache >::type m_runSummaryLock
void doEndRun(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) final
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)
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetup const &c, ModuleCallingContext const *mcc) 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
impl::choose_shared_vec< typename T::RunSummaryCache >::type m_runSummaries
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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 doEndLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetup const &c, ModuleCallingContext const *mcc) final
void setupLuminosityBlock(M *iProd, LuminosityBlockIndex iIndex) final
void setupRun(M *iProd, RunIndex iIndex) final
CallGlobalLuminosityBlockSummary< T > MyGlobalLuminosityBlockSummary
static void endJob(typename T::GlobalCache *iCache)
Definition: callAbilities.h:42
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
static void set(B *iProd, typename T::GlobalCache const *iCache)
Definition: callAbilities.h:38
Definition: Run.h:44