Esempio n. 1
0
def FFV4_3(F1, F2, COUP, M3, W3):
    OM3 = 0.0
    if (M3): OM3 = 1.0 / M3**2
    V3 = wavefunctions.WaveFunction(size=6)
    V3[0] = F1[0] + F2[0]
    V3[1] = F1[1] + F2[1]
    P3 = [
        -complex(V3[0]).real, -complex(V3[1]).real, -complex(V3[1]).imag,
        -complex(V3[0]).imag
    ]
    TMP4 = (F1[4] * (F2[2] * (P3[0] - P3[3]) - F2[3] * (P3[1] + 1j *
                                                        (P3[2]))) + F1[5] *
            (F2[2] * (+1j * (P3[2]) - P3[1]) + F2[3] * (P3[0] + P3[3])))
    TMP1 = (F1[2] * (F2[4] * (P3[0] + P3[3]) + F2[5] * (P3[1] + 1j *
                                                        (P3[2]))) + F1[3] *
            (F2[4] * (P3[1] - 1j * (P3[2])) + F2[5] * (P3[0] - P3[3])))
    denom = COUP / (P3[0]**2 - P3[1]**2 - P3[2]**2 - P3[3]**2 - M3 *
                    (M3 - 1j * W3))
    V3[2] = denom * (-2j) * (
        OM3 * -1 / 2 * P3[0] * (TMP1 + 2 * (TMP4)) +
        (+1 / 2 *
         (F1[2] * F2[4] + F1[3] * F2[5]) + F1[4] * F2[2] + F1[5] * F2[3]))
    V3[3] = denom * (-2j) * (
        OM3 * -1 / 2 * P3[1] * (TMP1 + 2 * (TMP4)) +
        (-1 / 2 *
         (F1[2] * F2[5] + F1[3] * F2[4]) + F1[4] * F2[3] + F1[5] * F2[2]))
    V3[4] = denom * 2j * (OM3 * 1 / 2 * P3[2] * (TMP1 + 2 * (TMP4)) +
                          (+1j / 2 * (F1[2] * F2[5]) - 1j / 2 *
                           (F1[3] * F2[4]) - 1j * (F1[4] * F2[3]) + 1j *
                           (F1[5] * F2[2])))
    V3[5] = denom * 2j * (OM3 * 1 / 2 * P3[3] * (TMP1 + 2 * (TMP4)) +
                          (+1 / 2 * (F1[2] * F2[4]) - 1 / 2 *
                           (F1[3] * F2[5]) - F1[4] * F2[2] + F1[5] * F2[3]))
    return V3
def sxxxxx(p, nss):
    """initialize a scalar wavefunction"""

    sc = WaveFunction(1)

    sc[2] = complex(1., 0.)
    sc[0] = complex(p[0] * nss, p[3] * nss)
    sc[1] = complex(p[1] * nss, p[2] * nss)
    return sc
Esempio n. 3
0
def FFV1P0_3(F1, F2, COUP, M3, W3):
    V3 = wavefunctions.WaveFunction(size=6)
    V3[0] = F1[0] + F2[0]
    V3[1] = F1[1] + F2[1]
    P3 = [
        -complex(V3[0]).real, -complex(V3[1]).real, -complex(V3[1]).imag,
        -complex(V3[0]).imag
    ]
    denom = COUP / (P3[0]**2 - P3[1]**2 - P3[2]**2 - P3[3]**2 - M3 *
                    (M3 - 1j * W3))
    V3[2] = denom * (-1j) * (F1[2] * F2[4] + F1[3] * F2[5] + F1[4] * F2[2] +
                             F1[5] * F2[3])
    V3[3] = denom * (-1j) * (F1[4] * F2[3] + F1[5] * F2[2] - F1[2] * F2[5] -
                             F1[3] * F2[4])
    V3[4] = denom * (-1j) * (-1j * (F1[2] * F2[5] + F1[5] * F2[2]) + 1j *
                             (F1[3] * F2[4] + F1[4] * F2[3]))
    V3[5] = denom * (-1j) * (F1[3] * F2[5] + F1[4] * F2[2] - F1[2] * F2[4] -
                             F1[5] * F2[3])
    return V3
