1 import FWCore.ParameterSet.Config
as cms
8 slimmedMuonsUpdated = cms.EDProducer(
"PATMuonUpdater",
9 src = cms.InputTag(
"slimmedMuons"),
10 vertices = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
11 computeMiniIso = cms.bool(
False),
12 fixDxySign = cms.bool(
True),
13 pfCandsForMiniIso = cms.InputTag(
"packedPFCandidates"),
14 miniIsoParams = PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi.patMuons.miniIsoParams,
15 recomputeMuonBasicSelectors = cms.bool(
False),
17 run2_miniAOD_80XLegacy.toModify( slimmedMuonsUpdated, computeMiniIso =
True, recomputeMuonBasicSelectors =
True )
19 isoForMu = cms.EDProducer(
"MuonIsoValueMapProducer",
20 src = cms.InputTag(
"slimmedMuonsUpdated"),
21 relative = cms.bool(
False),
22 rho_MiniIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
23 EAFile_MiniIso = cms.FileInPath(
"PhysicsTools/NanoAOD/data/effAreaMuons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
25 run2_miniAOD_80XLegacy.toModify(isoForMu, EAFile_MiniIso =
"PhysicsTools/NanoAOD/data/effAreaMuons_cone03_pfNeuHadronsAndPhotons_80X.txt")
26 run2_nanoAOD_94X2016.toModify(isoForMu, EAFile_MiniIso =
"PhysicsTools/NanoAOD/data/effAreaMuons_cone03_pfNeuHadronsAndPhotons_80X.txt")
28 ptRatioRelForMu = cms.EDProducer(
"MuonJetVarProducer",
29 srcJet = cms.InputTag(
"updatedJets"),
30 srcLep = cms.InputTag(
"slimmedMuonsUpdated"),
31 srcVtx = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
34 slimmedMuonsWithUserData = cms.EDProducer(
"PATMuonUserDataEmbedder",
35 src = cms.InputTag(
"slimmedMuonsUpdated"),
36 userFloats = cms.PSet(
37 miniIsoChg = cms.InputTag(
"isoForMu:miniIsoChg"),
38 miniIsoAll = cms.InputTag(
"isoForMu:miniIsoAll"),
39 ptRatio = cms.InputTag(
"ptRatioRelForMu:ptRatio"),
40 ptRel = cms.InputTag(
"ptRatioRelForMu:ptRel"),
41 jetNDauChargedMVASel = cms.InputTag(
"ptRatioRelForMu:jetNDauChargedMVASel"),
44 jetForLepJetVar = cms.InputTag(
"ptRatioRelForMu:jetForLepJetVar")
48 finalMuons = cms.EDFilter(
"PATMuonRefSelector",
49 src = cms.InputTag(
"slimmedMuonsWithUserData"),
50 cut = cms.string(
"pt > 15 || (pt > 3 && (passed('CutBasedIdLoose') || passed('SoftCutBasedId') || passed('SoftMvaId') || passed('CutBasedIdGlobalHighPt') || passed('CutBasedIdTrkHighPt')))")
53 finalLooseMuons = cms.EDFilter(
"PATMuonRefSelector",
54 src = cms.InputTag(
"slimmedMuonsWithUserData"),
55 cut = cms.string(
"pt > 3 && track.isNonnull && isLooseMuon")
58 muonMVATTH= cms.EDProducer(
"MuonBaseMVAValueMapProducer",
59 src = cms.InputTag(
"linkedObjects",
"muons"),
60 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/mu_BDTG_2017.weights.xml"),
61 name = cms.string(
"muonMVATTH"),
62 isClassifier = cms.bool(
True),
63 variablesOrder = cms.vstring([
"LepGood_pt",
"LepGood_eta",
"LepGood_jetNDauChargedMVASel",
"LepGood_miniRelIsoCharged",
"LepGood_miniRelIsoNeutral",
"LepGood_jetPtRelv2",
"LepGood_jetDF",
"LepGood_jetPtRatio",
"LepGood_dxy",
"LepGood_sip3d",
"LepGood_dz",
"LepGood_segmentComp"]),
65 LepGood_pt = cms.string(
"pt"),
66 LepGood_eta = cms.string(
"eta"),
67 LepGood_jetNDauChargedMVASel = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0"),
68 LepGood_miniRelIsoCharged = cms.string(
"userFloat('miniIsoChg')/pt"),
69 LepGood_miniRelIsoNeutral = cms.string(
"(userFloat('miniIsoAll')-userFloat('miniIsoChg'))/pt"),
70 LepGood_jetPtRelv2 = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0"),
71 LepGood_jetDF = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probbb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:problepb'),0.0):0.0"),
72 LepGood_jetPtRatio = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt)"),
73 LepGood_dxy = cms.string(
"log(abs(dB('PV2D')))"),
74 LepGood_sip3d = cms.string(
"abs(dB('PV3D')/edB('PV3D'))"),
75 LepGood_dz = cms.string(
"log(abs(dB('PVDZ')))"),
76 LepGood_segmentComp = cms.string(
"segmentCompatibility"),
81 muonMVALowPt = muonMVATTH.clone(
82 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/mu_BDTG_lowpt.weights.xml"),
83 name = cms.string(
"muonMVALowPt"),
86 run2_muon_2016.toModify(muonMVATTH,
87 weightFile =
"PhysicsTools/NanoAOD/data/mu_BDTG_2016.weights.xml",
90 from MuonAnalysis.MuonAssociators.muonFSRProducer_cfi
import muonFSRProducer
91 muonFSRphotons = muonFSRProducer.clone(
92 packedPFCandidates = cms.InputTag(
"packedPFCandidates"),
93 slimmedElectrons = cms.InputTag(
"slimmedElectrons"),
94 muons = cms.InputTag(
"linkedObjects",
"muons"),
96 from MuonAnalysis.MuonAssociators.muonFSRAssociator_cfi
import muonFSRAssociator
97 muonFSRassociation = muonFSRAssociator.clone(
98 photons = cms.InputTag(
"muonFSRphotons"),
99 muons = cms.InputTag(
"linkedObjects",
"muons"),
102 fsrTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
103 src = cms.InputTag(
"muonFSRphotons"),
104 cut = cms.string(
""),
105 name = cms.string(
"FsrPhoton"),
106 doc = cms.string(
"Final state radiation photons emitted by muons"),
107 singleton = cms.bool(
False),
108 extension = cms.bool(
False),
109 variables = cms.PSet(P3Vars,
110 relIso03 =
Var(
"userFloat('relIso03')",float,doc=
"relative isolation in a 0.3 cone without CHS"),
111 dROverEt2 =
Var(
"userFloat('dROverEt2')",float,doc=
"deltaR to associated muon divided by photon et2"),
112 muonIdx =
Var(
"?hasUserCand('associatedMuon')?userCand('associatedMuon').key():-1",int, doc=
"index of associated muon")
116 muonTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
117 src = cms.InputTag(
"linkedObjects",
"muons"),
118 cut = cms.string(
""),
119 name = cms.string(
"Muon"),
120 doc = cms.string(
"slimmedMuons after basic selection (" + finalMuons.cut.value()+
")"),
121 singleton = cms.bool(
False),
122 extension = cms.bool(
False),
123 variables = cms.PSet(CandVars,
124 ptErr =
Var(
"bestTrack().ptError()", float, doc =
"ptError of the muon track", precision=6),
125 tunepRelPt =
Var(
"tunePMuonBestTrack().pt/pt",float,doc=
"TuneP relative pt, tunePpt/pt",precision=6),
126 dz =
Var(
"dB('PVDZ')",float,doc=
"dz (with sign) wrt first PV, in cm",precision=10),
127 dzErr =
Var(
"abs(edB('PVDZ'))",float,doc=
"dz uncertainty, in cm",precision=6),
128 dxybs =
Var(
"dB('BS2D')",float,doc=
"dxy (with sign) wrt the beam spot, in cm",precision=10),
129 dxy =
Var(
"dB('PV2D')",float,doc=
"dxy (with sign) wrt first PV, in cm",precision=10),
130 dxyErr =
Var(
"edB('PV2D')",float,doc=
"dxy uncertainty, in cm",precision=6),
131 ip3d =
Var(
"abs(dB('PV3D'))",float,doc=
"3D impact parameter wrt first PV, in cm",precision=10),
132 sip3d =
Var(
"abs(dB('PV3D')/edB('PV3D'))",float,doc=
"3D impact parameter significance wrt first PV",precision=10),
133 segmentComp =
Var(
"segmentCompatibility()", float, doc =
"muon segment compatibility", precision=14),
134 nStations =
Var(
"numberOfMatchedStations", int, doc =
"number of matched stations with default arbitration (segment & track)"),
135 nTrackerLayers =
Var(
"?track.isNonnull?innerTrack().hitPattern().trackerLayersWithMeasurement():0", int, doc =
"number of layers in the tracker"),
136 highPurity =
Var(
"?track.isNonnull?innerTrack().quality('highPurity'):0", bool, doc =
"inner track is high purity"),
137 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
138 tkRelIso =
Var(
"isolationR03().sumPt/tunePMuonBestTrack().pt",float,doc=
"Tracker-based relative isolation dR=0.3 for highPt, trkIso/tunePpt",precision=6),
139 miniPFRelIso_chg =
Var(
"userFloat('miniIsoChg')/pt",float,doc=
"mini PF relative isolation, charged component"),
140 miniPFRelIso_all =
Var(
"userFloat('miniIsoAll')/pt",float,doc=
"mini PF relative isolation, total (with scaled rho*EA PU corrections)"),
141 pfRelIso03_chg =
Var(
"pfIsolationR03().sumChargedHadronPt/pt",float,doc=
"PF relative isolation dR=0.3, charged component"),
142 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)"),
143 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)"),
144 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),
145 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),
146 tightCharge =
Var(
"?(muonBestTrack().ptError()/muonBestTrack().pt() < 0.2)?2:0",int,doc=
"Tight charge criterion using pterr/pt of muonBestTrack (0:fail, 2:pass)"),
147 looseId =
Var(
"passed('CutBasedIdLoose')",bool, doc=
"muon is loose muon"),
148 isPFcand =
Var(
"isPFMuon",bool,doc=
"muon is PF candidate"),
149 isGlobal =
Var(
"isGlobalMuon",bool,doc=
"muon is global muon"),
150 isTracker =
Var(
"isTrackerMuon",bool,doc=
"muon is tracker muon"),
151 isStandalone =
Var(
"isStandAloneMuon",bool,doc=
"muon is a standalone muon"),
152 mediumId =
Var(
"passed('CutBasedIdMedium')",bool,doc=
"cut-based ID, medium WP"),
153 mediumPromptId =
Var(
"passed('CutBasedIdMediumPrompt')",bool,doc=
"cut-based ID, medium prompt WP"),
154 tightId =
Var(
"passed('CutBasedIdTight')",bool,doc=
"cut-based ID, tight WP"),
155 softId =
Var(
"passed('SoftCutBasedId')",bool,doc=
"soft cut-based ID"),
156 softMvaId =
Var(
"passed('SoftMvaId')",bool,doc=
"soft MVA ID"),
157 softMva =
Var(
"softMvaValue()",float,doc=
"soft MVA ID score",precision=6),
158 highPtId =
Var(
"?passed('CutBasedIdGlobalHighPt')?2:passed('CutBasedIdTrkHighPt')",
"uint8",doc=
"high-pT cut-based ID (1 = tracker high pT, 2 = global high pT, which includes tracker high pT)"),
159 pfIsoId =
Var(
"passed('PFIsoVeryLoose')+passed('PFIsoLoose')+passed('PFIsoMedium')+passed('PFIsoTight')+passed('PFIsoVeryTight')+passed('PFIsoVeryVeryTight')",
"uint8",doc=
"PFIso ID from miniAOD selector (1=PFIsoVeryLoose, 2=PFIsoLoose, 3=PFIsoMedium, 4=PFIsoTight, 5=PFIsoVeryTight, 6=PFIsoVeryVeryTight)"),
160 tkIsoId =
Var(
"?passed('TkIsoTight')?2:passed('TkIsoLoose')",
"uint8",doc=
"TkIso ID (1=TkIsoLoose, 2=TkIsoTight)"),
161 mvaId =
Var(
"passed('MvaLoose')+passed('MvaMedium')+passed('MvaTight')+passed('MvaVTight')+passed('MvaVVTight')",
"uint8",doc=
"Mva ID from miniAOD selector (1=MvaLoose, 2=MvaMedium, 3=MvaTight, 4=MvaVTight, 5=MvaVVTight)"),
162 mvaLowPtId =
Var(
"passed('LowPtMvaLoose')+passed('LowPtMvaMedium')",
"uint8", doc=
"Low Pt Mva ID from miniAOD selector (1=LowPtMvaLoose, 2=LowPtMvaMedium)"),
163 miniIsoId =
Var(
"passed('MiniIsoLoose')+passed('MiniIsoMedium')+passed('MiniIsoTight')+passed('MiniIsoVeryTight')",
"uint8",doc=
"MiniIso ID from miniAOD selector (1=MiniIsoLoose, 2=MiniIsoMedium, 3=MiniIsoTight, 4=MiniIsoVeryTight)"),
164 multiIsoId =
Var(
"?passed('MultiIsoMedium')?2:passed('MultiIsoLoose')",
"uint8",doc=
"MultiIsoId from miniAOD selector (1=MultiIsoLoose, 2=MultiIsoMedium)"),
165 puppiIsoId =
Var(
"passed('PuppiIsoLoose')+passed('PuppiIsoMedium')+passed('PuppiIsoTight')",
"uint8", doc=
"PuppiIsoId from miniAOD selector (1=Loose, 2=Medium, 3=Tight)"),
166 triggerIdLoose =
Var(
"passed('TriggerIdLoose')",bool,doc=
"TriggerIdLoose ID"),
167 inTimeMuon =
Var(
"passed('InTimeMuon')",bool,doc=
"inTimeMuon ID"),
168 jetNDauCharged =
Var(
"?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0",
"uint8", doc=
"number of charged daughters of the closest jet"),
170 externalVariables = cms.PSet(
171 mvaTTH =
ExtVar(cms.InputTag(
"muonMVATTH"),float, doc=
"TTH MVA lepton ID score",precision=14),
172 mvaLowPt =
ExtVar(cms.InputTag(
"muonMVALowPt"),float, doc=
"Low pt muon ID score",precision=14),
173 fsrPhotonIdx =
ExtVar(cms.InputTag(
"muonFSRassociation:fsrIndex"),int, doc=
"Index of the associated FSR photon"),
178 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
179 modifier.toModify(muonTable.variables, puppiIsoId =
None, softMva =
None)
181 run2_nanoAOD_102Xv1.toModify(muonTable.variables, puppiIsoId =
None)
184 muonsMCMatchForTable = cms.EDProducer(
"MCMatcher",
186 matched = cms.InputTag(
"finalGenParticles"),
187 mcPdgId = cms.vint32(13),
188 checkCharge = cms.bool(
False),
189 mcStatus = cms.vint32(1),
190 maxDeltaR = cms.double(0.3),
191 maxDPtRel = cms.double(0.5),
192 resolveAmbiguities = cms.bool(
True),
193 resolveByMatchQuality = cms.bool(
True),
196 muonMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
198 mcMap = cms.InputTag(
"muonsMCMatchForTable"),
199 objName = muonTable.name,
200 objType = muonTable.name,
201 branchName = cms.string(
"genPart"),
202 docString = cms.string(
"MC matching to status==1 muons"),
205 muonTask = cms.Task(slimmedMuonsUpdated,isoForMu,ptRatioRelForMu,slimmedMuonsWithUserData,finalMuons,finalLooseMuons )
206 muonMCTask = cms.Task(muonsMCMatchForTable,muonMCTable)
207 muonTablesTask = cms.Task(muonFSRphotons,muonFSRassociation,muonMVATTH,muonMVALowPt,muonTable,fsrTable)