-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DRAFT: 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
Draft
JanChyczynski
wants to merge
2
commits into
cms-sw:master
Choose a base branch
from
cms-AlCaDB:ES_PopConAnalyzer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
33 changes: 33 additions & 0 deletions
33
CondTools/Hcal/interface/EventSetupPayloadPopConAnalyzer.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
|
|
||
| //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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #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; | ||
| }; |
39 changes: 5 additions & 34 deletions
39
CondTools/Hcal/plugins/CastorElectronicsMapPopConAnalyzer.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.