From 131c83b6065733b1cbe68d5c67c43b5c7c06e49b Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 12 Jan 2022 11:21:47 +0100 Subject: [PATCH] pre-select high purity tracks as input for muon reco in pp_on_AA era --- .../GlobalMuonProducer/python/globalMuons_cfi.py | 7 ++++++- .../GlobalMuonProducer/src/GlobalMuonProducer.cc | 4 ++++ .../interface/GlobalMuonTrajectoryBuilder.h | 5 +++++ .../src/GlobalMuonTrajectoryBuilder.cc | 7 +++++++ .../MuonIdentification/plugins/MuonIdProducer.cc | 12 ++++++++++++ RecoMuon/MuonIdentification/plugins/MuonIdProducer.h | 5 +++++ RecoMuon/MuonIdentification/python/earlyMuons_cfi.py | 3 ++- .../MuonIdentification/python/muons1stStep_cfi.py | 4 +++- 8 files changed, 44 insertions(+), 3 deletions(-) diff --git a/RecoMuon/GlobalMuonProducer/python/globalMuons_cfi.py b/RecoMuon/GlobalMuonProducer/python/globalMuons_cfi.py index 3b707ff8b0968..7c4837fd938c4 100644 --- a/RecoMuon/GlobalMuonProducer/python/globalMuons_cfi.py +++ b/RecoMuon/GlobalMuonProducer/python/globalMuons_cfi.py @@ -10,7 +10,9 @@ GlobalTrajectoryBuilderCommon ), TrackerCollectionLabel = cms.InputTag("generalTracks"), - MuonCollectionLabel = cms.InputTag("standAloneMuons","UpdatedAtVtx") + MuonCollectionLabel = cms.InputTag("standAloneMuons","UpdatedAtVtx"), + VertexCollectionLabel = cms.InputTag("offlinePrimaryVertices"), + selectHighPurity = cms.bool(False) ) globalMuons.GLBTrajBuilderParameters.GlobalMuonTrackMatcher.Propagator = 'SmartPropagatorRK' @@ -28,3 +30,6 @@ GlobalMuonTrackMatcher = dict(Propagator = 'SmartPropagator') ) ) + +from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA +pp_on_AA.toModify(globalMuons, selectHighPurity = True) diff --git a/RecoMuon/GlobalMuonProducer/src/GlobalMuonProducer.cc b/RecoMuon/GlobalMuonProducer/src/GlobalMuonProducer.cc index c75f7c2f1007a..d9ba66e486937 100644 --- a/RecoMuon/GlobalMuonProducer/src/GlobalMuonProducer.cc +++ b/RecoMuon/GlobalMuonProducer/src/GlobalMuonProducer.cc @@ -39,6 +39,10 @@ GlobalMuonProducer::GlobalMuonProducer(const ParameterSet& parameterSet) { ParameterSet trajectoryBuilderParameters = parameterSet.getParameter("GLBTrajBuilderParameters"); InputTag trackCollectionTag = parameterSet.getParameter("TrackerCollectionLabel"); trajectoryBuilderParameters.addParameter("TrackerCollectionLabel", trackCollectionTag); + InputTag vertexCollectionTag = parameterSet.getParameter("VertexCollectionLabel"); + trajectoryBuilderParameters.addParameter("VertexCollectionLabel", vertexCollectionTag); + bool selectHighPurity_ = parameterSet.getParameter("selectHighPurity"); + trajectoryBuilderParameters.addParameter("selectHighPurity", selectHighPurity_); // STA Muon Collection Label theSTACollectionLabel = parameterSet.getParameter("MuonCollectionLabel"); diff --git a/RecoMuon/GlobalTrackFinder/interface/GlobalMuonTrajectoryBuilder.h b/RecoMuon/GlobalTrackFinder/interface/GlobalMuonTrajectoryBuilder.h index ab1b2136d5741..341eaf3b17428 100644 --- a/RecoMuon/GlobalTrackFinder/interface/GlobalMuonTrajectoryBuilder.h +++ b/RecoMuon/GlobalTrackFinder/interface/GlobalMuonTrajectoryBuilder.h @@ -14,6 +14,7 @@ #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "DataFormats/VertexReco/interface/Vertex.h" namespace edm { class ParameterSet; @@ -48,5 +49,9 @@ class GlobalMuonTrajectoryBuilder : public GlobalTrajectoryBuilderBase { edm::InputTag theTkTrackLabel; edm::EDGetTokenT allTrackerTracksToken; edm::Handle allTrackerTracks; + edm::InputTag thePrimaryVtxLabel; + edm::EDGetTokenT primaryVertexToken; + edm::Handle vertexCollection; + bool selectHighPurity_; }; #endif diff --git a/RecoMuon/GlobalTrackFinder/src/GlobalMuonTrajectoryBuilder.cc b/RecoMuon/GlobalTrackFinder/src/GlobalMuonTrajectoryBuilder.cc index 02e6fdfedff60..3f01fa3cebe7f 100644 --- a/RecoMuon/GlobalTrackFinder/src/GlobalMuonTrajectoryBuilder.cc +++ b/RecoMuon/GlobalTrackFinder/src/GlobalMuonTrajectoryBuilder.cc @@ -61,6 +61,9 @@ GlobalMuonTrajectoryBuilder::GlobalMuonTrajectoryBuilder(const edm::ParameterSet { theTkTrackLabel = par.getParameter("TrackerCollectionLabel"); allTrackerTracksToken = iC.consumes(theTkTrackLabel); + thePrimaryVtxLabel = par.getParameter("VertexCollectionLabel"); + primaryVertexToken = iC.mayConsume(thePrimaryVtxLabel); + selectHighPurity_ = par.getParameter("selectHighPurity"); } //-------------- @@ -80,6 +83,10 @@ void GlobalMuonTrajectoryBuilder::setEvent(const edm::Event& event) { // get tracker TrackCollection from Event event.getByToken(allTrackerTracksToken, allTrackerTracks); LogDebug(category) << " Found " << allTrackerTracks->size() << " tracker Tracks with label " << theTkTrackLabel; + + // get primary vertex from Event + event.getByToken(primaryVertexToken, vertexCollection); + LogDebug(category) << " Found " << vertexCollection->size() << " tracker Tracks with label " << thePrimaryVtxLabel; } // diff --git a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc index 974fa1d91b6f3..3fc9cdcdec7bc 100644 --- a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc +++ b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc @@ -157,6 +157,11 @@ MuonIdProducer::MuonIdProducer(const edm::ParameterSet& iConfig) std::make_unique(iConfig.getParameter("TrackerKinkFinderParameters"), iC); } + if (selectHighPurity_) { + const auto& pvTag = iConfig.getParameter("pvInputTag"); + pvToken_ = mayConsume(pvTag); + } + //create mesh holder meshAlgo_ = std::make_unique(iConfig.getParameter("arbitrationCleanerOptions")); @@ -253,6 +258,8 @@ void MuonIdProducer::init(edm::Event& iEvent, const edm::EventSetup& iSetup) { iEvent.getByToken(rpcHitToken_, rpcHitHandle_); if (fillGlobalTrackQuality_) iEvent.getByToken(glbQualToken_, glbQualHandle_); + if (selectHighPurity_) + iEvent.getByToken(pvToken_, pvHandle_); } reco::Muon MuonIdProducer::makeMuon(edm::Event& iEvent, @@ -540,6 +547,11 @@ void MuonIdProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) const reco::Track& track = innerTrackCollectionHandle_->at(i); if (!isGoodTrack(track)) continue; + if (selectHighPurity_ && !track.quality(reco::TrackBase::highPurity)) { + const reco::VertexCollection* recoVertices = pvHandle_.product(); + if (!recoVertices->at(0).isFake()) + continue; + } const auto& trackRef = reco::TrackRef(innerTrackCollectionHandle_, i); bool splitTrack = false; if (track.extra().isAvailable() && TrackDetectorAssociator::crossedIP(track)) diff --git a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.h b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.h index be7974dfa4ac9..bef21b9a00771 100644 --- a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.h +++ b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.h @@ -36,6 +36,7 @@ #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackReco/interface/TrackToTrackMap.h" +#include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/MuonReco/interface/Muon.h" #include "DataFormats/MuonReco/interface/MuonTrackLinks.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" @@ -231,6 +232,7 @@ class MuonIdProducer : public edm::stream::EDProducer<> { edm::Handle tpfmsCollectionHandle_; edm::Handle pickyCollectionHandle_; edm::Handle dytCollectionHandle_; + edm::Handle pvHandle_; edm::EDGetTokenT innerTrackCollectionToken_; edm::EDGetTokenT outerTrackCollectionToken_; @@ -239,6 +241,7 @@ class MuonIdProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT tpfmsCollectionToken_; edm::EDGetTokenT pickyCollectionToken_; edm::EDGetTokenT dytCollectionToken_; + edm::EDGetTokenT pvToken_; edm::EDGetTokenT rpcHitToken_; edm::EDGetTokenT > glbQualToken_; @@ -264,6 +267,8 @@ class MuonIdProducer : public edm::stream::EDProducer<> { bool fillGlobalTrackRefits_; edm::InputTag globalTrackQualityInputTag_; + edm::InputTag pvInputTag_; + bool selectHighPurity_; bool fillTrackerKink_; std::unique_ptr trackerKinkFinder_; diff --git a/RecoMuon/MuonIdentification/python/earlyMuons_cfi.py b/RecoMuon/MuonIdentification/python/earlyMuons_cfi.py index eaccc9d968b4b..0f10b0f204a6d 100644 --- a/RecoMuon/MuonIdentification/python/earlyMuons_cfi.py +++ b/RecoMuon/MuonIdentification/python/earlyMuons_cfi.py @@ -17,7 +17,8 @@ TrackAssociatorParameters = dict( useHO = False, useEcal = False, - useHcal = False) + useHcal = False), + pvInputTag = "firstStepPrimaryVertices" #Not used, but needed to avoid circular dependency in schedule ) earlyDisplacedMuons = earlyMuons.clone( inputCollectionLabels = ['earlyGeneralTracks','displacedStandAloneMuons:'] diff --git a/RecoMuon/MuonIdentification/python/muons1stStep_cfi.py b/RecoMuon/MuonIdentification/python/muons1stStep_cfi.py index 4cf0ab8b7aaf9..94664a7a384c4 100644 --- a/RecoMuon/MuonIdentification/python/muons1stStep_cfi.py +++ b/RecoMuon/MuonIdentification/python/muons1stStep_cfi.py @@ -66,6 +66,8 @@ # global quality fillGlobalTrackQuality = cms.bool(False), #input depends on external module output --> set to True where the sequence is defined globalTrackQualityInputTag = cms.InputTag('glbTrackQual'), + selectHighPurity = cms.bool(False), + pvInputTag = cms.InputTag('offlinePrimaryVertices'), # tracker kink finding fillTrackerKink = cms.bool(True), @@ -100,7 +102,7 @@ ) from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA -pp_on_AA.toModify(muons1stStep, minPt = 0.8) +pp_on_AA.toModify(muons1stStep, minPt = 0.8, selectHighPurity = True) from Configuration.ProcessModifiers.recoFromReco_cff import recoFromReco recoFromReco.toModify(muons1stStep,fillShowerDigis = False)