From 8e85bfb51d1f20cf519e677da3d08ac4269350b7 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Wed, 17 Nov 2021 20:15:26 +0100 Subject: [PATCH] Modernize analyzers in CondTools/RPC --- CondTools/RPC/plugins/CondReader.cc | 13 ++++++------- CondTools/RPC/plugins/PVSSIDReader.cc | 15 +++++++-------- CondTools/RPC/src/RPCDBPerformanceHandler.cc | 1 - CondTools/RPC/src/RPCStripNoisesRcdRead.cc | 14 +++++++------- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/CondTools/RPC/plugins/CondReader.cc b/CondTools/RPC/plugins/CondReader.cc index 4e5993e4dd58c..4e9000bb5d633 100644 --- a/CondTools/RPC/plugins/CondReader.cc +++ b/CondTools/RPC/plugins/CondReader.cc @@ -3,10 +3,9 @@ #include #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "CondTools/RPC/interface/RPCDBSimSetUp.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "CondFormats/RPCObjects/interface/RPCObCond.h" @@ -16,7 +15,7 @@ #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" #include "FWCore/ServiceRegistry/interface/Service.h" -class CondReader : public edm::EDAnalyzer { +class CondReader : public edm::one::EDAnalyzer<> { public: CondReader(const edm::ParameterSet& iConfig); @@ -26,19 +25,20 @@ class CondReader : public edm::EDAnalyzer { private: unsigned long long since; unsigned long long till; + edm::ESGetToken condRcd_token_; }; CondReader::CondReader(const edm::ParameterSet& iConfig) : since(iConfig.getUntrackedParameter("since", 0)), - till(iConfig.getUntrackedParameter("till", 0)) {} + till(iConfig.getUntrackedParameter("till", 0)), + condRcd_token_(esConsumes()) {} CondReader::~CondReader() {} void CondReader::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) { edm::Service mydbservice; - edm::ESHandle condRcd; - evtSetup.get().get(condRcd); + const RPCObImon* cond = &evtSetup.getData(condRcd_token_); edm::LogInfo("CondReader") << "[CondReader::analyze] End Reading Cond" << std::endl; std::cout << "Run start: " << since << " - Run stop: " << till << std::endl; @@ -52,7 +52,6 @@ void CondReader::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) int ntimeT = (tTime.hour() * 10000) + (tTime.minute() * 100) + tTime.second(); std::cout << "Run start: " << ndateS << " " << ntimeS << " - Run stop: " << ndateT << " " << ntimeT << std::endl; - const RPCObImon* cond = condRcd.product(); std::vector mycond = cond->ObImon_rpc; std::vector::iterator icond; diff --git a/CondTools/RPC/plugins/PVSSIDReader.cc b/CondTools/RPC/plugins/PVSSIDReader.cc index b9c864426ba20..1f9c232645c9f 100644 --- a/CondTools/RPC/plugins/PVSSIDReader.cc +++ b/CondTools/RPC/plugins/PVSSIDReader.cc @@ -3,32 +3,31 @@ #include #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "CondTools/RPC/interface/RPCDBSimSetUp.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "CondFormats/RPCObjects/interface/RPCObPVSSmap.h" #include "CondFormats/DataRecord/interface/RPCObPVSSmapRcd.h" -class PVSSIDReader : public edm::EDAnalyzer { +class PVSSIDReader : public edm::one::EDAnalyzer<> { public: PVSSIDReader(const edm::ParameterSet& iConfig); ~PVSSIDReader() override; void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) override; + +private: + edm::ESGetToken pvssmap_token_; }; -PVSSIDReader::PVSSIDReader(const edm::ParameterSet& iConfig) {} +PVSSIDReader::PVSSIDReader(const edm::ParameterSet& iConfig) : pvssmap_token_(esConsumes()) {} PVSSIDReader::~PVSSIDReader() {} void PVSSIDReader::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) { - edm::ESHandle pvssmapRcd; - evtSetup.get().get(pvssmapRcd); + const RPCObPVSSmap* pvssmap = &evtSetup.getData(pvssmap_token_); edm::LogInfo("PVSSIDReader") << "[PVSSIDReader::analyze] End Reading Pvssmap" << std::endl; - - const RPCObPVSSmap* pvssmap = pvssmapRcd.product(); std::vector mypvssmap = pvssmap->ObIDMap_rpc; std::vector::iterator ipvssmap; diff --git a/CondTools/RPC/src/RPCDBPerformanceHandler.cc b/CondTools/RPC/src/RPCDBPerformanceHandler.cc index 2187629e605e6..adea585a8b682 100644 --- a/CondTools/RPC/src/RPCDBPerformanceHandler.cc +++ b/CondTools/RPC/src/RPCDBPerformanceHandler.cc @@ -2,7 +2,6 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/CondTools/RPC/src/RPCStripNoisesRcdRead.cc b/CondTools/RPC/src/RPCStripNoisesRcdRead.cc index 2485ab5fd5aa1..c0963f799533b 100644 --- a/CondTools/RPC/src/RPCStripNoisesRcdRead.cc +++ b/CondTools/RPC/src/RPCStripNoisesRcdRead.cc @@ -3,31 +3,31 @@ #include #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "CondTools/RPC/interface/RPCDBSimSetUp.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "CondFormats/RPCObjects/interface/RPCStripNoises.h" #include "CondFormats/DataRecord/interface/RPCStripNoisesRcd.h" -class RPCStripNoisesRcdRead : public edm::EDAnalyzer { +class RPCStripNoisesRcdRead : public edm::one::EDAnalyzer<> { public: RPCStripNoisesRcdRead(const edm::ParameterSet& iConfig); ~RPCStripNoisesRcdRead() override; void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) override; + +private: + edm::ESGetToken noise_RcdToken_; }; -RPCStripNoisesRcdRead::RPCStripNoisesRcdRead(const edm::ParameterSet& iConfig) {} +RPCStripNoisesRcdRead::RPCStripNoisesRcdRead(const edm::ParameterSet& iConfig) : noise_RcdToken_(esConsumes()) {} RPCStripNoisesRcdRead::~RPCStripNoisesRcdRead() {} void RPCStripNoisesRcdRead::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) { - edm::ESHandle noiseRcd; - evtSetup.get().get(noiseRcd); + const RPCStripNoises* noiseRcd = &evtSetup.getData(noise_RcdToken_); edm::LogInfo("RPCStripNoisesReader") << "[RPCStripNoisesReader::analyze] End Reading RPCStripNoises" << std::endl; - std::vector vnoise = noiseRcd->getVNoise(); std::vector vcls = noiseRcd->getCls();