From 7892fb4b0814308c6eb612b6d8434bd974af5908 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Fri, 30 Nov 2018 16:02:14 -0600 Subject: add ability to fit for multiple vertices --- src/fit.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/fit.c') diff --git a/src/fit.c b/src/fit.c index 0634116..714a1cc 100644 --- a/src/fit.c +++ b/src/fit.c @@ -4978,33 +4978,36 @@ static struct startingParameters { double nll(unsigned int n, const double *x, double *grad, void *params) { fitParams *fpars = (fitParams *) params; - double T, theta, phi, t0; - double pos[3], dir[3]; + double theta, phi; double fval; - double z1[1], z2[1]; struct timeval tv_start, tv_stop; + vertex v; if (stop) nlopt_force_stop(opt); - T = x[0]; + v.id = fpars->id; - pos[0] = x[1]; - pos[1] = x[2]; - pos[2] = x[3]; + v.T0 = x[0]; + + v.pos[0] = x[1]; + v.pos[1] = x[2]; + v.pos[2] = x[3]; theta = x[4]; phi = x[5]; - dir[0] = sin(theta)*cos(phi); - dir[1] = sin(theta)*sin(phi); - dir[2] = cos(theta); + v.dir[0] = sin(theta)*cos(phi); + v.dir[1] = sin(theta)*sin(phi); + v.dir[2] = cos(theta); + + v.t0 = x[6]; - t0 = x[6]; + v.z1[0] = x[7]; + v.z2[0] = x[8]; - z1[0] = x[7]; - z2[0] = x[8]; + v.n = 1; gettimeofday(&tv_start, NULL); - fval = nll_muon(fpars->ev, fpars->id, T, pos, dir, t0, z1, z2, 1, fpars->dx, fpars->dx_shower, fpars->fast); + fval = nll_muon(fpars->ev, &v, 1, fpars->dx, fpars->dx_shower, 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; -- cgit