Exemple #1
0
def CostHE(p1, charge1, p2):
   #Cosine of the theta decay angle (top (Q=+2/3)) in the Helicity frame
   pTop1CM = TLorentzVector(0,0,-1,1)   # In the CM frame 
   pTop2CM = TLorentzVector(0,0,-1,1)   # In the CM frame 
   pDitopCM = TLorentzVector(0,0,-1,1) # In the CM frame 
   pTop1Ditop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pTop2Ditop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   beta = TVector3(0,0,0)
   zaxisCS = TVector3(0,0,0)

   # Get the muons parameters in the CM frame
   pTop1CM.SetPxPyPzE(p1.Px(),p1.Py(),p1.Pz(),p1.E())
   pTop2CM.SetPxPyPzE(p2.Px(),p2.Py(),p2.Pz(),p2.E())

   # Obtain the Ditop parameters in the CM frame
   pDitopCM=pTop1CM+pTop2CM

   # Translate the muon parameters in the Ditop rest frame
   beta=(-1./pDitopCM.E())*pDitopCM.Vect()
   if(beta.Mag()>=1): return 666.
   pTop1Ditop=pTop1CM
   pTop2Ditop=pTop2CM
   pTop1Ditop.Boost(beta)
   pTop2Ditop.Boost(beta)

   # Determine the z axis for the calculation of the polarization angle (i.e. the direction of the Ditop in the CM system)
   zaxis=(pDitopCM.Vect()).Unit()

   # Calculation of the polarization angle (angle between mu+ and the z axis defined above)
   cost = -999.
   if(charge1>0): cost = zaxis.Dot((pTop1Ditop.Vect()).Unit())
   else:          cost = zaxis.Dot((pTop2Ditop.Vect()).Unit())

   return cost
Exemple #2
0
def computeProcessedFeatures(muon1_p4, muon2_p4, unpairedMuon_p4, jpsi_p4, bc_p4):
  if ( bc_p4.M() != 0): 
    bcPtCorrected = (bcPdgMass * bc_p4.Pt())/ bc_p4.M()
  else:
    bcPtCorrected = bc_p4.Pt()

  muonsSystem_p4 = muon1_p4 + muon2_p4 + unpairedMuon_p4

  bcCorrected_p4 = TLorentzVector()
  bcCorrected_p4.SetPtEtaPhiM(bcPtCorrected,
      muonsSystem_p4.Eta(),
      muonsSystem_p4.Phi(),
      #bc_p4.M())
      bcPdgMass)
  boostToBcCorrectedRestFrame = -bcCorrected_p4.BoostVector()
  #boostToJpsiRestFrame = -(muon1_p4+muon2_p4).BoostVector()
  boostToJpsiRestFrame = -jpsi_p4.BoostVector()

  unpairedMuonBoostedToBcCorrectedRestFrame_p4 = TLorentzVector() 
  unpairedMuonBoostedToBcCorrectedRestFrame_p4.SetPtEtaPhiM(unpairedMuon_p4.Pt(), unpairedMuon_p4.Eta(), unpairedMuon_p4.Phi(), unpairedMuon_p4.M())
  unpairedMuonBoostedToBcCorrectedRestFrame_p4.Boost(boostToBcCorrectedRestFrame)
  unpairedMuonBoostedToJpsiRestFrame_p4 = TLorentzVector() 
  unpairedMuonBoostedToJpsiRestFrame_p4.SetPtEtaPhiM(unpairedMuon_p4.Pt(), unpairedMuon_p4.Eta(), unpairedMuon_p4.Phi(), unpairedMuon_p4.M())
  unpairedMuonBoostedToJpsiRestFrame_p4.Boost(boostToJpsiRestFrame)

  nn_energyBcRestFrame = unpairedMuonBoostedToBcCorrectedRestFrame_p4.E()
  #nn_missMass2 = (bcCorrected_p4 - muon1_p4 - muon2_p4 - unpairedMuon_p4).M2()
  nn_missMass2 = (bcCorrected_p4 - jpsi_p4 - unpairedMuon_p4).M2()
  #nn_q2 = (bc_p4 - muon1_p4 - muon2_p4).M2()
  nn_q2 = (bcCorrected_p4 - jpsi_p4).M2()
  #nn_missPt = bcCorrected_p4.Pt() - muon1_p4.Pt() - muon2_p4.Pt() - unpairedMuon_p4.Pt()
  nn_missPt = bcCorrected_p4.Pt() - jpsi_p4.Pt() - unpairedMuon_p4.Pt()
  nn_energyJpsiRestFrame = unpairedMuonBoostedToJpsiRestFrame_p4.E()
  #nn_varPt = (muon1_p4 + muon2_p4).Pt() - unpairedMuon_p4.Pt()
  nn_varPt = jpsi_p4.Pt() - unpairedMuon_p4.Pt()
  nn_deltaRMu1Mu2 = muon1_p4.DeltaR(muon2_p4)
  nn_unpairedMuPhi = unpairedMuon_p4.Phi()
  nn_unpairedMuPt = unpairedMuon_p4.Pt()
  nn_unpairedMuEta = unpairedMuon_p4.Eta()

  featuresEntry = np.array([
    [bcCorrected_p4.Pt()], 
    [bcCorrected_p4.Px()], 
    [bcCorrected_p4.Py()], 
    [bcCorrected_p4.Pz()], 
    [bcCorrected_p4.E()], 
    [nn_energyBcRestFrame],
    [nn_missMass2],
    [nn_q2],
    [nn_missPt],
    [nn_energyJpsiRestFrame],
    [nn_varPt],
    [nn_deltaRMu1Mu2],
    [nn_unpairedMuPhi],
    [nn_unpairedMuPt],
    [nn_unpairedMuEta]], 
    dtype=np.double)

  return featuresEntry
