Possible error in NumericalMinimization.C tutorial

I am not sure if this is an error with ROOT or with the documentation, so I decided to just post it here. I believe there is an error in the code example NumericalMinimization, since it crashes with a nullpointer exception for me. The issue appears to be that ROOT::Math::Factory::CreateMinimizer(minName, algoName) returns a nullpointer when minName = “Minuit2”, as it is by default in the tutorial. Changing this to “Minuit” fixes the issue, and, judging from the output, seems to actually use Minuit2 anyway.

ROOT Version: 6.22/07

I don’t see any problem with Minuit2:

C:\Users\bellenot\build\release\tutorials\fit>root -l NumericalMinimization.C
root [0]
Processing NumericalMinimization.C...
Minuit2Minimizer: Minimize with max-calls 1000000 convergence for edm < 0.001 strategy 1
Minuit2Minimizer : Valid minimum - status = 0
FVAL  = 1.84172281656905818e-08
Edm   = 1.8496132831401442e-08
Nfcn  = 174
x         = 0.999903     +/-  1.00396
y         = 0.999796     +/-  2.01024
Minimum: f(0.999903,0.999796): 1.84172e-08
Minimizer Minuit2 -    converged to the right minimum
(int) 0
root [1]

And with Minuit:

C:\Users\bellenot\build\release\tutorials\fit>root -l NumericalMinimization.C
root [0]
Processing NumericalMinimization.C...
 **    1 **SET PRINT           0
 **    2 **SET NOGRAD
    NO.   NAME         VALUE      STEP SIZE      LIMITS
     1 x           -1.00000e+00  1.00000e-02     no limits
     2 y            1.20000e+00  1.00000e-02     no limits
 **    3 **SET ERR           1
 **    4 **SET PRINT           0
 **    5 **SET STR           1
 **    6 **MIGRAD       1e+06       0.001
 FCN=2.25777e-08 FROM MIGRAD    STATUS=CONVERGED     173 CALLS         174 TOTAL
                     EDM=4.53436e-08    STRATEGY= 1      ERROR MATRIX ACCURATE
  EXT PARAMETER                                   STEP         FIRST
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  x            9.99892e-01   1.00386e+00   2.44090e-05   3.97495e-03
   2  y            9.99774e-01   2.01001e+00   4.88281e-05  -2.09540e-03
Minimum: f(0.999892,0.999774): 2.25777e-08
Minimizer Minuit -    converged to the right minimum
(int) 0

So maybe you don’t have Minuit2 in your ROOT build…

Ah yes, this is the issue - I do not have Minuit2 enabled.

I thought it was working since the output claims to use Minuit2:

Comparing with @bellenot’s output it is obvious that it uses the standard Minuit though.

Thanks, I’ll try rebuilding ROOT.

The output explicitly says “Minimizer Minuit2” so you do have it.
Check: root-config --has-minuit2

I did, and it said “no”.

Then I do not understand the "Minimizer Minuit2” output (for sure it does not come from “Minuit”).

You can also try:
root-config --features | grep -i minuit2

I looked a bit more into it with my freshly built root installation, and it turned out to be me not realizing the final output line actually comes from the script, and not the minimizer itself. I had changed the factory parameters to build a Minuit, while leaving the NumericalMinimization parameter as Minuit2, resulting in the output above.

Sorry for the confusion.