CMS 3D CMS Logo

DiObject.py
Go to the documentation of this file.
1 import math
2 
3 from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Muon, Tau, Electron
5 from PhysicsTools.Heppy.physicsobjects.HTauTauElectron import HTauTauElectron
6 from CMGTools.RootTools.utils.DeltaR import deltaR2
7 
9  '''Generic di-object class, to handle di-objects from the EDM file
10  '''
11 
12  def __init__(self, diobject):
13  '''diobject is the di-object read from the edm file'''
14  self.diobject = diobject
15  self.leg1Gen = None
16  self.leg2Gen = None
17  self.leg1DeltaR = -1
18  self.leg2DeltaR = -1
19  super(DiObject, self).__init__(diobject)
20 
21  def sumPt(self):
22  '''pt_leg1 + pt_leg2, e.g. used for finding the best DiTau.'''
23  return self.leg1().pt() + self.leg2().pt()
24 
25  def __str__(self):
26  header = '{cls}: mvis={mvis}, mT={mt}, sumpT={sumpt}'.format(
27  cls = self.__class__.__name__,
28  mvis = self.diobject.mass(),
29  mt = self.diobject.mTLeg2(),
30  sumpt = self.sumPt() )
31  return '\n'.join( [header,
32  '\t'+str(self.leg1()),
33  '\t'+str(self.leg2())] )
34 
35 
36 
37 class DiMuon( DiObject ):
38 
39  def __init__(self, diobject):
40  super(DiMuon, self).__init__(diobject)
41  self.mu1 = Muon( diobject.leg1() )
42  self.mu2 = Muon( diobject.leg2() )
43 
44  def leg1(self):
45  return self.mu1
46 
47  def leg2(self):
48  return self.mu2
49 
50  def __str__(self):
51  return 'DiMuon: mass={mass:5.2f}, sumpt={sumpt:5.2f}, pt={pt:5.2f}'.format(
52  mass = self.mass(),
53  sumpt = self.sumPt(),
54  pt = self.pt()
55  )
56 
57 
59 
60  def __init__(self, diobject):
61  super(DiElectron, self).__init__(diobject)
62  self.ele1 = Electron( diobject.leg1() )
63  self.ele2 = Electron( diobject.leg2() )
64 
65  def leg1(self):
66  return self.ele1
67 
68  def leg2(self):
69  return self.ele2
70 
71  def __str__(self):
72  header = 'DiElectron: mvis=%3.2f, sumpT=%3.2f' \
73  % (self.diobject.mass(),
74  self.sumPt() )
75  return '\n'.join( [header] )
76 
77 
78 class DiTau( DiObject ):
79  def __init__(self, diobject):
80  super(DiTau, self).__init__(diobject)
81 
82  def match(self, genParticles):
83  #TODO review matching algorithm
84  #TODO move matching stuff even higher?
85  # print self
86  genTaus = []
87  ZorPhotonorHiggs = [22, 23, 25, 35, 36, 37]
88  for gen in genParticles:
89  # print '\t', gen
90  if abs(gen.pdgId())==15 and gen.mother().pdgId() in ZorPhotonorHiggs:
91  genTaus.append( gen )
92  # print 'Gen taus: '
93  # print '\n'.join( map( str, genTaus ) )
94  if len(genTaus)!=2:
95  #COLIN what about WW, ZZ?
96  return (-1, -1)
97  else:
98  dR2leg1Min, self.leg1Gen = ( float('inf'), None)
99  dR2leg2Min, self.leg2Gen = ( float('inf'), None)
100  for genTau in genTaus:
101  dR2leg1 = deltaR2(self.leg1().eta(), self.leg1().phi(),
102  genTau.eta(), genTau.phi() )
103  dR2leg2 = deltaR2(self.leg2().eta(), self.leg2().phi(),
104  genTau.eta(), genTau.phi() )
105  if dR2leg1 < dR2leg1Min:
106  dR2leg1Min, self.leg1Gen = (dR2leg1, genTau)
107  if dR2leg2 < dR2leg2Min:
108  dR2leg2Min, self.leg2Gen = (dR2leg2, genTau)
109  # print dR2leg1Min, dR2leg2Min
110  # print self.leg1Gen
111  # print self.leg2Gen
112  self.leg1DeltaR = math.sqrt( dR2leg1Min )
113  self.leg2DeltaR = math.sqrt( dR2leg2Min )
114  return (self.leg1DeltaR, self.leg2DeltaR)
115 
116 
117 class TauMuon( DiTau ):
118  '''Holds a CMG TauMuon, and the 2 legs as a python Tau and Muon'''
119  def __init__(self, diobject):
120  super(TauMuon, self).__init__(diobject)
121  self.tau = Tau( self.leg1() )
122  self.mu = Muon( self.leg2() )
123 
124  def leg1(self):
125  return self.tau
126 
127  def leg2(self):
128  return self.mu
129 
130 
131 
133  def __init__(self, diobject):
134  super(TauElectron, self).__init__(diobject)
135  self.tau = Tau( diobject.leg1() )
136  self.ele = HTauTauElectron( diobject.leg2() )
137 
138  def leg1(self):
139  return self.tau
140 
141  def leg2(self):
142  return self.ele
143 
144 
146  def __init__(self, diobject):
147  super(MuonElectron, self).__init__(diobject)
148  self.mu = Muon( diobject.leg1() )
149  self.ele = HTauTauElectron( diobject.leg2() )
150 
151  def leg1(self):
152  return self.mu
153 
154  def leg2(self):
155  return self.ele
156 
157 
158 class TauTau( DiTau ):
159  def __init__(self, diobject):
160  super(TauTau, self).__init__(diobject)
161  self.tau = Tau( diobject.leg1() )
162  self.tau2 = Tau( diobject.leg2() )
163 
164  def leg1(self):
165  return self.tau
166 
167  def leg2(self):
168  return self.tau2
169 
170 
PhysicsObject
DiObject.TauElectron.leg2
def leg2(self)
Definition: DiObject.py:141
DiObject.DiObject.leg1DeltaR
leg1DeltaR
Definition: DiObject.py:17
DiObject.DiTau.__init__
def __init__(self, diobject)
Definition: DiObject.py:79
DiObject.MuonElectron.ele
ele
Definition: DiObject.py:149
DiObject.DiElectron.ele2
ele2
Definition: DiObject.py:63
DiObject.DiObject.sumPt
def sumPt(self)
Definition: DiObject.py:21
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
DiObject.TauElectron.ele
ele
Definition: DiObject.py:136
DiObject.TauTau
Definition: DiObject.py:158
DiObject.TauMuon.leg2
def leg2(self)
Definition: DiObject.py:127
DiObject.DiObject.leg1Gen
leg1Gen
Definition: DiObject.py:15
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
DiObject.TauTau.tau
tau
Definition: DiObject.py:161
Electron
Definition: Electron.py:1
DiObject.DiElectron.__init__
def __init__(self, diobject)
Definition: DiObject.py:60
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
DiObject.DiElectron.ele1
ele1
Definition: DiObject.py:62
Tau
Definition: Tau.py:1
DiObject.TauTau.tau2
tau2
Definition: DiObject.py:162
DiObject.DiElectron.leg2
def leg2(self)
Definition: DiObject.py:68
Muon
Definition: Muon.py:1
DiObject.MuonElectron.leg2
def leg2(self)
Definition: DiObject.py:154
DiObject.DiMuon.leg1
def leg1(self)
Definition: DiObject.py:44
DiObject.TauMuon.mu
mu
Definition: DiObject.py:122
DiObject.TauTau.leg1
def leg1(self)
Definition: DiObject.py:164
DiObject.DiMuon.__init__
def __init__(self, diobject)
Definition: DiObject.py:39
DiObject.DiMuon
Definition: DiObject.py:37
DiObject.DiObject.leg2DeltaR
leg2DeltaR
Definition: DiObject.py:18
DiObject.DiObject.__str__
def __str__(self)
Definition: DiObject.py:25
PVValHelper::eta
Definition: PVValidationHelpers.h:70
DiObject.DiMuon.__str__
def __str__(self)
Definition: DiObject.py:50
DiObject.TauElectron.__init__
def __init__(self, diobject)
Definition: DiObject.py:133
str
#define str(s)
Definition: TestProcessor.cc:53
DiObject.TauElectron.tau
tau
Definition: DiObject.py:135
DiObject.TauMuon
Definition: DiObject.py:117
DiObject.DiObject.__init__
def __init__(self, diobject)
Definition: DiObject.py:12
DiObject.DiTau.match
def match(self, genParticles)
Definition: DiObject.py:82
DiObject.TauTau.leg2
def leg2(self)
Definition: DiObject.py:167
DiObject.DiElectron.__str__
def __str__(self)
Definition: DiObject.py:71
DiObject.DiMuon.leg2
def leg2(self)
Definition: DiObject.py:47
DiObject.DiObject
Definition: DiObject.py:8
DiObject.MuonElectron.__init__
def __init__(self, diobject)
Definition: DiObject.py:146
DiObject.DiElectron
Definition: DiObject.py:58
DiObject.TauElectron
Definition: DiObject.py:132
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:117
DiObject.MuonElectron.mu
mu
Definition: DiObject.py:148
DiObject.DiObject.leg2Gen
leg2Gen
Definition: DiObject.py:16
DiObject.MuonElectron
Definition: DiObject.py:145
PhysicsObject
Definition: PhysicsObject.py:1
DiObject.TauElectron.leg1
def leg1(self)
Definition: DiObject.py:138
DiObject.DiElectron.leg1
def leg1(self)
Definition: DiObject.py:65
DiObject.DiMuon.mu2
mu2
Definition: DiObject.py:42
DiObject.TauMuon.leg1
def leg1(self)
Definition: DiObject.py:124
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
DiObject.TauMuon.__init__
def __init__(self, diobject)
Definition: DiObject.py:119
format
DiObject.DiObject.diobject
diobject
Definition: DiObject.py:14
DiObject.DiMuon.mu1
mu1
Definition: DiObject.py:41
DiObject.DiTau
Definition: DiObject.py:78
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DiObject.TauTau.__init__
def __init__(self, diobject)
Definition: DiObject.py:159
DiObject.TauMuon.tau
tau
Definition: DiObject.py:121
DiObject.MuonElectron.leg1
def leg1(self)
Definition: DiObject.py:151