Exemple #3
0
def PhiHE(p1, charge1, p2):
   # Phi decay angle (top (Q=+2/3)) in the Helicity frame
   pTop1Lab = TLorentzVector(0,0,-1,1)  # In the lab. frame 
   pTop2Lab = TLorentzVector(0,0,-1,1)  # In the lab. frame 
   pProjLab = TLorentzVector(0,0,-1,1)  # In the lab. frame 
   pTargLab = TLorentzVector(0,0,-1,1)  # In the lab. frame 
   pDitopLab = TLorentzVector(0,0,-1,1) # In the lab. frame 
   pTop1Ditop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pTop2Ditop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pProjDitop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pTargDitop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   beta = TVector3(0,0,0)
   xaxis = TVector3(0,0,0)
   yaxis = TVector3(0,0,0)
   zaxis = TVector3(0,0,0)
   mp = 0.93827231
   ep = 6500.

   # Get the muons parameters in the LAB frame
   pTop1Lab.SetPxPyPzE(p1.Px(),p1.Py(),p1.Pz(),p1.E())
   pTop2Lab.SetPxPyPzE(p2.Px(),p2.Py(),p2.Pz(),p2.E())
   
   # Obtain the Ditop parameters in the LAB frame
   pDitopLab=pTop1Lab+pTop2Lab
   zaxis=(pDitopLab.Vect()).Unit()
   
   # Translate the muon parameters in the Ditop rest frame
   beta=(-1./pDitopLab.E())*pDitopLab.Vect()
   if(beta.Mag()>=1.): return 666.
   
   pProjLab.SetPxPyPzE(0.,0.,-ep,TMath.Sqrt(ep*ep+mp*mp))
   pTargLab.SetPxPyPzE(0.,0.,+ep,TMath.Sqrt(ep*ep+mp*mp))
   
   pProjDitop=pProjLab
   pTargDitop=pTargLab
   
   pProjDitop.Boost(beta)
   pTargDitop.Boost(beta)
   
   yaxis=((pProjDitop.Vect()).Cross(pTargDitop.Vect())).Unit()
   xaxis=(yaxis.Cross(zaxis)).Unit()
   
   pTop1Ditop=pTop1Lab
   pTop2Ditop=pTop2Lab
   pTop1Ditop.Boost(beta)
   pTop2Ditop.Boost(beta)

   phi = -999.
   if(charge1>0.): phi = TMath.ATan2((pTop1Ditop.Vect()).Dot(yaxis),(pTop1Ditop.Vect()).Dot(xaxis))
   else:           phi = TMath.ATan2((pTop2Ditop.Vect()).Dot(yaxis),(pTop2Ditop.Vect()).Dot(xaxis))
   
   return phi
Exemple #4
0
def PhiCS(p1, charge1, p2):
   # Phi decay angle (top (Q=+2/3)) in the Collins-Soper frame
   pTop1CM = TLorentzVector(0,0,-1,1)  # In the CM frame
   pTop2CM = TLorentzVector(0,0,-1,1)  # In the CM frame
   pProjCM = TLorentzVector(0,0,-1,1)  # In the CM frame
   pTargCM = TLorentzVector(0,0,-1,1)  # In the CM frame
   pDitopCM = TLorentzVector(0,0,-1,1) # In the CM frame
   pTop1Ditop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pTop2Ditop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pProjDitop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pTargDitop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   beta = TVector3(0,0,0)
   yaxisCS = TVector3(0,0,0)
   xaxisCS = TVector3(0,0,0)
   zaxisCS = TVector3(0,0,0)
   mp = 0.93827231
   ep = 6500.

   # Fill the Lorentz vector for projectile and target in the CM frame
   pProjCM.SetPxPyPzE(0.,0.,-ep,TMath.Sqrt(ep*ep+mp*mp))
   pTargCM.SetPxPyPzE(0.,0.,+ep,TMath.Sqrt(ep*ep+mp*mp))

   # Get the muons parameters in the CM frame 
   pTop1CM.SetPxPyPzE(p1.Px(),p1.Py(),p1.Pz(),p1.E())
   pTop2CM.SetPxPyPzE(p2.Px(),p2.Py(),p2.Pz(),p2.E())

   # Obtain the Ditop parameters in the CM frame
   pDitopCM=pTop1CM+pTop2CM

   # Translate the Ditop parameters in the Ditop rest frame
   beta=(-1./pDitopCM.E())*pDitopCM.Vect()
   if(beta.Mag()>=1): return 666.
   pTop1Ditop=pTop1CM
   pTop2Ditop=pTop2CM
   pProjDitop=pProjCM
   pTargDitop=pTargCM
   pTop1Ditop.Boost(beta)
   pTop2Ditop.Boost(beta)
   pProjDitop.Boost(beta)
   pTargDitop.Boost(beta)

   # Determine the z axis for the CS angle 
   zaxisCS=(((pProjDitop.Vect()).Unit())-((pTargDitop.Vect()).Unit())).Unit()
   yaxisCS=(((pProjDitop.Vect()).Unit()).Cross((pTargDitop.Vect()).Unit())).Unit()
   xaxisCS=(yaxisCS.Cross(zaxisCS)).Unit()

   phi = -999.
   if(charge1>0.): phi = TMath.ATan2((pTop1Ditop.Vect()).Dot(yaxisCS),((pTop1Ditop.Vect()).Dot(xaxisCS)))
   else:           phi = TMath.ATan2((pTop2Ditop.Vect()).Dot(yaxisCS),((pTop2Ditop.Vect()).Dot(xaxisCS)))
   if(phi>TMath.Pi()): phi = phi-TMath.Pi()

   return phi
