CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
cutBasedElectronID_tools.py
Go to the documentation of this file.
1 
2 import FWCore.ParameterSet.Config as cms
3 
4 # Barrel/endcap division in eta
5 ebCutOff = 1.479
6 
7 # -----------------------------
8 # Version V1 common definitions
9 # -----------------------------
10 
12  """
13  This is a container class to hold numerical cut values for either
14  the barrel or endcap set of cuts for electron cut-based ID
15  """
16  def __init__(self,
17  idName,
18  dEtaInCut,
19  dPhiInCut,
20  full5x5_sigmaIEtaIEtaCut,
21  hOverECut,
22  dxyCut,
23  dzCut,
24  absEInverseMinusPInverseCut,
25  relCombIsolationWithDBetaLowPtCut,
26  relCombIsolationWithDBetaHighPtCut,
27  # conversion veto cut needs no parameters, so not mentioned
28  missingHitsCut
29  ):
30  self.idName = idName
31  self.dEtaInCut = dEtaInCut
32  self.dPhiInCut = dPhiInCut
33  self.full5x5_sigmaIEtaIEtaCut = full5x5_sigmaIEtaIEtaCut
34  self.hOverECut = hOverECut
35  self.dxyCut = dxyCut
36  self.dzCut = dzCut
37  self.absEInverseMinusPInverseCut = absEInverseMinusPInverseCut
38  self.relCombIsolationWithDBetaLowPtCut = relCombIsolationWithDBetaLowPtCut
39  self.relCombIsolationWithDBetaHighPtCut = relCombIsolationWithDBetaHighPtCut
40  # conversion veto cut needs no parameters, so not mentioned
41  self.missingHitsCut = missingHitsCut
42 
43 def configureVIDCutBasedEleID_V1( wpEB, wpEE ):
44  """
45  This function configures the full cms.PSet for a VID ID and returns it.
46  The inputs: two objects of the type WorkingPoint_V1, one
47  containing the cuts for the Barrel (EB) and the other one for the Endcap (EE).
48  """
49  # print "VID: Configuring cut set %s" % wpEB.idName
50  parameterSet = cms.PSet(
51  #
52  idName = cms.string( wpEB.idName ), # same name stored in the _EB and _EE objects
53  cutFlow = cms.VPSet(
54  cms.PSet( cutName = cms.string("MinPtCut"),
55  minPt = cms.double(5.0),
56  needsAdditionalProducts = cms.bool(False),
57  isIgnored = cms.bool(False) ),
58  cms.PSet( cutName = cms.string("GsfEleSCEtaMultiRangeCut"),
59  useAbsEta = cms.bool(True),
60  allowedEtaRanges = cms.VPSet(
61  cms.PSet( minEta = cms.double(0.0),
62  maxEta = cms.double(ebCutOff) ),
63  cms.PSet( minEta = cms.double(ebCutOff),
64  maxEta = cms.double(2.5) )
65  ),
66  needsAdditionalProducts = cms.bool(False),
67  isIgnored = cms.bool(False)),
68  cms.PSet( cutName = cms.string('GsfEleDEtaInCut'),
69  dEtaInCutValueEB = cms.double( wpEB.dEtaInCut ),
70  dEtaInCutValueEE = cms.double( wpEE.dEtaInCut ),
71  barrelCutOff = cms.double(ebCutOff),
72  needsAdditionalProducts = cms.bool(False),
73  isIgnored = cms.bool(False)),
74  cms.PSet( cutName = cms.string('GsfEleDPhiInCut'),
75  dPhiInCutValueEB = cms.double( wpEB.dPhiInCut ),
76  dPhiInCutValueEE = cms.double( wpEE.dPhiInCut ),
77  barrelCutOff = cms.double(ebCutOff),
78  needsAdditionalProducts = cms.bool(False),
79  isIgnored = cms.bool(False)),
80  cms.PSet( cutName = cms.string('GsfEleFull5x5SigmaIEtaIEtaCut'),
81  full5x5SigmaIEtaIEtaCutValueEB = cms.double( wpEB.full5x5_sigmaIEtaIEtaCut ),
82  full5x5SigmaIEtaIEtaCutValueEE = cms.double( wpEE.full5x5_sigmaIEtaIEtaCut ),
83  barrelCutOff = cms.double(ebCutOff),
84  needsAdditionalProducts = cms.bool(False),
85  isIgnored = cms.bool(False)),
86  cms.PSet( cutName = cms.string('GsfEleHadronicOverEMCut'),
87  hadronicOverEMCutValueEB = cms.double( wpEB.hOverECut ),
88  hadronicOverEMCutValueEE = cms.double( wpEE.hOverECut ),
89  barrelCutOff = cms.double(ebCutOff),
90  needsAdditionalProducts = cms.bool(False),
91  isIgnored = cms.bool(False)),
92  cms.PSet( cutName = cms.string('GsfEleDxyCut'),
93  dxyCutValueEB = cms.double( wpEB.dxyCut ),
94  dxyCutValueEE = cms.double( wpEE.dxyCut ),
95  vertexSrc = cms.InputTag("offlinePrimaryVertices"),
96  vertexSrcMiniAOD = cms.InputTag("offlineSlimmedPrimaryVertices"),
97  barrelCutOff = cms.double(ebCutOff),
98  needsAdditionalProducts = cms.bool(True),
99  isIgnored = cms.bool(False)),
100  cms.PSet( cutName = cms.string('GsfEleDzCut'),
101  dzCutValueEB = cms.double( wpEB.dzCut ),
102  dzCutValueEE = cms.double( wpEE.dzCut ),
103  vertexSrc = cms.InputTag("offlinePrimaryVertices"),
104  vertexSrcMiniAOD = cms.InputTag("offlineSlimmedPrimaryVertices"),
105  barrelCutOff = cms.double(ebCutOff),
106  needsAdditionalProducts = cms.bool(True),
107  isIgnored = cms.bool(False)),
108  cms.PSet( cutName = cms.string('GsfEleEInverseMinusPInverseCut'),
109  eInverseMinusPInverseCutValueEB = cms.double( wpEB.absEInverseMinusPInverseCut ),
110  eInverseMinusPInverseCutValueEE = cms.double( wpEE.absEInverseMinusPInverseCut ),
111  barrelCutOff = cms.double(ebCutOff),
112  needsAdditionalProducts = cms.bool(False),
113  isIgnored = cms.bool(False)),
114  cms.PSet( cutName = cms.string('GsfEleDeltaBetaIsoCutStandalone'),
115  isoCutEBLowPt = cms.double( wpEB.relCombIsolationWithDBetaLowPtCut ),
116  isoCutEBHighPt = cms.double( wpEB.relCombIsolationWithDBetaHighPtCut ),
117  isoCutEELowPt = cms.double( wpEE.relCombIsolationWithDBetaLowPtCut ),
118  isoCutEEHighPt = cms.double( wpEE.relCombIsolationWithDBetaHighPtCut ),
119  isRelativeIso = cms.bool(True),
120  deltaBetaConstant = cms.double(0.5),
121  ptCutOff = cms.double(20.0), # high pT above this value, low pT below
122  barrelCutOff = cms.double(ebCutOff),
123  needsAdditionalProducts = cms.bool(False),
124  isIgnored = cms.bool(False)),
125  cms.PSet( cutName = cms.string('GsfEleConversionVetoCut'),
126  conversionSrc = cms.InputTag('allConversions'),
127  conversionSrcMiniAOD = cms.InputTag('reducedEgamma:reducedConversions'),
128  beamspotSrc = cms.InputTag('offlineBeamSpot'),
129  needsAdditionalProducts = cms.bool(True),
130  isIgnored = cms.bool(False)),
131  cms.PSet( cutName = cms.string('GsfEleMissingHitsCut'),
132  maxMissingHitsEB = cms.uint32( wpEB.missingHitsCut ),
133  maxMissingHitsEE = cms.uint32( wpEE.missingHitsCut ),
134  barrelCutOff = cms.double(ebCutOff),
135  needsAdditionalProducts = cms.bool(False),
136  isIgnored = cms.bool(False) ),
137  )
138  )
139  #
140  return parameterSet
141 
142 # -----------------------------
143 # Version V2 common definitions
144 # -----------------------------
145 
147  """
148  This is a container class to hold numerical cut values for either
149  the barrel or endcap set of cuts for electron cut-based ID
150  """
151  def __init__(self,
152  idName,
153  dEtaInCut,
154  dPhiInCut,
155  full5x5_sigmaIEtaIEtaCut,
156  hOverECut,
157  dxyCut,
158  dzCut,
159  absEInverseMinusPInverseCut,
160  relCombIsolationWithEALowPtCut,
161  relCombIsolationWithEAHighPtCut,
162  # conversion veto cut needs no parameters, so not mentioned
163  missingHitsCut
164  ):
165  self.idName = idName
166  self.dEtaInCut = dEtaInCut
167  self.dPhiInCut = dPhiInCut
168  self.full5x5_sigmaIEtaIEtaCut = full5x5_sigmaIEtaIEtaCut
169  self.hOverECut = hOverECut
170  self.dxyCut = dxyCut
171  self.dzCut = dzCut
172  self.absEInverseMinusPInverseCut = absEInverseMinusPInverseCut
173  self.relCombIsolationWithEALowPtCut = relCombIsolationWithEALowPtCut
174  self.relCombIsolationWithEAHighPtCut = relCombIsolationWithEAHighPtCut
175  # conversion veto cut needs no parameters, so not mentioned
176  self.missingHitsCut = missingHitsCut
177 
179  """
180  A container class that holds the name of the file with the effective
181  area constants for pile-up corrections
182  """
183  def __init__(self,
184  neuHadAndPhoIsolationEffAreas
185  ):
186  self.neuHadAndPhoIsolationEffAreas = neuHadAndPhoIsolationEffAreas
187 
188 
189 def configureVIDCutBasedEleID_V2( wpEB, wpEE, isoInputs ):
190  """
191  This function configures the full cms.PSet for a VID ID and returns it.
192  The inputs: two objects of the type WorkingPoint_V2, one
193  containing the cuts for the Barrel (EB) and the other one for the Endcap (EE).
194  The third argument is an object that contains information necessary
195  for isolation calculations.
196  """
197  # print "VID: Configuring cut set %s" % wpEB.idName
198  parameterSet = cms.PSet(
199  #
200  idName = cms.string( wpEB.idName ), # same name stored in the _EB and _EE objects
201  cutFlow = cms.VPSet(
202  cms.PSet( cutName = cms.string("MinPtCut"),
203  minPt = cms.double(5.0),
204  needsAdditionalProducts = cms.bool(False),
205  isIgnored = cms.bool(False) ),
206  cms.PSet( cutName = cms.string("GsfEleSCEtaMultiRangeCut"),
207  useAbsEta = cms.bool(True),
208  allowedEtaRanges = cms.VPSet(
209  cms.PSet( minEta = cms.double(0.0),
210  maxEta = cms.double(ebCutOff) ),
211  cms.PSet( minEta = cms.double(ebCutOff),
212  maxEta = cms.double(2.5) )
213  ),
214  needsAdditionalProducts = cms.bool(False),
215  isIgnored = cms.bool(False)),
216  cms.PSet( cutName = cms.string('GsfEleDEtaInCut'),
217  dEtaInCutValueEB = cms.double( wpEB.dEtaInCut ),
218  dEtaInCutValueEE = cms.double( wpEE.dEtaInCut ),
219  barrelCutOff = cms.double(ebCutOff),
220  needsAdditionalProducts = cms.bool(False),
221  isIgnored = cms.bool(False)),
222  cms.PSet( cutName = cms.string('GsfEleDPhiInCut'),
223  dPhiInCutValueEB = cms.double( wpEB.dPhiInCut ),
224  dPhiInCutValueEE = cms.double( wpEE.dPhiInCut ),
225  barrelCutOff = cms.double(ebCutOff),
226  needsAdditionalProducts = cms.bool(False),
227  isIgnored = cms.bool(False)),
228  cms.PSet( cutName = cms.string('GsfEleFull5x5SigmaIEtaIEtaCut'),
229  full5x5SigmaIEtaIEtaCutValueEB = cms.double( wpEB.full5x5_sigmaIEtaIEtaCut ),
230  full5x5SigmaIEtaIEtaCutValueEE = cms.double( wpEE.full5x5_sigmaIEtaIEtaCut ),
231  barrelCutOff = cms.double(ebCutOff),
232  needsAdditionalProducts = cms.bool(False),
233  isIgnored = cms.bool(False)),
234  cms.PSet( cutName = cms.string('GsfEleHadronicOverEMCut'),
235  hadronicOverEMCutValueEB = cms.double( wpEB.hOverECut ),
236  hadronicOverEMCutValueEE = cms.double( wpEE.hOverECut ),
237  barrelCutOff = cms.double(ebCutOff),
238  needsAdditionalProducts = cms.bool(False),
239  isIgnored = cms.bool(False)),
240  cms.PSet( cutName = cms.string('GsfEleDxyCut'),
241  dxyCutValueEB = cms.double( wpEB.dxyCut ),
242  dxyCutValueEE = cms.double( wpEE.dxyCut ),
243  vertexSrc = cms.InputTag("offlinePrimaryVertices"),
244  vertexSrcMiniAOD = cms.InputTag("offlineSlimmedPrimaryVertices"),
245  barrelCutOff = cms.double(ebCutOff),
246  needsAdditionalProducts = cms.bool(True),
247  isIgnored = cms.bool(False)),
248  cms.PSet( cutName = cms.string('GsfEleDzCut'),
249  dzCutValueEB = cms.double( wpEB.dzCut ),
250  dzCutValueEE = cms.double( wpEE.dzCut ),
251  vertexSrc = cms.InputTag("offlinePrimaryVertices"),
252  vertexSrcMiniAOD = cms.InputTag("offlineSlimmedPrimaryVertices"),
253  barrelCutOff = cms.double(ebCutOff),
254  needsAdditionalProducts = cms.bool(True),
255  isIgnored = cms.bool(False)),
256  cms.PSet( cutName = cms.string('GsfEleEInverseMinusPInverseCut'),
257  eInverseMinusPInverseCutValueEB = cms.double( wpEB.absEInverseMinusPInverseCut ),
258  eInverseMinusPInverseCutValueEE = cms.double( wpEE.absEInverseMinusPInverseCut ),
259  barrelCutOff = cms.double(ebCutOff),
260  needsAdditionalProducts = cms.bool(False),
261  isIgnored = cms.bool(False)),
262  cms.PSet( cutName = cms.string('GsfEleEffAreaPFIsoCut'),
263  isoCutEBLowPt = cms.double( wpEB.relCombIsolationWithEALowPtCut ),
264  isoCutEBHighPt = cms.double( wpEB.relCombIsolationWithEAHighPtCut ),
265  isoCutEELowPt = cms.double( wpEE.relCombIsolationWithEALowPtCut ),
266  isoCutEEHighPt = cms.double( wpEE.relCombIsolationWithEAHighPtCut ),
267  isRelativeIso = cms.bool(True),
268  ptCutOff = cms.double(20.0), # high pT above this value, low pT below
269  barrelCutOff = cms.double(ebCutOff),
270  rho = cms.InputTag("fixedGridRhoFastjetAll"),
271  effAreasConfigFile = cms.FileInPath( isoInputs.neuHadAndPhoIsolationEffAreas ),
272  needsAdditionalProducts = cms.bool(True),
273  isIgnored = cms.bool(False) ),
274  cms.PSet( cutName = cms.string('GsfEleConversionVetoCut'),
275  conversionSrc = cms.InputTag('allConversions'),
276  conversionSrcMiniAOD = cms.InputTag('reducedEgamma:reducedConversions'),
277  beamspotSrc = cms.InputTag('offlineBeamSpot'),
278  needsAdditionalProducts = cms.bool(True),
279  isIgnored = cms.bool(False)),
280  cms.PSet( cutName = cms.string('GsfEleMissingHitsCut'),
281  maxMissingHitsEB = cms.uint32( wpEB.missingHitsCut ),
282  maxMissingHitsEE = cms.uint32( wpEE.missingHitsCut ),
283  barrelCutOff = cms.double(ebCutOff),
284  needsAdditionalProducts = cms.bool(False),
285  isIgnored = cms.bool(False) ),
286  )
287  )
288  #
289  return parameterSet
290