How to access TMinuit when using ROOT::Fit?

I would like to perform “SET NOGRAD” fit with ROOT::Fit, as given in one of the samples on this forum. However, there gMinuit is accessed after previous fit (with gradients) was performed. How to access gMinuit when no fit was performed before?

I understand that using TVirtualFitter has no result here…


I don’t understand fully your problem. The “NOGRAD” is the default in Minuit, so the first time (when also gMInuit is not available), you don’t need to call the “SET NOGRAD” command.

Also, if you are using the class ROOT::Fit::Fitter, and you don’t want to use the user provided gradient information (which is the default), it is enough you use the method ROOT::Fit::Fitter::SetFunction passing a reference to a simple parametric function interface (non implementing the gradient) (ROOT::Math::IParametricFunctionMultiDim) and not the method passing a reference to a gradient function (ROOT::Math::IParametricGradFunctionMultiDim)


I understand. But still I would like to know, if it is possible to access TMinuit from ROOT::Fit::Fitter etc. before performing the fit.

Let’s assume a following (rather non realistic) situation - I am using ROOT::Math::IParametricGradFunctionMultiDim. But once I would like to try it without gradients, not implementing the same function for the second time as ROOT::Math::IParametricFunctionMultiDim. I guess, I could try to cast it, but… isn’t there really a method to access TMinuit before performing a fit? :slight_smile:


you can access all the Minimizer options from the FitConfig class available from the ROOT::Fit::Fitter. See … arams.html.
If something is missing and you would like to control before fitting, please let me know.

If you need specific access to TMinuit, you can use gMinuit and, if it has not been created before you can create yourself by doing:

gMinuit = new TMinuit(npar);

Concerning your second point, I agree that you would need to perform a cast in that case. In order to hide the casting from the user I will implement an optional parameter in the Fitter::SetFunction method’s to specify explicitly if using the gradient or not. Something like:

 void  SetFunction(const  ROOT::Math::IParametricFunctionMultiDim & func, bool useGradient = false); 

 void  SetFunction(const  ROOT::Math::IParametricGradFunctionMultiDim & func, bool useGradient = true); 

Best Regards