CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions
TauDecayModes.TauDecayModes Class Reference
Inheritance diagram for TauDecayModes.TauDecayModes:

Public Member Functions

def __init__ (self)
 
def __str__ (self)
 
def genDecayModeFromJetInt (self, c)
 
def genDecayModeInt (self, daughters)
 
def intToName (self, anInt)
 
def nameToInt (self, aName)
 
def translateGenModeToInt (self, dm)
 

Static Public Member Functions

def genDecayMode (daughters)
 
def genDecayModeFromGenJet (c)
 

Public Attributes

 decayModeNames
 
 decayModes
 

Private Member Functions

def _decayModes (self)
 

Detailed Description

Definition at line 2 of file TauDecayModes.py.

Constructor & Destructor Documentation

def TauDecayModes.TauDecayModes.__init__ (   self)

Definition at line 4 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes._decayModes().

4  def __init__(self):
5  self._decayModes()
6 

Member Function Documentation

def TauDecayModes.TauDecayModes.__str__ (   self)

Definition at line 42 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.decayModes, and str.

42  def __str__(self):
43  return str( self.decayModes )
44 
#define str(s)
def TauDecayModes.TauDecayModes._decayModes (   self)
private
Builds the internal dictionaries from the enum defined in 
http://cmslxr.fnal.gov/lxr/source/DataFormats/TauReco/interface/PFTau.h

Definition at line 7 of file TauDecayModes.py.

Referenced by TauDecayModes.TauDecayModes.__init__().

7  def _decayModes(self):
8  '''Builds the internal dictionaries from the enum defined in
9  http://cmslxr.fnal.gov/lxr/source/DataFormats/TauReco/interface/PFTau.h'''
10  import six
11  tmp = [
12  'kNull',
13  'kOneProng0PiZero',
14  'kOneProng1PiZero',
15  'kOneProng2PiZero',
16  'kOneProng3PiZero',
17  'kOneProngNPiZero',
18  'kTwoProng0PiZero',
19  'kTwoProng1PiZero',
20  'kTwoProng2PiZero',
21  'kTwoProng3PiZero',
22  'kTwoProngNPiZero',
23  'kThreeProng0PiZero',
24  'kThreeProng1PiZero',
25  'kThreeProng2PiZero',
26  'kThreeProng3PiZero',
27  'kThreeProngNPiZero',
28  'kRareDecayMode'
29  ]
30  self.decayModes = dict( (index-1, name) for index, name in enumerate( tmp ) )
31  self.decayModeNames = dict( (value, key) for key, value \
32  in six.iteritems(self.decayModes) )
33 
def TauDecayModes.TauDecayModes.genDecayMode (   daughters)
static
Returns the generated tau decay mode based on a passed list of all
final daughters before further decay (as contained in miniAOD).

Definition at line 80 of file TauDecayModes.py.

References funct.abs().

Referenced by TauDecayModes.TauDecayModes.genDecayModeInt().

80  def genDecayMode(daughters):
81  ''' Returns the generated tau decay mode based on a passed list of all
82  final daughters before further decay (as contained in miniAOD).
83  '''
84  numElectrons = 0
85  numMuons = 0
86  numChargedHadrons = 0
87  numNeutralHadrons = 0
88  numPhotons = 0
89 
90  for daughter in daughters:
91  pdg_id = abs(daughter.pdgId())
92  if pdg_id == 22:
93  numPhotons += 1
94  elif pdg_id == 11:
95  numElectrons +=1
96  elif pdg_id == 13:
97  numMuons += 1
98  else:
99  if daughter.charge() != 0:
100  numChargedHadrons += 1
101  elif pdg_id not in [12, 14, 16]:
102  numNeutralHadrons += 1
103 
104  if numElectrons == 1:
105  return "electron"
106  if numMuons == 1:
107  return "muon"
108 
109  if numChargedHadrons == 1:
110  if numNeutralHadrons != 0:
111  return "kOneProngOther"
112  if numPhotons == 0:
113  return "kOneProng0PiZero"
114  elif numPhotons == 2:
115  return "kOneProng1PiZero"
116  elif numPhotons == 4:
117  return "kOneProng2PiZero"
118  elif numPhotons == 6:
119  return "kOneProng3PiZero"
120  else:
121  return "kOneProngNPiZero"
122  elif numChargedHadrons == 3:
123  if numNeutralHadrons != 0:
124  return "kThreeProngOther"
125  if numPhotons == 0:
126  return "kThreeProng0PiZero"
127  elif numPhotons == 2:
128  return "kThreeProng1PiZero"
129  elif numPhotons == 4:
130  return "kThreeProng2PiZero"
131  elif numPhotons == 6:
132  return "kThreeProng3PiZero"
133  else:
134  return "kThreeProngNPiZero"
135 
136  return "kRareDecayMode"
137 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def TauDecayModes.TauDecayModes.genDecayModeFromGenJet (   c)
static
Returns generated tau decay mode. Needs to be called on genJet
as stored in pat::Tau, if available.

