diff --git a/DQM/Physics/src/QcdPhotonsDQM.cc b/DQM/Physics/src/QcdPhotonsDQM.cc index 759895299be96..112aa5f7b5059 100644 --- a/DQM/Physics/src/QcdPhotonsDQM.cc +++ b/DQM/Physics/src/QcdPhotonsDQM.cc @@ -26,7 +26,6 @@ #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" @@ -34,14 +33,6 @@ #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" @@ -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("triggerPathToPass"); thePlotTheseTriggersToo_ = parameters.getParameter >("plotTheseTriggersToo"); @@ -341,7 +332,8 @@ void QcdPhotonsDQM::analyze(const Event& iEvent, const EventSetup& iSetup) { iEvent.getByToken(theBarrelRecHitToken_, EBReducedRecHits); Handle 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; diff --git a/DQM/Physics/src/QcdPhotonsDQM.h b/DQM/Physics/src/QcdPhotonsDQM.h index 860bf07cae243..8fba51f8ebc4b 100644 --- a/DQM/Physics/src/QcdPhotonsDQM.h +++ b/DQM/Physics/src/QcdPhotonsDQM.h @@ -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; } @@ -62,6 +64,7 @@ class QcdPhotonsDQM : public DQMEDAnalyzer { edm::InputTag theEndcapRecHitTag_; edm::EDGetTokenT theBarrelRecHitToken_; edm::EDGetTokenT theEndcapRecHitToken_; + EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; // Histograms MonitorElement* h_triggers_passed; diff --git a/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc b/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc index 1245d08124ebb..7bf1f668ca68d 100644 --- a/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc @@ -36,6 +36,7 @@ class ElectronIdMVAProducer : public edm::EDFilter { edm::EDGetTokenT eventrhoToken_; edm::EDGetTokenT reducedEBRecHitCollectionToken_; edm::EDGetTokenT reducedEERecHitCollectionToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; double _Rho; std::string method_; @@ -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("verbose", false); vertexToken_ = consumes(iConfig.getParameter("vertexTag")); electronToken_ = consumes(iConfig.getParameter("electronTag")); @@ -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 builder; iSetup.get().get("TransientTrackBuilder", builder); diff --git a/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc b/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc index a572d1494faba..26fc00eb61a75 100644 --- a/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc +++ b/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc @@ -92,6 +92,7 @@ class ElectronTestAnalyzer : public edm::EDAnalyzer { edm::EDGetTokenT muonToken_; edm::EDGetTokenT reducedEBRecHitCollectionToken_; edm::EDGetTokenT reducedEERecHitCollectionToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterESGetTokens_; EGammaMvaEleEstimator* myMVATrigV0; EGammaMvaEleEstimator* myMVATrigNoIPV0; @@ -179,7 +180,8 @@ ElectronTestAnalyzer::ElectronTestAnalyzer(const edm::ParameterSet& iConfig) eventrhoToken_(consumes(edm::InputTag("kt6PFJets", "rho"))), muonToken_(consumes(edm::InputTag("muons"))), reducedEBRecHitCollectionToken_(consumes(edm::InputTag("reducedEcalRecHitsEB"))), - reducedEERecHitCollectionToken_(consumes(edm::InputTag("reducedEcalRecHitsEE"))) { + reducedEERecHitCollectionToken_(consumes(edm::InputTag("reducedEcalRecHitsEE"))), + ecalClusterESGetTokens_{consumesCollector()} { Bool_t manualCat = true; ev = 0; @@ -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 builder; iSetup.get().get("TransientTrackBuilder", builder); @@ -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 builder; iSetup.get().get("TransientTrackBuilder", builder); diff --git a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc index 0d778ef39da73..c7e13d69917f3 100644 --- a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc @@ -86,6 +86,7 @@ PATElectronProducer::PATElectronProducer(const edm::ParameterSet& iConfig) reducedBarrelRecHitCollectionToken_(mayConsume(reducedBarrelRecHitCollection_)), reducedEndcapRecHitCollection_(iConfig.getParameter("reducedEndcapRecHitCollection")), reducedEndcapRecHitCollectionToken_(mayConsume(reducedEndcapRecHitCollection_)), + ecalClusterToolsESGetTokens_{consumesCollector()}, // PFCluster Isolation maps addPFClusterIso_(iConfig.getParameter("addPFClusterIso")), addPuppiIsolation_(iConfig.getParameter("addPuppiIsolation")), @@ -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 hConversions; diff --git a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.h b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.h index 3de14f24fe477..21c9aae8cf03b 100644 --- a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.h @@ -97,6 +97,7 @@ namespace pat { const edm::EDGetTokenT reducedBarrelRecHitCollectionToken_; const edm::InputTag reducedEndcapRecHitCollection_; const edm::EDGetTokenT reducedEndcapRecHitCollectionToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; const bool addPFClusterIso_; const bool addPuppiIsolation_; diff --git a/PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc index e3577bac59c8d..58ca1c865d4f1 100644 --- a/PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc @@ -46,6 +46,7 @@ namespace pat { const StringCutObjectSelector saveNonZSClusterShapes_; const edm::EDGetTokenT reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; const bool modifyElectron_; std::unique_ptr> electronModifier_; }; @@ -74,9 +75,10 @@ pat::PATElectronSlimmer::PATElectronSlimmer(const edm::ParameterSet& iConfig) linkToPackedPF_(iConfig.getParameter("linkToPackedPFCandidates")), saveNonZSClusterShapes_(iConfig.getParameter("saveNonZSClusterShapes")), reducedBarrelRecHitCollectionToken_( - consumes(iConfig.getParameter("reducedBarrelRecHitCollection"))), + consumes(iConfig.getParameter("reducedBarrelRecHitCollection"))), reducedEndcapRecHitCollectionToken_( - consumes(iConfig.getParameter("reducedEndcapRecHitCollection"))), + consumes(iConfig.getParameter("reducedEndcapRecHitCollection"))), + ecalClusterToolsESGetTokens_{consumesCollector()}, modifyElectron_(iConfig.getParameter("modifyElectrons")) { if (modifyElectron_) { const edm::ParameterSet& mod_config = iConfig.getParameter("modifierConfig"); @@ -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>(); out->reserve(src->size()); diff --git a/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.cc b/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.cc index 462de130de6f4..549891a633dfc 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.cc @@ -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" @@ -30,7 +29,10 @@ using namespace pat; PATPhotonProducer::PATPhotonProducer(const edm::ParameterSet &iConfig) - : isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter("userIsolation") + : + + ecalClusterToolsESGetTokens_{consumesCollector()}, + isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter("userIsolation") : edm::ParameterSet(), consumesCollector(), false), @@ -172,8 +174,10 @@ void PATPhotonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetu edm::Handle 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>> genMatches(genMatchTokens_.size()); diff --git a/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h b/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h index 3a08d29af2461..2831391184805 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h @@ -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<> { @@ -74,6 +76,8 @@ namespace pat { edm::InputTag reducedEndcapRecHitCollection_; edm::EDGetTokenT reducedEndcapRecHitCollectionToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; + bool addPFClusterIso_; bool addPuppiIsolation_; edm::EDGetTokenT > ecalPFClusterIsoT_; diff --git a/PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc b/PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc index cc9ade4172bca..b24d3da8313d6 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc @@ -48,6 +48,7 @@ namespace pat { reducedEndcapRecHitCollectionToken_; const bool modifyPhoton_; std::unique_ptr> photonModifier_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; }; } // namespace pat @@ -72,7 +73,8 @@ pat::PATPhotonSlimmer::PATPhotonSlimmer(const edm::ParameterSet& iConfig) consumes(iConfig.getParameter("reducedBarrelRecHitCollection"))), reducedEndcapRecHitCollectionToken_( consumes(iConfig.getParameter("reducedEndcapRecHitCollection"))), - modifyPhoton_(iConfig.getParameter("modifyPhotons")) { + modifyPhoton_(iConfig.getParameter("modifyPhotons")), + ecalClusterToolsESGetTokens_{consumesCollector()} { if (modifyPhoton_) { const edm::ParameterSet& mod_config = iConfig.getParameter("modifierConfig"); photonModifier_ = std::make_unique>(mod_config, consumesCollector()); @@ -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>(); out->reserve(src->size()); diff --git a/RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h b/RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h index f889d369ddc60..6340700f80fa2 100644 --- a/RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h +++ b/RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h @@ -26,6 +26,14 @@ #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" +#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" +#include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h" +#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h" +#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" + #include class CaloTopology; @@ -34,8 +42,41 @@ class CaloSubdetectorTopology; class EcalClusterLazyToolsBase { public: + struct ESData { + CaloGeometry const &caloGeometry; + CaloTopology const &caloTopology; + EcalIntercalibConstants const &ecalIntercalibConstants; + EcalADCToGeVConstant const &ecalADCToGeV; + EcalLaserDbService const &ecalLaserDbService; + }; + + class ESGetTokens { + public: + ESGetTokens(edm::ConsumesCollector &&cc) + : caloGeometryToken_{cc.esConsumes()}, + caloTopologyToken_{cc.esConsumes()}, + ecalIntercalibConstantsToken_{cc.esConsumes()}, + ecalADCToGeVConstantToken_{cc.esConsumes()}, + ecalLaserDbServiceToken_{cc.esConsumes()} {} + + ESData get(edm::EventSetup const &eventSetup) const { + return {.caloGeometry = eventSetup.getData(caloGeometryToken_), + .caloTopology = eventSetup.getData(caloTopologyToken_), + .ecalIntercalibConstants = eventSetup.getData(ecalIntercalibConstantsToken_), + .ecalADCToGeV = eventSetup.getData(ecalADCToGeVConstantToken_), + .ecalLaserDbService = eventSetup.getData(ecalLaserDbServiceToken_)}; + } + + private: + edm::ESGetToken caloGeometryToken_; + edm::ESGetToken caloTopologyToken_; + edm::ESGetToken ecalIntercalibConstantsToken_; + edm::ESGetToken ecalADCToGeVConstantToken_; + edm::ESGetToken ecalLaserDbServiceToken_; + }; + EcalClusterLazyToolsBase(const edm::Event &ev, - const edm::EventSetup &es, + ESData const &esData, edm::EDGetTokenT token1, edm::EDGetTokenT token2, std::optional> token3); @@ -47,7 +88,9 @@ class EcalClusterLazyToolsBase { // get BasicClusterSeedTime of the seed basic cluser of the supercluster float SuperClusterSeedTime(const reco::SuperCluster &cluster); // get BasicClusterTime of the seed basic cluser of the supercluster - float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev); + inline float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev) { + return BasicClusterTime((*cluster.seed()), ev); + } // mapping for preshower rechits std::map rechits_map_; @@ -67,12 +110,6 @@ class EcalClusterLazyToolsBase { float eseffsixix(const reco::SuperCluster &cluster); float eseffsiyiy(const reco::SuperCluster &cluster); - EcalRecHitCollection const *getEcalEBRecHitCollection() const { return ebRecHits_; } - EcalRecHitCollection const *getEcalEERecHitCollection() const { return eeRecHits_; } - EcalRecHitCollection const *getEcalESRecHitCollection() const { return esRecHits_; } - EcalIntercalibConstants const &getEcalIntercalibConstants() const { return *icalMap; } - edm::ESHandle const &getLaserHandle() const { return laser; } - protected: EcalRecHitCollection const *getEcalRecHitCollection(const reco::BasicCluster &cluster) const; @@ -82,17 +119,15 @@ class EcalClusterLazyToolsBase { const EcalRecHitCollection *eeRecHits_; const EcalRecHitCollection *esRecHits_; - edm::EDGetTokenT esRHToken_; - std::unique_ptr ecalPS_topology_ = nullptr; - edm::ESHandle ical; - const EcalIntercalibConstantMap *icalMap; - edm::ESHandle agc; - edm::ESHandle laser; + EcalIntercalibConstants const *ical = nullptr; + EcalIntercalibConstantMap const *icalMap = nullptr; + EcalADCToGeVConstant const *agc = nullptr; + EcalLaserDbService const *laser = nullptr; private: - void getESRecHits(const edm::Event &ev); + void getESRecHits(const edm::Event &ev, edm::EDGetTokenT const &esRecHitsToken); }; // class EcalClusterLazyToolsBase @@ -100,17 +135,17 @@ template class EcalClusterLazyToolsT : public EcalClusterLazyToolsBase { public: EcalClusterLazyToolsT(const edm::Event &ev, - const edm::EventSetup &es, + ESData const &esData, edm::EDGetTokenT token1, edm::EDGetTokenT token2) - : EcalClusterLazyToolsBase(ev, es, token1, token2, std::nullopt) {} + : EcalClusterLazyToolsBase(ev, esData, token1, token2, std::nullopt) {} EcalClusterLazyToolsT(const edm::Event &ev, - const edm::EventSetup &es, + ESData const &esData, edm::EDGetTokenT token1, edm::EDGetTokenT token2, edm::EDGetTokenT token3) - : EcalClusterLazyToolsBase(ev, es, token1, token2, token3) {} + : EcalClusterLazyToolsBase(ev, esData, token1, token2, token3) {} // Get the rec hit energies in a rectangle matrix around the seed. std::vector energyMatrix(reco::BasicCluster const &cluster, int size) const { diff --git a/RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc b/RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc index e8f536c9848a6..518b4a54dead5 100644 --- a/RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc +++ b/RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc @@ -8,27 +8,20 @@ #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/CaloTopology/interface/CaloTopology.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" #include "Geometry/CaloTopology/interface/EcalPreshowerTopology.h" #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h" #include "RecoCaloTools/Navigation/interface/EcalPreshowerNavigator.h" -#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h" -#include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h" -#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h" - #include "CommonTools/Utils/interface/StringToEnumValue.h" -#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" EcalClusterLazyToolsBase::EcalClusterLazyToolsBase(const edm::Event &ev, - const edm::EventSetup &eventSetup, + ESData const &esData, edm::EDGetTokenT token1, edm::EDGetTokenT token2, std::optional> token3) - : geometry_(&edm::get(eventSetup)), - topology_(&edm::get(eventSetup)), + : geometry_(&esData.caloGeometry), + topology_(&esData.caloTopology), ebRecHits_(&edm::get(ev, token1)), eeRecHits_(&edm::get(ev, token2)) { if (token3) { @@ -38,21 +31,21 @@ EcalClusterLazyToolsBase::EcalClusterLazyToolsBase(const edm::Event &ev, edm::LogInfo("subdetector geometry not available") << "EcalPreshower geometry is missing" << std::endl; } - esRHToken_ = *token3; - getESRecHits(ev); + getESRecHits(ev, *token3); } // get IC's - eventSetup.get().get(ical); + ical = &esData.ecalIntercalibConstants; icalMap = &ical->getMap(); // get ADCtoGeV - eventSetup.get().get(agc); + agc = &esData.ecalADCToGeV; // transp corrections - eventSetup.get().get(laser); + laser = &esData.ecalLaserDbService; } -void EcalClusterLazyToolsBase::getESRecHits(const edm::Event &ev) { - auto pESRecHits = ev.getHandle(esRHToken_); +void EcalClusterLazyToolsBase::getESRecHits(const edm::Event &ev, + edm::EDGetTokenT const &esRecHitsToken) { + auto pESRecHits = ev.getHandle(esRecHitsToken); esRecHits_ = pESRecHits.product(); // make the map of rechits rechits_map_.clear(); @@ -186,11 +179,6 @@ float EcalClusterLazyToolsBase::SuperClusterSeedTime(const reco::SuperCluster &c return BasicClusterSeedTime((*cluster.seed())); } -// get BasicClusterTime of the seed basic cluser of the supercluster -float EcalClusterLazyToolsBase::SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev) { - return BasicClusterTime((*cluster.seed()), ev); -} - // get Preshower effective sigmaIRIR float EcalClusterLazyToolsBase::eseffsirir(const reco::SuperCluster &cluster) { if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) diff --git a/RecoEcal/EgammaCoreTools/test/testEcalClusterLazyTools.cc b/RecoEcal/EgammaCoreTools/test/testEcalClusterLazyTools.cc index 7e683a1612105..08fe5d34a6aeb 100644 --- a/RecoEcal/EgammaCoreTools/test/testEcalClusterLazyTools.cc +++ b/RecoEcal/EgammaCoreTools/test/testEcalClusterLazyTools.cc @@ -45,15 +45,16 @@ class testEcalClusterLazyTools : public edm::one::EDAnalyzer<> { const edm::EDGetTokenT endcapClusterToken_; const edm::EDGetTokenT barrelRecHitToken_; const edm::EDGetTokenT endcapRecHitToken_; + + LazyTools::ESGetTokens esGetTokens_; }; testEcalClusterLazyTools::testEcalClusterLazyTools(const edm::ParameterSet& ps) - : barrelClusterToken_( - consumes(ps.getParameter("barrelClusterCollection"))), - endcapClusterToken_( - consumes(ps.getParameter("endcapClusterCollection"))), - barrelRecHitToken_(consumes(ps.getParameter("barrelRecHitCollection"))), - endcapRecHitToken_(consumes(ps.getParameter("endcapRecHitCollection"))) {} + : barrelClusterToken_(consumes(ps.getParameter("barrelClusterCollection"))), + endcapClusterToken_(consumes(ps.getParameter("endcapClusterCollection"))), + barrelRecHitToken_(consumes(ps.getParameter("barrelRecHitCollection"))), + endcapRecHitToken_(consumes(ps.getParameter("endcapRecHitCollection"))), + esGetTokens_{consumesCollector()} {} void testEcalClusterLazyTools::analyze(const edm::Event& ev, const edm::EventSetup& es) { edm::Handle pEBClusters; @@ -64,7 +65,7 @@ void testEcalClusterLazyTools::analyze(const edm::Event& ev, const edm::EventSet ev.getByToken(endcapClusterToken_, pEEClusters); const reco::BasicClusterCollection* eeClusters = pEEClusters.product(); - LazyTools lazyTools(ev, es, barrelRecHitToken_, endcapRecHitToken_); + LazyTools lazyTools(ev, esGetTokens_.get(es), barrelRecHitToken_, endcapRecHitToken_); std::cout << "========== BARREL ==========" << std::endl; for (auto const& clus : *ebClusters) { diff --git a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc index 93136a5c4f8de..5b2c463e5cc55 100644 --- a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc +++ b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc @@ -152,6 +152,7 @@ class LowPtGsfElectronSeedProducer final const edm::ESGetToken trajectoryFitterToken_; const edm::ESGetToken trajectorySmootherToken_; const edm::ESGetToken builderToken_; + const noZS::EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; const bool passThrough_; const bool usePfTracks_; @@ -182,6 +183,7 @@ LowPtGsfElectronSeedProducer::LowPtGsfElectronSeedProducer(const edm::ParameterS trajectoryFitterToken_{esConsumes(conf.getParameter("Fitter"))}, trajectorySmootherToken_{esConsumes(conf.getParameter("Smoother"))}, builderToken_{esConsumes(conf.getParameter("TTRHBuilder"))}, + ecalClusterToolsESGetTokens_{consumesCollector()}, passThrough_(conf.getParameter("PassThrough")), usePfTracks_(conf.getParameter("UsePfTracks")), minPtThreshold_(conf.getParameter("MinPtThreshold")), @@ -313,7 +315,7 @@ void LowPtGsfElectronSeedProducer::loop(const edm::Handle >& hand auto ecalClusters = event.getHandle(ecalClusters_); // Utility to access to shower shape vars - noZS::EcalClusterLazyTools ecalTools(event, setup, ebRecHits_, eeRecHits_); + noZS::EcalClusterLazyTools ecalTools(event, ecalClusterToolsESGetTokens_.get(setup), ebRecHits_, eeRecHits_); // Ensure each cluster is only matched once to a track std::vector matchedEcalClusters; diff --git a/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTClusterShapeProducer.cc b/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTClusterShapeProducer.cc index a10a0fbc7bf2c..3f52dbe33e98e 100644 --- a/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTClusterShapeProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTClusterShapeProducer.cc @@ -40,14 +40,15 @@ class EgammaHLTClusterShapeProducer : public edm::global::EDProducer<> { const edm::EDGetTokenT recoEcalCandidateProducer_; const edm::EDGetTokenT ecalRechitEBToken_; const edm::EDGetTokenT ecalRechitEEToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterLazyToolsESGetTokens_; const bool EtaOrIeta_; }; EgammaHLTClusterShapeProducer::EgammaHLTClusterShapeProducer(const edm::ParameterSet& config) - : recoEcalCandidateProducer_( - consumes(config.getParameter("recoEcalCandidateProducer"))), - ecalRechitEBToken_(consumes(config.getParameter("ecalRechitEB"))), - ecalRechitEEToken_(consumes(config.getParameter("ecalRechitEE"))), + : recoEcalCandidateProducer_(consumes(config.getParameter("recoEcalCandidateProducer"))), + ecalRechitEBToken_(consumes(config.getParameter("ecalRechitEB"))), + ecalRechitEEToken_(consumes(config.getParameter("ecalRechitEE"))), + ecalClusterLazyToolsESGetTokens_{consumesCollector()}, EtaOrIeta_(config.getParameter("isIeta")) { //register your products produces(); @@ -72,8 +73,10 @@ void EgammaHLTClusterShapeProducer::produce(edm::StreamID sid, edm::Handle recoecalcandHandle; iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); - EcalClusterLazyTools lazyTools(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); - noZS::EcalClusterLazyTools lazyTools5x5(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); + auto const& ecalClusterLazyToolsESData = ecalClusterLazyToolsESGetTokens_.get(iSetup); + + EcalClusterLazyTools lazyTools(iEvent, ecalClusterLazyToolsESData, ecalRechitEBToken_, ecalRechitEEToken_); + noZS::EcalClusterLazyTools lazyTools5x5(iEvent, ecalClusterLazyToolsESData, ecalRechitEBToken_, ecalRechitEEToken_); reco::RecoEcalCandidateIsolationMap clshMap(recoecalcandHandle); reco::RecoEcalCandidateIsolationMap clsh5x5Map(recoecalcandHandle); diff --git a/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTR9IDProducer.cc b/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTR9IDProducer.cc index beb1bda34f7cc..a2781c65796cf 100644 --- a/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTR9IDProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTR9IDProducer.cc @@ -38,7 +38,6 @@ class EgammaHLTR9IDProducer : public edm::global::EDProducer<> { public: explicit EgammaHLTR9IDProducer(const edm::ParameterSet&); - ~EgammaHLTR9IDProducer() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override; @@ -49,20 +48,19 @@ class EgammaHLTR9IDProducer : public edm::global::EDProducer<> { const edm::EDGetTokenT recoEcalCandidateProducer_; const edm::EDGetTokenT ecalRechitEBToken_; const edm::EDGetTokenT ecalRechitEEToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; }; EgammaHLTR9IDProducer::EgammaHLTR9IDProducer(const edm::ParameterSet& config) - : recoEcalCandidateProducer_( - consumes(config.getParameter("recoEcalCandidateProducer"))), - ecalRechitEBToken_(consumes(config.getParameter("ecalRechitEB"))), - ecalRechitEEToken_(consumes(config.getParameter("ecalRechitEE"))) { + : recoEcalCandidateProducer_(consumes(config.getParameter("recoEcalCandidateProducer"))), + ecalRechitEBToken_(consumes(config.getParameter("ecalRechitEB"))), + ecalRechitEEToken_(consumes(config.getParameter("ecalRechitEE"))), + ecalClusterToolsESGetTokens_{consumesCollector()} { //register your products produces(); produces("r95x5"); } -EgammaHLTR9IDProducer::~EgammaHLTR9IDProducer() {} - void EgammaHLTR9IDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalCandidate")); @@ -77,8 +75,9 @@ void EgammaHLTR9IDProducer::produce(edm::StreamID sid, edm::Event& iEvent, const edm::Handle recoecalcandHandle; iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); - EcalClusterLazyTools lazyTools(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); - noZS::EcalClusterLazyTools lazyTools5x5(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); + auto const& ecalClusterToolsESData = ecalClusterToolsESGetTokens_.get(iSetup); + EcalClusterLazyTools lazyTools(iEvent, ecalClusterToolsESData, ecalRechitEBToken_, ecalRechitEEToken_); + noZS::EcalClusterLazyTools lazyTools5x5(iEvent, ecalClusterToolsESData, ecalRechitEBToken_, ecalRechitEEToken_); reco::RecoEcalCandidateIsolationMap r9Map(recoecalcandHandle); reco::RecoEcalCandidateIsolationMap r95x5Map(recoecalcandHandle); for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoecalcandHandle->size(); iRecoEcalCand++) { diff --git a/RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h b/RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h index 133af9a83a57a..fc66f5bd5837d 100644 --- a/RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h +++ b/RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h @@ -15,6 +15,7 @@ #include "RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h" #include "CommonTools/CandAlgos/interface/ModifyObjectValueBase.h" #include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionBaseClass.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "DataFormats/EgammaCandidates/interface/Photon.h" @@ -50,6 +51,7 @@ class PhotonEnergyCorrector { edm::InputTag endcapEcalHits_; edm::EDGetTokenT barrelEcalHitsToken_; edm::EDGetTokenT endcapEcalHitsToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; std::unique_ptr photonUncertaintyCalculator_; }; diff --git a/RecoEgamma/EgammaPhotonAlgos/src/PhotonEnergyCorrector.cc b/RecoEgamma/EgammaPhotonAlgos/src/PhotonEnergyCorrector.cc index d0e17aa14e037..f71889d291c92 100644 --- a/RecoEgamma/EgammaPhotonAlgos/src/PhotonEnergyCorrector.cc +++ b/RecoEgamma/EgammaPhotonAlgos/src/PhotonEnergyCorrector.cc @@ -1,6 +1,5 @@ #include "RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h" #include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionFactory.h" -#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" #include "Geometry/CaloTopology/interface/CaloTopology.h" @@ -11,7 +10,8 @@ #include "RecoEgamma/EgammaPhotonAlgos/interface/EnergyUncertaintyPhotonSpecific.h" -PhotonEnergyCorrector::PhotonEnergyCorrector(const edm::ParameterSet& config, edm::ConsumesCollector&& iC) { +PhotonEnergyCorrector::PhotonEnergyCorrector(const edm::ParameterSet& config, edm::ConsumesCollector&& iC) + : ecalClusterToolsESGetTokens_{std::move(iC)} { minR9Barrel_ = config.getParameter("minR9Barrel"); minR9Endcap_ = config.getParameter("minR9Endcap"); // get the geometry from the event setup: @@ -95,7 +95,8 @@ void PhotonEnergyCorrector::calculate(edm::Event& evt, minR9 = minR9Endcap_; } - EcalClusterLazyTools lazyTools(evt, iSetup, barrelEcalHitsToken_, endcapEcalHitsToken_); + EcalClusterLazyTools lazyTools( + evt, ecalClusterToolsESGetTokens_.get(iSetup), barrelEcalHitsToken_, endcapEcalHitsToken_); ////////////// Here default Ecal corrections based on electrons //////////////////////// if (thePhoton.r9() > minR9) { diff --git a/RecoEgamma/EgammaPhotonProducers/interface/GEDPhotonProducer.h b/RecoEgamma/EgammaPhotonProducers/interface/GEDPhotonProducer.h index ad800012a4cfb..169d8b0c90903 100644 --- a/RecoEgamma/EgammaPhotonProducers/interface/GEDPhotonProducer.h +++ b/RecoEgamma/EgammaPhotonProducers/interface/GEDPhotonProducer.h @@ -114,6 +114,8 @@ class GEDPhotonProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT> phoPFECALClusIsolationToken_; edm::EDGetTokenT> phoPFHCALClusIsolationToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterESGetTokens_; + std::string conversionProducer_; std::string conversionCollection_; std::string valueMapPFCandPhoton_; diff --git a/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc b/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc index 9a644ca10ed98..8c2abb38fc878 100644 --- a/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc +++ b/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc @@ -56,7 +56,9 @@ GEDPhotonProducer::RecoStepInfo::RecoStepInfo(const std::string& step) : flags_( } GEDPhotonProducer::GEDPhotonProducer(const edm::ParameterSet& config) - : recoStep_(config.getParameter("reconstructionStep")), conf_(config) { + : ecalClusterESGetTokens_{consumesCollector()}, + recoStep_(config.getParameter("reconstructionStep")), + conf_(config) { // use configuration file to setup input/output collection names // photonProducer_ = conf_.getParameter("photonProducer"); @@ -644,7 +646,8 @@ void GEDPhotonProducer::fillPhotonCollection(edm::Event& evt, } // fill preshower shapes - EcalClusterLazyTools toolsforES(evt, es, barrelEcalHits_, endcapEcalHits_, preshowerHits_); + EcalClusterLazyTools toolsforES( + evt, ecalClusterESGetTokens_.get(es), barrelEcalHits_, endcapEcalHits_, preshowerHits_); const float sigmaRR = toolsforES.eseffsirir(*scRef); showerShape.effSigmaRR = sigmaRR; newCandidate.setShowerShapeVariables(showerShape); diff --git a/RecoEgamma/EgammaTools/plugins/EGEnergyAnalyzer.cc b/RecoEgamma/EgammaTools/plugins/EGEnergyAnalyzer.cc index 05631fbd5dd49..5ea8c90e089ae 100644 --- a/RecoEgamma/EgammaTools/plugins/EGEnergyAnalyzer.cc +++ b/RecoEgamma/EgammaTools/plugins/EGEnergyAnalyzer.cc @@ -57,9 +57,11 @@ class EGEnergyAnalyzer : public edm::one::EDAnalyzer<> { EGEnergyCorrector cordb; edm::EDGetTokenT ebRHToken_, eeRHToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; }; -EGEnergyAnalyzer::EGEnergyAnalyzer(const edm::ParameterSet& iConfig) { +EGEnergyAnalyzer::EGEnergyAnalyzer(const edm::ParameterSet& iConfig) + : ecalClusterToolsESGetTokens_{consumesCollector()} { ebRHToken_ = consumes(edm::InputTag("reducedEcalRecHitsEB")); eeRHToken_ = consumes(edm::InputTag("reducedEcalRecHitsEE")); } @@ -91,7 +93,7 @@ void EGEnergyAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& Handle hPhotonProduct; iEvent.getByLabel("photons", hPhotonProduct); - EcalClusterLazyTools lazyTools(iEvent, iSetup, ebRHToken_, eeRHToken_); + EcalClusterLazyTools lazyTools(iEvent, ecalClusterToolsESGetTokens_.get(iSetup), ebRHToken_, eeRHToken_); Handle hVertexProduct; iEvent.getByLabel("offlinePrimaryVerticesWithBS", hVertexProduct); diff --git a/RecoEgamma/ElectronIdentification/plugins/ElectronMVANtuplizer.cc b/RecoEgamma/ElectronIdentification/plugins/ElectronMVANtuplizer.cc index 366f7ddfb76dd..c41c2c2df6f7d 100644 --- a/RecoEgamma/ElectronIdentification/plugins/ElectronMVANtuplizer.cc +++ b/RecoEgamma/ElectronIdentification/plugins/ElectronMVANtuplizer.cc @@ -114,6 +114,8 @@ class ElectronMVANtuplizer : public edm::one::EDAnalyzer ebRecHits_; const edm::EDGetTokenT eeRecHits_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; + // to hold ID decisions and categories std::vector mvaPasses_; std::vector mvaValues_; @@ -166,6 +168,7 @@ ElectronMVANtuplizer::ElectronMVANtuplizer(const edm::ParameterSet& iConfig) genParticles_(consumes>(iConfig.getParameter("genParticles"))), ebRecHits_(consumes(iConfig.getParameter("ebReducedRecHitCollection"))), eeRecHits_(consumes(iConfig.getParameter("eeReducedRecHitCollection"))), + ecalClusterToolsESGetTokens_{consumesCollector()}, mvaPasses_(nEleMaps_), mvaValues_(nValMaps_), mvaCats_(nCats_), @@ -249,7 +252,8 @@ void ElectronMVANtuplizer::analyze(const edm::Event& iEvent, const edm::EventSet std::unique_ptr lazyTools; if (doEnergyMatrix_) { // Configure Lazy Tools, which will compute 5x5 quantities - lazyTools = std::make_unique(iEvent, iSetup, ebRecHits_, eeRecHits_); + lazyTools = std::make_unique( + iEvent, ecalClusterToolsESGetTokens_.get(iSetup), ebRecHits_, eeRecHits_); } // Get MC only Handles, which are allowed to be non-valid diff --git a/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc b/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc index 26b78428924d5..1c05588724292 100644 --- a/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc +++ b/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc @@ -114,6 +114,8 @@ class PhotonIDValueMapProducer : public edm::global::EDProducer<> { const edm::EDGetTokenT> pfCandsToken_; const edm::EDGetToken particleBasedIsolationToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; + const bool isAOD_; }; @@ -158,14 +160,15 @@ const unsigned char PT_MIN_THRESH = 0x8; PhotonIDValueMapProducer::PhotonIDValueMapProducer(const edm::ParameterSet& cfg) : usesES_(!cfg.getParameter("esReducedRecHitCollection").label().empty()), - src_(consumes>(cfg.getParameter("src"))), - ebRecHits_(consumes(cfg.getParameter("ebReducedRecHitCollection"))), - eeRecHits_(consumes(cfg.getParameter("eeReducedRecHitCollection"))), - esRecHits_(consumes(cfg.getParameter("esReducedRecHitCollection"))), - vtxToken_(consumes(cfg.getParameter("vertices"))), - pfCandsToken_(consumes>(cfg.getParameter("pfCandidates"))), + src_(consumes(cfg.getParameter("src"))), + ebRecHits_(consumes(cfg.getParameter("ebReducedRecHitCollection"))), + eeRecHits_(consumes(cfg.getParameter("eeReducedRecHitCollection"))), + esRecHits_(consumes(cfg.getParameter("esReducedRecHitCollection"))), + vtxToken_(consumes(cfg.getParameter("vertices"))), + pfCandsToken_(consumes(cfg.getParameter("pfCandidates"))), particleBasedIsolationToken_(mayConsume>>( cfg.getParameter("particleBasedIsolation")) /* ...only for AOD... */), + ecalClusterToolsESGetTokens_{consumesCollector()}, isAOD_(cfg.getParameter("isAOD")) { // Declare producibles for (int i = 0; i < nVars_; ++i) @@ -190,8 +193,10 @@ void PhotonIDValueMapProducer::produce(edm::StreamID, edm::Event& iEvent, const } // Configure Lazy Tools, which will compute 5x5 quantities - auto lazyToolnoZS = usesES_ ? noZS::EcalClusterLazyTools(iEvent, iSetup, ebRecHits_, eeRecHits_, esRecHits_) - : noZS::EcalClusterLazyTools(iEvent, iSetup, ebRecHits_, eeRecHits_); + auto const& ecalClusterToolsESData = ecalClusterToolsESGetTokens_.get(iSetup); + auto lazyToolnoZS = + usesES_ ? noZS::EcalClusterLazyTools(iEvent, ecalClusterToolsESData, ebRecHits_, eeRecHits_, esRecHits_) + : noZS::EcalClusterLazyTools(iEvent, ecalClusterToolsESData, ebRecHits_, eeRecHits_); // Get PV if (vertices->empty()) diff --git a/RecoEgamma/PhotonIdentification/plugins/PhotonMVANtuplizer.cc b/RecoEgamma/PhotonIdentification/plugins/PhotonMVANtuplizer.cc index 6c65366b758b1..79cdf3b07bb24 100644 --- a/RecoEgamma/PhotonIdentification/plugins/PhotonMVANtuplizer.cc +++ b/RecoEgamma/PhotonIdentification/plugins/PhotonMVANtuplizer.cc @@ -99,6 +99,8 @@ class PhotonMVANtuplizer : public edm::one::EDAnalyzer ebRecHits_; const edm::EDGetTokenT eeRecHits_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; + // to hold ID decisions and categories std::vector mvaPasses_; std::vector mvaValues_; @@ -173,6 +175,7 @@ PhotonMVANtuplizer::PhotonMVANtuplizer(const edm::ParameterSet& iConfig) genParticles_(consumes>(iConfig.getParameter("genParticles"))), ebRecHits_(consumes(iConfig.getParameter("ebReducedRecHitCollection"))), eeRecHits_(consumes(iConfig.getParameter("eeReducedRecHitCollection"))), + ecalClusterToolsESGetTokens_{consumesCollector()}, mvaPasses_(nPhoMaps_), mvaValues_(nValMaps_), mvaCats_(nCats_), @@ -251,7 +254,8 @@ void PhotonMVANtuplizer::analyze(const edm::Event& iEvent, const edm::EventSetup std::unique_ptr lazyTools; if (doEnergyMatrix_) { // Configure Lazy Tools, which will compute 5x5 quantities - lazyTools = std::make_unique(iEvent, iSetup, ebRecHits_, eeRecHits_); + lazyTools = std::make_unique( + iEvent, ecalClusterToolsESGetTokens_.get(iSetup), ebRecHits_, eeRecHits_); } // Fill with true number of pileup diff --git a/RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc b/RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc index d4fab98438ecb..8424f4e0d8d77 100644 --- a/RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc +++ b/RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc @@ -56,6 +56,7 @@ class HiSpikeCleaner : public edm::stream::EDProducer<> { edm::EDGetTokenT sCInputProducerToken_; edm::EDGetTokenT rHInputProducerBToken_; edm::EDGetTokenT rHInputProducerEToken_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; std::string outputCollection_; double TimingCut_; @@ -63,7 +64,7 @@ class HiSpikeCleaner : public edm::stream::EDProducer<> { double etCut_; }; -HiSpikeCleaner::HiSpikeCleaner(const edm::ParameterSet& iConfig) { +HiSpikeCleaner::HiSpikeCleaner(const edm::ParameterSet& iConfig) : ecalClusterToolsESGetTokens_{consumesCollector()} { //register your products /* Examples produces(); @@ -133,7 +134,8 @@ void HiSpikeCleaner::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) // Create a pointer to the RecHits and raw SuperClusters const reco::SuperClusterCollection* rawClusters = pRawSuperClusters.product(); - EcalClusterLazyTools lazyTool(iEvent, iSetup, rHInputProducerBToken_, rHInputProducerEToken_); + EcalClusterLazyTools lazyTool( + iEvent, ecalClusterToolsESGetTokens_.get(iSetup), rHInputProducerBToken_, rHInputProducerEToken_); // Define a collection of corrected SuperClusters to put back into the event auto corrClusters = std::make_unique(); diff --git a/RecoHI/HiEgammaAlgos/plugins/photonIsolationHIProducer.cc b/RecoHI/HiEgammaAlgos/plugins/photonIsolationHIProducer.cc index 240b4a2880515..f3d2525f6a1a9 100644 --- a/RecoHI/HiEgammaAlgos/plugins/photonIsolationHIProducer.cc +++ b/RecoHI/HiEgammaAlgos/plugins/photonIsolationHIProducer.cc @@ -38,19 +38,22 @@ class photonIsolationHIProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT endcapClusters_; edm::EDGetTokenT tracks_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; + std::string trackQuality_; }; photonIsolationHIProducer::photonIsolationHIProducer(const edm::ParameterSet& config) - : photonProducer_(consumes(config.getParameter("photonProducer"))), - barrelEcalHits_(consumes(config.getParameter("ebRecHitCollection"))), - endcapEcalHits_(consumes(config.getParameter("eeRecHitCollection"))), - hbhe_(consumes(config.getParameter("hbhe"))), - hf_(consumes(config.getParameter("hf"))), - ho_(consumes(config.getParameter("ho"))), - barrelClusters_(consumes(config.getParameter("basicClusterBarrel"))), - endcapClusters_(consumes(config.getParameter("basicClusterEndcap"))), - tracks_(consumes(config.getParameter("trackCollection"))), + : photonProducer_(consumes(config.getParameter("photonProducer"))), + barrelEcalHits_(consumes(config.getParameter("ebRecHitCollection"))), + endcapEcalHits_(consumes(config.getParameter("eeRecHitCollection"))), + hbhe_(consumes(config.getParameter("hbhe"))), + hf_(consumes(config.getParameter("hf"))), + ho_(consumes(config.getParameter("ho"))), + barrelClusters_(consumes(config.getParameter("basicClusterBarrel"))), + endcapClusters_(consumes(config.getParameter("basicClusterEndcap"))), + tracks_(consumes(config.getParameter("trackCollection"))), + ecalClusterToolsESGetTokens_{consumesCollector()}, trackQuality_(config.getParameter("trackQuality")) { produces(); } @@ -82,7 +85,7 @@ void photonIsolationHIProducer::produce(edm::Event& evt, const edm::EventSetup& EcalClusterIsoCalculator CxC(evt, es, barrelClusters, endcapClusters); HcalRechitIsoCalculator RxC(evt, es, hbhe, hf, ho); TrackIsoCalculator TxC(*trackCollection, trackQuality_); - EcalClusterLazyTools lazyTool(evt, es, barrelEcalHits_, endcapEcalHits_); + EcalClusterLazyTools lazyTool(evt, ecalClusterToolsESGetTokens_.get(es), barrelEcalHits_, endcapEcalHits_); for (reco::PhotonCollection::const_iterator phoItr = photons->begin(); phoItr != photons->end(); ++phoItr) { reco::HIPhotonIsolation iso; diff --git a/RecoParticleFlow/PFClusterProducer/interface/PFClusterEMEnergyCorrector.h b/RecoParticleFlow/PFClusterProducer/interface/PFClusterEMEnergyCorrector.h index cc704ecc12827..1f7fe28aecbf6 100644 --- a/RecoParticleFlow/PFClusterProducer/interface/PFClusterEMEnergyCorrector.h +++ b/RecoParticleFlow/PFClusterProducer/interface/PFClusterEMEnergyCorrector.h @@ -45,6 +45,8 @@ class PFClusterEMEnergyCorrector { edm::EDGetTokenT recHitsEE_; edm::EDGetTokenT bunchSpacing_; + const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; + std::vector condnames_mean_; std::vector condnames_sigma_; diff --git a/RecoParticleFlow/PFClusterProducer/src/PFClusterEMEnergyCorrector.cc b/RecoParticleFlow/PFClusterProducer/src/PFClusterEMEnergyCorrector.cc index f3ba9f31cefdd..5d63ea8f43ea1 100644 --- a/RecoParticleFlow/PFClusterProducer/src/PFClusterEMEnergyCorrector.cc +++ b/RecoParticleFlow/PFClusterProducer/src/PFClusterEMEnergyCorrector.cc @@ -12,7 +12,7 @@ namespace { } // namespace PFClusterEMEnergyCorrector::PFClusterEMEnergyCorrector(const edm::ParameterSet &conf, edm::ConsumesCollector &&cc) - : calibrator_(new PFEnergyCalibration) { + : ecalClusterToolsESGetTokens_{std::move(cc)}, calibrator_(new PFEnergyCalibration) { applyCrackCorrections_ = conf.getParameter("applyCrackCorrections"); applyMVACorrections_ = conf.getParameter("applyMVACorrections"); srfAwareCorrection_ = conf.getParameter("srfAwareCorrection"); @@ -148,7 +148,7 @@ void PFClusterEMEnergyCorrector::correctEnergies(const edm::Event &evt, } // Common objects for SRF-aware and old style corrections - EcalClusterLazyTools lazyTool(evt, es, recHitsEB_, recHitsEE_); + EcalClusterLazyTools lazyTool(evt, ecalClusterToolsESGetTokens_.get(es), recHitsEB_, recHitsEE_); EcalReadoutTools readoutTool(evt, es); if (!srfAwareCorrection_) { diff --git a/Validation/EcalClusters/interface/EgammaSuperClusters.h b/Validation/EcalClusters/interface/EgammaSuperClusters.h index 516224e22907e..1deb547e51122 100644 --- a/Validation/EcalClusters/interface/EgammaSuperClusters.h +++ b/Validation/EcalClusters/interface/EgammaSuperClusters.h @@ -17,6 +17,8 @@ #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" + #include "HistSpec.h" #include "DQMServices/Core/interface/DQMStore.h" @@ -47,6 +49,8 @@ class EgammaSuperClusters : public DQMEDAnalyzer { edm::EDGetTokenT barrelRecHitCollectionToken_; edm::EDGetTokenT endcapRecHitCollectionToken_; + EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; + HistSpec hsSize_; HistSpec hsNumBC_; HistSpec hsET_; diff --git a/Validation/EcalClusters/src/EgammaSuperClusters.cc b/Validation/EcalClusters/src/EgammaSuperClusters.cc index 5a53aad75c8e3..6950a78b4ab2e 100644 --- a/Validation/EcalClusters/src/EgammaSuperClusters.cc +++ b/Validation/EcalClusters/src/EgammaSuperClusters.cc @@ -4,8 +4,6 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" - #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/EgammaReco/interface/BasicCluster.h" #include "DataFormats/EgammaReco/interface/SuperCluster.h" @@ -31,6 +29,7 @@ EgammaSuperClusters::EgammaSuperClusters(const edm::ParameterSet &ps) consumes(ps.getParameter("barrelRecHitCollection"))), endcapRecHitCollectionToken_( consumes(ps.getParameter("endcapRecHitCollection"))), + ecalClusterToolsESGetTokens_{consumesCollector()}, hsSize_(ps, "Size"), hsNumBC_(ps, "NumBC"), hsET_(ps, "ET"), @@ -419,7 +418,8 @@ void EgammaSuperClusters::analyze(const edm::Event &evt, const edm::EventSetup & if (skipBarrel || skipEndcap) return; - EcalClusterLazyTools lazyTool(evt, es, barrelRecHitCollectionToken_, endcapRecHitCollectionToken_); + EcalClusterLazyTools lazyTool( + evt, ecalClusterToolsESGetTokens_.get(es), barrelRecHitCollectionToken_, endcapRecHitCollectionToken_); // Get the BARREL collections const reco::SuperClusterCollection *barrelRawSuperClusters = pBarrelRawSuperClusters.product();