1 import FWCore.ParameterSet.Config
as cms
4 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi
import simpleCandidateFlatTableProducer
10 from RecoEgamma.EgammaTools.lowPtElectronModifier_cfi
import lowPtElectronModifier
11 modifiedLowPtElectrons = cms.EDProducer(
12 "ModifiedElectronProducer",
13 src = cms.InputTag(
"slimmedLowPtElectrons"),
14 modifierConfig = cms.PSet(
15 modifications = cms.VPSet(lowPtElectronModifier)
20 updatedLowPtElectrons = cms.EDProducer(
22 src = cms.InputTag(
"modifiedLowPtElectrons"),
23 vertices = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
24 computeMiniIso = cms.bool(
True),
25 fixDxySign = cms.bool(
False),
26 pfCandsForMiniIso = cms.InputTag(
"packedPFCandidates"),
27 miniIsoParamsB = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsB,
28 miniIsoParamsE = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsE,
31 isoForLowPtEle = cms.EDProducer(
32 "EleIsoValueMapProducer",
33 src = cms.InputTag(
"updatedLowPtElectrons"),
34 relative = cms.bool(
True),
35 rho_MiniIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
36 rho_PFIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
37 EAFile_MiniIso = cms.FileInPath(
"RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
38 EAFile_PFIso = cms.FileInPath(
"RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
41 updatedLowPtElectronsWithUserData = cms.EDProducer(
42 "PATElectronUserDataEmbedder",
43 src = cms.InputTag(
"updatedLowPtElectrons"),
44 userFloats = cms.PSet(
45 miniIsoChg = cms.InputTag(
"isoForLowPtEle:miniIsoChg"),
46 miniIsoAll = cms.InputTag(
"isoForLowPtEle:miniIsoAll"),
48 userIntFromBools = cms.PSet(),
49 userInts = cms.PSet(),
50 userCands = cms.PSet(),
53 finalLowPtElectrons = cms.EDFilter(
54 "PATElectronRefSelector",
55 src = cms.InputTag(
"updatedLowPtElectronsWithUserData"),
56 cut = cms.string(
"pt > 1. && electronID('ID') > -0.25"),
63 lowPtElectronTable = simpleCandidateFlatTableProducer.clone(
64 src = cms.InputTag(
"linkedObjects",
"lowPtElectrons"),
65 name= cms.string(
"LowPtElectron"),
66 doc = cms.string(
"slimmedLowPtElectrons after basic selection (" + finalLowPtElectrons.cut.value()+
")"),
71 electronIdx =
Var(
"?overlaps('electrons').size()>0?overlaps('electrons')[0].key():-1",
"int16", doc=
"index of the overlapping PF electron (-1 if none)"),
72 photonIdx =
Var(
"?overlaps('photons').size()>0?overlaps('photons')[0].key():-1",
"int16", doc=
"index of the first associated photon (-1 if none)"),
74 ID =
Var(
"electronID('ID')",float,doc=
"ID, BDT (raw) score"),
75 unbiased =
Var(
"electronID('unbiased')",float,doc=
"ElectronSeed, pT- and dxy- agnostic BDT (raw) score"),
76 ptbiased =
Var(
"electronID('ptbiased')",float,doc=
"ElectronSeed, pT- and dxy- dependent BDT (raw) score"),
78 miniPFRelIso_chg =
Var(
"userFloat('miniIsoChg')",float,
79 doc=
"mini PF relative isolation, charged component"),
80 miniPFRelIso_all =
Var(
"userFloat('miniIsoAll')",float,
81 doc=
"mini PF relative isolation, total (with scaled rho*EA PU corrections)"),
83 convVeto =
Var(
"passConversionVeto()",bool,doc=
"pass conversion veto"),
84 convWP =
Var(
"userInt('convOpen')*1 + userInt('convLoose')*2 + userInt('convTight')*4",
85 "uint8", doc=
"conversion flag bit map: 1=Veto, 2=Loose, 3=Tight"),
86 convVtxRadius =
Var(
"userFloat('convVtxRadius')",float,doc=
"conversion vertex radius (cm)",precision=7),
88 lostHits =
Var(
"gsfTrack.hitPattern.numberOfLostHits('MISSING_INNER_HITS')",
"uint8",doc=
"number of missing inner hits"),
90 energyErr =
Var(
"p4Error('P4_COMBINATION')",float,doc=
"energy error of the cluster-track combination",precision=6),
91 deltaEtaSC =
Var(
"superCluster().eta()-eta()",float,doc=
"delta eta (SC,ele) with sign",precision=10),
92 r9 =
Var(
"full5x5_r9()",float,doc=
"R9 of the SC, calculated with full 5x5 region",precision=10),
93 sieie =
Var(
"full5x5_sigmaIetaIeta()",float,doc=
"sigma_IetaIeta of the SC, calculated with full 5x5 region",precision=10),
94 eInvMinusPInv =
Var(
"(1-eSuperClusterOverP())/ecalEnergy()",float,doc=
"1/E_SC - 1/p_trk",precision=10),
95 scEtOverPt =
Var(
"(superCluster().energy()/(pt*cosh(superCluster().eta())))-1",float,doc=
"(SC energy)/pt-1",precision=8),
96 hoe =
Var(
"hadronicOverEm()",float,doc=
"H over E",precision=8),
98 dxy =
Var(
"dB('PV2D')",float,doc=
"dxy (with sign) wrt first PV, in cm",precision=10),
99 dxyErr =
Var(
"edB('PV2D')",float,doc=
"dxy uncertainty, in cm",precision=6),
100 dz =
Var(
"dB('PVDZ')",float,doc=
"dz (with sign) wrt first PV, in cm",precision=10),
101 dzErr =
Var(
"abs(edB('PVDZ'))",float,doc=
"dz uncertainty, in cm",precision=6),
110 matchingLowPtElecPhoton = cms.EDProducer(
111 "GenJetGenPartMerger",
112 srcJet =cms.InputTag(
"particleLevel:leptons"),
113 srcPart=cms.InputTag(
"particleLevel:photons"),
114 cut = cms.string(
""),
115 hasTauAnc=cms.InputTag(
"tautaggerForMatching"),
118 lowPtElectronsMCMatchForTableAlt = cms.EDProducer(
119 "GenJetMatcherDRPtByDR",
120 src = lowPtElectronTable.src,
121 matched = cms.InputTag(
"matchingLowPtElecPhoton:merged"),
122 mcPdgId = cms.vint32(11,22),
123 checkCharge = cms.bool(
False),
124 mcStatus = cms.vint32(),
125 maxDeltaR = cms.double(0.3),
126 maxDPtRel = cms.double(0.5),
127 resolveAmbiguities = cms.bool(
True),
128 resolveByMatchQuality = cms.bool(
True),
131 lowPtElectronsMCMatchForTable = cms.EDProducer(
133 src = lowPtElectronTable.src,
134 matched = cms.InputTag(
"finalGenParticles"),
135 mcPdgId = cms.vint32(11),
136 checkCharge = cms.bool(
False),
137 mcStatus = cms.vint32(1),
138 maxDeltaR = cms.double(0.3),
139 maxDPtRel = cms.double(0.5),
140 resolveAmbiguities = cms.bool(
True),
141 resolveByMatchQuality = cms.bool(
True),
145 lowPtElectronMCTable = cms.EDProducer(
146 "CandMCMatchTableProducer",
147 src = lowPtElectronTable.src,
148 mcMapDressedLep = cms.InputTag(
"lowPtElectronsMCMatchForTableAlt"),
149 mcMap = cms.InputTag(
"lowPtElectronsMCMatchForTable"),
150 mapTauAnc = cms.InputTag(
"matchingLowPtElecPhoton:hasTauAnc"),
151 objName = lowPtElectronTable.name,
152 objType = electronMCTable.objType,
153 branchName = cms.string(
"genPart"),
154 docString = cms.string(
"MC matching to status==1 electrons or photons"),
155 genparticles = cms.InputTag(
"finalGenParticles"),
162 lowPtElectronTask = cms.Task(modifiedLowPtElectrons,
163 updatedLowPtElectrons,
165 updatedLowPtElectronsWithUserData,
168 lowPtElectronTablesTask = cms.Task(lowPtElectronTable)
170 lowPtElectronMCTask = cms.Task(
171 matchingLowPtElecPhoton,
172 lowPtElectronsMCMatchForTable,
173 lowPtElectronsMCMatchForTableAlt,
174 lowPtElectronMCTable)
183 run2_nanoAOD_106Xv2.toModify(
184 modifiedLowPtElectrons.modifierConfig,
185 modifications = cms.VPSet(lowPtElectronModifier,
186 lowPtRegressionModifier)
188 updatedLowPtElectronsWithUserData.userFloats,
189 ID = cms.InputTag(
"lowPtPATElectronID")
192 cut =
"pt > 1. && userFloat('ID') > -0.25" 194 lowPtElectronTable.variables,
195 embeddedID =
Var(
"electronID('ID')",float,doc=
"ID, BDT (raw) score"),
196 ID =
Var(
"userFloat('ID')",float,doc=
"New ID, BDT (raw) score")
199 from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronID_cfi
import lowPtGsfElectronID
200 lowPtPATElectronID = lowPtGsfElectronID.clone(
202 electrons =
"updatedLowPtElectrons",
205 'RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Nov28.root',
209 run2_nanoAOD_106Xv2.toReplaceWith(
211 lowPtElectronTask.copyAndAdd(lowPtPATElectronID)
def Var(expr, valtype, doc=None, precision=-1)