while trying to use the TFitter-function within a class I obtained the following error:
src/LKFMinuit.cpp:13: error: no matching function for call to ‘TFitter::SetFCN(<unresolved overloaded function type>)’
/cernroot/5_18_00/deb4.0-gcc4.1.2/include/TFitter.h:69: note: candidates are: virtual void TFitter::SetFCN(void*)
/cernroot/5_18_00/deb4.0-gcc4.1.2/include/TFitter.h:70: note: virtual void TFitter::SetFCN(void (*)(Int_t&, Double_t*, Double_t&, Double_t*, Int_t))
The attachment delivers a minimal example which reproduces the error. Does anybody know how to solve this? Or is impossible to use TMinuit within a class?
the function passed in TFitter::SetFCN, must be a global function or a static member function of a class, cannot be a member function.
You can fix this by making a static instance of your class (LKFMinuit)
If you are using the latest ROOT version, the alternative is to use the new fitter class, ROOT::Fit::Fitter. In this case you can use a member function of a class, as following:
Sorry dude, I should have put the code. I attached a simpler version of the code this time, no make file. You compile with
.L LKFMinuit.cpp+ //compile fitting class
.L lkf.cpp+ //compile main program
lkf() //run the fit
I just made the minuit function static and I call the member functions using the pointer to this (the object) that I declared as a global variable and initialize in the constructor. Code.tar.gz (880 Bytes)