示例#1
0
def isGoodBaseEvent(Chain, needPromptTau=False):

    nLooseTau = 0.
    lIndex = []
    for l in xrange(Chain._nL):
        if objectSelection.isGoodLightLepton(Chain, l):
            lIndex.append(l)
        elif objectSelection.isLooseTau(Chain, l, needPromptTau):
            lIndex.append(l)
            nLooseTau += 1.

    if len(lIndex) != 3: return -1

    if nLooseTau != 1: return -1

    #By now the first two should be light flavor and the third a tau since they were added last
    if Chain._lFlavor[lIndex[0]] != Chain._lFlavor[1]: return -1
    if Chain._lCharge[lIndex[0]] == Chain._lCharge[lIndex[1]]: return -1

    if Chain._met > 50: return -1

    l1 = TLorentzVector()
    l2 = TLorentzVector()

    l1.SetPtEtaPhiE(Chain._lPt[lIndex[0]], Chain._lEta[lIndex[0]],
                    Chain._lPhi[lIndex[0]], Chain._lE[lIndex[0]])
    l2.SetPtEtaPhiE(Chain._lPt[lIndex[1]], Chain._lEta[lIndex[1]],
                    Chain._lPhi[lIndex[1]], Chain._lE[lIndex[1]])
    if abs((l1 + l2).M() - 91.19) > 15: return -1

    return lIndex[2]
示例#2
0
    def invMass(self, leptons, types):
        if (len(leptons) != len(types)):
            self.msg.warning('invMass len(leptons)!=len(types) %i != %i' %
                             (len(leptons), len(types)))
            return -9999.

        result = TLorentzVector(0, 0, 0, 0)

        for iLept in range(len(leptons)):
            fourMomentum = TLorentzVector()
            # Electron: calculate 4-momentum based on cluster energy and track direction
            # Muon: use 4-momentum of the muon object
            if types[iLept] == "e":
                if leptons[iLept].cluster() and leptons[iLept].trackParticle():
                    fourMomentum.SetPtEtaPhiE(leptons[iLept].cluster().e()/math.cosh(leptons[iLept].trackParticle().eta()), \
                                              leptons[iLept].trackParticle().eta(), \
                                              leptons[iLept].trackParticle().phi(), \
                                              leptons[iLept].cluster().e())
                else:
                    fourMomentum.SetPtEtaPhiE(leptons[iLept].et(),
                                              leptons[iLept].eta(),
                                              leptons[iLept].phi(),
                                              leptons[iLept].e())
            else:
                fourMomentum.SetPtEtaPhiE(leptons[iLept].pt(),
                                          leptons[iLept].eta(),
                                          leptons[iLept].phi(),
                                          leptons[iLept].e())
            result = result + fourMomentum

        #print "total TLV is ", result.Px(),result.Py(),result.Pz(),result.E()
        return result.M()
示例#3
0
def ZMassReconstructed(Chain):

    bestMassDiff = 9999999.
    #Start looping over the first leptons
    for l1 in xrange(ord(Chain._nL) - 1):
        if not Chain._lPOGTight[l1] or Chain._lFlavor[l1] == 2: continue
        l1Vec = TLorentzVector()
        l1Vec.SetPtEtaPhiE(Chain._lPt[l1], Chain._lEta[l1], Chain._lPhi[l1],
                           Chain._lE[l1])

        #Start looping over the second lepton
        for l2 in xrange(l1 + 1, ord(Chain._nL)):
            if (not Chain._lPOGTight[l2] or Chain._lFlavor[l2] == 2): continue
            if (Chain._lFlavor[l1] != Chain._lFlavor[l2]): continue

            l2Vec = TLorentzVector()
            l2Vec.SetPtEtaPhiE(Chain._lPt[l2], Chain._lEta[l2],
                               Chain._lPhi[l2], Chain._lE[l2])
            mass = (l1Vec + l2Vec).M()

            if (abs(mass - 91.1876) < bestMassDiff):
                bestMassDiff = abs(mass - 91.1876)

            #print l1, l2, mass, bestMassDiff

    if bestMassDiff < 10.: return True

    return False
示例#4
0
def invariantMass(l_4vector1, l_4vector2):
  """Calculate the invariant mass of two TLorentzVectors"""

  tlv1 = TLorentzVector()
  tlv2 = TLorentzVector()
  tlv1.SetPtEtaPhiE(l_4vector1[0], l_4vector1[1], l_4vector1[2], l_4vector1[3])
  tlv2.SetPtEtaPhiE(l_4vector2[0], l_4vector2[1], l_4vector2[2], l_4vector2[3])

  return (tlv1 + tlv2).M()
def inv2(lepton):
    pt = lepton.lep_pt
    eta = lepton.lep_eta
    phi = lepton.lep_phi
    E = lepton.lep_E
    Lvec1 = TLorentzVector()
    Lvec1.SetPtEtaPhiE(pt[0], eta[0], phi[0], E[0])
    Lvec2 = TLorentzVector()
    Lvec2.SetPtEtaPhiE(pt[1], eta[1], phi[1], E[1])
    Lvec = Lvec1 + Lvec2
    return Lvec.M() / 1000
示例#6
0
def getHiggsMass(entry, tName, debug):
    # we are looping over jets, each has the information of Pt, Eta, Phi, E
    # they are available at different calibration stages:
    # Nominal, OneMu, PtRecoBukin, PtRecoGauss, Regression
    # we also know what is the correct simulated information: Parton
    # we want to compare the different calibrations and see which one
    # models better the Higgs boson mass
    # all Pt, E, M are in GeV
    # Higgs -> bb, meaning the b1 and b2 in this tree
    # let's see how we get a variable from the tree

    # jet 1
    # >>> b1 <<<
    b1_Opt_Pt, b1_Opt_Eta, b1_Opt_Phi, b1_Opt_E = getSpecificData(entry=entry,
                                                                  tName=tName,
                                                                  bVal="b1",
                                                                  debug=debug)
    b1_Opt_tlv = TLorentzVector()
    b1_Opt_tlv.SetPtEtaPhiE(b1_Opt_Pt, b1_Opt_Eta, b1_Opt_Phi, b1_Opt_E)
    b1_Opt_M = b1_Opt_tlv.M()
    if debug:
        print "b1_%s_M" % (tName), b1_Opt_M

    # jet 2
    # >>> b2 <<<
    b2_Opt_Pt, b2_Opt_Eta, b2_Opt_Phi, b2_Opt_E = getSpecificData(entry=entry,
                                                                  tName=tName,
                                                                  bVal="b2",
                                                                  debug=debug)
    b2_Opt_tlv = TLorentzVector()
    b2_Opt_tlv.SetPtEtaPhiE(b2_Opt_Pt, b2_Opt_Eta, b2_Opt_Phi, b2_Opt_E)
    b2_Opt_M = b2_Opt_tlv.M()
    if debug:
        print "b2_%s_M" % (tName), b2_Opt_M

    # Higgs boson candidate decaying to b1 and b2
    # TLorentzVector is the sum of the two TLorentzVectors
    Higgs_Opt_tlv = b1_Opt_tlv + b2_Opt_tlv
    Higgs_Opt_Pt = Higgs_Opt_tlv.Pt()
    Higgs_Opt_Eta = Higgs_Opt_tlv.Eta()
    Higgs_Opt_Phi = Higgs_Opt_tlv.Phi()
    Higgs_Opt_E = Higgs_Opt_tlv.E()
    if debug:
        print "Higgs_%s_Pt" % (tName), Higgs_Opt_Pt
        print "Higgs_%s_Eta" % (tName), Higgs_Opt_Eta
        print "Higgs_%s_Phi" % (tName), Higgs_Opt_Phi
        print "Higgs_&s_E" % (tName), Higgs_Opt_E
    Higgs_Opt_M = Higgs_Opt_tlv.M()
    if debug:
        print "Higgs_%s_M" % (tName), Higgs_Opt_M
    # the mass should be 125, but when measured we get a distribution around 125

    return Higgs_Opt_M
