CMS 3D CMS Logo

photons_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
4 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer
5 from math import ceil,log
6 
7 
8 photon_id_modules_WorkingPoints_nanoAOD = cms.PSet(
9  modules = cms.vstring(
10  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_RunIIIWinter22_122X_V1_cff',
11  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Winter22_122X_V1_cff',
12  # Fall17: need to include the modules too to make sure they are run
13  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
14  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
15  ),
16  WorkingPoints = cms.vstring(
17  "egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-loose",
18  "egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-medium",
19  "egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-tight",
20  )
21 )
22 
23 photon_id_modules_WorkingPoints_nanoAOD_Run2 = cms.PSet(
24  modules = cms.vstring(
25  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
26  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
27  ),
28  WorkingPoints = cms.vstring(
29  "egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-loose",
30  "egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-medium",
31  "egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-tight",
32  )
33 
34 )
35 
36 # make Fall17 the default one in Run2
37 run2_egamma.toModify(photon_id_modules_WorkingPoints_nanoAOD,
38  modules=photon_id_modules_WorkingPoints_nanoAOD_Run2.modules).\
39  toModify(photon_id_modules_WorkingPoints_nanoAOD,
40  WorkingPoints=photon_id_modules_WorkingPoints_nanoAOD_Run2.WorkingPoints)
41 
42 def make_bitmapVID_docstring(id_modules_working_points_pset):
43  pset = id_modules_working_points_pset
44 
45  for modname in pset.modules:
46  ids = __import__(modname, globals(), locals(), ['idName','cutFlow'])
47  for name in dir(ids):
48  _id = getattr(ids,name)
49  if hasattr(_id,'idName') and hasattr(_id,'cutFlow'):
50  if (len(pset.WorkingPoints)>0 and _id.idName == pset.WorkingPoints[0].split(':')[-1]):
51  cut_names = ','.join([cut.cutName.value() for cut in _id.cutFlow])
52  n_bits_per_cut = int(ceil(log(len(pset.WorkingPoints)+1,2)))
53  return 'VID compressed bitmap (%s), %d bits per cut'%(cut_names, n_bits_per_cut)
54  raise ValueError("Something is wrong in the photon ID modules parameter set!")
55 
56 
57 bitmapVIDForPho = cms.EDProducer("PhoVIDNestedWPBitmapProducer",
58  src = cms.InputTag("slimmedPhotons"),
59  srcForID = cms.InputTag("reducedEgamma","reducedGedPhotons"),
60  WorkingPoints = photon_id_modules_WorkingPoints_nanoAOD.WorkingPoints,
61 )
62 _bitmapVIDForPho_docstring = make_bitmapVID_docstring(photon_id_modules_WorkingPoints_nanoAOD)
63 
64 bitmapVIDForPhoRun2 = bitmapVIDForPho.clone(
65  WorkingPoints = photon_id_modules_WorkingPoints_nanoAOD_Run2.WorkingPoints,
66 )
67 _bitmapVIDForPhoRun2_docstring = make_bitmapVID_docstring(photon_id_modules_WorkingPoints_nanoAOD_Run2)
68 
69 isoForPho = cms.EDProducer("PhoIsoValueMapProducer",
70  src = cms.InputTag("slimmedPhotons"),
71  relative = cms.bool(False),
72  doQuadratic = cms.bool(True),
73  rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"),
74  QuadraticEAFile_PFIso_Chg = cms.FileInPath("RecoEgamma/PhotonIdentification/data/RunIII_Winter22/effectiveArea_ChgHadronIso_95percentBased.txt"),
75  QuadraticEAFile_PFIso_ECal = cms.FileInPath("RecoEgamma/PhotonIdentification/data/RunIII_Winter22/effectiveArea_ECalClusterIso_95percentBased.txt"),
76  QuadraticEAFile_PFIso_HCal = cms.FileInPath("RecoEgamma/PhotonIdentification/data/RunIII_Winter22/effectiveArea_HCalClusterIso_95percentBased.txt"),
77 )
78 
79 hOverEForPho = cms.EDProducer("PhoHoverEValueMapProducer",
80  src = cms.InputTag("slimmedPhotons"),
81  relative = cms.bool(False),
82  rho = cms.InputTag("fixedGridRhoFastjetAll"),
83  QuadraticEAFile_HoverE = cms.FileInPath("RecoEgamma/PhotonIdentification/data/RunIII_Winter22/effectiveArea_coneBasedHoverE_95percentBased.txt"),
84 )
85 
86 isoForPhoFall17V2 = isoForPho.clone(
87  doQuadratic = cms.bool(False),
88  EAFile_PFIso_Chg = cms.FileInPath("RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfChargedHadrons_90percentBased_V2.txt"),
89  EAFile_PFIso_Neu = cms.FileInPath("RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfNeutralHadrons_90percentBased_V2.txt"),
90  EAFile_PFIso_Pho = cms.FileInPath("RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfPhotons_90percentBased_V2.txt"),
91 )
92 
93 
94 seedGainPho = cms.EDProducer("PhotonSeedGainProducer", src = cms.InputTag("slimmedPhotons"))
95 
96 import RecoEgamma.EgammaTools.calibratedEgammas_cff
97 
98 calibratedPatPhotonsNano = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatPhotons.clone(
99  produceCalibratedObjs = False,
100  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_preVFP_RunFineEtaR9Gain"),
101 )
102 
103 (run2_egamma_2016 & tracker_apv_vfp30_2016).toModify(
104  calibratedPatPhotonsNano,
105  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_preVFP_RunFineEtaR9Gain")
106 )
107 
108 (run2_egamma_2016 & ~tracker_apv_vfp30_2016).toModify(
109  calibratedPatPhotonsNano,
110  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_postVFP_RunFineEtaR9Gain"),
111 )
112 
113 run2_egamma_2017.toModify(
114  calibratedPatPhotonsNano,
115  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_24Feb2020_runEtaR9Gain_v2")
116 )
117 
118 run2_egamma_2018.toModify(
119  calibratedPatPhotonsNano,
120  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_29Sep2020_RunFineEtaR9Gain")
121 )
122 
123 slimmedPhotonsWithUserData = cms.EDProducer("PATPhotonUserDataEmbedder",
124  src = cms.InputTag("slimmedPhotons"),
125  parentSrcs = cms.VInputTag("reducedEgamma:reducedGedPhotons"),
126  userFloats = cms.PSet(
127  mvaID = cms.InputTag("photonMVAValueMapProducer:PhotonMVAEstimatorRunIIIWinter22v1Values"),
128  PFIsoChgQuadratic = cms.InputTag("isoForPho:PFIsoChgQuadratic"),
129  PFIsoAllQuadratic = cms.InputTag("isoForPho:PFIsoAllQuadratic"),
130  HoverEQuadratic = cms.InputTag("hOverEForPho:HoEForPhoEACorr"),
131  mvaID_Fall17V2 = cms.InputTag("photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v2Values"),
132  PFIsoChgFall17V2 = cms.InputTag("isoForPhoFall17V2:PFIsoChg"),
133  PFIsoAllFall17V2 = cms.InputTag("isoForPhoFall17V2:PFIsoAll"),
134  ),
135  userIntFromBools = cms.PSet(
136  cutBasedID_loose = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-loose"),
137  cutBasedID_medium = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-medium"),
138  cutBasedID_tight = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-tight"),
139  cutBasedID_Fall17V2_loose = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-loose"),
140  cutBasedID_Fall17V2_medium = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-medium"),
141  cutBasedID_Fall17V2_tight = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-tight"),
142  mvaID_WP90 = cms.InputTag("egmPhotonIDs:mvaPhoID-RunIIIWinter22-v1-wp90"),
143  mvaID_WP80 = cms.InputTag("egmPhotonIDs:mvaPhoID-RunIIIWinter22-v1-wp80"),
144  mvaID_Fall17V2_WP90 = cms.InputTag("egmPhotonIDs:mvaPhoID-RunIIFall17-v2-wp90"),
145  mvaID_Fall17V2_WP80 = cms.InputTag("egmPhotonIDs:mvaPhoID-RunIIFall17-v2-wp80"),
146  ),
147  userInts = cms.PSet(
148  VIDNestedWPBitmap = cms.InputTag("bitmapVIDForPho"),
149  VIDNestedWPBitmapFall17V2 = cms.InputTag("bitmapVIDForPhoRun2"),
150  seedGain = cms.InputTag("seedGainPho"),
151 
152  )
153 )
154 
155 # no need for the Run3 IDs in Run2
156 run2_egamma.toModify(slimmedPhotonsWithUserData.userFloats,
157  mvaID = None,
158  PFIsoChgQuadratic = None,
159  PFIsoAllQuadratic = None,
160  HoverEQuadratic = None).\
161  toModify(slimmedPhotonsWithUserData.userIntFromBools,
162  cutBasedID_loose = None,
163  cutBasedID_medium = None,
164  cutBasedID_tight = None,
165  mvaID_WP90 = None,
166  mvaID_WP80 = None).\
167  toModify(slimmedPhotonsWithUserData.userInts,
168  VIDNestedWPBitmap = None)
169 
170 run2_egamma.toModify(
171  slimmedPhotonsWithUserData.userFloats,
172  ecalEnergyErrPostCorrNew = cms.InputTag("calibratedPatPhotonsNano","ecalEnergyErrPostCorr"),
173  ecalEnergyPreCorrNew = cms.InputTag("calibratedPatPhotonsNano","ecalEnergyPreCorr"),
174  ecalEnergyPostCorrNew = cms.InputTag("calibratedPatPhotonsNano","ecalEnergyPostCorr"),
175  energyScaleUpNew = cms.InputTag("calibratedPatPhotonsNano","energyScaleUp"),
176  energyScaleDownNew = cms.InputTag("calibratedPatPhotonsNano","energyScaleDown"),
177  energySigmaUpNew = cms.InputTag("calibratedPatPhotonsNano","energySigmaUp"),
178  energySigmaDownNew = cms.InputTag("calibratedPatPhotonsNano","energySigmaDown"),
179 )
180 
181 
182 finalPhotons = cms.EDFilter("PATPhotonRefSelector",
183  src = cms.InputTag("slimmedPhotonsWithUserData"),
184  cut = cms.string("pt > 5 ")
185 )
186 
187 photonTable = simpleCandidateFlatTableProducer.clone(
188  src = cms.InputTag("linkedObjects","photons"),
189  name= cms.string("Photon"),
190  doc = cms.string("slimmedPhotons after basic selection (" + finalPhotons.cut.value()+")"),
191  variables = cms.PSet(P3Vars,
192  jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", "int16", doc="index of the associated jet (-1 if none)"),
193  electronIdx = Var("?hasUserCand('electron')?userCand('electron').key():-1", "int16", doc="index of the associated electron (-1 if none)"),
194  energyErr = Var("getCorrectedEnergyError('regression2')",float,doc="energy error of the cluster from regression",precision=10),
195  energyRaw = Var("superCluster().rawEnergy()",float,doc="raw energy of photon supercluster", precision=10),
196  superclusterEta = Var("superCluster().eta()",float,doc="supercluster eta",precision=10),
197  r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=10),
198  sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
199  sipip = Var("showerShapeVariables().sigmaIphiIphi", float, doc="sigmaIphiIphi of the supercluster", precision=10),
200  sieip = Var("full5x5_showerShapeVariables().sigmaIetaIphi",float,doc="sigma_IetaIphi of the supercluster, calculated with full 5x5 region",precision=10),
201  s4 = Var("full5x5_showerShapeVariables().e2x2/full5x5_showerShapeVariables().e5x5",float,doc="e2x2/e5x5 of the supercluster, calculated with full 5x5 region",precision=10),
202  etaWidth = Var("superCluster().etaWidth()",float,doc="Width of the photon supercluster in eta", precision=10),
203  phiWidth = Var("superCluster().phiWidth()",float,doc="Width of the photon supercluster in phi", precision=10),
204  cutBased = Var(
205  "userInt('cutBasedID_loose')+userInt('cutBasedID_medium')+userInt('cutBasedID_tight')",
206  "uint8",
207  doc="cut-based ID bitmap, RunIIIWinter22V1, (0:fail, 1:loose, 2:medium, 3:tight)",
208  ),
209  vidNestedWPBitmap = Var(
210  "userInt('VIDNestedWPBitmap')",
211  int,
212  doc="RunIIIWinter22V1 " + _bitmapVIDForPho_docstring
213  ),
214  electronVeto = Var("passElectronVeto()",bool,doc="pass electron veto"),
215  pixelSeed = Var("hasPixelSeed()",bool,doc="has pixel seed"),
216  hasConversionTracks = Var("hasConversionTracks()",bool,doc="Variable specifying if photon has associated conversion tracks (one-legged or two-legged)"),
217  mvaID = Var("userFloat('mvaID')",float,doc="MVA ID score, Winter22V1",precision=10),
218  mvaID_WP90 = Var("userInt('mvaID_WP90')",bool,doc="MVA ID WP90, Winter22V1"),
219  mvaID_WP80 = Var("userInt('mvaID_WP80')",bool,doc="MVA ID WP80, Winter22V1"),
220  trkSumPtHollowConeDR03 = Var("trkSumPtHollowConeDR03()",float,doc="Sum of track pT in a hollow cone of outer radius, inner radius", precision=10),
221  trkSumPtSolidConeDR04 = Var("trkSumPtSolidConeDR04()",float,doc="Sum of track pT in a cone of dR=0.4", precision=10),
222  ecalPFClusterIso = Var("ecalPFClusterIso()",float,doc="sum pt of ecal clusters, vetoing clusters part of photon", precision=10),
223  hcalPFClusterIso = Var("hcalPFClusterIso()",float,doc="sum pt of hcal clusters, vetoing clusters part of photon", precision=10),
224  pfPhoIso03 = Var("photonIso()",float,doc="PF absolute isolation dR=0.3, photon component (uncorrected)"),
225  pfChargedIso = Var("chargedHadronIso()",float,doc="PF absolute isolation dR=0.3, charged component with dxy,dz match to PV", precision=8),
226  pfChargedIsoPFPV = Var("chargedHadronPFPVIso()",float,doc="PF absolute isolation dR=0.3, charged component (PF PV only)"),
227  pfChargedIsoWorstVtx = Var("chargedHadronWorstVtxIso()",float,doc="PF absolute isolation dR=0.3, charged component (Vertex with largest isolation)"),
228  pfRelIso03_chg_quadratic = Var("userFloat('PFIsoChgQuadratic')/pt",float,doc="PF relative isolation dR=0.3, charged hadron component (with quadraticEA*rho*rho + linearEA*rho Winter22V1 corrections)"),
229  pfRelIso03_all_quadratic = Var("userFloat('PFIsoAllQuadratic')/pt",float,doc="PF relative isolation dR=0.3, total (with quadraticEA*rho*rho + linearEA*rho Winter22V1 corrections)"),
230  hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8),
231  hoe_PUcorr = Var("userFloat('HoverEQuadratic')",float,doc="PU corrected H/E (cone-based with quadraticEA*rho*rho + linearEA*rho Winter22V1 corrections)",precision=8),
232  isScEtaEB = Var("abs(superCluster().eta()) < 1.4442",bool,doc="is supercluster eta within barrel acceptance"),
233  isScEtaEE = Var("abs(superCluster().eta()) > 1.566 && abs(superCluster().eta()) < 2.5",bool,doc="is supercluster eta within endcap acceptance"),
234  seedGain = Var("userInt('seedGain')","uint8",doc="Gain of the seed crystal"),
235  seediEtaOriX = Var("superCluster().seedCrysIEtaOrIx","int16",doc="iEta or iX of seed crystal. iEta is barrel-only, iX is endcap-only. iEta runs from -85 to +85, with no crystal at iEta=0. iX runs from 1 to 100."),
236  seediPhiOriY = Var("superCluster().seedCrysIPhiOrIy","int16",doc="iPhi or iY of seed crystal. iPhi is barrel-only, iY is endcap-only. iPhi runs from 1 to 360. iY runs from 1 to 100."),
237  # position of photon is best approximated by position of seed cluster, not the SC centroid
238  x_calo = Var("superCluster().seed().position().x()",float,doc="photon supercluster position on calorimeter, x coordinate (cm)",precision=10),
239  y_calo = Var("superCluster().seed().position().y()",float,doc="photon supercluster position on calorimeter, y coordinate (cm)",precision=10),
240  z_calo = Var("superCluster().seed().position().z()",float,doc="photon supercluster position on calorimeter, z coordinate (cm)",precision=10),
241  # ES variables
242  esEffSigmaRR = Var("full5x5_showerShapeVariables().effSigmaRR()", float, doc="preshower sigmaRR"),
243  esEnergyOverRawE = Var("superCluster().preshowerEnergy()/superCluster().rawEnergy()", float, doc="ratio of preshower energy to raw supercluster energy"),
244  haloTaggerMVAVal = Var("haloTaggerMVAVal()",float,doc="Value of MVA based BDT based beam halo tagger in the Ecal endcap (valid for pT > 200 GeV)",precision=8),
245  )
246 )
247 
248 _phoVarsExtra = cms.PSet(
249  r9Frac = Var("r9()",float,doc="Fractional R9 of the supercluster",precision=10),
250  energy = Var("energy",float,doc="energy after regression",precision=10),
251  rawPreshowerEnergy = Var("superCluster.preshowerEnergy",float,doc="energy deposited in preshower",precision=10),
252  seedClusEnergy = Var("superCluster.seed.energy",float,doc="seed cluster energy",precision=10),
253  e5x5 = Var("full5x5_showerShapeVariables.e5x5",float,doc="energy in 5x5",precision=10),
254  dEtaSeedClusSuperClus = Var("superCluster.seed.eta-superCluster.position.Eta",float,doc="dEta(seed,SC)",precision=10),
255  dPhiSeedClusSuperClus = Var("deltaPhi(superCluster.seed.phi,superCluster.position.Phi)",float,doc="dPhi(seed,SC)",precision=10),
256  sigmaIphiIphiFull5x5 = Var("full5x5_showerShapeVariables().sigmaIphiIphi",float,doc="Full5x5 sigmaIPhiIPhi",precision=10),
257  eMax = Var("full5x5_maxEnergyXtal()",float,doc="Emax",precision=10),
258  e2nd = Var("full5x5_showerShapeVariables.e2nd",float,doc="E2nd",precision=10),
259  eTop = Var("full5x5_showerShapeVariables.eTop",float,doc="Etop",precision=10),
260  eBottom = Var("full5x5_showerShapeVariables.eBottom",float,doc="Ebottom",precision=10),
261  eLeft = Var("full5x5_showerShapeVariables.eLeft",float,doc="Eleft",precision=10),
262  eRight = Var("full5x5_showerShapeVariables.eRight",float,doc="Eright",precision=10),
263  e2x5max = Var("full5x5_showerShapeVariables.e2x5Max",float,doc="energy in 2x5",precision=10),
264  e2x5Top = Var("full5x5_showerShapeVariables.e2x5Top",float,doc="E2x5Top",precision=10),
265  e2x5Bottom = Var("full5x5_showerShapeVariables.e2x5Bottom",float,doc="E2x5Bottom",precision=10),
266  e2x5Left = Var("full5x5_showerShapeVariables.e2x5Left",float,doc="E2x5Left",precision=10),
267  e2x5Right = Var("full5x5_showerShapeVariables.e2x5Right",float,doc="E2x5Right",precision=10),
268  nSaturatedXtals = Var("nSaturatedXtals",int,doc="number of saturated crystals"),
269  numberOfClusters = Var("superCluster.clusters.size",int,doc="number of clusters"),
270  hadTowOverEm = Var("hadTowOverEm",float,doc="single tower based H/E",precision=10),
271  ecalRecHitIsolation = Var("ecalRecHitSumEtConeDR03",float,doc="ECAL RecHit isolation",precision=10),
272  sigmaIetaIetaFrac = Var("sigmaIetaIeta",float,doc="fractional sigmaIetaIeta",precision=10),
273  chargedHadronIso = Var("chargedHadronIso",float,doc="charged hadron Isolation",precision=10),
274  iEtaMod5 = Var("?superCluster.seedCrysIEtaOrIx>0?(superCluster.seedCrysIEtaOrIx-1)%5:(superCluster.seedCrysIEtaOrIx+1)%5",int,doc="iEtaMod5"),
275  iEtaMod20 = Var("?abs(superCluster.seedCrysIEtaOrIx)<=25?(superCluster.seedCrysIEtaOrIx-(?superCluster.seedCrysIEtaOrIx>0?+1:-1))%20:(superCluster.seedCrysIEtaOrIx-(?superCluster.seedCrysIEtaOrIx>0?+26:-26))%20",int,doc="iEtaMod20"),
276  iPhiMod2 = Var("(superCluster.seedCrysIPhiOrIy-1)%2",int,doc="iPhiMod2"),
277  iPhiMod20 = Var("(superCluster.seedCrysIPhiOrIy-1)%20",int,doc="iPhiMod20"),
278 )
279 
280 #these eras need to make the energy correction, hence the "New". Also save only Fall17V2 IDS in Run2, No Run3 Winter22V1 and quadratic iso in Run2
281 run2_egamma.toModify(
282  photonTable.variables,
283  pt = Var("pt*userFloat('ecalEnergyPostCorrNew')/userFloat('ecalEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
284  energyErr = Var("userFloat('ecalEnergyErrPostCorrNew')",float,doc="energy error of the cluster from regression",precision=6),
285  eCorr = Var("userFloat('ecalEnergyPostCorrNew')/userFloat('ecalEnergyPreCorrNew')",float,doc="ratio of the calibrated energy/miniaod energy"),
286  hoe = Var("hadTowOverEm()",float,doc="H over E (Run2)",precision=8),
287  cutBased = Var(
288  "userInt('cutBasedID_Fall17V2_loose')+userInt('cutBasedID_Fall17V2_medium')+userInt('cutBasedID_Fall17V2_tight')",
289  "uint8",
290  doc="cut-based ID bitmap, Fall17V2, (0:fail, 1:loose, 2:medium, 3:tight)",
291  ),
292  vidNestedWPBitmap = Var(
293  "userInt('VIDNestedWPBitmapFall17V2')",
294  int,
295  doc="Fall17V2 " + _bitmapVIDForPhoRun2_docstring
296  ),
297  mvaID = Var("userFloat('mvaID_Fall17V2')",float,doc="MVA ID score, Fall17V2",precision=10),
298  mvaID_WP90 = Var("userInt('mvaID_Fall17V2_WP90')",bool,doc="MVA ID WP90, Fall17V2"),
299  mvaID_WP80 = Var("userInt('mvaID_Fall17V2_WP80')",bool,doc="MVA ID WP80, Fall17V2"),
300  pfRelIso03_chg = Var("userFloat('PFIsoChgFall17V2')/pt",float,doc="PF relative isolation dR=0.3, charged component (with Fall17V2rho*EA PU corrections)"),
301  pfRelIso03_all = Var("userFloat('PFIsoAllFall17V2')/pt",float,doc="PF relative isolation dR=0.3, total (with Fall17V2 rho*EA PU corrections)"),
302  pfRelIso03_chg_quadratic=None,
303  pfRelIso03_all_quadratic=None,
304  hoe_PUcorr=None
305 )
306 
307 photonsMCMatchForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
308  src = photonTable.src, # final reco collection
309  matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
310  mcPdgId = cms.vint32(11,22), # one or more PDG ID (11 = el, 22 = pho); absolute values (see below)
311  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
312  mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
313  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
314  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
315  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
316  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
317 )
318 
319 photonMCTable = cms.EDProducer("CandMCMatchTableProducer",
320  src = photonTable.src,
321  mcMap = cms.InputTag("photonsMCMatchForTable"),
322  objName = photonTable.name,
323  objType = photonTable.name, #cms.string("Photon"),
324  branchName = cms.string("genPart"),
325  docString = cms.string("MC matching to status==1 photons or electrons"),
326 )
327 
328 #adding 4 most imp scale & smearing variables to table
329 run2_egamma.toModify(
330  photonTable.variables,
331  dEscaleUp=Var("userFloat('ecalEnergyPostCorrNew') - userFloat('energyScaleUpNew')", float, doc="ecal energy scale shifted 1 sigma up (adding gain/stat/syst in quadrature)", precision=8),
332  dEscaleDown=Var("userFloat('ecalEnergyPostCorrNew') - userFloat('energyScaleDownNew')", float, doc="ecal energy scale shifted 1 sigma down (adding gain/stat/syst in quadrature)", precision=8),
333  dEsigmaUp=Var("userFloat('ecalEnergyPostCorrNew') - userFloat('energySigmaUpNew')", float, doc="ecal energy smearing value shifted 1 sigma up", precision=8),
334  dEsigmaDown=Var("userFloat('ecalEnergyPostCorrNew') - userFloat('energySigmaDownNew')", float, doc="ecal energy smearing value shifted 1 sigma up", precision=8),
335 )
336 
337 
338 photonTask = cms.Task(bitmapVIDForPho, bitmapVIDForPhoRun2, isoForPho, hOverEForPho, isoForPhoFall17V2, seedGainPho, slimmedPhotonsWithUserData, finalPhotons)
339 
340 photonTablesTask = cms.Task(photonTable)
341 photonMCTask = cms.Task(photonsMCMatchForTable, photonMCTable)
342 
343 _photonTask_Run2 = photonTask.copy()
344 _photonTask_Run2.remove(bitmapVIDForPho)
345 _photonTask_Run2.remove(isoForPho)
346 _photonTask_Run2.remove(hOverEForPho)
347 _photonTask_Run2.add(calibratedPatPhotonsNano)
348 run2_egamma.toReplaceWith(photonTask, _photonTask_Run2)
constexpr int32_t ceil(float num)
def Var(expr, valtype, doc=None, precision=-1)
Definition: common_cff.py:16
def make_bitmapVID_docstring(id_modules_working_points_pset)
Definition: photons_cff.py:42
static std::string join(char **cmd)
Definition: RemoteFile.cc:19