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("-----------------------------------------")
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])
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])
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)
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])
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])