From 448d048e81d394ecbafab1efc38e70e391dfcb99 Mon Sep 17 00:00:00 2001 From: Stan Seibert Date: Tue, 17 Apr 2012 10:47:02 -0400 Subject: If (0,0,0) passed in for direction vector, constant_particle_gun will pick isotropically distributed directions. --- chroma/generator/vertex.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chroma/generator/vertex.py b/chroma/generator/vertex.py index 513a961..e8f4139 100644 --- a/chroma/generator/vertex.py +++ b/chroma/generator/vertex.py @@ -76,8 +76,13 @@ def pi0_gun(pos_iter, dir_iter, ke_iter, t0_iter=constant(0.0), start_id=0, gamm def constant_particle_gun(particle_name, pos, dir, ke, t0=0.0, start_id=0): '''Convenience wrapper around particle gun that assumes all arguments are constants, rather than generators.''' + if (dir == 0.0).all(): + dir_gen = isotropic() + else: + dir_gen = constant(dir) + if particle_name == 'pi0': - return pi0_gun(constant(pos), constant(dir), constant(ke), + return pi0_gun(constant(pos), dir_gen, constant(ke), constant(t0), start_id=start_id) else: - return particle_gun(constant(particle_name), constant(pos), constant(dir), constant(ke), constant(t0), start_id=start_id) + return particle_gun(constant(particle_name), constant(pos), dir_gen, constant(ke), constant(t0), start_id=start_id) -- cgit