diff --git a/L1Trigger/RegionalCaloTrigger/interface/L1RCTInputProducer.h b/L1Trigger/RegionalCaloTrigger/interface/L1RCTInputProducer.h index da2a4afe3e3a6..b75422c6e0fd2 100644 --- a/L1Trigger/RegionalCaloTrigger/interface/L1RCTInputProducer.h +++ b/L1Trigger/RegionalCaloTrigger/interface/L1RCTInputProducer.h @@ -1,7 +1,7 @@ #ifndef L1RCTInputProducer_h #define L1RCTInputProducer_h -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -27,7 +27,7 @@ class L1RCT; class L1RCTLookupTables; -class L1RCTInputProducer : public edm::EDProducer { +class L1RCTInputProducer : public edm::stream::EDProducer<> { public: explicit L1RCTInputProducer(const edm::ParameterSet &ps); ~L1RCTInputProducer() override; diff --git a/L1Trigger/RegionalCaloTrigger/interface/L1RCTLutWriter.h b/L1Trigger/RegionalCaloTrigger/interface/L1RCTLutWriter.h index 6c156959db005..fa4abea30b7d0 100644 --- a/L1Trigger/RegionalCaloTrigger/interface/L1RCTLutWriter.h +++ b/L1Trigger/RegionalCaloTrigger/interface/L1RCTLutWriter.h @@ -27,7 +27,7 @@ #include // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" @@ -56,7 +56,7 @@ class L1RCTParameters; // class declaration // -class L1RCTLutWriter : public edm::EDAnalyzer { +class L1RCTLutWriter : public edm::one::EDAnalyzer<> { public: explicit L1RCTLutWriter(const edm::ParameterSet &); ~L1RCTLutWriter() override; diff --git a/L1Trigger/RegionalCaloTrigger/interface/L1RCTRelValAnalyzer.h b/L1Trigger/RegionalCaloTrigger/interface/L1RCTRelValAnalyzer.h index 12c1864306706..ec085cde561d7 100644 --- a/L1Trigger/RegionalCaloTrigger/interface/L1RCTRelValAnalyzer.h +++ b/L1Trigger/RegionalCaloTrigger/interface/L1RCTRelValAnalyzer.h @@ -22,7 +22,7 @@ #include #include // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" @@ -42,7 +42,7 @@ // class declaration // -class L1RCTRelValAnalyzer : public edm::EDAnalyzer { +class L1RCTRelValAnalyzer : public edm::one::EDAnalyzer { public: explicit L1RCTRelValAnalyzer(const edm::ParameterSet &); ~L1RCTRelValAnalyzer() override; @@ -51,8 +51,8 @@ class L1RCTRelValAnalyzer : public edm::EDAnalyzer { private: // ----------member data --------------------------- - edm::InputTag rctEmCandsLabel; - edm::InputTag rctRegionsLabel; + edm::EDGetTokenT m_rctEmCands; + edm::EDGetTokenT m_rctRegions; TH1F *h_emRank; TH1F *h_emIeta; diff --git a/L1Trigger/RegionalCaloTrigger/interface/L1RCTSaveInput.h b/L1Trigger/RegionalCaloTrigger/interface/L1RCTSaveInput.h index f427111ac1e0c..688b17719cfd4 100644 --- a/L1Trigger/RegionalCaloTrigger/interface/L1RCTSaveInput.h +++ b/L1Trigger/RegionalCaloTrigger/interface/L1RCTSaveInput.h @@ -24,7 +24,7 @@ #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -46,11 +46,13 @@ #include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h" #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h" #include "CalibCalorimetry/EcalTPGTools/interface/EcalTPGScale.h" +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" +#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" class L1RCTLookupTables; class L1RCT; -class L1RCTSaveInput : public edm::EDAnalyzer { +class L1RCTSaveInput : public edm::one::EDAnalyzer<> { public: explicit L1RCTSaveInput(const edm::ParameterSet &); ~L1RCTSaveInput() override; @@ -62,8 +64,8 @@ class L1RCTSaveInput : public edm::EDAnalyzer { L1RCT *rct; bool useEcal; bool useHcal; - edm::InputTag ecalDigisLabel; - edm::InputTag hcalDigisLabel; + edm::EDGetTokenT ecalDigisToken_; + edm::EDGetTokenT hcalDigisToken_; edm::ESGetToken rctParametersToken_; edm::ESGetToken channelMaskToken_; edm::ESGetToken emScaleToken_; diff --git a/L1Trigger/RegionalCaloTrigger/interface/L1RCTTPGProvider.h b/L1Trigger/RegionalCaloTrigger/interface/L1RCTTPGProvider.h index 7412856d9e8ec..9d0ee2da45f3b 100644 --- a/L1Trigger/RegionalCaloTrigger/interface/L1RCTTPGProvider.h +++ b/L1Trigger/RegionalCaloTrigger/interface/L1RCTTPGProvider.h @@ -19,33 +19,36 @@ // system include files #include +#include // user include files -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" +#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h" + // // class decleration // -class L1RCTTPGProvider : public edm::EDProducer { +class L1RCTTPGProvider : public edm::global::EDProducer<> { public: explicit L1RCTTPGProvider(const edm::ParameterSet &); ~L1RCTTPGProvider() override; private: - void produce(edm::Event &, const edm::EventSetup &) override; - void endJob() override; + void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; // ----------member data --------------------------- - edm::InputTag ecalTPG_; - edm::InputTag hcalTPG_; - bool useHcalCosmicTiming; - bool useEcalCosmicTiming; + edm::EDGetTokenT ecalTPG_; + edm::EDGetTokenT hcalTPG_; + mutable std::atomic useHcalCosmicTiming; + mutable std::atomic useEcalCosmicTiming; int preSamples; int postSamples; int hfShift; diff --git a/L1Trigger/RegionalCaloTrigger/interface/L1RCTTestAnalyzer.h b/L1Trigger/RegionalCaloTrigger/interface/L1RCTTestAnalyzer.h index fcdc9056c65bd..085bf9e47755c 100644 --- a/L1Trigger/RegionalCaloTrigger/interface/L1RCTTestAnalyzer.h +++ b/L1Trigger/RegionalCaloTrigger/interface/L1RCTTestAnalyzer.h @@ -21,7 +21,7 @@ #include #include // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" @@ -50,7 +50,7 @@ // class declaration // -class L1RCTTestAnalyzer : public edm::EDAnalyzer { +class L1RCTTestAnalyzer : public edm::one::EDAnalyzer { public: explicit L1RCTTestAnalyzer(const edm::ParameterSet &); ~L1RCTTestAnalyzer() override; diff --git a/L1Trigger/RegionalCaloTrigger/interface/MaskedRctInputDigiProducer.h b/L1Trigger/RegionalCaloTrigger/interface/MaskedRctInputDigiProducer.h index d928488def585..f59f5c21cf877 100644 --- a/L1Trigger/RegionalCaloTrigger/interface/MaskedRctInputDigiProducer.h +++ b/L1Trigger/RegionalCaloTrigger/interface/MaskedRctInputDigiProducer.h @@ -26,7 +26,7 @@ RCT. #include // user include files -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -42,21 +42,20 @@ RCT. // class declaration // -class MaskedRctInputDigiProducer : public edm::EDProducer { +class MaskedRctInputDigiProducer : public edm::global::EDProducer<> { public: explicit MaskedRctInputDigiProducer(const edm::ParameterSet &); ~MaskedRctInputDigiProducer() override; private: - void produce(edm::Event &, const edm::EventSetup &) override; - void endJob() override; + void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; // ----------member data --------------------------- bool useEcal_; bool useHcal_; - edm::InputTag ecalDigisLabel_; - edm::InputTag hcalDigisLabel_; + edm::EDGetTokenT ecalDigisToken_; + edm::EDGetTokenT hcalDigisToken_; edm::FileInPath maskFile_; }; #endif diff --git a/L1Trigger/RegionalCaloTrigger/plugins/L1RCTRelValAnalyzer.cc b/L1Trigger/RegionalCaloTrigger/plugins/L1RCTRelValAnalyzer.cc index cab6f630c4fbb..1a92e3bac2e1e 100644 --- a/L1Trigger/RegionalCaloTrigger/plugins/L1RCTRelValAnalyzer.cc +++ b/L1Trigger/RegionalCaloTrigger/plugins/L1RCTRelValAnalyzer.cc @@ -24,10 +24,11 @@ using std::string; // constructors and destructor // L1RCTRelValAnalyzer::L1RCTRelValAnalyzer(const edm::ParameterSet &iConfig) - : rctEmCandsLabel(iConfig.getParameter("rctEmCandsLabel")), - rctRegionsLabel(iConfig.getParameter("rctRegionsLabel")) { + : m_rctEmCands(consumes(iConfig.getParameter("rctEmCandsLabel"))), + m_rctRegions(consumes(iConfig.getParameter("rctRegionsLabel"))) { // now do what ever initialization is needed + usesResource(TFileService::kSharedResource); edm::Service fs; h_emRank = fs->make("emRank", "emRank", 64, 0., 64.); h_emIeta = fs->make("emOccupancyIeta", "emOccupancyIeta", 22, 0., 22.); @@ -52,27 +53,12 @@ L1RCTRelValAnalyzer::~L1RCTRelValAnalyzer() { // ------------ method called to produce the data ------------ void L1RCTRelValAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { using namespace edm; -#ifdef THIS_IS_AN_EVENT_EXAMPLE - Handle pIn; - iEvent.getByLabel("example", pIn); -#endif - -#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE - ESHandle pSetup; - iSetup.get().get(pSetup); -#endif // as in L1GctTestAnalyzer.cc - Handle rctEmCands; - Handle rctRegions; - - L1CaloEmCollection::const_iterator em; - L1CaloRegionCollection::const_iterator rgn; - - iEvent.getByLabel(rctEmCandsLabel, rctEmCands); - iEvent.getByLabel(rctRegionsLabel, rctRegions); + Handle rctEmCands = iEvent.getHandle(m_rctEmCands); + Handle rctRegions = iEvent.getHandle(m_rctRegions); - for (em = rctEmCands->begin(); em != rctEmCands->end(); em++) { + for (auto em = rctEmCands->begin(); em != rctEmCands->end(); em++) { if ((*em).rank() > 0) { h_emRank->Fill((*em).rank()); h_emIeta->Fill((*em).regionId().ieta()); @@ -85,7 +71,7 @@ void L1RCTRelValAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetu } } - for (rgn = rctRegions->begin(); rgn != rctRegions->end(); rgn++) { + for (auto rgn = rctRegions->begin(); rgn != rctRegions->end(); rgn++) { if ((*rgn).et() > 0) { h_regionSum->Fill((*rgn).et()); h_regionSumIetaIphi->Fill((*rgn).gctEta(), (*rgn).gctPhi(), (*rgn).et()); diff --git a/L1Trigger/RegionalCaloTrigger/plugins/L1RCTSaveInput.cc b/L1Trigger/RegionalCaloTrigger/plugins/L1RCTSaveInput.cc index b7eac77982f7b..469e2ae81636e 100644 --- a/L1Trigger/RegionalCaloTrigger/plugins/L1RCTSaveInput.cc +++ b/L1Trigger/RegionalCaloTrigger/plugins/L1RCTSaveInput.cc @@ -30,8 +30,8 @@ L1RCTSaveInput::L1RCTSaveInput(const edm::ParameterSet &conf) rct(new L1RCT(rctLookupTables)), useEcal(conf.getParameter("useEcal")), useHcal(conf.getParameter("useHcal")), - ecalDigisLabel(conf.getParameter("ecalDigisLabel")), - hcalDigisLabel(conf.getParameter("hcalDigisLabel")), + ecalDigisToken_(consumes(conf.getParameter("ecalDigisLabel"))), + hcalDigisToken_(consumes(conf.getParameter("hcalDigisLabel"))), rctParametersToken_(esConsumes()), channelMaskToken_(esConsumes()), emScaleToken_(esConsumes()), @@ -42,8 +42,7 @@ L1RCTSaveInput::L1RCTSaveInput(const edm::ParameterSet &conf) tokens_(consumesCollector()) { ofs.open(fileName.c_str(), std::ios::app); if (!ofs) { - std::cerr << "Could not create " << fileName << std::endl; - exit(1); + throw cms::Exception("FailedFileOpen") << "Could not create " << fileName << std::endl; } } @@ -141,10 +140,8 @@ void L1RCTSaveInput::analyze(const edm::Event &event, const edm::EventSetup &eve rctLookupTables->setEcalScale(e); } - edm::Handle ecal; - edm::Handle hcal; - event.getByLabel(ecalDigisLabel, ecal); - event.getByLabel(hcalDigisLabel, hcal); + edm::Handle ecal = event.getHandle(ecalDigisToken_); + edm::Handle hcal = event.getHandle(hcalDigisToken_); EcalTrigPrimDigiCollection ecalColl; HcalTrigPrimDigiCollection hcalColl; if (ecal.isValid()) { diff --git a/L1Trigger/RegionalCaloTrigger/plugins/L1RCTTPGProvider.cc b/L1Trigger/RegionalCaloTrigger/plugins/L1RCTTPGProvider.cc index 26d0918634a5c..47c1093dad232 100644 --- a/L1Trigger/RegionalCaloTrigger/plugins/L1RCTTPGProvider.cc +++ b/L1Trigger/RegionalCaloTrigger/plugins/L1RCTTPGProvider.cc @@ -3,8 +3,8 @@ #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTTPGProvider.h" L1RCTTPGProvider::L1RCTTPGProvider(const edm::ParameterSet &iConfig) - : ecalTPG_(iConfig.getParameter("ecalTPGs")), - hcalTPG_(iConfig.getParameter("hcalTPGs")), + : ecalTPG_(consumes(iConfig.getParameter("ecalTPGs"))), + hcalTPG_(consumes(iConfig.getParameter("hcalTPGs"))), useHcalCosmicTiming(iConfig.getParameter("useHCALCosmicTiming")), useEcalCosmicTiming(iConfig.getParameter("useECALCosmicTiming")), preSamples(iConfig.getParameter("preSamples")), @@ -45,7 +45,7 @@ L1RCTTPGProvider::~L1RCTTPGProvider() { // // ------------ method called to produce the data ------------ -void L1RCTTPGProvider::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { +void L1RCTTPGProvider::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { using namespace edm; // Declare handles Handle ecal; @@ -58,7 +58,7 @@ void L1RCTTPGProvider::produce(edm::Event &iEvent, const edm::EventSetup &iSetup unsigned nSamples = preSamples + postSamples + 1; - if (iEvent.getByLabel(ecalTPG_, ecal)) + if ((ecal = iEvent.getHandle(ecalTPG_))) if (ecal.isValid()) { // loop through all ecal digis for (EcalTrigPrimDigiCollection::const_iterator ecal_it = ecal->begin(); ecal_it != ecal->end(); ecal_it++) { @@ -152,7 +152,7 @@ void L1RCTTPGProvider::produce(edm::Event &iEvent, const edm::EventSetup &iSetup } } - if (iEvent.getByLabel(hcalTPG_, hcal)) + if ((hcal = iEvent.getHandle(hcalTPG_))) if (hcal.isValid()) { // loop through all hcal digis for (HcalTrigPrimDigiCollection::const_iterator hcal_it = hcal->begin(); hcal_it != hcal->end(); hcal_it++) { @@ -301,10 +301,3 @@ void L1RCTTPGProvider::produce(edm::Event &iEvent, const edm::EventSetup &iSetup iEvent.put(std::move(hcalIn2), hcal_label); } } - -// ------------ method called once each job just before starting event loop -// ------------ - -// ------------ method called once each job just after ending the event loop -// ------------ -void L1RCTTPGProvider::endJob() {} diff --git a/L1Trigger/RegionalCaloTrigger/plugins/L1RCTTestAnalyzer.cc b/L1Trigger/RegionalCaloTrigger/plugins/L1RCTTestAnalyzer.cc index 4693bd22eb366..b16d70c38a1b2 100644 --- a/L1Trigger/RegionalCaloTrigger/plugins/L1RCTTestAnalyzer.cc +++ b/L1Trigger/RegionalCaloTrigger/plugins/L1RCTTestAnalyzer.cc @@ -32,6 +32,7 @@ L1RCTTestAnalyzer::L1RCTTestAnalyzer(const edm::ParameterSet &iConfig) rctDigisLabel(iConfig.getParameter("rctDigisLabel")) { // now do what ever initialization is needed + usesResource(TFileService::kSharedResource); edm::Service fs; emTree = fs->make("emTree", "L1 RCT EM tree"); diff --git a/L1Trigger/RegionalCaloTrigger/plugins/MaskedRctInputDigiProducer.cc b/L1Trigger/RegionalCaloTrigger/plugins/MaskedRctInputDigiProducer.cc index ad539d61cb530..58adfffb1ce2b 100644 --- a/L1Trigger/RegionalCaloTrigger/plugins/MaskedRctInputDigiProducer.cc +++ b/L1Trigger/RegionalCaloTrigger/plugins/MaskedRctInputDigiProducer.cc @@ -15,9 +15,13 @@ using std::vector; MaskedRctInputDigiProducer::MaskedRctInputDigiProducer(const edm::ParameterSet &iConfig) : useEcal_(iConfig.getParameter("useEcal")), useHcal_(iConfig.getParameter("useHcal")), - ecalDigisLabel_(iConfig.getParameter("ecalDigisLabel")), - hcalDigisLabel_(iConfig.getParameter("hcalDigisLabel")), maskFile_(iConfig.getParameter("maskFile")) { + if (useEcal_) { + ecalDigisToken_ = consumes(iConfig.getParameter("ecalDigisLabel")); + } + if (useHcal_) { + hcalDigisToken_ = consumes(iConfig.getParameter("hcalDigisLabel")); + } // register your products /* Examples produces(); @@ -42,27 +46,17 @@ MaskedRctInputDigiProducer::~MaskedRctInputDigiProducer() { // // ------------ method called to produce the data ------------ -void MaskedRctInputDigiProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { +void MaskedRctInputDigiProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { using namespace edm; - /* This is an event example - //Read 'ExampleData' from the Event - Handle pIn; - iEvent.getByLabel("example",pIn); - - //Use the ExampleData to create an ExampleData2 which - // is put into the Event - std::unique_ptr pOut(new ExampleData2(*pIn)); - iEvent.put(std::move(pOut)); - */ edm::Handle ecal; edm::Handle hcal; if (useEcal_) { - iEvent.getByLabel(ecalDigisLabel_, ecal); + ecal = iEvent.getHandle(ecalDigisToken_); } if (useHcal_) { - iEvent.getByLabel(hcalDigisLabel_, hcal); + hcal = iEvent.getHandle(hcalDigisToken_); } EcalTrigPrimDigiCollection ecalColl; @@ -74,12 +68,6 @@ void MaskedRctInputDigiProducer::produce(edm::Event &iEvent, const edm::EventSet hcalColl = *hcal; } - /* this is an EventSetup example - //Read SetupData from the SetupRecord in the EventSetup - ESHandle pSetup; - iSetup.get().get(pSetup); - */ - ifstream maskFileStream(maskFile_.fullPath().c_str()); if (!maskFileStream.is_open()) { throw cms::Exception("FileInPathError") << "RCT mask file not opened" << std::endl; @@ -333,12 +321,5 @@ void MaskedRctInputDigiProducer::produce(edm::Event &iEvent, const edm::EventSet iEvent.put(std::move(maskedHcalTPs)); } -// ------------ method called once each job just before starting event loop -// ------------ - -// ------------ method called once each job just after ending the event loop -// ------------ -void MaskedRctInputDigiProducer::endJob() {} - // define this as a plug-in DEFINE_FWK_MODULE(MaskedRctInputDigiProducer);