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