CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  false};
164  MyGlobalRun::beginRun(cnstR, c, m_global.get(), m_runs[ri]);
165  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
167  }
168  }
169  void doEndRun(RunTransitionInfo const& info, ModuleCallingContext const* mcc) final {
171  RunPrincipal const& rp = info.principal();
172  Run r(rp, moduleDescription(), mcc, true);
173  r.setConsumer(consumer());
174 
175  RunIndex ri = rp.index();
176  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
177  ESParentContext pc{mcc};
178  const EventSetup c{info,
179  static_cast<unsigned int>(Transition::EndRun),
181  pc,
182  false};
184  MyGlobalRun::endRun(r, c, &rc);
185  }
186  }
187 
190  LuminosityBlockPrincipal const& lbp = info.principal();
191  LuminosityBlock lb(lbp, moduleDescription(), mcc, false);
192  lb.setConsumer(consumer());
193  LuminosityBlock const& cnstLb = lb;
194  LuminosityBlockIndex li = lbp.index();
195  RunIndex ri = lbp.runPrincipal().index();
196  typename T::RunContext rc(m_runs[ri].get(), m_global.get());
197  ESParentContext pc{mcc};
198  const EventSetup c{info,
199  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
201  pc,
202  false};
204  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
206  }
207  }
210  LuminosityBlockPrincipal const& lbp = info.principal();
211  LuminosityBlock lb(lbp, moduleDescription(), mcc, true);
212  lb.setConsumer(consumer());
213 
214  LuminosityBlockIndex li = lbp.index();
215  RunIndex ri = lbp.runPrincipal().index();
216  typename T::LuminosityBlockContext lc(m_lumis[li].get(), m_runs[ri].get(), m_global.get());
217  ESParentContext pc{mcc};
218  const EventSetup c{info,
219  static_cast<unsigned int>(Transition::EndLuminosityBlock),
221  pc,
222  false};
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)
RunPrincipal const & runPrincipal() const
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)
const edm::EventSetup & c
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
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
static std::unique_ptr< Base > makeModule(ParameterSet const &pset)
const EDConsumerBase * consumer() const
bool wantsInputProcessBlocks() const final
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)
LuminosityBlockIndex index() const
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 beginRun(edm::Run const &iRun, edm::EventSetup const &iES, typename T::GlobalCache const *iGC, std::shared_ptr< typename T::RunCache const > &oCache)
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
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
void setConsumer(EDConsumerBase const *iConsumer)
Definition: ProcessBlock.h:53
impl::choose_mutex< typename T::RunSummaryCache >::type m_runSummaryLock
impl::choose_shared_vec< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaries
EDAnalyzerAdaptor(edm::ParameterSet const &iPSet)
void selectInputProcessBlocks(ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase) final
static void set(B *iProd, typename T::LuminosityBlockCache const *iCache)
const ModuleDescription & moduleDescription() const
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)
RunIndex index() const
Definition: RunPrincipal.h:57
bool wantsProcessBlocks() const final
impl::choose_mutex< typename T::LuminosityBlockSummaryCache >::type m_lumiSummaryLock
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
static void beginLuminosityBlock(edm::LuminosityBlock const &Lumi, edm::EventSetup const &iES, typename T::RunContext const *iRC, std::shared_ptr< typename T::LuminosityBlockCache const > &oCache)
const EDAnalyzerAdaptor & operator=(const EDAnalyzerAdaptor &)=delete
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:52
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)
tuple module
Definition: callgraph.py:69
static void prevalidate(ConfigurationDescriptions &descriptions)
ESProxyIndex const * esGetTokenIndices(edm::Transition iTrans) const