I’ve been trying to use TMinuit to fit a function and I think I have everything set up correctly, but the code won’t compile. I’m using the compiler from MSVC 8 and I believe the error is in my implementation of TMinuit::SetFCN.
//Function does stuff
TMinuit* fit = new TMinuit(5);
fit -> SetFCN(MyFunction);
}
This gives a compiler error ‘MyClass::MyFunction’: function call missing argument list. When I try fit -> SetFCN(&MyClass::MyFunction); I get the error ‘void TMinuit::SetFCN(void )’ : cannot convert parameter 1 from 'void (_thiscall MyFunction::)(Int_t &,Double_t *,Double_t &, Double_t *, Int_t)’ to ‘void *’. If anyone can point me in the right direction, I’d really appreciate it.
In your case, it seems that the function is not static, this means it can only be used in conjunction with an object. Passing (and then) both an object and a function is slightly more difficult and was not implemented when TMinuit was first developed.
We are now working to alleviate the situation by introduction support for functor objects.
Well it is not really my case, this is an old topic. Personnaly I have the error
error: no matching function for call to ‘TMinuit::SetFCN(<unknown type>)’
/cern/pro/root/include/TMinuit.h:269: note: candidates are: virtual void TMinuit::SetFCN(void*)
/cern/pro/root/include/TMinuit.h:270: note: virtual void TMinuit::SetFCN(void (*)(Int_t&, Double_t*, Double_t&, Double_t*, Int_t))
or
error: no matching function for call to ‘TMinuit::SetFCN(void (myClass::*)(Int_t&, Double_t*, Double_t&, Double_t*, Int_t))’
[...]
if I give myClass::myFcn in argument to SetFCN.
But anyway I guess this is the same problem, and you are right about the conjunction since I use several TMinuit objects which FCN need a customed array in argument… I’ll try to get round the problem.
Yes, I could, thank you for making me know this feature.
However, as far as I understand the Minuit2 package is independant from ROOT (at least for old versions), and since my code will (or might…) be used by other people than me, I don’t want to impose them to install a new package.
Furthermore, my code will be mainly used on CCALI servers (Lyon), which ROOT version is 4.02/00, I don’t know if Minuit2 is so far backward compatible ?
So, I will just try to find a trick for know, but I keep this in mind for my personal utilisation…
Minuit2 is part of ROOT for versions >= 5.08.
You could use with older versions, but it is more complicated (you need to install and use as an external package)
I am trying to do something similar using ROOT::Math::Minimizer, following the examples given in the links provided in the post before this one. However, I keep hitting an error message whenever I try to compile:
/a/apps/local/root-05.24.00/include/Math/Functor.h:86: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘((const ROOT::Math::FunctorHandler<ROOT::Math::Functor, Double_t (Functor_Test::*)(const Double_t*)>*)this)->ROOT::Math::FunctorHandler<ROOT::Math::Functor, Double_t (Functor_Test::*)(const Double_t*)>::fFunc (...)’, e.g. ‘(... ->* ((const ROOT::Math::FunctorHandler<ROOT::Math::Functor, Double_t (Functor_Test::*)(const Double_t*)>*)this)->ROOT::Math::FunctorHandler<ROOT::Math::Functor, Double_t (Functor_Test::*)(const Double_t*)>::fFunc) (...)’
I have no idea what to make of this. Has anybody else run into this before, and have suggestions for what to do? I have included code that should reproduce the error.