Fit N-sigma 2D histogram with TMinuit

Dear Experts,

I have a problem (again…) with my 2D histogram fit.

I have a density of points on a 2D histogram (see in attachment) and I want to fit it with an ellipse.
I used TMinuit to minimized this but I have some problems…

  1. My minimization was made with 5 parameters, which correspond to xmin, xmax, ymin, ymax (coordinates of the ellipse tangents) and b (minor axis). To minimized these parameters I used:

    gMinuit->mnparm(0, “x1”, 15.9, 0.1, 5,20,ierflg);
    gMinuit->mnparm(1, “y1”, 0, 0.1, 0,3,ierflg);
    gMinuit->mnparm(2, “x2”, 153, 0.1,153.25,165,ierflg);
    gMinuit->mnparm(3, “y2”, 68, 0.1, 68.3,73,ierflg);
    gMinuit->mnparm(4, “b”, 20, 0.1, 18,20,ierflg);

But : I observed that my parameters are not minimized and the ellipse is built with the limit parameters. This behaviour can be explained by achieve limits. So I tried to fix this changing the limits but every time they are achived… :open_mouth: (my ellipse grown and grown, disappeared and does not fit anything :confused: )

  1. The goal of this minimization is to have the 1-sigma, 2-sigma (and why not n-sigma) contours. I expected the 1-sigma contour gives by the TMinuit minimization but it’s not the case (see 1)). I can choose my limits in order to have a “1-sigma” contour (around the purple part) but it’s physically incorrect (and very random).
    I tried to used :

TGraph gr1 = (TGraph)gMinuit->Contour(40,0,1);

to obtain the 1-sigma contour, but I don’t succeed because:
* I have 5 parameters in my minimization
* these parameters are not the axis parameters.
I tried to obtain axis parameters to put them in arguments of contour but this function take only an Int_t and the fit parameters as parameters.

Eventually I’d like to plot the 2-sigma contour too. I know that it can be obtain by the same way that the 1-sigma contour (with gMinuit->SetErrorDef(4) before) but it is the same problem.

Do you have any ideas how to obtain the 1-sigma and 2-sigma of this kind of histogram with the TMinuit minimization? Maybe I used a wrong method…

Thanks a lot to read me :wink:

c1.pdf (83.8 KB)

I think this topic is already discussed in