CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
mvaElectronID_tools.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 # =======================================================
4 # Define simple containers for MVA cut values and related
5 # =======================================================
6 
8  """
9  This is a container class to hold MVA cut values for a 3-category MVA
10  as well as the names of the value maps that contain the MVA values computed
11  for all particles in a producer upstream.
12  """
13  def __init__(self,
14  idName,
15  mvaValueMapName,
16  mvaCategoriesMapName,
17  cutCategory0,
18  cutCategory1,
19  cutCategory2
20  ):
21  self.idName = idName
22  self.mvaValueMapName = mvaValueMapName
23  self.mvaCategoriesMapName = mvaCategoriesMapName
24  self.cutCategory0 = cutCategory0
25  self.cutCategory1 = cutCategory1
26  self.cutCategory2 = cutCategory2
27 
28  def getCutValues(self):
29  return [self.cutCategory0, self.cutCategory1, self.cutCategory2]
30 
32  """
33  This is a container class to hold MVA cut values for a 6-category MVA
34  as well as the names of the value maps that contain the MVA values computed
35  for all particles in a producer upstream.
36  """
37  def __init__(self,
38  idName,
39  mvaValueMapName,
40  mvaCategoriesMapName,
41  cutCategory0,
42  cutCategory1,
43  cutCategory2,
44  cutCategory3,
45  cutCategory4,
46  cutCategory5
47  ):
48  self.idName = idName
49  self.mvaValueMapName = mvaValueMapName
50  self.mvaCategoriesMapName = mvaCategoriesMapName
51  self.cutCategory0 = cutCategory0
52  self.cutCategory1 = cutCategory1
53  self.cutCategory2 = cutCategory2
54  self.cutCategory3 = cutCategory3
55  self.cutCategory4 = cutCategory4
56  self.cutCategory5 = cutCategory5
57 
58  def getCutValues(self):
59  return [self.cutCategory0, self.cutCategory1, self.cutCategory2,
60  self.cutCategory3, self.cutCategory4, self.cutCategory5]
61 
62 # ==============================================================
63 # Define the complete MVA cut sets
64 # ==============================================================
65 
67  """
68  This function configures the full cms.PSet for a VID ID and returns it.
69  The inputs: an object of the class EleMVA_6Categories_WP or similar
70  that contains all necessary parameters for this MVA.
71  """
72  parameterSet = cms.PSet(
73  #
74  idName = cms.string( mvaWP.idName ),
75  cutFlow = cms.VPSet(
76  cms.PSet( cutName = cms.string("GsfEleMVACut"),
77  mvaCuts = cms.vdouble( mvaWP.getCutValues() ),
78  mvaValueMapName = cms.InputTag( mvaWP.mvaValueMapName ),
79  mvaCategoriesMapName =cms.InputTag( mvaWP.mvaCategoriesMapName ),
80  needsAdditionalProducts = cms.bool(True),
81  isIgnored = cms.bool(False)
82  )
83  )
84  )
85  #
86  return parameterSet