Translated from PhysicsTools/JetMCUtils/interface/JetMCTag.h,
which is not available in FWlite.

Definition at line 67 of file TauDecayModes.py.

Referenced by TauDecayModes.TauDecayModes.genDecayModeFromJetInt().

68  ''' Returns generated tau decay mode. Needs to be called on genJet
69  as stored in pat::Tau, if available.
70 
71  Translated from PhysicsTools/JetMCUtils/interface/JetMCTag.h,
72  which is not available in FWlite.
73  '''
74 
75  daughters = c.daughterPtrVector()
76 
77  return TauDecayModes.genDecayMode(daughters)
78 
def TauDecayModes.TauDecayModes.genDecayModeFromJetInt (   self,
  c 
)
def TauDecayModes.TauDecayModes.genDecayModeInt (   self,
  daughters 
)

Definition at line 45 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.genDecayMode(), and TauDecayModes.TauDecayModes.translateGenModeToInt().

45  def genDecayModeInt(self, daughters):
46  dm = self.genDecayMode(daughters)
47  return self.translateGenModeToInt(dm)
48 
def genDecayModeInt(self, daughters)
def translateGenModeToInt(self, dm)
def TauDecayModes.TauDecayModes.intToName (   self,
  anInt 
)
Returns the decay mode name corresponding to an int.

Definition at line 34 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.decayModes.

34  def intToName( self, anInt ):
35  '''Returns the decay mode name corresponding to an int.'''
36  return self.decayModes[ anInt ]
37 
def intToName(self, anInt)
def TauDecayModes.TauDecayModes.nameToInt (   self,
  aName 
)
Returns the decay mode int corresponding to a name.

Definition at line 38 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.decayModeNames.

Referenced by TauDecayModes.TauDecayModes.translateGenModeToInt().

38  def nameToInt( self, aName ):
39  '''Returns the decay mode int corresponding to a name.'''
40  return self.decayModeNames[ aName ]
41 
def nameToInt(self, aName)
def TauDecayModes.TauDecayModes.translateGenModeToInt (   self,
  dm 
)

Definition at line 53 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.decayModeNames, and TauDecayModes.TauDecayModes.nameToInt().

Referenced by TauDecayModes.TauDecayModes.genDecayModeFromJetInt(), and TauDecayModes.TauDecayModes.genDecayModeInt().

53  def translateGenModeToInt(self, dm):
54  if dm in self.decayModeNames:
55  return self.nameToInt(dm)
56  elif dm == 'electron':
57  return -11
58  elif dm == 'muon':
59  return -13
60  elif dm == 'kOneProngOther':
61  return 100 # one-prong + 100
62  elif dm == 'kThreeProngOther':
63  return 110 # three-prong + 100
64  return -99
65 
def nameToInt(self, aName)
def translateGenModeToInt(self, dm)

Member Data Documentation

TauDecayModes.TauDecayModes.decayModeNames
TauDecayModes.TauDecayModes.decayModes