From 7fe0819c74bc2f695f2e81103ccd6b34bf90e58f Mon Sep 17 00:00:00 2001 From: sesanche Date: Tue, 14 May 2019 09:47:50 +0200 Subject: [PATCH 1/8] Loosening muon id cuts, adding flag for loose id and adding lowpt mva --- PhysicsTools/NanoAOD/python/muons_cff.py | 14 +++++++++++--- PhysicsTools/NanoAOD/python/nano_cff.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/muons_cff.py b/PhysicsTools/NanoAOD/python/muons_cff.py index 3f7767c2dbd70..6ff7875818e79 100644 --- a/PhysicsTools/NanoAOD/python/muons_cff.py +++ b/PhysicsTools/NanoAOD/python/muons_cff.py @@ -53,7 +53,7 @@ finalMuons = cms.EDFilter("PATMuonRefSelector", src = cms.InputTag("slimmedMuonsWithUserData"), - cut = cms.string("pt > 3 && track.isNonnull && isLooseMuon") + cut = cms.string("pt > 3 && (passed('CutBasedIdLoose') || passed('SoftCutBasedId') || passed('CutBasedIdGlobalHighPt') || passed('CutBasedIdTrkHighPt'))") ) muonMVATTH= cms.EDProducer("MuonBaseMVAValueMapProducer", @@ -79,6 +79,12 @@ ) ) +muonMVALowPt = muonMVATTH.clone( + weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/mu_BDTG_lowpt.weights.xml"), + name = cms.string("muonMVALowPt"), +) + + for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016: modifier.toModify(muonMVATTH, weightFile = "PhysicsTools/NanoAOD/data/mu_BDTG_2016.weights.xml", @@ -101,7 +107,7 @@ sip3d = Var("abs(dB('PV3D')/edB('PV3D'))",float,doc="3D impact parameter significance wrt first PV",precision=10), segmentComp = Var("segmentCompatibility()", float, doc = "muon segment compatibility", precision=14), # keep higher precision since people have cuts with 3 digits on this nStations = Var("numberOfMatchedStations", int, doc = "number of matched stations with default arbitration (segment & track)"), - nTrackerLayers = Var("innerTrack().hitPattern().trackerLayersWithMeasurement()", int, doc = "number of layers in the tracker"), + nTrackerLayers = Var("?track.isNonnull?innerTrack().hitPattern().trackerLayersWithMeasurement():0", int, doc = "number of layers in the tracker"), jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"), miniPFRelIso_chg = Var("userFloat('miniIsoChg')/pt",float,doc="mini PF relative isolation, charged component"), miniPFRelIso_all = Var("userFloat('miniIsoAll')/pt",float,doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"), @@ -111,6 +117,7 @@ jetRelIso = Var("?userCand('jetForLepJetVar').isNonnull()?(1./userFloat('ptRatio'))-1.:(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt",float,doc="Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)",precision=8), jetPtRelv2 = Var("?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0",float,doc="Relative momentum of the lepton with respect to the closest jet after subtracting the lepton",precision=8), tightCharge = Var("?(muonBestTrack().ptError()/muonBestTrack().pt() < 0.2)?2:0",int,doc="Tight charge criterion using pterr/pt of muonBestTrack (0:fail, 2:pass)"), + looseId = Var("passed('CutBasedIdLoose')",bool, doc="muon is loose muon"), isPFcand = Var("isPFMuon",bool,doc="muon is PF candidate"), isGlobal = Var("isGlobalMuon",bool,doc="muon is global muon"), isTracker = Var("isTrackerMuon",bool,doc="muon is tracker muon"), @@ -130,6 +137,7 @@ ), externalVariables = cms.PSet( mvaTTH = ExtVar(cms.InputTag("muonMVATTH"),float, doc="TTH MVA lepton ID score",precision=14), + mvaLowPt = ExtVar(cms.InputTag("muonMVALowPt"),float, doc="Low pt muon ID score",precision=14), ), ) @@ -157,7 +165,7 @@ muonSequence = cms.Sequence(isoForMu + ptRatioRelForMu + slimmedMuonsWithUserData + finalMuons) muonMC = cms.Sequence(muonsMCMatchForTable + muonMCTable) -muonTables = cms.Sequence(muonMVATTH + muonTable) +muonTables = cms.Sequence(muonMVATTH + muonMVALowPt + muonTable) _withUpdate_sequence = muonSequence.copy() _withUpdate_sequence.replace(isoForMu, slimmedMuonsUpdated+isoForMu) diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index 6e24b7e577cef..77f218536494a 100644 --- a/PhysicsTools/NanoAOD/python/nano_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_cff.py @@ -47,7 +47,7 @@ taus=cms.InputTag("linkedObjects","taus"), photons=cms.InputTag("linkedObjects","photons"), jetSel=cms.string("pt>15"), - muonSel=cms.string("isPFMuon && innerTrack.validFraction >= 0.49 && ( isGlobalMuon && globalTrack.normalizedChi2 < 3 && combinedQuality.chi2LocalPosition < 12 && combinedQuality.trkKink < 20 && segmentCompatibility >= 0.303 || segmentCompatibility >= 0.451 )"), + muonSel=cms.string("track.isNonnull && isLooseMuon && isPFMuon && innerTrack.validFraction >= 0.49 && ( isGlobalMuon && globalTrack.normalizedChi2 < 3 && combinedQuality.chi2LocalPosition < 12 && combinedQuality.trkKink < 20 && segmentCompatibility >= 0.303 || segmentCompatibility >= 0.451 )"), electronSel=cms.string(""), tauSel=cms.string(""), photonSel=cms.string(""), From f22b4b72498dd0e81d0c59930abdae52502070f5 Mon Sep 17 00:00:00 2001 From: sesanche Date: Tue, 14 May 2019 10:15:07 +0200 Subject: [PATCH 2/8] Also adding soft mva --- PhysicsTools/NanoAOD/python/muons_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/NanoAOD/python/muons_cff.py b/PhysicsTools/NanoAOD/python/muons_cff.py index 6ff7875818e79..b1c5bae13e9f8 100644 --- a/PhysicsTools/NanoAOD/python/muons_cff.py +++ b/PhysicsTools/NanoAOD/python/muons_cff.py @@ -53,7 +53,7 @@ finalMuons = cms.EDFilter("PATMuonRefSelector", src = cms.InputTag("slimmedMuonsWithUserData"), - cut = cms.string("pt > 3 && (passed('CutBasedIdLoose') || passed('SoftCutBasedId') || passed('CutBasedIdGlobalHighPt') || passed('CutBasedIdTrkHighPt'))") + cut = cms.string("pt > 3 && (passed('CutBasedIdLoose') || passed('SoftCutBasedId') || passed('SoftMvaId') || passed('CutBasedIdGlobalHighPt') || passed('CutBasedIdTrkHighPt'))") ) muonMVATTH= cms.EDProducer("MuonBaseMVAValueMapProducer", From 9fbc69211acf16b3e67a9bdb857dc5ce280f17ef Mon Sep 17 00:00:00 2001 From: sesanche Date: Tue, 14 May 2019 12:15:39 +0200 Subject: [PATCH 3/8] Fixing DQM --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 7da588244390d..41fb39311f5db 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -53,6 +53,7 @@ NoPlot('jetIdx'), Plot1D('jetPtRelv2', 'jetPtRelv2', 20, 0, 60, 'Relative momentum of the lepton with respect to the closest jet after subtracting the lepton'), Plot1D('jetRelIso', 'jetRelIso', 20, -0.2, 1.8, 'Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)'), + Plot1D('looseId', 'looseId', 2, -0.5, 1.5, 'muon is loose muon'), Plot1D('lostHits', 'lostHits', 4, -0.5, 3.5, 'number of missing inner hits'), NoPlot('mass'), Plot1D('miniPFRelIso_all', 'miniPFRelIso_all', 20, 0, 1, 'mini PF relative isolation, total (with scaled rho*EA PU corrections)'), @@ -74,6 +75,7 @@ Plot1D('mvaFall17V2noIso_WP90', 'mvaFall17V2noIso_WP90', 2, -0.5, 1.5, 'MVA noIso ID V2 WP90'), Plot1D('mvaFall17V2noIso_WPL', 'mvaFall17V2noIso_WPL', 2, -0.5, 1.5, 'MVA noIso ID V2 loose WP'), Plot1D('mvaTTH', 'mvaTTH', 20, -1, 1, 'TTH MVA lepton ID score'), + Plot1D('mvaLowPt', 'mvaLowPt', 20, -1, 1, 'Low pt muon ID score'), Plot1D('pdgId', 'pdgId', 27, -13.5, 13.5, 'PDG code assigned by the event reconstruction (not by MC truth)'), Plot1D('pfRelIso03_all', 'pfRelIso03_all', 20, 0, 2, 'PF relative isolation dR=0.3, total (with rho*EA PU corrections)'), Plot1D('pfRelIso03_chg', 'pfRelIso03_chg', 20, 0, 2, 'PF relative isolation dR=0.3, charged component'), From 222078ef38be72141162d6338340f300993e813b Mon Sep 17 00:00:00 2001 From: sesanche Date: Tue, 14 May 2019 17:57:10 +0200 Subject: [PATCH 4/8] Fix dqm --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 41fb39311f5db..f2aac8b8a1bdc 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -53,7 +53,6 @@ NoPlot('jetIdx'), Plot1D('jetPtRelv2', 'jetPtRelv2', 20, 0, 60, 'Relative momentum of the lepton with respect to the closest jet after subtracting the lepton'), Plot1D('jetRelIso', 'jetRelIso', 20, -0.2, 1.8, 'Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)'), - Plot1D('looseId', 'looseId', 2, -0.5, 1.5, 'muon is loose muon'), Plot1D('lostHits', 'lostHits', 4, -0.5, 3.5, 'number of missing inner hits'), NoPlot('mass'), Plot1D('miniPFRelIso_all', 'miniPFRelIso_all', 20, 0, 1, 'mini PF relative isolation, total (with scaled rho*EA PU corrections)'), @@ -75,7 +74,6 @@ Plot1D('mvaFall17V2noIso_WP90', 'mvaFall17V2noIso_WP90', 2, -0.5, 1.5, 'MVA noIso ID V2 WP90'), Plot1D('mvaFall17V2noIso_WPL', 'mvaFall17V2noIso_WPL', 2, -0.5, 1.5, 'MVA noIso ID V2 loose WP'), Plot1D('mvaTTH', 'mvaTTH', 20, -1, 1, 'TTH MVA lepton ID score'), - Plot1D('mvaLowPt', 'mvaLowPt', 20, -1, 1, 'Low pt muon ID score'), Plot1D('pdgId', 'pdgId', 27, -13.5, 13.5, 'PDG code assigned by the event reconstruction (not by MC truth)'), Plot1D('pfRelIso03_all', 'pfRelIso03_all', 20, 0, 2, 'PF relative isolation dR=0.3, total (with rho*EA PU corrections)'), Plot1D('pfRelIso03_chg', 'pfRelIso03_chg', 20, 0, 2, 'PF relative isolation dR=0.3, charged component'), @@ -338,6 +336,7 @@ NoPlot('jetIdx'), Plot1D('jetPtRelv2', 'jetPtRelv2', 20, 0, 30, 'Relative momentum of the lepton with respect to the closest jet after subtracting the lepton'), Plot1D('jetRelIso', 'jetRelIso', 20, -0.2, 1.8, 'Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)'), + Plot1D('looseId', 'looseId', 2, -0.5, 1.5, 'muon is loose muon'), NoPlot('mass'), Profile1D('mediumId', 'mediumId', 'pt', 16, 0, 80, 'POG Medium muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)'), Plot1D('mediumPromptId', 'mediumPromptId', 2, -0.5, 1.5, 'cut-based ID, medium prompt WP'), @@ -347,6 +346,7 @@ Plot1D('multiIsoId', 'multiIsoId', 3, -0.5, 2.5, 'MultiIsoId from miniAOD selector (1=MultiIsoLoose, 2=MultiIsoMedium)'), Plot1D('mvaId', 'mvaId', 4, -0.5, 3.5, 'Mva ID from miniAOD selector (1=MvaLoose, 2=MvaMedium, 3=MvaTight)'), Plot1D('mvaTTH', 'mvaTTH', 20, -1, 1, 'TTH MVA lepton ID score'), + Plot1D('mvaLowPt', 'mvaLowPt', 20, -1, 1, 'Low pt muon ID score'), Plot1D('nStations', 'nStations', 5, -0.5, 4.5, 'number of matched stations with default arbitration (segment & track)'), Plot1D('nTrackerLayers', 'nTrackerLayers', 15, 2.5, 17.5, 'number of layers in the tracker'), Plot1D('pdgId', 'pdgId', 27, -13.5, 13.5, 'PDG code assigned by the event reconstruction (not by MC truth)'), From 7539d5f9838708a1a19071b32295aad139d65027 Mon Sep 17 00:00:00 2001 From: sesanche Date: Tue, 14 May 2019 20:57:05 +0200 Subject: [PATCH 5/8] Fix dqm --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index f2aac8b8a1bdc..cfc6518318358 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -345,8 +345,8 @@ Plot1D('miniPFRelIso_chg', 'miniPFRelIso_chg', 20, 0, 1, 'mini PF relative isolation, charged component'), Plot1D('multiIsoId', 'multiIsoId', 3, -0.5, 2.5, 'MultiIsoId from miniAOD selector (1=MultiIsoLoose, 2=MultiIsoMedium)'), Plot1D('mvaId', 'mvaId', 4, -0.5, 3.5, 'Mva ID from miniAOD selector (1=MvaLoose, 2=MvaMedium, 3=MvaTight)'), - Plot1D('mvaTTH', 'mvaTTH', 20, -1, 1, 'TTH MVA lepton ID score'), Plot1D('mvaLowPt', 'mvaLowPt', 20, -1, 1, 'Low pt muon ID score'), + Plot1D('mvaTTH', 'mvaTTH', 20, -1, 1, 'TTH MVA lepton ID score'), Plot1D('nStations', 'nStations', 5, -0.5, 4.5, 'number of matched stations with default arbitration (segment & track)'), Plot1D('nTrackerLayers', 'nTrackerLayers', 15, 2.5, 17.5, 'number of layers in the tracker'), Plot1D('pdgId', 'pdgId', 27, -13.5, 13.5, 'PDG code assigned by the event reconstruction (not by MC truth)'), From d06b5e57a032266624b6d8da90dbf68f86f14acf Mon Sep 17 00:00:00 2001 From: peruzzim Date: Tue, 14 May 2019 22:47:06 +0200 Subject: [PATCH 6/8] Keep loose muon selector for isotrack cleaning --- PhysicsTools/NanoAOD/python/muons_cff.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PhysicsTools/NanoAOD/python/muons_cff.py b/PhysicsTools/NanoAOD/python/muons_cff.py index b1c5bae13e9f8..63067be45023a 100644 --- a/PhysicsTools/NanoAOD/python/muons_cff.py +++ b/PhysicsTools/NanoAOD/python/muons_cff.py @@ -56,6 +56,11 @@ cut = cms.string("pt > 3 && (passed('CutBasedIdLoose') || passed('SoftCutBasedId') || passed('SoftMvaId') || passed('CutBasedIdGlobalHighPt') || passed('CutBasedIdTrkHighPt'))") ) +finalLooseMuons = cms.EDFilter("PATMuonRefSelector", # for isotrack cleaning + src = cms.InputTag("finalMuons"), + cut = cms.string("track.isNonnull && isLooseMuon") +) + muonMVATTH= cms.EDProducer("MuonBaseMVAValueMapProducer", src = cms.InputTag("linkedObjects","muons"), weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/mu_BDTG_2017.weights.xml"), @@ -163,7 +168,7 @@ docString = cms.string("MC matching to status==1 muons"), ) -muonSequence = cms.Sequence(isoForMu + ptRatioRelForMu + slimmedMuonsWithUserData + finalMuons) +muonSequence = cms.Sequence(isoForMu + ptRatioRelForMu + slimmedMuonsWithUserData + finalMuons + finalLooseMuons) muonMC = cms.Sequence(muonsMCMatchForTable + muonMCTable) muonTables = cms.Sequence(muonMVATTH + muonMVALowPt + muonTable) From e8443adfe59629319a290aba1310e0d72bda9e8c Mon Sep 17 00:00:00 2001 From: peruzzim Date: Tue, 14 May 2019 22:47:45 +0200 Subject: [PATCH 7/8] Keep using PF loose muons for isotrack cleaning --- PhysicsTools/NanoAOD/python/isotracks_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/NanoAOD/python/isotracks_cff.py b/PhysicsTools/NanoAOD/python/isotracks_cff.py index 1317af3f36cd1..76daacf2f0b1a 100644 --- a/PhysicsTools/NanoAOD/python/isotracks_cff.py +++ b/PhysicsTools/NanoAOD/python/isotracks_cff.py @@ -6,7 +6,7 @@ cut = cms.string("((pt>5 && (abs(pdgId) == 11 || abs(pdgId) == 13)) || pt > 10) && (abs(pdgId) < 15 || abs(eta) < 2.5) && abs(dxy) < 0.2 && abs(dz) < 0.1 && ((pfIsolationDR03().chargedHadronIso < 5 && pt < 25) || pfIsolationDR03().chargedHadronIso/pt < 0.2)"), finalLeptons = cms.VInputTag( cms.InputTag("finalElectrons"), - cms.InputTag("finalMuons"), + cms.InputTag("finalLooseMuons"), ), ) From f2989b9db288f18de04eb1d965b7a2fb37affa69 Mon Sep 17 00:00:00 2001 From: peruzzim Date: Tue, 14 May 2019 23:49:28 +0200 Subject: [PATCH 8/8] Correct collection type --- PhysicsTools/NanoAOD/python/muons_cff.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/muons_cff.py b/PhysicsTools/NanoAOD/python/muons_cff.py index 63067be45023a..04e8bc0c0d638 100644 --- a/PhysicsTools/NanoAOD/python/muons_cff.py +++ b/PhysicsTools/NanoAOD/python/muons_cff.py @@ -57,8 +57,8 @@ ) finalLooseMuons = cms.EDFilter("PATMuonRefSelector", # for isotrack cleaning - src = cms.InputTag("finalMuons"), - cut = cms.string("track.isNonnull && isLooseMuon") + src = cms.InputTag("slimmedMuonsWithUserData"), + cut = cms.string("pt > 3 && track.isNonnull && isLooseMuon") ) muonMVATTH= cms.EDProducer("MuonBaseMVAValueMapProducer",