Skip to content

Commit

Permalink
Migrate {Ecal,Hcal}HaloAlgo to EventSetup consumes
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Oct 17, 2020
1 parent 99f65c7 commit e89864b
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
3 changes: 2 additions & 1 deletion RecoMET/METAlgorithms/interface/EcalHaloAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
class EcalHaloAlgo {
public:
// constructor
EcalHaloAlgo();
explicit EcalHaloAlgo(edm::ConsumesCollector iC);
// destructor
~EcalHaloAlgo() {}

Expand Down Expand Up @@ -117,6 +117,7 @@ class EcalHaloAlgo {
float SumEnergyThreshold;
int NHitsThreshold;

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geoToken_;
const CaloGeometry* geo;
math::XYZPoint getPosition(const DetId& id, reco::Vertex::Point vtx);
};
Expand Down
5 changes: 2 additions & 3 deletions RecoMET/METAlgorithms/interface/HcalHaloAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
class HcalHaloAlgo {
public:
//constructor
HcalHaloAlgo();
//destructor
~HcalHaloAlgo() {}
explicit HcalHaloAlgo(edm::ConsumesCollector iC);

// run algorithm
reco::HcalHaloData Calculate(const CaloGeometry& TheCaloGeometry,
Expand Down Expand Up @@ -99,6 +97,7 @@ class HcalHaloAlgo {
float SumEnergyThreshold;
int NHitsThreshold;

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geoToken_;
const CaloGeometry* geo_;
const HcalGeometry* hgeo_;
math::XYZPoint getPosition(const DetId& id, reco::Vertex::Point vtx);
Expand Down
7 changes: 3 additions & 4 deletions RecoMET/METAlgorithms/src/EcalHaloAlgo.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "RecoMET/METAlgorithms/interface/EcalHaloAlgo.h"
#include "DataFormats/Common/interface/ValueMap.h"

Expand All @@ -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.;
Expand Down Expand Up @@ -182,9 +183,7 @@ EcalHaloData EcalHaloAlgo::Calculate(const CaloGeometry& TheCaloGeometry,
TheAngleFiller.fill();
}

edm::ESHandle<CaloGeometry> pGeo;
TheSetup.get<CaloGeometryRecord>().get(pGeo);
geo = pGeo.product();
geo = &TheSetup.getData(geoToken_);

//Halo cluster building:
//Various clusters are built, depending on the subdetector.
Expand Down
7 changes: 3 additions & 4 deletions RecoMET/METAlgorithms/src/HcalHaloAlgo.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "RecoMET/METAlgorithms/interface/HcalHaloAlgo.h"
#include <map>

Expand All @@ -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.;
Expand Down Expand Up @@ -223,9 +224,7 @@ HcalHaloData HcalHaloAlgo::Calculate(const CaloGeometry& TheCaloGeometry,
prevHadEt = tower->hadEt();
}

edm::ESHandle<CaloGeometry> pGeo;
TheSetup.get<CaloGeometryRecord>().get(pGeo);
geo_ = pGeo.product();
geo_ = &TheSetup.getData(geoToken_);
hgeo_ = dynamic_cast<const HcalGeometry*>(geo_->getSubdetectorGeometry(DetId::Hcal, 1));

//Halo cluster building:
Expand Down
1 change: 1 addition & 0 deletions RecoMET/METProducers/interface/EcalHaloDataProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ namespace reco {
edm::EDGetTokenT<reco::SuperClusterCollection> supercluster_token_;
edm::EDGetTokenT<reco::PhotonCollection> photon_token_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> calogeometry_token_;
EcalHaloAlgo EcalAlgo;

float EBRecHitEnergyThreshold;
float EERecHitEnergyThreshold;
Expand Down
1 change: 1 addition & 0 deletions RecoMET/METProducers/interface/HcalHaloDataProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ namespace reco {
edm::EDGetTokenT<HFRecHitCollection> hfrechit_token_;
edm::EDGetTokenT<CaloTowerCollection> calotower_token_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> calogeometry_token_;
HcalHaloAlgo HcalAlgo;

float HBRecHitEnergyThreshold;
float HERecHitEnergyThreshold;
Expand Down
3 changes: 1 addition & 2 deletions RecoMET/METProducers/src/EcalHaloDataProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<edm::InputTag>("EBRecHitLabel");
IT_EERecHit = iConfig.getParameter<edm::InputTag>("EERecHitLabel");
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions RecoMET/METProducers/src/HcalHaloDataProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<edm::InputTag>("EBRecHitLabel");
IT_EERecHit = iConfig.getParameter<edm::InputTag>("EERecHitLabel");
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit e89864b

Please sign in to comment.