Exemple #1
0
 def returnCosTheta1(self, theJPsi, theL1, theL2, thePhoton):
     j, l1, l2, g = TLorentzVector(theJPsi), TLorentzVector(theL1), TLorentzVector(theL2), TLorentzVector(thePhoton)
     # Boost objects to the JPsi rest frame
     l1.Boost( -j.BoostVector() )
     l2.Boost( -j.BoostVector() )
     g.Boost( -j.BoostVector() )
     # cos theta = Gamma dot L1 / (|Gamma|*|L1|)
     value = g.Vect().Dot( l1.Vect() ) / ( (g.Vect().Mag())*(l1.Vect().Mag()) ) if g.Vect().Mag() > 0. and l1.Vect().Mag() > 0. else -2
     if value != value or math.isinf(value): return -2.
     return value
Exemple #2
0
 def returnCosThetaStar(self, theH, theJPsi):
     h, j = TLorentzVector(theH), TLorentzVector(theJPsi)
     # Boost the Z to the A rest frame
     j.Boost(-h.BoostVector())
     value = j.CosTheta()
     if value != value or math.isinf(value): return -2.
     return value
Exemple #3
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
Exemple #4
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 #5
0
    def process(self, event):
        '''Smear the beam energy.
        
        The two incoming particle energies are smeared under
        a Gaussian pdf of width sigma relative to the beam energy
        
        All outgoing particles are then boosted to the new com
        system 
        '''
        genptcs = getattr(event, self.cfg_ana.gen_particles)
        sigma = self.cfg_ana.sigma
        f1 = random.gauss(1, sigma)
        f2 = random.gauss(1, sigma)
        
        beamptcs = [p for p in genptcs if p.status() == 4]
        pprint.pprint(beamptcs)
        
        assert(len(beamptcs) == 2)
        
        def smear(ptc, factor):
            e = ptc.p4().E() * factor
            pz = math.sqrt(e ** 2 - ptc.m() ** 2)
            if ptc.p4().Pz() < 0:
                pz = -pz                
            ptc._tlv.SetPxPyPzE( ptc.p4().Px(),
                                 ptc.p4().Py(),
                                 pz,
                                 e)        

        newcom = TLorentzVector()
        for ptc, factor in zip(beamptcs, [f1, f2]):
            smear(ptc, factor)
            ptc.p4().Print()
            print ptc.m()
            newcom += ptc.p4()
        
        print 'new com:'
        newcom.Print()
        boost = newcom.BoostVector()
        
        stablep4_before = TLorentzVector()
        stablep4 = TLorentzVector()
        for p in genptcs:
            if p in beamptcs:
                continue
            if p.status() == 1:
                stablep4_before += p._tlv
            # p._tlv.Boost(boost)
            p._tlv.Boost(boost)
            if p.status() == 1:
                stablep4 += p._tlv
                
        pprint.pprint(beamptcs)
        print newcom.E(), newcom.Pz()
        print stablep4.E(), stablep4.Pz()
        print stablep4_before.E(), stablep4_before.Pz()
        boost.Print()
Exemple #6
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 #7
0
 def returnPhi(self, theH, theL1, theL2, theL3, theL4):
     h, l1, l2, l3, l4 = TLorentzVector(theH), TLorentzVector(
         theL1), TLorentzVector(theL2), TLorentzVector(
             theL3), TLorentzVector(theL4)
     # Boost objects to the A rest frame
     l1.Boost(-h.BoostVector())
     l2.Boost(-h.BoostVector())
     l3.Boost(-h.BoostVector())
     l4.Boost(-h.BoostVector())
     # Build unit vectors orthogonal to the decay planes
     Zplane = l1.Vect().Cross(l2.Vect())  # L1 x L2
     Hplane = l3.Vect().Cross(l4.Vect())  # B1 x B2
     Zplane.SetMag(1.)
     Hplane.SetMag(1.)
     # Sign of Phi
     z1 = l1 + l2
     sgn = 1 if z1.Vect().Dot(Zplane.Cross(Hplane)) > 0 else -1
     value = sgn * math.acos(Zplane.Dot(Hplane))
     if value != value or math.isinf(value): return -5.
     return value
Exemple #8
0
 def returnPhi1(self, theH, theL1, theL2):
     h, l1, l2 = TLorentzVector(theH), TLorentzVector(theL1), TLorentzVector(theL2)
     beamAxis = TVector3(0., 0., 1.)
     # Boost objects to the A rest frame
     l1.Boost( -h.BoostVector() )
     l2.Boost( -h.BoostVector() )
     # Reconstruct JPsi in H rest frame
     j = l1 + l2
     # Build unit vectors orthogonal to the decay planes
     Zplane = TVector3(l1.Vect().Cross( l2.Vect() )) # L1 x L2
     Bplane = TVector3(beamAxis.Cross( j.Vect() )) # Beam x JPsi, beam/JPsi plane
     if Zplane.Mag() == 0. or Bplane.Mag() == 0.: return -4.
     Zplane.SetMag(1.)
     Bplane.SetMag(1.)
     # Sign of Phi1
     sgn = j.Vect().Dot( Zplane.Cross(Bplane) )
     sgn /= abs(sgn)
     if abs(Zplane.Dot(Bplane)) > 1.: return -5.
     value = sgn * math.acos( Zplane.Dot(Bplane) )
     if value != value or math.isinf(value): return -5.
     return value
