class containing the result of the fit and all the related information (fitted parameter values, error, covariance matrix and minimizer result information) Contains a pointer also to the fitted (model) function, modified with the fit parameter values.
When the fit is valid, it is constructed from a Minimizer and a model function pointer
Definition at line 47 of file FitResult.h.
Public Types | |
typedef ROOT::Math::IParamMultiFunction | IModelFunction |
Public Member Functions | |
FitResult () | |
Default constructor for an empty (non valid) fit result. | |
FitResult (const FitConfig &fconfig) | |
Constructor from a fit-config for a dummy fit (e.g. | |
virtual | ~FitResult () |
Destructor. | |
double | Chi2 () const |
Return the Chi2 value after fitting In case of unbinned fits (or not defined one, see the documentation of Fitter::FitFCN) return -1 In case of binned likelihood fits (Poisson Likelihood) return the 2 * negative log-likelihood ratio using the definition of Baker-Cousins. | |
bool | Contour (unsigned int ipar, unsigned int jpar, unsigned int &npoints, double *pntsx, double *pntsy, double confLevel=0.683) |
create contour of two parameters around the minimum pass as option confidence level: default is a value of 0.683 | |
double | Correlation (unsigned int i, unsigned int j) const |
retrieve correlation elements | |
double | CovMatrix (unsigned int i, unsigned int j) const |
retrieve covariance matrix element | |
int | CovMatrixStatus () const |
covariance matrix status code using Minuit convention : =0 not calculated, =1 approximated, =2 made pos def , =3 accurate | |
double | Edm () const |
Expected distance from minimum. | |
double | Error (unsigned int i) const |
parameter error by index | |
const std::vector< double > & | Errors () const |
parameter errors (return st::vector) | |
void | FillResult (const std::shared_ptr< ROOT::Math::Minimizer > &min, const FitConfig &fconfig, const std::shared_ptr< IModelFunction > &f, bool isValid, unsigned int sizeOfData=0, int fitType=1, const ROOT::Math::IMultiGenFunction *chi2func=nullptr, unsigned int ncalls=0) |
Fill the fit result from a Minimizer instance after fitting Run also Minos if requested from the configuration. | |
const BinData * | FittedBinData () const |
return BinData used in the fit (return a nullptr in case a different fit is done or the data are not available Pointer is managed internally, it must not be deleted | |
const IModelFunction * | FittedFunction () const |
fitting quantities | |
void | GetConfidenceIntervals (const BinData &data, double *ci, double cl=0.95, bool norm=false) const |
evaluate confidence interval for the point specified in the passed data sets the confidence interval are returned in the array ci cl is the desired confidence interval value. | |
std::vector< double > | GetConfidenceIntervals (double cl=0.95, bool norm=false) const |
evaluate confidence interval for the data set used in the last fit the confidence interval are returned as a vector of data points | |
void | GetConfidenceIntervals (unsigned int n, unsigned int stride1, unsigned int stride2, const double *x, double *ci, double cl=0.95, bool norm=false) const |
get confidence intervals for an array of n points x. | |
template<class Matrix > | |
void | GetCorrelationMatrix (Matrix &mat) const |
fill a correlation matrix elements using a generic symmetric matrix class implementing operator(i,j) the matrix must be previously allocates with right size (npar * npar) | |
template<class Matrix > | |
void | GetCovarianceMatrix (Matrix &mat) const |
fill covariance matrix elements using a generic matrix class implementing operator(i,j) the matrix must be previously allocates with right size (npar * npar) | |
const double * | GetErrors () const |
parameter errors (return const pointer) | |
std::string | GetParameterName (unsigned int ipar) const |
get name of parameter (deprecated) | |
const double * | GetParams () const |
parameter values (return const pointer) | |
double | GlobalCC (unsigned int i) const |
parameter global correlation coefficient | |
bool | HasMinosError (unsigned int i) const |
query if parameter i has the Minos error | |
int | Index (const std::string &name) const |
get index for parameter name (return -1 if not found) | |
bool | IsEmpty () const |
True if a fit result does not exist (even invalid) with parameter values. | |
bool | IsParameterBound (unsigned int ipar) const |
query if a parameter is bound | |
bool | IsParameterFixed (unsigned int ipar) const |
query if a parameter is fixed | |
bool | IsValid () const |
True if fit successful, otherwise false. | |
double | LowerError (unsigned int i) const |
lower Minos error. If Minos has not run for parameter i return the parabolic error | |
double | MinFcnValue () const |
Return value of the objective function (chi2 or likelihood) used in the fit. | |
const std::string & | MinimizerType () const |
minimization quantities | |
unsigned int | NCalls () const |
Number of function calls to find minimum. | |
unsigned int | Ndf () const |
Number of degree of freedom. | |
unsigned int | NFreeParameters () const |
get total number of free parameters | |
bool | NormalizedErrors () const |
flag to check if errors are normalized | |
void | NormalizeErrors () |
normalize errors using chi2/ndf for chi2 fits | |
unsigned int | NPar () const |
total number of parameters (abbreviation) | |
unsigned int | NTotalParameters () const |
get total number of parameters | |
double | Parameter (unsigned int i) const |
parameter value by index | |
bool | ParameterBounds (unsigned int ipar, double &lower, double &upper) const |
retrieve parameter bounds - return false if parameter is not bound | |
const std::vector< double > & | Parameters () const |
parameter values (return std::vector) | |
double | ParError (unsigned int i) const |
parameter error by index | |
std::string | ParName (unsigned int i) const |
name of the parameter | |
void | Print (std::ostream &os, bool covmat=false) const |
print the result and optionally covariance matrix and correlations | |
void | PrintCovMatrix (std::ostream &os) const |
print error matrix and correlations | |
double | Prob () const |
p value of the fit (chi2 probability) | |
bool | Scan (unsigned int ipar, unsigned int &npoints, double *pntsx, double *pntsy, double xmin=0, double xmax=0) |
scan likelihood value of parameter and fill the given graph. | |
void | SetChi2AndNdf (double chi2, unsigned int npoints) |
Set the chi2 and the ndf This function should be called when using an external FCN for fitting and one provides the chi2 and the number of fitting data points) to store and have them printed in the FitResult class. | |
void | SetMinosError (unsigned int i, double elow, double eup) |
set the Minos errors for parameter i (called by the Fitter class when running Minos) | |
int | Status () const |
minimizer status code | |
bool | Update (const std::shared_ptr< ROOT::Math::Minimizer > &min, const ROOT::Fit::FitConfig &fconfig, bool isValid, unsigned int ncalls=0) |
Update the fit result with a new minimization status To be run only if same fit is performed with same configuration Note that in this case MINOS is not re-run. | |
double | UpperError (unsigned int i) const |
upper Minos error. If Minos has not run for parameter i return the parabolic error | |
double | Value (unsigned int i) const |
parameter value by index | |
Protected Member Functions | |
std::shared_ptr< IModelFunction > | ModelFunction () |
Return pointer non const pointer to model (fit) function with fitted parameter values. | |
void | SetModelFunction (const std::shared_ptr< IModelFunction > &func) |
Protected Attributes | |
std::map< unsigned int, unsigned int > | fBoundParams |
list of limited parameters | |
double | fChi2 |
fit chi2 value (different than fval in case of chi2 fits) | |
std::vector< double > | fCovMatrix |
covariance matrix (size is npar*(npar+1)/2) where npar is total parameters | |
int | fCovStatus |
covariance matrix status code | |
double | fEdm |
expected distance from minimum | |
std::vector< double > | fErrors |
errors | |
std::shared_ptr< FitData > | fFitData |
! data set used in the fit | |
std::shared_ptr< IModelFunction > | fFitFunc |
! model function resulting from the fit. | |
std::map< unsigned int, bool > | fFixedParams |
list of fixed parameters | |
std::vector< double > | fGlobalCC |
global Correlation coefficient | |
std::shared_ptr< ROOT::Math::Minimizer > | fMinimizer |
! minimizer object used for fitting | |
std::string | fMinimType |
string indicating type of minimizer | |
std::map< unsigned int, std::pair< double, double > > | fMinosErrors |
map contains the two Minos errors | |
unsigned int | fNCalls |
number of function calls | |
unsigned int | fNdf |
number of degree of freedom | |
unsigned int | fNFree |
number of fit free parameters (total parameters are in size of parameter vector) | |
bool | fNormalized |
flag for indicating is errors are normalized | |
std::shared_ptr< ROOT::Math::IMultiGenFunction > | fObjFunc |
! objective function used for fitting | |
std::vector< std::pair< double, double > > | fParamBounds |
parameter bounds | |
std::vector< double > | fParams |
parameter values. Size is total number of parameters | |
std::vector< std::string > | fParNames |
parameter names (only with FCN only fits, when fFitFunc=0) | |
int | fStatus |
minimizer status code | |
double | fVal |
minimum function value | |
bool | fValid |
flag for indicating valid fit | |
Friends | |
class | Fitter |
#include <Fit/FitResult.h>
Definition at line 51 of file FitResult.h.
ROOT::Fit::FitResult::FitResult | ( | ) |
Default constructor for an empty (non valid) fit result.
Definition at line 45 of file FitResult.cxx.
ROOT::Fit::FitResult::FitResult | ( | const FitConfig & | fconfig | ) |
Constructor from a fit-config for a dummy fit (e.g.
when only one fcn evaluation is done)
Definition at line 52 of file FitResult.cxx.
|
inlinevirtual |
Destructor.
Definition at line 69 of file FitResult.h.
|
inline |
Return the Chi2 value after fitting In case of unbinned fits (or not defined one, see the documentation of Fitter::FitFCN) return -1 In case of binned likelihood fits (Poisson Likelihood) return the 2 * negative log-likelihood ratio using the definition of Baker-Cousins.
Definition at line 153 of file FitResult.h.
bool ROOT::Fit::FitResult::Contour | ( | unsigned int | ipar, |
unsigned int | jpar, | ||
unsigned int & | npoints, | ||
double * | pntsx, | ||
double * | pntsy, | ||
double | confLevel = 0.683 |
||
) |
create contour of two parameters around the minimum pass as option confidence level: default is a value of 0.683
Create a 2D contour around the minimum for the parameter ipar and jpar if a minimum does not exist or is invalid it will return false A array for x and y points should be provided Pass optionally the confidence level, default is 0.683 it is assumed that ErrorDef() defines the right error definition (i.e 1 sigma error for one parameter).
If not the confidence level are scaled to new level
Definition at line 660 of file FitResult.cxx.
retrieve correlation elements
Definition at line 225 of file FitResult.h.
retrieve covariance matrix element
Definition at line 215 of file FitResult.h.
|
inline |
covariance matrix status code using Minuit convention : =0 not calculated, =1 approximated, =2 made pos def , =3 accurate
Definition at line 133 of file FitResult.h.
|
inline |
Expected distance from minimum.
Definition at line 117 of file FitResult.h.
parameter error by index
Definition at line 179 of file FitResult.h.
|
inline |
parameter errors (return st::vector)
Definition at line 162 of file FitResult.h.
void ROOT::Fit::FitResult::FillResult | ( | const std::shared_ptr< ROOT::Math::Minimizer > & | min, |
const FitConfig & | fconfig, | ||
const std::shared_ptr< IModelFunction > & | f, | ||
bool | isValid, | ||
unsigned int | sizeOfData = 0 , |
||
int | fitType = 1 , |
||
const ROOT::Math::IMultiGenFunction * | chi2func = nullptr , |
||
unsigned int | ncalls = 0 |
||
) |
Fill the fit result from a Minimizer instance after fitting Run also Minos if requested from the configuration.
Definition at line 100 of file FitResult.cxx.
const BinData * ROOT::Fit::FitResult::FittedBinData | ( | ) | const |
return BinData used in the fit (return a nullptr in case a different fit is done or the data are not available Pointer is managed internally, it must not be deleted
Definition at line 631 of file FitResult.cxx.
|
inline |
fitting quantities
Return pointer to model (fit) function with fitted parameter values. Pointer is managed internally. I must not be deleted
Definition at line 139 of file FitResult.h.
void ROOT::Fit::FitResult::GetConfidenceIntervals | ( | const BinData & | data, |
double * | ci, | ||
double | cl = 0.95 , |
||
bool | norm = false |
||
) | const |
evaluate confidence interval for the point specified in the passed data sets the confidence interval are returned in the array ci cl is the desired confidence interval value.
This method is maintained for backward compatibility and will be deprecated
Definition at line 583 of file FitResult.cxx.
std::vector< double > ROOT::Fit::FitResult::GetConfidenceIntervals | ( | double | cl = 0.95 , |
bool | norm = false |
||
) | const |
evaluate confidence interval for the data set used in the last fit the confidence interval are returned as a vector of data points
Definition at line 599 of file FitResult.cxx.
void ROOT::Fit::FitResult::GetConfidenceIntervals | ( | unsigned int | n, |
unsigned int | stride1, | ||
unsigned int | stride2, | ||
const double * | x, | ||
double * | ci, | ||
double | cl = 0.95 , |
||
bool | norm = false |
||
) | const |
get confidence intervals for an array of n points x.
stride1 indicates the stride in the coordinate space while stride2 the stride in dimension space. For 1-dim points : stride1=1, stride2=1 for multi-dim points arranged as (x0,x1,...,xN,y0,....yN) stride1=1 stride2=n for multi-dim points arranged as (x0,y0,..,x1,y1,...,xN,yN,..) stride1=ndim, stride2=1
the confidence interval are returned in the array ci cl is the desired confidence interval value norm is a flag to control if the intervals need to be normalized to the chi2/ndf value The intervals can be corrected optionally using the chi2/ndf value of the fit if a chi2 fit is performed. This has changed since ROOT 6.14, before the interval were corrected by default.
Definition at line 506 of file FitResult.cxx.
|
inline |
fill a correlation matrix elements using a generic symmetric matrix class implementing operator(i,j) the matrix must be previously allocates with right size (npar * npar)
Definition at line 249 of file FitResult.h.
fill covariance matrix elements using a generic matrix class implementing operator(i,j) the matrix must be previously allocates with right size (npar * npar)
Definition at line 235 of file FitResult.h.
|
inline |
parameter errors (return const pointer)
Definition at line 164 of file FitResult.h.
|
inline |
get name of parameter (deprecated)
Definition at line 327 of file FitResult.h.
|
inline |
parameter values (return const pointer)
Definition at line 169 of file FitResult.h.
parameter global correlation coefficient
Definition at line 209 of file FitResult.h.
query if parameter i has the Minos error
Definition at line 325 of file FitResult.cxx.
int ROOT::Fit::FitResult::Index | ( | const std::string & | name | ) | const |
get index for parameter name (return -1 if not found)
Definition at line 351 of file FitResult.cxx.
|
inline |
True if a fit result does not exist (even invalid) with parameter values.
Definition at line 108 of file FitResult.h.
query if a parameter is bound
Definition at line 361 of file FitResult.cxx.
query if a parameter is fixed
Definition at line 365 of file FitResult.cxx.
|
inline |
True if fit successful, otherwise false.
A fit is considered successful if the minimizer succeeded in finding the minimum. It could happen that subsequent operations like error analysis (e.g. Minos) failed. In that case the status can be still true if the original minimization algorithm succeeded in finding the minimum. One can query in that case the minimizer return status using Status(). It is responsibility to the Minimizer class to tag a found minimum as valid or not and to produce also a status code.
Definition at line 105 of file FitResult.h.
lower Minos error. If Minos has not run for parameter i return the parabolic error
Definition at line 332 of file FitResult.cxx.
|
inline |
Return value of the objective function (chi2 or likelihood) used in the fit.
Definition at line 111 of file FitResult.h.
|
inline |
|
inlineprotected |
Return pointer non const pointer to model (fit) function with fitted parameter values.
used by Fitter class
Definition at line 337 of file FitResult.h.
|
inline |
Number of function calls to find minimum.
Definition at line 114 of file FitResult.h.
|
inline |
Number of degree of freedom.
Definition at line 156 of file FitResult.h.
|
inline |
get total number of free parameters
Definition at line 125 of file FitResult.h.
|
inline |
flag to check if errors are normalized
Definition at line 308 of file FitResult.h.
void ROOT::Fit::FitResult::NormalizeErrors | ( | ) |
normalize errors using chi2/ndf for chi2 fits
Definition at line 298 of file FitResult.cxx.
|
inline |
total number of parameters (abbreviation)
Definition at line 122 of file FitResult.h.
|
inline |
get total number of parameters
Definition at line 120 of file FitResult.h.
parameter value by index
Definition at line 174 of file FitResult.h.
bool ROOT::Fit::FitResult::ParameterBounds | ( | unsigned int | ipar, |
double & | lower, | ||
double & | upper | ||
) | const |
retrieve parameter bounds - return false if parameter is not bound
Definition at line 369 of file FitResult.cxx.
|
inline |
parameter values (return std::vector)
Definition at line 167 of file FitResult.h.
parameter error by index
Definition at line 183 of file FitResult.h.
std::string ROOT::Fit::FitResult::ParName | ( | unsigned int | i | ) | const |
name of the parameter
Definition at line 382 of file FitResult.cxx.
void ROOT::Fit::FitResult::Print | ( | std::ostream & | os, |
bool | covmat = false |
||
) | const |
print the result and optionally covariance matrix and correlations
Definition at line 389 of file FitResult.cxx.
void ROOT::Fit::FitResult::PrintCovMatrix | ( | std::ostream & | os | ) | const |
print error matrix and correlations
Definition at line 447 of file FitResult.cxx.
double ROOT::Fit::FitResult::Prob | ( | ) | const |
p value of the fit (chi2 probability)
Definition at line 320 of file FitResult.cxx.
bool ROOT::Fit::FitResult::Scan | ( | unsigned int | ipar, |
unsigned int & | npoints, | ||
double * | pntsx, | ||
double * | pntsy, | ||
double | xmin = 0 , |
||
double | xmax = 0 |
||
) |
scan likelihood value of parameter and fill the given graph.
Scan parameter ipar between value of xmin and xmax A array for x and y points should be provided.
Definition at line 639 of file FitResult.cxx.
Set the chi2 and the ndf This function should be called when using an external FCN for fitting and one provides the chi2 and the number of fitting data points) to store and have them printed in the FitResult class.
Definition at line 311 of file FitResult.cxx.
set the Minos errors for parameter i (called by the Fitter class when running Minos)
Definition at line 346 of file FitResult.cxx.
|
inlineprotected |
Definition at line 338 of file FitResult.h.
|
inline |
minimizer status code
Definition at line 128 of file FitResult.h.
bool ROOT::Fit::FitResult::Update | ( | const std::shared_ptr< ROOT::Math::Minimizer > & | min, |
const ROOT::Fit::FitConfig & | fconfig, | ||
bool | isValid, | ||
unsigned int | ncalls = 0 |
||
) |
Update the fit result with a new minimization status To be run only if same fit is performed with same configuration Note that in this case MINOS is not re-run.
If one wants to run also MINOS a new result must be created
Definition at line 224 of file FitResult.cxx.
upper Minos error. If Minos has not run for parameter i return the parabolic error
Definition at line 339 of file FitResult.cxx.
parameter value by index
Definition at line 172 of file FitResult.h.
|
friend |
Definition at line 340 of file FitResult.h.
list of limited parameters
Definition at line 358 of file FitResult.h.
|
protected |
fit chi2 value (different than fval in case of chi2 fits)
Definition at line 352 of file FitResult.h.
|
protected |
covariance matrix (size is npar*(npar+1)/2) where npar is total parameters
Definition at line 362 of file FitResult.h.
|
protected |
covariance matrix status code
Definition at line 349 of file FitResult.h.
|
protected |
expected distance from minimum
Definition at line 351 of file FitResult.h.
|
protected |
errors
Definition at line 361 of file FitResult.h.
|
protected |
! data set used in the fit
Definition at line 356 of file FitResult.h.
|
protected |
! model function resulting from the fit.
Definition at line 355 of file FitResult.h.
list of fixed parameters
Definition at line 357 of file FitResult.h.
|
protected |
global Correlation coefficient
Definition at line 363 of file FitResult.h.
|
protected |
! minimizer object used for fitting
Definition at line 353 of file FitResult.h.
|
protected |
string indicating type of minimizer
Definition at line 365 of file FitResult.h.
map contains the two Minos errors
Definition at line 364 of file FitResult.h.
|
protected |
number of function calls
Definition at line 347 of file FitResult.h.
|
protected |
number of degree of freedom
Definition at line 346 of file FitResult.h.
|
protected |
number of fit free parameters (total parameters are in size of parameter vector)
Definition at line 345 of file FitResult.h.
|
protected |
flag for indicating is errors are normalized
Definition at line 344 of file FitResult.h.
|
protected |
! objective function used for fitting
Definition at line 354 of file FitResult.h.
parameter bounds
Definition at line 359 of file FitResult.h.
|
protected |
parameter values. Size is total number of parameters
Definition at line 360 of file FitResult.h.
|
protected |
parameter names (only with FCN only fits, when fFitFunc=0)
Definition at line 366 of file FitResult.h.
|
protected |
minimizer status code
Definition at line 348 of file FitResult.h.
|
protected |
minimum function value
Definition at line 350 of file FitResult.h.
|
protected |
flag for indicating valid fit
Definition at line 343 of file FitResult.h.