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    #
    start = time.time()
    pair = phsp.AverageOnhost(B0, functor, nentries)
    end = time.time()

    print('\n' * 2)
    print("----------------- Host ----------------")
    print("|< cos(theta_K) >(B0 -> J/psi K pi): ", pair[0], " +- ", pair[1])
    print("| Number of events :", nentries)
    print("| Time (ms)        :", end - start)
    print("-----------------------------------------")
Beispiel #2
0
 def test_N_PhaseSpace(self):
     vector_mass = 9629.140252
     ps1 = hypy.PhaseSpace1(vector_mass, random_floats(0.1, 2.2, 1))
     ps2 = hypy.PhaseSpace2(vector_mass, random_floats(0.1, 2.2, 2))
     ps3 = hypy.PhaseSpace3(vector_mass, random_floats(0.1, 2.2, 3))
     ps4 = hypy.PhaseSpace4(vector_mass, random_floats(0.1, 2.2, 4))
     ps5 = hypy.PhaseSpace5(vector_mass, random_floats(0.1, 2.2, 5))
     ps6 = hypy.PhaseSpace6(vector_mass, random_floats(0.1, 2.2, 6))
     ps7 = hypy.PhaseSpace7(vector_mass, random_floats(0.1, 2.2, 7))
     ps8 = hypy.PhaseSpace8(vector_mass, random_floats(0.1, 2.2, 8))
     ps9 = hypy.PhaseSpace9(vector_mass, random_floats(0.1, 2.2, 9))
     ps10 = hypy.PhaseSpace10(vector_mass, random_floats(0.1, 2.2, 10))
     self.assertIsInstance(ps1, hypy.PhaseSpace1,
                           'Failure: Not an instance of PhaseSpace1')
     self.assertIsInstance(ps2, hypy.PhaseSpace2,
                           'Failure: Not an instance of PhaseSpace2')
     self.assertIsInstance(ps3, hypy.PhaseSpace3,
                           'Failure: Not an instance of PhaseSpace3')
     self.assertIsInstance(ps4, hypy.PhaseSpace4,
                           'Failure: Not an instance of PhaseSpace4')
     self.assertIsInstance(ps5, hypy.PhaseSpace5,
                           'Failure: Not an instance of PhaseSpace5')
     self.assertIsInstance(ps6, hypy.PhaseSpace6,
                           'Failure: Not an instance of PhaseSpace6')
     self.assertIsInstance(ps7, hypy.PhaseSpace7,
                           'Failure: Not an instance of PhaseSpace7')
     self.assertIsInstance(ps8, hypy.PhaseSpace8,
                           'Failure: Not an instance of PhaseSpace8')
     self.assertIsInstance(ps9, hypy.PhaseSpace9,
                           'Failure: Not an instance of PhaseSpace9')
     self.assertIsInstance(ps10, hypy.PhaseSpace10,
                           'Failure: Not an instance of PhaseSpace10')
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
    mu_mass = 0.1056583745
    if len(sys.argv) > 1:
        nentries = int(sys.argv[1])

    B0 = hypy.Vector4R(B0_mass, 0.0, 0.0, 0.0)
    masses1 = [Jpsi_mass, K_mass, pi_mass]  # List of daughter particles
    masses2 = [mu_mass, mu_mass]  # List of grand-daughter particles

    phsp1 = hypy.PhaseSpace3(masses1)
    phsp2 = hypy.PhaseSpace2(masses2)

    #     Device    #

    daughters_d = hypy.host_events_3(nentries)
    grand_daughters_d = hypy.host_events_2(nentries)
    start = time.time()

    phsp1.GenerateOnhost(B0, daughters_d)
    phsp2.GenerateOnhost(daughters_d.getDaughters(0), grand_daughters_d)

    end = time.time()

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

    for i in range(10):
        print(daughters_d[i], grand_daughters_d[i])

    #     Host    #

    daughters_h = hypy.host_events_3(nentries)
    grand_daughters_h = hypy.host_events_2(nentries)
    start = time.time()

    phsp1.GenerateOnhost(B0, daughters_h)
    phsp2.GenerateOnhost(daughters_h.getDaughters(0), grand_daughters_h)

    end = time.time()

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

    for i in range(10):
        print(daughters_h[i], grand_daughters_h[i])
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(masses)

    #     Device    #
    events_d = hypy.device_events_3(nentries)
    start = time.time()
    phsp.GenerateOndevice(B0, events_d)
    end = time.time()

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

    for i in range(10):
        print(events_d[i])

    #     Host    #
    events_h = hypy.host_events_3(nentries)
    start = time.time()
    phsp.GenerateOnhost(B0, events_h)
    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(events_h[i])
Beispiel #5
0
    def test_generator_2(self):
        nentries = 5
        B0_mass = 5.27955
        Jpsi_mass = 3.0969
        K_mass = 0.493677
        pi_mass = 0.13957061
        mu_mass = 0.1056583745

        B0 = hypy.Vector4R(B0_mass, 0.0, 0.0, 0.0)
        masses1 = [Jpsi_mass, K_mass, pi_mass]
        masses2 = [mu_mass, mu_mass]

        phsp1 = hypy.PhaseSpace3(B0_mass, masses1)
        phsp2 = hypy.PhaseSpace2(Jpsi_mass, masses2)

        daughters_d = hypy.host_events_3(nentries)
        grand_daughters_d = hypy.host_events_2(nentries)

        phsp1.GenerateOnhost(B0, daughters_d)
        phsp2.GenerateOnhost(daughters_d.getDaughters(0), grand_daughters_d)
Beispiel #6
0
    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])
Beispiel #7
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])