CMS 3D CMS Logo

lowPtElectrons_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
4 
5 ################################################################################
6 # Modules
7 ################################################################################
8 
9 from RecoEgamma.EgammaTools.lowPtElectronModifier_cfi import lowPtElectronModifier
10 from RecoEgamma.EgammaElectronProducers.lowPtGsfElectrons_cff import lowPtRegressionModifier
11 modifiedLowPtElectrons = cms.EDProducer(
12  "ModifiedElectronProducer",
13  src = cms.InputTag("slimmedLowPtElectrons"),
14  modifierConfig = cms.PSet(
15  modifications = cms.VPSet(lowPtElectronModifier,lowPtRegressionModifier)
16  )
17 )
18 
20 updatedLowPtElectrons = cms.EDProducer(
21  "PATElectronUpdater",
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,
29 )
30 
31 from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronID_cff import lowPtGsfElectronID
32 lowPtPATElectronID = lowPtGsfElectronID.clone(
33  usePAT = True,
34  electrons = "updatedLowPtElectrons",
35  unbiased = "",
36  ModelWeights = [
37  'RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Nov28.root',
38  ],
39  Version = cms.string('V1'),
40  rho = "fixedGridRhoFastjetAll",
41 )
42 
43 isoForLowPtEle = cms.EDProducer(
44  "EleIsoValueMapProducer",
45  src = cms.InputTag("updatedLowPtElectrons"),
46  relative = cms.bool(True),
47  rho_MiniIso = cms.InputTag("fixedGridRhoFastjetAll"),
48  rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"),
49  EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
50  EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
51 )
52 
53 updatedLowPtElectronsWithUserData = cms.EDProducer(
54  "PATElectronUserDataEmbedder",
55  src = cms.InputTag("updatedLowPtElectrons"),
56  userFloats = cms.PSet(
57  ID = cms.InputTag("lowPtPATElectronID"),
58  miniIsoChg = cms.InputTag("isoForLowPtEle:miniIsoChg"),
59  miniIsoAll = cms.InputTag("isoForLowPtEle:miniIsoAll"),
60  ),
61  userIntFromBools = cms.PSet(),
62  userInts = cms.PSet(),
63  userCands = cms.PSet(),
64 )
65 
66 finalLowPtElectrons = cms.EDFilter(
67  "PATElectronRefSelector",
68  src = cms.InputTag("updatedLowPtElectronsWithUserData"),
69  cut = cms.string("pt > 1. && userFloat('ID') > -0.25"),
70 )
71 
72 ################################################################################
73 # electronTable
74 ################################################################################
75 
76 lowPtElectronTable = cms.EDProducer(
77  "SimpleCandidateFlatTableProducer",
78  src = cms.InputTag("finalLowPtElectrons"),
79  cut = cms.string(""),
80  name= cms.string("LowPtElectron"),
81  doc = cms.string("slimmedLowPtElectrons after basic selection (" + finalLowPtElectrons.cut.value()+")"),
82  singleton = cms.bool(False), # the number of entries is variable
83  extension = cms.bool(False), # this is the main table for the electrons
84  variables = cms.PSet(
85  # Basic variables
86  CandVars,
87  # BDT scores and WPs
88  embeddedID = Var("electronID('ID')",float,doc="ID, BDT (raw) score"),
89  ID = Var("userFloat('ID')",float,doc="New ID, BDT (raw) score"),
90  unbiased = Var("electronID('unbiased')",float,doc="ElectronSeed, pT- and dxy- agnostic BDT (raw) score"),
91  ptbiased = Var("electronID('ptbiased')",float,doc="ElectronSeed, pT- and dxy- dependent BDT (raw) score"),
92  # Isolation
93  miniPFRelIso_chg = Var("userFloat('miniIsoChg')",float,
94  doc="mini PF relative isolation, charged component"),
95  miniPFRelIso_all = Var("userFloat('miniIsoAll')",float,
96  doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"),
97  # Conversions
98  convVeto = Var("passConversionVeto()",bool,doc="pass conversion veto"),
99  convWP = Var("userInt('convOpen')*1 + userInt('convLoose')*2 + userInt('convTight')*4",
100  int,doc="conversion flag bit map: 1=Veto, 2=Loose, 3=Tight"),
101  convVtxRadius = Var("userFloat('convVtxRadius')",float,doc="conversion vertex radius (cm)",precision=7),
102  # Tracking
103  lostHits = Var("gsfTrack.hitPattern.numberOfLostHits('MISSING_INNER_HITS')","uint8",doc="number of missing inner hits"),
104  # Cluster-related
105  energyErr = Var("p4Error('P4_COMBINATION')",float,doc="energy error of the cluster-track combination",precision=6),
106  deltaEtaSC = Var("superCluster().eta()-eta()",float,doc="delta eta (SC,ele) with sign",precision=10),
107  r9 = Var("full5x5_r9()",float,doc="R9 of the SC, calculated with full 5x5 region",precision=10),
108  sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the SC, calculated with full 5x5 region",precision=10),
109  eInvMinusPInv = Var("(1-eSuperClusterOverP())/ecalEnergy()",float,doc="1/E_SC - 1/p_trk",precision=10),
110  scEtOverPt = Var("(superCluster().energy()/(pt*cosh(superCluster().eta())))-1",float,doc="(SC energy)/pt-1",precision=8),
111  hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8),
112  # Displacement
113  dxy = Var("dB('PV2D')",float,doc="dxy (with sign) wrt first PV, in cm",precision=10),
114  dxyErr = Var("edB('PV2D')",float,doc="dxy uncertainty, in cm",precision=6),
115  dz = Var("dB('PVDZ')",float,doc="dz (with sign) wrt first PV, in cm",precision=10),
116  dzErr = Var("abs(edB('PVDZ'))",float,doc="dz uncertainty, in cm",precision=6),
117  # Cross-referencing
118  #jetIdx
119  #photonIdx
120  ),
121 )
122 
123 ################################################################################
124 # electronTable (MC)
125 ################################################################################
126 
127 # Depends on tautaggerForMatching being run in electrons_cff
128 matchingLowPtElecPhoton = cms.EDProducer(
129  "GenJetGenPartMerger",
130  srcJet =cms.InputTag("particleLevel:leptons"),
131  srcPart=cms.InputTag("particleLevel:photons"),
132  cut = cms.string(""),
133  hasTauAnc=cms.InputTag("tautaggerForMatching"),
134 )
135 
136 lowPtElectronsMCMatchForTableAlt = cms.EDProducer(
137  "GenJetMatcherDRPtByDR", # cut on deltaR, deltaPt/Pt; pick best by deltaR
138  src = lowPtElectronTable.src, # final reco collection
139  matched = cms.InputTag("matchingLowPtElecPhoton:merged"), # final mc-truth particle collection
140  mcPdgId = cms.vint32(11,22), # one or more PDG ID (11 = el, 22 = pho); absolute values (see below)
141  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
142  mcStatus = cms.vint32(),
143  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
144  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
145  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
146  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
147 )
148 
149 lowPtElectronsMCMatchForTable = cms.EDProducer(
150  "MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
151  src = lowPtElectronTable.src, # final reco collection
152  matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
153  mcPdgId = cms.vint32(11), # one or more PDG ID (11 = ele); absolute values (see below)
154  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
155  mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
156  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
157  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
158  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
159  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
160 )
161 
162 from PhysicsTools.NanoAOD.electrons_cff import electronMCTable
163 lowPtElectronMCTable = cms.EDProducer(
164  "CandMCMatchTableProducer",
165  src = lowPtElectronTable.src,
166  mcMapDressedLep = cms.InputTag("lowPtElectronsMCMatchForTableAlt"),
167  mcMap = cms.InputTag("lowPtElectronsMCMatchForTable"),
168  mapTauAnc = cms.InputTag("matchingLowPtElecPhoton:hasTauAnc"),
169  objName = lowPtElectronTable.name,
170  objType = electronMCTable.objType,
171  branchName = cms.string("genPart"),
172  docString = cms.string("MC matching to status==1 electrons or photons"),
173  genparticles = cms.InputTag("finalGenParticles"),
174 )
175 
176 ################################################################################
177 # Sequences
178 ################################################################################
179 
180 lowPtElectronSequence = cms.Sequence(modifiedLowPtElectrons
181  +updatedLowPtElectrons
182  +lowPtPATElectronID
183  +isoForLowPtEle
184  +updatedLowPtElectronsWithUserData
185  +finalLowPtElectrons)
186 lowPtElectronTables = cms.Sequence(lowPtElectronTable)
187 lowPtElectronMC = cms.Sequence(
188  matchingLowPtElecPhoton
189  +lowPtElectronsMCMatchForTable
190  +lowPtElectronsMCMatchForTableAlt
191  +lowPtElectronMCTable)
192 
193 ################################################################################
194 # Modifiers
195 ################################################################################
196 
197 _modifiers = ~(run2_nanoAOD_106Xv2 | run2_nanoAOD_devel)
198 _modifiers.toReplaceWith(lowPtElectronSequence,cms.Sequence())
199 _modifiers.toReplaceWith(lowPtElectronTables,cms.Sequence())
200 _modifiers.toReplaceWith(lowPtElectronMC,cms.Sequence())
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20