aboutsummaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2018-10-18 10:13:54 -0500
committertlatorre <tlatorre@uchicago.edu>2018-10-18 10:13:54 -0500
commit4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495 (patch)
tree427fb1ab4017868cf0d228750d812c0e1bb85940 /src/path.c
parent93f4b97a553998ac8fb59005c3d99b303afb6f60 (diff)
downloadsddm-4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495.tar.gz
sddm-4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495.tar.bz2
sddm-4f1c77fb1dcc1c1a927c0ee6b7571aebcff71495.zip
update path_init() to check for a divide by zero
This commit updates path_init() to check that beta > 0 before dividing by it to compute the time. Previously when fitting electrons it would occasionally divide by zero which would cause the inf to propagate all the way through the likelihood function.
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/path.c b/src/path.c
index 340f8c7..85233d6 100644
--- a/src/path.c
+++ b/src/path.c
@@ -84,7 +84,10 @@ path *path_init(double *pos, double *dir, double T0, double range, double theta0
dz[i] = (s[i]-s[i-1])*cos(theta);
/* Calculate total energy */
- t[i] = t[i-1] + (s[i]-s[i-1])/(beta[i]*SPEED_OF_LIGHT);
+ if (beta[i] > 0)
+ t[i] = t[i-1] + (s[i]-s[i-1])/(beta[i]*SPEED_OF_LIGHT);
+ else
+ t[i] = t[i-1];
x[i] = x[i-1] + dx[i];
y[i] = y[i-1] + dy[i];