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
34 
35 // forward declarations
36 
37 namespace edm {
38  namespace stream {
39 
40  template <typename ABase, typename ModType>
41  struct BaseToAdaptor;
42 
43  template <typename T>
45  template <typename ModType>
48  };
49 
50  template <typename T>
52  public:
53  EDAnalyzerAdaptor(edm::ParameterSet const& iPSet) : m_pset(&iPSet) {
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 = impl::makeGlobal<T>(iPSet, dummy);
60  }
61  ~EDAnalyzerAdaptor() override {}
62 
63  static void fillDescriptions(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); }
64  static void prevalidate(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); }
65 
67  bool wantsGlobalLuminosityBlocks() const final {
69  }
70 
71  private:
77 
78  void setupStreamModules() final {
79  this->createStreamModules([this]() -> EDAnalyzerBase* {
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 
92  void doEndJob() final { MyGlobal::endJob(m_global.get()); }
93  void setupRun(EDAnalyzerBase* iProd, RunIndex iIndex) final { MyGlobalRun::set(iProd, m_runs[iIndex].get()); }
94  void streamEndRunSummary(EDAnalyzerBase* 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 
101  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
102  }
104  edm::LuminosityBlock const& iLumi,
105  edm::EventSetup const& iES) final {
106  auto s = m_lumiSummaries[iLumi.index()].get();
107  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
108  MyGlobalLuminosityBlockSummary::streamEndLuminosityBlockSummary(iProd, iLumi, iES, s);
109  }
110 
111  void doBeginRun(RunPrincipal const& rp, EventSetupImpl const& ci, ModuleCallingContext const* mcc) final {
113  Run r(rp, moduleDescription(), mcc, false);
114  r.setConsumer(consumer());
115  Run const& cnstR = r;
116  RunIndex ri = rp.index();
117  const EventSetup c{ci,
118  static_cast<unsigned int>(Transition::BeginRun),
119  this->consumer()->esGetTokenIndices(Transition::BeginRun)};
120  MyGlobalRun::beginRun(cnstR, c, m_global.get(), m_runs[ri]);
121  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
122  MyGlobalRunSummary::beginRun(cnstR, c, &rc, m_runSummaries[ri]);
123  }
124  }
125  void doEndRun(RunPrincipal const& rp, EventSetupImpl const& ci, ModuleCallingContext const* mcc) final {
127  Run r(rp, moduleDescription(), mcc, true);
128  r.setConsumer(consumer());
129 
130  RunIndex ri = rp.index();
131  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
132  const EventSetup c{ci,
133  static_cast<unsigned int>(Transition::EndRun),
134  this->consumer()->esGetTokenIndices(Transition::EndRun)};
135  MyGlobalRunSummary::globalEndRun(r, c, &rc, m_runSummaries[ri].get());
136  MyGlobalRun::endRun(r, c, &rc);
137  }
138  }
139 
141  EventSetupImpl const& ci,
142  ModuleCallingContext const* mcc) final {
144  LuminosityBlock lb(lbp, moduleDescription(), mcc, false);
145  lb.setConsumer(consumer());
146  LuminosityBlock const& cnstLb = lb;
147  LuminosityBlockIndex li = lbp.index();
148  RunIndex ri = lbp.runPrincipal().index();
149  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
150  const EventSetup c{ci,
151  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
152  this->consumer()->esGetTokenIndices(Transition::BeginLuminosityBlock)};
153  MyGlobalLuminosityBlock::beginLuminosityBlock(cnstLb, c, &rc, m_lumis[li]);
154  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
155  MyGlobalLuminosityBlockSummary::beginLuminosityBlock(cnstLb, c, &lc, m_lumiSummaries[li]);
156  }
157  }
159  EventSetupImpl const& ci,
160  ModuleCallingContext const* mcc) final {
162  LuminosityBlock lb(lbp, moduleDescription(), mcc, true);
163  lb.setConsumer(consumer());
164 
165  LuminosityBlockIndex li = lbp.index();
166  RunIndex ri = lbp.runPrincipal().index();
167  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
168  const EventSetup c{ci,
169  static_cast<unsigned int>(Transition::EndLuminosityBlock),
170  this->consumer()->esGetTokenIndices(Transition::EndLuminosityBlock)};
171  MyGlobalLuminosityBlockSummary::globalEndLuminosityBlock(lb, c, &lc, m_lumiSummaries[li].get());
172  MyGlobalLuminosityBlock::endLuminosityBlock(lb, c, &lc);
173  }
174  }
175 
176  EDAnalyzerAdaptor(const EDAnalyzerAdaptor&) = delete; // stop default
177 
178  const EDAnalyzerAdaptor& operator=(const EDAnalyzerAdaptor&) = delete; // stop default
179 
180  // ---------- member data --------------------------------
189  };
190  } // namespace stream
191 
192  template <>
195 
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 } // namespace edm
206 
207 #endif
void streamEndRunSummary(EDAnalyzerBase *iProd, edm::Run const &iRun, edm::EventSetup const &iES) 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 streamEndLuminosityBlockSummary(EDAnalyzerBase *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES) final
bool wantsGlobalRuns() const final
void doBeginRun(RunPrincipal const &rp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
void preallocLumis(unsigned int iNLumis) final
void setupLuminosityBlock(EDAnalyzerBase *iProd, LuminosityBlockIndex iIndex) 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
bool wantsGlobalLuminosityBlocks() const final
impl::choose_shared_vec< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaries
EDAnalyzerAdaptor(edm::ParameterSet const &iPSet)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void doEndRun(RunPrincipal const &rp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
impl::choose_shared_vec< typename T::LuminosityBlockCache const >::type m_lumis
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
CallGlobalLuminosityBlockSummary< T > MyGlobalLuminosityBlockSummary
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 setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:51
CallGlobalRunSummary< T > MyGlobalRunSummary
void doEndLuminosityBlock(LuminosityBlockPrincipal const &lbp, EventSetupImpl const &ci, ModuleCallingContext const *mcc) final
Definition: vlib.h:208
#define constexpr
void setupRun(EDAnalyzerBase *iProd, RunIndex iIndex) final
Definition: Run.h:45
static void prevalidate(ConfigurationDescriptions &descriptions)