示例#7
0
def Return_mTbs(jet, metPt, metPhi):
    #setting of the 4vectors seems fine naeively?
    met4Vec = TLorentzVector()
    met4Vec.SetPtEtaPhiE(metPt, 0, metPhi, metPt)
    bjet4Vec = TLorentzVector()
    bjet4Vec.SetPtEtaPhiE(jet[0], jet[1], jet[2], jet[3])

    mTb = (met4Vec + bjet4Vec).Mt()  # this assumes masses for the b-jet

    #using 4vectors and dPhi method (massless particles)
    mTb0 = math.sqrt(2. * met4Vec.Et() * bjet4Vec.Et() *
                     (1. - math.cos(met4Vec.DeltaPhi(bjet4Vec))))

    return {'mTb_mass': mTb, 'mTb_massless': mTb0}
示例#8
0
def calcCosThetaStar(j1, j2):
    """docstring for calcCosThetaStar"""

    tmpCM1 = j1 + j2
    tmpJ1 = TLorentzVector()
    tmpJ2 = TLorentzVector()
    tmpJ1.SetPtEtaPhiE(j1.Pt(), j1.Eta(), j1.Phi(), j1.E())
    tmpJ2.SetPtEtaPhiE(j2.Pt(), j2.Eta(), j2.Phi(), j2.E())
    tmpJ1.Boost(-tmpCM1.BoostVector())
    tmpJ2.Boost(-tmpCM1.BoostVector())
    tmpV1 = TVector3(tmpJ1.X(), tmpJ1.Y(), tmpJ1.Z())
    tmpV2 = TVector3(tmpJ2.X(), tmpJ2.Y(), tmpJ2.Z())
    #cosThetaStar1 = abs( ( ( pairoff08[1].Px() * pairoff08[2].Px() ) + ( pairoff08[1].Py() * pairoff08[2].Py() ) + ( pairoff08[1].Pz() * pairoff08[2].Pz() ) )  / ( pairoff08[1].E() * pairoff08[2].E() ) )
    cosThetaStar = abs(tmpV1.CosTheta())

    return cosThetaStar
示例#9
0
 def getFourMomentum(self, obj, number):
     fourMomentum = TLorentzVector(0, 0, 0, 0)
     # Electron: calculate 4-momentum based on cluster energy and track direction
     # ET cut is used for electrons
     if self.cutDict["types"][number] == "e":
         if obj.cluster() and obj.trackParticle() and abs(
                 obj.trackParticle().eta()) < 300.:
             fourMomentum.SetPtEtaPhiE(obj.cluster().e()/math.cosh(obj.trackParticle().eta()), \
                                       obj.trackParticle().eta(), obj.trackParticle().phi(), \
                                       obj.cluster().e())
         else:
             fourMomentum.SetPtEtaPhiE(obj.et(), obj.eta(), obj.phi(),
                                       obj.e())
     else:
         fourMomentum.SetPtEtaPhiE(obj.pt(), obj.eta(), obj.phi(), obj.e())
     return fourMomentum
示例#10
0
def getTLV(particle, derivation, entry):

    prefix = particle + "_" + derivation

    attnamePt = prefix + "_Pt"
    b_Pt = getattr(entry, attnamePt)

    attnameEta = prefix + "_Eta"
    b_Eta = getattr(entry, attnameEta)

    attnamePhi = prefix + "_Phi"
    b_Phi = getattr(entry, attnamePhi)

    attnameE = prefix + "_E"
    b_E = getattr(entry, attnameE)

    if debug:
        print "b_Pt", b_Pt
        print "b_Eta", b_Eta
        print "b_Phi", b_Phi
        print "b_E", b_E

    #define TLorentzvec
    b_tlv = TLorentzVector()
    b_tlv.SetPtEtaPhiE(b_Pt, b_Eta, b_Phi, b_E)

    return b_tlv