Exemple #5
0
def get_incoming_partons(ZZjj_p4):

    com_energy_half = ZZjj_p4.M() / 2.
    parton_1 = TLorentzVector()
    parton_1.SetPxPyPzE(0, 0, com_energy_half, com_energy_half)
    parton_2 = TLorentzVector()
    parton_2.SetPxPyPzE(0, 0, -com_energy_half, com_energy_half)

    boost = ZZjj_p4.BoostVector()

    parton_1.Boost(boost)
    parton_2.Boost(boost)

    return [p4_to_MG_vector(parton_1), p4_to_MG_vector(parton_2)]
Exemple #6
0
def CostCS(p1, charge1, p2):
   #Cosine of the theta decay angle (top (Q=+2/3)) in the Collins-Soper frame
   pTop1CM = TLorentzVector(0,0,-1,1)  # In the CM. frame
   pTop2CM = TLorentzVector(0,0,-1,1)  # In the CM. frame
   pProjCM = TLorentzVector(0,0,-1,1) # In the CM. frame
   pTargCM = TLorentzVector(0,0,-1,1) # In the CM. frame
   pDitopCM = TLorentzVector(0,0,-1,1) # In the CM. frame
   pTop1Ditop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pTop2Ditop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pProjDitop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   pTargDitop = TLorentzVector(0,0,-1,1) # In the Ditop rest frame
   beta = TVector3(0,0,0)
   zaxisCS = TVector3(0,0,0)
   mp = 0.93827231
   ep = 6500.

   # Fill the Lorentz vector for projectile and target in the CM frame
   pProjCM.SetPxPyPzE(0.,0.,-ep,TMath.Sqrt(ep*ep+mp*mp))
   pTargCM.SetPxPyPzE(0.,0.,+ep,TMath.Sqrt(ep*ep+mp*mp))

   # Get the Topons parameters in the CM frame 
   pTop1CM.SetPxPyPzE(p1.Px(),p1.Py(),p1.Pz(),p1.E())
   pTop2CM.SetPxPyPzE(p2.Px(),p2.Py(),p2.Pz(),p2.E())

   # Obtain the Ditop parameters in the CM frame
   pDitopCM=pTop1CM+pTop2CM

   # Translate the Ditop parameters in the Ditop rest frame
   beta=(-1./pDitopCM.E())*pDitopCM.Vect()
   if(beta.Mag()>=1): return 666.
   pTop1Ditop=pTop1CM
   pTop2Ditop=pTop2CM
   pProjDitop=pProjCM
   pTargDitop=pTargCM
   pTop1Ditop.Boost(beta)
   pTop2Ditop.Boost(beta)
   pProjDitop.Boost(beta)
   pTargDitop.Boost(beta)

   # Determine the z axis for the CS angle 
   zaxisCS=(((pProjDitop.Vect()).Unit())-((pTargDitop.Vect()).Unit())).Unit();

   # Determine the CS angle (angle between Top+ and the z axis defined above)
   cost = -999

   if(charge1>0): cost = zaxisCS.Dot((pTop1Ditop.Vect()).Unit())
   else:          cost = zaxisCS.Dot((pTop2Ditop.Vect()).Unit())

   return cost
def TransBoosted_Angle(pt1,eta1,phi1,pt2,eta2,phi2,ptz,etaz,phiz,mass,Met,Metphi):
	mu1 = TLorentzVector()
	mu2 = TLorentzVector()
	zb = TLorentzVector()
	met = TLorentzVector()
	mu1.SetPtEtaPhiM(pt1,0,phi1,0)
	mu2.SetPtEtaPhiM(pt2,0,phi2,0)
	zb.SetPtEtaPhiM(ptz,0,phiz,mass)
	MET.SetPtEtaPhiM(Met,0,Metphi,0)
	MET.Boost(-zb.Px()/zb.Et(),-zb.Py()/zb.Et(),0)
	mu1.Boost(-zb.Px()/zb.Et(),-zb.Py()/zb.Et(),0)
	mu2.Boost(-zb.Px()/zb.Et(),-zb.Py()/zb.Et(),0)
	angleBoost_1 = MET.DeltaPhi(mu1)
	angleBoost_2 = MET.DeltaPhi(mu2)
	angleBoost_Z = MET.DeltaPhi(zb)
	return [angleBoost_Z,angleBoost_1,angleBoost_2]
