From a9de615784e0a5fdeb4e87e4eed1c779011a912b Mon Sep 17 00:00:00 2001 From: Davide Bruschini Date: Thu, 30 Jun 2022 17:42:00 +0200 Subject: [PATCH 1/5] Copied "nanoGenWmassCustomize" to nanoTP_cff.py --- PhysicsTools/NanoAOD/python/nanoTP_cff.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PhysicsTools/NanoAOD/python/nanoTP_cff.py b/PhysicsTools/NanoAOD/python/nanoTP_cff.py index 72c164dd89cf4..e47c62d27ecc7 100644 --- a/PhysicsTools/NanoAOD/python/nanoTP_cff.py +++ b/PhysicsTools/NanoAOD/python/nanoTP_cff.py @@ -75,3 +75,16 @@ def customizeMuonPassThrough(process): process.finalMuons.cut = cms.string("||".join([passStandalone, process.finalMuons.cut.value()])) process.linkedMuons.cut = process.finalMuons.cut return process + +def nanoGenWmassCustomize(process): + pdgSelection="?(abs(pdgId) == 11|| abs(pdgId)==13 || abs(pdgId)==15 ||abs(pdgId)== 12 || abs(pdgId)== 14 || abs(pdgId)== 16|| abs(pdgId)== 6|| abs(pdgId)== 24|| pdgId== 23|| pdgId== 25)" + # Keep precision same as default RECO for selected particles + ptPrecision="{}?{}:{}".format(pdgSelection, CandVars.pt.precision.value(),genParticleTable.variables.pt.precision.value()) + process.genParticleTable.variables.pt.precision=cms.string(ptPrecision) + phiPrecision="{} ? {} : {}".format(pdgSelection, CandVars.phi.precision.value(), genParticleTable.variables.phi.precision.value()) + process.genParticleTable.variables.phi.precision=cms.string(phiPrecision) + etaPrecision="{} ? {} : {}".format(pdgSelection, CandVars.eta.precision.value(), genParticleTable.variables.eta.precision.value()) + process.genParticleTable.variables.eta.precision=cms.string(etaPrecision) + process.genParticleTable.variables.pt.precision=cms.string(etaPrecision) + + return process From 485c3b5a56e9f02cbd448b8f91a91fee7bf0d3b3 Mon Sep 17 00:00:00 2001 From: Davide Bruschini Date: Sun, 24 Jul 2022 16:15:38 +0200 Subject: [PATCH 2/5] GenPart precision bug fix --- PhysicsTools/NanoAOD/python/nano_cff.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index 4649882acaf34..fc49f52f70b27 100644 --- a/PhysicsTools/NanoAOD/python/nano_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_cff.py @@ -457,13 +457,12 @@ def nanoAOD_customizeMC(process): def nanoGenWmassCustomize(process): pdgSelection="?(abs(pdgId) == 11|| abs(pdgId)==13 || abs(pdgId)==15 ||abs(pdgId)== 12 || abs(pdgId)== 14 || abs(pdgId)== 16|| abs(pdgId)== 6|| abs(pdgId)== 24|| pdgId== 23|| pdgId== 25)" # Keep precision same as default RECO for selected particles - ptPrecision="{}?{}:{}".format(pdgSelection, CandVars.pt.precision.value(),genParticleTable.variables.pt.precision.value()) + ptPrecision="{}?{}:{}".format(pdgSelection, 23,genParticleTable.variables.pt.precision.value()) process.genParticleTable.variables.pt.precision=cms.string(ptPrecision) phiPrecision="{} ? {} : {}".format(pdgSelection, CandVars.phi.precision.value(), genParticleTable.variables.phi.precision.value()) process.genParticleTable.variables.phi.precision=cms.string(phiPrecision) etaPrecision="{} ? {} : {}".format(pdgSelection, CandVars.eta.precision.value(), genParticleTable.variables.eta.precision.value()) process.genParticleTable.variables.eta.precision=cms.string(etaPrecision) - process.genParticleTable.variables.pt.precision=cms.string(etaPrecision) process.lheInfoTable.storeAllLHEInfo = True From 6a4e3929f64d9b298f52b8439c58486956fe132d Mon Sep 17 00:00:00 2001 From: Davide Bruschini Date: Fri, 7 Oct 2022 11:42:19 +0200 Subject: [PATCH 3/5] Added X,Y,Z information to potentially be used for reco efficiency --- PhysicsTools/NanoAOD/python/generalTracks_cff.py | 3 +++ PhysicsTools/NanoAOD/python/muons_cff.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/PhysicsTools/NanoAOD/python/generalTracks_cff.py b/PhysicsTools/NanoAOD/python/generalTracks_cff.py index 506fbc73fbb6e..09d1d986d8149 100644 --- a/PhysicsTools/NanoAOD/python/generalTracks_cff.py +++ b/PhysicsTools/NanoAOD/python/generalTracks_cff.py @@ -20,6 +20,9 @@ trackOriginalAlgo = Var('originalAlgo()', 'int', precision=-1, doc='Track original algo enum'), qualityMask = Var('qualityMask()', 'int', precision=-1, doc='Quality mask of the track.'), extraIdx = Var('extra().key()', 'int', precision=-1, doc='Index of the TrackExtra in the original collection'), + X = Var('vx', 'float', precision=-1, doc='Track X position'), + Y = Var('vy', 'float', precision=-1, doc='Track Y position'), + Z = Var('vz', 'float', precision=-1, doc='Track Z position'), ), ) diff --git a/PhysicsTools/NanoAOD/python/muons_cff.py b/PhysicsTools/NanoAOD/python/muons_cff.py index 617fdf11d776e..2b8e15693f904 100644 --- a/PhysicsTools/NanoAOD/python/muons_cff.py +++ b/PhysicsTools/NanoAOD/python/muons_cff.py @@ -187,6 +187,9 @@ miniPFRelIso_all = Var("?hasUserFloat('miniIsoAll') ? userFloat('miniIsoAll')/pt : -1",float,doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"), pfRelIso03_chg = Var("pfIsolationR03().sumChargedHadronPt/pt",float,doc="PF relative isolation dR=0.3, charged component"), pfRelIso03_all = Var("(pfIsolationR03().sumChargedHadronPt + max(pfIsolationR03().sumNeutralHadronEt + pfIsolationR03().sumPhotonEt - pfIsolationR03().sumPUPt/2,0.0))/pt",float,doc="PF relative isolation dR=0.3, total (deltaBeta corrections)"), + pfRelIso04_chg = Var("pfIsolationR04().sumChargedHadronPt/pt",float,doc="PF relative isolation dR=0.4, charged component"), + pfRelIso04_neu = Var("pfIsolationR04().sumNeutralHadronEt/pt",float,doc="PF relative isolation dR=0.4, charged component"), + pfRelIso04_pho = Var("pfIsolationR04().sumPhotonEt/pt",float,doc="PF relative isolation dR=0.4, charged component"), pfRelIso04_all = Var("(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt",float,doc="PF relative isolation dR=0.4, total (deltaBeta corrections)"), 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), @@ -219,6 +222,9 @@ standaloneCharge = Var("? standAloneMuon().isNonnull() ? standAloneMuon().charge() : -99", float, doc = "phi of the standalone muon", precision=14), innerTrackAlgo = Var('? innerTrack().isNonnull() ? innerTrack().algo() : -99', 'int', precision=-1, doc='Track algo enum, check DataFormats/TrackReco/interface/TrackBase.h for details.'), innerTrackOriginalAlgo = Var('? innerTrack().isNonnull() ? innerTrack().originalAlgo() : -99', 'int', precision=-1, doc='Track original algo enum'), + X = Var('vx', 'float', precision=-1, doc='Muon X position'), + Y = Var('vy', 'float', precision=-1, doc='Muon Y position'), + Z = Var('vz', 'float', precision=-1, doc='Muon Z position'), ), externalVariables = cms.PSet( mvaTTH = ExtVar(cms.InputTag("muonMVATTH"),float, doc="TTH MVA lepton ID score",precision=14), From 82dcd69e2d9d7cc9d6fc71feeba845562fbc2d07 Mon Sep 17 00:00:00 2001 From: Davide Bruschini Date: Mon, 17 Oct 2022 13:58:32 +0200 Subject: [PATCH 4/5] Changed implementation of X,Y,Z information for muons. Added nValidHits for standard muon collection --- PhysicsTools/NanoAOD/python/muons_cff.py | 4 +--- PhysicsTools/NanoAOD/python/nanoTP_cff.py | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/muons_cff.py b/PhysicsTools/NanoAOD/python/muons_cff.py index 2b8e15693f904..656392db02d22 100644 --- a/PhysicsTools/NanoAOD/python/muons_cff.py +++ b/PhysicsTools/NanoAOD/python/muons_cff.py @@ -220,11 +220,9 @@ standaloneEta = Var("? standAloneMuon().isNonnull() ? standAloneMuon().eta() : -99", float, doc = "eta of the standalone muon", precision=14), standalonePhi = Var("? standAloneMuon().isNonnull() ? standAloneMuon().phi() : -99", float, doc = "phi of the standalone muon", precision=14), standaloneCharge = Var("? standAloneMuon().isNonnull() ? standAloneMuon().charge() : -99", float, doc = "phi of the standalone muon", precision=14), + standaloneNumberOfValidHits = Var('? standAloneMuon().isNonnull() ? standAloneMuon().numberOfValidHits() : -1', 'int', precision=-1, doc='Number of valid hits in track (standalone chambers)'), innerTrackAlgo = Var('? innerTrack().isNonnull() ? innerTrack().algo() : -99', 'int', precision=-1, doc='Track algo enum, check DataFormats/TrackReco/interface/TrackBase.h for details.'), innerTrackOriginalAlgo = Var('? innerTrack().isNonnull() ? innerTrack().originalAlgo() : -99', 'int', precision=-1, doc='Track original algo enum'), - X = Var('vx', 'float', precision=-1, doc='Muon X position'), - Y = Var('vy', 'float', precision=-1, doc='Muon Y position'), - Z = Var('vz', 'float', precision=-1, doc='Muon Z position'), ), externalVariables = cms.PSet( mvaTTH = ExtVar(cms.InputTag("muonMVATTH"),float, doc="TTH MVA lepton ID score",precision=14), diff --git a/PhysicsTools/NanoAOD/python/nanoTP_cff.py b/PhysicsTools/NanoAOD/python/nanoTP_cff.py index 8896d1f9dc829..005301aac3d23 100644 --- a/PhysicsTools/NanoAOD/python/nanoTP_cff.py +++ b/PhysicsTools/NanoAOD/python/nanoTP_cff.py @@ -66,6 +66,9 @@ def customizeNANOTP(process): muonTable.variables = cms.PSet(muonTable.variables, standaloneExtraIdx = Var('? standAloneMuon().isNonnull() ? standAloneMuon().extra().key() : -99', 'int', precision=-1, doc='Index of the innerTrack TrackExtra in the original collection'), innerTrackExtraIdx = Var('? innerTrack().isNonnull() ? innerTrack().extra().key() : -99', 'int', precision=-1, doc='Index of the innerTrack TrackExtra in the original collection'), + X = Var('vx', 'float', precision=-1, doc='Muon X position'), + Y = Var('vy', 'float', precision=-1, doc='Muon Y position'), + Z = Var('vz', 'float', precision=-1, doc='Muon Z position'), ) muonTable.externalVariables = cms.PSet( isStandAloneUpdatedAtVtx = ExtVar(cms.InputTag("mergedStandAloneMuons:muonUpdatedAtVtx"),bool, doc="is standalone muon track updated at vertex"), From ba1f5f4a36f5259cb54fdc5deff9db4d0c170a2c Mon Sep 17 00:00:00 2001 From: Davide Bruschini Date: Fri, 16 Dec 2022 14:39:07 +0100 Subject: [PATCH 5/5] X,Y,Z information naming scheme changed --- PhysicsTools/NanoAOD/python/generalTracks_cff.py | 6 +++--- PhysicsTools/NanoAOD/python/nanoTP_cff.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/generalTracks_cff.py b/PhysicsTools/NanoAOD/python/generalTracks_cff.py index 09d1d986d8149..b3372788de791 100644 --- a/PhysicsTools/NanoAOD/python/generalTracks_cff.py +++ b/PhysicsTools/NanoAOD/python/generalTracks_cff.py @@ -20,9 +20,9 @@ trackOriginalAlgo = Var('originalAlgo()', 'int', precision=-1, doc='Track original algo enum'), qualityMask = Var('qualityMask()', 'int', precision=-1, doc='Quality mask of the track.'), extraIdx = Var('extra().key()', 'int', precision=-1, doc='Index of the TrackExtra in the original collection'), - X = Var('vx', 'float', precision=-1, doc='Track X position'), - Y = Var('vy', 'float', precision=-1, doc='Track Y position'), - Z = Var('vz', 'float', precision=-1, doc='Track Z position'), + vx = Var('vx', 'float', precision=-1, doc='Track X position'), + vy = Var('vy', 'float', precision=-1, doc='Track Y position'), + vz = Var('vz', 'float', precision=-1, doc='Track Z position'), ), ) diff --git a/PhysicsTools/NanoAOD/python/nanoTP_cff.py b/PhysicsTools/NanoAOD/python/nanoTP_cff.py index 89ab09ef7dcee..0f71b757a5eaf 100644 --- a/PhysicsTools/NanoAOD/python/nanoTP_cff.py +++ b/PhysicsTools/NanoAOD/python/nanoTP_cff.py @@ -66,9 +66,9 @@ def customizeNANOTP(process): muonTable.variables = cms.PSet(muonTable.variables, standaloneExtraIdx = Var('? standAloneMuon().isNonnull() ? standAloneMuon().extra().key() : -99', 'int', precision=-1, doc='Index of the innerTrack TrackExtra in the original collection'), innerTrackExtraIdx = Var('? innerTrack().isNonnull() ? innerTrack().extra().key() : -99', 'int', precision=-1, doc='Index of the innerTrack TrackExtra in the original collection'), - X = Var('vx', 'float', precision=-1, doc='Muon X position'), - Y = Var('vy', 'float', precision=-1, doc='Muon Y position'), - Z = Var('vz', 'float', precision=-1, doc='Muon Z position'), + vx = Var('vx', 'float', precision=-1, doc='Muon X position'), + vy = Var('vy', 'float', precision=-1, doc='Muon Y position'), + vz = Var('vz', 'float', precision=-1, doc='Muon Z position'), ) muonTable.externalVariables = cms.PSet( isStandAloneUpdatedAtVtx = ExtVar(cms.InputTag("mergedStandAloneMuons:muonUpdatedAtVtx"),bool, doc="is standalone muon track updated at vertex"),