Esempio n. 4
0
def FFV2_3(F1, F2, COUP, M3, W3):
    OM3 = 0.0
    if (M3): OM3 = 1.0 / M3**2
    V3 = wavefunctions.WaveFunction(size=6)
    V3[0] = F1[0] + F2[0]
    V3[1] = F1[1] + F2[1]
    P3 = [
        -complex(V3[0]).real, -complex(V3[1]).real, -complex(V3[1]).imag,
        -complex(V3[0]).imag
    ]
    TMP1 = (F1[2] * (F2[4] * (P3[0] + P3[3]) + F2[5] * (P3[1] + 1j *
                                                        (P3[2]))) + F1[3] *
            (F2[4] * (P3[1] - 1j * (P3[2])) + F2[5] * (P3[0] - P3[3])))
    denom = COUP / (P3[0]**2 - P3[1]**2 - P3[2]**2 - P3[3]**2 - M3 *
                    (M3 - 1j * W3))
    V3[2] = denom * (-1j) * (F1[2] * F2[4] + F1[3] * F2[5] -
                             P3[0] * OM3 * TMP1)
    V3[3] = denom * (-1j) * (-F1[2] * F2[5] - F1[3] * F2[4] -
                             P3[1] * OM3 * TMP1)
    V3[4] = denom * (-1j) * (-1j * (F1[2] * F2[5]) + 1j *
                             (F1[3] * F2[4]) - P3[2] * OM3 * TMP1)
    V3[5] = denom * (-1j) * (F1[3] * F2[5] - F1[2] * F2[4] -
                             P3[3] * OM3 * TMP1)
    return V3
    def __init__(self, param_card=None):
        """ Instantiates using default value or the path of a SLHA param card."""
       
        # Param card accessor
        slha = ParamCard(param_card)
        
        self.ZERO = 0.

        # Computing independent parameters
        mdl_WH = slha.get_block_entry("decay", 25, 6.382339e-03);
        mdl_WT = slha.get_block_entry("decay", 6, 1.491500e+00);
        mdl_WW = slha.get_block_entry("decay", 24, 2.047600e+00);
        mdl_WZ = slha.get_block_entry("decay", 23, 2.441404e+00);
        mdl_MTA = slha.get_block_entry("mass", 15, 1.777000e+00);
        mdl_MH = slha.get_block_entry("mass", 25, 1.250000e+02);
        mdl_MB = slha.get_block_entry("mass", 5, 4.700000e+00);
        mdl_MT = slha.get_block_entry("mass", 6, 1.730000e+02);
        mdl_MZ = slha.get_block_entry("mass", 23, 9.118800e+01);
        mdl_ymtau = slha.get_block_entry("yukawa", 15, 1.777000e+00);
        mdl_ymt = slha.get_block_entry("yukawa", 6, 1.730000e+02);
        mdl_ymb = slha.get_block_entry("yukawa", 5, 4.700000e+00);
        aS = slha.get_block_entry("sminputs", 3, 1.180000e-01);
        mdl_Gf = slha.get_block_entry("sminputs", 2, 1.166390e-05);
        aEWM1 = slha.get_block_entry("sminputs", 1, 1.325070e+02);
        mdl_conjg__CKM3x3 = 1.0
        mdl_CKM3x3 = 1.0
        mdl_conjg__CKM1x1 = 1.0
        mdl_complexi = complex(0,1)
        mdl_MZ__exp__2 = mdl_MZ**2
        mdl_MZ__exp__4 = mdl_MZ**4
        mdl_sqrt__2 =  cmath.sqrt(2) 
        mdl_MH__exp__2 = mdl_MH**2
        mdl_aEW = 1/aEWM1
        mdl_MW = cmath.sqrt(mdl_MZ__exp__2/2. + cmath.sqrt(mdl_MZ__exp__4/4. - (mdl_aEW*cmath.pi*mdl_MZ__exp__2)/(mdl_Gf*mdl_sqrt__2)))
        mdl_sqrt__aEW =  cmath.sqrt(mdl_aEW) 
        mdl_ee = 2*mdl_sqrt__aEW*cmath.sqrt(cmath.pi)
        mdl_MW__exp__2 = mdl_MW**2
        mdl_sw2 = 1 - mdl_MW__exp__2/mdl_MZ__exp__2
        mdl_cw = cmath.sqrt(1 - mdl_sw2)
        mdl_sqrt__sw2 =  cmath.sqrt(mdl_sw2) 
        mdl_sw = mdl_sqrt__sw2
        mdl_g1 = mdl_ee/mdl_cw
        mdl_gw = mdl_ee/mdl_sw
        mdl_vev = (2*mdl_MW*mdl_sw)/mdl_ee
        mdl_vev__exp__2 = mdl_vev**2
        mdl_lam = mdl_MH__exp__2/(2.*mdl_vev__exp__2)
        mdl_yb = (mdl_ymb*mdl_sqrt__2)/mdl_vev
        mdl_yt = (mdl_ymt*mdl_sqrt__2)/mdl_vev
        mdl_ytau = (mdl_ymtau*mdl_sqrt__2)/mdl_vev
        mdl_muH = cmath.sqrt(mdl_lam*mdl_vev__exp__2)
        mdl_I1x33 = mdl_yb*mdl_conjg__CKM3x3
        mdl_I2x33 = mdl_yt*mdl_conjg__CKM3x3
        mdl_I3x33 = mdl_CKM3x3*mdl_yt
        mdl_I4x33 = mdl_CKM3x3*mdl_yb
        mdl_ee__exp__2 = mdl_ee**2
        mdl_sw__exp__2 = mdl_sw**2
        mdl_cw__exp__2 = mdl_cw**2

        # Computing independent couplings
        GC_3 = -(mdl_ee*mdl_complexi)
        GC_51 = (mdl_cw*mdl_ee*mdl_complexi)/(2.*mdl_sw)
        GC_59 = (mdl_ee*mdl_complexi*mdl_sw)/(2.*mdl_cw)

        # Computing dependent parameters
        mdl_sqrt__aS =  cmath.sqrt(aS) 
        G = 2*mdl_sqrt__aS*cmath.sqrt(cmath.pi)
        mdl_G__exp__2 = G**2

        # Computing independent parameters


        # Setting independent parameters
        # Model parameters independent of aS
        self.mdl_WH = float(mdl_WH.real)
        self.mdl_WT = float(mdl_WT.real)
        self.mdl_WW = float(mdl_WW.real)
        self.mdl_WZ = float(mdl_WZ.real)
        self.mdl_MTA = float(mdl_MTA.real)
        self.mdl_MH = float(mdl_MH.real)
        self.mdl_MB = float(mdl_MB.real)
        self.mdl_MT = float(mdl_MT.real)
        self.mdl_MZ = float(mdl_MZ.real)
        self.mdl_ymtau = float(mdl_ymtau.real)
        self.mdl_ymt = float(mdl_ymt.real)
        self.mdl_ymb = float(mdl_ymb.real)
        self.aS = float(aS.real)
        self.mdl_Gf = float(mdl_Gf.real)
        self.aEWM1 = float(aEWM1.real)
        self.mdl_conjg__CKM3x3 = float(mdl_conjg__CKM3x3.real)
        self.mdl_CKM3x3 = float(mdl_CKM3x3.real)
        self.mdl_conjg__CKM1x1 = float(mdl_conjg__CKM1x1.real)
        self.mdl_complexi = complex(mdl_complexi)
        self.mdl_MZ__exp__2 = float(mdl_MZ__exp__2.real)
        self.mdl_MZ__exp__4 = float(mdl_MZ__exp__4.real)
        self.mdl_sqrt__2 = float(mdl_sqrt__2.real)
        self.mdl_MH__exp__2 = float(mdl_MH__exp__2.real)
        self.mdl_aEW = float(mdl_aEW.real)
        self.mdl_MW = float(mdl_MW.real)
        self.mdl_sqrt__aEW = float(mdl_sqrt__aEW.real)
        self.mdl_ee = float(mdl_ee.real)
        self.mdl_MW__exp__2 = float(mdl_MW__exp__2.real)
        self.mdl_sw2 = float(mdl_sw2.real)
        self.mdl_cw = float(mdl_cw.real)
        self.mdl_sqrt__sw2 = float(mdl_sqrt__sw2.real)
        self.mdl_sw = float(mdl_sw.real)
        self.mdl_g1 = float(mdl_g1.real)
        self.mdl_gw = float(mdl_gw.real)
        self.mdl_vev = float(mdl_vev.real)
        self.mdl_vev__exp__2 = float(mdl_vev__exp__2.real)
        self.mdl_lam = float(mdl_lam.real)
        self.mdl_yb = float(mdl_yb.real)
        self.mdl_yt = float(mdl_yt.real)
        self.mdl_ytau = float(mdl_ytau.real)
        self.mdl_muH = float(mdl_muH.real)
        self.mdl_I1x33 = complex(mdl_I1x33)
        self.mdl_I2x33 = complex(mdl_I2x33)
        self.mdl_I3x33 = complex(mdl_I3x33)
        self.mdl_I4x33 = complex(mdl_I4x33)
        self.mdl_ee__exp__2 = float(mdl_ee__exp__2.real)
        self.mdl_sw__exp__2 = float(mdl_sw__exp__2.real)
        self.mdl_cw__exp__2 = float(mdl_cw__exp__2.real)

        # Setting independent couplings
        # Model parameters dependent on aS
        self.mdl_sqrt__aS = float(mdl_sqrt__aS.real)
        self.G = float(G.real)
        self.mdl_G__exp__2 = float(mdl_G__exp__2.real)

        # Setting dependent parameters
        # Model couplings independent of aS
        self.GC_3 = complex(GC_3)
        self.GC_51 = complex(GC_51)
        self.GC_59 = complex(GC_59)