Exemple #9
0
 def test_many(self):
     nzeds = 100
     masses = np.linspace(80, 100, nzeds)
     boosts = np.linspace(1, 50, nzeds)
     thetas = np.linspace(1, math.pi, nzeds)
     for mass, boost, theta in zip(masses, boosts, thetas):
         energy = mass / 2.
         ptc1 = Particle(11, -1, TLorentzVector(0, energy, 0, energy))
         ptc2 = Particle(11, 1, TLorentzVector(0, -energy, 0, energy))
         resonance = Resonance(ptc1, ptc2, 23)
         p3_lab = TVector3()
         p3_lab.SetMagThetaPhi(boost, theta, 0.1)
         p4_lab = TLorentzVector()
         p4_lab.SetVectM(p3_lab, mass)
         bp4 = copy.deepcopy(resonance.p4())
         boost_vector = p4_lab.BoostVector()
         bp4.Boost(boost_vector)
         places = 8
         self.assertAlmostEqual(bp4.Vect().Mag(), boost, places)
         self.assertAlmostEqual(bp4.M(), mass, places)
         resonance.boost(boost_vector)
         self.assertAlmostEqual(bp4.E(), resonance.e(), places)
Exemple #10
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 #11
0
def jpsimuDirections(chiccand, jpsicand, frame='hx'):
    """return two directions: 
       1. direction vector of jpsi in the chic rest frame, wrt to the direction of chic
       2. direction vector of muon in the jpsi rest frame, wrt to the direction of the psi as seen in the chic rest frame"""

    pbeam = 3500
    Mpsi = 3.097
    Mprot = 0.938

    Ebeam = sqrt(pbeam**2 + Mprot**2)

    targ = TLorentzVector(0., 0., -pbeam, Ebeam)
    beam = TLorentzVector(0., 0., pbeam, Ebeam)

    # chic 4vector in lab frame
    chi = TLorentzVector()
    #chi.SetXYZM(chiccand.px(), chiccand.py(), chiccand.pz(), mass)
    chi.SetXYZM(chiccand.px(), chiccand.py(), chiccand.pz(), chiccand.mass())

    chi_direction = chi.Vect().Unit()

    # psi 4vector in lab fram
    psi = TLorentzVector()
    psi.SetXYZM(jpsicand.px(), jpsicand.py(), jpsicand.pz(), jpsicand.mass())

    cm_to_chi = -chi.BoostVector()
    chi_to_cm = chi.BoostVector()

    cm_to_psi = -psi.BoostVector()

    beam_chi = beam
    beam_chi.Boost(cm_to_chi)  # beam in the chi rest frame

    targ_chi = targ
    targ_chi.Boost(cm_to_chi)  # target in the chi rest frame

    beam_direction_chi = beam_chi.Vect().Unit()
    targ_direction_chi = targ_chi.Vect().Unit()
    beam_targ_bisec_chi = (beam_direction_chi - targ_direction_chi).Unit()

    psi_chi = psi
    psi_chi.Boost(cm_to_chi)  # psi in the chi rest frame

    psi_direction_chi = psi_chi.Vect().Unit()

    # all polarization frames have the same Y axis = the normal to the plane
    # formed by the directions of the colliding hadrons

    Yaxis = (beam_direction_chi.Cross(targ_direction_chi)).Unit()

    # transform(rotation) psi momentum components from polarization axis system
    # to the system with x,y,z axes as in the laboratory

    ChiPolAxis = chi_direction
    # helicity frame
    if frame is 'cs':
        ChiPolAxis = beam_targ_bisec_chi

    newZaxis = ChiPolAxis
    newYaxis = Yaxis
    newXaxis = newYaxis.Cross(newZaxis)

    # rotation needed to go to the chi rest frame
    rotation = TRotation()
    rotation.SetToIdentity()
    rotation.RotateAxes(newXaxis, newYaxis, newZaxis)
    rotation.Invert()

    psi_chi_rotated = psi_chi.Vect()

    psi_chi_rotated.Transform(rotation)
    # direction of the psi in the chi rest frame
    # relative to direction of chi in the lab

    # now calculate muon direction in the jpsi rest frame wrt chi direction
    mumass = 0.105

    Yaxis = (ChiPolAxis.Cross(psi_direction_chi)).Unit()

    newZaxis = psi_direction_chi
    newYaxis = Yaxis
    newXaxis = newYaxis.Cross(newZaxis)

    rotation.SetToIdentity()
    rotation.RotateAxes(newXaxis, newYaxis, newZaxis)
    rotation.Invert()

    #muon in the lab
    lepton = TLorentzVector()
    lepton.SetXYZM(
        jpsicand.daughter(0).px(),
        jpsicand.daughter(0).py(),
        jpsicand.daughter(0).pz(), mumass)

    #muon in the psi rest frame
    lepton_psi = lepton
    lepton_psi.Boost(cm_to_psi)

    lepton_psi_rotated = lepton_psi.Vect()
    lepton_psi_rotated.Transform(rotation)

    return psi_chi_rotated, lepton_psi_rotated
Exemple #12
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 #13
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 #14
0
    def BoostVector(self):

        vector = TLorentzVector.BoostVector(self)
        vector.__class__ = Vector3
        return vector
Exemple #15
0
 weight_mad = info_pruned.weight() / abs(info_pruned.weight())
 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: