Accessing 2D fit function with ROOT::Fit

I attach a 2D gauss fitting example (modified from a 1D gauss fitting exmaple given on this forum). Cloning the function:


for 1D gauss worked, but for 2D gauss ROOT cannot find any function under the address returned by this Clone(). How to access it properly?

The other problem is… why such a simple 2D sample does not converge with Minuit (although it converges with Fumili)?
exampleGradFit2D.C (4.9 KB)


Clone works, but for creating the TF1 just do:

	f = new TF2("fitFunc",ff,-5,5,-5,5,0,"");

Otherwise the constructor with a void * will be used (needed for CINT).

For the fitting, when you have so many empty bins and many bins with low statistics, the chi2 method is not good. You should use a likelihood method
Also Simplex is not a good minimizer. You should use Migrad

Best Regards