From e89864b02fd675b722b28dffff006a7ed7fe5e3f Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Fri, 16 Oct 2020 21:34:40 +0200 Subject: [PATCH] Migrate {Ecal,Hcal}HaloAlgo to EventSetup consumes --- RecoMET/METAlgorithms/interface/EcalHaloAlgo.h | 3 ++- RecoMET/METAlgorithms/interface/HcalHaloAlgo.h | 5 ++--- RecoMET/METAlgorithms/src/EcalHaloAlgo.cc | 7 +++---- RecoMET/METAlgorithms/src/HcalHaloAlgo.cc | 7 +++---- RecoMET/METProducers/interface/EcalHaloDataProducer.h | 1 + RecoMET/METProducers/interface/HcalHaloDataProducer.h | 1 + RecoMET/METProducers/src/EcalHaloDataProducer.cc | 3 +-- RecoMET/METProducers/src/HcalHaloDataProducer.cc | 3 +-- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/RecoMET/METAlgorithms/interface/EcalHaloAlgo.h b/RecoMET/METAlgorithms/interface/EcalHaloAlgo.h index b5737a565754b..12f8d955e215b 100644 --- a/RecoMET/METAlgorithms/interface/EcalHaloAlgo.h +++ b/RecoMET/METAlgorithms/interface/EcalHaloAlgo.h @@ -44,7 +44,7 @@ class EcalHaloAlgo { public: // constructor - EcalHaloAlgo(); + explicit EcalHaloAlgo(edm::ConsumesCollector iC); // destructor ~EcalHaloAlgo() {} @@ -117,6 +117,7 @@ class EcalHaloAlgo { float SumEnergyThreshold; int NHitsThreshold; + edm::ESGetToken geoToken_; const CaloGeometry* geo; math::XYZPoint getPosition(const DetId& id, reco::Vertex::Point vtx); }; diff --git a/RecoMET/METAlgorithms/interface/HcalHaloAlgo.h b/RecoMET/METAlgorithms/interface/HcalHaloAlgo.h index bed5c02e73e6f..2ebe366015e2b 100644 --- a/RecoMET/METAlgorithms/interface/HcalHaloAlgo.h +++ b/RecoMET/METAlgorithms/interface/HcalHaloAlgo.h @@ -39,9 +39,7 @@ class HcalHaloAlgo { public: //constructor - HcalHaloAlgo(); - //destructor - ~HcalHaloAlgo() {} + explicit HcalHaloAlgo(edm::ConsumesCollector iC); // run algorithm reco::HcalHaloData Calculate(const CaloGeometry& TheCaloGeometry, @@ -99,6 +97,7 @@ class HcalHaloAlgo { float SumEnergyThreshold; int NHitsThreshold; + edm::ESGetToken geoToken_; const CaloGeometry* geo_; const HcalGeometry* hgeo_; math::XYZPoint getPosition(const DetId& id, reco::Vertex::Point vtx); diff --git a/RecoMET/METAlgorithms/src/EcalHaloAlgo.cc b/RecoMET/METAlgorithms/src/EcalHaloAlgo.cc index d8d6588af3003..fb939f02b93eb 100644 --- a/RecoMET/METAlgorithms/src/EcalHaloAlgo.cc +++ b/RecoMET/METAlgorithms/src/EcalHaloAlgo.cc @@ -1,3 +1,4 @@ +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "RecoMET/METAlgorithms/interface/EcalHaloAlgo.h" #include "DataFormats/Common/interface/ValueMap.h" @@ -16,7 +17,7 @@ using namespace edm; bool CompareTime(const EcalRecHit* x, const EcalRecHit* y) { return x->time() < y->time(); } -EcalHaloAlgo::EcalHaloAlgo() { +EcalHaloAlgo::EcalHaloAlgo(edm::ConsumesCollector iC) : geoToken_(iC.esConsumes()) { RoundnessCut = 0; AngleCut = 0; EBRecHitEnergyThreshold = 0.; @@ -182,9 +183,7 @@ EcalHaloData EcalHaloAlgo::Calculate(const CaloGeometry& TheCaloGeometry, TheAngleFiller.fill(); } - edm::ESHandle pGeo; - TheSetup.get().get(pGeo); - geo = pGeo.product(); + geo = &TheSetup.getData(geoToken_); //Halo cluster building: //Various clusters are built, depending on the subdetector. diff --git a/RecoMET/METAlgorithms/src/HcalHaloAlgo.cc b/RecoMET/METAlgorithms/src/HcalHaloAlgo.cc index 01df8e817a4a8..3ac31a33c7772 100644 --- a/RecoMET/METAlgorithms/src/HcalHaloAlgo.cc +++ b/RecoMET/METAlgorithms/src/HcalHaloAlgo.cc @@ -1,3 +1,4 @@ +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "RecoMET/METAlgorithms/interface/HcalHaloAlgo.h" #include @@ -20,7 +21,7 @@ bool CompareTowers(const CaloTower* x, const CaloTower* y) { return x->iphi() * 1000 + x->ieta() < y->iphi() * 1000 + y->ieta(); } -HcalHaloAlgo::HcalHaloAlgo() : geo_(nullptr), hgeo_(nullptr) { +HcalHaloAlgo::HcalHaloAlgo(edm::ConsumesCollector iC) : geoToken_(iC.esConsumes()), geo_(nullptr), hgeo_(nullptr) { HBRecHitEnergyThreshold = 0.; HERecHitEnergyThreshold = 0.; SumEnergyThreshold = 0.; @@ -223,9 +224,7 @@ HcalHaloData HcalHaloAlgo::Calculate(const CaloGeometry& TheCaloGeometry, prevHadEt = tower->hadEt(); } - edm::ESHandle pGeo; - TheSetup.get().get(pGeo); - geo_ = pGeo.product(); + geo_ = &TheSetup.getData(geoToken_); hgeo_ = dynamic_cast(geo_->getSubdetectorGeometry(DetId::Hcal, 1)); //Halo cluster building: diff --git a/RecoMET/METProducers/interface/EcalHaloDataProducer.h b/RecoMET/METProducers/interface/EcalHaloDataProducer.h index e14ab504fab09..a81cea5230a98 100644 --- a/RecoMET/METProducers/interface/EcalHaloDataProducer.h +++ b/RecoMET/METProducers/interface/EcalHaloDataProducer.h @@ -116,6 +116,7 @@ namespace reco { edm::EDGetTokenT supercluster_token_; edm::EDGetTokenT photon_token_; edm::ESGetToken calogeometry_token_; + EcalHaloAlgo EcalAlgo; float EBRecHitEnergyThreshold; float EERecHitEnergyThreshold; diff --git a/RecoMET/METProducers/interface/HcalHaloDataProducer.h b/RecoMET/METProducers/interface/HcalHaloDataProducer.h index 0b0e5786dc64f..f719cd54a9425 100644 --- a/RecoMET/METProducers/interface/HcalHaloDataProducer.h +++ b/RecoMET/METProducers/interface/HcalHaloDataProducer.h @@ -105,6 +105,7 @@ namespace reco { edm::EDGetTokenT hfrechit_token_; edm::EDGetTokenT calotower_token_; edm::ESGetToken calogeometry_token_; + HcalHaloAlgo HcalAlgo; float HBRecHitEnergyThreshold; float HERecHitEnergyThreshold; diff --git a/RecoMET/METProducers/src/EcalHaloDataProducer.cc b/RecoMET/METProducers/src/EcalHaloDataProducer.cc index 6edb297a3cc8c..29e8f5d63371c 100644 --- a/RecoMET/METProducers/src/EcalHaloDataProducer.cc +++ b/RecoMET/METProducers/src/EcalHaloDataProducer.cc @@ -12,7 +12,7 @@ using namespace edm; using namespace std; using namespace reco; -EcalHaloDataProducer::EcalHaloDataProducer(const edm::ParameterSet& iConfig) { +EcalHaloDataProducer::EcalHaloDataProducer(const edm::ParameterSet& iConfig) : EcalAlgo(consumesCollector()) { //RecHit Level IT_EBRecHit = iConfig.getParameter("EBRecHitLabel"); IT_EERecHit = iConfig.getParameter("EERecHitLabel"); @@ -82,7 +82,6 @@ void EcalHaloDataProducer::produce(Event& iEvent, const EventSetup& iSetup) { iEvent.getByToken(photon_token_, ThePhotons); //Run the EcalHaloAlgo to reconstruct the EcalHaloData object - EcalHaloAlgo EcalAlgo; EcalAlgo.SetRoundnessCut(RoundnessCut); EcalAlgo.SetAngleCut(AngleCut); EcalAlgo.SetRecHitEnergyThresholds(EBRecHitEnergyThreshold, EERecHitEnergyThreshold, ESRecHitEnergyThreshold); diff --git a/RecoMET/METProducers/src/HcalHaloDataProducer.cc b/RecoMET/METProducers/src/HcalHaloDataProducer.cc index 3254ff169617d..4b25f906038f6 100644 --- a/RecoMET/METProducers/src/HcalHaloDataProducer.cc +++ b/RecoMET/METProducers/src/HcalHaloDataProducer.cc @@ -12,7 +12,7 @@ using namespace edm; using namespace std; using namespace reco; -HcalHaloDataProducer::HcalHaloDataProducer(const edm::ParameterSet& iConfig) { +HcalHaloDataProducer::HcalHaloDataProducer(const edm::ParameterSet& iConfig) : HcalAlgo(consumesCollector()) { //RecHit Level IT_EBRecHit = iConfig.getParameter("EBRecHitLabel"); IT_EERecHit = iConfig.getParameter("EERecHitLabel"); @@ -63,7 +63,6 @@ void HcalHaloDataProducer::produce(Event& iEvent, const EventSetup& iSetup) { iEvent.getByToken(hfrechit_token_, TheHFRecHits); // Run the HcalHaloAlgo to reconstruct the HcalHaloData object - HcalHaloAlgo HcalAlgo; HcalAlgo.SetRecHitEnergyThresholds(HBRecHitEnergyThreshold, HERecHitEnergyThreshold); HcalAlgo.SetPhiWedgeThresholds(SumHcalEnergyThreshold, NHitsHcalThreshold);