aboutsummaryrefslogtreecommitdiff
path: root/src/fit.c
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2018-11-17 12:44:22 -0600
committertlatorre <tlatorre@uchicago.edu>2018-11-17 12:44:22 -0600
commit7cb12a69eb94eafce80e05efe86716772b023bcd (patch)
treeec7a9cd427a1435fd5aa7561a3742af9a03887b9 /src/fit.c
parent5a3edcfceecdfa594bd8c5286455bdfa7fe852fb (diff)
downloadsddm-7cb12a69eb94eafce80e05efe86716772b023bcd.tar.gz
sddm-7cb12a69eb94eafce80e05efe86716772b023bcd.tar.bz2
sddm-7cb12a69eb94eafce80e05efe86716772b023bcd.zip
speed up likelihood function and switch to using fixed dx
This commit speeds up the likelihood function by about ~20% by using the precomputed track positions, directions, times, etc. instead of interpolating them on the fly. It also switches to computing the number of points to integrate along the track by dividing the track length by a specified distance, currently set to 1 cm. This should hopefully speed things up for lower energies and result in more stable fits at high energies.
Diffstat (limited to 'src/fit.c')
-rw-r--r--src/fit.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/fit.c b/src/fit.c
index 2b9652a..6ac97f1 100644
--- a/src/fit.c
+++ b/src/fit.c
@@ -38,7 +38,7 @@ static size_t iter;
typedef struct fitParams {
event *ev;
- int n;
+ double dx;
int fast;
int print;
int id;
@@ -5003,7 +5003,7 @@ double nll(unsigned int n, const double *x, double *grad, void *params)
z2[0] = x[8];
gettimeofday(&tv_start, NULL);
- fval = nll_muon(fpars->ev, fpars->id, T, pos, dir, t0, z1, z2, 1, fpars->n, fpars->fast);
+ fval = nll_muon(fpars->ev, fpars->id, T, pos, dir, t0, z1, z2, 1, fpars->dx, fpars->fast);
gettimeofday(&tv_stop, NULL);
long long elapsed = (tv_stop.tv_sec - tv_start.tv_sec)*1000 + (tv_stop.tv_usec - tv_start.tv_usec)/1000;
@@ -5211,7 +5211,7 @@ int fit_event(event *ev, double *xopt, double *fmin, int id)
* faster, we set the absolute tolerance on the likelihood to 1.0, the
* maximum number of function evaluations to 100, and the relative
* tolerance on the numerical integration to 10%. */
- fpars.n = 100;
+ fpars.dx = 1.0;
fpars.fast = 1;
fpars.print = 0;
nlopt_set_ftol_abs(opt, 1.0);
@@ -5304,7 +5304,7 @@ int fit_event(event *ev, double *xopt, double *fmin, int id)
nlopt_set_upper_bounds(opt, ub);
/* Now, we do the "real" minimization. */
- fpars.n = 500;
+ fpars.dx = 1.0;
fpars.fast = 0;
fpars.print = 1;
nlopt_set_ftol_abs(opt, 1e-5);