test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 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 
5  def __init__(self):
6  self._decayModes()

Member Function Documentation

def TauDecayModes.TauDecayModes.__str__ (   self)

Definition at line 41 of file TauDecayModes.py.

References TauDecayModes.TauDecayModes.decayModes.

41 
42  def __str__(self):
43  return str( self.decayModes )
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 
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  '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 self.decayModes.iteritems() )
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 
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"
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().

66 
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)
def TauDecayModes.TauDecayModes.genDecayModeFromJetInt (   self,
  c 
)

Definition at line 48 of file TauDecayModes.py.

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

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

Definition at line 44 of file TauDecayModes.py.

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

44 
45  def genDecayModeInt(self, daughters):
46  dm = self.genDecayMode(daughters)
47  return self.translateGenModeToInt(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 
34  def intToName( self, anInt ):
35  '''Returns the decay mode name corresponding to an int.'''
36  return self.decayModes[ 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 
38  def nameToInt( self, aName ):
39  '''Returns the decay mode int corresponding to a name.'''
40  return self.decayModeNames[ 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 
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

Member Data Documentation

TauDecayModes.TauDecayModes.decayModeNames

Definition at line 30 of file TauDecayModes.py.

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

TauDecayModes.TauDecayModes.decayModes

Definition at line 29 of file TauDecayModes.py.

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