CMS 3D CMS Logo

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 
7 class EleMVA_WP:
8  """
9  This is a container class to hold MVA cut values for a n-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  IMPORTANT: the cuts need to be given in alphabetical order, which must
14  be the order in which they are used by the cut class.
15  """
16  def __init__(self,
17  idName,
18  mvaValueMapName,
19  mvaCategoriesMapName,
20  **cuts
21  ):
22  self.idName = idName
23  self.mvaValueMapName = mvaValueMapName
24  self.mvaCategoriesMapName = mvaCategoriesMapName
25  self.cuts = cuts
26 
27  def getCutValues(self):
28  keylist = self.cuts.keys()
29  keylist.sort()
30  return [self.cuts[key] for key in keylist]
31 
32 # This is for backwards compatibility with IDs <= 2016
33 EleMVA_3Categories_WP = EleMVA_WP
34 EleMVA_6Categories_WP = EleMVA_WP
35 
36 # ==============================================================
37 # Define the complete MVA cut sets
38 # ==============================================================
39 
40 def configureVIDMVAEleID_V1(mvaWP, cutName="GsfEleMVACut"):
41  """
42  This function configures the full cms.PSet for a VID ID and returns it.
43  The inputs: an object of the class EleMVA_WP or similar
44  that contains all necessary parameters for this MVA.
45  """
46  parameterSet = cms.PSet(
47  #
48  idName = cms.string( mvaWP.idName ),
49  cutFlow = cms.VPSet(
50  cms.PSet( cutName = cms.string(cutName),
51  mvaCuts = cms.vdouble( mvaWP.getCutValues() ),
52  mvaValueMapName = cms.InputTag( mvaWP.mvaValueMapName ),
53  mvaCategoriesMapName =cms.InputTag( mvaWP.mvaCategoriesMapName ),
54  needsAdditionalProducts = cms.bool(True),
55  isIgnored = cms.bool(False)
56  )
57  )
58  )
59  #
60  return parameterSet
def __init__(self, idName, mvaValueMapName, mvaCategoriesMapName, cuts)
def configureVIDMVAEleID_V1(mvaWP, cutName="GsfEleMVACut")