def _x(self,c,o):
     dphi = deltaPhi(c.phi(),self.met.phi())
     codphi = deltaPhi(c.phi(),o.phi())
     if abs(codphi)==math.pi or codphi==0:
         x = 0
     else:
         x = c.pt()/(c.pt() + self.met.et()*(math.cos(dphi) - math.sin(dphi)/math.tan(codphi)))
     # note: large met and small deltaphi between c/o results in large negative values for denom
     # this doesnt work for our boosted topology in a->tt since met resolution is poor
     #if x<0:
     #    print x, c.pt(), self.met.et(), dphi, codphi
     return x
 def _x(self, c, o):
     dphi = deltaPhi(c.phi(), self.met.phi())
     codphi = deltaPhi(c.phi(), o.phi())
     if abs(codphi) == math.pi or codphi == 0:
         x = 0
     else:
         x = c.pt() / (c.pt() + self.met.pt() *
                       (math.cos(dphi) - math.sin(dphi) / math.tan(codphi)))
     # note: large met and small deltaphi between c/o results in large negative values for denom
     # this doesnt work for our boosted topology in a->tt since met resolution is poor
     #if x<0:
     #    print x, c.pt(), self.met.pt(), dphi, codphi
     return x
Exemple #3
0
    def getCompositeVariable(self,rtrow,var,*cands):
        '''Create a composite candidate'''

        key = '_'.join(['{0}_{1}'.format(*cand) for cand in cands] + [var])
        if key in self.cache: return self.cache[key]

        vec = ROOT.TLorentzVector()
        for cand in cands:
            vec += self.getObjectVariable(rtrow,cand,'p4')

        if var=='p4':
            val = vec
        elif var in ['mass','Mass','m','M']:
            val = vec.M()
        elif var in ['pt','Pt']:
            val = vec.Pt()
        elif var in ['eta','Eta']:
            val = vec.Eta()
        elif var in ['phi','Phi']:
            val = vec.Phi()
        elif var in ['energy','Energy']:
            val = vec.Energy()
        elif len(cands)==2:
            if var in ['deltaR','dR','dr','DR']:
                eta1 = self.getObjectVariable(rtrow,cands[0],'eta')
                phi1 = self.getObjectVariable(rtrow,cands[0],'phi')
                eta2 = self.getObjectVariable(rtrow,cands[1],'eta')
                phi2 = self.getObjectVariable(rtrow,cands[1],'phi')
                val = deltaR(eta1,phi1,eta2,phi2)
            elif var in ['deltaPhi','dPhi','dphi','DPhi']:
                phi1 = self.getObjectVariable(rtrow,cands[0],'phi')
                phi2 = self.getObjectVariable(rtrow,cands[1],'phi')
                val = deltaPhi(phi1,phi2)
            elif var in ['deltaEta','dEta','deta','DEta']:
                eta1 = self.getObjectVariable(rtrow,cands[0],'eta')
                eta2 = self.getObjectVariable(rtrow,cands[1],'eta')
                val = abs(eta1-eta2)
            else:
                val = 0
        else:
            val = 0

        self.cache[key] = val
        return val
Exemple #4
0
    def getCompositeMetVariable(self,rtrow,var,met,*cands):
        '''Get composite met variables'''

        key = '_'.join(['{0}_{1}'.format(*cand) for cand in cands] + ['{0}_{1}'.format(*met)] + [var])
        if key in self.cache: return self.cache[key]

        candVec = self.getCompositeVariable(rtrow,'p4',*cands)

        metVec = ROOT.TLorentzVector()
        metPt = self.getObjectVariable(rtrow,met,'et')
        metPhi = self.getObjectVariable(rtrow,met,'phi')
        metVec.SetPtEtaPhiM(metPt,0,metPhi,0)

        vec = candVec + metVec

        if var=='p4':
            val = vec
        elif var in ['mt','Mt','mT','MT']:
            #val = math.sqrt(2*candVec.Pt()*metPt*(1-math.cos(deltaPhi(candVec.Phi(),metPhi))))
            val = math.sqrt(abs((candVec.Et()+metVec.Et())**2 - (vec.Pt())**2))
        elif var in ['mass','Mass','m','M']:
            val = vec.M()
        elif var in ['pt','Pt']:
            val = vec.Pt()
        elif var in ['eta','Eta']:
            val = vec.Eta()
        elif var in ['phi','Phi']:
            val = vec.Phi()
        elif var in ['energy','Energy']:
            val = vec.Energy()
        elif len(cands)==1:
            if var in ['deltaPhi','dPhi','dphi','DPhi']:
                phi1 = self.getObjectVariable(rtrow,cands[0],'phi')
                phi2 = metPhi
                val = deltaPhi(phi1,phi2)
            else:
                val = 0
        else:
            val = 0

        self.cache[key] = val
        return val
 def deltaPhi(self):
     candP4 = self.candP4()
     return deltaPhi(self.met.phi(), candP4.Phi())
 def deltaPhi(self):
     return deltaPhi(self.objects[0].phi(), self.objects[1].phi())
 def deltaPhi(self):
     candP4 = self.candP4()
     return deltaPhi(self.met.phi(),candP4.Phi())
 def deltaPhi(self):
     return deltaPhi(self.objects[0].phi(),
                    self.objects[1].phi())