1 import FWCore.ParameterSet.Config
as cms
2 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff
import run2_miniAOD_80XLegacy
3 from Configuration.Eras.Modifier_run2_nanoAOD_92X_cff
import run2_nanoAOD_92X
8 slimmedMuonsUpdated = cms.EDProducer(
"PATMuonUpdater",
9 src = cms.InputTag(
"slimmedMuons"),
10 vertices = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
11 computeMiniIso = cms.bool(
False),
12 pfCandsForMiniIso = cms.InputTag(
"packedPFCandidates"),
13 miniIsoParams = PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi.patMuons.miniIsoParams,
14 recomputeMuonBasicSelectors = cms.bool(
False),
16 run2_nanoAOD_92X.toModify( slimmedMuonsUpdated, recomputeMuonBasicSelectors =
True )
17 run2_miniAOD_80XLegacy.toModify( slimmedMuonsUpdated, computeMiniIso =
True, recomputeMuonBasicSelectors =
True )
19 isoForMu = cms.EDProducer(
"MuonIsoValueMapProducer",
20 src = cms.InputTag(
"slimmedMuons"),
21 relative = cms.bool(
False),
22 rho_MiniIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
23 EAFile_MiniIso = cms.FileInPath(
"PhysicsTools/NanoAOD/data/effAreaMuons_cone03_pfNeuHadronsAndPhotons_80X.txt"),
25 run2_miniAOD_80XLegacy.toModify(isoForMu, src =
"slimmedMuonsUpdated")
26 run2_nanoAOD_92X.toModify(isoForMu, src =
"slimmedMuonsUpdated")
28 ptRatioRelForMu = cms.EDProducer(
"MuonJetVarProducer",
29 srcJet = cms.InputTag(
"slimmedJets"),
30 srcLep = cms.InputTag(
"slimmedMuons"),
31 srcVtx = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
33 run2_miniAOD_80XLegacy.toModify(ptRatioRelForMu, srcLep =
"slimmedMuonsUpdated")
34 run2_nanoAOD_92X.toModify(ptRatioRelForMu, srcLep =
"slimmedMuonsUpdated")
36 slimmedMuonsWithUserData = cms.EDProducer(
"PATMuonUserDataEmbedder",
37 src = cms.InputTag(
"slimmedMuons"),
38 userFloats = cms.PSet(
39 miniIsoChg = cms.InputTag(
"isoForMu:miniIsoChg"),
40 miniIsoAll = cms.InputTag(
"isoForMu:miniIsoAll"),
41 ptRatio = cms.InputTag(
"ptRatioRelForMu:ptRatio"),
42 ptRel = cms.InputTag(
"ptRatioRelForMu:ptRel"),
43 jetNDauChargedMVASel = cms.InputTag(
"ptRatioRelForMu:jetNDauChargedMVASel"),
46 jetForLepJetVar = cms.InputTag(
"ptRatioRelForMu:jetForLepJetVar")
49 run2_miniAOD_80XLegacy.toModify(slimmedMuonsWithUserData, src =
"slimmedMuonsUpdated")
50 run2_nanoAOD_92X.toModify(slimmedMuonsWithUserData, src =
"slimmedMuonsUpdated")
52 finalMuons = cms.EDFilter(
"PATMuonRefSelector",
53 src = cms.InputTag(
"slimmedMuonsWithUserData"),
54 cut = cms.string(
"pt > 3 && track.isNonnull && isLooseMuon")
57 muonMVATTH= cms.EDProducer(
"MuonBaseMVAValueMapProducer",
58 src = cms.InputTag(
"linkedObjects",
"muons"),
59 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/mu_BDTG.weights.xml"),
60 name = cms.string(
"muonMVATTH"),
61 isClassifier = cms.bool(
True),
62 variablesOrder = cms.vstring([
"LepGood_pt",
"LepGood_eta",
"LepGood_jetNDauChargedMVASel",
"LepGood_miniRelIsoCharged",
"LepGood_miniRelIsoNeutral",
"LepGood_jetPtRelv2",
"LepGood_jetPtRatio",
"LepGood_jetBTagCSV",
"LepGood_sip3d",
"LepGood_dxy",
"LepGood_dz",
"LepGood_segmentCompatibility"]),
64 LepGood_pt = cms.string(
"pt"),
65 LepGood_eta = cms.string(
"eta"),
66 LepGood_jetNDauChargedMVASel = cms.string(
"userFloat('jetNDauChargedMVASel')"),
67 LepGood_miniRelIsoCharged = cms.string(
"userFloat('miniIsoChg')/pt"),
68 LepGood_miniRelIsoNeutral = cms.string(
"(userFloat('miniIsoAll')-userFloat('miniIsoChg'))/pt"),
69 LepGood_jetPtRelv2 = cms.string(
"userFloat('ptRel')"),
70 LepGood_jetPtRatio = cms.string(
"min(userFloat('ptRatio'),1.5)"),
71 LepGood_jetBTagCSV = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags'),0.0):-99.0"),
72 LepGood_sip3d = cms.string(
"abs(dB('PV3D')/edB('PV3D'))"),
73 LepGood_dxy = cms.string(
"log(abs(dB('PV2D')))"),
74 LepGood_dz = cms.string(
"log(abs(dB('PVDZ')))"),
75 LepGood_segmentCompatibility = cms.string(
"segmentCompatibility"),
79 muonTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
80 src = cms.InputTag(
"linkedObjects",
"muons"),
82 name = cms.string(
"Muon"),
83 doc = cms.string(
"slimmedMuons after basic selection (" + finalMuons.cut.value()+
")"),
84 singleton = cms.bool(
False),
85 extension = cms.bool(
False),
86 variables = cms.PSet(CandVars,
87 ptErr =
Var(
"bestTrack().ptError()", float, doc =
"ptError of the muon track", precision=6),
88 dz =
Var(
"dB('PVDZ')",float,doc=
"dz (with sign) wrt first PV, in cm",precision=10),
89 dzErr =
Var(
"abs(edB('PVDZ'))",float,doc=
"dz uncertainty, in cm",precision=6),
90 dxy =
Var(
"dB('PV2D')",float,doc=
"dxy (with sign) wrt first PV, in cm",precision=10),
91 dxyErr =
Var(
"edB('PV2D')",float,doc=
"dxy uncertainty, in cm",precision=6),
92 ip3d =
Var(
"abs(dB('PV3D'))",float,doc=
"3D impact parameter wrt first PV, in cm",precision=10),
93 sip3d =
Var(
"abs(dB('PV3D')/edB('PV3D'))",float,doc=
"3D impact parameter significance wrt first PV",precision=10),
94 segmentComp =
Var(
"segmentCompatibility()", float, doc =
"muon segment compatibility", precision=14),
95 nStations =
Var(
"numberOfMatchedStations", int, doc =
"number of matched stations with default arbitration (segment & track)"),
96 nTrackerLayers =
Var(
"innerTrack().hitPattern().trackerLayersWithMeasurement()", int, doc =
"number of layers in the tracker"),
97 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
98 miniPFRelIso_chg =
Var(
"userFloat('miniIsoChg')/pt",float,doc=
"mini PF relative isolation, charged component"),
99 miniPFRelIso_all =
Var(
"userFloat('miniIsoAll')/pt",float,doc=
"mini PF relative isolation, total (with scaled rho*EA PU corrections)"),
100 pfRelIso03_chg =
Var(
"pfIsolationR03().sumChargedHadronPt/pt",float,doc=
"PF relative isolation dR=0.3, charged component"),
101 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)"),
102 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)"),
103 tightCharge =
Var(
"?(muonBestTrack().ptError()/muonBestTrack().pt() < 0.2)?2:0",int,doc=
"Tight charge criterion using pterr/pt of muonBestTrack (0:fail, 2:pass)"),
104 isPFcand =
Var(
"isPFMuon",bool,doc=
"muon is PF candidate"),
105 mediumId =
Var(
"passed('CutBasedIdMedium')",bool,doc=
"cut-based ID, medium WP"),
106 tightId =
Var(
"passed('CutBasedIdTight')",bool,doc=
"cut-based ID, tight WP"),
107 softId =
Var(
"passed('SoftCutBasedId')",bool,doc=
"soft cut-based ID"),
108 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)"),
110 externalVariables = cms.PSet(
111 mvaTTH =
ExtVar(cms.InputTag(
"muonMVATTH"),float, doc=
"TTH MVA lepton ID score",precision=14),
115 muonsMCMatchForTable = cms.EDProducer(
"MCMatcher",
117 matched = cms.InputTag(
"finalGenParticles"),
118 mcPdgId = cms.vint32(13),
119 checkCharge = cms.bool(
False),
120 mcStatus = cms.vint32(1),
121 maxDeltaR = cms.double(0.3),
122 maxDPtRel = cms.double(0.5),
123 resolveAmbiguities = cms.bool(
True),
124 resolveByMatchQuality = cms.bool(
True),
127 muonMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
129 mcMap = cms.InputTag(
"muonsMCMatchForTable"),
130 objName = muonTable.name,
131 objType = muonTable.name,
132 branchName = cms.string(
"genPart"),
133 docString = cms.string(
"MC matching to status==1 muons"),
136 muonSequence = cms.Sequence(isoForMu + ptRatioRelForMu + slimmedMuonsWithUserData + finalMuons)
137 muonMC = cms.Sequence(muonsMCMatchForTable + muonMCTable)
138 muonTables = cms.Sequence(muonMVATTH + muonTable)
140 _withUpdate_sequence = muonSequence.copy()
141 _withUpdate_sequence.replace(isoForMu, slimmedMuonsUpdated+isoForMu)
142 run2_nanoAOD_92X.toReplaceWith(muonSequence, _withUpdate_sequence)
143 run2_miniAOD_80XLegacy.toReplaceWith(muonSequence, _withUpdate_sequence)
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)