Scan selected parameter from initial value to final value in RooFit

Hi,
I would like to save the progress of one or more floating parameters when I do fit a pdf with RooFit. I mean to say, I would like to see graphically how my parameter is going to the final value starting from an initial value.
As far as I know, this is possible for the scanning likelihood function. Is there a similar method available for saving progress of a parameter?

If not please suggest a way to do that.

Hi @pkalbhor,

I will invite @jonas to this topic; if there is a way to achieve what you want, I’m sure he knows how to do it.

Cheers,
J.

1 Like

Hi, @jonas. I am still stuck here. There exists a physical boundary to the solution of a fitter. I am noticing that solution hits the boundary more times than expected. I would like to see if MINUIT is really scanning the whole phase space before hitting a boundary.
I hope that makes sense.

Hi @pkalbhor, sorry for the late reply, I somehow missed your post!

The RooFitResult only stores the initial and the final parameters and no RooFit class involved in the minimization caches the values that Minuit used for each iteration.

However, there is a mechanism to log all the parameter values and the NLL value in each iteration to a text file, which you can set with RooMinimizer::setLogFile. You can see in the source code of RooMinimizerFcn::DoEval what is logged exactly. This is the function that is called by Minuit.

You can the analyze the text file as you like. Here is an example how you can do the fit with the log file for a simple Gaussian:

void example() {

   RooRealVar x("x", "x",0, 0, 10);

   RooRealVar mean("mean","mean", 5, 0, 10);
   RooRealVar sigma("sigma","sigma", 2, 0.1, 10);

   RooGaussian gauss("gauss", "gauss", x, mean, sigma);

   std::unique_ptr<RooDataSet> data{gauss.generate(x, 2000)};

   mean.setVal(1.0);

   std::unique_ptr<RooAbsReal> nll{gauss.createNLL(*data)};

   RooMinimizer minimizer(*nll);
   minimizer.setLogFile("minimizer.log");
   minimizer.minimize("Minuit", "minuit");
   std::unique_ptr<RooFitResult> result(minimizer.save());

   result->Print();

}

I hope this is a good-enough solution for you, otherwise let me know and don’t hesitate to ask further questions in general!

Cheers,
Jonas

Many thanks @jonas.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.