CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TauDecayModes.py
Go to the documentation of this file.
1 print 'importing'
2 
3 class TauDecayModes( object ):
4 
5  def __init__(self):
6  self._decayModes()
7 
8  def _decayModes(self):
9  '''Builds the internal dictionaries from the enum defined in
10  http://cmslxr.fnal.gov/lxr/source/DataFormats/TauReco/interface/PFTau.h'''
11  tmp = [
12  'kOneProng0PiZero',
13  'kOneProng1PiZero',
14  'kOneProng2PiZero',
15  'kOneProng3PiZero',
16  'kOneProngNPiZero',
17  'kTwoProng0PiZero',
18  'kTwoProng1PiZero',
19  'kTwoProng2PiZero',
20  'kTwoProng3PiZero',
21  'kTwoProngNPiZero',
22  'kThreeProng0PiZero',
23  'kThreeProng1PiZero',
24  'kThreeProng2PiZero',
25  'kThreeProng3PiZero',
26  'kThreeProngNPiZero',
27  'kRareDecayMode'
28  ]
29  self.decayModes = dict( (index, name) for index,name in enumerate( tmp ) )
30  self.decayModeNames = dict( (value, key) for key, value \
31  in self.decayModes.iteritems() )
32 
33  def intToName( self, anInt ):
34  '''Returns the decay mode name corresponding to an int.'''
35  return self.decayModes[ anInt ]
36 
37  def nameToInt( self, aName ):
38  '''Returns the decay mode int corresponding to a name.'''
39  return self.decayModeNames[ aName ]
40 
41  def __str__(self):
42  return str( self.decayModes )
43 
44 tauDecayModes = TauDecayModes()
45 
46 if __name__ == '__main__':
47 
48  dec = TauDecayModes()
49  print dec
50 
51  print 0, dec.intToName(0)
52  print 'kThreeProng0PiZero', dec.nameToInt('kThreeProng0PiZero')
list object
Definition: dbtoconf.py:77