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 preallocLumis(unsigned int iNLumis) final {
100  m_lumis.resize(iNLumis);
101  m_lumiSummaries.resize(iNLumis);
102  }
103 
104  void doBeginJob() final { MyGlobal::beginJob(m_global.get()); }
105  void doEndJob() final { MyGlobal::endJob(m_global.get()); }
106  void setupRun(EDAnalyzerBase* iProd, RunIndex iIndex) final { MyGlobalRun::set(iProd, m_runs[iIndex].get()); }
107  void streamEndRunSummary(EDAnalyzerBase* iProd, edm::Run const& iRun, edm::EventSetup const& iES) final {
108  auto s = m_runSummaries[iRun.index()].get();
109  std::lock_guard<decltype(m_runSummaryLock)> guard(m_runSummaryLock);
110  MyGlobalRunSummary::streamEndRunSummary(iProd, iRun, iES, s);
111  }
112 
114  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
115  }
117  edm::LuminosityBlock const& iLumi,
118  edm::EventSetup const& iES) final {
119  auto s = m_lumiSummaries[iLumi.index()].get();
120  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
122  }
123 
125  if constexpr (T::HasAbility::kWatchProcessBlock) {
126  ProcessBlock processBlock(pbp, moduleDescription(), mcc, false);
127  processBlock.setConsumer(consumer());
128  ProcessBlock const& cnstProcessBlock = processBlock;
129  MyWatchProcessBlock::beginProcessBlock(cnstProcessBlock, m_global.get());
130  }
131  }
132 
134  if constexpr (T::HasAbility::kInputProcessBlockCache) {
135  ProcessBlock processBlock(pbp, moduleDescription(), mcc, false);
136  processBlock.setConsumer(consumer());
137  ProcessBlock const& cnstProcessBlock = processBlock;
139  }
140  }
141 
142  void doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) final {
143  if constexpr (T::HasAbility::kWatchProcessBlock) {
144  ProcessBlock processBlock(pbp, moduleDescription(), mcc, true);
145  processBlock.setConsumer(consumer());
146  ProcessBlock const& cnstProcessBlock = processBlock;
147  MyWatchProcessBlock::endProcessBlock(cnstProcessBlock, m_global.get());
148  }
149  }
150 
151  void doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
153  RunPrincipal const& rp = info.principal();
154  Run r(rp, moduleDescription(), mcc, false);
155  r.setConsumer(consumer());
156  Run const& cnstR = r;
157  RunIndex ri = rp.index();
158  ESParentContext pc{mcc};
159  const EventSetup c{info,
160  static_cast<unsigned int>(Transition::BeginRun),
162  pc};
163  MyGlobalRun::beginRun(cnstR, c, m_global.get(), m_runs[ri]);
164  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
166  }
167  }
168  void doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
170  RunPrincipal const& rp = info.principal();
171  Run r(rp, moduleDescription(), mcc, true);
172  r.setConsumer(consumer());
173 
174  RunIndex ri = rp.index();
175  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
176  ESParentContext pc{mcc};
177  const EventSetup c{info,
178  static_cast<unsigned int>(Transition::EndRun),
180  pc};
182  MyGlobalRun::endRun(r, c, &rc);
183  }
184  }
185 
188  LuminosityBlockPrincipal const& lbp = info.principal();
189  LuminosityBlock lb(lbp, moduleDescription(), mcc, false);
190  lb.setConsumer(consumer());
191  LuminosityBlock const& cnstLb = lb;
192  LuminosityBlockIndex li = lbp.index();
193  RunIndex ri = lbp.runPrincipal().index();
194  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
195  ESParentContext pc{mcc};
196  const EventSetup c{info,
197  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
199  pc};
201  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
203  }
204  }
207  LuminosityBlockPrincipal const& lbp = info.principal();
208  LuminosityBlock lb(lbp, moduleDescription(), mcc, true);
209  lb.setConsumer(consumer());
210 
211  LuminosityBlockIndex li = lbp.index();
212  RunIndex ri = lbp.runPrincipal().index();
213  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
214  ESParentContext pc{mcc};
215  const EventSetup c{info,
216  static_cast<unsigned int>(Transition::EndLuminosityBlock),
218  pc};
221  }
222  }
223 
225 
226  void selectInputProcessBlocks(ProductRegistry const& productRegistry,
227  ProcessBlockHelperBase const& processBlockHelperBase) final {
229  m_inputProcessBlocks, productRegistry, processBlockHelperBase, *consumer());
230  }
231 
232  // ---------- member data --------------------------------
242  };
243  } // namespace stream
244 
245  template <>
248 
249  public:
250  template <typename ModType>
251  static std::unique_ptr<Base> makeModule(ParameterSet const& pset) {
252  typedef typename stream::BaseToAdaptor<Base, ModType>::Type Adaptor;
253  auto module = std::make_unique<Adaptor>(pset);
254  return std::unique_ptr<Base>(module.release());
255  }
256  };
257 
258 } // namespace edm
259 
260 #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:57
EDAnalyzerAdaptor(edm::ParameterSet const &iPSet)
void selectInputProcessBlocks(ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase) final
static void set(B *iProd, typename T::LuminosityBlockCache const *iCache)
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)