示例#11
0
    def get_jets_vectors(self):
        '''
        Returns a list of 4-momenta for jets looking only at jets
        that are cleaned from FatJets.
        A list of indexes in the collection of CleanJet is returned as a reference. 
        '''
        jets = []
        coll_ids = []
        for ijnf in range(len(self.JetNotFat_coll)):
            jetindex = self.JetNotFat_coll[ijnf].jetIdx
            # index in the original Jet collection
            rawjetid = self.Jet_coll[jetindex].jetIdx
            pt, eta, phi, mass = self.Jet_coll[jetindex].pt, \
                        self.Jet_coll[jetindex].eta,\
                        self.Jet_coll[jetindex].phi, \
                        self.rawJet_coll[rawjetid].mass

            if abs(eta) > 10: continue
            p = pt * cosh(eta)
            en = sqrt(p**2 + mass**2)
            vec = TLorentzVector()
            vec.SetPtEtaPhiE(pt, eta, phi, en)
            # check if different from the previous one
            if self.debug:
                print "Jet index: ", jetindex, "> pt:", pt, " eta:", eta, " phi:", phi, " mass:", mass
            jets.append(vec)
            coll_ids.append(jetindex)
        return jets, coll_ids
示例#12
0
def matchHasOverlap(Chain, index):  #Only works for taus at the moment
    hasOverlap = False
    inputVec = TLorentzVector()
    inputVec.SetPtEtaPhiE(Chain._lMatchPt[index], Chain._lMatchEta[index],
                          Chain._lMatchPhi[index], Chain._lMatchE[index])

    for l in xrange(ord(Chain._gen_nL)):
        if l == index or Chain._gen_lFlavor == 2: continue

        lVec = TLorentzVector()
        lVec.SetPtEtaPhiE(Chain._gen_lPt[l], Chain._gen_lEta[l],
                          Chain._gen_lPhi[l], Chain._gen_lE[l])

        dR = inputVec.DeltaR(lVec)
        if dR < .4: hasOverlap = True

    return hasOverlap
示例#13
0
文件: muons.py 项目: sebj101/muons
def four_momentum(i_lepton, tree):
    pt = tree.lep_pt[i_lepton]
    eta = tree.lep_eta[i_lepton]
    phi = tree.lep_phi[i_lepton]
    E = tree.lep_E[i_lepton]
    p = TLorentzVector()
    p.SetPtEtaPhiE(pt, eta, phi, E)
    return p
示例#14
0
 def passedInvariantMassCuts(self, lIndices):
     vec = []
     for l in lIndices:
         v = TLorentzVector()
         v.SetPtEtaPhiE(self.Chain._lPt[l], self.Chain._lEta[l], self.Chain._lPhi[l], self.Chain._lE[l])
         vec.append(v)
     Mlll = (vec[0] + vec[1] + vec[2]).M()
     if abs(Mlll-91.19) < 15 :  return False
     return True
示例#15
0
def isCleanJet(Chain, index):

    if Chain._jetPt[index] < 25.: return False

    if not Chain._jetIsTight[index]: return False

    jetVec = TLorentzVector()
    jetVec.SetPtEtaPhiE(Chain._jetPt[index], Chain._jetEta[index],
                        Chain._jetPhi[index], Chain._jetE[index])

    for l in xrange(Chain._nL):
        lVec = TLorentzVector()
        lVec.SetPtEtaPhiE(Chain._lPt[l], Chain._lEta[l], Chain._lPhi[l],
                          Chain._lE[l])
        if jetVec.DeltaR(lVec) < 0.4:
            return False

    return True