def oxxxxx(p, fmass, nhel, nsf):
    """ initialize an outgoing fermion"""

    fo = WaveFunction(2)
    fo[0] = complex(p[0] * nsf, p[3] * nsf)
    fo[1] = complex(p[1] * nsf, p[2] * nsf)
    nh = nhel * nsf
    if (fmass != 0.):
        pp = min(p[0], sqrt(p[1]**2 + p[2]**2 + p[3]**2))
        if (pp == 0.):
            sqm = [sqrt(abs(fmass))]
            sqm.append(sign(sqm[0], fmass))
            ip = int(-((1 - nh) // 2) * nhel)
            im = int((1 + nh) // 2 * nhel)

            fo[2] = im * sqm[abs(im)]
            fo[3] = ip * nsf * sqm[abs(im)]
            fo[4] = im * nsf * sqm[abs(ip)]
            fo[5] = ip * sqm[abs(ip)]

        else:
            sf = [(1 + nsf + (1 - nsf) * nh) * 0.5,
                  (1 + nsf - (1 - nsf) * nh) * 0.5]
            omega = [sqrt(p[0] + pp), fmass / (sqrt(p[0] + pp))]
            ip = (1 + nh) // 2
            im = (1 - nh) // 2
            sfomeg = [sf[0] * omega[ip], sf[1] * omega[im]]
            pp3 = max(pp + p[3], 0.)
            if (pp3 == 0.):
                chi1 = complex(-nh, 0.)
            else:
                chi1 = complex(nh*p[1]/sqrt(2.*pp*pp3),\
                -p[2]/sqrt(2.*pp*pp3))
            chi = [complex(sqrt(pp3 * 0.5 / pp)), chi1]

            fo[2] = sfomeg[1] * chi[im]
            fo[3] = sfomeg[1] * chi[ip]
            fo[4] = sfomeg[0] * chi[im]
            fo[5] = sfomeg[0] * chi[ip]

    else:
        sqp0p3 = sqrt(max(p[0] + p[3], 0.)) * nsf
        if (sqp0p3 == 0.):
            chi1 = complex(-nhel * sqrt(2. * p[0]), 0.)
        else:
            chi1 = complex(nh * p[1] / sqp0p3, -p[2] / sqp0p3)
        chi = [complex(sqp0p3, 0.), chi1]
        if (nh == 1):
            fo[2] = chi[0]
            fo[3] = chi[1]
            fo[4] = complex(0., 0.)
            fo[5] = complex(0., 0.)
        else:
            fo[2] = complex(0., 0.)
            fo[3] = complex(0., 0.)
            fo[4] = chi[1]
            fo[5] = chi[0]

    return fo
def orxxxx(p, mass, nhel, nsr):
    """ initialize a incoming spin 3/2 wavefunction."""

    # This routines is a python translation of a routine written by
    # K.Mawatari in fortran dated from the 2008/02/26

    ro = WaveFunction(spin=4)

    sqh = sqrt(0.5)
    sq2 = sqrt(2)
    sq3 = sqrt(3)

    pt2 = p[1]**2 + p[2]**2
    pp = min([p[0], sqrt(pt2 + p[3]**2)])
    pt = min([pp, sqrt(pt2)])
    rc = {}
    rc[(4, 0)] = complex(p[0], p[3]) * nsr
    rc[(5, 0)] = complex(p[1], p[2]) * nsr

    nsv = nsr  # nsv=+1 for final, -1 for initial

    # Construct eps+
    if nhel > 0:
        ep = [0] * 4
        if pp:
            #ep[0] = 0
            ep[3] = pt / pp * sqh
            if pt:
                pzpt = p[3] / (pp * pt) * sqh
                ep[1] = complex(-p[1] * pzpt, -nsv * p[2] / pt * sqh)
                ep[2] = complex(-p[2] * pzpt, nsv * p[1] / pt * sqh)
            else:
                ep[1] = -sqh
                ep[2] = complex(0, nsv * sign(sqh, p[3]))
        else:
            #ep[0] = 0d0
            ep[1] = -sqh
            ep[2] = complex(0, nsv * sqh)
            #ep[3] = 0d0

    if (nhel < 0):
        #construct eps-
        em = [0] * 4
        if (pp == 0):
            #em[0] = 0
            em[1] = sqh
            em[2] = complex(0, nsv * sqh)
            #em[3] = 0
        else:
            #em[0] = 0
            em[3] = -pt / pp * sqh
            if pt:
                pzpt = -p[3] / (pp * pt) * sqh
                em[1] = complex(-p[1] * pzpt, -nsv * p[2] / pt * sqh)
                em[2] = complex(-p[2] * pzpt, nsv * p[1] / pt * sqh)
            else:
                em[1] = sqh
                em[2] = complex(0, nsv * sign(sqh, p[3]))

    if (abs(nhel) <= 1):
        #construct eps0
        e0 = [0] * 4
        if (pp == 0):
            #e0[0] = complex( rZero )
            #e0[1] = complex( rZero )
            #e0[2] = complex( rZero )
            e0[3] = 1
        else:
            emp = p[0] / (mass * pp)
            e0[0] = pp / mass
            e0[3] = p[3] * emp
            if pt:
                e0[1] = p[1] * emp
                e0[2] = p[2] * emp
            #else:
            #   e0[1] = complex( rZero )
            #   e0[2] = complex( rZero )

    if nhel >= -1:
        #constract spinor+
        nh = nsr
        sqm, fop, omega, sf, sfomeg = [0] * 2, [0] * 4, [0] * 2, [0] * 2, [
            0
        ] * 2
        chi = [0] * 2
        if mass:
            pp = min([p[0], sqrt(p[1]**2 + p[2]**2 + p[3]**2)])
            if (pp == 0):
                sqm[0] = sqrt(
                    abs(mass))  # possibility of negative fermion masses
                sqm[1] = sign(sqm[0],
                              mass)  # possibility of negative fermion masses
                ip = -((1 + nh) / 2)
                im = (1 - nh) / 2
                fop[0] = im * sqm[im]
                fop[1] = ip * nsr * sqm[im]
                fop[2] = im * nsr * sqm[-ip]
                fop[3] = ip * sqm[-ip]
            else:
                pp = min(p[0], sqrt(p[1]**2 + p[2]**2 + p[3]**2))
                sf[0] = (1 + nsr + (1 - nsr) * nh) * 0.5
                sf[1] = (1 + nsr - (1 - nsr) * nh) * 0.5
                omega[0] = sqrt(p[0] + pp)
                omega[1] = mass / omega[0]
                ip = (3 + nh) // 2 - 1  # -1 since this is index
                im = (3 - nh) // 2 - 1  # -1 since this is index
                sfomeg[0] = sf[0] * omega[ip]
                sfomeg[1] = sf[1] * omega[im]
                pp3 = max([pp + p[3], 0])
                chi[0] = sqrt(pp3 * 0.5 / pp)
                if pp3 == 0:
                    chi[1] = -nh
                else:
                    chi[1] = complex(nh * p[1], -p[2]) / sqrt(2 * pp * pp3)

                fop[0] = sfomeg[1] * chi[im]
                fop[1] = sfomeg[1] * chi[ip]
                fop[2] = sfomeg[0] * chi[im]
                fop[3] = sfomeg[0] * chi[ip]

        else:
            if (p[1] == 0 and p[2] == 0 and p[3] < 0):
                sqp0p3 = 0
            else:
                sqp0p3 = sqrt(max(p[0] + p[3], 0)) * nsr

            chi[0] = sqp0p3
            if (sqp0p3 == 0):
                chi[1] = complex(-nhel) * sqrt(2 * p[0])
            else:
                chi[1] = complex(nh * p[1], -p[2]) / sqp0p3

            if (nh == 1):
                fop[0] = chi[0]
                fop[1] = chi[1]
                #fop[2] = 0
                #fop[3] = 0
            else:
                #fop[0] = 0
                #fop[1] = 0
                fop[2] = chi[1]
                fop[3] = chi[0]

    if (nhel < 2):
        # constract spinor+
        sqm, fom, omega, sf, sfomeg = [0] * 2, [0] * 4, [0] * 2, [0] * 2, [
            0
        ] * 2
        chi = [0] * 2

        nh = -nsr
        if mass:
            pp = min([p[0], sqrt(p[1]**2 + p[2]**2 + p[3]**2)])
            if (pp == 0):
                sqm[0] = sqrt(
                    abs(mass))  # possibility of negative fermion masses
                sqm[1] = sign(sqm[0],
                              mass)  # possibility of negative fermion masses
                ip = -((1 + nh) / 2)
                im = (1 - nh) / 2

                fom[0] = im * sqm[im]
                fom[1] = ip * nsr * sqm[im]
                fom[2] = im * nsr * sqm[-ip]
                fom[3] = ip * sqm[-ip]

            else:
                pp = min([p[0], sqrt(p[1]**2 + p[2]**2 + p[3]**2)])
                sf[0] = (1 + nsr + (1 - nsr) * nh) * 0.5
                sf[1] = (1 + nsr - (1 - nsr) * nh) * 0.5
                omega[0] = sqrt(p[0] + pp)
                omega[1] = mass / omega[0]
                ip = (3 + nh) // 2 - 1  #-1 since ip is an index
                im = (3 - nh) // 2 - 1
                sfomeg[0] = sf[0] * omega[ip]
                sfomeg[1] = sf[1] * omega[im]
                pp3 = max([pp + p[3], 0])
                chi[0] = sqrt(pp3 * 0.5 / pp)
                if (pp3 == 0):
                    chi[1] = -nh
                else:
                    chi[1] = complex(nh * p[1], -p[2]) / sqrt(2 * pp * pp3)

                fom[0] = sfomeg[1] * chi[im]
                fom[1] = sfomeg[1] * chi[ip]
                fom[2] = sfomeg[0] * chi[im]
                fom[3] = sfomeg[0] * chi[ip]
        else:
            if (p[1] == 0 == p[2] and p[3] < 0):
                sqp0p3 = 0
            else:
                sqp0p3 = sqrt(max([p[0] + p[3], 0])) * nsr
            chi[0] = sqp0p3
            if (sqp0p3 == 0):
                chi[1] = complex(-nhel) * sqrt(2 * p[0])
            else:
                chi[1] = complex(nh * p[1], -p[2]) / sqp0p3
            if (nh == 1):
                fom[0] = chi[0]
                fom[1] = chi[1]
                #fom[2] = 0
                #fom[3] = 0
            else:
                #fom[1] = 0
                #fom[2] = 0
                fom[2] = chi[1]
                fom[3] = chi[0]

    cond1 = (pt == 0 and p[3] >= 0)
    cond2 = (pt == 0 and p[3] < 0)

    # spin-3/2 fermion wavefunction
    if nhel == 3:
        for i, j in product(range(4), range(4)):
            rc[(i, j)] = ep[i] * fop[j]

    elif nhel == 1:
        for i, j in product(range(4), range(4)):
            if cond1:
                rc[(i,
                    j)] = sq2 / sq3 * e0[i] * fop[j] + 1 / sq3 * ep[i] * fom[j]
            elif cond2:
                rc[(i,
                    j)] = sq2 / sq3 * e0[i] * fop[j] - 1 / sq3 * ep[i] * fom[j]
            else:
                rc[(i,j)] = sq2/sq3*e0[i]*fop[j] + 1/sq3*ep[i]*fom[j] * \
                                                      complex(p[1],-nsr*p[2])/pt

    elif nhel == -1:
        for i, j in product(range(4), range(4)):
            if cond1:
                rc[(i,
                    j)] = 1 / sq3 * em[i] * fop[j] + sq2 / sq3 * e0[i] * fom[j]
            elif cond2:
                rc[(i,
                    j)] = 1 / sq3 * em[i] * fop[j] - sq2 / sq3 * e0[i] * fom[j]
            else:
                rc[(i,j)] =  1/sq3*em[i]*fop[j] + sq2/sq3*e0[i]*fom[j] *\
                                                      complex(p[1],-nsr*p[2])/pt
    else:
        for i, j in product(range(4), range(4)):
            if cond1:
                rc[(i, j)] = em[i] * fom[j]
            elif cond2:
                rc[(i, j)] = -em[i] * fom[j]
            else:
                rc[(i, j)] = em[i] * fom[j] * complex(p[1], -nsr * p[2]) / pt

    ro[2] = rc[(0, 0)]
    ro[3] = rc[(0, 1)]
    ro[4] = rc[(0, 2)]
    ro[5] = rc[(0, 3)]
    ro[6] = rc[(1, 0)]
    ro[7] = rc[(1, 1)]
    ro[8] = rc[(1, 2)]
    ro[9] = rc[(1, 3)]
    ro[10] = rc[(2, 0)]
    ro[11] = rc[(2, 1)]
    ro[12] = rc[(2, 2)]
    ro[13] = rc[(2, 3)]
    ro[14] = rc[(3, 0)]
    ro[15] = rc[(3, 1)]
    ro[16] = rc[(3, 2)]
    ro[17] = rc[(3, 3)]
    ro[0] = rc[(4, 0)]
    ro[1] = rc[(5, 0)]

    return ro
def irxxxx(p, mass, nhel, nsr):
    """ initialize a incoming spin 3/2 wavefunction."""

    # This routines is a python translation of a routine written by
    # K.Mawatari in fortran dated from the 2008/02/26

    ri = WaveFunction(4)

    sqh = sqrt(0.5)
    sq2 = sqrt(2)
    sq3 = sqrt(3)

    pt2 = p[1]**2 + p[2]**2
    pp = min([p[0], sqrt(pt2 + p[3]**2)])
    pt = min([pp, sqrt(pt2)])

    rc = {}
    rc[(4, 0)] = -1.0 * complex(p[0], p[3]) * nsr
    rc[(5, 0)] = -1.0 * complex(p[1], p[2]) * nsr

    nsv = -nsr  # nsv=+1 for final, -1 for initial

    # Construct eps+
    if nhel > 0:
        ep = [0] * 4
        if pp:
            #ep[0] = 0
            ep[3] = pt / pp * sqh
            if pt:
                pzpt = p[3] / (pp * pt) * sqh
                ep[1] = complex(-p[1] * pzpt, -nsv * p[2] / pt * sqh)
                ep[2] = complex(-p[2] * pzpt, nsv * p[1] / pt * sqh)
            else:
                ep[1] = -sqh
                ep[2] = complex(0, nsv * sign(sqh, p[3]))
        else:
            #ep[0] = 0d0
            ep[1] = -sqh
            ep[2] = complex(0, nsv * sqh)
            #ep[3] = 0d0

    if (nhel < 0):
        #construct eps-
        em = [0] * 4
        if (pp == 0):
            #em[0] = 0
            em[1] = sqh
            em[2] = complex(0, nsv * sqh)
            #em[3] = 0
        else:
            #em[0] = 0
            em[3] = -pt / pp * sqh
            if pt:
                pzpt = -p[3] / (pp * pt) * sqh
                em[1] = complex(-p[1] * pzpt, -nsv * p[2] / pt * sqh)
                em[2] = complex(-p[2] * pzpt, nsv * p[1] / pt * sqh)
            else:
                em[1] = sqh
                em[2] = complex(0, nsv * sign(sqh, p[3]))

    if (abs(nhel) <= 1):
        #construct eps0
        e0 = [0] * 4
        if (pp == 0):
            #e0[0] = complex( rZero )
            #e0[1] = complex( rZero )
            #e0[2] = complex( rZero )
            e0[3] = 1
        else:
            emp = p[0] / (mass * pp)
            e0[0] = pp / mass
            e0[3] = p[3] * emp
            if pt:
                e0[1] = p[1] * emp
                e0[2] = p[2] * emp
            #else:
            #   e0[1] = complex( rZero )
            #   e0[2] = complex( rZero )

    if (nhel >= -1):
        # constract spinor+
        fip = [0] * 4
        sf, omega, sfomeg, chi = [0, 0], [0, 0], [0, 0], [0, 0]
        nh = nsr
        if mass:
            pp = min([p[0], sqrt(p[1]**2 + p[2]**2 + p[3]**2)])
            if pp == 0:
                sqm = sqrt(mass)
                ip = (1 + nh) // 2
                im = (1 - nh) // 2
                fip[0] = ip * sqm
                fip[1] = im * nsr * sqm
                fip[2] = ip * nsr * sqm
                fip[3] = im * sqm
            else:
                sf[0] = float(1 + nsr + (1 - nsr) * nh) * 0.5
                sf[1] = float(1 + nsr - (1 - nsr) * nh) * 0.5
                omega[0] = sqrt(p[0] + pp)
                omega[1] = mass / omega[0]
                ip = ((3 + nh) // 2) - 1  # -1 since they are index
                im = ((3 - nh) // 2) - 1  # -1 since they are index
                sfomeg[0] = sf[0] * omega[ip]
                sfomeg[1] = sf[1] * omega[im]
                pp3 = max([pp + p[3], 0])
                chi[0] = sqrt(pp3 * 0.5 / pp)
                if pp3 == 0:
                    chi[1] = -nh
                else:
                    chi[1] = complex(nh * p[1], p[2]) / sqrt(2 * pp * pp3)

                fip[0] = sfomeg[0] * chi[im]
                fip[1] = sfomeg[0] * chi[ip]
                fip[2] = sfomeg[1] * chi[im]
                fip[3] = sfomeg[1] * chi[ip]
        else:
            sqp0p3 = sqrt(max([p[0] + p[3], 0])) * nsr
            chi[0] = sqp0p3
            if sqp0p3 == 0:
                chi[1] = -nhel * sqrt(2 * p[0])
            else:
                chi[1] = complex(nh * p[1], p[2]) / sqp0p3
            if nh == 1:
                #fip[0] = complex( rZero )
                #fip[1] = complex( rZero )
                fip[2] = chi[0]
                fip[3] = chi[1]
            else:
                fip[0] = chi[1]
                fip[1] = chi[0]
                #fip(3) = complex( rZero )
                #fip(4) = complex( rZero )

    if (nhel <= 1):
        # constract spinor-
        fim = [0] * 4
        sf, omega, sfomeg, chi = [0, 0], [0, 0], [0, 0], [0, 0]
        nh = -nsr
        if mass:
            pp = min([p[0], sqrt(p[1]**2 + p[2]**2 + p[3]**2)])
            if pp == 0:
                sqm = sqrt(mass)
                ip = (1 + nh) / 2
                im = (1 - nh) / 2
                fim[0] = ip * sqm
                fim[1] = im * nsr * sqm
                fim[2] = ip * nsr * sqm
                fim[3] = im * sqm
            else:
                sf[0] = float(1 + nsr + (1 - nsr) * nh) * 0.5
                sf[1] = float(1 + nsr - (1 - nsr) * nh) * 0.5
                omega[0] = sqrt(p[0] + pp)
                omega[1] = mass / omega[0]
                ip = (3 + nh) // 2 - 1
                im = (3 - nh) // 2 - 1
                sfomeg[0] = sf[0] * omega[ip]
                sfomeg[1] = sf[1] * omega[im]
                pp3 = max([pp + p[3], 0])
                chi[0] = sqrt(pp3 * 0.5 / pp)
                if pp3 == 0:
                    chi[1] = -nh
                else:
                    chi[1] = complex(nh * p[1], p[2]) / sqrt(2 * pp * pp3)

                fim[0] = sfomeg[0] * chi[im]
                fim[1] = sfomeg[0] * chi[ip]
                fim[2] = sfomeg[1] * chi[im]
                fim[3] = sfomeg[1] * chi[ip]
        else:
            sqp0p3 = sqrt(max([p[0] + p[3], 0])) * nsr
            chi[0] = sqp0p3
            if sqp0p3 == 0:
                chi[1] = -nhel * sqrt(2 * p[0])
            else:
                chi[1] = complex(nh * p[1], p[2]) / sqp0p3
            if nh == 1:
                #fip[0] = complex( rZero )
                #fip[1] = complex( rZero )
                fim[2] = chi[0]
                fim[3] = chi[1]
            else:
                fim[0] = chi[1]
                fim[1] = chi[0]
                #fip(3) = complex( rZero )
                #fip(4) = complex( rZero )

    # recurent relation put her for optimization
    cond1 = (pt == 0 and p[3] >= 0)
    cond2 = (pt == 0 and p[3] < 0)

    # spin-3/2 fermion wavefunction
    if nhel == 3:
        for i, j in product(range(4), range(4)):
            rc[(i, j)] = ep[i] * fip[j]

    elif nhel == 1:
        for i, j in product(range(4), range(4)):
            if cond1:
                rc[(i,
                    j)] = sq2 / sq3 * e0[i] * fip[j] + 1 / sq3 * ep[i] * fim[j]
            elif cond2:
                rc[(i,
                    j)] = sq2 / sq3 * e0[i] * fip[j] - 1 / sq3 * ep[i] * fim[j]
            else:
                rc[(i,j)] = sq2/sq3*e0[i]*fip[j] + \
                                   1/sq3*ep[i]*fim[j] *complex(p[1],nsr*p[2])/pt
    elif nhel == -1:
        for i, j in product(range(4), range(4)):
            if cond1:
                rc[(i,
                    j)] = 1 / sq3 * em[i] * fip[j] + sq2 / sq3 * e0[i] * fim[j]
            elif cond2:
                rc[(i,
                    j)] = 1 / sq3 * em[i] * fip[j] - sq2 / sq3 * e0[i] * fim[j]
            else:
                rc[(i,j)] = 1/sq3*em[i]*fip[j] + \
                                sq2/sq3*e0[i]*fim[j] *complex(p[1],nsr*p[2])/pt
    else:
        for i, j in product(range(4), range(4)):
            if cond1:
                rc[(i, j)] = em[i] * fim[j]
            elif cond2:
                rc[(i, j)] = -em[i] * fim[j]
            else:
                rc[(i, j)] = em[i] * fim[j] * complex(p[1], nsr * p[2]) / pt

    ri[2] = rc[(0, 0)]
    ri[3] = rc[(0, 1)]
    ri[4] = rc[(0, 2)]
    ri[5] = rc[(0, 3)]
    ri[6] = rc[(1, 0)]
    ri[7] = rc[(1, 1)]
    ri[8] = rc[(1, 2)]
    ri[9] = rc[(1, 3)]
    ri[10] = rc[(2, 0)]
    ri[11] = rc[(2, 1)]
    ri[12] = rc[(2, 2)]
    ri[13] = rc[(2, 3)]
    ri[14] = rc[(3, 0)]
    ri[15] = rc[(3, 1)]
    ri[16] = rc[(3, 2)]
    ri[17] = rc[(3, 3)]
    ri[0] = rc[(4, 0)]
    ri[1] = rc[(5, 0)]

    return ri
def txxxxx(p, tmass, nhel, nst):
    """ initialize a tensor wavefunction"""

    tc = WaveFunction(5)

    sqh = sqrt(0.5)
    sqs = sqrt(1 / 6)

    pt2 = p[1]**2 + p[2]**2
    pp = min(p[0], sqrt(pt2 + p[3]**2))
    pt = min(pp, sqrt(pt2))

    ft = {}
    ft[(4, 0)] = complex(p[0], p[3]) * nst
    ft[(5, 0)] = complex(p[1], p[2]) * nst

    if (nhel >= 0):
        #construct eps+
        ep = [0] * 4

        if (pp == 0):
            #ep[0] = 0
            ep[1] = -sqh
            ep[2] = complex(0, nst * sqh)
            #ep[3] = 0
        else:
            #ep[0] = 0
            ep[3] = pt / pp * sqh
            if (pt != 0):
                pzpt = p[3] / (pp * pt) * sqh
                ep[1] = complex(-p[1] * pzpt, -nst * p[2] / pt * sqh)
                ep[2] = complex(-p[2] * pzpt, nst * p[1] / pt * sqh)
            else:
                ep[1] = -sqh
                ep[2] = complex(0, nst * sign(sqh, p[3]))

    if (nhel <= 0):
        #construct eps-
        em = [0] * 4
        if (pp == 0):
            #em[0] = 0
            em[1] = sqh
            em[2] = complex(0, nst * sqh)
            #em[3] = 0
        else:
            #em[0] = 0
            em[3] = -pt / pp * sqh
            if pt:
                pzpt = -p[3] / (pp * pt) * sqh
                em[1] = complex(-p[1] * pzpt, -nst * p[2] / pt * sqh)
                em[2] = complex(-p[2] * pzpt, nst * p[1] / pt * sqh)
            else:
                em[1] = sqh
                em[2] = complex(0, nst * sign(sqh, p[3]))

    if (abs(nhel) <= 1):
        #construct eps0
        e0 = [0] * 4
        if (pp == 0):
            #e0[0] = complex( rZero )
            #e0[1] = complex( rZero )
            #e0[2] = complex( rZero )
            e0[3] = 1
        else:
            emp = p[0] / (tmass * pp)
            e0[0] = pp / tmass
            e0[3] = p[3] * emp
            if pt:
                e0[1] = p[1] * emp
                e0[2] = p[2] * emp
            #else:
            #   e0[1] = complex( rZero )
            #   e0[2] = complex( rZero )

    if nhel == 2:
        for j in range(4):
            for i in range(4):
                ft[(i, j)] = ep[i] * ep[j]
    elif nhel == -2:
        for j in range(4):
            for i in range(4):
                ft[(i, j)] = em[i] * em[j]
    elif tmass == 0:
        for j in range(4):
            for i in range(4):
                ft[(i, j)] = 0
    elif nhel == 1:
        for j in range(4):
            for i in range(4):
                ft[(i, j)] = sqh * (ep[i] * e0[j] + e0[i] * ep[j])
    elif nhel == 0:
        for j in range(4):
            for i in range(4):
                ft[(i, j)] = sqs * (ep[i] * em[j] + em[i] * ep[j] +
                                    2 * e0[i] * e0[j])
    elif nhel == -1:
        for j in range(4):
            for i in range(4):
                ft[(i, j)] = sqh * (em[i] * e0[j] + e0[i] * em[j])

    else:
        raise Exception, 'invalid helicity TXXXXXX'

    tc[2] = ft[(0, 0)]
    tc[3] = ft[(0, 1)]
    tc[4] = ft[(0, 2)]
    tc[5] = ft[(0, 3)]
    tc[6] = ft[(1, 0)]
    tc[7] = ft[(1, 1)]
    tc[8] = ft[(1, 2)]
    tc[9] = ft[(1, 3)]
    tc[10] = ft[(2, 0)]
    tc[11] = ft[(2, 1)]
    tc[12] = ft[(2, 2)]
    tc[13] = ft[(2, 3)]
    tc[14] = ft[(3, 0)]
    tc[15] = ft[(3, 1)]
    tc[16] = ft[(3, 2)]
    tc[17] = ft[(3, 3)]
    tc[0] = ft[(4, 0)]
    tc[1] = ft[(5, 0)]

    return tc
def ixxxxx(p, fmass, nhel, nsf):
    """Defines an inflow fermion."""

    fi = WaveFunction(2)

    fi[0] = complex(-1.0 * p[0] * nsf, -1.0 * p[3] * nsf)
    fi[1] = complex(-1.0 * p[1] * nsf, -1.0 * p[2] * nsf)
    nh = nhel * nsf
    if (fmass != 0.):
        pp = min(p[0], sqrt(p[1]**2 + p[2]**2 + p[3]**2))
        if (pp == 0.):
            sqm = [sqrt(abs(fmass))]
            sqm.append(sign(sqm[0], fmass))
            ip = (1 + nh) // 2
            im = (1 - nh) // 2

            fi[2] = ip * sqm[ip]
            fi[3] = im * nsf * sqm[ip]
            fi[4] = ip * nsf * sqm[im]
            fi[5] = im * sqm[im]

        else:
            sf = [(1 + nsf + (1 - nsf) * nh) * 0.5,
                  (1 + nsf - (1 - nsf) * nh) * 0.5]
            omega = [sqrt(p[0] + pp), fmass / (sqrt(p[0] + pp))]
            ip = (1 + nh) // 2
            im = (1 - nh) // 2
            sfomeg = [sf[0] * omega[ip], sf[1] * omega[im]]
            pp3 = max(pp + p[3], 0.)
            if (pp3 == 0.):
                chi1 = complex(-nh, 0.)
            else:
                chi1 = complex(nh*p[1]/sqrt(2.*pp*pp3),\
                p[2]/sqrt(2.*pp*pp3))
            chi = [complex(sqrt(pp3 * 0.5 / pp)), chi1]

            fi[2] = sfomeg[0] * chi[im]
            fi[3] = sfomeg[0] * chi[ip]
            fi[4] = sfomeg[1] * chi[im]
            fi[5] = sfomeg[1] * chi[ip]

    else:
        sqp0p3 = sqrt(max(p[0] + p[3], 0.)) * nsf
        if (sqp0p3 == 0.):
            chi1 = complex(-nhel * sqrt(2. * p[0]), 0.)
        else:
            chi1 = complex(nh * p[1] / sqp0p3, p[2] / sqp0p3)
        chi = [complex(sqp0p3, 0.), chi1]
        if (nh == 1):
            fi[2] = complex(0., 0.)
            fi[3] = complex(0., 0.)
            fi[4] = chi[0]
            fi[5] = chi[1]
        else:
            fi[2] = chi[1]
            fi[3] = chi[0]
            fi[4] = complex(0., 0.)
            fi[5] = complex(0., 0.)

    return fi
def vxxxxx(p, vmass, nhel, nsv):
    """ initialize a vector wavefunction. nhel=4 is for checking BRST"""

    vc = WaveFunction(3)

    sqh = sqrt(0.5)
    nsvahl = nsv * abs(nhel)
    pt2 = p[1]**2 + p[2]**2
    pp = min(p[0], sqrt(pt2 + p[3]**2))
    pt = min(pp, sqrt(pt2))

    vc[0] = complex(p[0] * nsv, p[3] * nsv)
    vc[1] = complex(p[1] * nsv, p[2] * nsv)

    if (nhel == 4):
        if (vmass == 0.):
            vc[2] = 1.
            vc[3] = p[1] / p[0]
            vc[4] = p[2] / p[0]
            vc[5] = p[3] / p[0]
        else:
            vc[2] = p[0] / vmass
            vc[3] = p[1] / vmass
            vc[4] = p[2] / vmass
            vc[5] = p[3] / vmass

        return vc

    if (vmass != 0.):
        hel0 = 1. - abs(nhel)

        if (pp == 0.):
            vc[2] = complex(0., 0.)
            vc[3] = complex(-nhel * sqh, 0.)
            vc[4] = complex(0., nsvahl * sqh)
            vc[5] = complex(hel0, 0.)

        else:
            emp = p[0] / (vmass * pp)
            vc[2] = complex(hel0 * pp / vmass, 0.)
            vc[5] = complex(hel0 * p[3] * emp + nhel * pt / pp * sqh)
            if (pt != 0.):
                pzpt = p[3] / (pp * pt) * sqh * nhel
                vc[3] = complex(hel0*p[1]*emp-p[1]*pzpt, \
                    -nsvahl*p[2]/pt*sqh)
                vc[4] = complex(hel0*p[2]*emp-p[2]*pzpt, \
                    nsvahl*p[1]/pt*sqh)
            else:
                vc[3] = complex(-nhel * sqh, 0.)
                vc[4] = complex(0., nsvahl * sign(sqh, p[3]))
    else:
        pp = p[0]
        pt = sqrt(p[1]**2 + p[2]**2)
        vc[2] = complex(0., 0.)
        vc[5] = complex(nhel * pt / pp * sqh)
        if (pt != 0.):
            pzpt = p[3] / (pp * pt) * sqh * nhel
            vc[3] = complex(-p[1] * pzpt, -nsv * p[2] / pt * sqh)
            vc[4] = complex(-p[2] * pzpt, nsv * p[1] / pt * sqh)
        else:
            vc[3] = complex(-nhel * sqh, 0.)
            vc[4] = complex(0., nsv * sign(sqh, p[3]))

    return vc