CMS 3D CMS Logo

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
33 
34 // forward declarations
35 
36 namespace edm {
37  namespace stream {
38 
39  template<typename ABase, typename ModType> struct BaseToAdaptor;
40 
41  template<typename T> class EDAnalyzerAdaptor;
42  template<typename ModType> struct BaseToAdaptor<EDAnalyzerAdaptorBase,ModType> {
44  };
45 
46  template<typename T>
48  {
49 
50  public:
52  m_pset(&iPSet)
53  {
54  m_runs.resize(1);
55  m_lumis.resize(1);
56  m_runSummaries.resize(1);
57  m_lumiSummaries.resize(1);
58  typename T::GlobalCache const* dummy=nullptr;
59  m_global.reset( impl::makeGlobal<T>(iPSet,dummy).release());
60  }
62  }
63 
64  static void fillDescriptions(ConfigurationDescriptions& descriptions) {
65  T::fillDescriptions(descriptions);
66  }
67  static void prevalidate(ConfigurationDescriptions& descriptions) {
68  T::prevalidate(descriptions);
69  }
70 
71 
72  private:
78 
79  void setupStreamModules() override final {
80  this->createStreamModules([this] () -> EDAnalyzerBase* {
81  auto tmp = impl::makeStreamModule<T>(*m_pset,m_global.get());
82  MyGlobal::set(tmp,m_global.get());
83  return tmp;
84  });
85  m_pset= nullptr;
86  }
87 
88  void doEndJob() override final {
89  MyGlobal::endJob(m_global.get());
90  }
91  void setupRun(EDAnalyzerBase* iProd, RunIndex iIndex) override final {
92  MyGlobalRun::set(iProd, m_runs[iIndex].get());
93  }
95  edm::Run const& iRun,
96  edm::EventSetup const& iES) override final {
97  auto s = m_runSummaries[iRun.index()].get();
98  std::lock_guard<decltype(m_runSummaryLock)> guard(m_runSummaryLock);
99  MyGlobalRunSummary::streamEndRunSummary(iProd,iRun,iES,s);
100  }
101 
102  void setupLuminosityBlock(EDAnalyzerBase* iProd, LuminosityBlockIndex iIndex) override final
103  {
104  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
105  }
107  edm::LuminosityBlock const& iLumi,
108  edm::EventSetup const& iES) override final {
109  auto s = m_lumiSummaries[iLumi.index()].get();
110  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
111  MyGlobalLuminosityBlockSummary::streamEndLuminosityBlockSummary(iProd,iLumi,iES,s);
112  }
113 
114  void doBeginRun(RunPrincipal const& rp,
115  EventSetup const& c,
116  ModuleCallingContext const* mcc) override final {
118  Run r(rp, moduleDescription(), mcc);
119  r.setConsumer(consumer());
120  Run const& cnstR = r;
121  RunIndex ri = rp.index();
122  MyGlobalRun::beginRun(cnstR,c,m_global.get(),m_runs[ri]);
123  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
124  MyGlobalRunSummary::beginRun(cnstR,c,&rc,m_runSummaries[ri]);
125  }
126  }
127  void doEndRun(RunPrincipal const& rp,
128  EventSetup const& c,
129  ModuleCallingContext const* mcc) override final
130  {
132 
133  Run r(rp, moduleDescription(), mcc);
134  r.setConsumer(consumer());
135 
136  RunIndex ri = rp.index();
137  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
138  MyGlobalRunSummary::globalEndRun(r,c,&rc,m_runSummaries[ri].get());
139  MyGlobalRun::endRun(r,c,&rc);
140  }
141  }
142 
144  EventSetup const& c,
145  ModuleCallingContext const* mcc) override final
146  {
148  LuminosityBlock lb(lbp, moduleDescription(), mcc);
149  lb.setConsumer(consumer());
150  LuminosityBlock const& cnstLb = lb;
151  LuminosityBlockIndex li = lbp.index();
152  RunIndex ri = lbp.runPrincipal().index();
153  typename T::RunContext rc(m_runs[ri].get(),m_global.get());
154  MyGlobalLuminosityBlock::beginLuminosityBlock(cnstLb,c,&rc,m_lumis[li]);
155  typename T::LuminosityBlockContext lc(m_lumis[li].get(),m_runs[ri].get(),m_global.get());
156  MyGlobalLuminosityBlockSummary::beginLuminosityBlock(cnstLb,c,&lc,m_lumiSummaries[li]);
157  }
158 
159  }
161  EventSetup const& c,
162  ModuleCallingContext const* mcc) override final {
164 
165  LuminosityBlock lb(lbp, moduleDescription(), mcc);
166  lb.setConsumer(consumer());
167 
168  LuminosityBlockIndex li = lbp.index();
169  RunIndex ri = lbp.runPrincipal().index();
170  typename T::LuminosityBlockContext lc(m_lumis[li].get(),m_runs[ri].get(),m_global.get());
171  MyGlobalLuminosityBlockSummary::globalEndLuminosityBlock(lb,c,&lc,m_lumiSummaries[li].get());
172  MyGlobalLuminosityBlock::endLuminosityBlock(lb,c,&lc);
173  }
174  }
175 
176  EDAnalyzerAdaptor(const EDAnalyzerAdaptor&); // stop default
177 
178  const EDAnalyzerAdaptor& operator=(const EDAnalyzerAdaptor&); // stop default
179 
180  // ---------- member data --------------------------------
189  };
190  }
191 
192  template<>
194  {
196  public:
197  template<typename ModType>
198  static std::unique_ptr<Base> makeModule(ParameterSet const& pset) {
199  typedef typename stream::BaseToAdaptor<Base,ModType>::Type Adaptor;
200  auto module = std::make_unique<Adaptor>(pset);
201  return std::unique_ptr<Base>(module.release());
202  }
203  };
204 
205 }
206 
207 #endif
void setupLuminosityBlock(EDAnalyzerBase *iProd, LuminosityBlockIndex iIndex) override final
void doBeginRun(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override final
impl::choose_shared_vec< typename T::RunCache const >::type m_runs
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void setConsumer(EDConsumerBase const *iConsumer)
static std::unique_ptr< Base > makeModule(ParameterSet const &pset)
void setupRun(EDAnalyzerBase *iProd, RunIndex iIndex) override final
void doEndRun(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override final
impl::choose_unique_ptr< typename T::GlobalCache >::type m_global
impl::choose_shared_vec< typename T::RunSummaryCache >::type m_runSummaries
impl::choose_mutex< typename T::RunSummaryCache >::type m_runSummaryLock
CallGlobalLuminosityBlock< T > MyGlobalLuminosityBlock
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 setupStreamModules() override final
impl::choose_shared_vec< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaries
EDAnalyzerAdaptor(edm::ParameterSet const &iPSet)
void streamEndRunSummary(EDAnalyzerBase *iProd, edm::Run const &iRun, edm::EventSetup const &iES) override final
impl::choose_shared_vec< typename T::LuminosityBlockCache const >::type m_lumis
void doEndLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetup const &c, ModuleCallingContext const *mcc) override final
CallGlobalLuminosityBlockSummary< T > MyGlobalLuminosityBlockSummary
void doEndJob() override final
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
impl::choose_mutex< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaryLock
HLT enums.
std::vector< std::shared_ptr< T > > type
Definition: dummy_helpers.h:64
void streamEndLuminosityBlockSummary(EDAnalyzerBase *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES) override final
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetup const &c, ModuleCallingContext const *mcc) override final
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:49
CallGlobalRunSummary< T > MyGlobalRunSummary
Definition: vlib.h:208
Definition: Run.h:42
static void prevalidate(ConfigurationDescriptions &descriptions)