Fit problems in loop with LL options

Dear all,
I am fitting a histogram with a 2D Gaussian fit.
If I run the routine in attachment, I obtain:
Fitting h_det5

FCN=2727.51 FROM MIGRAD STATUS=CONVERGED 708 CALLS 709 TOTAL
EDM=1.81552e-08 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 3.7 per cent
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 Const 5.52174e+01 4.20742e-01 -5.23325e-03 1.55902e-04
2 X_{0} 5.60390e-01 4.92729e-03 2.43741e-07 -1.11188e-02
3 #sigma_{x} 6.38465e-01 3.66225e-03 -9.37910e-06 -2.51550e-03
4 Y_{0} 3.24723e-01 5.01235e-03 3.52534e-05 3.06743e-02
5 #sigma_{y} 6.53994e-01 3.74802e-03 -2.87263e-05 5.30264e-03
6 #rho 6.53553e-02 7.76242e-03 2.38471e-05 6.23997e-03
ERR DEF= 0.5

When rerunning the same routine a second time (just digiting fit()), the results are different.
root [2] fit()

Fitting h_det5

Warning in : Abnormal termination of minimization.
FCN=7288.27 FROM MIGRAD STATUS=FAILED 487 CALLS 488 TOTAL
EDM=241881 STRATEGY= 1 ERR MATRIX NOT POS-DEF
EXT PARAMETER APPROXIMATE STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 Const 5.34293e+01 7.89373e-01 0.00000e+00 -2.21596e+01
2 X_{0} 7.71619e-01 7.07214e-01 -0.00000e+00 5.46626e+02
3 #sigma_{x} 6.80560e-01 7.07219e-01 0.00000e+00 -4.38550e+03
4 Y_{0} 8.05029e-01 7.07107e-01 -0.00000e+00 9.78507e+03
5 #sigma_{y} 8.45970e-01 7.07161e-01 0.00000e+00 -4.51600e+03
6 #rho 5.09386e-01 7.07216e-01 -0.00000e+00 9.31772e+03
ERR DEF= 0.5

This has strong consequences on a value I am calculating by using the results of the fit. In the first case this value is 0.17 and in the second becomes 0.13.
I would not mind so much, if the second results would not be obtained also running the routine only once, but from j=2 (for j=1 the histogram is empty) up to a j>5; i.e. in the loop.

This issue does not show up if I fit withouth the LL option.
Could anyone help me to fix the problem when using the LL option, please?

Thx,
franciuska
subroutines.c (2.18 KB)
results_from_9072_to_9078.root (838 KB)