ROOT logo
ROOT » MATH » MATHCORE » ROOT::Fit::FitResult

class ROOT::Fit::FitResult


   class containg 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

   @ingroup FitMain

Function Members (Methods)

public:
virtual~FitResult()
doubleChi2() const
doubleCorrelation(unsigned int i, unsigned int j) const
doubleCovMatrix(unsigned int i, unsigned int j) const
intCovMatrixStatus() const
doubleEdm() const
doubleError(unsigned int i) const
const vector<double>&Errors() const
ROOT::Fit::FitResultFitResult()
ROOT::Fit::FitResultFitResult(const ROOT::Fit::FitConfig& fconfig)
ROOT::Fit::FitResultFitResult(const ROOT::Fit::FitResult&)
ROOT::Fit::FitResultFitResult(ROOT::Math::Minimizer& min, const ROOT::Fit::FitConfig& fconfig, const ROOT::Fit::FitResult::IModelFunction* f, bool isValid, unsigned int sizeOfData = 0, bool binFit = true, const ROOT::Math::IMultiGenFunction* chi2func = 0, unsigned int ncalls = 0)
const ROOT::Fit::FitResult::IModelFunction*FittedFunction() const
voidGetConfidenceIntervals(const ROOT::Fit::BinData& data, double* ci, double cl = 0.95, bool norm = true) const
voidGetConfidenceIntervals(unsigned int n, unsigned int stride1, unsigned int stride2, const double* x, double* ci, double cl = 0.95, bool norm = true) const
voidGetCorrelationMatrix(TMatrixTSym<double>& mat) const
voidGetCorrelationMatrix<TMatrixDSym>(TMatrixTSym<double>& mat) const
voidGetCovarianceMatrix(TMatrixTSym<double>& mat) const
voidGetCovarianceMatrix<TMatrixDSym>(TMatrixTSym<double>& mat) const
const double*GetErrors() const
stringGetParameterName(unsigned int ipar) const
const double*GetParams() const
doubleGlobalCC(unsigned int i) const
boolHasMinosError(unsigned int i) const
intIndex(const string& name) const
boolIsEmpty() const
boolIsParameterBound(unsigned int ipar) const
boolIsParameterFixed(unsigned int ipar) const
boolIsValid() const
doubleLowerError(unsigned int i) const
doubleMinFcnValue() const
const string&MinimizerType() const
unsigned intNCalls() const
unsigned intNdf() const
unsigned intNFreeParameters() const
boolNormalizedErrors() const
voidNormalizeErrors()
unsigned intNPar() const
unsigned intNTotalParameters() const
ROOT::Fit::FitResult&operator=(const ROOT::Fit::FitResult& rhs)
doubleParameter(unsigned int i) const
boolParameterBounds(unsigned int ipar, double& lower, double& upper) const
const vector<double>&Parameters() const
doubleParError(unsigned int i) const
stringParName(unsigned int i) const
voidPrint(ostream& os, bool covmat = false) const
voidPrintCovMatrix(ostream& os) const
doubleProb() const
voidSetMinosError(unsigned int i, double elow, double eup)
intStatus() const
boolUpdate(const ROOT::Math::Minimizer& min, bool isValid, unsigned int ncalls = 0)
doubleUpperError(unsigned int i) const
doubleValue(unsigned int i) const
protected:
ROOT::Fit::FitResult::IModelFunction*ModelFunction()
voidSetModelFunction(ROOT::Fit::FitResult::IModelFunction* func)

Data Members

protected:
map<unsigned int,unsigned int>fBoundParamslist of limited parameters
doublefChi2fit chi2 value (different than fval in case of chi2 fits)
vector<double>fCovMatrixcovariance matrix (size is npar*(npar+1)/2) where npar is total parameters
intfCovStatuscovariance matrix status code
doublefEdmexpected distance from mimimum
vector<double>fErrorserrors
ROOT::Fit::FitResult::IModelFunction*fFitFunc! model function resulting from the fit. It is given by Fitter but it is managed by FitResult
map<unsigned int,bool>fFixedParamslist of fixed parameters
vector<double>fGlobalCCglobal Correlation coefficient
stringfMinimTypestring indicating type of minimizer
map<unsigned int,std::pair<double,double> >fMinosErrorsmap contains the two Minos errors
unsigned intfNCallsnumber of function calls
unsigned intfNFreenumber of fit free parameters (total parameters are in size of parameter vector)
unsigned intfNdfnumber of degree of freedom
boolfNormalizedflag for indicating is errors are normalized
vector<std::string>fParNamesparameter names (only with FCN only fits, when fFitFunc=0)
vector<std::pair<double,double> >fParamBoundsparameter bounds
vector<double>fParamsparameter values. Size is total number of parameters
intfStatusminimizer status code
doublefValminimum function value
boolfValidflag for indicating valid fit

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

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. when only one fcn evaluation is done)

FitResult(ROOT::Math::Minimizer& min, const ROOT::Fit::FitConfig& fconfig, const ROOT::Fit::FitResult::IModelFunction* f, bool isValid, unsigned int sizeOfData = 0, bool binFit = true, const ROOT::Math::IMultiGenFunction* chi2func = 0, unsigned int ncalls = 0)
      Construct from a Minimizer instance after fitting
      Run also Minos if requested from the configuration

