-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Base classes for refactor of CondTools/Hcal PopConAnalyzers and PopConSourceHandlers #49905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,6 @@ | ||
| #ifndef CastorElectronicsMapHandler_h | ||
| #define CastorElectronicsMapHandler_h | ||
| #pragma once | ||
|
|
||
| // Radek Ofierzynski, 27.02.2008 | ||
| // Adapted for CASTOR by L. Mundim (26/03/2009) | ||
|
|
||
| #include <string> | ||
| #include <iostream> | ||
| #include <typeinfo> | ||
| #include <fstream> | ||
|
|
||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| #include "CondCore/PopCon/interface/PopConSourceHandler.h" | ||
|
|
||
| #include "FWCore/Framework/interface/Event.h" | ||
| #include "DataFormats/Common/interface/Handle.h" | ||
| #include "FWCore/Framework/interface/EventSetup.h" | ||
| // user include files | ||
| #include "CondTools/Hcal/interface/SinglePayloadPopConHandler.h" | ||
| #include "CondFormats/CastorObjects/interface/CastorElectronicsMap.h" | ||
| #include "CondFormats/DataRecord/interface/CastorElectronicsMapRcd.h" | ||
| #include "CalibCalorimetry/CastorCalib/interface/CastorDbASCIIIO.h" | ||
|
|
||
| class CastorElectronicsMapHandler : public popcon::PopConSourceHandler<CastorElectronicsMap> { | ||
| public: | ||
| void getNewObjects() override; | ||
| std::string id() const override { return m_name; } | ||
| ~CastorElectronicsMapHandler() override; | ||
| CastorElectronicsMapHandler(edm::ParameterSet const&); | ||
|
|
||
| void initObject(CastorElectronicsMap*); | ||
|
|
||
| private: | ||
| unsigned int sinceTime; | ||
| edm::FileInPath fFile; | ||
| CastorElectronicsMap* myDBObject; | ||
| std::string m_name; | ||
| }; | ||
| #endif | ||
| typedef SinglePayloadPopConHandler<CastorElectronicsMap> CastorElectronicsMapHandler; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include "CondCore/PopCon/interface/PopConAnalyzer.h" | ||
| #include "FWCore/Framework/interface/EventSetup.h" | ||
|
|
||
| template <typename T> | ||
| concept CanAcceptPayload = requires(T& h, std::unique_ptr<typename T::value_type> p) { | ||
| typename T::value_type; | ||
| { h.initPayload(std::move(p)) }; | ||
| }; | ||
|
|
||
| template <CanAcceptPayload SourceHandler, typename PayloadRcd> | ||
| class EventSetupPayloadPopConAnalyzer : public popcon::PopConAnalyzer<SourceHandler> { | ||
| public: | ||
| using Payload = typename SourceHandler::value_type; | ||
|
|
||
| EventSetupPayloadPopConAnalyzer(const edm::ParameterSet& pset) | ||
| : popcon::PopConAnalyzer<SourceHandler>(pset), m_token(this->template esConsumes<Payload, PayloadRcd>()) {} | ||
|
|
||
| private: | ||
| void analyze(const edm::Event& ev, const edm::EventSetup& esetup) override { | ||
| // TODO confirm that all use cases are meant to have this run only once: | ||
| // then throw exception if run more than once | ||
| // and rename the class to include "Single" | ||
|
Comment on lines
+23
to
+25
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only thing left for this PR to be ready: @igv4321 since you have a relvant PopConAnalyzer in your PR #49556, can you confirm that the use cases in HCal for these clases are meant to have analyzer run only once? Or maybe tag someone from HCal who could confirm it? Then I can go ahead and implement throwing on multiple executions of analyze
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I can confirm that "analyze" method in HcalPulseDelaysPopConAnalyzer is intended to run only once. But I can't vouch for every such class in CondTools/Hcal/plugins, I don't have time to look through all that code and figure out all possible use cases. |
||
|
|
||
| //Using ES to get the data: | ||
| this->source().initPayload(std::make_unique<Payload>(esetup.getData(m_token))); | ||
| } | ||
|
|
||
| private: | ||
| edm::ESGetToken<Payload, PayloadRcd> m_token; | ||
| }; | ||
JanChyczynski marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #pragma once | ||
|
|
||
| #include "CondCore/PopCon/interface/PopConSourceHandler.h" | ||
| #include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
| #include "FWCore/Utilities/interface/Exception.h" | ||
| #include <memory> | ||
| #include <string> | ||
| #include <typeinfo> | ||
|
|
||
| template <typename Payload> | ||
| class SinglePayloadPopConHandler : public popcon::PopConSourceHandler<Payload> { | ||
| public: | ||
| SinglePayloadPopConHandler(edm::ParameterSet const& ps) | ||
| : m_name(ps.getUntrackedParameter<std::string>( | ||
| "name", std::string("SinglePayloadPopConHandler<") + typeid(Payload).name() + ">")), | ||
| m_sinceTime(ps.getUntrackedParameter<unsigned>("IOVRun", 0)) {} | ||
|
|
||
| void getNewObjects() override { | ||
| edm::LogInfo(m_name) << "------- " << m_name << " - > getNewObjects\n" | ||
| << "got offlineInfo " << this->tagInfo().name << ", size " << this->tagInfo().size | ||
| << ", last object valid since " << this->tagInfo().lastInterval.since; | ||
|
|
||
| if (!m_payload) { | ||
| throw cms::Exception("Empty DB object") << m_name << " has received empty object - nothing to write to DB"; | ||
| } | ||
|
|
||
| edm::LogInfo(m_name) << "Using IOV run " << m_sinceTime; | ||
|
|
||
| // prepare for transfer: | ||
| this->m_iovs.emplace(m_sinceTime, std::shared_ptr<Payload>(std::move(m_payload))); | ||
|
|
||
| edm::LogInfo(m_name) << "------- " << m_name << " - > getNewObjects" << std::endl; | ||
| } | ||
|
|
||
| std::string id() const override { return m_name; } | ||
|
|
||
| void initPayload(std::unique_ptr<Payload> payload) { m_payload = std::move(payload); } | ||
|
|
||
| private: | ||
| std::string m_name; | ||
| unsigned int m_sinceTime; | ||
| std::unique_ptr<Payload> m_payload; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,10 @@ | ||
| #include "CondCore/PopCon/interface/PopConAnalyzer.h" | ||
| #include "CondFormats/CastorObjects/interface/CastorElectronicsMap.h" | ||
| #include "CondFormats/DataRecord/interface/CastorElectronicsMapRcd.h" | ||
| #include "CondTools/Hcal/interface/EventSetupPayloadPopConAnalyzer.h" | ||
| #include "CondTools/Hcal/interface/CastorElectronicsMapHandler.h" | ||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
|
|
||
| //typedef popcon::PopConAnalyzer<CastorElectronicsMapHandler> CastorElectronicsMapPopConAnalyzer; | ||
|
|
||
| class CastorElectronicsMapPopConAnalyzer : public popcon::PopConAnalyzer<CastorElectronicsMapHandler> { | ||
| public: | ||
| typedef CastorElectronicsMapHandler SourceHandler; | ||
|
|
||
| CastorElectronicsMapPopConAnalyzer(const edm::ParameterSet& pset) | ||
| : popcon::PopConAnalyzer<CastorElectronicsMapHandler>(pset), | ||
| m_populator(pset), | ||
| m_source(pset.getParameter<edm::ParameterSet>("Source")), | ||
| m_tok(esConsumes<CastorElectronicsMap, CastorElectronicsMapRcd>()) {} | ||
|
|
||
| private: | ||
| void endJob() override { | ||
| m_source.initObject(myDBObject); | ||
| write(); | ||
| } | ||
|
|
||
| void analyze(const edm::Event& ev, const edm::EventSetup& esetup) override { | ||
| //Using ES to get the data: | ||
|
|
||
| myDBObject = new CastorElectronicsMap(esetup.getData(m_tok)); | ||
| } | ||
|
|
||
| void write() { m_populator.write(m_source); } | ||
|
|
||
| private: | ||
| popcon::PopCon m_populator; | ||
| SourceHandler m_source; | ||
| edm::ESGetToken<CastorElectronicsMap, CastorElectronicsMapRcd> m_tok; | ||
|
|
||
| CastorElectronicsMap* myDBObject; | ||
| }; | ||
| typedef EventSetupPayloadPopConAnalyzer<CastorElectronicsMapHandler, CastorElectronicsMapRcd> | ||
| CastorElectronicsMapPopConAnalyzer; | ||
|
|
||
| DEFINE_FWK_MODULE(CastorElectronicsMapPopConAnalyzer); |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.