CMS 3D CMS Logo

egammaObjectModificationsInMiniAOD_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 #electron mva ids
4 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff as ele_spring16_gp_v1
5 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff as ele_spring16_hzz_v1
6 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff as ele_fall17_iso_v1
7 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff as ele_fall17_noIso_v1
8 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff as ele_fall17_iso_v2
9 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff as ele_fall17_noIso_v2
10 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer18UL_ID_ISO_cff as ele_summer18UL_hzz
11 
12 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_iso_V1_cff as ele_RunIIIWinter22_iso_v1
13 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_noIso_V1_cff as ele_RunIIIWinter22_noIso_v1
14 import RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Winter22_HZZ_V1_cff as ele_Winter22_HZZ_V1
15 
16 #photon mva ids
17 import RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff as pho_spring16_nt_v1
21 
22 
23 ele_mva_prod_name = 'electronMVAValueMapProducer'
24 pho_mva_prod_name = 'photonMVAValueMapProducer'
25 
26 def setup_mva(val_pset,cat_pset,prod_name,mva_name):
27  value_name = '%s:%sValues'%(prod_name,mva_name)
28  cat_name = '%s:%sCategories'%(prod_name,mva_name)
29  setattr( val_pset, '%sValues'%mva_name, cms.InputTag(value_name) )
30  setattr( cat_pset, '%sCategories'%mva_name, cms.InputTag(cat_name) )
31 
32 egamma_modifications = cms.VPSet(
33  cms.PSet( modifierName = cms.string('EGExtraInfoModifierFromFloatValueMaps'),
34  electron_config = cms.PSet( ),
35  photon_config = cms.PSet( )
36  ),
37  cms.PSet( modifierName = cms.string('EGExtraInfoModifierFromIntValueMaps'),
38  electron_config = cms.PSet( ),
39  photon_config = cms.PSet( )
40  )
41 )
42 
43 #setup the mva value maps to embed
44 for ele_mva_cff in [
45  ele_spring16_gp_v1,
46  ele_spring16_hzz_v1,
47  ele_fall17_iso_v1,
48  ele_fall17_noIso_v1,
49  ele_fall17_iso_v2,
50  ele_fall17_noIso_v2,
51  ele_summer18UL_hzz,
52  ele_RunIIIWinter22_iso_v1,
53  ele_RunIIIWinter22_noIso_v1,
54  ele_Winter22_HZZ_V1
55  ]:
56 
57  setup_mva(egamma_modifications[0].electron_config,
58  egamma_modifications[1].electron_config,
59  ele_mva_prod_name,
60  ele_mva_cff.mvaClassName + ele_mva_cff.mvaTag)
61 
62 for pho_mva_cff in [
63  pho_spring16_nt_v1,
64  pho_fall17_94X_v1p1,
65  pho_fall17_94X_v2,
66  pho_winter22_122X_v1
67  ]:
68 
69  setup_mva(egamma_modifications[0].photon_config,
70  egamma_modifications[1].photon_config,
71  pho_mva_prod_name,
72  pho_mva_cff.mvaClassName + pho_mva_cff.mvaTag)
73 
74 
77 
78 #from RecoEgamma.EgammaTools.regressionModifier_cfi import *
79 
80 #egamma_modifications.append( regressionModifier )
81 
82 
85 reducedEgammaEnergyScaleAndSmearingModifier = cms.PSet(
86  modifierName = cms.string('EGExtraInfoModifierFromFloatValueMaps'),
87  electron_config = cms.PSet(),
88  photon_config = cms.PSet()
89 )
90 from RecoEgamma.EgammaTools.calibratedEgammas_cff import prefixName
91 import RecoEgamma.EgammaTools.calibratedElectronProducer_cfi
92 for valueMapName in RecoEgamma.EgammaTools.calibratedElectronProducer_cfi.calibratedElectronProducer.valueMapsStored:
93  setattr(reducedEgammaEnergyScaleAndSmearingModifier.electron_config,valueMapName,cms.InputTag("reducedEgamma",prefixName("calibEle",valueMapName)))
94 
95 import RecoEgamma.EgammaTools.calibratedPhotonProducer_cfi
96 for valueMapName in RecoEgamma.EgammaTools.calibratedPhotonProducer_cfi.calibratedPhotonProducer.valueMapsStored:
97  setattr(reducedEgammaEnergyScaleAndSmearingModifier.photon_config,valueMapName,cms.InputTag("reducedEgamma",prefixName("calibPho",valueMapName)))
98 
99 
102 egamma8XObjectUpdateModifier = cms.PSet(
103  modifierName = cms.string('EG8XObjectUpdateModifier'),
104  ecalRecHitsEB = cms.InputTag("reducedEgamma","reducedEBRecHits"),
105  ecalRecHitsEE = cms.InputTag("reducedEgamma","reducedEERecHits"),
106 )
107 
108 
111 egamma9X105XUpdateModifier = cms.PSet(
112  modifierName = cms.string('EG9X105XObjectUpdateModifier'),
113  eleCollVMsAreKeyedTo = cms.InputTag("slimmedElectrons",processName=cms.InputTag.skipCurrentProcess()),
114  phoCollVMsAreKeyedTo = cms.InputTag("slimmedPhotons",processName=cms.InputTag.skipCurrentProcess()),
115  conversions = cms.InputTag("reducedEgamma","reducedConversions"),
116  beamspot = cms.InputTag("offlineBeamSpot"),
117  ecalRecHitsEB = cms.InputTag("reducedEgamma","reducedEBRecHits"),
118  ecalRecHitsEE = cms.InputTag("reducedEgamma","reducedEERecHits"),
119  eleTrkIso = cms.InputTag("heepIDVarValueMaps","eleTrkPtIso"),
120  eleTrkIso04 = cms.InputTag("heepIDVarValueMaps","eleTrkPtIso04"),
121  phoPhotonIso = cms.InputTag("photonIDValueMapProducer","phoPhotonIsolation"),
122  phoNeutralHadIso = cms.InputTag("photonIDValueMapProducer","phoNeutralHadronIsolation"),
123  phoChargedHadIso = cms.InputTag("photonIDValueMapProducer","phoChargedIsolation"),
124  phoChargedHadWorstVtxIso = cms.InputTag("photonIDValueMapProducer","phoWorstChargedIsolation"),
125  phoChargedHadWorstVtxConeVetoIso = cms.InputTag("photonIDValueMapProducer","phoWorstChargedIsolationConeVeto"),
126  phoChargedHadPFPVIso = cms.InputTag("egmPhotonIsolation","h+-DR030-"),
127  allowGsfTrackForConvs = cms.bool(False),
128  updateChargedHadPFPVIso = cms.bool(True)
129 )
130 
131 
136 from RecoEgamma.EgammaTools.calibratedEgammas_cff import ecalTrkCombinationRegression
137 egamma8XLegacyEtScaleSysModifier = cms.PSet(
138  modifierName = cms.string('EGEtScaleSysModifier'),
139  epCombConfig = ecalTrkCombinationRegression,
140  uncertFunc = cms.PSet(
141  name = cms.string("UncertFuncV1"),
142  lowEt = cms.double(43.5),
143  highEt = cms.double(46.5),
144  lowEtUncert = cms.double(0.002),
145  highEtUncert = cms.double(-0.002)
146  )
147  )
148 
149 # modifier for photon isolation used in heavy ions
150 egammaHIPhotonIsolationModifier = cms.PSet(
151  modifierName = cms.string('EGExtraInfoModifierFromHIPhotonIsolationValueMaps'),
152  electron_config = cms.PSet(),
153  photon_config = cms.PSet(
154  photonIsolationHI = cms.InputTag("reducedEgamma:photonIsolationHIProducerppGED")
155  )
156  )
157 
158 photonDRNModifier = cms.PSet(
159  modifierName = cms.string("EGRegressionModifierDRN"),
160  patPhotons = cms.PSet(
161  source = cms.InputTag("selectedPatPhotons"),
162  correctionsSource = cms.InputTag('patPhotonsDRN'),
163  energyFloat = cms.string("energyDRN"),
164  resFloat = cms.string("resolutionDRN")
165  )
166  )
167 
169  modifiers.append(reducedEgammaEnergyScaleAndSmearingModifier)
170 
172  modifiers.insert(0,egamma8XObjectUpdateModifier)
173 
175  modifiers.append(reducedEgammaEnergyScaleAndSmearingModifier)
176  modifiers.append(egamma8XLegacyEtScaleSysModifier)
177 
179  modifiers.append(egammaHIPhotonIsolationModifier)
180 
181 def appendPhotonDRNModifier(modifiers):
182  modifiers.append(photonDRNModifier)
183 
184 from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
185 from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
186 (run2_miniAOD_94XFall17 | run2_miniAOD_UL).toModify(egamma_modifications,appendReducedEgammaEnergyScaleAndSmearingModifier)
187 
188 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
189 #80X doesnt have the bug which prevents GsfTracks used to match conversions so set true
190 run2_miniAOD_80XLegacy.toModify(egamma9X105XUpdateModifier,allowGsfTrackForConvs = True)
191 run2_miniAOD_80XLegacy.toModify(egamma_modifications,appendEgamma8XLegacyAppendableModifiers)
192 run2_miniAOD_80XLegacy.toModify(egamma_modifications,prependEgamma8XObjectUpdateModifier)
193 
194 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
195 pp_on_AA.toModify(egamma_modifications, appendEgammaHIPhotonIsolationModifier)
196 
197 from Configuration.ProcessModifiers.photonDRN_cff import _photonDRN
198 _photonDRN.toModify(egamma_modifications, appendPhotonDRNModifier)
def prefixName(prefix, name)
def setup_mva(val_pset, cat_pset, prod_name, mva_name)