예제 #1
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    #
    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("-----------------------------------------")
예제 #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')
예제 #3
0
    def test_generator_1(self):
        vec4 = hypy.Vector4R(5.2795, 0.0, 0.0, 0.0)
        phsp = hypy.PhaseSpace4(vec4.mass(),
                                [3.096916, 0.493677, 0.13957018, 0.0195018])
        e_host = hypy.host_events_4(3)
        phsp.GenerateOnhost(vec4, e_host)
        tup = ((0.00050889380, (3.313285880268, 0.981747490679, 0.005536704420,
                                -0.650473537337),
                (0.528272074985, 0.154894458053, 0.006307332616,
                 -0.106406434487), (0.209418530338, -0.152425202031,
                                    0.024947630249, 0.022813575657),
                (1.228523514408, -0.984216746700, -0.036791667286,
                 0.734066396167)),
               (0.058617670787, (3.181438349277, -0.034345750002,
                                 0.692455498149, 0.223577753225),
                (0.595461244293, -0.018288616145, -0.053836704201,
                 -0.328061349334), (0.910711077543, 0.099545613220,
                                    -0.759288734814, -0.472743185766),
                (0.591889328884, -0.046911247072, 0.120669940866,
                 0.577226781875)),
               (0.037078448741, (3.436518049135, -0.543157507761,
                                 1.201628372929, 0.692702509097),
                (1.109001046733, 0.238844824859, -0.908952559761,
                 -0.320818850861), (0.551878708090, 0.310808628125,
                                    -0.378529831045, -0.212610999220),
                (0.182102196040, -0.006495945222, 0.085854017877,
                 -0.159272659014)))
        self.check_equals(e_host, tup)

        e_device = hypy.device_events_4(3)
        phsp.GenerateOndevice(vec4, e_device)
        self.check_equals(e_device, tup)
 def test_average_on(self):
     vec4 = hypy.Vector4R(5.2795, 0.0, 0.0, 0.0)
     p = hypy.PhaseSpace4([3.096916, 0.493677, 0.13957018, 0.0195018])
     tup1 = p.AverageOnhost(vec4, functor, 10)
     tup2 = (-0.983049786694, 0.010451881904)
     self.assertAlmostEqual(tup1[0], tup2[0])
     self.assertAlmostEqual(tup1[1], tup2[1])
예제 #5
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(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])
예제 #6
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
    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])
예제 #7
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)
예제 #8
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])
예제 #9
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])
예제 #10
0
 def test_seed(self):
     vector_mass = 5.140252
     float_list = [1.1, 1.2, 0.242, 0.8385977]
     ps = hypy.PhaseSpace4(vector_mass, float_list)
     ps.SetSeed(123)
     self.assertEqual(123, ps.GetSeed())
예제 #11
0
 def test_default_constructor(self):
     vector_mass = 5.140252
     float_list = [1.1, 1.2, 0.242, 0.8385977]
     ps = hypy.PhaseSpace4(vector_mass, float_list)
     self.assertIsInstance(ps, hypy.PhaseSpace4,
                           'Failure: Not an instance of PhaseSpace_4')
 def test_seed(self):
     float_list = [1.1, 1.2, 0.242, 0.8385977]
     ps = hypy.PhaseSpace4(float_list)
     ps.SetSeed(123)
     self.assertEqual(123, ps.GetSeed())