Exemple #8
0
def jet_processing(jet):
    # Find the jet (eta, phi)
    center=jet.sum(axis=0)
    v_jet=TLorentzVector(center[1], center[2], center[3], center[0])
    # Centering parameters
    phi=v_jet.Phi()
    bv = v_jet.BoostVector()
    bv.SetPerp(0)
    for n in np.arange(len(jet)):
        if np.sum(jet[n,:]) != 0:
            v = TLorentzVector(jet[n,1], jet[n,2], jet[n,3], jet[n,0])
            v.RotateZ(-phi)
            v.Boost(-bv)
            jet[n,:] = v[3], v[0], v[1], v[2] #(E,Px,Py,Pz)
    # Rotating parameters
    weighted_phi=0
    weighted_eta=0
    for n in np.arange(len(jet)):
        if np.sum(jet[n,:]) != 0:
            v = TLorentzVector(jet[n,1], jet[n,2], jet[n,3], jet[n,0])
            r = np.sqrt(v.Phi()**2 + v.Eta()**2)
            if r != 0: #in case there is only one component
                weighted_phi += v.Phi() * v.E()/r
                weighted_eta += v.Eta() * v.E()/r
    #alpha = np.arctan2(weighted_phi, weighted_eta) #approximately align at eta
    alpha = np.arctan2(weighted_eta, weighted_phi) #approximately align at phi
    for n in np.arange(len(jet)):
        if np.sum(jet[n,:]) != 0:
            v = TLorentzVector(jet[n,1], jet[n,2], jet[n,3], jet[n,0])
            #v.rotate_x(alpha) #approximately align at eta
            v.RotateX(-alpha) #approximately align at phi
            jet[n,:] = v[3], v[0], v[1], v[2] #(E,Px,Py,Pz)
    return jet
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
Exemple #10
0
def JpsiKst_Angles(kaon, pion, mu1, mu2):
    """
    paula
    """
    P11p = kaon[1]
    P12p = pion[1]
    P21p = mu1[1]
    P22p = mu2[1]
    from ROOT import TLorentzVector, TVector3

    def NProductV(alpha, Vect):
        Vect1 = [Vect.x(), Vect.y(), Vect.z()]
        for i in range(0, 3):
            Vect1[i] = alpha * Vect[i]
        return TVector3(Vect1[0], Vect1[1], Vect1[2])

    p1 = TLorentzVector(P11p[0], P11p[1], P11p[2], kaon[0])
    p2 = TLorentzVector(P12p[0], P12p[1], P12p[2], pion[0])
    p3 = TLorentzVector(P21p[0], P21p[1], P21p[2], mu1[0])
    p4 = TLorentzVector(P22p[0], P22p[1], P22p[2], mu2[0])
    p1Psi = TLorentzVector(p1)

    p12 = TLorentzVector(p1 + p2)
    p34 = TLorentzVector(p3 + p4)
    BK0S = TLorentzVector(p1 + p2 + p3 + p4)
    BPsi = TLorentzVector(p1 + p2 + p3 + p4)

    p1.Boost(NProductV(-1. / (p12.E()), p12.Vect()))
    BK0S.Boost(NProductV(-1. / (p12.E()), p12.Vect()))

    ThK = (p1.Vect()).Angle(-BK0S.Vect())

    p1Psi.Boost(NProductV(-1. / (p34.E()), p34.Vect()))
    BPsi.Boost(NProductV(-1. / (p34.E()), p34.Vect()))

    xtr = BPsi.Vect().Unit()
    ytr = (p1Psi.Vect().Unit() - NProductV(
        (p1Psi.Vect().Unit()).Dot(xtr), xtr)).Unit()
    ztr = xtr.Cross(ytr)

    p3.Boost(NProductV(-1. / (p34.E()), p34.Vect()))
    Thtr = ztr.Angle(p3.Vect())
    Phitr = xtr.Angle(p3.Vect() - NProductV(ztr.Dot(p3.Vect()), ztr))
    if (ytr.Angle(p3.Vect() - NProductV(ztr.Dot(p3.Vect()), ztr)) > pi / 2.):
        Phitr = -Phitr

    return ThK, Thtr, Phitr
def Boosted_Angle(pt1, eta1, phi1, pt2, eta2, phi2, ptz, etaz, phiz, mass):
    mu1 = TLorentzVector()
    mu2 = TLorentzVector()
    zb = TLorentzVector()
    mu1.SetPtEtaPhiM(pt1, eta1, phi1, 0)
    mu2.SetPtEtaPhiM(pt2, eta2, phi2, 0)
    angle = mu1.Angle(mu2.Vect())
    zb.SetPtEtaPhiM(ptz, etaz, phiz, mass)
    angle_Z1 = zb.Angle(mu1.Vect())
    angle_Z2 = zb.Angle(mu2.Vect())
    mu1.Boost(-zb.Px() / zb.E(), -zb.Py() / zb.E(), -zb.Pz() / zb.E())
    mu2.Boost(-zb.Px() / zb.E(), -zb.Py() / zb.E(), -zb.Pz() / zb.E())
    angleBoost = mu1.Angle(mu2.Vect())
    angleBoost_Z1 = zb.Angle(mu1.Vect())
    angleBoost_Z2 = zb.Angle(mu2.Vect())
    #print "******&&&&******", angle, angleBoost
    return [angleBoost, angle, angleBoost_Z1, angle_Z1, angle_Z2]
