ROOT   Reference Guide

Minuit-RooMinimizer interface which synchronizes parameter data and coordinates evaluation of likelihood (gradient) values.

This class provides an interface between RooFit and Minuit. It synchronizes parameter values from Minuit, calls calculator classes to evaluate likelihood and likelihood gradient values and returns them to Minuit. The Wrapper objects do the actual calculations. These are constructed inside the MinuitFcnGrad constructor using the RooAbsL likelihood passed in to the constructor, usually directly from RooMinimizer, with which this class is intimately coupled, being a RooAbsMinimizerFcn implementation. MinuitFcnGrad inherits from ROOT::Math::IMultiGradFunction as well, which allows it to be used as the FCN and GRAD parameters Minuit expects.

Note
The class is not intended for use by end-users. We recommend to either use RooMinimizer with a RooAbsL derived likelihood object, or to use a higher level entry point like RooAbsPdf::fitTo() or RooAbsPdf::createNLL().

Definition at line 31 of file MinuitFcnGrad.h.

## Public Member Functions

std::string getFunctionName () const override
RooMinimizer sometimes needs the name of the minimized function. Implement this in the derived class. More...

std::string getFunctionTitle () const override
RooMinimizer sometimes needs the title of the minimized function. Implement this in the derived class. More...

ROOT::Math::IMultiGenFunctiongetMultiGenFcn () override

IMultiGradFunction overrides necessary for Minuit. More...

double operator() (const double *x) const

bool returnsInMinuit2ParameterSpace () const

void setOffsetting (bool flag) override
Enable or disable offsetting on the function to be minimized, which enhances numerical precision. More...

void setOptimizeConstOnFunction (RooAbsArg::ConstOpCode opcode, bool doAlsoTrackingOpt) override
This function must be overridden in the derived class to pass on constant term optimization configuration to the function to be minimized. More...

bool Synchronize (std::vector< ROOT::Fit::ParameterSettings > &parameter_settings) override
Overridden from RooAbsMinimizerFcn to include gradient strategy synchronization. More...

Public Member Functions inherited from RooAbsMinimizerFcn
RooAbsMinimizerFcn (const RooAbsMinimizerFcn &other)

RooAbsMinimizerFcn (RooArgList paramList, RooMinimizer *context)

virtual ~RooAbsMinimizerFcn ()=default

void ApplyCovarianceMatrix (TMatrixDSym &V)
Set different external covariance matrix. More...

void BackProp (const ROOT::Fit::FitResult &results)
Put Minuit results back into RooFit objects. More...

RooMinimizer::Config const & cfg () const

Int_t evalCounter () const

RooArgListGetConstParamList ()

RooArgListGetFloatParamList ()

virtual std::string getFunctionName () const =0
RooMinimizer sometimes needs the name of the minimized function. Implement this in the derived class. More...

virtual std::string getFunctionTitle () const =0
RooMinimizer sometimes needs the title of the minimized function. Implement this in the derived class. More...

RooArgListGetInitConstParamList ()

RooArgListGetInitFloatParamList ()

std::ofstream * GetLogFile ()

doubleGetMaxFCN ()

virtual ROOT::Math::IMultiGenFunctiongetMultiGenFcn ()=0

unsigned int getNDim () const

Int_t GetNumInvalidNLL () const

double getOffset () const
Return a possible offset that's applied to the function to separate invalid function values from valid ones. More...

std::vector< doublegetParameterValues () const

unsigned int NDim () const

bool SetLogFile (const char *inLogfile)
Change the file name for logging of a RooMinimizer of all MINUIT steppings through the parameter space. More...

virtual void setOffsetting (bool flag)=0
Enable or disable offsetting on the function to be minimized, which enhances numerical precision. More...

void setOptimizeConst (Int_t flag)

bool SetPdfParamVal (int index, double value) const
Set value of parameter i. More...

virtual bool Synchronize (std::vector< ROOT::Fit::ParameterSettings > &parameters)
Like synchronizeParameterSettings, Synchronize informs Minuit through its parameter_settings vector of RooFit parameter properties, but Synchronize can be overridden to e.g. More...