FitResult(const FitResult &)
      Copy constructor.

virtual ~FitResult()
      Destructor

bool Update(const ROOT::Math::Minimizer& min, 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

const std::string & MinimizerType() const
 minimization quantities 
 minimizer type
{ return fMinimType; }
bool IsValid() const
       True if fit successful, otherwise false.
       A fit is considered successful if the minimizer succeded 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 responability to the Minimizer class to tag a found minimum as valid or not
       and to produce also a status code.

{ return fValid; }
bool IsEmpty() const
 True if a fit result does not exist (even invalid) with parameter values
{ return (fParams.size() == 0); }
double MinFcnValue() const
 Return value of the objective function (chi2 or likelihood) used in the fit
{ return fVal; }
unsigned int NCalls() const
Number of function calls to find minimum
{ return fNCalls; }
double Edm() const
Expected distance from minimum
{ return fEdm; }
unsigned int NTotalParameters() const
   get total number of parameters
{ return fParams.size(); }
unsigned int NPar() const
 total number of parameters (abbreviation)
{ return NTotalParameters(); }
unsigned int NFreeParameters() const
 get total number of free parameters
{ return fNFree; }
int Status() const
 minimizer status code
{ return fStatus; }
int CovMatrixStatus() const
covariance matrix status code
 using Minuit convention : =0 not calculated, =1 approximated, =2 made pos def , =3 accurate
{ return fCovStatus; }
const IModelFunction * FittedFunction() const
 fitting quantities 
 Return pointer to model (fit) function with fitted parameter values.
{ return fFitFunc; }
double Chi2() const
 Chi2 fit value
 in case of likelihood must be computed ?
{ return fChi2; }
unsigned int Ndf() const
 Number of degree of freedom
{ return fNdf; }
double Prob() const
 p value of the fit (chi2 probability)
const std::vector<double> & Errors() const
 parameter errors (return st::vector)
{ return fErrors; }
const double * GetErrors() const
 parameter errors (return const pointer)
{ return (fErrors.empty()) ? 0 : &fErrors.front(); }
const std::vector<double> & Parameters() const
 parameter values (return std::vector)
{ return fParams; }
const double * GetParams() const
 parameter values (return const pointer)
{ return &fParams.front(); }
double Value(unsigned int i) const
 parameter value by index
{ return fParams[i]; }
double Parameter(unsigned int i) const
 parameter value by index
{ return fParams[i]; }
double Error(unsigned int i) const
 parameter error by index
 (NOTE: this due to conflict with TObject::Error cannot used in derived class which
 inherits from TObject. Use instead ParError (or Errors()[i] )
double ParError(unsigned int i) const
 parameter error by index
std::string ParName(unsigned int i) const
 name of the parameter
void SetMinosError(unsigned int i, double elow, double eup)
 set the Minos errors for parameter i (called by the Fitter class when running Minos)
bool HasMinosError(unsigned int i) const
 query if parameter i has the Minos error
double LowerError(unsigned int i) const
 lower Minos error. If Minos has not run for parameter i return the parabolic error
double UpperError(unsigned int i) const
 upper Minos error. If Minos has not run for parameter i return the parabolic error
double GlobalCC(unsigned int i) const
 parameter global correlation coefficient
double CovMatrix(unsigned int i, unsigned int j) const
 retrieve covariance matrix element
double Correlation(unsigned int i, unsigned int j) const
 retrieve correlation elements
void GetCovarianceMatrix(TMatrixTSym<double>& 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)
void GetCorrelationMatrix(TMatrixTSym<double>& 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)
void GetConfidenceIntervals(unsigned int n, unsigned int stride1, unsigned int stride2, const double* x, double* ci, double cl = 0.95, bool norm = true) 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 arraged  as (x0,y0,..,x1,y1,...,xN,yN,..)     stride1=ndim,  stride2=1

      the confidence interval are returned in the array ci
      cl is the desired confidedence interval value
      norm is a flag to control if the intervals need to be normalized to the chi2/ndf value
      By default the intervals are corrected using the chi2/ndf value of the fit if a chi2 fit is performed

void GetConfidenceIntervals(const ROOT::Fit::BinData& data, double* ci, double cl = 0.95, bool norm = true) 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

int Index(const string& name) const
 get index for parameter name (return -1 if not found)
void NormalizeErrors()
normalize errors using chi2/ndf for chi2 fits
bool NormalizedErrors() const
 flag to chek if errors are normalized
{ return fNormalized; }
void Print(ostream& os, bool covmat = false) const
 print the result and optionaly covariance matrix and correlations
void PrintCovMatrix(ostream& os) const
print error matrix and correlations
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 ParameterBounds(unsigned int ipar, double& lower, double& upper) const
 retrieve parameter bounds - return false if parameter is not bound
std::string GetParameterName(unsigned int ipar) const
 get name of parameter (deprecated)
void SetModelFunction(ROOT::Fit::FitResult::IModelFunction* func)
{ fFitFunc = func; }