Exemple #12
0
def calculateFinalStateMomenta_GOLD(mB0, m23, mMuMu, cosTheta1, cosTheta2, phi,
                                    mMuPlus, mMuMinus, mPi, mK, pion_ID):
    if (pion_ID > 0):  # anti-B0
        if (phi > 0): phi = pi - phi
        else: phi = -pi - phi
        cosTheta1 = -cosTheta1

    pJpsi = daughterMomentum(mB0, mMuMu, m23)
    p4Jpsi = TLorentzVector(0, 0, +pJpsi, sqrt(mMuMu * mMuMu + pJpsi * pJpsi))
    p4Kpi = TLorentzVector(0, 0, -pJpsi, sqrt(m23 * m23 + pJpsi * pJpsi))
    pB = TLorentzVector(0, 0, 0, mB0)

    # 4-momenta of muons, first in dimuon rest frame which are then boosted
    # using p4Jpsi to B0 rest frame
    pMu = daughterMomentum(mMuMu, mMuPlus, mMuMinus)

    pMuPlus = TLorentzVector()
    pMuMinus = TLorentzVector()
    pPi = TLorentzVector()
    pK = TLorentzVector()

    pMuPlus.SetPxPyPzE(pMu * sqrt(1 - cosTheta1 * cosTheta1), 0,
                       pMu * cosTheta1, sqrt(mMuPlus * mMuPlus + pMu * pMu))

    pMuMinus.SetPxPyPzE(-pMu * sqrt(1 - cosTheta1 * cosTheta1),
                        0, -pMu * cosTheta1,
                        sqrt(mMuMinus * mMuMinus + pMu * pMu))

    pMuPlus.Boost(p4Jpsi.BoostVector())
    pMuMinus.Boost(p4Jpsi.BoostVector())

    # Now kaon and pion to finish
    ppK = daughterMomentum(m23, mK, mPi)
    pz = ppK * cosTheta2
    pT = ppK * sqrt(1 - cosTheta2 * cosTheta2)
    py = -pT * sin(phi)
    px = -pT * cos(phi)

    pK.SetPxPyPzE(px, -py, -pz, sqrt(mK * mK + ppK * ppK))
    pPi.SetPxPyPzE(-px, py, pz, sqrt(mPi * mPi + ppK * ppK))
    pK.Boost(p4Kpi.BoostVector())
    pPi.Boost(p4Kpi.BoostVector())
    return pMuPlus, pMuMinus, pPi, pK
Exemple #13
0
def momentum_aftr_boost(df, args):  #args must have 4 elements xyzt or pxpypzE
    px, py, pz = getXYZ(df, args)
    E = DfToNp(df[[args[3]]].dropna(axis=0))
    l = TLorentzVector()
    with np.nditer([px, py, pz, E, None, None, None, None]) as it:
        for pi, pj, pk, el, pm, pn, po, eq in it:
            l.SetPxPyPzE(pi, pj, pk, el)
            bi = pi / el
            l.Boost(-bi, 0, 0)
            pm[...] = l.Px()
            pn[...] = l.Py()
            po[...] = l.Pz()
            eq[...] = l.E()
        return (it.operands[4], it.operands[5], it.operands[6], it.operands[7])
Exemple #14
0
def cosThetaBoost(pa, ida, pb, idb, doflip=False):
   #  http://xrootd.slac.stanford.edu/BFROOT/www/doc/workbook_backup_010108/analysis/analysis.html
   #  A useful quantity in many analyses is the helicity angle.
   #  In the reaction Y . X . a + b, the helicity angle of
   #  particle a is the angle measured in the rest frame of the
   #  deidaying parent particle, X, between the direction of the
   #  deiday daughter a and the direction of the grandparent particle Y.
   pTmp = pa+pb;                     # this is the mumu system (Z) 4vector
   ZboostVector = pTmp.BoostVector() # this is the 3vector of the Z
   p = TLorentzVector(0,0,-1,1)      # this is the muon 4vector
   if  (ida>0): p.SetPxPyPzE(pa.Px(),pa.Py(),pa.Pz(),pa.E())
   else:        p.SetPxPyPzE(pb.Px(),pb.Py(),pb.Pz(),pb.E())
   p.Boost(-ZboostVector) # boost p to the Ditop CM (rest) frame
   cosThetaB = p.Vect()*pTmp.Vect()/(p.P()*pTmp.P())
   if(ySystem(pa,pb)<0. and doflip): cosThetaB *= -1. # reclassify ???
   return cosThetaB
Exemple #15
0
def boost(df, args):  #args must have 4 elements xyzt or pxpypzE
    px, py, pz = getXYZ(df, args)
    E = DfToNp(df[[args[3]]].dropna(axis=0))
    l = TLorentzVector()
    with np.nditer([px, py, pz, E, None, None, None, None]) as it:
        for pi, pj, pk, el, pm, en, phi, cost in it:
            l.SetPxPyPzE(pi, pj, pk, el)
            bi = pi / el
            bj = pj / el
            bk = pk / el
            l.Boost(-bi, -bj, -bk)
            pm[...] = l.Px()
            en[...] = l.E()
            phi[...] = l.Phi()
            cost[...] = l.CosTheta()
        return (it.operands[4], it.operands[5], it.operands[6], it.operands[7])
Exemple #16
0
def position_aftr_boost(df, args):  #args must have 4 elements xyzt or pxpypzE
    px, py, pz = getXYZ(df, args)
    E = DfToNp(df[[args[3]]].dropna(axis=0))
    l = TLorentzVector()
    with np.nditer([px, py, pz, E, None, None, None]) as it:
        for pi, pj, pk, el, x, y, z in it:
            l.SetPxPyPzE(pi, pj, pk, el)
            #p = math.hypot(pi,pj)
            #p = math.hypot(pk,p)
            bi = pi / el
            bj = pj / el
            bk = pk / el
            #print(b)
            l.Boost(-bi, -bj, -bk)
            z[...] = l.X()
            y[...] = l.Y()
            z[...] = l.Z()
        return (it.operands[4], it.operands[5], it.operands[6])