bool synchronizeParameterSettings (std::vector< ROOT::Fit::ParameterSettings > &parameters, bool optConst)
Informs Minuit through its parameter_settings vector of RooFit parameter properties. More...

void zeroEvalCount ()

## Private Member Functions

template<class Func >
void applyToLikelihood (Func &&func) const

bool syncParameterValuesFromMinuitCalls (const double *x, bool minuit_internal) const
Minuit calls (via FcnAdapters etc) DoEval or Gradient with a set of parameters x. More...

## Private Attributes

std::shared_ptr< WrapperCalculationCleanFlags_calculationIsClean

std::unique_ptr< LikelihoodWrapper_likelihood

std::vector< double_minuitExternalX

bool _minuitInternalRooFitXMismatch = false

std::vector< double_minuitInternalX

Protected Member Functions inherited from RooAbsMinimizerFcn
void ClearPdfParamAsymErr (Int_t index)
Modify PDF parameter error by ordinal index (needed by MINUIT) More...

void finishDoEval () const

void optimizeConstantTerms (bool constStatChange, bool constValChange)

void printEvalErrors () const
Print information about why evaluation failed. More...

virtual void setOptimizeConstOnFunction (RooAbsArg::ConstOpCode opcode, bool doAlsoTrackingOpt)=0
This function must be overridden in the derived class to pass on constant term optimization configuration to the function to be minimized. More...

void SetPdfParamErr (Int_t index, double loVal, double hiVal)
Modify PDF parameter error by ordinal index (needed by MINUIT) More...

void SetPdfParamErr (Int_t index, double value)
Modify PDF parameter error by ordinal index (needed by MINUIT) More...

Protected Attributes inherited from RooAbsMinimizerFcn
std::unique_ptr< RooArgList_constParamList

RooMinimizer_context

int _evalCounter {0}

std::unique_ptr< RooArgList_floatParamList

double _funcOffset {0.}

std::unique_ptr< RooArgList_initConstParamList

std::unique_ptr< RooArgList_initFloatParamList

std::ofstream * _logfile = nullptr

double _maxFCN = -std::numeric_limits<double>::infinity()

unsigned int _nDim = 0

bool _optConst = false

#include </home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master/roofit/roofitcore/src/TestStatistics/MinuitFcnGrad.h>

[legend]

## Constructor & Destructor Documentation

Parameters
 [in] absL The input likelihood. [in] context RooMinimizer that creates and owns this class. [in] parameters The vector of ParameterSettings objects that describe the parameters used in the Minuit [in] likelihoodMode Lmode [in] likelihoodGradientMode Lgrad [in] verbose true for verbose output Fitter. Note that these must match the set used in the Fitter used by context! It can be passed in from RooMinimizer with fitter()->Config().ParamsSettings().

Definition at line 82 of file MinuitFcnGrad.cxx.

## ◆ applyToLikelihood()

template<class Func >
 void RooFit::TestStatistics::MinuitFcnGrad::applyToLikelihood ( Func && func ) const
inlineprivate

Definition at line 70 of file MinuitFcnGrad.h.

## ◆ getFunctionName()

inlineoverridevirtual

RooMinimizer sometimes needs the name of the minimized function. Implement this in the derived class.

Implements RooAbsMinimizerFcn.

Definition at line 57 of file MinuitFcnGrad.h.

## ◆ getFunctionTitle()

inlineoverridevirtual

RooMinimizer sometimes needs the title of the minimized function. Implement this in the derived class.

Implements RooAbsMinimizerFcn.

Definition at line 59 of file MinuitFcnGrad.h.

## ◆ getMultiGenFcn()

inlineoverridevirtual

Implements RooAbsMinimizerFcn.

Definition at line 48 of file MinuitFcnGrad.h.

Definition at line 264 of file MinuitFcnGrad.cxx.

Definition at line 272 of file MinuitFcnGrad.cxx.

