Error status with RooMinimizerFcn during a fit in a range

Dear ROOTers,

I have some issues understanding an error during a fit. First let me explain what I am doing…
I am trying to apply a backtracing procedure based on RooFit. The backtracing procedure consists on trying to find the best input parameters of a model which reproduces the best a given (experimental) distribution of chosen experimental variables (observables). I am trying to apply this procedure on Toy-events from a model where I control the input parameters distribution.

The first step of my work is to generate with a model 2 observables from a distribution of 2 input model parameters (in my case a correlated-2D gaussian). These events (10000 events with 2 observables) are then stored in a RooDataHist. It will be the events I want to fit.

The second step is to select a binning in parameters and generate events for each bin of them (1000 events) and store them in a RooDataHist. As an example if I set for the first parameter 20 bins and 10 bins for second, I will have 20x10=200 RooDataHist.

The third step is then to generate a RooHistPdf from each of the RooDataHist created at the second step.

The fourth step is to create a RooAddPdf from the set of RooHistPdf I have created at the third step, each of them with a coefficient value between 0. and 1. This RooAddPdf will then be fitted to the RooDataHist created at the first step.

The fit is going well in my case, using the RooAddPdf::fitTo() method, but I have some issues when I try to fit in a range.
If I set the observables ranges like in the following:

RooRealVar obs1(“obs1”, “observable 1”, Min1, Max1);
RooRealVar obs2(“obs2”, “observable 2”, Min2, Max2);
obs1.setRange(“RANGE”, min1, max1);
obs2.setRange(“RANGE”, min2, max2);

And try to fit the RooDataHist created at first step using the RooAddPdf created at step four like this:

RooFitResult *result = pdf->fitTo(datahist, Save(), NumCPU(7), Minimizer(“GSLMultMin”, “conjugatefr”), Extended(kFALSE), Offset(kTRUE), Range(“RANGE”));

I have error messages arrising like the following one…

WARNING: Minization – RooMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (-1e+30) to force MIGRAD to back out of this region.

I am quite lost because the fit is going well without setting the range…
Do you have any idea about how to solve this problem, or where to investigate ?

Thanks a lot,


Normally you get these errors when the pdf evaluated on the current parameter is 0 or negative.
It could be that by setting the range the fit goes toward bad parameter values.
I would suggest to try starting with better parameter values, closer to the minimum or to bound the parameters better.



Hi Lorenzo and thanks for your help,

I also thought about a bad p.d.f evaluation on the current parameters, after reading the RooFit users manual. In fact, for both fits (with or without setting the range) I have the same number of parameters, with the same initial values (exactly 1./num_par, where num_par is the number of parameters for the fit). And the fit is going well without the range.

Are these initial values modified by setting the range, making the fit going toward bad parameter values ?

I have tried after your message to start with parameters values close to the minimum, but I still have the same error messages.

Is it possible that the normalization of the p.d.f is not going well, making these errors ?

Best regards,


Th initial values are not modified after setting the range, but it could be that the minimiser after setting the range goes in a bad region.
It is also possible that there is a problem with the pdf normalisation (its integral) after setting the range.
I would try first to change minimiser (e.g. use Minuit2) to see if the situation improves or use another numerical integration algorithm.

Best Regards


Hi again,

I’ve just tried to change minimizer to Minuit2 and used the different numerical integration algorithms (migrad, simplex and minimize) with parameters values closed to the real values. These error messages are still here:

WARNING: Minization – RooMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (-1e+30) to force MIGRAD to back out of this region.

(printing about MIGRAD even if I’ve changed the numerical integration algorithm)

I have also tried with GSLMultiMin (conjugatefr, conjugatepr) and GSLSimAn, but still have the same error messages…

I have also tried to force the integrals to be calculated numerically for the RooAddPdf, using the RooAddPdf::forceNumInt() method, and no improvement…

I am quite lost, is there any possibility to know more about these errors, if they come from the p.d.f normalization or the minimiser which after the range goes in a bad region ?


By increasing the print level to 3 of the minimiser you should get more output and understand this better


Hi Lorenzo,

I have increased the PrintLevel to 3 as you suggested, and I have some new informations in the error. Here are the output errors, using Minuit2 minimizer and minimize algorithm, and starting with parameters closed to the minimum.

WARNING: Minization – RooMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (-1e+30) to force MIGRAD to back out of this region. Error log follows
Parameter values: (list of parameters values which is too long to print here) W0=9.53674e-07, W1=6.43732e-08…, W99=9.53674e-08
RooNLLVar::nll_Model_datahist_exp[ paramSet=(W0,W1,…W99) ]
function value is NAN @ paramSet=(W0 = 9.53674e-07, W1=6.43732e-08…, W99=9.53674e-08)
PID6155/RooRealMPFE::nll_Model_datahist_exp_1e11e1e0_MPFE3[ arg=nll_Model_datahist_exp_GOF3 vars=(W0,W1,…W99) ]
function value is NAN @ paramSet=(W0 = 9.53674e-07, W1=6.43732e-08…, W99=9.53674e-08)
(…remaining 54 messages suppressed)
p.d.f value is Not-a-Number (-nan), forcing value to zero @ !refCoefNorm=(APrimaryWoN = 32, EStarPrimaryWoN = 67.821), pdfs=(HistPdf0 = 0/700,HistPdf1 = 0/700…,HistPdf99=2/399), !coefficients=(W0 = 2.12684e-09, Model_recursive_fraction_HistPdf1 = 6.43732e-08, Model_recursive_fraction_HistPdf2 = 1.8306e-09,…, Model_recursive_fraction_HistPdf99 = 0.359202)

and these messages keep repeating…

For more information about these log errors:

  • Model is the name of the RooAddPdf I try to fit to data
  • APrimaryWoN and EStarPrimaryWoN are the observable names

I’ve also looked in the RooAddPdf class, to understand better where something can be wrong in the p.d.f evaluation. I am using ROOT version 5.34. Maybe I am wrong, but I’ve understood that the range is used in the creation of the NLL that is then used by the minimizer in the RooAddPdf::fitTo() method. In this version of ROOT, the NLL is created with the RooAddPdf::createNLL() method… Do you think the errors can come from the creation of the NLL, or is it because of the minimizer ?

Thanks for your help,