|
| 1 | +import HydraPython as hypy |
| 2 | +import sys |
| 3 | +import time |
| 4 | + |
| 5 | + |
| 6 | +def main(): |
| 7 | + """ |
| 8 | + This example shows how to use the Hydra's |
| 9 | + phase space Monte Carlo algorithms to |
| 10 | + generate a sample of B0 -> J/psi K pi and |
| 11 | + use the multiple daughters to generate the |
| 12 | + grand-daughters. |
| 13 | + """ |
| 14 | + nentries = 1000000 |
| 15 | + B0_mass = 5.27955 |
| 16 | + Jpsi_mass = 3.0969 |
| 17 | + K_mass = 0.493677 |
| 18 | + pi_mass = 0.13957061 |
| 19 | + mu_mass = 0.1056583745 |
| 20 | + if len(sys.argv) > 1: |
| 21 | + nentries = int(sys.argv[1]) |
| 22 | + |
| 23 | + B0 = hypy.Vector4R(B0_mass, 0.0, 0.0, 0.0) |
| 24 | + masses1 = [Jpsi_mass, K_mass, pi_mass] |
| 25 | + masses2 = [mu_mass, mu_mass] |
| 26 | + |
| 27 | + phsp1 = hypy.PhaseSpace3(B0_mass, masses1) |
| 28 | + phsp2 = hypy.PhaseSpace2(Jpsi_mass, masses2) |
| 29 | + |
| 30 | + # Device # |
| 31 | + |
| 32 | + daughters_d = hypy.host_events_3(nentries) |
| 33 | + grand_daughters_d = hypy.host_events_2(nentries) |
| 34 | + start = time.time() |
| 35 | + |
| 36 | + phsp1.GenerateOnhost(B0, daughters_d) |
| 37 | + phsp2.GenerateOnhost(daughters_d.getDaughters(0), grand_daughters_d) |
| 38 | + |
| 39 | + end = time.time() |
| 40 | + |
| 41 | + print('\n' * 2) |
| 42 | + print("------------------ Host -----------------") |
| 43 | + print("| B0 -> J/psi K pi | J/psi -> mu+ mu-") |
| 44 | + print("| Number of events :", nentries) |
| 45 | + print("| Time (ms) :", end - start) |
| 46 | + print("-----------------------------------------") |
| 47 | + |
| 48 | + for i in range(10): |
| 49 | + print(daughters_d[i], grand_daughters_d[i]) |
| 50 | + |
| 51 | + # Host # |
| 52 | + |
| 53 | + daughters_h = hypy.host_events_3(nentries) |
| 54 | + grand_daughters_h = hypy.host_events_2(nentries) |
| 55 | + start = time.time() |
| 56 | + |
| 57 | + phsp1.GenerateOnhost(B0, daughters_h) |
| 58 | + phsp2.GenerateOnhost(daughters_h.getDaughters(0), grand_daughters_h) |
| 59 | + |
| 60 | + end = time.time() |
| 61 | + |
| 62 | + print('\n' * 2) |
| 63 | + print("----------------- Device ----------------") |
| 64 | + print("| B0 -> J/psi K pi | J/psi -> mu+ mu-") |
| 65 | + print("| Number of events :", nentries) |
| 66 | + print("| Time (ms) :", end - start) |
| 67 | + print("-----------------------------------------") |
| 68 | + |
| 69 | + for i in range(10): |
| 70 | + print(daughters_h[i], grand_daughters_h[i]) |
| 71 | + |
| 72 | + |
| 73 | +if __name__ == '__main__': |
| 74 | + main() |
0 commit comments