## ◆ operator()()

 double RooFit::TestStatistics::MinuitFcnGrad::operator() ( const double * x ) const

Definition at line 111 of file MinuitFcnGrad.cxx.

## ◆ returnsInMinuit2ParameterSpace()

inline

Definition at line 41 of file MinuitFcnGrad.h.

## ◆ setOffsetting()

 void RooFit::TestStatistics::MinuitFcnGrad::setOffsetting ( bool flag )
inlineoverridevirtual

Enable or disable offsetting on the function to be minimized, which enhances numerical precision.

Implements RooAbsMinimizerFcn.

Definition at line 61 of file MinuitFcnGrad.h.

## ◆ setOptimizeConstOnFunction()

 void RooFit::TestStatistics::MinuitFcnGrad::setOptimizeConstOnFunction ( RooAbsArg::ConstOpCode opcode, bool doAlsoTrackingOpt )
inlineoverridevirtual

This function must be overridden in the derived class to pass on constant term optimization configuration to the function to be minimized.

For a RooAbsArg, this would be RooAbsArg::constOptimizeTestStatistic.

Implements RooAbsMinimizerFcn.

Definition at line 43 of file MinuitFcnGrad.h.

## ◆ Synchronize()

 bool RooFit::TestStatistics::MinuitFcnGrad::Synchronize ( std::vector< ROOT::Fit::ParameterSettings > & parameter_settings )
overridevirtual

Overridden from RooAbsMinimizerFcn to include gradient strategy synchronization.

Reimplemented from RooAbsMinimizerFcn.

Definition at line 281 of file MinuitFcnGrad.cxx.

## ◆ syncParameterValuesFromMinuitCalls()

 bool RooFit::TestStatistics::MinuitFcnGrad::syncParameterValuesFromMinuitCalls ( const double * x, bool minuit_internal ) const
private

Minuit calls (via FcnAdapters etc) DoEval or Gradient with a set of parameters x.

This function syncs these values to the proper places in RooFit.

The first twist, and reason this function is more complicated than one may imagine, is that Minuit internally uses a transformed parameter space to account for parameter boundaries. Whether we receive these Minuit "internal" parameter values or "regular"/untransformed RooFit parameter space values depends on the situation.

• The values that arrive here via DoEval are always "normal" parameter values, since Minuit transforms these back into regular space before passing to DoEval (see MnUserFcn::operator() which wraps the Fcn(Gradient)Base in ModularFunctionMinimizer::Minimize and is used for direct function calls from that point on in the minimizer). These can thus always be safely synced with this function's RooFit parameters using SetPdfParamVal.

The second twist is that the Minuit external parameters may still be different from the ones used in RooFit. This happens when Minuit tries out values that lay outside the RooFit parameter's range(s). RooFit's setVal (called inside SetPdfParamVal) then clips the RooAbsArg's value to one of the range limits, instead of setting it to the value Minuit intended. When this happens, i.e. syncParameterValuesFromMinuitCalls is called with minuit_internal = false and the values do not match the previous values stored in _minuitInternalX but the values after SetPdfParamVal did not get set to the intended value, the _minuitInternalRooFitXMismatch flag is set. This information can be used by calculators, if desired, for instance when a calculator does not want to make use of the range information in the RooAbsArg parameters.

Definition at line 213 of file MinuitFcnGrad.cxx.

## Member Data Documentation

mutableprivate

Definition at line 82 of file MinuitFcnGrad.h.

## ◆ _calculationIsClean

mutableprivate

Definition at line 84 of file MinuitFcnGrad.h.

private

Definition at line 81 of file MinuitFcnGrad.h.

## ◆ _likelihood

private

Definition at line 79 of file MinuitFcnGrad.h.

private

Definition at line 80 of file MinuitFcnGrad.h.

## ◆ _minuitExternalX

mutableprivate

Definition at line 87 of file MinuitFcnGrad.h.

## ◆ _minuitInternalRooFitXMismatch

mutableprivate

Definition at line 91 of file MinuitFcnGrad.h.