示例#16
0
def Return_Top(jet, id_csv, metPhi):

    masses = [-1000, -1000, -1000, -1000, -1000, -1000]

    b_tmp = TLorentzVector()
    b_tmp.SetPtEtaPhiE(jet[id_csv][0], jet[id_csv][1], jet[id_csv][2],
                       jet[id_csv][3])
    jet_nob = list(jet)
    jet_nob.pop(id_csv)

    j1dR_tmp = TLorentzVector()
    j1dR_tmp.SetPtEtaPhiE(0, 0, 0, 0)
    j2dR_tmp = TLorentzVector()
    j2dR_tmp.SetPtEtaPhiE(0, 0, 0, 0)

    a = list(combinations(jet_nob, 2))
    min_DeltaR = 1000

    for x in a:

        if x[0][0] < -5 or x[1][0] < -5: continue
        if x[0][1] < -5 or x[1][1] < -5: continue

        if (math.sqrt(
                math.pow((x[0][0] - x[1][0]), 2) +
                math.pow((x[0][1] - x[1][1]), 2)) < min_DeltaR):
            j1dR_tmp.SetPtEtaPhiE(x[0][0], x[0][1], x[0][2], x[0][3])
            j2dR_tmp.SetPtEtaPhiE(x[1][0], x[1][1], x[1][2], x[1][3])

    topdR_tmp = TLorentzVector()
    topdR_tmp = j1dR_tmp + j2dR_tmp + b_tmp

    WdR_tmp = TLorentzVector()
    WdR_tmp = j1dR_tmp + j2dR_tmp

    masses[0] = topdR_tmp.M()
    masses[1] = WdR_tmp.M()

    masses[2] = math.fabs(DeltaPhi(WdR_tmp.Phi(), b_tmp.Phi()))
    masses[3] = math.fabs(DeltaPhi(topdR_tmp.Phi(), b_tmp.Phi()))
    masses[4] = math.fabs(DeltaPhi(WdR_tmp.Phi(), metPhi))
    masses[5] = math.fabs(DeltaPhi(topdR_tmp.Phi(), metPhi))

    return masses
示例#17
0
def lepHasOverlap(Chain, index, isGen=False):

    #Check the flavor of the lepton and initialize variables
    hasOverlap = False
    inputVec = TLorentzVector()
    inputVec.SetPtEtaPhiE(Chain._lPt[index], Chain._lEta[index],
                          Chain._lPhi[index], Chain._lE[index])

    #Loop over all leptons with a different flavor
    for l in xrange(ord(Chain._nL)):
        if l == index or Chain._lFlavor[l] == Chain._lFlavor[index]: continue
        if not Chain._lPOGLoose[l]: continue

        lVec = TLorentzVector()
        lVec.SetPtEtaPhiE(Chain._lPt[l], Chain._lEta[l], Chain._lPhi[l],
                          Chain._lE[l])

        dR = inputVec.DeltaR(lVec)
        if dR < .4: hasOverlap = True

    return hasOverlap
示例#18
0
def tauHasOverlap(Chain, index):

    #Check the flavor of the lepton and initialize variables
    hasOverlap = False
    inputVec = TLorentzVector()
    inputVec.SetPtEtaPhiE(Chain._lPt[index], Chain._lEta[index],
                          Chain._lPhi[index], Chain._lE[index])

    #Loop over all leptons with a different flavor and a different index
    for l in xrange(Chain._nLight):
        if l == index or Chain._lFlavor[l] == Chain._lFlavor[index]: continue
        if isLooseLightLeptonEwkino(Chain, l): continue

        lVec = TLorentzVector()
        lVec.SetPtEtaPhiE(Chain._lPt[l], Chain._lEta[l], Chain._lPhi[l],
                          Chain._lE[l])

        dR = inputVec.DeltaR(lVec)
        if dR < .4: hasOverlap = True

    return hasOverlap
示例#19
0
def get_four_momenta(data, ilepton):
    """
    Get the four-momentum of a given lepton from TTree data and
    return the result as a TLorentzVector. ilepton starts from 0
    and the function assumes GetEntry has been called and number
    of leptons has been checked.
    """
    pt = TLorentzVector()
    pt.SetPtEtaPhiE(data.lep_pt[ilepton] , \
                    data.lep_eta[ilepton], \
                    data.lep_phi[ilepton], \
                    data.lep_E[ilepton])
    return pt
