test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
heepElectronID_tools.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 # Define eta constants
4 ebMax = 1.4442
5 eeMin = 1.566
6 ebCutOff=1.479
7 
8 
9 # ===============================================
10 # Define containers used by cut definitions
11 # ===============================================
12 
14  """
15  This is a container class to hold numerical cut values for either
16  the barrel or endcap set of cuts
17  """
18  def __init__(self,
19  idName,
20  dEtaInSeedCut,
21  dPhiInCut,
22  full5x5SigmaIEtaIEtaCut,
23  # Two constants for the GsfEleFull5x5E2x5OverE5x5Cut
24  minE1x5OverE5x5Cut,
25  minE2x5OverE5x5Cut,
26  # Three constants for the GsfEleHadronicOverEMLinearCut:
27  # cut = constTerm if value < slopeStart
28  # cut = slopeTerm * (value - slopeStart) + constTerm if value >= slopeStart
29  hOverESlopeTerm,
30  hOverESlopeStart,
31  hOverEConstTerm,
32  # Three constants for the GsfEleTrkPtIsoCut:
33  # cut = constTerm if value < slopeStart
34  # cut = slopeTerm * (value - slopeStart) + constTerm if value >= slopeStart
35  trkIsoSlopeTerm,
36  trkIsoSlopeStart,
37  trkIsoConstTerm,
38  # Three constants for the GsfEleEmHadD1IsoRhoCut:
39  # cut = constTerm if value < slopeStart
40  # cut = slopeTerm * (value - slopeStart) + constTerm if value >= slopeStart
41  # Also for the same cut, the effective area for the rho correction of the isolation
42  ehIsoSlopeTerm,
43  ehIsoSlopeStart,
44  ehIsoConstTerm,
45  effAreaForEHIso,
46  # other cuts:
47  dxyCut,
48  maxMissingHitsCut,
49  ecalDrivenCut
50  ):
51  # assign values taken from all the arguments above
52  self.idName = idName
53  self.dEtaInSeedCut = dEtaInSeedCut
54  self.dPhiInCut = dPhiInCut
55  self.full5x5SigmaIEtaIEtaCut = full5x5SigmaIEtaIEtaCut
56  self.minE1x5OverE5x5Cut = minE1x5OverE5x5Cut
57  self.minE2x5OverE5x5Cut = minE2x5OverE5x5Cut
58  self.hOverESlopeTerm = hOverESlopeTerm
59  self.hOverESlopeStart = hOverESlopeStart
60  self.hOverEConstTerm = hOverEConstTerm
61  self.trkIsoSlopeTerm = trkIsoSlopeTerm
62  self.trkIsoSlopeStart = trkIsoSlopeStart
63  self.trkIsoConstTerm = trkIsoConstTerm
64  self.ehIsoSlopeTerm = ehIsoSlopeTerm
65  self.ehIsoSlopeStart = ehIsoSlopeStart
66  self.ehIsoConstTerm = ehIsoConstTerm
67  self.effAreaForEHIso = effAreaForEHIso
68  self.dxyCut = dxyCut
69  self.maxMissingHitsCut = maxMissingHitsCut
70  self.ecalDrivenCut = ecalDrivenCut
71 # ==============================================================
72 # Define individual cut configurations used by complete cut sets
73 # ==============================================================
74 
75 # The mininum pt cut is set to 5 GeV
77  return cms.PSet(
78  cutName = cms.string("MinPtCut"),
79  minPt = cms.double(35.0),
80  needsAdditionalProducts = cms.bool(False),
81  isIgnored = cms.bool(False)
82  )
83 
84 # Take all particles in the eta ranges 0-ebMax and eeMin-2.5
86  return cms.PSet(
87  cutName = cms.string("GsfEleSCEtaMultiRangeCut"),
88  useAbsEta = cms.bool(True),
89  allowedEtaRanges = cms.VPSet(
90  cms.PSet( minEta = cms.double(0.0),
91  maxEta = cms.double(ebMax) ),
92  cms.PSet( minEta = cms.double(eeMin),
93  maxEta = cms.double(2.5) )
94  ),
95  needsAdditionalProducts = cms.bool(False),
96  isIgnored = cms.bool(False)
97  )
98 
99 # Configure the cut on the dEtaIn for the seed
100 def psetGsfEleDEtaInSeedCut(wpEB, wpEE):
101  return cms.PSet(
102  cutName = cms.string('GsfEleDEtaInSeedCut'),
103  dEtaInSeedCutValueEB = cms.double( wpEB.dEtaInSeedCut ),
104  dEtaInSeedCutValueEE = cms.double( wpEE.dEtaInSeedCut ),
105  barrelCutOff = cms.double(ebCutOff),
106  needsAdditionalProducts = cms.bool(False),
107  isIgnored = cms.bool(False)
108  )
109 
110 # Configure the cut on the dPhiIn
111 def psetGsfEleDPhiInCut(wpEB, wpEE):
112  return cms.PSet(
113  cutName = cms.string('GsfEleDPhiInCut'),
114  dPhiInCutValueEB = cms.double( wpEB.dPhiInCut ),
115  dPhiInCutValueEE = cms.double( wpEE.dPhiInCut ),
116  barrelCutOff = cms.double(ebCutOff),
117  needsAdditionalProducts = cms.bool(False),
118  isIgnored = cms.bool(False)
119  )
120 
121 # Confugure the full 5x5 sigmaIEtaIEta cut
123  return cms.PSet(
124  cutName = cms.string('GsfEleFull5x5SigmaIEtaIEtaCut'),
125  full5x5SigmaIEtaIEtaCutValueEB = cms.double( wpEB.full5x5SigmaIEtaIEtaCut ),
126  full5x5SigmaIEtaIEtaCutValueEE = cms.double( wpEE.full5x5SigmaIEtaIEtaCut ),
127  barrelCutOff = cms.double(ebCutOff),
128  needsAdditionalProducts = cms.bool(False),
129  isIgnored = cms.bool(False)
130  )
131 
132 # Configure XxX shower shape cuts
134  return cms.PSet(
135  cutName = cms.string('GsfEleFull5x5E2x5OverE5x5Cut'),
136  # E1x5 / E5x5
137  minE1x5OverE5x5EB = cms.double( wpEB.minE1x5OverE5x5Cut ),
138  minE1x5OverE5x5EE = cms.double( wpEE.minE1x5OverE5x5Cut ),
139  # E2x5 / E5x5
140  minE2x5OverE5x5EB = cms.double( wpEB.minE2x5OverE5x5Cut ),
141  minE2x5OverE5x5EE = cms.double( wpEE.minE2x5OverE5x5Cut ),
142  needsAdditionalProducts = cms.bool(False),
143  isIgnored = cms.bool(False)
144  )
145 
146 # Configure the cut of E/H
148  return cms.PSet(
149  cutName = cms.string('GsfEleHadronicOverEMLinearCut'),
150  # Three constants for the GsfEleHadronicOverEMLinearCut
151  # cut = constTerm if value < slopeStart
152  # cut = slopeTerm * (value - slopeStart) + constTerm if value >= slopeStart
153  slopeTermEB = cms.double( wpEB.hOverESlopeTerm ),
154  slopeTermEE = cms.double( wpEE.hOverESlopeTerm ),
155  slopeStartEB = cms.double( wpEB.hOverESlopeStart ),
156  slopeStartEE = cms.double( wpEE.hOverESlopeStart ),
157  constTermEB = cms.double( wpEB.hOverEConstTerm ),
158  constTermEE = cms.double( wpEE.hOverEConstTerm ),
159  needsAdditionalProducts = cms.bool(False),
160  isIgnored = cms.bool(False)
161  )
162 
163 # Configure the cut on the tracker isolation
164 def psetGsfEleTrkPtIsoCut(wpEB, wpEE):
165  return cms.PSet(
166  cutName = cms.string('GsfEleTrkPtIsoCut'),
167  # Three constants for the GsfEleTrkPtIsoCut
168  # cut = constTerm if value < slopeStart
169  # cut = slopeTerm * (value - slopeStart) + constTerm if value >= slopeStart
170  slopeTermEB = cms.double( wpEB.trkIsoSlopeTerm ),
171  slopeTermEE = cms.double( wpEE.trkIsoSlopeTerm ),
172  slopeStartEB = cms.double( wpEB.trkIsoSlopeStart ),
173  slopeStartEE = cms.double( wpEE.trkIsoSlopeStart ),
174  constTermEB = cms.double( wpEB.trkIsoConstTerm ),
175  constTermEE = cms.double( wpEE.trkIsoConstTerm ),
176  needsAdditionalProducts = cms.bool(False),
177  isIgnored = cms.bool(False)
178  )
179 
180 # Configure the cut on the EM + Had_depth_1 isolation with rho correction
182  return cms.PSet(
183  cutName = cms.string('GsfEleEmHadD1IsoRhoCut'),
184  slopeTermEB = cms.double( wpEB.ehIsoSlopeTerm ),
185  slopeTermEE = cms.double( wpEE.ehIsoSlopeTerm ),
186  slopeStartEB = cms.double( wpEB.ehIsoSlopeStart ),
187  slopeStartEE = cms.double( wpEE.ehIsoSlopeStart ),
188  constTermEB = cms.double( wpEB.ehIsoConstTerm ),
189  constTermEE = cms.double( wpEE.ehIsoConstTerm ),
190  rhoConstant = cms.double( wpEB.effAreaForEHIso), # expected to be the same for EB and EE
191  rho = cms.InputTag("fixedGridRhoFastjetAll"),
192  needsAdditionalProducts = cms.bool(True),
193  isIgnored = cms.bool(False)
194  )
195 
196 # Configure the dxy cut
197 def psetGsfEleDxyCut(wpEB, wpEE):
198  return cms.PSet(
199  cutName = cms.string('GsfEleDxyCut'),
200  dxyCutValueEB = cms.double( wpEB.dxyCut ),
201  dxyCutValueEE = cms.double( wpEE.dxyCut ),
202  vertexSrc = cms.InputTag("offlinePrimaryVertices"),
203  vertexSrcMiniAOD = cms.InputTag("offlineSlimmedPrimaryVertices"),
204  barrelCutOff = cms.double(ebCutOff),
205  needsAdditionalProducts = cms.bool(True),
206  isIgnored = cms.bool(False)
207  )
208 
209 # Configure the cut on missing hits
210 def psetGsfEleMissingHitsCut(wpEB, wpEE):
211  return cms.PSet(
212  cutName = cms.string('GsfEleMissingHitsCut'),
213  maxMissingHitsEB = cms.uint32( wpEB.maxMissingHitsCut ),
214  maxMissingHitsEE = cms.uint32( wpEE.maxMissingHitsCut ),
215  barrelCutOff = cms.double(ebCutOff),
216  needsAdditionalProducts = cms.bool(False),
217  isIgnored = cms.bool(False)
218  )
219 def psetGsfEleEcalDrivenCut(wpEB, wpEE):
220  return cms.PSet(
221  cutName = cms.string('GsfEleEcalDrivenCut'),
222  ecalDrivenEB = cms.int32( wpEB.ecalDrivenCut ),
223  ecalDrivenEE = cms.int32( wpEE.ecalDrivenCut ),
224  barrelCutOff = cms.double(ebCutOff),
225  needsAdditionalProducts = cms.bool(False),
226  isIgnored = cms.bool(False)
227  )
228 
229 # ==============================================================
230 # Define the complete cut sets
231 # ==============================================================
232 
234  """
235  This function configures the full cms.PSet for a VID ID and returns it.
236  The inputs: two objects of the type HEEP_WorkingPoint_V1, one
237  containing the cuts for the Barrel (EB) and the other one for the Endcap (EE).
238  """
239  parameterSet = cms.PSet(
240  idName = cms.string("heepElectronID-HEEPV51"),
241  cutFlow = cms.VPSet(
242  psetMinPtCut(), #0
244  psetGsfEleDEtaInSeedCut(wpEB,wpEE), #2
245  psetGsfEleDPhiInCut(wpEB,wpEE), #3
246  psetGsfEleFull5x5SigmaIEtaIEtaCut(wpEB,wpEE), #4
247  psetGsfEleFull5x5E2x5OverE5x5Cut(wpEB,wpEE), #5
248  psetGsfEleHadronicOverEMLinearCut(wpEB,wpEE), #6
249  psetGsfEleTrkPtIsoCut(wpEB,wpEE), #7
250  psetGsfEleEmHadD1IsoRhoCut(wpEB,wpEE), #8
251  psetGsfEleDxyCut(wpEB,wpEE), #9
252  psetGsfEleMissingHitsCut(wpEB,wpEE), #10,
253  psetGsfEleEcalDrivenCut(wpEB,wpEE) #11
254  )
255  )
256  return parameterSet
257 
259  """
260  This function configures the full cms.PSet for a VID ID and returns it.
261  The inputs: two objects of the type HEEP_WorkingPoint_V1, one
262  containing the cuts for the Barrel (EB) and the other one for the Endcap (EE).
263  """
264  parameterSet = cms.PSet(
265  idName = cms.string("heepElectronID-HEEPV60"),
266  cutFlow = cms.VPSet(
267  psetMinPtCut(), #0
269  psetGsfEleDEtaInSeedCut(wpEB,wpEE), #2
270  psetGsfEleDPhiInCut(wpEB,wpEE), #3
271  psetGsfEleFull5x5SigmaIEtaIEtaCut(wpEB,wpEE), #4
272  psetGsfEleFull5x5E2x5OverE5x5Cut(wpEB,wpEE), #5
273  psetGsfEleHadronicOverEMLinearCut(wpEB,wpEE), #6
274  psetGsfEleTrkPtIsoCut(wpEB,wpEE), #7
275  psetGsfEleEmHadD1IsoRhoCut(wpEB,wpEE), #8
276  psetGsfEleDxyCut(wpEB,wpEE), #9
277  psetGsfEleMissingHitsCut(wpEB,wpEE), #10,
278  psetGsfEleEcalDrivenCut(wpEB,wpEE) #11
279  )
280  )
281  return parameterSet