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)
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  tmp = [
11  'kNull',
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-1, name) for index, name in enumerate( tmp ) )
30  self.decayModeNames = dict( (value, key) for key, value \
31  in self.decayModes.iteritems() )
32 
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 79 of file TauDecayModes.py.

References funct.abs().

Referenced by TauDecayModes.TauDecayModes.genDecayModeInt().

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

Referenced by TauDecayModes.TauDecayModes.genDecayModeFromJetInt().

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

Definition at line 44 of file TauDecayModes.py.

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

44  def genDecayModeInt(self, daughters):
45  dm = self.genDecayMode(daughters)
46  return self.translateGenModeToInt(dm)
47 
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 33 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.decayModes.

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

Definition at line 37 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.decayModeNames.

Referenced by TauDecayModes.TauDecayModes.translateGenModeToInt().

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

Definition at line 52 of file TauDecayModes.py.

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

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

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

Member Data Documentation

TauDecayModes.TauDecayModes.decayModeNames
TauDecayModes.TauDecayModes.decayModes