CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EDAnalyzerAdaptor.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_stream_EDAnalyzerAdaptor_h
2 #define FWCore_Framework_stream_EDAnalyzerAdaptor_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : EDAnalyzerAdaptor
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 
33 // forward declarations
34 
35 namespace edm {
36  namespace stream {
37 
38  namespace impl {
39  template<typename T, typename G>
40  std::unique_ptr<G> makeGlobal(edm::ParameterSet const& iPSet, G const*) {
41  return T::initializeGlobalCache(iPSet);
42  }
43  template<typename T>
44  dummy_ptr makeGlobal(edm::ParameterSet const& iPSet, void const*) {
45  return dummy_ptr();
46  }
47 
48  template< typename T, typename G>
50  G const* iGlobal) {
51  return new T(iPSet,iGlobal);
52  }
53 
54  template< typename T>
56  void const* ) {
57  return new T(iPSet);
58  }
59  }
60 
61  template<typename ABase, typename ModType> struct BaseToAdaptor;
62 
63  template<typename T> class EDAnalyzerAdaptor;
64  template<typename ModType> struct BaseToAdaptor<EDAnalyzerAdaptorBase,ModType> {
66  };
67 
68  template<typename T>
70  {
71 
72  public:
74  m_pset(&iPSet)
75  {
76  m_runs.resize(1);
77  m_lumis.resize(1);
78  m_runSummaries.resize(1);
79  m_lumiSummaries.resize(1);
80  typename T::GlobalCache const* dummy=nullptr;
81  m_global.reset( impl::makeGlobal<T>(iPSet,dummy).release());
82  }
84  }
85 
86  static void fillDescriptions(ConfigurationDescriptions& descriptions) {
87  T::fillDescriptions(descriptions);
88  }
89  static void prevalidate(ConfigurationDescriptions& descriptions) {
90  T::prevalidate(descriptions);
91  }
92 
93 
94  private:
100 
101  void setupStreamModules() override final {
102  this->createStreamModules([this] () -> EDAnalyzerBase* {return impl::makeStreamModule<T>(*m_pset,m_global.get());});
103  m_pset= nullptr;
104  }
105 
106  void doEndJob() override final {
107  MyGlobal::endJob(m_global.get());
108  }
109  void setupRun(EDAnalyzerBase* iProd, RunIndex iIndex) override final {
110  MyGlobal::set(iProd,m_global.get());
111  MyGlobalRun::set(iProd, m_runs[iIndex].get());
112  }
114  edm::Run const& iRun,
115  edm::EventSetup const& iES) override final {
116  auto s = m_runSummaries[iRun.index()].get();
118  }
119 
120  void setupLuminosityBlock(EDAnalyzerBase* iProd, LuminosityBlockIndex iIndex) override final
121  {
122  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
123  }
125  edm::LuminosityBlock const& iLumi,
126  edm::EventSetup const& iES) override final {
127  auto s = m_lumiSummaries[iLumi.index()].get();
129  }
130 
132  EventSetup const& c,
133  ModuleCallingContext const* mcc) override final {
135  Run r(rp, moduleDescription(), mcc);
136  r.setConsumer(consumer());
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  }
143  }
145  EventSetup const& c,
146  ModuleCallingContext const* mcc) override final
147  {
149 
150  Run r(rp, moduleDescription(), mcc);
151  r.setConsumer(consumer());
152 
153  RunIndex ri = rp.index();
154  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
156  MyGlobalRun::endRun(r,c,&rc);
157  }
158  }
159 
161  EventSetup const& c,
162  ModuleCallingContext const* mcc) override final
163  {
165  LuminosityBlock lb(lbp, moduleDescription(), mcc);
166  lb.setConsumer(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  }
175 
176  }
178  EventSetup const& c,
179  ModuleCallingContext const* mcc) override final {
181 
182  LuminosityBlock lb(lbp, moduleDescription(), mcc);
183  lb.setConsumer(consumer());
184 
185  LuminosityBlockIndex li = lbp.index();
186  RunIndex ri = lbp.runPrincipal().index();
187  typename T::LuminosityBlockContext lc(m_lumis[li].get(),m_runs[ri].get(),m_global.get());
190  }
191  }
192 
193  EDAnalyzerAdaptor(const EDAnalyzerAdaptor&); // stop default
194 
195  const EDAnalyzerAdaptor& operator=(const EDAnalyzerAdaptor&); // stop default
196 
197  // ---------- member data --------------------------------
204  };
205  }
206 
207  template<>
209  {
211  public:
212  template<typename ModType>
213  static std::unique_ptr<Base> makeModule(ParameterSet const& pset) {
214  typedef typename stream::BaseToAdaptor<Base,ModType>::Type Adaptor;
215  std::unique_ptr<Adaptor> module = std::unique_ptr<Adaptor>(new Adaptor(pset));
216  return std::unique_ptr<Base>(module.release());
217  }
218  };
219 
220 }
221 
222 #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)
void doBeginLuminosityBlock(LuminosityBlockPrincipal &lbp, EventSetup const &c, ModuleCallingContext const *mcc) overridefinal
static void beginRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::RunSummaryCache > &oCache)
impl::choose_shared_vec< typename T::RunCache const >::type m_runs
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void setConsumer(EDConsumerBase const *iConsumer)
static void endRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext)
Definition: callAbilities.h:71
void setupRun(EDAnalyzerBase *iProd, RunIndex iIndex) overridefinal
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
static std::unique_ptr< Base > makeModule(ParameterSet const &pset)
const EDConsumerBase * consumer() const
void streamEndLuminosityBlockSummary(EDAnalyzerBase *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES) overridefinal
static void streamEndRunSummary(B *iProd, edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunSummaryCache *iCache)
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
static void set(B *iProd, typename T::RunCache const *iCache)
Definition: callAbilities.h:67
impl::choose_unique_ptr< typename T::GlobalCache >::type m_global
static void beginLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iRC, std::shared_ptr< typename T::LuminosityBlockSummaryCache > &oCache)
impl::choose_shared_vec< typename T::RunSummaryCache >::type m_runSummaries
void doEndLuminosityBlock(LuminosityBlockPrincipal &lbp, EventSetup const &c, ModuleCallingContext const *mcc) overridefinal
CallGlobalLuminosityBlock< T > MyGlobalLuminosityBlock
impl::choose_shared_vec< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaries
EDAnalyzerAdaptor(edm::ParameterSet const &iPSet)
void setupLuminosityBlock(EDAnalyzerBase *iProd, LuminosityBlockIndex iIndex) overridefinal
static void set(B *iProd, typename T::LuminosityBlockCache const *iCache)
std::unique_ptr< G > makeGlobal(edm::ParameterSet const &iPSet, G const *)
const ModuleDescription & moduleDescription()
impl::choose_shared_vec< typename T::LuminosityBlockCache const >::type m_lumis
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)
CallGlobalLuminosityBlockSummary< T > MyGlobalLuminosityBlockSummary
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext, typename T::RunSummaryCache *iCache)
void streamEndRunSummary(EDAnalyzerBase *iProd, edm::Run const &iRun, edm::EventSetup const &iES) overridefinal
void doBeginRun(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc) overridefinal
std::vector< std::shared_ptr< T > > type
Definition: dummy_helpers.h:56
void setupStreamModules() overridefinal
void doEndRun(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc) overridefinal
const EDAnalyzerAdaptor & operator=(const EDAnalyzerAdaptor &)
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
CallGlobalRunSummary< T > MyGlobalRunSummary
Definition: vlib.h:208
static void set(B *iProd, typename T::GlobalCache const *iCache)
Definition: callAbilities.h:37
Definition: Run.h:41
static void prevalidate(ConfigurationDescriptions &descriptions)