MnHesse on Minuit2 standalone: too many arguments

I am using MINUIT 5.34.14 standalone version (downloaded from http://seal.web.cern.ch/seal/snapshot/work-packages/mathlibs/minuit/) on Ubuntu 20.04 on WSL.

I am trying to use the MnHesse class to estimate the covariance matrix of my fit, since MIGRAD alone sometimes provides negative variances. The fit itself goes smoothly and MIGRAD converges. However, no matter the syntax I use, MnHesse gives me a “too many arguments” error at compiling time. Of course, when I state that the program runs smoothly I mean without the call to MnHess. Here is the relevant code:

ROOT::Minuit2::MnUserParameters params;
params.Add("energy", initEn, initEnErr);
params.Add("pos", initPos, initPosErr);
params.Add("sigma", initSigma, initSigmaErr);
params.Add("pitch", anodePitch, 0);

FitFunc fitFunc(dataOn, anodesOn, datavarOn);   //FitFunc is the fitting function class that requires, x, y and sigma^2(y). It is a class derived from ROOT::Minuit2::FCNBase
ROOT::Minuit2::MnMigrad migrad(fitFunc, params);
migrad.Fix("pitch");
ROOT::Minuit2::FunctionMinimum fmin = migrad();

ROOT::Minuit2::MnHesse hesse();
hesse(fitFunc, fmin);
// I have also attempted the following, in alternative to the previous line:
// fmin.UserState() = hesse(fitFunc, fmin.UserParameters());
// but the error is still there

To be clear, I checked the header of MnHesse and it seems to me that my attempts should work. Here is also the MnHesse operators I can finde in Minuit2/MnHesse.h:

   ///
   /// low-level API
   ///
   /// FCN + parameters + errors
   MnUserParameterState operator()(const FCNBase&, const std::vector<double>&, const std::vector<double>&, unsigned int maxcalls=0) const;
   /// FCN + parameters + covariance
   MnUserParameterState operator()(const FCNBase&, const std::vector<double>&,  unsigned int nrow, const std::vector<double>&, unsigned int maxcalls = 0) const;
   /// FCN + parameters + MnUserCovariance
   MnUserParameterState operator()(const FCNBase&, const std::vector<double>&, const MnUserCovariance&, unsigned int maxcalls=0) const;
   ///
   /// high-level API
   ///
   /// FCN + MnUserParameters
   MnUserParameterState operator()(const FCNBase&, const MnUserParameters&, unsigned int maxcalls=0) const;
   /// FCN + MnUserParameters + MnUserCovariance
   MnUserParameterState operator()(const FCNBase&, const MnUserParameters&, const MnUserCovariance&, unsigned int maxcalls=0) const;
   /// FCN + MnUserParameterState
   MnUserParameterState operator()(const FCNBase&, const MnUserParameterState&, unsigned int maxcalls=0) const;
   /// 
   /// API to use MnHesse after minimization when function mimimum is avalilable, otherwise information on the last state will be 
   /// lost. (It would be needed to re-call the gradient and spend extra useless function calls) 
   /// The Function Minimum is updated (modified) by adding the Hesse results as last state of minimization
   ///
   void operator()(const FCNBase&, FunctionMinimum&, unsigned int maxcalls=0) const;
   

   /// internal interface
   ///
   MinimumState operator()(const MnFcn&, const MinimumState&, const MnUserTransformation&, unsigned int maxcalls=0) const;

Any insights on what I am doing wrong?

_ROOT Version: MINUIT 5.34.14 standalone
_Platform: Ubuntu 20.04 on WSL
_Compiler: gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0


Hi @Rdat,
sorry for the high latency! This question is really for @moneta but he is currently off.
Please ping us again in two weeks if you don’t hear anything before then!

Cheers,
Enrico

Hi,

Can you please attach your code and the compilation error. At first sight , it seems correct, you should use after minimization this interface of MnHesse,
https://root.cern.ch/doc/master/classROOT_1_1Minuit2_1_1MnHesse.html#a3b6ba68a41260029bc6bde433170e600

In general, I think it is easier to use the Minuit2Minimizer interface, where internally you can call Migrad and Hesse.
You can see also from its implementation how you should call MnHesse,
https://root.cern.ch/doc/master/Minuit2Minimizer_8cxx_source.html#l01116

If you need an example on how to use the Minuit2Minimizer, you can see this ROOT tutorial,
https://root.cern.ch/doc/master/NumericalMinimization_8C.html

If you having the standaonle Minuit version, you need just to create directly the Minuit2Minimizer class instead of using the Factory class, i.e. replace the line

 ROOT::Math::Minimizer* minimum = ROOT::Math::Factory::CreateMinimizer(minName, algoName);

with

 ROOT::Math::Minimizer* minimum = new ROOT::Minuit2::Minuit2Minimizer(algoName);

Lorenzo