CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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__
 
def __str__
 
def genDecayModeFromJetInt
 
def genDecayModeInt
 
def intToName
 
def nameToInt
 
def translateGenModeToInt
 

Static Public Member Functions

def genDecayMode
 
def genDecayModeFromGenJet
 

Public Attributes

 decayModeNames
 
 decayModes
 

Private Member Functions

def _decayModes
 

Detailed Description

Definition at line 3 of file TauDecayModes.py.

Constructor & Destructor Documentation

def TauDecayModes.TauDecayModes.__init__ (   self)

Definition at line 5 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes._decayModes().

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

Member Function Documentation

def TauDecayModes.TauDecayModes.__str__ (   self)

Definition at line 42 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.decayModes, and str.

42 
43  def __str__(self):
44  return str( self.decayModes )
#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 8 of file TauDecayModes.py.

Referenced by TauDecayModes.TauDecayModes.__init__().

8 
9  def _decayModes(self):
10  '''Builds the internal dictionaries from the enum defined in
11  http://cmslxr.fnal.gov/lxr/source/DataFormats/TauReco/interface/PFTau.h'''
12  tmp = [
13  'kNull',
14  'kOneProng0PiZero',
15  'kOneProng1PiZero',
16  'kOneProng2PiZero',
17  'kOneProng3PiZero',
18  'kOneProngNPiZero',
19  'kTwoProng0PiZero',
20  'kTwoProng1PiZero',
21  'kTwoProng2PiZero',
22  'kTwoProng3PiZero',
23  'kTwoProngNPiZero',
24  'kThreeProng0PiZero',
25  'kThreeProng1PiZero',
26  'kThreeProng2PiZero',
27  'kThreeProng3PiZero',
28  'kThreeProngNPiZero',
29  'kRareDecayMode'
30  ]
31  self.decayModes = dict( (index-1, name) for index, name in enumerate( tmp ) )
32  self.decayModeNames = dict( (value, key) for key, value \
33  in self.decayModes.items() )
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 
81  def genDecayMode(daughters):
82  ''' Returns the generated tau decay mode based on a passed list of all
83  final daughters before further decay (as contained in miniAOD).
84  '''
85  numElectrons = 0
86  numMuons = 0
87  numChargedHadrons = 0
88  numNeutralHadrons = 0
89  numPhotons = 0
90 
91  for daughter in daughters:
92  pdg_id = abs(daughter.pdgId())
93  if pdg_id == 22:
94  numPhotons += 1
95  elif pdg_id == 11:
96  numElectrons +=1
97  elif pdg_id == 13:
98  numMuons += 1
99  else:
100  if daughter.charge() != 0:
101  numChargedHadrons += 1
102  elif pdg_id not in [12, 14, 16]:
103  numNeutralHadrons += 1
104 
105  if numElectrons == 1:
106  return "electron"
107  if numMuons == 1:
108  return "muon"
109 
110  if numChargedHadrons == 1:
111  if numNeutralHadrons != 0:
112  return "kOneProngOther"
113  if numPhotons == 0:
114  return "kOneProng0PiZero"
115  elif numPhotons == 2:
116  return "kOneProng1PiZero"
117  elif numPhotons == 4:
118  return "kOneProng2PiZero"
119  elif numPhotons == 6:
120  return "kOneProng3PiZero"
121  else:
122  return "kOneProngNPiZero"
123  elif numChargedHadrons == 3:
124  if numNeutralHadrons != 0:
125  return "kThreeProngOther"
126  if numPhotons == 0:
127  return "kThreeProng0PiZero"
128  elif numPhotons == 2:
129  return "kThreeProng1PiZero"
130  elif numPhotons == 4:
131  return "kThreeProng2PiZero"
132  elif numPhotons == 6:
133  return "kThreeProng3PiZero"
134  else:
135  return "kThreeProngNPiZero"
136 
137  return "kRareDecayMode"
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().

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

Definition at line 49 of file TauDecayModes.py.

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

49 
50  def genDecayModeFromJetInt(self, c):
51  dm = self.genDecayModeFromGenJet(c)
52  return self.translateGenModeToInt(dm)
def TauDecayModes.TauDecayModes.genDecayModeInt (   self,
  daughters 
)

Definition at line 45 of file TauDecayModes.py.

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

45 
46  def genDecayModeInt(self, daughters):
47  dm = self.genDecayMode(daughters)
48  return self.translateGenModeToInt(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 
35  def intToName( self, anInt ):
36  '''Returns the decay mode name corresponding to an int.'''
37  return self.decayModes[ 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 
39  def nameToInt( self, aName ):
40  '''Returns the decay mode int corresponding to a name.'''
41  return self.decayModeNames[ 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 
54  def translateGenModeToInt(self, dm):
55  if dm in self.decayModeNames:
56  return self.nameToInt(dm)
57  elif dm == 'electron':
58  return -11
59  elif dm == 'muon':
60  return -13
61  elif dm == 'kOneProngOther':
62  return 100 # one-prong + 100
63  elif dm == 'kThreeProngOther':
64  return 110 # three-prong + 100
65  return -99

Member Data Documentation

TauDecayModes.TauDecayModes.decayModeNames

Definition at line 31 of file TauDecayModes.py.

Referenced by TauDecayModes.TauDecayModes.nameToInt(), and TauDecayModes.TauDecayModes.translateGenModeToInt().

TauDecayModes.TauDecayModes.decayModes

Definition at line 30 of file TauDecayModes.py.

Referenced by TauDecayModes.TauDecayModes.__str__(), and TauDecayModes.TauDecayModes.intToName().