示例#20
0
def findMatchLepton(Chain, index):
    out_index = None
    inputVec = TLorentzVector()
    inputVec.SetPtEtaPhiE(Chain._lPt[index], Chain._lEta[index],
                          Chain._lPhi[index], Chain._lE[index])

    minDeltaR = 9999999.
    for l in xrange(ord(Chain._gen_nL)):
        if Chain._gen_lFlavor[l] == Chain._lFlavor[index]: continue
        if not Chain._gen_lIsPrompt[l]: continue

        lVec = TLorentzVector()
        lVec.SetPtEtaPhiE(Chain._gen_lPt[l], Chain._gen_lEta[l],
                          Chain._gen_lPhi[l], Chain._gen_lE[l])

        dR = inputVec.DeltaR(lVec)
        if dR < minDeltaR:
            out_index = l
            minDeltaR = dR

    if minDeltaR < .3:
        return out_index
    else:
        return -1
示例#21
0
def GetTlv(name,entry):
    #like "OneMu", "PtRecoBukin", "PtRecoGauss", "PtRecoAverageBukinAndGauss", "Parton". 
    #name b1_Nominal   
    Pt=getattr(entry,name+"_Pt")
    Eta=getattr(entry,name+"_Eta")
    Phi=getattr(entry,name+"_Phi")
    E=getattr(entry,name+"_E")
    if debug:
        print name+"_Pt",Pt
        print name+"_Eta",Eta
        print name+"_Phi",Phi
        print name+"_E",E
    tlv=TLorentzVector()
    tlv.SetPtEtaPhiE(Pt,Eta,Phi,E)
    return tlv
示例#22
0
def get_quadrimomenta(pts, etas, phis, nvec, debug=False):
    vectors = []
    for i in range(nvec):
        pt, eta, phi = pts[i], etas[i], phis[i]
        if debug:
            print ("pt:", pt ," eta:", eta, " phi:", phi)
        if abs(eta)>10:
            continue
        else:
            p = pt * cosh(eta)
        #assume m =0, p = E
        v = TLorentzVector()
        v.SetPtEtaPhiE(pt, eta, phi, p)
        vectors.append(v)
    return vectors
示例#23
0
def q2_calc_vec_from_kine(en, theta, phi):

    #create Lorentz vector from electron kinematics loaded from the tree

    #transverse momentum
    m = TDatabasePDG.Instance().GetParticle(11).Mass()
    pt = sqrt(0.5 * (en**2 - m**2) * (1. - cos(2. * theta)))

    #pseudorapidity
    eta = -log(tan(theta / 2.))

    #set the Lorentz vector
    vec = TLorentzVector()
    vec.SetPtEtaPhiE(pt, eta, phi, en)

    return vec
示例#24
0
def jet(entry, jetid, calibid):
    Pt = getattr(entry, "%s_%s_Pt" % (jetid, calibid))
    Eta = getattr(entry, "%s_%s_Eta" % (jetid, calibid))
    Phi = getattr(entry, "%s_%s_Phi" % (jetid, calibid))
    E = getattr(entry, "%s_%s_E" % (jetid, calibid))
    if debug:
        print "%s_%s_Pt", Pt % (jetid, calibid)
        print "%s_%s_Eta", Eta % (jetid, calibid)
        print "%s_%s_Phi", Phi % (jetid, calibid)
        print "%s_%s_E", E % (jetid, calibid)
    tlv = TLorentzVector()
    tlv.SetPtEtaPhiE(Pt, Eta, Phi, E)
    M = tlv.M()
    if debug:
        print "%s_%s_M", M % (jetid, calibid)
    return tlv, M
示例#25
0
def get_jets(event, ptmin=20., debug=False):
    jets = []
    for pt, eta, phi,mass in  zip(event.std_vector_jet_pt, 
                     event.std_vector_jet_eta, event.std_vector_jet_phi, 
                     event.std_vector_jet_mass):
        if pt < 0 or pt < ptmin:
            break
        if abs(eta) < 10 :
            p = pt * cosh(eta)
            vec = TLorentzVector()
            en = sqrt(p**2 + mass**2)
            vec.SetPtEtaPhiE(pt, eta, phi, en)
            # check if different from the previous one
            if debug:
                print ("Jet > pt:", pt ," eta:", eta, " phi:", phi, " mass:"), mass
            jets.append(vec)
    return jets