Exemple #17
0
    # x         : heavy boson
    mu_m      = TLorentzVector()
    mu_p      = TLorentzVector()
    g         = TLorentzVector()
    jpsi      = TLorentzVector()
    x         = TLorentzVector()

    # set
    mu_m.SetPtEtaPhiM(p_pt[i_mm], p_eta[i_mm], p_phi[i_mm], p_M[i_mm]);
    mu_p.SetPtEtaPhiM(p_pt[i_mp], p_eta[i_mp], p_phi[i_mp], p_M[i_mp]);
    g.SetPtEtaPhiM   (p_pt[i_g],  p_eta[i_g],  p_phi[i_g],  p_M[i_g] );

    jpsi = mu_m + mu_p
    x    = mu_m + mu_p + g

    mu_m.Boost(-x.BoostVector());
    mu_p.Boost(-x.BoostVector());
    g.Boost   (-x.BoostVector());
    jpsi.Boost(-x.BoostVector());
    x.Boost   (-x.BoostVector());

    mu_m.Boost(-jpsi.BoostVector());
    mu_p.Boost(-jpsi.BoostVector());
    g.Boost   (-jpsi.BoostVector());

    # if ((jpsi.Vect().Mag()>tol) and (mu_p.Vect().Mag()>tol) and (mu_m.Vect().Mag()>tol) and (g.Vect().Mag()>tol) and (x.Vect().Mag()>0)):
    l_cosThetaStar.append(jpsi.CosTheta())

    cosTheta1 = jpsi.Vect().Dot(mu_p.Vect()) / ((jpsi.Vect().Mag())*(mu_p.Vect().Mag()));
    l_cosTheta1mu_p.append(cosTheta1)
Exemple #18
0
    def __init__(self, parse, tree, hepmc_attrib):

        print("Quasi-real configuration:")

        #electron and proton beam energy, GeV
        self.Ee = parse.getfloat("main", "Ee")
        self.Ep = parse.getfloat("main", "Ep")
        print("Ee =", self.Ee, "GeV")
        print("Ep =", self.Ep, "GeV")

        #electron and proton mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()
        mp = TDatabasePDG.Instance().GetParticle(2212).Mass()

        #boost vector pbvec of proton beam
        pbeam = TLorentzVector()
        pbeam.SetPxPyPzE(0, 0, TMath.Sqrt(self.Ep**2-mp**2), self.Ep)
        self.pbvec = pbeam.BoostVector()

        #electron beam energy Ee_p in proton beam rest frame
        ebeam = TLorentzVector()
        ebeam.SetPxPyPzE(0, 0, -TMath.Sqrt(self.Ee**2-self.me**2), self.Ee)
        ebeam.Boost(-self.pbvec.x(), -self.pbvec.y(), -self.pbvec.z()) # transform to proton beam frame
        self.Ee_p = ebeam.E()

        #center-of-mass squared s, GeV^2
        self.s = self.get_s(self.Ee, self.Ep)
        print("s =", self.s, "GeV^2")
        print("sqrt(s) =", TMath.Sqrt(self.s), "GeV")

        #range in x
        xmin = parse.getfloat("main", "xmin")
        xmax = parse.getfloat("main", "xmax")
        print("xmin =", xmin)
        print("xmax =", xmax)

        #range in u = log_10(x)
        umin = TMath.Log10(xmin)
        umax = TMath.Log10(xmax)
        print("umin =", umin)
        print("umax =", umax)

        #range in y
        ymin = parse.getfloat("main", "ymin")
        ymax = parse.getfloat("main", "ymax")

        #range in W
        wmin = -1.
        wmax = -1.
        if parse.has_option("main", "Wmin"):
            wmin = parse.getfloat("main", "Wmin")
            print("Wmin =", wmin)
        if parse.has_option("main", "Wmax"):
            wmax = parse.getfloat("main", "Wmax")
            print("Wmax =", wmax)

        #adjust range in y according to W
        if wmin > 0 and ymin < wmin**2/self.s:
            ymin = wmin**2/self.s
        if wmax > 0 and ymax > wmax**2/self.s:
            ymax = wmax**2/self.s

        print("ymin =", ymin)
        print("ymax =", ymax)

        #range in v = log_10(y)
        vmin = TMath.Log10(ymin)
        vmax = TMath.Log10(ymax)
        print("vmin =", vmin)
        print("vmax =", vmax)

        #range in Q2
        self.Q2min = parse.getfloat("main", "Q2min")
        self.Q2max = parse.getfloat("main", "Q2max")
        print("Q2min =", self.Q2min)
        print("Q2max =", self.Q2max)

        #constant term in the cross section
        self.const = TMath.Log(10)*TMath.Log(10)*(1./137)/(2.*math.pi)

        #cross section formula for d^2 sigma / dxdy, Eq. II.6
        #transformed as x -> u = log_10(x) and y -> v = log_10(y)
        self.eq_II6_uv_par = self.eq_II6_uv(self)
        self.eq = TF2("d2SigDuDvII6", self.eq_II6_uv_par, umin, umax, vmin, vmax)

        self.eq.SetNpx(1000)
        self.eq.SetNpy(1000)

        #uniform generator for azimuthal angles
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        #generator event variables in output tree
        tnam = ["gen_u", "gen_v", "true_x", "true_y", "true_Q2", "true_W2"]
        tnam += ["true_el_Q2"]
        tnam += ["true_el_pT", "true_el_theta", "true_el_phi", "true_el_E"]

        #create the tree variables
        tcmd = "struct gen_out { Double_t "
        for i in tnam:
            tcmd += i + ", "
        tcmd = tcmd[:-2] + ";};"
        gROOT.ProcessLine( tcmd )
        self.out = rt.gen_out()

        #put zero to all variables
        for i in tnam:
            exec("self.out."+i+"=0")

        #set the variables in the tree
        if tree is not None:
            for i in tnam:
                tree.Branch(i, addressof(self.out, i), i+"/D")

        #event attributes for hepmc
        self.hepmc_attrib = hepmc_attrib

        #counters for all generated and selected events
        self.nall = 0
        self.nsel = 0

        #print generator statistics at the end
        atexit.register(self.show_stat)

        #total integrated cross section
        self.sigma_tot = self.eq.Integral(umin, umax, vmin, vmax)
        print("Total integrated cross section for a given x and y range:", self.sigma_tot, "mb")

        print("Quasi-real photoproduction initialized")
