From e7adaefc6d028e02ae6ce4db50ef9432777ea0dc Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 6 Nov 2021 21:04:06 +0100 Subject: [PATCH 1/2] Make use of ESGetToken in SimTracker/TrackerHitAssociation --- .../interface/TrackerHitAssociator.h | 2 -- .../TrackerHitAssociation/test/TestAssociator.cc | 3 --- .../TrackerHitAssociation/test/TestAssociator.h | 4 ++-- .../TrackerHitAssociation/test/myTrackAnalyzer.cc | 6 +++--- .../TrackerHitAssociation/test/myTrackAnalyzer.h | 12 ++++++------ 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h b/SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h index 82fbba6d154e2..55a955d4cef10 100644 --- a/SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h +++ b/SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h @@ -16,11 +16,9 @@ ************************************************************/ //#include -#include "FWCore/Framework/interface/EDAnalyzer.h" #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 "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Utilities/interface/EDGetToken.h" diff --git a/SimTracker/TrackerHitAssociation/test/TestAssociator.cc b/SimTracker/TrackerHitAssociation/test/TestAssociator.cc index 0dd62191c9872..3b4eefe4da74d 100644 --- a/SimTracker/TrackerHitAssociation/test/TestAssociator.cc +++ b/SimTracker/TrackerHitAssociation/test/TestAssociator.cc @@ -11,9 +11,6 @@ #include "SimTracker/TrackerHitAssociation/test/TestAssociator.h" -//--- framework stuff -#include "FWCore/Framework/interface/ESHandle.h" - //--- for Geometry: #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" diff --git a/SimTracker/TrackerHitAssociation/test/TestAssociator.h b/SimTracker/TrackerHitAssociation/test/TestAssociator.h index d0212f66a6a40..e3a80136596d3 100644 --- a/SimTracker/TrackerHitAssociation/test/TestAssociator.h +++ b/SimTracker/TrackerHitAssociation/test/TestAssociator.h @@ -8,14 +8,14 @@ * ************************************************************/ -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h" -class TestAssociator : public edm::EDAnalyzer { +class TestAssociator : public edm::one::EDAnalyzer<> { public: explicit TestAssociator(const edm::ParameterSet& conf); diff --git a/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.cc b/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.cc index 1658d1dada4d8..765fe65105ddd 100644 --- a/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.cc +++ b/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.cc @@ -13,7 +13,8 @@ myTrackAnalyzer::myTrackAnalyzer(edm::ParameterSet const& conf) : trackerHitAssociatorConfig_(conf, consumesCollector()), doPixel_(conf.getParameter("associatePixel")), doStrip_(conf.getParameter("associateStrip")), - trackCollectionTag_(conf.getParameter("trackCollectionTag")) {} + trackCollectionTag_(conf.getParameter("trackCollectionTag")), + tokGeo_(esConsumes()) {} myTrackAnalyzer::~myTrackAnalyzer() {} @@ -21,8 +22,7 @@ void myTrackAnalyzer::analyze(const edm::Event& event, const edm::EventSetup& se // // extract tracker geometry // - edm::ESHandle theG; - setup.get().get(theG); + auto const& theG = setup.getHandle(tokGeo_); using namespace std; diff --git a/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h b/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h index dc0f780bee839..76898d846282f 100644 --- a/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h +++ b/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h @@ -4,17 +4,15 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" @@ -39,7 +37,7 @@ class SiStripHitAssociator; -class myTrackAnalyzer : public edm::EDAnalyzer { +class myTrackAnalyzer : public edm::one::EDAnalyzer<> { public: typedef std::map sim_id_map; sim_id_map SimIdMap; @@ -52,8 +50,10 @@ class myTrackAnalyzer : public edm::EDAnalyzer { private: TrackerHitAssociator::Config trackerHitAssociatorConfig_; - bool doPixel_, doStrip_; - edm::InputTag trackCollectionTag_; + const bool doPixel_, doStrip_; + const edm::InputTag trackCollectionTag_; + const edm::ESGetToken tokGeo_; + }; #endif From cc8afac5ebe1cac2e7817aa6c51d1390444650e6 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 6 Nov 2021 21:21:30 +0100 Subject: [PATCH 2/2] code check --- SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h | 1 - 1 file changed, 1 deletion(-) diff --git a/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h b/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h index 76898d846282f..fe3c25c0be18e 100644 --- a/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h +++ b/SimTracker/TrackerHitAssociation/test/myTrackAnalyzer.h @@ -53,7 +53,6 @@ class myTrackAnalyzer : public edm::one::EDAnalyzer<> { const bool doPixel_, doStrip_; const edm::InputTag trackCollectionTag_; const edm::ESGetToken tokGeo_; - }; #endif