aboutsummaryrefslogtreecommitdiff
path: root/src/fit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fit.c')
-rw-r--r--src/fit.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/fit.c b/src/fit.c
index 2a86456..7deec9d 100644
--- a/src/fit.c
+++ b/src/fit.c
@@ -20,6 +20,7 @@ double nll(unsigned int n, const double *x, double *grad, void *params)
double pos[3], dir[3];
static size_t iter;
double fval;
+ double z1[1], z2[1];
T = x[0];
@@ -35,9 +36,12 @@ double nll(unsigned int n, const double *x, double *grad, void *params)
t0 = x[6];
- fval = nll_muon((event *) params, T, pos, dir, t0);
+ z1[0] = x[7];
+ z2[0] = x[8];
- printf("%5zu %10.2f %7.2f %7.2f %7.2f %4.2f %4.2f %5.2f f() = %7.3e\n",
+ fval = nll_muon((event *) params, T, pos, dir, t0, z1, z2, 1);
+
+ printf("%5zu %10.2f %7.2f %7.2f %7.2f %4.2f %4.2f %5.2f %4.2f %4.2f f() = %7.3e\n",
iter++,
x[0],
x[1],
@@ -46,6 +50,8 @@ double nll(unsigned int n, const double *x, double *grad, void *params)
x[4],
x[5],
x[6],
+ x[7],
+ x[8],
fval);
return fval;
@@ -53,20 +59,22 @@ double nll(unsigned int n, const double *x, double *grad, void *params)
int fit_event(event *ev, double *fmin)
{
- double x[7], ss[7], lb[7], ub[7];
+ double x[9], ss[9], lb[9], ub[9];
int rv;
- nlopt_opt opt = nlopt_create(NLOPT_LN_SBPLX, 7);
+ nlopt_opt opt = nlopt_create(NLOPT_LN_BOBYQA, 9);
nlopt_set_min_objective(opt,nll,ev);
nlopt_set_ftol_abs(opt, 1e-5);
- x[0] = 1000.0;
- x[1] = 100.0;
- x[2] = 100.0;
- x[3] = 100.0;
+ x[0] = 1200.0;
+ x[1] = 0.0;
+ x[2] = 0.0;
+ x[3] = 0.0;
x[4] = 1.57;
x[5] = 0.0;
x[6] = 130.0;
+ x[7] = 0.0;
+ x[8] = 0.0;
ss[0] = 10.0;
ss[1] = 10.0;
@@ -75,6 +83,8 @@ int fit_event(event *ev, double *fmin)
ss[4] = 0.1;
ss[5] = 0.1;
ss[6] = 1.0;
+ ss[7] = 0.1;
+ ss[8] = 0.1;
lb[0] = 1.0;
lb[1] = -1000.0;
@@ -83,6 +93,8 @@ int fit_event(event *ev, double *fmin)
lb[4] = 0.0;
lb[5] = 0.0;
lb[6] = 0.0;
+ lb[7] = -10.0;
+ lb[8] = -10.0;
ub[0] = 100000.0;
ub[1] = 1000.0;
@@ -91,6 +103,8 @@ int fit_event(event *ev, double *fmin)
ub[4] = M_PI;
ub[5] = 2*M_PI;
ub[6] = 400.0;
+ ub[7] = 10.0;
+ ub[8] = 10.0;
nlopt_set_lower_bounds(opt, lb);
nlopt_set_upper_bounds(opt, ub);