Exemple #19
0
 neu_posi = -999
 ele_posi = -999
 mu_posi = -999
 for p in pruned:
     if (p.isDirectHardProcessTauDecayProductFinalState()):
         print 'ID:', p.pdgId()
         lep_mad.SetPtEtaPhiE(p.pt(), p.eta(), p.phi(), p.energy())
         madspin_TLorentzVector.append(lep_mad.Clone())
         madspin_pdgid_index.append(p.pdgId())
 for i in range(len(madspin_pdgid_index)):
     tau_mad = tau_mad + madspin_TLorentzVector[i]
 tauphi_mad.Fill(tau_mad.Phi(), weight_mad)
 taueta_mad.Fill(tau_mad.Eta(), weight_mad)
 taupt_mad.Fill(tau_mad.Pt(), weight_mad)
 tau_mad_boost = tau_mad.BoostVector()
 tau_mad.Boost(-tau_mad_boost)
 if -16 in madspin_pdgid_index: neu_posi = madspin_pdgid_index.index(-16)
 if 16 in madspin_pdgid_index: neu_posi = madspin_pdgid_index.index(16)
 neu_mad = madspin_TLorentzVector[neu_posi]
 neu_mad.Boost(-tau_mad_boost)
 nphi_mad.Fill(cos(neu_mad.Angle(tau_mad.Vect())), weight_mad)
 if -11 in madspin_pdgid_index: ele_posi = madspin_pdgid_index.index(-11)
 if 11 in madspin_pdgid_index: ele_posi = madspin_pdgid_index.index(11)
 if ele_posi != -999:
     ele_mad = madspin_TLorentzVector[ele_posi]
     ele_mad.Boost(-tau_mad_boost)
     elephi_mad.Fill(cos(ele_mad.Angle(tau_mad.Vect())), weight_mad)
 if -13 in madspin_pdgid_index: mu_posi = madspin_pdgid_index.index(-13)
 if 13 in madspin_pdgid_index: mu_posi = madspin_pdgid_index.index(13)
 if mu_posi != -999:
     mu_mad = madspin_TLorentzVector[mu_posi]
Exemple #20
0
    def __init__(self, parse, tree):

        #electron and proton energy, GeV
        self.Ee = parse.getfloat("main", "Ee")
        self.Ep = parse.getfloat("main", "Ep")

        print("Ee, GeV =", self.Ee)
        print("Ep, GeV =", self.Ep)

        #A and Z of the nucleus
        self.A = 1
        self.Z = 1
        if parse.has_option("main", "A"):
            self.A = parse.getint("main", "A")
        if parse.has_option("main", "Z"):
            self.Z = parse.getint("main", "Z")
        print("A:", self.A)
        print("Z:", self.Z)

        #minimal photon energy, GeV
        self.emin = parse.getfloat("main", "emin")
        print("emin, GeV =", self.emin)

        #alpha r_e^2
        self.ar2 = 7.297 * 2.818 * 2.818 * 1e-2  # m barn

        #electron and nucleus mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()
        self.mp = TDatabasePDG.Instance().GetParticle(2212).Mass()
        self.mn = self.A * self.mp

        #nucleus beam vector
        nvec = TLorentzVector()
        pz_a = TMath.Sqrt(self.Ep**2 - self.mp**2) * self.Z
        en_a = TMath.Sqrt(pz_a**2 + self.mn**2)
        nvec.SetPxPyPzE(0, 0, pz_a, en_a)
        print("Nucleus beam gamma:", nvec.Gamma())

        #boost vector of nucleus beam
        self.nbvec = nvec.BoostVector()

        #electron beam vector
        evec = TLorentzVector()
        evec.SetPxPyPzE(0, 0, -TMath.Sqrt(self.Ee**2 - self.me**2), self.Ee)
        print("Electron beam gamma:", evec.Gamma())

        #electron beam energy in nucleus beam rest frame
        evec.Boost(-self.nbvec.x(), -self.nbvec.y(), -self.nbvec.z())
        self.Ee_n = evec.E()

        print("Ee_n, GeV:", self.Ee_n)

        #minimal photon energy in nucleus rest frame
        eminv = TLorentzVector()
        eminv.SetPxPyPzE(0, 0, -self.emin, self.emin)
        eminv.Boost(-self.nbvec.x(), -self.nbvec.y(), -self.nbvec.z())
        emin_n = eminv.E()
        print("emin_n, GeV:", emin_n)

        #maximal delta in nucleus frame
        dmax_n = 100.
        if parse.has_option("main", "dmax_n"):
            dmax_n = parse.getfloat("main", "dmax_n")

        print("dmax_n:", dmax_n)

        #cross section formula
        self.eqpar = self.eq(self)
        self.dSigDwDt = TF2("dSigDwDt", self.eqpar, emin_n, self.Ee_n, 0,
                            dmax_n)
        self.dSigDwDt.SetNpx(2000)
        self.dSigDwDt.SetNpy(2000)
        gRandom.SetSeed(5572323)

        #total integrated cross section over all delta (to 1e5)
        dSigInt = TF2("dSigInt", self.eqpar, emin_n, self.Ee_n, 0, 1e5)
        sigma_tot = dSigInt.Integral(emin_n, self.Ee_n, 0, 1e5)

        print("Total cross section, mb:", sigma_tot)

        #uniform generator for azimuthal angles
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        #tree output from the generator
        tlist = ["true_phot_w", "true_phot_delta", "true_phot_theta_n"]
        tlist += ["true_phot_theta", "true_phot_phi", "true_phot_E"]
        tlist += ["true_el_theta", "true_el_phi", "true_el_E"]
        self.tree_out = self.set_tree(tree, tlist)

        print("Lifshitz_93p16 parametrization initialized")
