diff options
author | Anthony LaTorre <tlatorre9@gmail.com> | 2011-08-26 18:28:56 -0400 |
---|---|---|
committer | Anthony LaTorre <tlatorre9@gmail.com> | 2011-08-26 18:28:56 -0400 |
commit | 375046868564e4911ab3c6094e7e7fc92edd76c6 (patch) | |
tree | 5db1266f76c5c658710b99848aebbebcede8aab3 /generator | |
parent | dcfc4bf3fe6c3f0e768b4c22ee56240fed16f089 (diff) | |
download | chroma-375046868564e4911ab3c6094e7e7fc92edd76c6.tar.gz chroma-375046868564e4911ab3c6094e7e7fc92edd76c6.tar.bz2 chroma-375046868564e4911ab3c6094e7e7fc92edd76c6.zip |
vertex.isotropic() yields values from transform.uniform_sphere()
Diffstat (limited to 'generator')
-rw-r--r-- | generator/vertex.py | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/generator/vertex.py b/generator/vertex.py index 139d675..7bf9ba0 100644 --- a/generator/vertex.py +++ b/generator/vertex.py @@ -1,10 +1,9 @@ -import itertools import numpy as np -from math import sin, cos, sqrt -import copy +from itertools import izip, count -import chroma.pi0 as pi0 +from chroma.pi0 import pi0_decay from chroma.event import Event, Subtrack +from chroma.transform import uniform_sphere # generator parts for use with gun() @@ -14,13 +13,7 @@ def constant(obj): def isotropic(): while True: - cos_theta = np.random.uniform(-1.0, 1.0) - sin_theta = sqrt(1.0 - cos_theta**2) - phi = np.random.uniform(0.0, 2*np.pi) - direction = np.array([sin_theta * cos(phi), - sin_theta * sin(phi), - cos_theta]) - yield direction + yield uniform_sphere() def line_segment(point1, point2): while True: @@ -40,7 +33,7 @@ def flat(e_lo, e_hi): def particle_gun(particle_name, position, direction, total_energy, start_id=0): for i, ev_particle, ev_position, ev_direction, ev_total_energy in \ - itertools.izip(itertools.count(start_id), + izip(count(start_id), particle_name, position, direction, total_energy): ev = Event(event_id=i, particle_name=ev_particle, gen_position=ev_position, gen_direction=ev_direction, gen_total_energy=ev_total_energy) @@ -48,7 +41,7 @@ def particle_gun(particle_name, position, direction, total_energy, start_id=0): def pi0_gun(pi0_position, pi0_direction, pi0_total_energy, start_id=0): for i, ev_position, ev_direction, ev_total_energy in \ - itertools.izip(itertools.count(start_id), pi0_position, pi0_direction, pi0_total_energy): + izip(count(start_id), pi0_position, pi0_direction, pi0_total_energy): ev = Event(event_id=i, particle_name='pi0', gen_position=ev_position, gen_direction=ev_direction, gen_total_energy=ev_total_energy) @@ -59,7 +52,7 @@ def pi0_gun(pi0_position, pi0_direction, pi0_total_energy, start_id=0): theta_rest = np.arccos(cos_theta_rest) phi_rest = np.random.random_sample() * 2 * np.pi - (gamma1_e, gamma1_dir), (gamma2_e, gamma2_dir) = pi0.pi0_decay(energy=ev_total_energy, + (gamma1_e, gamma1_dir), (gamma2_e, gamma2_dir) = pi0_decay(energy=ev_total_energy, direction=ev_direction, theta=theta_rest, phi=phi_rest) |