diff options
author | Stan Seibert <stan@mtrr.org> | 2012-04-17 10:47:02 -0400 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:38 -0700 |
commit | 448d048e81d394ecbafab1efc38e70e391dfcb99 (patch) | |
tree | a51c2dcd05c9b6c6e3ea242b2030c413e2400823 | |
parent | 8dfc46b06d7aa98fb272c9b73a9573e14722d66d (diff) | |
download | chroma-448d048e81d394ecbafab1efc38e70e391dfcb99.tar.gz chroma-448d048e81d394ecbafab1efc38e70e391dfcb99.tar.bz2 chroma-448d048e81d394ecbafab1efc38e70e391dfcb99.zip |
If (0,0,0) passed in for direction vector, constant_particle_gun will pick isotropically distributed directions.
-rw-r--r-- | chroma/generator/vertex.py | 9 |
1 files 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) |