def test_evaluate(self):
        b0_mass = 5.27955
        jpsi_mass = 3.0969
        k_mass = 0.493677
        pi_mass = 0.13957061

        b0 = hypy.Vector4R(b0_mass, 0.0, 0.0, 0.0)
        masses = [jpsi_mass, k_mass, pi_mass]
        phsp = hypy.PhaseSpace3(b0_mass, masses)

        result = hypy.host_vector_float2(5)
        phsp.EvaluateOnhost(b0, result, functor)
        tup = ((0.004857093031, -0.999950534243),
               (0.006868934284, -0.999842558622), (0.011390565091,
                                                   -0.999882127917),
               (0.016108047503, -0.999560206432), (0.020888558031,
                                                   -0.999196543388))

        for i in range(5):
            self.assertAlmostEqual(tup[i][0], result[i][0])
            self.assertAlmostEqual(tup[i][1], result[i][1])
Exemple #2
0
def main():

    nentries = 1000000
    B0_mass = 5.27955  # All masses are given in GeV/c^2
    Jpsi_mass = 3.0969
    K_mass = 0.493677
    pi_mass = 0.13957061
    if len(sys.argv) > 1:
        nentries = int(sys.argv[1])

    B0 = hypy.Vector4R(B0_mass, 0.0, 0.0, 0.0)
    masses = [Jpsi_mass, K_mass, pi_mass]  # List of final-state particles
    phsp = hypy.PhaseSpace3(B0_mass, masses)

    #     Device    #

    print()
    print(
        constants.RED,
        "ERROR: device is not supported with custom functors in current HydraPython version."
    )
    print(constants.RESET)

    #     Host    #
    result = hypy.host_vector_float2(nentries)
    start = time.time()
    phsp.EvaluateOnhost(B0, result, functor)
    end = time.time()

    print('\n' * 2)
    print("----------------- Host ----------------")
    print("| B0 -> J/psi K pi")
    print("| Number of events :", nentries)
    print("| Time (ms)        :", end - start)
    print("-----------------------------------------")

    for i in range(10):
        print("<", i, ">: ", result[i])