CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
30 // forward declarations
31 
32 namespace edm {
33  namespace stream {
34  namespace impl {
35  template<typename T, typename G>
36  std::unique_ptr<G> makeGlobal(edm::ParameterSet const& iPSet, G const*) {
37  return T::initializeGlobalCache(iPSet);
38  }
39  template<typename T>
40  dummy_ptr makeGlobal(edm::ParameterSet const& iPSet, void const*) {
41  return dummy_ptr();
42  }
43 
44  template< typename T, typename G>
45  T* makeStreamModule(edm::ParameterSet const& iPSet,
46  G const* iGlobal) {
47  return new T(iPSet,iGlobal);
48  }
49 
50  template< typename T>
51  T* makeStreamModule(edm::ParameterSet const& iPSet,
52  void const* ) {
53  return new T(iPSet);
54  }
55  }
56 
57  template<typename T, typename M, typename B>
58  class ProducingModuleAdaptor : public B
59  {
60 
61  public:
63  m_pset(&iPSet)
64  {
65  m_runs.resize(1);
66  m_lumis.resize(1);
67  m_runSummaries.resize(1);
68  m_lumiSummaries.resize(1);
69  typename T::GlobalCache const* dummy=nullptr;
70  m_global.reset( impl::makeGlobal<T>(iPSet,dummy).release());
71  }
73  }
74 
75  static void fillDescriptions(ConfigurationDescriptions& descriptions) {
76  T::fillDescriptions(descriptions);
77  }
78  static void prevalidate(ConfigurationDescriptions& descriptions) {
79  T::prevalidate(descriptions);
80  }
81 
82 
83  private:
93 
94  void setupStreamModules() override final {
95  this->createStreamModules([this] () -> M* {return impl::makeStreamModule<T>(*m_pset,m_global.get());});
96  m_pset= nullptr;
97  }
98 
99  void doEndJob() override final {
100  MyGlobal::endJob(m_global.get());
101  }
102  void setupRun(M* iProd, RunIndex iIndex) override final {
103  MyGlobal::set(iProd,m_global.get());
104  MyGlobalRun::set(iProd, m_runs[iIndex].get());
105  }
106  void streamEndRunSummary(M* iProd,
107  edm::Run const& iRun,
108  edm::EventSetup const& iES) override final {
109  auto s = m_runSummaries[iRun.index()].get();
111  }
112 
113  void setupLuminosityBlock(M* iProd, LuminosityBlockIndex iIndex) override final
114  {
115  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
116  }
118  edm::LuminosityBlock const& iLumi,
119  edm::EventSetup const& iES) override final {
120  auto s = m_lumiSummaries[iLumi.index()].get();
122  }
123 
125  EventSetup const& c,
126  ModuleCallingContext const* mcc) override final {
128  Run r(rp, this->moduleDescription(), mcc);
129  r.setConsumer(this->consumer());
130  Run const& cnstR = r;
131  RunIndex ri = rp.index();
132  MyGlobalRun::beginRun(cnstR,c,m_global.get(),m_runs[ri]);
133  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
135  if(T::HasAbility::kBeginRunProducer) {
137  this->commit(r);
138  }
139  }
140  }
142  EventSetup const& c,
143  ModuleCallingContext const* mcc) override final
144  {
146 
147  Run r(rp, this->moduleDescription(), mcc);
148  r.setConsumer(this->consumer());
149 
150  RunIndex ri = rp.index();
151  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
152  if(T::HasAbility::kEndRunProducer) {
153  MyEndRunProduce::produce(r,c,&rc,m_runSummaries[ri].get());
154  this->commit(r);
155  }
157  MyGlobalRun::endRun(r,c,&rc);
158  }
159  }
160 
162  ModuleCallingContext const* mcc) override final
163  {
164  if(T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or T::HasAbility::kBeginLuminosityBlockProducer) {
165  LuminosityBlock lb(lbp, this->moduleDescription(), mcc);
166  lb.setConsumer(this->consumer());
167  LuminosityBlock const& cnstLb = lb;
168  LuminosityBlockIndex li = lbp.index();
169  RunIndex ri = lbp.runPrincipal().index();
170  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
172  typename T::LuminosityBlockContext lc(m_lumis[li].get(),m_runs[ri].get(),m_global.get());
174  if(T::HasAbility::kBeginLuminosityBlockProducer) {
176  this->commit(lb);
177  }
178  }
179 
180  }
182  EventSetup const& c,
183  ModuleCallingContext const* mcc) override final {
184  if(T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache or T::HasAbility::kEndLuminosityBlockProducer) {
185 
186  LuminosityBlock lb(lbp, this->moduleDescription(), mcc);
187  lb.setConsumer(this->consumer());
188 
189  LuminosityBlockIndex li = lbp.index();
190  RunIndex ri = lbp.runPrincipal().index();
191  typename T::LuminosityBlockContext lc(m_lumis[li].get(),m_runs[ri].get(),m_global.get());
192  if(T::HasAbility::kEndLuminosityBlockProducer) {
194  this->commit(lb);
195  }
198  }
199  }
200 
201  ProducingModuleAdaptor(const ProducingModuleAdaptor&) = delete; // stop default
202 
203  const ProducingModuleAdaptor& operator=(const ProducingModuleAdaptor&) = delete; // stop default
204 
205  // ---------- member data --------------------------------
212  };
213  }
214 }
215 
216 #endif
static void endLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext)
T * makeStreamModule(edm::ParameterSet const &iPSet, G const *iGlobal)
static void beginRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::RunSummaryCache > &oCache)
void setConsumer(EDConsumerBase const *iConsumer)
void doBeginRun(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc) overridefinal
static void endRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext)
Definition: callAbilities.h:71
impl::choose_unique_ptr< typename T::GlobalCache >::type m_global
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void doEndRun(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc) overridefinal
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 setupLuminosityBlock(M *iProd, LuminosityBlockIndex iIndex) overridefinal
static void prevalidate(ConfigurationDescriptions &descriptions)
static void streamEndRunSummary(B *iProd, edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunSummaryCache *iCache)
const ProducingModuleAdaptor & operator=(const ProducingModuleAdaptor &)=delete
void streamEndLuminosityBlockSummary(M *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES) overridefinal
void doEndLuminosityBlock(LuminosityBlockPrincipal &lbp, EventSetup const &c, ModuleCallingContext const *mcc) overridefinal
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:59
void streamEndRunSummary(M *iProd, edm::Run const &iRun, edm::EventSetup const &iES) overridefinal
static void set(B *iProd, typename T::RunCache const *iCache)
Definition: callAbilities.h:67
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)
impl::choose_shared_vec< typename T::RunSummaryCache >::type m_runSummaries
impl::choose_shared_vec< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaries
static void set(B *iProd, typename T::LuminosityBlockCache const *iCache)
std::unique_ptr< G > makeGlobal(edm::ParameterSet const &iPSet, G const *)
void setupRun(M *iProd, RunIndex iIndex) overridefinal
CallGlobalLuminosityBlockSummary< T > MyGlobalLuminosityBlockSummary
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)
CallGlobalLuminosityBlock< T > MyGlobalLuminosityBlock
impl::choose_shared_vec< typename T::RunCache const >::type m_runs
ProducingModuleAdaptor(edm::ParameterSet const &iPSet)
CallBeginRunProduce< T > MyBeginRunProduce
CallGlobalRunSummary< T > MyGlobalRunSummary
void doBeginLuminosityBlock(LuminosityBlockPrincipal &lbp, EventSetup const &c, ModuleCallingContext const *mcc) overridefinal
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:56
CallBeginLuminosityBlockProduce< T > MyBeginLuminosityBlockProduce
static void globalEndLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext, typename T::LuminosityBlockSummaryCache *iCache)
long double T
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:48
static void set(B *iProd, typename T::GlobalCache const *iCache)
Definition: callAbilities.h:37
Definition: Run.h:41