8 '''Builds the internal dictionaries from the enum defined in
9 http://cmslxr.fnal.gov/lxr/source/DataFormats/TauReco/interface/PFTau.h'''
29 self.
decayModes =
dict( (index-1, name)
for index, name
in enumerate( tmp ) )
31 in self.decayModes.iteritems() )
34 '''Returns the decay mode name corresponding to an int.'''
38 '''Returns the decay mode int corresponding to a name.'''
55 elif dm ==
'electron':
59 elif dm ==
'kOneProngOther':
61 elif dm ==
'kThreeProngOther':
67 ''' Returns generated tau decay mode. Needs to be called on genJet
68 as stored in pat::Tau, if available.
70 Translated from PhysicsTools/JetMCUtils/interface/JetMCTag.h,
71 which is not available in FWlite.
74 daughters = c.daughterPtrVector()
76 return TauDecayModes.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).
89 for daughter
in daughters:
90 pdg_id =
abs(daughter.pdgId())
98 if daughter.charge() != 0:
99 numChargedHadrons += 1
100 elif pdg_id
not in [12, 14, 16]:
101 numNeutralHadrons += 1
103 if numElectrons == 1:
108 if numChargedHadrons == 1:
109 if numNeutralHadrons != 0:
110 return "kOneProngOther"
112 return "kOneProng0PiZero"
113 elif numPhotons == 2:
114 return "kOneProng1PiZero"
115 elif numPhotons == 4:
116 return "kOneProng2PiZero"
117 elif numPhotons == 6:
118 return "kOneProng3PiZero"
120 return "kOneProngNPiZero"
121 elif numChargedHadrons == 3:
122 if numNeutralHadrons != 0:
123 return "kThreeProngOther"
125 return "kThreeProng0PiZero"
126 elif numPhotons == 2:
127 return "kThreeProng1PiZero"
128 elif numPhotons == 4:
129 return "kThreeProng2PiZero"
130 elif numPhotons == 6:
131 return "kThreeProng3PiZero"
133 return "kThreeProngNPiZero"
135 return "kRareDecayMode"
139 if __name__ ==
'__main__':
144 print 0, dec.intToName(0)
145 print 'kThreeProng0PiZero', dec.nameToInt(
'kThreeProng0PiZero')
def genDecayModeFromGenJet
Abs< T >::type abs(const T &t)
def translateGenModeToInt
def genDecayModeFromJetInt