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; }
75  bool wantsGlobalRuns() const final { return T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache; }
76  bool wantsStreamRuns() const final { return T::HasAbility::kWatchRuns; }
78  return T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache;
79  }
80  bool wantsStreamLuminosityBlocks() const final { return T::HasAbility::kWatchLuminosityBlocks; }
81 
82  private:
90 
91  void setupStreamModules() final {
92  this->createStreamModules([this](unsigned int iStreamModule) -> EDAnalyzerBase* {
93  auto tmp = impl::makeStreamModule<T>(*m_pset, m_global.get());
94  MyGlobal::set(tmp, m_global.get());
96  return tmp;
97  });
98  m_pset = nullptr;
99  }
100 
101  void preallocRuns(unsigned int iNRuns) final {
102  m_runs.resize(iNRuns);
103  m_runSummaries.resize(iNRuns);
104  }
105  void preallocLumis(unsigned int iNLumis) final {
106  m_lumis.resize(iNLumis);
107  m_lumiSummaries.resize(iNLumis);
108  }
109 
110  void doBeginJob() final { MyGlobal::beginJob(m_global.get()); }
111  void doEndJob() final { MyGlobal::endJob(m_global.get()); }
112  void setupRun(EDAnalyzerBase* iProd, RunIndex iIndex) final { MyGlobalRun::set(iProd, m_runs[iIndex].get()); }
113  void streamEndRunSummary(EDAnalyzerBase* iProd, edm::Run const& iRun, edm::EventSetup const& iES) final {
114  auto s = m_runSummaries[iRun.index()].get();
115  std::lock_guard<decltype(m_runSummaryLock)> guard(m_runSummaryLock);
116  MyGlobalRunSummary::streamEndRunSummary(iProd, iRun, iES, s);
117  }
118 
120  MyGlobalLuminosityBlock::set(iProd, m_lumis[iIndex].get());
121  }
123  edm::LuminosityBlock const& iLumi,
124  edm::EventSetup const& iES) final {
125  auto s = m_lumiSummaries[iLumi.index()].get();
126  std::lock_guard<decltype(m_lumiSummaryLock)> guard(m_lumiSummaryLock);
128  }
129 
131  if constexpr (T::HasAbility::kWatchProcessBlock) {
132  ProcessBlock processBlock(pbp, moduleDescription(), mcc, false);
133  processBlock.setConsumer(consumer());
134  ProcessBlock const& cnstProcessBlock = processBlock;
135  MyWatchProcessBlock::beginProcessBlock(cnstProcessBlock, m_global.get());
136  }
137  }
138 
140  if constexpr (T::HasAbility::kInputProcessBlockCache) {
141  ProcessBlock processBlock(pbp, moduleDescription(), mcc, false);
142  processBlock.setConsumer(consumer());
143  ProcessBlock const& cnstProcessBlock = processBlock;
145  }
146  }
147 
148  void doEndProcessBlock(ProcessBlockPrincipal const& pbp, ModuleCallingContext const* mcc) final {
149  if constexpr (T::HasAbility::kWatchProcessBlock) {
150  ProcessBlock processBlock(pbp, moduleDescription(), mcc, true);
151  processBlock.setConsumer(consumer());
152  ProcessBlock const& cnstProcessBlock = processBlock;
153  MyWatchProcessBlock::endProcessBlock(cnstProcessBlock, m_global.get());
154  }
155  }
156 
157  void doBeginRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
158  if constexpr (T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache) {
159  RunPrincipal const& rp = info.principal();
160  Run r(rp, moduleDescription(), mcc, false);
161  r.setConsumer(consumer());
162  Run const& cnstR = r;
163  RunIndex ri = rp.index();
164  ESParentContext pc{mcc};
165  const EventSetup c{info,
166  static_cast<unsigned int>(Transition::BeginRun),
168  pc};
169  MyGlobalRun::beginRun(cnstR, c, m_global.get(), m_runs[ri]);
170  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
172  }
173  }
174  void doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
175  if constexpr (T::HasAbility::kRunCache or T::HasAbility::kRunSummaryCache) {
176  RunPrincipal const& rp = info.principal();
177  Run r(rp, moduleDescription(), mcc, true);
178  r.setConsumer(consumer());
179 
180  RunIndex ri = rp.index();
181  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
182  ESParentContext pc{mcc};
183  const EventSetup c{info,
184  static_cast<unsigned int>(Transition::EndRun),
186  pc};
188  MyGlobalRun::endRun(r, c, &rc);
189  }
190  }
191 
193  if constexpr (T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache) {
194  LuminosityBlockPrincipal const& lbp = info.principal();
195  LuminosityBlock lb(lbp, moduleDescription(), mcc, false);
196  lb.setConsumer(consumer());
197  LuminosityBlock const& cnstLb = lb;
198  LuminosityBlockIndex li = lbp.index();
199  RunIndex ri = lbp.runPrincipal().index();
200  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
201  ESParentContext pc{mcc};
202  const EventSetup c{info,
203  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
205  pc};
207  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
209  }
210  }
212  if constexpr (T::HasAbility::kLuminosityBlockCache or T::HasAbility::kLuminosityBlockSummaryCache) {
213  LuminosityBlockPrincipal const& lbp = info.principal();
214  LuminosityBlock lb(lbp, moduleDescription(), mcc, true);
215  lb.setConsumer(consumer());
216 
217  LuminosityBlockIndex li = lbp.index();
218  RunIndex ri = lbp.runPrincipal().index();
219  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
220  ESParentContext pc{mcc};
221  const EventSetup c{info,
222  static_cast<unsigned int>(Transition::EndLuminosityBlock),
224  pc};
227  }
228  }
229 
231 
232  void selectInputProcessBlocks(ProductRegistry const& productRegistry,
233  ProcessBlockHelperBase const& processBlockHelperBase) final {
235  m_inputProcessBlocks, productRegistry, processBlockHelperBase, *consumer());
236  }
237 
238  // ---------- member data --------------------------------
248  };
249  } // namespace stream
250 
251  template <>
254 
255  public:
256  template <typename ModType>
257  static std::unique_ptr<Base> makeModule(ParameterSet const& pset) {
258  typedef typename stream::BaseToAdaptor<Base, ModType>::Type Adaptor;
259  auto module = std::make_unique<Adaptor>(pset);
260  return std::unique_ptr<Base>(module.release());
261  }
262  };
263 
264 } // namespace edm
265 
266 #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
bool wantsStreamRuns() const 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
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
ESResolverIndex const * esGetTokenIndices(edm::Transition iTrans) 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
bool wantsStreamLuminosityBlocks() const final
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)