Exemple #21
0
def get_gen_kin(rootfile):

    intree = rfile.Get('kin')
    d = tree2array(intree)

    Px = d['Px_FinalState']
    Py = d['Py_FinalState']
    Pz = d['Pz_FinalState']
    E = d['E_FinalState']

    Px_beam = d['Px_Beam']
    Py_beam = d['Py_Beam']
    Pz_beam = d['Pz_Beam']
    E_beam = d['E_Beam']

    #get numpy arrays to save later
    mproton = np.zeros_like(Px)
    metap = np.zeros_like(Px)
    mpi0 = np.zeros_like(Px)
    metaprimepi0 = np.zeros_like(Px)
    beam_energy = np.zeros_like(Px)
    cos_theta = np.zeros_like(Px)

    #declare  TLorentzVector
    Beam_P4 = TLorentzVector()
    Proton_P4 = TLorentzVector()
    Etaprime_P4 = TLorentzVector()
    Pi0_P4 = TLorentzVector()
    Etaprimepi0_P4 = TLorentzVector()

    #declare stuff to convert to GJ frame
    boostGJ = TVector3()
    Beam_P4_GJ = TLorentzVector()
    Proton_P4_GJ = TLorentzVector()
    Etaprime_P4_GJ = TLorentzVector()
    Pi0_P4_GJ = TLorentzVector()
    Etaprimepi0_P4_GJ = TLorentzVector()

    z_GJ = TVector3()
    z_hat_GJ = TVector3()

    y_GJ = TVector3()
    y_hat_GJ = TVector3()

    x_hat_GJ = TVector3()
    vetaprime = TVector3()

    for i in range(len(Px)):
        #for i in range(100):
        #m = np.sqrt(E[i][0]**2 - (Px[i][0]**2 + Py[i][0]**2 + Pz[i][0]**2))
        #metap[i] = m

        #get  TLorentzVector vectors
        Beam_P4.SetPxPyPzE(Px_beam[i], Py_beam[i], Pz_beam[i], E_beam[i])
        Proton_P4.SetPxPyPzE(Px[i][0], Py[i][0], Pz[i][0], E[i][0])
        Etaprime_P4.SetPxPyPzE(Px[i][1], Py[i][1], Pz[i][1], E[i][1])
        Pi0_P4.SetPxPyPzE(Px[i][2], Py[i][2], Pz[i][2], E[i][2])

        #do stuff here
        Etaprimepi0_P4 = Etaprime_P4 + Pi0_P4

        #get the boost vector
        boostGJ = (-1) * (Etaprimepi0_P4.Vect()) * (1.0 / Etaprimepi0_P4.E())

        Beam_P4_GJ = Beam_P4
        Proton_P4_GJ = Proton_P4
        Etaprime_P4_GJ = Etaprime_P4
        Pi0_P4_GJ = Pi0_P4
        Etaprimepi0_P4_GJ = Etaprimepi0_P4

        #boost vectors to GJ frame
        Beam_P4_GJ.Boost(boostGJ)
        Proton_P4_GJ.Boost(boostGJ)
        Etaprime_P4_GJ.Boost(boostGJ)
        Pi0_P4_GJ.Boost(boostGJ)
        Etaprimepi0_P4_GJ.Boost(boostGJ)

        z_GJ.SetXYZ(Beam_P4_GJ.X(), Beam_P4_GJ.Y(), Beam_P4_GJ.Z())
        z_hat_GJ = z_GJ.Unit()

        y_GJ = Beam_P4.Vect().Cross(Etaprimepi0_P4.Vect())
        y_hat_GJ = y_GJ.Unit()

        x_hat_GJ = y_hat_GJ.Cross(z_hat_GJ)

        vetaprime.SetXYZ(Etaprime_P4_GJ.Vect() * x_hat_GJ,
                         Etaprime_P4_GJ.Vect() * y_hat_GJ,
                         Etaprime_P4_GJ.Vect() * z_hat_GJ)
        cos_theta[i] = vetaprime.CosTheta()

        mproton[i] = Proton_P4.M()
        metap[i] = Etaprime_P4.M()
        mpi0[i] = Pi0_P4.M()
        metaprimepi0[i] = Etaprimepi0_P4.M()
        beam_energy[i] = Beam_P4.E()

    return np.savez(
        '/Users/rupeshdotel/analysis/work/pi0pippimeta/data/MC/check_events.npz',
        mproton=mproton,
        metap=metap,
        mpi0=mpi0,
        metaprimepi0=metaprimepi0,
        cos_theta=cos_theta,
        beam_energy=beam_energy)