Home | News | Documentation | Download

How to set conditions on fit parameters?

I have the function that I use to fit:

Double_t fun(Double_t *x, Double_t *par) 
    Double_t z2 = x[0] * x[0] / par[0] / par[0] + x[1] * x[1] / par[1] / par[1];
    z2 *= par[2] * par[2];
    return -sqrt(z2) + par[3];
TF2 *f = new TF2("f", fun, -50, 50, -50, 50, npar);
hist>Fit("f", "Q");

I want the process to be carried out on the condition that the par[0]/par[1] relation is constant and equal, for example, 2. How to perform it?

Perhaps @StephanH can help

Multiply the current fit function with something like
Gauss(2 | par[0]/par[1], 0.1)

For the fitter, this is something like:
par[0]/par[1] should be equal to 2 within 10% uncertainty. You can obviously change the target value and the “strength” of this constraint as desired.
Make sure, though, that par[1] doesn’t go to zero. Otherwise, it will blow up.

Redefine your “fun” so that the new “par[1]” becomes the current “par[0]/par[1]” and then you can simply use: "f->FixParameter(1, 2.);