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
37 
38 // forward declarations
39 
40 namespace edm {
41  namespace stream {
42 
43  template <typename ABase, typename ModType>
44  struct BaseToAdaptor;
45 
46  template <typename T>
48  template <typename ModType>
51  };
52 
53  template <typename T>
55  public:
56  EDAnalyzerAdaptor(edm::ParameterSet const& iPSet) : m_pset(&iPSet) {
57  m_runs.resize(1);
58  m_lumis.resize(1);
59  m_runSummaries.resize(1);
60  m_lumiSummaries.resize(1);
61  typename T::GlobalCache const* dummy = nullptr;
62  m_global = impl::makeGlobal<T>(iPSet, dummy);
63  typename T::InputProcessBlockCache const* dummyInputProcessBlockCacheImpl = nullptr;
64  m_inputProcessBlocks = impl::makeInputProcessBlockCacheImpl(dummyInputProcessBlockCacheImpl);
65  }
66  EDAnalyzerAdaptor(const EDAnalyzerAdaptor&) = delete; // stop default
67  const EDAnalyzerAdaptor& operator=(const EDAnalyzerAdaptor&) = delete; // stop default
69 
70  static void fillDescriptions(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); }
71  static void prevalidate(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); }
72 
73  bool wantsProcessBlocks() const final { return T::HasAbility::kWatchProcessBlock; }
74  bool wantsInputProcessBlocks() const final { return T::HasAbility::kInputProcessBlockCache; }
78  }
79 
80  private:
88 
89  void setupStreamModules() final {
90  this->createStreamModules([this](unsigned int iStreamModule) -> EDAnalyzerBase* {
91  auto tmp = impl::makeStreamModule<T>(*m_pset, m_global.get());
92  MyGlobal::set(tmp, m_global.get());
94  return tmp;
95  });
96  m_pset = nullptr;
97  }
98 
99  void preallocRuns(unsigned int iNRuns) final {
100  m_runs.resize(iNRuns);
101  m_runSummaries.resize(iNRuns);
102  }
103  void preallocLumis(unsigned int iNLumis) final {
104  m_lumis.resize(iNLumis);
105  m_lumiSummaries.resize(iNLumis);
106  }
107 
108  void doBeginJob() final { MyGlobal::beginJob(m_global.get()); }
109  void doEndJob() final { MyGlobal::endJob(m_global.get()); }
110  void setupRun(EDAnalyzerBase* iProd, RunIndex iIndex) final { MyGlobalRun::set(iProd, m_runs[iIndex].get()); }
111  void streamEndRunSummary(EDAnalyzerBase* iProd, edm::Run const& iRun, edm::EventSetup const& iES) final {
112  auto s = m_runSummaries[iRun.index()].get();
113  std::lock_guard<decltype(m_runSummaryLock)> guard(m_runSummaryLock);
114  MyGlobalRunSummary::streamEndRunSummary(iProd, iRun, iES, s);
115  }
116 
118  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
119  }
121  edm::LuminosityBlock const& iLumi,
122  edm::EventSetup const& iES) final {
123  auto s = m_lumiSummaries[iLumi.index()].get();
124  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
126  }
127 
129  if constexpr (T::HasAbility::kWatchProcessBlock) {
130  ProcessBlock processBlock(pbp, moduleDescription(), mcc, false);
131  processBlock.setConsumer(consumer());
132  ProcessBlock const& cnstProcessBlock = processBlock;
133  MyWatchProcessBlock::beginProcessBlock(cnstProcessBlock, m_global.get());
134  }
135  }
136 
138  if constexpr (T::HasAbility::kInputProcessBlockCache) {
139  ProcessBlock processBlock(pbp, moduleDescription(), mcc, false);
140  processBlock.setConsumer(consumer());
141  ProcessBlock const& cnstProcessBlock = processBlock;
143  }
144  }
145 
146  void doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) final {
147  if constexpr (T::HasAbility::kWatchProcessBlock) {
148  ProcessBlock processBlock(pbp, moduleDescription(), mcc, true);
149  processBlock.setConsumer(consumer());
150  ProcessBlock const& cnstProcessBlock = processBlock;
151  MyWatchProcessBlock::endProcessBlock(cnstProcessBlock, m_global.get());
152  }
153  }
154 
155  void doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
157  RunPrincipal const& rp = info.principal();
158  Run r(rp, moduleDescription(), mcc, false);
159  r.setConsumer(consumer());
160  Run const& cnstR = r;
161  RunIndex ri = rp.index();
162  ESParentContext pc{mcc};
163  const EventSetup c{info,
164  static_cast<unsigned int>(Transition::BeginRun),
166  pc};
167  MyGlobalRun::beginRun(cnstR, c, m_global.get(), m_runs[ri]);
168  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
170  }
171  }
172  void doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
174  RunPrincipal const& rp = info.principal();
175  Run r(rp, moduleDescription(), mcc, true);
176  r.setConsumer(consumer());
177 
178  RunIndex ri = rp.index();
179  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
180  ESParentContext pc{mcc};
181  const EventSetup c{info,
182  static_cast<unsigned int>(Transition::EndRun),
184  pc};
186  MyGlobalRun::endRun(r, c, &rc);
187  }
188  }
189 
192  LuminosityBlockPrincipal const& lbp = info.principal();
193  LuminosityBlock lb(lbp, moduleDescription(), mcc, false);
194  lb.setConsumer(consumer());
195  LuminosityBlock const& cnstLb = lb;
196  LuminosityBlockIndex li = lbp.index();
197  RunIndex ri = lbp.runPrincipal().index();
198  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
199  ESParentContext pc{mcc};
200  const EventSetup c{info,
201  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
203  pc};
205  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
207  }
208  }
211  LuminosityBlockPrincipal const& lbp = info.principal();
212  LuminosityBlock lb(lbp, moduleDescription(), mcc, true);
213  lb.setConsumer(consumer());
214 
215  LuminosityBlockIndex li = lbp.index();
216  RunIndex ri = lbp.runPrincipal().index();
217  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
218  ESParentContext pc{mcc};
219  const EventSetup c{info,
220  static_cast<unsigned int>(Transition::EndLuminosityBlock),
222  pc};
225  }
226  }
227 
229 
230  void selectInputProcessBlocks(ProductRegistry const& productRegistry,
231  ProcessBlockHelperBase const& processBlockHelperBase) final {
233  m_inputProcessBlocks, productRegistry, processBlockHelperBase, *consumer());
234  }
235 
236  // ---------- member data --------------------------------
246  };
247  } // namespace stream
248 
249  template <>
252 
253  public:
254  template <typename ModType>
255  static std::unique_ptr<Base> makeModule(ParameterSet const& pset) {
256  typedef typename stream::BaseToAdaptor<Base, ModType>::Type Adaptor;
257  auto module = std::make_unique<Adaptor>(pset);
258  return std::unique_ptr<Base>(module.release());
259  }
260  };
261 
262 } // namespace edm
263 
264 #endif
static void endLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext)
void streamEndRunSummary(EDAnalyzerBase *iProd, edm::Run const &iRun, edm::EventSetup const &iES) final
static void beginProcessBlock(edm::ProcessBlock const &iProcessBlock, typename T::GlobalCache *iGC)
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)
impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type m_inputProcessBlocks
static const TGPicture * info(bool iBackgroundIsBlack)
void setConsumer(EDConsumerBase const *iConsumer)
std::unique_ptr< G > makeInputProcessBlockCacheImpl(G const *)
Definition: makeGlobal.h:49
static void endRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext)
void doBeginRun(RunTransitionInfo const &info, ModuleCallingContext const *mcc) final
static std::unique_ptr< Base > makeModule(ParameterSet const &pset)
static void beginRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::GlobalCache const *iGC, std::shared_ptr< typename T::RunCache const > &oCache)
bool wantsInputProcessBlocks() const final
RunPrincipal const & runPrincipal() const
void streamEndLuminosityBlockSummary(EDAnalyzerBase *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES) final
void preallocLumis(unsigned int iNLumis) final
static void set(T *iProd, typename impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type const *iCaches, unsigned int iStreamModule)
Definition: callAbilities.h:76
static void selectInputProcessBlocks(typename impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type &iCaches, ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase, EDConsumerBase const &edConsumerBase)
Definition: callAbilities.h:86
ESProxyIndex const * esGetTokenIndices(edm::Transition iTrans) const
static void clearCaches(typename impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type &iCaches)
static void streamEndRunSummary(B *iProd, edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunSummaryCache *iCache)
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
static void accessInputProcessBlock(edm::ProcessBlock const &processBlock, typename T::GlobalCache *iGC, typename impl::choose_unique_ptr< typename T::InputProcessBlockCache >::type &iCaches)
Definition: callAbilities.h:94
void doEndRun(RunTransitionInfo const &info, ModuleCallingContext const *mcc) final
void doBeginProcessBlock(ProcessBlockPrincipal const &pbp, ModuleCallingContext const *mcc) final
static void set(B *iProd, typename T::RunCache const *iCache)
void setupLuminosityBlock(EDAnalyzerBase *iProd, LuminosityBlockIndex iIndex) final
bool wantsGlobalLuminosityBlocks() const final
static void beginLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::LuminosityBlockCache const > &oCache)
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)
void doAccessInputProcessBlock(ProcessBlockPrincipal const &pbp, ModuleCallingContext const *mcc) final
impl::choose_shared_vec< typename T::RunSummaryCache >::type m_runSummaries
const EDConsumerBase * consumer() const
void setConsumer(EDConsumerBase const *iConsumer)
Definition: ProcessBlock.h:53
const ModuleDescription & moduleDescription() const
impl::choose_mutex< typename T::RunSummaryCache >::type m_runSummaryLock
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::LuminosityBlockSummaryCache >::type m_lumiSummaries
RunIndex index() const
Definition: RunPrincipal.h:56
EDAnalyzerAdaptor(edm::ParameterSet const &iPSet)
void selectInputProcessBlocks(ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase) final
static void set(B *iProd, typename T::LuminosityBlockCache const *iCache)
void preallocRuns(unsigned int iNRuns) final
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
impl::choose_shared_vec< typename T::LuminosityBlockCache const >::type m_lumis
static void endJob(typename T::GlobalCache *iCache)
Definition: callAbilities.h:59
static void streamEndLuminosityBlockSummary(B *iProd, edm::LuminosityBlock const &iLumi, edm::EventSetup const &iES, typename T::LuminosityBlockSummaryCache *iCache)
void doEndProcessBlock(ProcessBlockPrincipal const &pbp, ModuleCallingContext const *mcc) final
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::RunContext const *iContext, typename T::RunSummaryCache *iCache)
bool wantsProcessBlocks() const final
impl::choose_mutex< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaryLock
HLT enums.
LuminosityBlockIndex index() const
static void beginJob(typename T::GlobalCache *iCache)
Definition: callAbilities.h:54
std::vector< std::shared_ptr< T > > type
Definition: dummy_helpers.h:64
void doEndLuminosityBlock(LumiTransitionInfo const &info, ModuleCallingContext const *mcc) final
static void globalEndLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::LuminosityBlockContext const *iContext, typename T::LuminosityBlockSummaryCache *iCache)
tmp
align.sh
Definition: createJobs.py:716
const EDAnalyzerAdaptor & operator=(const EDAnalyzerAdaptor &)=delete
bool wantsGlobalRuns() const final
void doBeginLuminosityBlock(LumiTransitionInfo const &info, ModuleCallingContext const *mcc) final
static void set(B *iProd, typename T::GlobalCache const *iCache)
Definition: callAbilities.h:51
void setupRun(EDAnalyzerBase *iProd, RunIndex iIndex) final
Definition: Run.h:45
static void endProcessBlock(edm::ProcessBlock const &iProcessBlock, typename T::GlobalCache *iGC)
static void prevalidate(ConfigurationDescriptions &descriptions)