Minuit2: how to reach parameter errors inside my own FCN

I need to make use of the current errors of the variable parameters (for “weighted” sum of parameter squares) inside my own function:

class MyFcn : public ROOT::Minuit2::FCNBase { ... double operator()( const std::vector<double>& par ) const; ... };
And in my main program I have typical calls:

... ROOT::Minuit2::MnUserParameters upar; ... upar.Add(...); ... MyFcn myfcn(...); ROOT::Minuit2::MnMigrad migrad( myfcn, upar ); ROOT::Minuit2::FunctionMinimum min = migrad(); ...
A standard approach is to implement:

double operator()( const std::vector<double>& par ) const { ... // but how to reach the errors from here? ... }
Intuitively, I would instead need:

double operator()( const ROOT::Minuit2::MnUserParameters& params ) const { ... //now I could reach both parameter values and their errors: double parVal0 = params.Value("parName0"); double parErr0 = params.Error("parName0"); ... }
But that does not work.

So how can I do this? Many thanks in advance!

Hi,

The parameter errors are computed only after the fit, so it does not make sense to pass them in the calculation of the objective (FCN ) function, which his called during the iteration for the minimisation.
If you want to pass some user-defined errors in the function, I suggest you to pass then in the constructor of your defined MyFcn class.

Best Regards

Lorenzo

Thank you, Lorenzo! Understood.

Cheers,