Possible bug in RooMinimizer contour change ErrorDef and gets not restored

Dear experts ,
I suspect i have found a bug in the RooMinimizer.contour() call.

If i try to call 2 contours in a row, the second one uses an ErrorDef which probably comes out from the previous contour.
Even doing Minimizer.setEps or Minimizer.setErrorLevel(0.5) doesn’t restore the values.
One can simply take the example at ROOT: tutorials/roofit/rf601_intminuit.C File Reference
and try to make 2 contours in a row to see the issue making 2 frames

   RooPlot *frame = m.contour(frac, sigma_g2, 1, 2, 3); 
//m.setEps( 0.5); m.setErrorLevel(0.5); doesn't give back the same plot
//   m.fitter()->GetMinimizer()->SetErrorDef(0.5); does give back the same plot
  RooPlot *frame2 = m.contour(frac, sigma_g2, 1,2,3);

I don’t know if it’s the desired behaviour but i would have tough that once contour is run, nothing will change if one rerun it.

From my mac, with ROOT 6.24/02

Looking through the source code
When the scan step is run it calls

_theFitter->GetMinimizer()->SetErrorDef(n[ic]*n[ic]*errdef)

And before exiting

// restore the original ERRDEF
  _theFitter->Config().MinimizerOptions().SetErrorDef(errdef);

I am not sure if the resetting via Config() is the source of the problem i see but i wonder why the changing of errDef and the resetting pass through 2 different methods

@moneta @jonas Can you comment?

Hi Renato

Thank you for reporting this problem. I think it should be easy to reproduce it. I will open a GitHub issue for this one

Cheers

Lorenzo

No problem, glad to help here.
If the workaround is to call

m.fitter()->GetMinimizer()->SetErrorDef(0.5); 

between 2 contours executed in a row or just after it is over, a behaviour i saw which i was not understanding but now it’s fixed is that within a macro itself the code works well, i.e the code doesn’t complain, but when i use this in a compiled source code, it doesn’t compile and gives me this message

././test.C:106:30: error: member access into incomplete type 'ROOT::Math::Minimizer'
   m.fitter()->GetMinimizer()->SetErrorDef(0.5);
                             ^
/Users/quaglian/opt/anaconda3/envs/ROOT/include/Fit/FitConfig.h:32:13: note: forward declaration of 'ROOT::Math::Minimizer'
      class Minimizer;

you can check this behaviour doing

.x test.C++

The error disappear including
#include <Math/Minimizer.h>

My suggestion would be to update the example macro adding this fix commented for example and in case it can be expanded plotting 2 frames with 2 contours in a row where the second one calls for the 2D case 68% coverage , 95, 99 %
using

   RooPlot *frame2 = m.contour(frac, sigma_g2,  sqrt( TMath::ChisquareQuantile(0.6827, 2)),  sqrt(TMath::ChisquareQuantile(0.9545, 2)), sqrt(TMath::ChisquareQuantile(0.9973, 2) ) );

to also highlight that contour with 2DOF and 68% coverage should be done differently than the 1D case.

Cheers
Renato

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