CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
trainingvars Namespace Reference

Functions

def get_var_default
 
def get_var_idx
 
def get_var_name
 
def get_var_pset
 
def var_match
 

Variables

dictionary training_vars
 
tuple varname_regex_ = re.compile(r'(?P<name>[a-zA-Z0-9]+)(:?_(?P<idx>\d+))?$')
 

Function Documentation

def trainingvars.get_var_default (   varname)

Definition at line 93 of file trainingvars.py.

References get_var_name().

Referenced by get_var_pset().

93 
94 def get_var_default(varname):
95  'returns the default value used in the traing'
96  name = get_var_name(varname)
97  return training_vars[name]['default']
def get_var_default
Definition: trainingvars.py:93
def trainingvars.get_var_idx (   varname)

Definition at line 98 of file trainingvars.py.

References var_match().

Referenced by get_var_pset().

98 
99 def get_var_idx(varname):
100  'returns the index in case of vectorial TaggingVariableName'
101  match = var_match(varname)
102  idx = match.group('idx')
103  return int(idx) if idx else None
def trainingvars.get_var_name (   varname)

Definition at line 81 of file trainingvars.py.

References var_match().

Referenced by get_var_default(), and get_var_pset().

81 
82 def get_var_name(varname):
83  'returns the TaggingVariableName of a MVA Name'
84  match = var_match(varname)
85  name = match.group('name')
86  if name not in training_vars:
87  raise ValueError(
88  'Variable name {0}, matched to name {1}, '
89  'is not among the known trainig variables.'.format(
90  varname, name)
91  )
92  return name
def trainingvars.get_var_pset (   mvaname)

Definition at line 104 of file trainingvars.py.

References cms::cuda.assert(), get_var_default(), get_var_idx(), and get_var_name().

Referenced by helpers.get_vars().

105 def get_var_pset(mvaname):
106  'returns the cms.PSet to be used by CharmTaggerESProducer'
107  pset = cms.PSet(
108  name = cms.string(mvaname),
109  taggingVarName = cms.string(get_var_name(mvaname)),
110  default = cms.double(get_var_default(mvaname))
111  )
112  idx = get_var_idx(mvaname)
113  if idx is not None:
114  pset.idx = cms.int32(idx)
115  return pset
def get_var_default
Definition: trainingvars.py:93
def trainingvars.var_match (   varname)
matches the name used in the MVA training to 
get the TaggingVariableName and index

Definition at line 70 of file trainingvars.py.

Referenced by get_var_idx(), and get_var_name().

70 
71 def var_match(varname):
72  '''matches the name used in the MVA training to
73  get the TaggingVariableName and index'''
74  match = varname_regex_.match(varname)
75  if not match:
76  raise ValueError(
77  'Variable name {0} does not match '
78  'the default regular expression'.format(varname)
79  )
80  return match

Variable Documentation

dictionary trainingvars.training_vars

Definition at line 4 of file trainingvars.py.

tuple trainingvars.varname_regex_ = re.compile(r'(?P<name>[a-zA-Z0-9]+)(:?_(?P<idx>\d+))?$')

Definition at line 69 of file trainingvars.py.