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 3 of file TauDecayModes.py.

Constructor & Destructor Documentation

◆ __init__()

def TauDecayModes.TauDecayModes.__init__ (   self)

Definition at line 5 of file TauDecayModes.py.

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

References TauDecayModes.TauDecayModes._decayModes().

Member Function Documentation

◆ __str__()

def TauDecayModes.TauDecayModes.__str__ (   self)

Definition at line 43 of file TauDecayModes.py.

43  def __str__(self):
44  return str( self.decayModes )
45 

References TauDecayModes.TauDecayModes.decayModes, and str.

◆ _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 8 of file TauDecayModes.py.

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  import six
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 six.iteritems(self.decayModes) )
34 

Referenced by TauDecayModes.TauDecayModes.__init__().

◆ genDecayMode()

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 81 of file TauDecayModes.py.

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"
138 

References funct.abs().

Referenced by TauDecayModes.TauDecayModes.genDecayModeInt().

◆ genDecayModeFromGenJet()

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 68 of file TauDecayModes.py.

68  def genDecayModeFromGenJet(c):
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)
79 

Referenced by TauDecayModes.TauDecayModes.genDecayModeFromJetInt().

◆ genDecayModeFromJetInt()

def TauDecayModes.TauDecayModes.genDecayModeFromJetInt (   self,
  c 
)

Definition at line 50 of file TauDecayModes.py.

50  def genDecayModeFromJetInt(self, c):
51  dm = self.genDecayModeFromGenJet(c)
52  return self.translateGenModeToInt(dm)
53 

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

◆ genDecayModeInt()

def TauDecayModes.TauDecayModes.genDecayModeInt (   self,
  daughters 
)

Definition at line 46 of file TauDecayModes.py.

46  def genDecayModeInt(self, daughters):
47  dm = self.genDecayMode(daughters)
48  return self.translateGenModeToInt(dm)
49 

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

◆ intToName()

def TauDecayModes.TauDecayModes.intToName (   self,
  anInt 
)
Returns the decay mode name corresponding to an int.

Definition at line 35 of file TauDecayModes.py.

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

References TauDecayModes.TauDecayModes.decayModes.

◆ nameToInt()

def TauDecayModes.TauDecayModes.nameToInt (   self,
  aName 
)
Returns the decay mode int corresponding to a name.

Definition at line 39 of file TauDecayModes.py.

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

References TauDecayModes.TauDecayModes.decayModeNames.

Referenced by TauDecayModes.TauDecayModes.translateGenModeToInt().

◆ translateGenModeToInt()

def TauDecayModes.TauDecayModes.translateGenModeToInt (   self,
  dm 
)

Definition at line 54 of file TauDecayModes.py.

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
66 

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

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

Member Data Documentation

◆ decayModeNames

TauDecayModes.TauDecayModes.decayModeNames

◆ decayModes

TauDecayModes.TauDecayModes.decayModes
str
#define str(s)
Definition: TestProcessor.cc:52
TriggerAnalyzer.__str__
def __str__(self)
Definition: TriggerAnalyzer.py:103
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22