From 8b61ca6e3f1f008795a8f6512b08c8e1565ac382 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Fri, 7 Aug 2020 22:33:42 -0500 Subject: [PATCH 1/4] Migrate to esConsumes --- Validation/MuonCSCDigis/interface/CSCStubMatcher.h | 2 +- Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc | 6 ++---- Validation/MuonCSCDigis/plugins/CSCDigiValidation.h | 4 ++++ Validation/MuonCSCDigis/src/CSCStubMatcher.cc | 8 +++++--- Validation/MuonHits/interface/CSCSimHitMatcher.h | 4 +++- Validation/MuonHits/interface/DTSimHitMatcher.h | 4 +++- Validation/MuonHits/interface/GEMSimHitMatcher.h | 4 +++- Validation/MuonHits/interface/ME0SimHitMatcher.h | 4 +++- Validation/MuonHits/interface/RPCSimHitMatcher.h | 4 +++- Validation/MuonHits/src/CSCSimHitMatcher.cc | 7 ++++--- Validation/MuonHits/src/DTSimHitMatcher.cc | 7 ++++--- Validation/MuonHits/src/GEMSimHitMatcher.cc | 7 ++++--- Validation/MuonHits/src/ME0SimHitMatcher.cc | 7 ++++--- Validation/MuonHits/src/RPCSimHitMatcher.cc | 7 ++++--- 14 files changed, 47 insertions(+), 28 deletions(-) diff --git a/Validation/MuonCSCDigis/interface/CSCStubMatcher.h b/Validation/MuonCSCDigis/interface/CSCStubMatcher.h index ea35289dbff29..d5acd5b43d75d 100644 --- a/Validation/MuonCSCDigis/interface/CSCStubMatcher.h +++ b/Validation/MuonCSCDigis/interface/CSCStubMatcher.h @@ -105,7 +105,7 @@ class CSCStubMatcher { std::shared_ptr cscDigiMatcher_; std::shared_ptr gemDigiMatcher_; - edm::ESHandle csc_geom_; + edm::ESGetToken geomToken_; const CSCGeometry* cscGeometry_; // all stubs (not necessarily matching) in crossed chambers with digis diff --git a/Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc b/Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc index b62d59560706b..02a399be6247e 100644 --- a/Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc +++ b/Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc @@ -1,7 +1,5 @@ #include "Validation/MuonCSCDigis/plugins/CSCDigiValidation.h" #include "FWCore/ServiceRegistry/interface/Service.h" -#include "Geometry/CSCGeometry/interface/CSCGeometry.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Validation/MuonCSCDigis/interface/CSCALCTDigiValidation.h" #include "Validation/MuonCSCDigis/interface/CSCCLCTDigiValidation.h" #include "Validation/MuonCSCDigis/interface/CSCComparatorDigiValidation.h" @@ -37,6 +35,7 @@ CSCDigiValidation::CSCDigiValidation(const edm::ParameterSet &ps) theWireDigiValidation->setSimHitMap(&theSimHitMap); theComparatorDigiValidation->setSimHitMap(&theSimHitMap); } + geomToken_ = esConsumes(); } CSCDigiValidation::~CSCDigiValidation() {} @@ -56,8 +55,7 @@ void CSCDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &even theSimHitMap.fill(e); // find the geometry & conditions for this event - edm::ESHandle hGeom; - eventSetup.get().get(hGeom); + edm::ESHandle hGeom = eventSetup.getHandle(geomToken_); const CSCGeometry *pGeom = &*hGeom; theStripDigiValidation->setGeometry(pGeom); diff --git a/Validation/MuonCSCDigis/plugins/CSCDigiValidation.h b/Validation/MuonCSCDigis/plugins/CSCDigiValidation.h index edb7c8cb605e1..6ecac8f812028 100644 --- a/Validation/MuonCSCDigis/plugins/CSCDigiValidation.h +++ b/Validation/MuonCSCDigis/plugins/CSCDigiValidation.h @@ -5,11 +5,13 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Utilities/interface/ESGetToken.h" #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/DQMStore.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "SimMuon/MCTruth/interface/PSimHitMap.h" class CSCStripDigiValidation; @@ -35,6 +37,8 @@ class CSCDigiValidation : public DQMEDAnalyzer { std::unique_ptr theComparatorDigiValidation; std::unique_ptr theALCTDigiValidation; std::unique_ptr theCLCTDigiValidation; + + edm::ESGetToken geomToken_; }; #endif diff --git a/Validation/MuonCSCDigis/src/CSCStubMatcher.cc b/Validation/MuonCSCDigis/src/CSCStubMatcher.cc index 826977d1ad092..4d5ea58648261 100644 --- a/Validation/MuonCSCDigis/src/CSCStubMatcher.cc +++ b/Validation/MuonCSCDigis/src/CSCStubMatcher.cc @@ -37,6 +37,8 @@ CSCStubMatcher::CSCStubMatcher(const edm::ParameterSet& pSet, edm::ConsumesColle alctToken_ = iC.consumes(cscALCT.getParameter("inputTag")); lctToken_ = iC.consumes(cscLCT.getParameter("inputTag")); mplctToken_ = iC.consumes(cscMPLCT.getParameter("inputTag")); + + geomToken_ = iC.esConsumes(); } void CSCStubMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -48,9 +50,9 @@ void CSCStubMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetu iEvent.getByToken(lctToken_, lctsH_); iEvent.getByToken(mplctToken_, mplctsH_); - iSetup.get().get(csc_geom_); - if (csc_geom_.isValid()) { - cscGeometry_ = &*csc_geom_; + edm::ESHandle hGeom = iSetup.getHandle(geomToken_); + if (hGeom.isValid()) { + cscGeometry_ = hGeom.product(); } else { edm::LogError("CSCStubMatcher") << "+++ Info: CSC geometry is unavailable."; } diff --git a/Validation/MuonHits/interface/CSCSimHitMatcher.h b/Validation/MuonHits/interface/CSCSimHitMatcher.h index afcccc80fe4f2..99bdcc5b54046 100644 --- a/Validation/MuonHits/interface/CSCSimHitMatcher.h +++ b/Validation/MuonHits/interface/CSCSimHitMatcher.h @@ -8,6 +8,8 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" #include "Validation/MuonHits/interface/MuonSimHitMatcher.h" @@ -75,7 +77,7 @@ class CSCSimHitMatcher : public MuonSimHitMatcher { void clear(); - edm::ESHandle csc_geom_; + edm::ESGetToken geomToken_; }; #endif diff --git a/Validation/MuonHits/interface/DTSimHitMatcher.h b/Validation/MuonHits/interface/DTSimHitMatcher.h index 1eaa9bc4a23e7..d85eb816119c6 100644 --- a/Validation/MuonHits/interface/DTSimHitMatcher.h +++ b/Validation/MuonHits/interface/DTSimHitMatcher.h @@ -8,6 +8,8 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Validation/MuonHits/interface/MuonSimHitMatcher.h" @@ -73,7 +75,7 @@ class DTSimHitMatcher : public MuonSimHitMatcher { std::map layer_to_hits_; std::map superlayer_to_hits_; - edm::ESHandle dt_geom_; + edm::ESGetToken geomToken_; }; #endif diff --git a/Validation/MuonHits/interface/GEMSimHitMatcher.h b/Validation/MuonHits/interface/GEMSimHitMatcher.h index d863587cc01a4..671c77527e817 100644 --- a/Validation/MuonHits/interface/GEMSimHitMatcher.h +++ b/Validation/MuonHits/interface/GEMSimHitMatcher.h @@ -8,6 +8,8 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Validation/MuonHits/interface/MuonSimHitMatcher.h" @@ -77,7 +79,7 @@ class GEMSimHitMatcher : public MuonSimHitMatcher { void clear(); - edm::ESHandle gem_geom_; + edm::ESGetToken geomToken_; std::map superchamber_to_hits_; diff --git a/Validation/MuonHits/interface/ME0SimHitMatcher.h b/Validation/MuonHits/interface/ME0SimHitMatcher.h index 834269ccd94e9..2721807db4f80 100644 --- a/Validation/MuonHits/interface/ME0SimHitMatcher.h +++ b/Validation/MuonHits/interface/ME0SimHitMatcher.h @@ -8,6 +8,8 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/GEMGeometry/interface/ME0Geometry.h" #include "Validation/MuonHits/interface/MuonSimHitMatcher.h" @@ -62,7 +64,7 @@ class ME0SimHitMatcher : public MuonSimHitMatcher { private: void matchSimHitsToSimTrack(); - edm::ESHandle me0_geom_; + edm::ESGetToken geomToken_; // detids with hits in pads std::map > detids_to_pads_; diff --git a/Validation/MuonHits/interface/RPCSimHitMatcher.h b/Validation/MuonHits/interface/RPCSimHitMatcher.h index dcaf264d24058..e5db7283ed40a 100644 --- a/Validation/MuonHits/interface/RPCSimHitMatcher.h +++ b/Validation/MuonHits/interface/RPCSimHitMatcher.h @@ -8,6 +8,8 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/RPCGeometry/interface/RPCGeometry.h" #include "Validation/MuonHits/interface/MuonSimHitMatcher.h" @@ -44,7 +46,7 @@ class RPCSimHitMatcher : public MuonSimHitMatcher { private: void matchSimHitsToSimTrack(); - edm::ESHandle rpc_geom_; + edm::ESGetToken geomToken_; }; #endif diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index 53c30cf00236e..da46a04173f20 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -10,13 +10,14 @@ CSCSimHitMatcher::CSCSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCol discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + geomToken_ = iC.esConsumes(); } /// initialize the event void CSCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - iSetup.get().get(csc_geom_); - if (csc_geom_.isValid()) { - geometry_ = &*csc_geom_; + edm::ESHandle hGeom = iSetup.getHandle(geomToken_); + if (hGeom.isValid()) { + geometry_ = hGeom.product(); } else { hasGeometry_ = false; edm::LogWarning("CSCSimHitMatcher") << "+++ Info: CSC geometry is unavailable. +++\n"; diff --git a/Validation/MuonHits/src/DTSimHitMatcher.cc b/Validation/MuonHits/src/DTSimHitMatcher.cc index df2101dcb3f70..70b66959f1072 100644 --- a/Validation/MuonHits/src/DTSimHitMatcher.cc +++ b/Validation/MuonHits/src/DTSimHitMatcher.cc @@ -10,13 +10,14 @@ DTSimHitMatcher::DTSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesColle discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + geomToken_ = iC.esConsumes(); } /// initialize the event void DTSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - iSetup.get().get(dt_geom_); - if (dt_geom_.isValid()) { - geometry_ = &*dt_geom_; + edm::ESHandle hGeom = iSetup.getHandle(geomToken_); + if (hGeom.isValid()) { + geometry_ = hGeom.product(); } else { hasGeometry_ = false; edm::LogWarning("DTSimHitMatcher") << "+++ Info: DT geometry is unavailable. +++\n"; diff --git a/Validation/MuonHits/src/GEMSimHitMatcher.cc b/Validation/MuonHits/src/GEMSimHitMatcher.cc index c7c02b434372d..d94f23c66fa56 100644 --- a/Validation/MuonHits/src/GEMSimHitMatcher.cc +++ b/Validation/MuonHits/src/GEMSimHitMatcher.cc @@ -10,13 +10,14 @@ GEMSimHitMatcher::GEMSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCol discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + geomToken_ = iC.esConsumes(); } /// initialize the event void GEMSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - iSetup.get().get(gem_geom_); - if (gem_geom_.isValid()) { - geometry_ = dynamic_cast(&*gem_geom_); + edm::ESHandle hGeom = iSetup.getHandle(geomToken_); + if (hGeom.isValid()) { + geometry_ = hGeom.product(); } else { hasGeometry_ = false; edm::LogWarning("GEMSimHitMatcher") << "+++ Info: GEM geometry is unavailable. +++\n"; diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc index 75ea634badf05..675627ac920c5 100644 --- a/Validation/MuonHits/src/ME0SimHitMatcher.cc +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -10,13 +10,14 @@ ME0SimHitMatcher::ME0SimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCol discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + geomToken_ = iC.esConsumes(); } /// initialize the event void ME0SimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - iSetup.get().get(me0_geom_); - if (me0_geom_.isValid()) { - geometry_ = &*me0_geom_; + edm::ESHandle hGeom = iSetup.getHandle(geomToken_); + if (hGeom.isValid()) { + geometry_ = hGeom.product(); } else { hasGeometry_ = false; edm::LogWarning("ME0SimHitMatcher") << "+++ Info: ME0 geometry is unavailable. +++\n"; diff --git a/Validation/MuonHits/src/RPCSimHitMatcher.cc b/Validation/MuonHits/src/RPCSimHitMatcher.cc index 7fbfccf5b7962..043e2ea55257e 100644 --- a/Validation/MuonHits/src/RPCSimHitMatcher.cc +++ b/Validation/MuonHits/src/RPCSimHitMatcher.cc @@ -11,13 +11,14 @@ RPCSimHitMatcher::RPCSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCol discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + geomToken_ = iC.esConsumes(); } /// initialize the event void RPCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - iSetup.get().get(rpc_geom_); - if (rpc_geom_.isValid()) { - geometry_ = &*rpc_geom_; + edm::ESHandle hGeom = iSetup.getHandle(geomToken_); + if (hGeom.isValid()) { + geometry_ = hGeom.product(); } else { hasGeometry_ = false; edm::LogWarning("RPCSimHitMatcher") << "+++ Info: RPC geometry is unavailable. +++\n"; From 3cdd0da4580ef45e44d5035c81fd9b5a7328d0c9 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Sat, 8 Aug 2020 18:29:34 -0500 Subject: [PATCH 2/4] Suggestion by Chris Jones --- Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc b/Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc index 02a399be6247e..05c0c1d10ef1e 100644 --- a/Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc +++ b/Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc @@ -55,8 +55,7 @@ void CSCDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &even theSimHitMap.fill(e); // find the geometry & conditions for this event - edm::ESHandle hGeom = eventSetup.getHandle(geomToken_); - const CSCGeometry *pGeom = &*hGeom; + const CSCGeometry *pGeom = &eventSetup.getData(geomToken_); theStripDigiValidation->setGeometry(pGeom); theWireDigiValidation->setGeometry(pGeom); From b5abe4b108cc878b4f08e5ceb8a816a72c7571a3 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Sat, 8 Aug 2020 20:16:28 -0500 Subject: [PATCH 3/4] Use esConsumes. Replace cout by LogInfo --- .../plugins/CSCTriggerPrimitivesProducer.cc | 4 +- .../plugins/CSCTriggerPrimitivesProducer.h | 5 +- .../interface/CSCBaseValidation.h | 1 - .../MuonCSCDigis/plugins/CSCDigiValidation.h | 1 - Validation/MuonCSCDigis/src/CSCStubMatcher.cc | 7 +- .../MuonGEMDigis/interface/GEMDigiMatcher.h | 2 +- .../MuonGEMDigis/plugins/GEMCheckGeometry.cc | 12 +--- .../MuonGEMDigis/plugins/GEMCheckGeometry.h | 3 + Validation/MuonGEMDigis/src/GEMDigiMatcher.cc | 36 +++++----- .../MuonGEMHits/interface/GEMBaseValidation.h | 2 +- .../MuonGEMHits/src/GEMBaseValidation.cc | 8 +-- .../interface/GEMRecHitMatcher.h | 3 +- .../MuonGEMRecHits/src/GEMRecHitMatcher.cc | 12 ++-- .../MuonHits/interface/MuonSimHitMatcher.h | 1 - .../plugins/MuonSimHitsValidAnalyzer.cc | 9 ++- .../plugins/MuonSimHitsValidAnalyzer.h | 2 +- Validation/MuonHits/src/CSCSimHitMatcher.cc | 47 ++++++------- Validation/MuonHits/src/DTSimHitMatcher.cc | 45 +++++------- Validation/MuonHits/src/GEMSimHitMatcher.cc | 68 +++++++------------ Validation/MuonHits/src/ME0SimHitMatcher.cc | 45 +++++------- Validation/MuonHits/src/RPCSimHitMatcher.cc | 46 ++++++------- .../interface/ME0BaseValidation.h | 2 +- .../plugins/MuonME0DigisHarvestor.cc | 1 - .../plugins/MuonME0DigisHarvestor.h | 1 - .../plugins/MuonME0SegHarvestor.cc | 1 - .../plugins/MuonME0SegHarvestor.h | 1 - .../src/ME0BaseValidation.cc | 1 + .../src/ME0DigisValidation.cc | 4 +- .../src/ME0HitsValidation.cc | 6 +- .../src/ME0RecHitsValidation.cc | 7 +- .../src/ME0SegmentsValidation.cc | 8 +-- 31 files changed, 151 insertions(+), 240 deletions(-) diff --git a/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.cc b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.cc index 882b3b16d4472..d84d2a8cb266c 100644 --- a/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.cc +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.cc @@ -16,7 +16,6 @@ #include "L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h" #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h" @@ -89,8 +88,7 @@ CSCTriggerPrimitivesProducer::~CSCTriggerPrimitivesProducer() {} void CSCTriggerPrimitivesProducer::produce(edm::Event& ev, const edm::EventSetup& setup) { // get the csc geometry - edm::ESHandle h = setup.getHandle(cscToken_); - builder_->setCSCGeometry(&*h); + builder_->setCSCGeometry(&setup.getData(cscToken_)); // get the gem geometry if it's there edm::ESHandle h_gem = setup.getHandle(gemToken_); diff --git a/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h index 9b9dba73d64cd..23280074bf3de 100644 --- a/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h @@ -40,10 +40,11 @@ #include "DataFormats/GEMDigi/interface/GEMPadDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMPadDigiClusterCollection.h" #include "L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "CondFormats/DataRecord/interface/CSCBadChambersRcd.h" -#include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "CondFormats/DataRecord/interface/CSCDBL1TPParametersRcd.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" // temporarily switch to a "one" module with a CSCTriggerPrimitivesBuilder data member class CSCTriggerPrimitivesProducer : public edm::one::EDProducer<> { diff --git a/Validation/MuonCSCDigis/interface/CSCBaseValidation.h b/Validation/MuonCSCDigis/interface/CSCBaseValidation.h index 33f61d9b2e8b1..d5c4e0a84b42c 100644 --- a/Validation/MuonCSCDigis/interface/CSCBaseValidation.h +++ b/Validation/MuonCSCDigis/interface/CSCBaseValidation.h @@ -4,7 +4,6 @@ // user include files #include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Utilities/interface/InputTag.h" diff --git a/Validation/MuonCSCDigis/plugins/CSCDigiValidation.h b/Validation/MuonCSCDigis/plugins/CSCDigiValidation.h index 6ecac8f812028..f8ceabef3daf7 100644 --- a/Validation/MuonCSCDigis/plugins/CSCDigiValidation.h +++ b/Validation/MuonCSCDigis/plugins/CSCDigiValidation.h @@ -3,7 +3,6 @@ // user include files -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Utilities/interface/ESGetToken.h" diff --git a/Validation/MuonCSCDigis/src/CSCStubMatcher.cc b/Validation/MuonCSCDigis/src/CSCStubMatcher.cc index 4d5ea58648261..3f677754abe7c 100644 --- a/Validation/MuonCSCDigis/src/CSCStubMatcher.cc +++ b/Validation/MuonCSCDigis/src/CSCStubMatcher.cc @@ -50,12 +50,7 @@ void CSCStubMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetu iEvent.getByToken(lctToken_, lctsH_); iEvent.getByToken(mplctToken_, mplctsH_); - edm::ESHandle hGeom = iSetup.getHandle(geomToken_); - if (hGeom.isValid()) { - cscGeometry_ = hGeom.product(); - } else { - edm::LogError("CSCStubMatcher") << "+++ Info: CSC geometry is unavailable."; - } + cscGeometry_ = &iSetup.getData(geomToken_); } // do the matching diff --git a/Validation/MuonGEMDigis/interface/GEMDigiMatcher.h b/Validation/MuonGEMDigis/interface/GEMDigiMatcher.h index 1135ff9da2186..9aa92efcd4b92 100644 --- a/Validation/MuonGEMDigis/interface/GEMDigiMatcher.h +++ b/Validation/MuonGEMDigis/interface/GEMDigiMatcher.h @@ -132,7 +132,7 @@ class GEMDigiMatcher { std::shared_ptr muonSimHitMatcher_; - edm::ESHandle gem_geom_; + edm::ESGetToken geomToken_; const GEMGeometry* gemGeometry_; template diff --git a/Validation/MuonGEMDigis/plugins/GEMCheckGeometry.cc b/Validation/MuonGEMDigis/plugins/GEMCheckGeometry.cc index d513d59d7c5d2..7864d014e1192 100644 --- a/Validation/MuonGEMDigis/plugins/GEMCheckGeometry.cc +++ b/Validation/MuonGEMDigis/plugins/GEMCheckGeometry.cc @@ -1,10 +1,7 @@ #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Utilities/interface/InputTag.h" #include "Geometry/CommonTopologies/interface/StripTopology.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" -#include "Geometry/GEMGeometry/interface/GEMGeometry.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Validation/MuonGEMDigis/plugins/GEMCheckGeometry.h" #include @@ -15,18 +12,15 @@ GEMCheckGeometry::GEMCheckGeometry(const edm::ParameterSet &gc) { minPhi_ = gc.getUntrackedParameter("minPhi", -180.); maxPhi_ = gc.getUntrackedParameter("maxPhi", +180.); detailPlot_ = gc.getParameter("detailPlot"); + geomToken_ = esConsumes(); } void GEMCheckGeometry::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &Run, edm::EventSetup const &iSetup) { if (!detailPlot_) return; - const GEMGeometry *GEMGeometry_; - try { - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - GEMGeometry_ = &*hGeom; - } catch (edm::eventsetup::NoProxyException &e) { + const GEMGeometry *GEMGeometry_ = &iSetup.getData(geomToken_); + if (!GEMGeometry_) { edm::LogError("MuonGEMGeometry") << "+++ Error : GEM geometry is unavailable on event loop. +++\n"; return; } diff --git a/Validation/MuonGEMDigis/plugins/GEMCheckGeometry.h b/Validation/MuonGEMDigis/plugins/GEMCheckGeometry.h index 3c0c8e70db73d..4164c3520f008 100644 --- a/Validation/MuonGEMDigis/plugins/GEMCheckGeometry.h +++ b/Validation/MuonGEMDigis/plugins/GEMCheckGeometry.h @@ -9,6 +9,8 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" class GEMCheckGeometry : public DQMEDAnalyzer { public: @@ -25,6 +27,7 @@ class GEMCheckGeometry : public DQMEDAnalyzer { double minPhi_; double maxPhi_; bool detailPlot_; + edm::ESGetToken geomToken_; }; #endif diff --git a/Validation/MuonGEMDigis/src/GEMDigiMatcher.cc b/Validation/MuonGEMDigis/src/GEMDigiMatcher.cc index 34df5341ed30c..ab7cb4c6d6526 100644 --- a/Validation/MuonGEMDigis/src/GEMDigiMatcher.cc +++ b/Validation/MuonGEMDigis/src/GEMDigiMatcher.cc @@ -36,6 +36,8 @@ GEMDigiMatcher::GEMDigiMatcher(const edm::ParameterSet& pset, edm::ConsumesColle gemPadToken_ = iC.consumes(gemPad.getParameter("inputTag")); gemClusterToken_ = iC.consumes(gemCluster.getParameter("inputTag")); gemCoPadToken_ = iC.consumes(gemCoPad.getParameter("inputTag")); + + geomToken_ = iC.esConsumes(); } void GEMDigiMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -47,12 +49,7 @@ void GEMDigiMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetu iEvent.getByToken(gemClusterToken_, gemClustersH_); iEvent.getByToken(gemCoPadToken_, gemCoPadsH_); - iSetup.get().get(gem_geom_); - if (gem_geom_.isValid()) { - gemGeometry_ = &*gem_geom_; - } else { - std::cout << "+++ Info: GEM geometry is unavailable. +++\n"; - } + gemGeometry_ = &iSetup.getData(geomToken_); } /// do the matching @@ -83,7 +80,7 @@ void GEMDigiMatcher::match(const SimTrack& t, const SimVertex& v) { void GEMDigiMatcher::matchDigisSLToSimTrack(const edm::DetSetVector& digisSL) { if (verboseSimLink_) - cout << "Matching simtrack to GEM simlinks" << endl; + edm::LogInfo("GEMDigiMatcher") << "Matching simtrack to GEM simlinks" << endl; // loop on the simlinks for (auto itsimlink = digisSL.begin(); itsimlink != digisSL.end(); itsimlink++) { @@ -100,8 +97,9 @@ void GEMDigiMatcher::matchDigisSLToSimTrack(const edm::DetSetVectorgetStrip() << " " << sl->getBx() << " " - << sl->getEnergyLoss() << " " << sl->getTimeOfFlight() << " " << sl->getParticleType() << std::endl; + edm::LogInfo("GEMDigiMatcher") << "GEMDigiSimLink " << p_id << " " << sl->getStrip() << " " << sl->getBx() + << " " << sl->getEnergyLoss() << " " << sl->getTimeOfFlight() << " " + << sl->getParticleType() << std::endl; // consider only the muon hits if (simMuOnly_ && std::abs(sl->getParticleType()) != 13) @@ -120,7 +118,7 @@ void GEMDigiMatcher::matchDigisSLToSimTrack(const edm::DetSetVectorgetEntryPoint() and simhit.momentumAtEntry() == sl->getMomentumAtEntry()) { detid_to_simLinks_[p_id.rawId()].push_back(*sl); if (verboseSimLink_) - cout << "...was matched!" << endl; + edm::LogInfo("GEMDigiMatcher") << "...was matched!" << endl; break; } } @@ -130,7 +128,7 @@ void GEMDigiMatcher::matchDigisSLToSimTrack(const edm::DetSetVectordetIds()) { GEMDetId p_id(id); @@ -142,7 +140,7 @@ void GEMDigiMatcher::matchDigisToSimTrack(const GEMDigiCollection& digis) { continue; if (verboseDigi_) - cout << "GEMDigi " << p_id << " " << *d << endl; + edm::LogInfo("GEMDigiMatcher") << "GEMDigi " << p_id << " " << *d << endl; // check that the digi matches to at least one GEMDigiSimLink for (const auto& sl : detid_to_simLinks_[p_id.rawId()]) { @@ -151,7 +149,7 @@ void GEMDigiMatcher::matchDigisToSimTrack(const GEMDigiCollection& digis) { chamber_to_digis_[p_id.chamberId().rawId()].push_back(*d); superchamber_to_digis_[p_id.superChamberId().rawId()].push_back(*d); if (verboseDigi_) - cout << "...was matched!" << endl; + edm::LogInfo("GEMDigiMatcher") << "...was matched!" << endl; break; } } @@ -172,7 +170,7 @@ void GEMDigiMatcher::matchPadsToSimTrack(const GEMPadDigiCollection& pads) { continue; if (verbosePad_) - cout << "GEMPad " << p_id << " " << *pad << endl; + edm::LogInfo("GEMDigiMatcher") << "GEMPad " << p_id << " " << *pad << endl; // check that it matches a pad that was hit by SimHits from our track for (auto digi : detid_to_digis_[p_id.rawId()]) { @@ -181,7 +179,7 @@ void GEMDigiMatcher::matchPadsToSimTrack(const GEMPadDigiCollection& pads) { chamber_to_pads_[p_id.chamberId().rawId()].push_back(*pad); superchamber_to_pads_[p_id.superChamberId().rawId()].push_back(*pad); if (verbosePad_) - cout << "...was matched!" << endl; + edm::LogInfo("GEMDigiMatcher") << "...was matched!" << endl; break; } } @@ -204,7 +202,7 @@ void GEMDigiMatcher::matchClustersToSimTrack(const GEMPadDigiClusterCollection& continue; if (verboseCluster_) - cout << "GEMCluster " << p_id << " " << *cluster << endl; + edm::LogInfo("GEMDigiMatcher") << "GEMCluster " << p_id << " " << *cluster << endl; // check that at least one pad was hit by the track for (const auto& p : cluster->pads()) { @@ -219,7 +217,7 @@ void GEMDigiMatcher::matchClustersToSimTrack(const GEMPadDigiClusterCollection& chamber_to_clusters_[p_id.chamberId().rawId()].push_back(*cluster); superchamber_to_clusters_[p_id.superChamberId().rawId()].push_back(*cluster); if (verboseCluster_) - cout << "...was matched!" << endl; + edm::LogInfo("GEMDigiMatcher") << "...was matched!" << endl; } } } @@ -237,7 +235,7 @@ void GEMDigiMatcher::matchCoPadsToSimTrack(const GEMCoPadDigiCollection& co_pads continue; if (verboseCoPad_) - cout << "GEMCoPadDigi: " << id << " " << *copad << endl; + edm::LogInfo("GEMDigiMatcher") << "GEMCoPadDigi: " << id << " " << *copad << endl; bool isMatchedL1 = false; bool isMatchedL2 = false; @@ -260,7 +258,7 @@ void GEMDigiMatcher::matchCoPadsToSimTrack(const GEMCoPadDigiCollection& co_pads if (isMatchedL1 and isMatchedL2) { superchamber_to_copads_[id.rawId()].push_back(*copad); if (verboseCoPad_) - cout << "...was matched! " << endl; + edm::LogInfo("GEMDigiMatcher") << "...was matched! " << endl; } } } diff --git a/Validation/MuonGEMHits/interface/GEMBaseValidation.h b/Validation/MuonGEMHits/interface/GEMBaseValidation.h index 9c8700dea6f44..2f69c1ec1b8fa 100644 --- a/Validation/MuonGEMHits/interface/GEMBaseValidation.h +++ b/Validation/MuonGEMHits/interface/GEMBaseValidation.h @@ -7,7 +7,6 @@ #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Utilities/interface/EDGetToken.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -92,6 +91,7 @@ class GEMBaseValidation : public DQMEDAnalyzer { // NOTE Constants const Int_t kMuonPDGId_ = 13; const std::string kLogCategory_; // see member initializer list + edm::ESGetToken geomToken_; }; template diff --git a/Validation/MuonGEMHits/src/GEMBaseValidation.cc b/Validation/MuonGEMHits/src/GEMBaseValidation.cc index 70884e8de4015..4bf04a901b4e0 100644 --- a/Validation/MuonGEMHits/src/GEMBaseValidation.cc +++ b/Validation/MuonGEMHits/src/GEMBaseValidation.cc @@ -16,16 +16,12 @@ GEMBaseValidation::GEMBaseValidation(const edm::ParameterSet& ps, std::string lo eta_range_ = ps.getUntrackedParameter >("EtaOccRange"); detail_plot_ = ps.getParameter("detailPlot"); + geomToken_ = esConsumes(); } GEMBaseValidation::~GEMBaseValidation() {} -const GEMGeometry* GEMBaseValidation::initGeometry(edm::EventSetup const& setup) { - edm::ESHandle geom_handle; - setup.get().get(geom_handle); - const GEMGeometry* gem = &*geom_handle; - return gem; -} +const GEMGeometry* GEMBaseValidation::initGeometry(edm::EventSetup const& setup) { return &setup.getData(geomToken_); } Int_t GEMBaseValidation::getDetOccBinX(Int_t chamber_id, Int_t layer_id) { return 2 * chamber_id + layer_id - 2; } diff --git a/Validation/MuonGEMRecHits/interface/GEMRecHitMatcher.h b/Validation/MuonGEMRecHits/interface/GEMRecHitMatcher.h index c07b5f9566f40..23d7512115fff 100644 --- a/Validation/MuonGEMRecHits/interface/GEMRecHitMatcher.h +++ b/Validation/MuonGEMRecHits/interface/GEMRecHitMatcher.h @@ -14,7 +14,6 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" #include "SimDataFormats/Track/interface/SimTrackContainer.h" @@ -91,7 +90,7 @@ class GEMRecHitMatcher { edm::EDGetTokenT gemRecHitToken_; edm::Handle gemRecHitH_; - edm::ESHandle gem_geom_; + edm::ESGetToken geomToken_; const GEMGeometry* gemGeometry_; int minBX_, maxBX_; diff --git a/Validation/MuonGEMRecHits/src/GEMRecHitMatcher.cc b/Validation/MuonGEMRecHits/src/GEMRecHitMatcher.cc index 332c89fb95570..c4055687142ac 100644 --- a/Validation/MuonGEMRecHits/src/GEMRecHitMatcher.cc +++ b/Validation/MuonGEMRecHits/src/GEMRecHitMatcher.cc @@ -14,6 +14,7 @@ GEMRecHitMatcher::GEMRecHitMatcher(const edm::ParameterSet& pset, edm::ConsumesC gemDigiMatcher_.reset(new GEMDigiMatcher(pset, std::move(iC))); gemRecHitToken_ = iC.consumes(gemRecHit.getParameter("inputTag")); + geomToken_ = iC.esConsumes(); } void GEMRecHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -21,12 +22,7 @@ void GEMRecHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSe iEvent.getByToken(gemRecHitToken_, gemRecHitH_); - iSetup.get().get(gem_geom_); - if (gem_geom_.isValid()) { - gemGeometry_ = &*gem_geom_; - } else { - std::cout << "+++ Info: GEM geometry is unavailable. +++\n"; - } + gemGeometry_ = &iSetup.getData(geomToken_); } /// do the matching @@ -60,7 +56,7 @@ void GEMRecHitMatcher::matchRecHitsToSimTrack(const GEMRecHitCollection& rechits for (auto d = rechits_in_det.first; d != rechits_in_det.second; ++d) { if (verbose()) - cout << "recHit " << p_id << " " << *d << endl; + edm::LogInfo("GEMDigiMatcher") << "recHit " << p_id << " " << *d << endl; // check that the rechit is within BX range if (d->BunchX() < minBX_ || d->BunchX() > maxBX_) @@ -80,7 +76,7 @@ void GEMRecHitMatcher::matchRecHitsToSimTrack(const GEMRecHitCollection& rechits if (!stripFound) continue; if (verbose()) - cout << "oki" << endl; + edm::LogInfo("GEMDigiMatcher") << "oki" << endl; recHits_.push_back(*d); detid_to_recHits_[id].push_back(*d); diff --git a/Validation/MuonHits/interface/MuonSimHitMatcher.h b/Validation/MuonHits/interface/MuonSimHitMatcher.h index 2e2dbb042c0dd..5a7c254de8b22 100644 --- a/Validation/MuonHits/interface/MuonSimHitMatcher.h +++ b/Validation/MuonHits/interface/MuonSimHitMatcher.h @@ -11,7 +11,6 @@ #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/Math/interface/deltaPhi.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/Frameworkfwd.h" diff --git a/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc index 0847a5398f93c..d69f75357d7f9 100644 --- a/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc +++ b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc @@ -68,6 +68,7 @@ MuonSimHitsValidAnalyzer::MuonSimHitsValidAnalyzer(const edm::ParameterSet& iPSe nummu_DT = 0; nummu_CSC = 0; nummu_RPC = 0; + geomToken_ = esConsumes(); } MuonSimHitsValidAnalyzer::~MuonSimHitsValidAnalyzer() {} @@ -309,15 +310,13 @@ void MuonSimHitsValidAnalyzer::fillDT(const edm::Event& iEvent, const edm::Event edm::PSimHitContainer::const_iterator itHit; /// access the DT - /// access the DT geometry - edm::ESHandle theDTGeometry; - iSetup.get().get(theDTGeometry); - if (!theDTGeometry.isValid()) { + edm::ESHandle hGeom = iSetup.getHandle(geomToken_); + if (!hGeom.isValid()) { edm::LogWarning("MuonSimHitsValidAnalyzer::fillDT") << "Unable to find MuonGeometryRecord for the DTGeometry in event!"; return; } - const DTGeometry& theDTMuon(*theDTGeometry); + const DTGeometry& theDTMuon(*hGeom); /// get DT information edm::Handle MuonDTContainer; diff --git a/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h index 8391f5d5d9170..8b36b1f00d9f6 100644 --- a/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h +++ b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h @@ -6,7 +6,6 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "DataFormats/Provenance/interface/Provenance.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -87,6 +86,7 @@ class MuonSimHitsValidAnalyzer : public DQMEDAnalyzer { /// Input tags edm::EDGetTokenT DTHitsToken_; + edm::ESGetToken geomToken_; // Monitor elements // DT diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index da46a04173f20..86051eb9d143f 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -15,13 +15,7 @@ CSCSimHitMatcher::CSCSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCol /// initialize the event void CSCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::ESHandle hGeom = iSetup.getHandle(geomToken_); - if (hGeom.isValid()) { - geometry_ = hGeom.product(); - } else { - hasGeometry_ = false; - edm::LogWarning("CSCSimHitMatcher") << "+++ Info: CSC geometry is unavailable. +++\n"; - } + geometry_ = &iSetup.getData(geomToken_); MuonSimHitMatcher::init(iEvent, iSetup); } @@ -38,27 +32,24 @@ void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { if (std::abs(track.momentum().eta()) > 2.45) return; - if (hasGeometry_) { - matchSimHitsToSimTrack(); - - if (verbose_) { - edm::LogInfo("CSCSimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedCSCSimHits " << hits_.size() - << endl; - edm::LogInfo("CSCSimHitMatcher") << "detids CSC " << detIds(0).size() << endl; - - for (const auto& id : detIds(0)) { - const auto& simhits = hitsInDetId(id); - const auto& simhits_gp = simHitsMeanPosition(simhits); - const auto& strips = hitStripsInDetId(id); - CSCDetId cscid(id); - if (cscid.station() == 1 and (cscid.ring() == 1 or cscid.ring() == 4)) { - edm::LogInfo("CSCSimHitMatcher") << "cscdetid " << CSCDetId(id) << ": " << simhits.size() << " " - << simhits_gp.phi() << " " << detid_to_hits_[id].size() << endl; - edm::LogInfo("CSCSimHitMatcher") << "nStrip " << strips.size() << endl; - edm::LogInfo("CSCSimHitMatcher") << "strips : "; - for (const auto& p : strips) { - edm::LogInfo("CSCSimHitMatcher") << p; - } + matchSimHitsToSimTrack(); + + if (verbose_) { + edm::LogInfo("CSCSimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedCSCSimHits " << hits_.size(); + edm::LogInfo("CSCSimHitMatcher") << "detids CSC " << detIds(0).size(); + + for (const auto& id : detIds(0)) { + const auto& simhits = hitsInDetId(id); + const auto& simhits_gp = simHitsMeanPosition(simhits); + const auto& strips = hitStripsInDetId(id); + CSCDetId cscid(id); + if (cscid.station() == 1 and (cscid.ring() == 1 or cscid.ring() == 4)) { + edm::LogInfo("CSCSimHitMatcher") << "cscdetid " << CSCDetId(id) << ": " << simhits.size() << " " + << simhits_gp.phi() << " " << detid_to_hits_[id].size(); + edm::LogInfo("CSCSimHitMatcher") << "nStrip " << strips.size(); + edm::LogInfo("CSCSimHitMatcher") << "strips : "; + for (const auto& p : strips) { + edm::LogInfo("CSCSimHitMatcher") << p; } } } diff --git a/Validation/MuonHits/src/DTSimHitMatcher.cc b/Validation/MuonHits/src/DTSimHitMatcher.cc index 70b66959f1072..278264775f387 100644 --- a/Validation/MuonHits/src/DTSimHitMatcher.cc +++ b/Validation/MuonHits/src/DTSimHitMatcher.cc @@ -15,13 +15,7 @@ DTSimHitMatcher::DTSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesColle /// initialize the event void DTSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::ESHandle hGeom = iSetup.getHandle(geomToken_); - if (hGeom.isValid()) { - geometry_ = hGeom.product(); - } else { - hasGeometry_ = false; - edm::LogWarning("DTSimHitMatcher") << "+++ Info: DT geometry is unavailable. +++\n"; - } + geometry_ = &iSetup.getData(geomToken_); MuonSimHitMatcher::init(iEvent, iSetup); } @@ -30,22 +24,19 @@ void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { // instantiates the track ids and simhits MuonSimHitMatcher::match(track, vertex); - if (hasGeometry_) { - matchSimHitsToSimTrack(); - - if (verbose_) { - edm::LogInfo("DTSimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedDTSimHits " << hits_.size() - << endl; - edm::LogInfo("DTSimHitMatcher") << "detids DT " << detIds(0).size() << endl; - - const auto& dt_det_ids = detIds(0); - for (const auto& id : dt_det_ids) { - const auto& dt_simhits = MuonSimHitMatcher::hitsInDetId(id); - const auto& dt_simhits_gp = simHitsMeanPosition(dt_simhits); - edm::LogInfo("DTSimHitMatcher") << "DTWireId " << DTWireId(id) << ": nHits " << dt_simhits.size() << " eta " - << dt_simhits_gp.eta() << " phi " << dt_simhits_gp.phi() << " nCh " - << chamber_to_hits_[id].size() << endl; - } + matchSimHitsToSimTrack(); + + if (verbose_) { + edm::LogInfo("DTSimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedDTSimHits " << hits_.size(); + edm::LogInfo("DTSimHitMatcher") << "detids DT " << detIds(0).size(); + + const auto& dt_det_ids = detIds(0); + for (const auto& id : dt_det_ids) { + const auto& dt_simhits = MuonSimHitMatcher::hitsInDetId(id); + const auto& dt_simhits_gp = simHitsMeanPosition(dt_simhits); + edm::LogInfo("DTSimHitMatcher") << "DTWireId " << DTWireId(id) << ": nHits " << dt_simhits.size() << " eta " + << dt_simhits_gp.eta() << " phi " << dt_simhits_gp.phi() << " nCh " + << chamber_to_hits_[id].size(); } } } @@ -246,7 +237,7 @@ std::set DTSimHitMatcher::hitWiresInDTLayerId(unsigned int detid, DTWireId wid(id, wn); for (const auto& h : MuonSimHitMatcher::hitsInDetId(wid.rawId())) { if (verbose_) - edm::LogInfo("DTSimHitMatcher") << "central DTWireId " << wid << " simhit " << h << endl; + edm::LogInfo("DTSimHitMatcher") << "central DTWireId " << wid << " simhit " << h; int smin = wn - margin_n_wires; smin = (smin > 0) ? smin : 1; int smax = wn + margin_n_wires; @@ -254,7 +245,7 @@ std::set DTSimHitMatcher::hitWiresInDTLayerId(unsigned int detid, for (int ss = smin; ss <= smax; ++ss) { DTWireId widd(id, ss); if (verbose_) - edm::LogInfo("DTSimHitMatcher") << "\tadding DTWireId to collection " << widd << endl; + edm::LogInfo("DTSimHitMatcher") << "\tadding DTWireId to collection " << widd; result.insert(widd.rawId()); } } @@ -268,7 +259,7 @@ std::set DTSimHitMatcher::hitWiresInDTSuperLayerId(unsigned int de const auto& layers(dynamic_cast(geometry_)->superLayer(DTSuperLayerId(detid))->layers()); for (const auto& l : layers) { if (verbose_) - edm::LogInfo("DTSimHitMatcher") << "hitWiresInDTSuperLayerId::l id " << l->id() << endl; + edm::LogInfo("DTSimHitMatcher") << "hitWiresInDTSuperLayerId::l id " << l->id(); const auto& p(hitWiresInDTLayerId(l->id().rawId(), margin_n_wires)); result.insert(p.begin(), p.end()); } @@ -280,7 +271,7 @@ std::set DTSimHitMatcher::hitWiresInDTChamberId(unsigned int detid const auto& superLayers(dynamic_cast(geometry_)->chamber(DTChamberId(detid))->superLayers()); for (const auto& sl : superLayers) { if (verbose_) - edm::LogInfo("DTSimHitMatcher") << "hitWiresInDTChamberId::sl id " << sl->id() << endl; + edm::LogInfo("DTSimHitMatcher") << "hitWiresInDTChamberId::sl id " << sl->id(); const auto& p(hitWiresInDTSuperLayerId(sl->id().rawId(), margin_n_wires)); result.insert(p.begin(), p.end()); } diff --git a/Validation/MuonHits/src/GEMSimHitMatcher.cc b/Validation/MuonHits/src/GEMSimHitMatcher.cc index d94f23c66fa56..4d23dee28a08f 100644 --- a/Validation/MuonHits/src/GEMSimHitMatcher.cc +++ b/Validation/MuonHits/src/GEMSimHitMatcher.cc @@ -15,13 +15,7 @@ GEMSimHitMatcher::GEMSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCol /// initialize the event void GEMSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::ESHandle hGeom = iSetup.getHandle(geomToken_); - if (hGeom.isValid()) { - geometry_ = hGeom.product(); - } else { - hasGeometry_ = false; - edm::LogWarning("GEMSimHitMatcher") << "+++ Info: GEM geometry is unavailable. +++\n"; - } + geometry_ = &iSetup.getData(geomToken_); MuonSimHitMatcher::init(iEvent, iSetup); } @@ -36,36 +30,33 @@ void GEMSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { if (std::abs(track.momentum().eta()) < 1.55) return; - if (hasGeometry_) { - matchSimHitsToSimTrack(); - - if (verbose_) { - edm::LogInfo("GEMSimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedGEMSimHits " << hits_.size() - << endl; - edm::LogInfo("GEMSimHitMatcher") << "detids GEM " << detIds(0).size() << endl; - - const auto& gem_ch_ids = detIds(); - for (const auto& id : gem_ch_ids) { - const auto& gem_simhits = MuonSimHitMatcher::hitsInDetId(id); - const auto& gem_simhits_gp = simHitsMeanPosition(gem_simhits); - edm::LogInfo("GEMSimHitMatcher") << "gemchid " << GEMDetId(id) << ": nHits " << gem_simhits.size() << " phi " - << gem_simhits_gp.phi() << " nCh " << chamber_to_hits_[id].size() << endl; - const auto& strips = hitStripsInDetId(id); - edm::LogInfo("GEMSimHitMatcher") << "nStrip " << strips.size() << endl; - edm::LogInfo("GEMSimHitMatcher") << "strips : "; - for (const auto& p : strips) { - edm::LogInfo("GEMSimHitMatcher") << p; - } - } - const auto& gem_sch_ids = superChamberIds(); - for (const auto& id : gem_sch_ids) { - const auto& gem_simhits = hitsInSuperChamber(id); - const auto& gem_simhits_gp = simHitsMeanPosition(gem_simhits); - edm::LogInfo("GEMSimHitMatcher") << "gemschid " << GEMDetId(id) << ": " << nCoincidencePadsWithHits() << " | " - << gem_simhits.size() << " " << gem_simhits_gp.phi() << " " - << superchamber_to_hits_[id].size() << endl; + matchSimHitsToSimTrack(); + + if (verbose_) { + edm::LogInfo("GEMSimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedGEMSimHits " << hits_.size(); + edm::LogInfo("GEMSimHitMatcher") << "detids GEM " << detIds(0).size(); + + const auto& gem_ch_ids = detIds(); + for (const auto& id : gem_ch_ids) { + const auto& gem_simhits = MuonSimHitMatcher::hitsInDetId(id); + const auto& gem_simhits_gp = simHitsMeanPosition(gem_simhits); + edm::LogInfo("GEMSimHitMatcher") << "gemchid " << GEMDetId(id) << ": nHits " << gem_simhits.size() << " phi " + << gem_simhits_gp.phi() << " nCh " << chamber_to_hits_[id].size(); + const auto& strips = hitStripsInDetId(id); + edm::LogInfo("GEMSimHitMatcher") << "nStrip " << strips.size(); + edm::LogInfo("GEMSimHitMatcher") << "strips : "; + for (const auto& p : strips) { + edm::LogInfo("GEMSimHitMatcher") << p; } } + const auto& gem_sch_ids = superChamberIds(); + for (const auto& id : gem_sch_ids) { + const auto& gem_simhits = hitsInSuperChamber(id); + const auto& gem_simhits_gp = simHitsMeanPosition(gem_simhits); + edm::LogInfo("GEMSimHitMatcher") << "gemschid " << GEMDetId(id) << ": " << nCoincidencePadsWithHits() << " | " + << gem_simhits.size() << " " << gem_simhits_gp.phi() << " " + << superchamber_to_hits_[id].size(); + } } } @@ -77,10 +68,6 @@ void GEMSimHitMatcher::matchSimHitsToSimTrack() { const GEMDetId& p_id(h.detUnitId()); - if (verbose_) - std::cout << "Candidate GEM simhit " << p_id << " " << h << " " << h.particleType() << " " << h.processType() - << std::endl; - int pdgid = h.particleType(); // consider only the muon hits @@ -91,9 +78,6 @@ void GEMSimHitMatcher::matchSimHitsToSimTrack() { if (discardEleHits_ && std::abs(pdgid) == 11) continue; - if (verbose_) - std::cout << "...was matched" << std::endl; - detid_to_hits_[p_id.rawId()].push_back(h); hits_.push_back(h); chamber_to_hits_[p_id.chamberId().rawId()].push_back(h); diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc index 675627ac920c5..131bed5e6bd22 100644 --- a/Validation/MuonHits/src/ME0SimHitMatcher.cc +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -15,13 +15,7 @@ ME0SimHitMatcher::ME0SimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCol /// initialize the event void ME0SimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::ESHandle hGeom = iSetup.getHandle(geomToken_); - if (hGeom.isValid()) { - geometry_ = hGeom.product(); - } else { - hasGeometry_ = false; - edm::LogWarning("ME0SimHitMatcher") << "+++ Info: ME0 geometry is unavailable. +++\n"; - } + geometry_ = &iSetup.getData(geomToken_); MuonSimHitMatcher::init(iEvent, iSetup); } @@ -30,26 +24,23 @@ void ME0SimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { // instantiates the track ids and simhits MuonSimHitMatcher::match(track, vertex); - if (hasGeometry_) { - matchSimHitsToSimTrack(); - - if (verbose_) { - edm::LogInfo("ME0SimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedME0SimHits " << hits_.size() - << endl; - edm::LogInfo("ME0SimHitMatcher") << "detids ME0 " << detIds().size() << endl; - - const auto& me0_ch_ids = detIds(); - for (const auto& id : me0_ch_ids) { - const auto& me0_simhits = MuonSimHitMatcher::hitsInChamber(id); - const auto& me0_simhits_gp = simHitsMeanPosition(me0_simhits); - edm::LogInfo("ME0SimHitMatcher") << "me0chid " << ME0DetId(id) << ": nHits " << me0_simhits.size() << " phi " - << me0_simhits_gp.phi() << " nCh " << chamber_to_hits_[id].size() << endl; - const auto& strips = hitStripsInDetId(id); - edm::LogInfo("ME0SimHitMatcher") << "nStrip " << strips.size() << endl; - edm::LogInfo("ME0SimHitMatcher") << "strips : "; - for (const auto& p : strips) { - edm::LogInfo("ME0SimHitMatcher") << p; - } + matchSimHitsToSimTrack(); + + if (verbose_) { + edm::LogInfo("ME0SimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedME0SimHits " << hits_.size(); + edm::LogInfo("ME0SimHitMatcher") << "detids ME0 " << detIds().size(); + + const auto& me0_ch_ids = detIds(); + for (const auto& id : me0_ch_ids) { + const auto& me0_simhits = MuonSimHitMatcher::hitsInChamber(id); + const auto& me0_simhits_gp = simHitsMeanPosition(me0_simhits); + edm::LogInfo("ME0SimHitMatcher") << "me0chid " << ME0DetId(id) << ": nHits " << me0_simhits.size() << " phi " + << me0_simhits_gp.phi() << " nCh " << chamber_to_hits_[id].size(); + const auto& strips = hitStripsInDetId(id); + edm::LogInfo("ME0SimHitMatcher") << "nStrip " << strips.size(); + edm::LogInfo("ME0SimHitMatcher") << "strips : "; + for (const auto& p : strips) { + edm::LogInfo("ME0SimHitMatcher") << p; } } } diff --git a/Validation/MuonHits/src/RPCSimHitMatcher.cc b/Validation/MuonHits/src/RPCSimHitMatcher.cc index 043e2ea55257e..d352fae335ce0 100644 --- a/Validation/MuonHits/src/RPCSimHitMatcher.cc +++ b/Validation/MuonHits/src/RPCSimHitMatcher.cc @@ -16,13 +16,7 @@ RPCSimHitMatcher::RPCSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCol /// initialize the event void RPCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::ESHandle hGeom = iSetup.getHandle(geomToken_); - if (hGeom.isValid()) { - geometry_ = hGeom.product(); - } else { - hasGeometry_ = false; - edm::LogWarning("RPCSimHitMatcher") << "+++ Info: RPC geometry is unavailable. +++\n"; - } + geometry_ = &iSetup.getData(geomToken_); MuonSimHitMatcher::init(iEvent, iSetup); } @@ -31,26 +25,24 @@ void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { // instantiates the track ids and simhits MuonSimHitMatcher::match(track, vertex); - if (hasGeometry_) { - matchSimHitsToSimTrack(); - - if (verbose_) { - edm::LogInfo("RPCSimHitMatcher") << "nSimHits " << simHits_.size() << " nTrackIds " << track_ids_.size() << endl; - edm::LogInfo("RPCSimHitMatcher") << "detids RPC " << detIds().size() << endl; - - const auto& ch_ids = chamberIds(); - for (const auto& id : ch_ids) { - const auto& simhits = MuonSimHitMatcher::hitsInChamber(id); - const auto& simhits_gp = simHitsMeanPosition(simhits); - edm::LogInfo("RPCSimHitMatcher") << "RPCDetId " << RPCDetId(id) << ": nHits " << simhits.size() << " eta " - << simhits_gp.eta() << " phi " << simhits_gp.phi() << " nCh " - << chamber_to_hits_[id].size() << endl; - const auto& strips = hitStripsInDetId(id); - edm::LogInfo("RPCSimHitMatcher") << "nStrips " << strips.size() << endl; - edm::LogInfo("RPCSimHitMatcher") << "strips : "; - for (const auto& p : strips) { - edm::LogInfo("RPCSimHitMatcher") << p; - } + matchSimHitsToSimTrack(); + + if (verbose_) { + edm::LogInfo("RPCSimHitMatcher") << "nSimHits " << simHits_.size() << " nTrackIds " << track_ids_.size(); + edm::LogInfo("RPCSimHitMatcher") << "detids RPC " << detIds().size(); + + const auto& ch_ids = chamberIds(); + for (const auto& id : ch_ids) { + const auto& simhits = MuonSimHitMatcher::hitsInChamber(id); + const auto& simhits_gp = simHitsMeanPosition(simhits); + edm::LogInfo("RPCSimHitMatcher") << "RPCDetId " << RPCDetId(id) << ": nHits " << simhits.size() << " eta " + << simhits_gp.eta() << " phi " << simhits_gp.phi() << " nCh " + << chamber_to_hits_[id].size(); + const auto& strips = hitStripsInDetId(id); + edm::LogInfo("RPCSimHitMatcher") << "nStrips " << strips.size(); + edm::LogInfo("RPCSimHitMatcher") << "strips : "; + for (const auto& p : strips) { + edm::LogInfo("RPCSimHitMatcher") << p; } } } diff --git a/Validation/MuonME0Validation/interface/ME0BaseValidation.h b/Validation/MuonME0Validation/interface/ME0BaseValidation.h index d64bd28e65763..fb514feaaba3a 100644 --- a/Validation/MuonME0Validation/interface/ME0BaseValidation.h +++ b/Validation/MuonME0Validation/interface/ME0BaseValidation.h @@ -10,7 +10,6 @@ #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -35,6 +34,7 @@ class ME0BaseValidation : public DQMEDAnalyzer { std::vector RangeZR_; edm::EDGetToken InputTagToken_; int nBinXY_; + edm::ESGetToken geomToken_; private: }; diff --git a/Validation/MuonME0Validation/plugins/MuonME0DigisHarvestor.cc b/Validation/MuonME0Validation/plugins/MuonME0DigisHarvestor.cc index 78ed0d8504fa4..76e478b909901 100644 --- a/Validation/MuonME0Validation/plugins/MuonME0DigisHarvestor.cc +++ b/Validation/MuonME0Validation/plugins/MuonME0DigisHarvestor.cc @@ -3,7 +3,6 @@ // user include files #include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/Validation/MuonME0Validation/plugins/MuonME0DigisHarvestor.h b/Validation/MuonME0Validation/plugins/MuonME0DigisHarvestor.h index 7aca571ada2bc..557f520de7b3a 100644 --- a/Validation/MuonME0Validation/plugins/MuonME0DigisHarvestor.h +++ b/Validation/MuonME0Validation/plugins/MuonME0DigisHarvestor.h @@ -2,7 +2,6 @@ #define MuonME0DigisHarvestor_H #include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "DQMServices/Core/interface/DQMEDHarvester.h" diff --git a/Validation/MuonME0Validation/plugins/MuonME0SegHarvestor.cc b/Validation/MuonME0Validation/plugins/MuonME0SegHarvestor.cc index 169900ca90d29..a6b18bd13d1b9 100644 --- a/Validation/MuonME0Validation/plugins/MuonME0SegHarvestor.cc +++ b/Validation/MuonME0Validation/plugins/MuonME0SegHarvestor.cc @@ -3,7 +3,6 @@ // user include files #include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/Validation/MuonME0Validation/plugins/MuonME0SegHarvestor.h b/Validation/MuonME0Validation/plugins/MuonME0SegHarvestor.h index d645c5ddd505e..45a73f0e550e9 100644 --- a/Validation/MuonME0Validation/plugins/MuonME0SegHarvestor.h +++ b/Validation/MuonME0Validation/plugins/MuonME0SegHarvestor.h @@ -2,7 +2,6 @@ #define MuonME0SegHarvestor_H #include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "DQMServices/Core/interface/DQMEDHarvester.h" diff --git a/Validation/MuonME0Validation/src/ME0BaseValidation.cc b/Validation/MuonME0Validation/src/ME0BaseValidation.cc index 56e567512e242..35c6cd194a9ca 100644 --- a/Validation/MuonME0Validation/src/ME0BaseValidation.cc +++ b/Validation/MuonME0Validation/src/ME0BaseValidation.cc @@ -16,6 +16,7 @@ ME0BaseValidation::ME0BaseValidation(const edm::ParameterSet &ps) { layerLabel.push_back("4"); layerLabel.push_back("5"); layerLabel.push_back("6"); + geomToken_ = esConsumes(); } ME0BaseValidation::~ME0BaseValidation() {} diff --git a/Validation/MuonME0Validation/src/ME0DigisValidation.cc b/Validation/MuonME0Validation/src/ME0DigisValidation.cc index f261845c06d8d..7f39f9efe83bd 100644 --- a/Validation/MuonME0Validation/src/ME0DigisValidation.cc +++ b/Validation/MuonME0Validation/src/ME0DigisValidation.cc @@ -158,9 +158,7 @@ void ME0DigisValidation::bookHistograms(DQMStore::IBooker &ibooker, ME0DigisValidation::~ME0DigisValidation() {} void ME0DigisValidation::analyze(const edm::Event &e, const edm::EventSetup &iSetup) { - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const ME0Geometry *ME0Geometry_ = (&*hGeom); + const ME0Geometry *ME0Geometry_ = &iSetup.getData(geomToken_); edm::Handle ME0Hits; e.getByToken(InputTagToken_, ME0Hits); diff --git a/Validation/MuonME0Validation/src/ME0HitsValidation.cc b/Validation/MuonME0Validation/src/ME0HitsValidation.cc index 0914e92597f69..7338728dda7ba 100644 --- a/Validation/MuonME0Validation/src/ME0HitsValidation.cc +++ b/Validation/MuonME0Validation/src/ME0HitsValidation.cc @@ -58,9 +58,7 @@ void ME0HitsValidation::bookHistograms(DQMStore::IBooker &ibooker, edm::Run cons ME0HitsValidation::~ME0HitsValidation() {} void ME0HitsValidation::analyze(const edm::Event &e, const edm::EventSetup &iSetup) { - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const ME0Geometry *ME0Geometry_ = (&*hGeom); + const ME0Geometry *ME0Geometry_ = &iSetup.getData(geomToken_); edm::Handle ME0Hits; e.getByToken(InputTagToken_, ME0Hits); @@ -79,7 +77,7 @@ void ME0HitsValidation::analyze(const edm::Event &e, const edm::EventSetup &iSet // Int_t even_odd = id.chamber()%2; if (ME0Geometry_->idToDet(hits->detUnitId()) == nullptr) { - std::cout << "simHit did not matched with GEMGeometry." << std::endl; + edm::LogInfo("ME0HitsValidation") << "simHit did not matched with GEMGeometry." << std::endl; continue; } diff --git a/Validation/MuonME0Validation/src/ME0RecHitsValidation.cc b/Validation/MuonME0Validation/src/ME0RecHitsValidation.cc index 48c70f713e3ce..1b1ffce0a4753 100644 --- a/Validation/MuonME0Validation/src/ME0RecHitsValidation.cc +++ b/Validation/MuonME0Validation/src/ME0RecHitsValidation.cc @@ -59,9 +59,8 @@ void ME0RecHitsValidation::bookHistograms(DQMStore::IBooker &ibooker, ME0RecHitsValidation::~ME0RecHitsValidation() {} void ME0RecHitsValidation::analyze(const edm::Event &e, const edm::EventSetup &iSetup) { - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const ME0Geometry *ME0Geometry_ = (&*hGeom); + const ME0Geometry *ME0Geometry_ = &iSetup.getData(geomToken_); + edm::Handle ME0Hits; e.getByToken(InputTagToken_, ME0Hits); @@ -83,7 +82,7 @@ void ME0RecHitsValidation::analyze(const edm::Event &e, const edm::EventSetup &i // Int_t even_odd = id.chamber()%2; if (ME0Geometry_->idToDet(hits->detUnitId()) == nullptr) { - std::cout << "simHit did not matched with GEMGeometry." << std::endl; + edm::LogInfo("ME0RecHitsValidation") << "simHit did not matched with GEMGeometry." << std::endl; continue; } diff --git a/Validation/MuonME0Validation/src/ME0SegmentsValidation.cc b/Validation/MuonME0Validation/src/ME0SegmentsValidation.cc index 13fca1bb27af6..89b4853bb38fd 100644 --- a/Validation/MuonME0Validation/src/ME0SegmentsValidation.cc +++ b/Validation/MuonME0Validation/src/ME0SegmentsValidation.cc @@ -18,10 +18,6 @@ ME0SegmentsValidation::ME0SegmentsValidation(const edm::ParameterSet &cfg) : ME0 void ME0SegmentsValidation::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &Run, edm::EventSetup const &iSetup) { - // edm::ESHandle hGeom; - // iSetup.get().get(hGeom); - // const ME0Geometry* ME0Geometry_ =( &*hGeom); - LogDebug("MuonME0SegmentsValidation") << "Info : Loading Geometry information\n"; ibooker.setCurrentFolder("MuonME0RecHitsV/ME0SegmentsTask"); @@ -109,9 +105,7 @@ void ME0SegmentsValidation::bookHistograms(DQMStore::IBooker &ibooker, ME0SegmentsValidation::~ME0SegmentsValidation() {} void ME0SegmentsValidation::analyze(const edm::Event &e, const edm::EventSetup &iSetup) { - edm::ESHandle hGeom; - iSetup.get().get(hGeom); - const ME0Geometry *ME0Geometry_ = (&*hGeom); + const ME0Geometry *ME0Geometry_ = &iSetup.getData(geomToken_); edm::Handle ME0Hits; e.getByToken(InputTagToken_, ME0Hits); From 93fb6ab3f4b19a9b6c8587ca8b479e4f58e90283 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Mon, 10 Aug 2020 10:27:10 -0500 Subject: [PATCH 4/4] Use esConsumes --- .../CSCEfficiency/src/CSCEfficiency.cc | 13 +++--- .../CSCEfficiency/src/CSCEfficiency.h | 41 ++++++------------- .../CSCValidation/src/CSCValidation.cc | 5 ++- .../CSCValidation/src/CSCValidation.h | 17 ++------ .../CSCRecHits/src/CSCRecHitValidation.cc | 10 ++--- .../CSCRecHits/src/CSCRecHitValidation.h | 11 ++--- .../plugins/GEMCoPadDigiValidation.cc | 6 ++- .../plugins/GEMCoPadDigiValidation.h | 2 + .../plugins/GEMPadDigiClusterValidation.cc | 6 ++- .../plugins/GEMPadDigiClusterValidation.h | 2 + .../plugins/GEMPadDigiValidation.cc | 6 ++- .../plugins/GEMPadDigiValidation.h | 2 + .../plugins/GEMStripDigiValidation.cc | 6 ++- .../plugins/GEMStripDigiValidation.h | 2 + .../MuonGEMHits/interface/GEMBaseValidation.h | 2 +- .../plugins/GEMSimHitValidation.cc | 6 ++- .../MuonGEMHits/plugins/GEMSimHitValidation.h | 2 + .../MuonGEMHits/src/GEMBaseValidation.cc | 3 -- .../plugins/GEMRecHitValidation.cc | 6 ++- .../plugins/GEMRecHitValidation.h | 3 +- .../interface/ME0RecHitsValidation.h | 4 -- .../interface/ME0SegmentsValidation.h | 9 +--- 22 files changed, 72 insertions(+), 92 deletions(-) diff --git a/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc b/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc index bf7fef0c5767e..1391d5b91514f 100644 --- a/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc +++ b/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc @@ -1,7 +1,7 @@ /* - * Routine to calculate CSC efficiencies + * Routine to calculate CSC efficiencies * Comments about the program logic are denoted by //---- - * + * * Stoyan Stoynev, Northwestern University. */ @@ -74,8 +74,7 @@ bool CSCEfficiency::filter(edm::Event &event, const edm::EventSetup &eventSetup) //---- Get the CSC Geometry : if (printalot) printf("\tget the CSC geometry.\n"); - edm::ESHandle cscGeom; - eventSetup.get().get(cscGeom); + edm::ESHandle cscGeom = eventSetup.getHandle(geomToken_); // use theTrackingGeometry instead of cscGeom? edm::ESHandle theTrackingGeometry; @@ -1685,6 +1684,8 @@ CSCEfficiency::CSCEfficiency(const edm::ParameterSet &pset) { tk_token = consumes >(pset.getParameter("tracksTag")); sh_token = consumes(pset.getParameter("simHitTag")); + geomToken_ = esConsumes(); + edm::ParameterSet serviceParameters = pset.getParameter("ServiceParameters"); // maybe use the service for getting magnetic field, propagators, etc. ... theService = new MuonServiceProxy(serviceParameters, consumesCollector()); @@ -1942,11 +1943,11 @@ CSCEfficiency::CSCEfficiency(const edm::ParameterSet &pset) { // /* sprintf(SpecName,"Sim_Rechits_each_Ch%d",iChamber); - ChHist[ec][st][rg][iChamber-FirstCh].SimRechits_each = + ChHist[ec][st][rg][iChamber-FirstCh].SimRechits_each = new TH1F(SpecName,"Existing RecHit (Sim), each;layers (1-6);entries",nLayer_bins,Layer_min,Layer_max); // sprintf(SpecName,"Sim_Simhits_each_Ch%d",iChamber); - ChHist[ec][st][rg][iChamber-FirstCh].SimSimhits_each = + ChHist[ec][st][rg][iChamber-FirstCh].SimSimhits_each = new TH1F(SpecName,"Existing SimHit (Sim), each;layers (1-6);entries",nLayer_bins,Layer_min,Layer_max); */ theFile->cd(); diff --git a/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.h b/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.h index 2920d14184abd..399c53230ceec 100644 --- a/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.h +++ b/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.h @@ -3,59 +3,40 @@ /** \class CSCEfficiency * - * Efficiency calculations + * Efficiency calculations * Stoyan Stoynev, Northwestern University */ // how many of the headers below are not needed?... #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDFilter.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include +#include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "DataFormats/CSCDigi/interface/CSCALCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h" -#include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h" -#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h" +#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h" +#include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h" +#include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h" #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" -#include - #include "Geometry/CSCGeometry/interface/CSCGeometry.h" -#include -#include -#include -#include +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/GeometryVector/interface/GlobalVector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" #include "DataFormats/GeometryVector/interface/LocalVector.h" -#include "DataFormats/CSCDigi/interface/CSCWireDigi.h" -#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h" -#include "DataFormats/CSCDigi/interface/CSCStripDigi.h" -#include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h" - -#include "DataFormats/CSCDigi/interface/CSCComparatorDigi.h" -#include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h" - -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" - #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h" @@ -68,7 +49,7 @@ #include "TrackingTools/DetLayers/interface/NavigationDirection.h" #include "TrackingTools/GeomPropagators/interface/Propagator.h" -#include +#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h" #include "RecoMuon/TrackingTools/interface/MuonPatternRecoDumper.h" #include "DataFormats/Common/interface/TriggerResults.h" @@ -145,6 +126,8 @@ class CSCEfficiency : public edm::EDFilter { edm::EDGetTokenT ht_token; + edm::ESGetToken geomToken_; + // unsigned int printout_NEvents; bool isData; diff --git a/RecoLocalMuon/CSCValidation/src/CSCValidation.cc b/RecoLocalMuon/CSCValidation/src/CSCValidation.cc index e2b4686f109c9..db103499ace7a 100644 --- a/RecoLocalMuon/CSCValidation/src/CSCValidation.cc +++ b/RecoLocalMuon/CSCValidation/src/CSCValidation.cc @@ -122,6 +122,8 @@ CSCValidation::CSCValidation(const ParameterSet& pset) { // setup trees to hold global position data for rechits and segments if (writeTreeToFile) histos->setupTrees(); + + geomToken_ = esConsumes(); } ////////////////// @@ -195,8 +197,7 @@ void CSCValidation::analyze(const Event& event, const EventSetup& eventSetup) { } // Get the CSC Geometry : - edm::ESHandle cscGeom; - eventSetup.get().get(cscGeom); + edm::ESHandle cscGeom = eventSetup.getHandle(geomToken_); // Get the RecHits collection : edm::Handle recHits; diff --git a/RecoLocalMuon/CSCValidation/src/CSCValidation.h b/RecoLocalMuon/CSCValidation/src/CSCValidation.h index 7e5e6cf64a76d..c1b34ac3d4bc6 100644 --- a/RecoLocalMuon/CSCValidation/src/CSCValidation.h +++ b/RecoLocalMuon/CSCValidation/src/CSCValidation.h @@ -19,25 +19,18 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/ESGetToken.h" -#include "DataFormats/CSCDigi/interface/CSCWireDigi.h" #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h" -#include "DataFormats/CSCDigi/interface/CSCStripDigi.h" #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h" -#include "DataFormats/CSCDigi/interface/CSCComparatorDigi.h" #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h" -#include "DataFormats/CSCDigi/interface/CSCALCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h" -#include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h" -#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h" #include "EventFilter/CSCRawToDigi/interface/CSCDCCEventData.h" @@ -64,9 +57,7 @@ #include "DataFormats/FEDRawData/interface/FEDNumbering.h" #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" -#include -#include +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutRecord.h" @@ -75,9 +66,6 @@ #include "FWCore/Common/interface/TriggerNames.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" -#include "Geometry/CSCGeometry/interface/CSCChamber.h" -#include "Geometry/CSCGeometry/interface/CSCLayer.h" -#include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "DataFormats/TrackReco/interface/Track.h" @@ -258,6 +246,7 @@ class CSCValidation : public edm::EDAnalyzer { edm::EDGetTokenT tr_token; edm::EDGetTokenT sa_token; edm::EDGetTokenT sh_token; + edm::ESGetToken geomToken_; // module on/off switches bool makeOccupancyPlots; diff --git a/Validation/CSCRecHits/src/CSCRecHitValidation.cc b/Validation/CSCRecHits/src/CSCRecHitValidation.cc index f342e754a4d46..4cb4c6ddb316a 100644 --- a/Validation/CSCRecHits/src/CSCRecHitValidation.cc +++ b/Validation/CSCRecHits/src/CSCRecHitValidation.cc @@ -1,18 +1,16 @@ #include "DQMServices/Core/interface/DQMStore.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" -#include "Geometry/CSCGeometry/interface/CSCGeometry.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Validation/CSCRecHits/src/CSCRecHitValidation.h" -#include +#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" CSCRecHitValidation::CSCRecHitValidation(const edm::ParameterSet &ps) : theSimHitMap(ps.getParameter("simHitsTag"), consumesCollector()), - theCSCGeometry(nullptr), the2DValidation(nullptr), theSegmentValidation(nullptr) { the2DValidation = new CSCRecHit2DValidation(ps.getParameter("recHitLabel"), consumesCollector()); theSegmentValidation = new CSCSegmentValidation(ps.getParameter("segmentLabel"), consumesCollector()); + geomToken_ = esConsumes(); } CSCRecHitValidation::~CSCRecHitValidation() { @@ -31,9 +29,7 @@ void CSCRecHitValidation::analyze(const edm::Event &e, const edm::EventSetup &ev theSimHitMap.fill(e); // find the geometry & conditions for this event - edm::ESHandle hGeom; - eventSetup.get().get(hGeom); - theCSCGeometry = &*hGeom; + const CSCGeometry *theCSCGeometry = &eventSetup.getData(geomToken_); the2DValidation->setGeometry(theCSCGeometry); the2DValidation->setSimHitMap(&theSimHitMap); diff --git a/Validation/CSCRecHits/src/CSCRecHitValidation.h b/Validation/CSCRecHits/src/CSCRecHitValidation.h index cb30a549d8b31..58697895d89c3 100644 --- a/Validation/CSCRecHits/src/CSCRecHitValidation.h +++ b/Validation/CSCRecHits/src/CSCRecHitValidation.h @@ -3,14 +3,15 @@ // user include files -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Utilities/interface/EDGetToken.h" -#include -#include +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" -#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "SimMuon/MCTruth/interface/PSimHitMap.h" #include "Validation/CSCRecHits/src/CSCRecHit2DValidation.h" #include "Validation/CSCRecHits/src/CSCSegmentValidation.h" @@ -24,7 +25,7 @@ class CSCRecHitValidation : public DQMEDAnalyzer { private: PSimHitMap theSimHitMap; - const CSCGeometry *theCSCGeometry; + edm::ESGetToken geomToken_; CSCRecHit2DValidation *the2DValidation; CSCSegmentValidation *theSegmentValidation; diff --git a/Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.cc b/Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.cc index 8a7b13b42ec1d..f88d7996ec3f8 100644 --- a/Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.cc +++ b/Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.cc @@ -6,6 +6,8 @@ GEMCoPadDigiValidation::GEMCoPadDigiValidation(const edm::ParameterSet& pset) const auto& copad_tag = copad_pset.getParameter("inputTag"); copad_token_ = consumes(copad_tag); + geomToken_ = esConsumes(); + geomTokenBeginRun_ = esConsumes(); gem_bx_min_ = copad_pset.getParameter("minBX"); gem_bx_max_ = copad_pset.getParameter("maxBX"); @@ -14,7 +16,7 @@ GEMCoPadDigiValidation::GEMCoPadDigiValidation(const edm::ParameterSet& pset) void GEMCoPadDigiValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run const& run, edm::EventSetup const& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_); // NOTE Occupancy booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/CoPad/Occupancy"); @@ -92,7 +94,7 @@ void GEMCoPadDigiValidation::bookHistograms(DQMStore::IBooker& booker, GEMCoPadDigiValidation::~GEMCoPadDigiValidation() {} void GEMCoPadDigiValidation::analyze(const edm::Event& event, const edm::EventSetup& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomToken_); edm::Handle copad_collection; event.getByToken(copad_token_, copad_collection); diff --git a/Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.h b/Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.h index 7d69d6ed6bfc8..8749ac8b61efd 100644 --- a/Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.h +++ b/Validation/MuonGEMDigis/plugins/GEMCoPadDigiValidation.h @@ -23,6 +23,8 @@ class GEMCoPadDigiValidation : public GEMBaseValidation { // Parameters edm::EDGetTokenT copad_token_; + edm::ESGetToken geomToken_; + edm::ESGetToken geomTokenBeginRun_; // int gem_bx_min_, gem_bx_max_; diff --git a/Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.cc b/Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.cc index 9e80e837daeda..8a61fe946e65f 100644 --- a/Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.cc +++ b/Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.cc @@ -6,12 +6,14 @@ GEMPadDigiClusterValidation::GEMPadDigiClusterValidation(const edm::ParameterSet const auto& pad_cluster_pset = pset.getParameterSet("gemPadCluster"); const auto& pad_cluster_tag = pad_cluster_pset.getParameter("inputTag"); pad_cluster_token_ = consumes(pad_cluster_tag); + geomToken_ = esConsumes(); + geomTokenBeginRun_ = esConsumes(); } void GEMPadDigiClusterValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run const& Run, edm::EventSetup const& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_); // NOTE Occupancy booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/PadCluster/Occupancy"); @@ -109,7 +111,7 @@ void GEMPadDigiClusterValidation::bookHistograms(DQMStore::IBooker& booker, GEMPadDigiClusterValidation::~GEMPadDigiClusterValidation() {} void GEMPadDigiClusterValidation::analyze(const edm::Event& event, const edm::EventSetup& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomToken_); edm::Handle collection; event.getByToken(pad_cluster_token_, collection); diff --git a/Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.h b/Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.h index 72742e6ef8d96..b8f6baacd6fcf 100644 --- a/Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.h +++ b/Validation/MuonGEMDigis/plugins/GEMPadDigiClusterValidation.h @@ -21,6 +21,8 @@ class GEMPadDigiClusterValidation : public GEMBaseValidation { MEMap3Ids me_detail_bx_; edm::EDGetTokenT pad_cluster_token_; + edm::ESGetToken geomToken_; + edm::ESGetToken geomTokenBeginRun_; }; #endif // Validation_MuonGEMDigis_GEMPadDigiClusterValidation_h diff --git a/Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.cc b/Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.cc index 6fb11a5ddf7f7..614058685297d 100644 --- a/Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.cc +++ b/Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.cc @@ -5,12 +5,14 @@ GEMPadDigiValidation::GEMPadDigiValidation(const edm::ParameterSet& pset) const auto& pad_pset = pset.getParameterSet("gemPadDigi"); const auto& pad_tag = pad_pset.getParameter("inputTag"); pad_token_ = consumes(pad_tag); + geomToken_ = esConsumes(); + geomTokenBeginRun_ = esConsumes(); } void GEMPadDigiValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run const& Run, edm::EventSetup const& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_); // NOTE Occupancy booker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask/Pad/Occupancy"); @@ -109,7 +111,7 @@ void GEMPadDigiValidation::bookHistograms(DQMStore::IBooker& booker, GEMPadDigiValidation::~GEMPadDigiValidation() {} void GEMPadDigiValidation::analyze(const edm::Event& event, const edm::EventSetup& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomToken_); edm::Handle collection; event.getByToken(pad_token_, collection); diff --git a/Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.h b/Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.h index b98d35089adbf..f0e13d2fc5c26 100644 --- a/Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.h +++ b/Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.h @@ -14,6 +14,8 @@ class GEMPadDigiValidation : public GEMBaseValidation { private: // NOTE Parameters edm::EDGetTokenT pad_token_; + edm::ESGetToken geomToken_; + edm::ESGetToken geomTokenBeginRun_; // NOTE MonitorElemnts MEMap2Ids me_occ_det_; diff --git a/Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.cc b/Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.cc index ba21121603224..beb4b50313f00 100644 --- a/Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.cc +++ b/Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.cc @@ -10,12 +10,14 @@ GEMStripDigiValidation::GEMStripDigiValidation(const edm::ParameterSet& pset) const auto& simhit_pset = pset.getParameterSet("gemSimHit"); const auto& simhit_tag = simhit_pset.getParameter("inputTag"); simhit_token_ = consumes(simhit_tag); + geomToken_ = esConsumes(); + geomTokenBeginRun_ = esConsumes(); } void GEMStripDigiValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run const& run, edm::EventSetup const& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_); if (gem == nullptr) { edm::LogError(kLogCategory_) << "Failed to initialize GEM geometry."; return; @@ -162,7 +164,7 @@ void GEMStripDigiValidation::bookHistograms(DQMStore::IBooker& booker, GEMStripDigiValidation::~GEMStripDigiValidation() {} void GEMStripDigiValidation::analyze(const edm::Event& event, const edm::EventSetup& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomToken_); if (gem == nullptr) { edm::LogError(kLogCategory_) << "Failed to initialize GEM geometry."; return; diff --git a/Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.h b/Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.h index 475b2faf4ce47..ba49f0f1cfbd6 100644 --- a/Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.h +++ b/Validation/MuonGEMDigis/plugins/GEMStripDigiValidation.h @@ -15,6 +15,8 @@ class GEMStripDigiValidation : public GEMBaseValidation { // ParameterSet edm::EDGetTokenT strip_token_; edm::EDGetTokenT simhit_token_; + edm::ESGetToken geomToken_; + edm::ESGetToken geomTokenBeginRun_; // NOTE Monitor elements diff --git a/Validation/MuonGEMHits/interface/GEMBaseValidation.h b/Validation/MuonGEMHits/interface/GEMBaseValidation.h index 2f69c1ec1b8fa..f13a89bf8aecb 100644 --- a/Validation/MuonGEMHits/interface/GEMBaseValidation.h +++ b/Validation/MuonGEMHits/interface/GEMBaseValidation.h @@ -22,7 +22,6 @@ class GEMBaseValidation : public DQMEDAnalyzer { void analyze(const edm::Event& e, const edm::EventSetup&) override = 0; protected: - const GEMGeometry* initGeometry(const edm::EventSetup&); Int_t getDetOccBinX(Int_t chamber_id, Int_t layer_id); Bool_t isMuonSimHit(const PSimHit&); @@ -92,6 +91,7 @@ class GEMBaseValidation : public DQMEDAnalyzer { const Int_t kMuonPDGId_ = 13; const std::string kLogCategory_; // see member initializer list edm::ESGetToken geomToken_; + edm::ESGetToken geomTokenBeginRun_; }; template diff --git a/Validation/MuonGEMHits/plugins/GEMSimHitValidation.cc b/Validation/MuonGEMHits/plugins/GEMSimHitValidation.cc index d93b5a21a366f..6dfe4bc27ac56 100644 --- a/Validation/MuonGEMHits/plugins/GEMSimHitValidation.cc +++ b/Validation/MuonGEMHits/plugins/GEMSimHitValidation.cc @@ -9,12 +9,14 @@ GEMSimHitValidation::GEMSimHitValidation(const edm::ParameterSet& pset) simhit_token_ = consumes(simhit_tag); tof_range_ = pset.getUntrackedParameter >("TOFRange"); + geomToken_ = esConsumes(); + geomTokenBeginRun_ = esConsumes(); } GEMSimHitValidation::~GEMSimHitValidation() {} void GEMSimHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run const& run, edm::EventSetup const& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_); // NOTE Time of flight booker.setCurrentFolder("MuonGEMHitsV/GEMHitsTask/TimeOfFlight"); @@ -155,7 +157,7 @@ std::tuple GEMSimHitValidation::getTOFRange(Int_t station_id } void GEMSimHitValidation::analyze(const edm::Event& event, const edm::EventSetup& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomToken_); edm::Handle simhit_container; event.getByToken(simhit_token_, simhit_container); diff --git a/Validation/MuonGEMHits/plugins/GEMSimHitValidation.h b/Validation/MuonGEMHits/plugins/GEMSimHitValidation.h index bac422636bafa..7b279654fbc9d 100644 --- a/Validation/MuonGEMHits/plugins/GEMSimHitValidation.h +++ b/Validation/MuonGEMHits/plugins/GEMSimHitValidation.h @@ -20,6 +20,8 @@ class GEMSimHitValidation : public GEMBaseValidation { // Parameters edm::EDGetTokenT simhit_token_; + edm::ESGetToken geomToken_; + edm::ESGetToken geomTokenBeginRun_; std::vector tof_range_; // Monitor elemnts diff --git a/Validation/MuonGEMHits/src/GEMBaseValidation.cc b/Validation/MuonGEMHits/src/GEMBaseValidation.cc index 4bf04a901b4e0..49cd46a09ab9b 100644 --- a/Validation/MuonGEMHits/src/GEMBaseValidation.cc +++ b/Validation/MuonGEMHits/src/GEMBaseValidation.cc @@ -16,13 +16,10 @@ GEMBaseValidation::GEMBaseValidation(const edm::ParameterSet& ps, std::string lo eta_range_ = ps.getUntrackedParameter >("EtaOccRange"); detail_plot_ = ps.getParameter("detailPlot"); - geomToken_ = esConsumes(); } GEMBaseValidation::~GEMBaseValidation() {} -const GEMGeometry* GEMBaseValidation::initGeometry(edm::EventSetup const& setup) { return &setup.getData(geomToken_); } - Int_t GEMBaseValidation::getDetOccBinX(Int_t chamber_id, Int_t layer_id) { return 2 * chamber_id + layer_id - 2; } Bool_t GEMBaseValidation::isMuonSimHit(const PSimHit& simhit) { return std::abs(simhit.particleType()) == kMuonPDGId_; } diff --git a/Validation/MuonGEMRecHits/plugins/GEMRecHitValidation.cc b/Validation/MuonGEMRecHits/plugins/GEMRecHitValidation.cc index b9f376e624c2c..4445838ff9cd8 100644 --- a/Validation/MuonGEMRecHits/plugins/GEMRecHitValidation.cc +++ b/Validation/MuonGEMRecHits/plugins/GEMRecHitValidation.cc @@ -12,12 +12,14 @@ GEMRecHitValidation::GEMRecHitValidation(const edm::ParameterSet& pset) const auto& simhit_pset = pset.getParameterSet("gemSimHit"); const auto& simhit_tag = simhit_pset.getParameter("inputTag"); simhit_token_ = consumes(simhit_tag); + geomToken_ = esConsumes(); + geomTokenBeginRun_ = esConsumes(); } GEMRecHitValidation::~GEMRecHitValidation() {} void GEMRecHitValidation::bookHistograms(DQMStore::IBooker& booker, edm::Run const& run, edm::EventSetup const& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomTokenBeginRun_); // NOTE Cluster Size booker.setCurrentFolder("MuonGEMRecHitsV/GEMRecHitsTask/ClusterSize"); @@ -189,7 +191,7 @@ Bool_t GEMRecHitValidation::matchRecHitAgainstSimHit(GEMRecHitCollection::const_ } void GEMRecHitValidation::analyze(const edm::Event& event, const edm::EventSetup& setup) { - const GEMGeometry* gem = initGeometry(setup); + const GEMGeometry* gem = &setup.getData(geomToken_); edm::Handle simhit_container; event.getByToken(simhit_token_, simhit_container); diff --git a/Validation/MuonGEMRecHits/plugins/GEMRecHitValidation.h b/Validation/MuonGEMRecHits/plugins/GEMRecHitValidation.h index d17f70b17b88d..a92499ba2806e 100644 --- a/Validation/MuonGEMRecHits/plugins/GEMRecHitValidation.h +++ b/Validation/MuonGEMRecHits/plugins/GEMRecHitValidation.h @@ -15,9 +15,10 @@ class GEMRecHitValidation : public GEMBaseValidation { Bool_t matchRecHitAgainstSimHit(GEMRecHitCollection::const_iterator, Int_t); // Parameter - edm::EDGetTokenT rechit_token_; edm::EDGetTokenT simhit_token_; + edm::ESGetToken geomToken_; + edm::ESGetToken geomTokenBeginRun_; // MonitorElement MonitorElement* me_cls_; diff --git a/Validation/MuonME0Validation/interface/ME0RecHitsValidation.h b/Validation/MuonME0Validation/interface/ME0RecHitsValidation.h index 6aa19e3993cbe..259b245f4a63c 100644 --- a/Validation/MuonME0Validation/interface/ME0RecHitsValidation.h +++ b/Validation/MuonME0Validation/interface/ME0RecHitsValidation.h @@ -2,11 +2,7 @@ #define ME0RecHitsValidation_H #include "Validation/MuonME0Validation/interface/ME0BaseValidation.h" - -// Data Format #include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include class ME0RecHitsValidation : public ME0BaseValidation { public: diff --git a/Validation/MuonME0Validation/interface/ME0SegmentsValidation.h b/Validation/MuonME0Validation/interface/ME0SegmentsValidation.h index cbdbe4adc78d9..179ffc6e8ef06 100644 --- a/Validation/MuonME0Validation/interface/ME0SegmentsValidation.h +++ b/Validation/MuonME0Validation/interface/ME0SegmentsValidation.h @@ -2,16 +2,9 @@ #define ME0SegmentsValidation_H #include "Validation/MuonME0Validation/interface/ME0BaseValidation.h" - -#include -#include - -#include "DataFormats/GEMDigi/interface/ME0DigiPreReco.h" #include "DataFormats/GEMDigi/interface/ME0DigiPreRecoCollection.h" +#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h" #include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" -#include "SimDataFormats/Track/interface/SimTrackContainer.h" -#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" -#include class ME0SegmentsValidation : public ME0BaseValidation { public: