VIVE L’AMOUR!
I’ve got a class: class chi_2_functor {
public:
int NDF;
chi_2_functor(int ndf) { NDF = ndf; }
double operator() (double *x, double *p) {
double v = 0.0;
if (p)
for (int i = 0; i < NDF; i++) v += (x[i] - p[i]) * (x[i] - p[i]);
else
for (int i = 0; i < NDF; i++) v += (x[i] - i) * (x[i] - i);
return v;
}
};
I’ve successfully been using it with TF1, TF2 and TF3: [code]{
double x, y, z, v;
double p[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
chi_2_functor *cf1 = new chi_2_functor(1);
TF1 *f1 = new TF1(“f1”, cf1, -1, 1, 11, “chi_2_functor”);
f1->SetParameters§;
x = f1->GetMinimumX(); v = f1->GetMinimum();
std::cout << "f1( " << x << " ) = " << v << std::endl;
TF1 *f10 = new TF1(“f10”, cf1, -1, 1, 0, “chi_2_functor”);
x = f10->GetMinimumX(); v = f10->GetMinimum();
std::cout << "f10( " << x << " ) = " << v << std::endl;
chi_2_functor *cf2 = new chi_2_functor(2);
TF2 *f2 = new TF2(“f2”, cf2, -1, 1, 0, 2, 11, “chi_2_functor”);
f2->SetParameters§;
f2->GetMinimumXY(x, y); v = f2->Eval(x, y);
std::cout << "f2( " << x << " , " << y << " ) = " << v << std::endl;
TF2 *f20 = new TF2(“f20”, cf2, -1, 1, 0, 2, 0, “chi_2_functor”);
f20->GetMinimumXY(x, y); v = f20->Eval(x, y);
std::cout << "f20( " << x << " , " << y << " ) = " << v << std::endl;
chi_2_functor *cf3 = new chi_2_functor(3);
TF3 *f3 = new TF3(“f3”, cf3, -1, 1, 0, 2, 1, 3, 11, “chi_2_functor”);
f3->SetParameters§;
f3->GetMinimumXYZ(x, y, z); v = f3->Eval(x, y, z);
std::cout << "f3( " << x << " , " << y << " , " << z << " ) = " << v << std::endl;
TF3 *f30 = new TF3(“f30”, cf3, -1, 1, 0, 2, 1, 3, 0, “chi_2_functor”);
f30->GetMinimumXYZ(x, y, z); v = f30->Eval(x, y, z);
std::cout << “f30( " << x << " , " << y << " , " << z << " ) = " << v << std::endl;
}[/code]
Well, now I need to find minima for 4 to 11 parameters … and there’s no TF4, …, TF11.
I think I’d like to use Minuit2 (in the first approximation, later maybe GSL) … but I cannot find any suitable example.
In general, I would need to “set limits” on (some) parameters and I would need to “fix” (some) others.
The real problem is - how can I re-use my “chi_2_functor” class and its ''operator()” when defining / creating the “FCN” to be minimized?
Note: I don’t really want to change the layout of the “chi_2_functor” class (a lot of my existing source code depends on it). I could, however, say “Double_t operator() (Double_t *x, Double_t *p = 0);”, if that makes things easier (i.e. for the current purposes, I could live fine without “p”).
If possible, I would prefer to stay away from RooFit - I’d like to do everything “manually”, following “conventional” procedures.
A pitiful case, am I not?
Pepe Le Pew.