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.simplePATPhotonFlatTableProducer_cfi import simplePATPhotonFlatTableProducer
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 )
101 
102 (run2_egamma_2016 & tracker_apv_vfp30_2016).toModify(
103  calibratedPatPhotonsNano,
104  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_preVFP_RunFineEtaR9Gain_v3")
105 )
106 
107 (run2_egamma_2016 & ~tracker_apv_vfp30_2016).toModify(
108  calibratedPatPhotonsNano,
109  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_postVFP_RunFineEtaR9Gain_v1"),
110 )
111 
112 run2_egamma_2017.toModify(
113  calibratedPatPhotonsNano,
114  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_24Feb2020_runEtaR9Gain_v2")
115 )
116 
117 run2_egamma_2018.toModify(
118  calibratedPatPhotonsNano,
119  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_29Sep2020_RunFineEtaR9Gain")
120 )
121 
122 slimmedPhotonsWithUserData = cms.EDProducer("PATPhotonUserDataEmbedder",
123  src = cms.InputTag("slimmedPhotons"),
124  parentSrcs = cms.VInputTag("reducedEgamma:reducedGedPhotons"),
125  userFloats = cms.PSet(
126  mvaID = cms.InputTag("photonMVAValueMapProducer:PhotonMVAEstimatorRunIIIWinter22v1Values"),
127  PFIsoChgQuadratic = cms.InputTag("isoForPho:PFIsoChgQuadratic"),
128  PFIsoAllQuadratic = cms.InputTag("isoForPho:PFIsoAllQuadratic"),
129  HoverEQuadratic = cms.InputTag("hOverEForPho:HoEForPhoEACorr"),
130  mvaID_Fall17V2 = cms.InputTag("photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v2Values"),
131  PFIsoChgFall17V2 = cms.InputTag("isoForPhoFall17V2:PFIsoChg"),
132  PFIsoAllFall17V2 = cms.InputTag("isoForPhoFall17V2:PFIsoAll"),
133  ),
134  userIntFromBools = cms.PSet(
135  cutBasedID_loose = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-loose"),
136  cutBasedID_medium = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-medium"),
137  cutBasedID_tight = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-RunIIIWinter22-122X-V1-tight"),
138  cutBasedID_Fall17V2_loose = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-loose"),
139  cutBasedID_Fall17V2_medium = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-medium"),
140  cutBasedID_Fall17V2_tight = cms.InputTag("egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-tight"),
141  mvaID_WP90 = cms.InputTag("egmPhotonIDs:mvaPhoID-RunIIIWinter22-v1-wp90"),
142  mvaID_WP80 = cms.InputTag("egmPhotonIDs:mvaPhoID-RunIIIWinter22-v1-wp80"),
143  mvaID_Fall17V2_WP90 = cms.InputTag("egmPhotonIDs:mvaPhoID-RunIIFall17-v2-wp90"),
144  mvaID_Fall17V2_WP80 = cms.InputTag("egmPhotonIDs:mvaPhoID-RunIIFall17-v2-wp80"),
145  ),
146  userInts = cms.PSet(
147  VIDNestedWPBitmap = cms.InputTag("bitmapVIDForPho"),
148  VIDNestedWPBitmapFall17V2 = cms.InputTag("bitmapVIDForPhoRun2"),
149  seedGain = cms.InputTag("seedGainPho"),
150 
151  )
152 )
153 
154 # no need for the Run3 IDs in Run2
155 run2_egamma.toModify(slimmedPhotonsWithUserData.userFloats,
156  mvaID = None,
157  PFIsoChgQuadratic = None,
158  PFIsoAllQuadratic = None,
159  HoverEQuadratic = None).\
160  toModify(slimmedPhotonsWithUserData.userIntFromBools,
161  cutBasedID_loose = None,
162  cutBasedID_medium = None,
163  cutBasedID_tight = None,
164  mvaID_WP90 = None,
165  mvaID_WP80 = None).\
166  toModify(slimmedPhotonsWithUserData.userInts,
167  VIDNestedWPBitmap = None)
168 
169 run2_egamma.toModify(
170  slimmedPhotonsWithUserData.userFloats,
171  ecalEnergyErrPostCorrNew = cms.InputTag("calibratedPatPhotonsNano","ecalEnergyErrPostCorr"),
172  ecalEnergyPreCorrNew = cms.InputTag("calibratedPatPhotonsNano","ecalEnergyPreCorr"),
173  ecalEnergyPostCorrNew = cms.InputTag("calibratedPatPhotonsNano","ecalEnergyPostCorr"),
174  energyScaleUpNew = cms.InputTag("calibratedPatPhotonsNano","energyScaleUp"),
175  energyScaleDownNew = cms.InputTag("calibratedPatPhotonsNano","energyScaleDown"),
176  energySigmaUpNew = cms.InputTag("calibratedPatPhotonsNano","energySigmaUp"),
177  energySigmaDownNew = cms.InputTag("calibratedPatPhotonsNano","energySigmaDown"),
178 )
179 
180 
181 finalPhotons = cms.EDFilter("PATPhotonRefSelector",
182  src = cms.InputTag("slimmedPhotonsWithUserData"),
183  cut = cms.string("pt > 5 ")
184 )
185 
186 photonTable = simplePATPhotonFlatTableProducer.clone(
187  src = cms.InputTag("linkedObjects","photons"),
188  name= cms.string("Photon"),
189  doc = cms.string("slimmedPhotons after basic selection (" + finalPhotons.cut.value()+")"),
190  variables = cms.PSet(P3Vars,
191  jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", "int16", doc="index of the associated jet (-1 if none)"),
192  electronIdx = Var("?hasUserCand('electron')?userCand('electron').key():-1", "int16", doc="index of the associated electron (-1 if none)"),
193  energyErr = Var("getCorrectedEnergyError('regression2')",float,doc="energy error of the cluster from regression",precision=10),
194  energyRaw = Var("superCluster().rawEnergy()",float,doc="raw energy of photon supercluster", precision=10),
195  superclusterEta = Var("superCluster().eta()",float,doc="supercluster eta",precision=10),
196  r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=10),
197  sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
198  sipip = Var("showerShapeVariables().sigmaIphiIphi", float, doc="sigmaIphiIphi of the supercluster", precision=10),
199  sieip = Var("full5x5_showerShapeVariables().sigmaIetaIphi",float,doc="sigma_IetaIphi of the supercluster, calculated with full 5x5 region",precision=10),
200  s4 = Var("full5x5_showerShapeVariables().e2x2/full5x5_showerShapeVariables().e5x5",float,doc="e2x2/e5x5 of the supercluster, calculated with full 5x5 region",precision=10),
201  etaWidth = Var("superCluster().etaWidth()",float,doc="Width of the photon supercluster in eta", precision=10),
202  phiWidth = Var("superCluster().phiWidth()",float,doc="Width of the photon supercluster in phi", precision=10),
203  cutBased = Var(
204  "userInt('cutBasedID_loose')+userInt('cutBasedID_medium')+userInt('cutBasedID_tight')",
205  "uint8",
206  doc="cut-based ID bitmap, RunIIIWinter22V1: fail ==0, loose >=1 , medium >=2, tight >=3",
207  ),
208  vidNestedWPBitmap = Var(
209  "userInt('VIDNestedWPBitmap')",
210  int,
211  doc="RunIIIWinter22V1 " + _bitmapVIDForPho_docstring
212  ),
213  electronVeto = Var("passElectronVeto()",bool,doc="pass electron veto"),
214  pixelSeed = Var("hasPixelSeed()",bool,doc="has pixel seed"),
215  hasConversionTracks = Var("hasConversionTracks()",bool,doc="Variable specifying if photon has associated conversion tracks (one-legged or two-legged)"),
216  mvaID = Var("userFloat('mvaID')",float,doc="MVA ID score, Winter22V1",precision=10),
217  mvaID_WP90 = Var("userInt('mvaID_WP90')",bool,doc="MVA ID WP90, Winter22V1"),
218  mvaID_WP80 = Var("userInt('mvaID_WP80')",bool,doc="MVA ID WP80, Winter22V1"),
219  trkSumPtHollowConeDR03 = Var("trkSumPtHollowConeDR03()",float,doc="Sum of track pT in a hollow cone of outer radius, inner radius", precision=10),
220  trkSumPtSolidConeDR04 = Var("trkSumPtSolidConeDR04()",float,doc="Sum of track pT in a cone of dR=0.4", precision=10),
221  ecalPFClusterIso = Var("ecalPFClusterIso()",float,doc="sum pt of ecal clusters, vetoing clusters part of photon", precision=10),
222  hcalPFClusterIso = Var("hcalPFClusterIso()",float,doc="sum pt of hcal clusters, vetoing clusters part of photon", precision=10),
223  pfPhoIso03 = Var("photonIso()",float,doc="PF absolute isolation dR=0.3, photon component (uncorrected)"),
224  pfChargedIso = Var("chargedHadronIso()",float,doc="PF absolute isolation dR=0.3, charged component with dxy,dz match to PV", precision=8),
225  pfChargedIsoPFPV = Var("chargedHadronPFPVIso()",float,doc="PF absolute isolation dR=0.3, charged component (PF PV only)"),
226  pfChargedIsoWorstVtx = Var("chargedHadronWorstVtxIso()",float,doc="PF absolute isolation dR=0.3, charged component (Vertex with largest isolation)"),
227  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)"),
228  pfRelIso03_all_quadratic = Var("userFloat('PFIsoAllQuadratic')/pt",float,doc="PF relative isolation dR=0.3, total (with quadraticEA*rho*rho + linearEA*rho Winter22V1 corrections)"),
229  hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8),
230  hoe_Tower = Var("hadTowOverEm()",float,doc="H over E Tower based calculation",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  superclusterPhi = Var("superCluster().phi()",float,doc="supercluster phi",precision=10),
255  seedClusterEta = Var("superCluster().seed().eta()",float,doc="seed cluster eta",precision=10),
256  seedClusterPhi = Var("superCluster().seed().phi()",float,doc="seed cluster phi",precision=10),
257  sigmaIphiIphiFull5x5 = Var("full5x5_showerShapeVariables().sigmaIphiIphi",float,doc="Full5x5 sigmaIPhiIPhi",precision=10),
258  eMax = Var("full5x5_maxEnergyXtal()",float,doc="Emax",precision=10),
259  e2nd = Var("full5x5_showerShapeVariables.e2nd",float,doc="E2nd",precision=10),
260  eTop = Var("full5x5_showerShapeVariables.eTop",float,doc="Etop",precision=10),
261  eBottom = Var("full5x5_showerShapeVariables.eBottom",float,doc="Ebottom",precision=10),
262  eLeft = Var("full5x5_showerShapeVariables.eLeft",float,doc="Eleft",precision=10),
263  eRight = Var("full5x5_showerShapeVariables.eRight",float,doc="Eright",precision=10),
264  e2x5max = Var("full5x5_showerShapeVariables.e2x5Max",float,doc="energy in 2x5",precision=10),
265  e2x5Top = Var("full5x5_showerShapeVariables.e2x5Top",float,doc="E2x5Top",precision=10),
266  e2x5Bottom = Var("full5x5_showerShapeVariables.e2x5Bottom",float,doc="E2x5Bottom",precision=10),
267  e2x5Left = Var("full5x5_showerShapeVariables.e2x5Left",float,doc="E2x5Left",precision=10),
268  e2x5Right = Var("full5x5_showerShapeVariables.e2x5Right",float,doc="E2x5Right",precision=10),
269  nSaturatedXtals = Var("nSaturatedXtals",int,doc="number of saturated crystals"),
270  numberOfClusters = Var("superCluster.clusters.size",int,doc="number of clusters"),
271  hadTowOverEm = Var("hadTowOverEm",float,doc="single tower based H/E",precision=10),
272  ecalRecHitIsolation = Var("ecalRecHitSumEtConeDR03",float,doc="ECAL RecHit isolation",precision=10),
273  sigmaIetaIetaFrac = Var("sigmaIetaIeta",float,doc="fractional sigmaIetaIeta",precision=10),
274  chargedHadronIso = Var("chargedHadronIso",float,doc="charged hadron Isolation",precision=10),
275  iEtaMod5 = Var("?superCluster.seedCrysIEtaOrIx>0?(superCluster.seedCrysIEtaOrIx-1)%5:(superCluster.seedCrysIEtaOrIx+1)%5",int,doc="iEtaMod5"),
276  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"),
277  iPhiMod2 = Var("(superCluster.seedCrysIPhiOrIy-1)%2",int,doc="iPhiMod2"),
278  iPhiMod20 = Var("(superCluster.seedCrysIPhiOrIy-1)%20",int,doc="iPhiMod20"),
279 )
280 
281 #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
282 run2_egamma.toModify(
283  photonTable.variables,
284  pt = Var("pt*userFloat('ecalEnergyPostCorrNew')/userFloat('ecalEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
285  energyErr = Var("userFloat('ecalEnergyErrPostCorrNew')",float,doc="energy error of the cluster from regression",precision=6),
286  ptPreCorr = Var("pt",float,doc="pt of the photon before energy corrections"),
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: fail ==0, loose >=1 , medium >=2, tight >=3",
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, lazyEval=False)
Definition: common_cff.py:17
def make_bitmapVID_docstring(id_modules_working_points_pset)
Definition: photons_cff.py:42
static std::string join(char **cmd)
Definition: RemoteFile.cc:21