Skip to content

Commit

Permalink
Migrate EcalClusterLazyTools to ESGetToken
Browse files Browse the repository at this point in the history
  • Loading branch information
guitargeek committed Oct 22, 2020
1 parent 676f6ad commit 593a614
Show file tree
Hide file tree
Showing 30 changed files with 213 additions and 127 deletions.
14 changes: 3 additions & 11 deletions DQM/Physics/src/QcdPhotonsDQM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,13 @@
#include "DataFormats/VertexReco/interface/Vertex.h"

// For removing ECAL Spikes
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h"

// geometry
//#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
//#include "Geometry/Records/interface/CaloGeometryRecord.h"
//#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
//#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
//#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
//#include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"

// Math stuff
#include "DataFormats/Math/interface/deltaR.h"
#include "DataFormats/Math/interface/deltaPhi.h"
Expand All @@ -54,7 +45,7 @@ using namespace std;
using namespace edm;
using namespace reco;

QcdPhotonsDQM::QcdPhotonsDQM(const ParameterSet& parameters) {
QcdPhotonsDQM::QcdPhotonsDQM(const ParameterSet& parameters) : ecalClusterToolsESGetTokens_{consumesCollector()} {
// Get parameters from configuration file
theTriggerPathToPass_ = parameters.getParameter<string>("triggerPathToPass");
thePlotTheseTriggersToo_ = parameters.getParameter<vector<string> >("plotTheseTriggersToo");
Expand Down Expand Up @@ -341,7 +332,8 @@ void QcdPhotonsDQM::analyze(const Event& iEvent, const EventSetup& iSetup) {
iEvent.getByToken(theBarrelRecHitToken_, EBReducedRecHits);
Handle<EcalRecHitCollection> EEReducedRecHits;
iEvent.getByToken(theEndcapRecHitToken_, EEReducedRecHits);
EcalClusterLazyTools lazyTool(iEvent, iSetup, theBarrelRecHitToken_, theEndcapRecHitToken_);
EcalClusterLazyTools lazyTool(
iEvent, ecalClusterToolsESGetTokens_.get(iSetup), theBarrelRecHitToken_, theEndcapRecHitToken_);

// Find the highest et "decent" photon
float photon_et = -9.0;
Expand Down
3 changes: 3 additions & 0 deletions DQM/Physics/src/QcdPhotonsDQM.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"

namespace reco {
class Jet;
}
Expand Down Expand Up @@ -62,6 +64,7 @@ class QcdPhotonsDQM : public DQMEDAnalyzer {
edm::InputTag theEndcapRecHitTag_;
edm::EDGetTokenT<EcalRecHitCollection> theBarrelRecHitToken_;
edm::EDGetTokenT<EcalRecHitCollection> theEndcapRecHitToken_;
EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_;

// Histograms
MonitorElement* h_triggers_passed;
Expand Down
9 changes: 7 additions & 2 deletions EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ElectronIdMVAProducer : public edm::EDFilter {
edm::EDGetTokenT<double> eventrhoToken_;
edm::EDGetTokenT<EcalRecHitCollection> reducedEBRecHitCollectionToken_;
edm::EDGetTokenT<EcalRecHitCollection> reducedEERecHitCollectionToken_;
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_;

double _Rho;
std::string method_;
Expand All @@ -57,7 +58,8 @@ class ElectronIdMVAProducer : public edm::EDFilter {
//
// constructors and destructor
//
ElectronIdMVAProducer::ElectronIdMVAProducer(const edm::ParameterSet& iConfig) {
ElectronIdMVAProducer::ElectronIdMVAProducer(const edm::ParameterSet& iConfig)
: ecalClusterToolsESGetTokens_{consumesCollector()} {
verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexTag"));
electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
Expand Down Expand Up @@ -128,7 +130,10 @@ bool ElectronIdMVAProducer::filter(edm::Event& iEvent, const edm::EventSetup& iS
dummy = reco::Vertex(p, e, 0, 0, 0);
}

EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_);
EcalClusterLazyTools lazyTools(iEvent,
ecalClusterToolsESGetTokens_.get(iSetup),
reducedEBRecHitCollectionToken_,
reducedEERecHitCollectionToken_);

edm::ESHandle<TransientTrackBuilder> builder;
iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
Expand Down
10 changes: 7 additions & 3 deletions EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ElectronTestAnalyzer : public edm::EDAnalyzer {
edm::EDGetTokenT<reco::MuonCollection> muonToken_;
edm::EDGetTokenT<EcalRecHitCollection> reducedEBRecHitCollectionToken_;
edm::EDGetTokenT<EcalRecHitCollection> reducedEERecHitCollectionToken_;
const EcalClusterLazyTools::ESGetTokens ecalClusterESGetTokens_;

EGammaMvaEleEstimator* myMVATrigV0;
EGammaMvaEleEstimator* myMVATrigNoIPV0;
Expand Down Expand Up @@ -179,7 +180,8 @@ ElectronTestAnalyzer::ElectronTestAnalyzer(const edm::ParameterSet& iConfig)
eventrhoToken_(consumes<double>(edm::InputTag("kt6PFJets", "rho"))),
muonToken_(consumes<reco::MuonCollection>(edm::InputTag("muons"))),
reducedEBRecHitCollectionToken_(consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"))),
reducedEERecHitCollectionToken_(consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"))) {
reducedEERecHitCollectionToken_(consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"))),
ecalClusterESGetTokens_{consumesCollector()} {
Bool_t manualCat = true;

ev = 0;
Expand Down Expand Up @@ -294,7 +296,8 @@ void ElectronTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
reco::Vertex::Point p(0, 0, 0);
dummy = reco::Vertex(p, e, 0, 0, 0);
}
EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_);
EcalClusterLazyTools lazyTools(
iEvent, ecalClusterESGetTokens_.get(iSetup), reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_);

edm::ESHandle<TransientTrackBuilder> builder;
iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
Expand Down Expand Up @@ -687,7 +690,8 @@ void ElectronTestAnalyzer::evaluate_mvas(const edm::Event& iEvent, const edm::Ev
IdentifiedMuons.push_back(*iM);
}

EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_);
EcalClusterLazyTools lazyTools(
iEvent, ecalClusterESGetTokens_.get(iSetup), reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_);

edm::ESHandle<TransientTrackBuilder> builder;
iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
Expand Down
7 changes: 5 additions & 2 deletions PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ PATElectronProducer::PATElectronProducer(const edm::ParameterSet& iConfig)
reducedBarrelRecHitCollectionToken_(mayConsume<EcalRecHitCollection>(reducedBarrelRecHitCollection_)),
reducedEndcapRecHitCollection_(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection")),
reducedEndcapRecHitCollectionToken_(mayConsume<EcalRecHitCollection>(reducedEndcapRecHitCollection_)),
ecalClusterToolsESGetTokens_{consumesCollector()},
// PFCluster Isolation maps
addPFClusterIso_(iConfig.getParameter<bool>("addPFClusterIso")),
addPuppiIsolation_(iConfig.getParameter<bool>("addPuppiIsolation")),
Expand Down Expand Up @@ -251,8 +252,10 @@ void PATElectronProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
edm::InputTag reducedEBRecHitCollection(string("reducedEcalRecHitsEB"));
edm::InputTag reducedEERecHitCollection(string("reducedEcalRecHitsEE"));
//EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollection, reducedEERecHitCollection);
EcalClusterLazyTools lazyTools(
iEvent, iSetup, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_);
EcalClusterLazyTools lazyTools(iEvent,
ecalClusterToolsESGetTokens_.get(iSetup),
reducedBarrelRecHitCollectionToken_,
reducedEndcapRecHitCollectionToken_);

// for conversion veto selection
edm::Handle<reco::ConversionCollection> hConversions;
Expand Down
1 change: 1 addition & 0 deletions PhysicsTools/PatAlgos/plugins/PATElectronProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace pat {
const edm::EDGetTokenT<EcalRecHitCollection> reducedBarrelRecHitCollectionToken_;
const edm::InputTag reducedEndcapRecHitCollection_;
const edm::EDGetTokenT<EcalRecHitCollection> reducedEndcapRecHitCollectionToken_;
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_;

const bool addPFClusterIso_;
const bool addPuppiIsolation_;
Expand Down
12 changes: 8 additions & 4 deletions PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace pat {
const StringCutObjectSelector<pat::Electron> saveNonZSClusterShapes_;
const edm::EDGetTokenT<EcalRecHitCollection> reducedBarrelRecHitCollectionToken_,
reducedEndcapRecHitCollectionToken_;
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_;
const bool modifyElectron_;
std::unique_ptr<pat::ObjectModifier<pat::Electron>> electronModifier_;
};
Expand Down Expand Up @@ -74,9 +75,10 @@ pat::PATElectronSlimmer::PATElectronSlimmer(const edm::ParameterSet& iConfig)
linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
reducedBarrelRecHitCollectionToken_(
consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
consumes(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
reducedEndcapRecHitCollectionToken_(
consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection"))),
consumes(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection"))),
ecalClusterToolsESGetTokens_{consumesCollector()},
modifyElectron_(iConfig.getParameter<bool>("modifyElectrons")) {
if (modifyElectron_) {
const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
Expand Down Expand Up @@ -106,8 +108,10 @@ void pat::PATElectronSlimmer::produce(edm::Event& iEvent, const edm::EventSetup&
iEvent.getByToken(pf2pc_, pf2pc);
iEvent.getByToken(pc_, pc);
}
noZS::EcalClusterLazyTools lazyToolsNoZS(
iEvent, iSetup, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_);
noZS::EcalClusterLazyTools lazyToolsNoZS(iEvent,
ecalClusterToolsESGetTokens_.get(iSetup),
reducedBarrelRecHitCollectionToken_,
reducedEndcapRecHitCollectionToken_);

auto out = std::make_unique<std::vector<pat::Electron>>();
out->reserve(src->size());
Expand Down
12 changes: 8 additions & 4 deletions PhysicsTools/PatAlgos/plugins/PATPhotonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
#include "Geometry/CaloTopology/interface/CaloTopology.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
Expand All @@ -30,7 +29,10 @@
using namespace pat;

PATPhotonProducer::PATPhotonProducer(const edm::ParameterSet &iConfig)
: isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation")
:

ecalClusterToolsESGetTokens_{consumesCollector()},
isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation")
: edm::ParameterSet(),
consumesCollector(),
false),
Expand Down Expand Up @@ -172,8 +174,10 @@ void PATPhotonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetu
edm::Handle<reco::BeamSpot> beamSpotHandle;
iEvent.getByToken(beamLineToken_, beamSpotHandle);

EcalClusterLazyTools lazyTools(
iEvent, iSetup, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_);
EcalClusterLazyTools lazyTools(iEvent,
ecalClusterToolsESGetTokens_.get(iSetup),
reducedBarrelRecHitCollectionToken_,
reducedEndcapRecHitCollectionToken_);

// prepare the MC matching
std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> genMatches(genMatchTokens_.size());
Expand Down
4 changes: 4 additions & 0 deletions PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"

#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"

namespace pat {

class PATPhotonProducer : public edm::stream::EDProducer<> {
Expand Down Expand Up @@ -74,6 +76,8 @@ namespace pat {
edm::InputTag reducedEndcapRecHitCollection_;
edm::EDGetTokenT<EcalRecHitCollection> reducedEndcapRecHitCollectionToken_;

const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_;

bool addPFClusterIso_;
bool addPuppiIsolation_;
edm::EDGetTokenT<edm::ValueMap<float> > ecalPFClusterIsoT_;
Expand Down
10 changes: 7 additions & 3 deletions PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace pat {
reducedEndcapRecHitCollectionToken_;
const bool modifyPhoton_;
std::unique_ptr<pat::ObjectModifier<pat::Photon>> photonModifier_;
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_;
};

} // namespace pat
Expand All @@ -72,7 +73,8 @@ pat::PATPhotonSlimmer::PATPhotonSlimmer(const edm::ParameterSet& iConfig)
consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
reducedEndcapRecHitCollectionToken_(
consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection"))),
modifyPhoton_(iConfig.getParameter<bool>("modifyPhotons")) {
modifyPhoton_(iConfig.getParameter<bool>("modifyPhotons")),
ecalClusterToolsESGetTokens_{consumesCollector()} {
if (modifyPhoton_) {
const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
photonModifier_ = std::make_unique<pat::ObjectModifier<pat::Photon>>(mod_config, consumesCollector());
Expand Down Expand Up @@ -101,8 +103,10 @@ void pat::PATPhotonSlimmer::produce(edm::Event& iEvent, const edm::EventSetup& i
iEvent.getByToken(pf2pc_, pf2pc);
iEvent.getByToken(pc_, pc);
}
noZS::EcalClusterLazyTools lazyToolsNoZS(
iEvent, iSetup, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_);
noZS::EcalClusterLazyTools lazyToolsNoZS(iEvent,
ecalClusterToolsESGetTokens_.get(iSetup),
reducedBarrelRecHitCollectionToken_,
reducedEndcapRecHitCollectionToken_);

auto out = std::make_unique<std::vector<pat::Photon>>();
out->reserve(src->size());
Expand Down
Loading

0 comments on commit 593a614

Please sign in to comment.