示例#26
0
def Jets(jet, calib, entry):

    name = jet + "_" + calib + "_"
    Ptname = name + "Pt"
    Etaname = name + "Eta"
    Phiname = name + "Phi"
    Ename = name + "E"

    b_Pt = getattr(entry, Ptname)
    b_Eta = getattr(entry, Etaname)
    b_Phi = getattr(entry, Phiname)
    b_E = getattr(entry, Ename)

    b_tlv = TLorentzVector()
    b_tlv.SetPtEtaPhiE(b_Pt, b_Eta, b_Phi, b_E)
    b_M = b_tlv.M()

    return b_tlv
示例#27
0
def get_hard_partons(event, debug=False):
    partons = []
    pids = []
    for pt, eta, phi, pid, isHard in    \
                zip(event.std_vector_partonGen_pt, event.std_vector_partonGen_eta,
                event.std_vector_partonGen_phi, event.std_vector_partonGen_pid,
                event.std_vector_partonGen_isHardProcess):
        if isHard == 1 and abs(eta) < 10:
            p = pt * cosh(eta)
            vec = TLorentzVector()
            vec.SetPtEtaPhiE(pt, eta, phi, p)
            # check if different from the previous one
            if len(partons) == 0 or vec != partons[-1]:
                if debug:
                    print "Parton > pid: ", pid, " pt:", pt, " eta:", eta, " phi:", phi
                partons.append(vec)
                pids.append(int(pid))
    return partons, pids
示例#28
0
def get_jets_byindex(event, indexes, ptmin=20., debug=False):
    jets = []
    for i, (pt, eta, phi, mass), in enumerate(
            zip(event.std_vector_jet_pt, event.std_vector_jet_eta,
                event.std_vector_jet_phi, event.std_vector_jet_mass)):

        if pt < ptmin or pt < 0:
            break
        if i in indexes:
            if abs(eta) < 10:
                p = pt * cosh(eta)
                en = sqrt(p**2 + mass**2)
                vec = TLorentzVector()
                vec.SetPtEtaPhiE(pt, eta, phi, en)
                # check if different from the previous one
                if debug:
                    print "Jet > pt:", pt, " eta:", eta, " phi:", phi, " mass:", mass
                jets.append(vec)
    return jets
示例#29
0
def get_tlv(entry,b,scale,debug):
    if debug:
        print "get_tlv() for b",b," for scale",scale
    # jet 1
    prefix=b+"_"+scale+"_"
    Pt=getattr(entry,prefix+"Pt")
    Eta=getattr(entry,prefix+"Eta")
    Phi=getattr(entry,prefix+"Phi")
    E=getattr(entry,prefix+"E")
    if debug:
        print "Pt",Pt
        print "Eta",Eta
        print "Phi",Phi
        print "E",E
    tlv=TLorentzVector()
    tlv.SetPtEtaPhiE(Pt,Eta,Phi,E)
    M=tlv.M()
    if debug:
        print "M",M
    return tlv
示例#30
0
def FlipEta(lep, jets):
    """Takes in LorentzVector lep, jets and flips the sign of eta for each
    @==========================================================
    @ Parameters
    lep: LorentzVector containing lepton information
    jets: Array of LorentzVectors containing jet information
    @==========================================================
    @ Return
    Flipped LorentzVectors
    """
    lep_new = TLorentzVector()
    lep_new.SetPtEtaPhiE(lep.Pt(), -lep.Eta(), lep.Phi(), lep.E())
    new_jets = []
    for lj in jets:
        new_jets += [TLorentzVector(lj)]
        new_jet = new_jets[-1]
        new_jet.SetPtEtaPhiE(lj.Pt(), -lj.Eta(), lj.Phi(), lj.E())
        new_jet.btag = lj.btag

    return lep_new, new_jets