From 707c4b11398a67b8988d858cb3b23fc5137d4a68 Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 14 Sep 2021 19:02:48 +0200 Subject: [PATCH] complete es consumes migration of Alignment/CommonAlignmentProducer --- .../interface/AlignmentTrackSelector.h | 8 +++- .../AlignmentMuonHIPTrajectorySelector.cc | 4 +- .../plugins/GlobalTrackerMuonAlignment.cc | 47 +++++++++---------- .../src/AlignmentTrackSelector.cc | 12 ++--- 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/interface/AlignmentTrackSelector.h b/Alignment/CommonAlignmentProducer/interface/AlignmentTrackSelector.h index 1b215eb534cdd..9aa337f5d6f5e 100644 --- a/Alignment/CommonAlignmentProducer/interface/AlignmentTrackSelector.h +++ b/Alignment/CommonAlignmentProducer/interface/AlignmentTrackSelector.h @@ -2,12 +2,14 @@ #define Alignment_CommonAlignmentAlgorithm_AlignmentTrackSelector_h #include "DataFormats/Alignment/interface/AliClusterValueMapFwd.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "Geometry/Records/interface/TrackerTopologyRcd.h" #include namespace edm { @@ -60,6 +62,8 @@ class AlignmentTrackSelector { }; ComparePt ptComparator; + edm::ESGetToken tTopoToken_; + const bool applyBasicCuts_, applyNHighestPt_, applyMultiplicityFilter_; const int seedOnlyFromAbove_; const bool applyIsolation_, chargeCheck_; diff --git a/Alignment/CommonAlignmentProducer/plugins/AlignmentMuonHIPTrajectorySelector.cc b/Alignment/CommonAlignmentProducer/plugins/AlignmentMuonHIPTrajectorySelector.cc index 417ed047241a4..60298e34112bf 100644 --- a/Alignment/CommonAlignmentProducer/plugins/AlignmentMuonHIPTrajectorySelector.cc +++ b/Alignment/CommonAlignmentProducer/plugins/AlignmentMuonHIPTrajectorySelector.cc @@ -24,7 +24,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -51,7 +51,7 @@ // class decleration // -class AlignmentMuonHIPTrajectorySelector : public edm::EDProducer { +class AlignmentMuonHIPTrajectorySelector : public edm::stream::EDProducer<> { public: explicit AlignmentMuonHIPTrajectorySelector(const edm::ParameterSet&); ~AlignmentMuonHIPTrajectorySelector() override; diff --git a/Alignment/CommonAlignmentProducer/plugins/GlobalTrackerMuonAlignment.cc b/Alignment/CommonAlignmentProducer/plugins/GlobalTrackerMuonAlignment.cc index b72d7b31cd1c7..6f566743fbbb8 100644 --- a/Alignment/CommonAlignmentProducer/plugins/GlobalTrackerMuonAlignment.cc +++ b/Alignment/CommonAlignmentProducer/plugins/GlobalTrackerMuonAlignment.cc @@ -31,7 +31,7 @@ // Framework #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESWatcher.h" #include "FWCore/Framework/interface/Frameworkfwd.h" //#include "FWCore/Framework/interface/EDProducer.h" @@ -106,7 +106,7 @@ using namespace reco; // class declaration // -class GlobalTrackerMuonAlignment : public edm::EDAnalyzer { +class GlobalTrackerMuonAlignment : public edm::one::EDAnalyzer<> { public: explicit GlobalTrackerMuonAlignment(const edm::ParameterSet&); ~GlobalTrackerMuonAlignment() override; @@ -155,6 +155,11 @@ class GlobalTrackerMuonAlignment : public edm::EDAnalyzer { void endJob() override; // ----------member data --------------------------- + edm::ESGetToken m_TkGeometryToken; + edm::ESGetToken m_MagFieldToken; + edm::ESGetToken m_globalPosToken; + edm::ESGetToken m_propToken; + edm::ESGetToken m_ttrhBuilderToken; edm::InputTag trackTags_; // used to select what tracks to read from configuration file edm::InputTag muonTags_; // used to select what standalone muons @@ -270,18 +275,19 @@ class GlobalTrackerMuonAlignment : public edm::EDAnalyzer { // constructors and destructor // GlobalTrackerMuonAlignment::GlobalTrackerMuonAlignment(const edm::ParameterSet& iConfig) - : trackTags_(iConfig.getParameter("tracks")), + : m_TkGeometryToken(esConsumes()), + m_MagFieldToken(esConsumes()), + m_globalPosToken(esConsumes()), + m_propToken(esConsumes(edm::ESInputTag("", iConfig.getParameter("Propagator")))), + m_ttrhBuilderToken(esConsumes(edm::ESInputTag("", "witTrackAngle"))), + trackTags_(iConfig.getParameter("tracks")), muonTags_(iConfig.getParameter("muons")), gmuonTags_(iConfig.getParameter("gmuons")), smuonTags_(iConfig.getParameter("smuons")), - propagator_(iConfig.getParameter("Propagator")), - cosmicMuonMode_(iConfig.getParameter("cosmics")), isolatedMuonMode_(iConfig.getParameter("isolated")), - refitMuon_(iConfig.getParameter("refitmuon")), refitTrack_(iConfig.getParameter("refittrack")), - rootOutFile_(iConfig.getUntrackedParameter("rootOutFile")), txtOutFile_(iConfig.getUntrackedParameter("txtOutFile")), writeDB_(iConfig.getUntrackedParameter("writeDB")), @@ -660,20 +666,17 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrack(const edm::Event& iEvent, con //iSetup.get().get(cscGeometry); if (watchTrackingGeometry_.check(iSetup) || !trackingGeometry_) { - edm::ESHandle trackingGeometry; - iSetup.get().get(trackingGeometry); + edm::ESHandle trackingGeometry = iSetup.getHandle(m_TkGeometryToken); trackingGeometry_ = &*trackingGeometry; } if (watchMagneticFieldRecord_.check(iSetup) || !magneticField_) { - edm::ESHandle magneticField; - iSetup.get().get(magneticField); + edm::ESHandle magneticField = iSetup.getHandle(m_MagFieldToken); magneticField_ = &*magneticField; } if (watchGlobalPositionRcd_.check(iSetup) || !globalPositionRcd_) { - edm::ESHandle globalPositionRcd; - iSetup.get().get(globalPositionRcd); + edm::ESHandle globalPositionRcd = iSetup.getHandle(m_globalPosToken); globalPositionRcd_ = &*globalPositionRcd; for (std::vector::const_iterator i = globalPositionRcd_->m_align.begin(); i != globalPositionRcd_->m_align.end(); @@ -695,8 +698,7 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrack(const edm::Event& iEvent, con } } // end of GlobalPositionRcd - ESHandle propagator; - iSetup.get().get(propagator_, propagator); + edm::ESHandle propagator = iSetup.getHandle(m_propToken); SteppingHelixPropagator alongStHePr = SteppingHelixPropagator(magneticField_, alongMomentum); SteppingHelixPropagator oppositeStHePr = SteppingHelixPropagator(magneticField_, oppositeToMomentum); @@ -1339,21 +1341,18 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrajectory(const edm::Event& iEvent //iSetup.get().get(cscGeometry); if (watchTrackingGeometry_.check(iSetup) || !trackingGeometry_) { - edm::ESHandle trackingGeometry; - iSetup.get().get(trackingGeometry); + edm::ESHandle trackingGeometry = iSetup.getHandle(m_TkGeometryToken); trackingGeometry_ = &*trackingGeometry; theTrackingGeometry = trackingGeometry; } if (watchMagneticFieldRecord_.check(iSetup) || !magneticField_) { - edm::ESHandle magneticField; - iSetup.get().get(magneticField); + edm::ESHandle magneticField = iSetup.getHandle(m_MagFieldToken); magneticField_ = &*magneticField; } if (watchGlobalPositionRcd_.check(iSetup) || !globalPositionRcd_) { - edm::ESHandle globalPositionRcd; - iSetup.get().get(globalPositionRcd); + edm::ESHandle globalPositionRcd = iSetup.getHandle(m_globalPosToken); globalPositionRcd_ = &*globalPositionRcd; for (std::vector::const_iterator i = globalPositionRcd_->m_align.begin(); i != globalPositionRcd_->m_align.end(); @@ -1379,8 +1378,7 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrajectory(const edm::Event& iEvent } } // end of GlobalPositionRcd - ESHandle propagator; - iSetup.get().get(propagator_, propagator); + edm::ESHandle propagator = iSetup.getHandle(m_propToken); SteppingHelixPropagator alongStHePr = SteppingHelixPropagator(magneticField_, alongMomentum); SteppingHelixPropagator oppositeStHePr = SteppingHelixPropagator(magneticField_, oppositeToMomentum); @@ -1407,8 +1405,7 @@ void GlobalTrackerMuonAlignment::analyzeTrackTrajectory(const edm::Event& iEvent theFitterOp = new KFTrajectoryFitter(oppositeSmPr, *theUpdator, *theEstimator); theSmootherOp = new KFTrajectorySmoother(oppositeSmPr, *theUpdator, *theEstimator); - edm::ESHandle builder; - iSetup.get().get("WithTrackAngle", builder); + edm::ESHandle builder = iSetup.getHandle(m_ttrhBuilderToken); this->TTRHBuilder = &(*builder); this->MuRHBuilder = new MuonTransientTrackingRecHitBuilder(theTrackingGeometry); if (debug_) { diff --git a/Alignment/CommonAlignmentProducer/src/AlignmentTrackSelector.cc b/Alignment/CommonAlignmentProducer/src/AlignmentTrackSelector.cc index 59cfb81b812d1..35b1b72f26acc 100644 --- a/Alignment/CommonAlignmentProducer/src/AlignmentTrackSelector.cc +++ b/Alignment/CommonAlignmentProducer/src/AlignmentTrackSelector.cc @@ -16,12 +16,9 @@ #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/Alignment/interface/AlignmentClusterFlag.h" #include "DataFormats/Alignment/interface/AliClusterValueMap.h" - #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/SiStripDetId/interface/SiStripDetId.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "Geometry/Records/interface/TrackerTopologyRcd.h" #include @@ -31,7 +28,8 @@ const int kFPIX = PixelSubdetector::PixelEndcap; // constructor ---------------------------------------------------------------- AlignmentTrackSelector::AlignmentTrackSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) - : applyBasicCuts_(cfg.getParameter("applyBasicCuts")), + : tTopoToken_(iC.esConsumes()), + applyBasicCuts_(cfg.getParameter("applyBasicCuts")), applyNHighestPt_(cfg.getParameter("applyNHighestPt")), applyMultiplicityFilter_(cfg.getParameter("applyMultiplicityFilter")), seedOnlyFromAbove_(cfg.getParameter("seedOnlyFrom")), @@ -222,7 +220,7 @@ AlignmentTrackSelector::AlignmentTrackSelector(const edm::ParameterSet& cfg, edm // destructor ----------------------------------------------------------------- -AlignmentTrackSelector::~AlignmentTrackSelector() {} +AlignmentTrackSelector::~AlignmentTrackSelector() = default; // do selection --------------------------------------------------------------- @@ -321,9 +319,7 @@ bool AlignmentTrackSelector::detailedHitsCheck(const reco::Track* trackp, const edm::Event& evt, const edm::EventSetup& eSetup) const { //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - eSetup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); + const TrackerTopology* const tTopo = &eSetup.getData(tTopoToken_); // checking hit requirements beyond simple number of valid hits