13#ifndef ROOT_Fit_FitResult
14#define ROOT_Fit_FitResult
78 void FillResult(
const std::shared_ptr<ROOT::Math::Minimizer> & min,
const FitConfig & fconfig,
const std::shared_ptr<IModelFunction> &
f,
79 bool isValid,
unsigned int sizeOfData = 0,
int fitType = 1,
const ROOT::Math::IMultiGenFunction *chi2func =
nullptr,
unsigned int ncalls = 0);
88 bool Update(
const std::shared_ptr<ROOT::Math::Minimizer> & min,
const ROOT::Fit::FitConfig & fconfig,
bool isValid,
unsigned int ncalls = 0);
179 double Error(
unsigned int i)
const {
188 std::string
ParName(
unsigned int i)
const;
215 double CovMatrix (
unsigned int i,
unsigned int j)
const {
229 return ( tmp > 0) ?
CovMatrix(i,j)/ std::sqrt(tmp) : 0;
234 template<
class Matrix>
236 unsigned int npar =
fErrors.size();
237 if (
fCovMatrix.size() != npar*(npar+1)/2 )
return;
238 for (
unsigned int i = 0; i< npar; ++i) {
239 for (
unsigned int j = 0; j<=i; ++j) {
241 if (i != j) mat(j,i) = mat(i,j);
248 template<
class Matrix>
250 unsigned int npar =
fErrors.size();
251 if (
fCovMatrix.size() != npar*(npar+1)/2)
return;
252 for (
unsigned int i = 0; i< npar; ++i) {
253 for (
unsigned int j = 0; j<=i; ++j) {
255 mat(i,j) = (tmp > 0) ?
fCovMatrix[j + i*(i+1)/2 ] / std::sqrt(tmp) : 0;
256 if (i != j) mat(j,i) = mat(i,j);
274 void GetConfidenceIntervals(
unsigned int n,
unsigned int stride1,
unsigned int stride2,
const double *
x,
double * ci,
double cl=0.95,
bool norm =
false )
const;
293 bool Scan(
unsigned int ipar,
unsigned int &npoints,
double *pntsx,
double *pntsy,
double xmin = 0,
double xmax = 0);
299 bool Contour(
unsigned int ipar,
unsigned int jpar,
unsigned int &npoints,
double *pntsx,
double *pntsy,
double confLevel = 0.683);
302 int Index(
const std::string &
name)
const;
311 void Print(std::ostream & os,
bool covmat =
false)
const;
323 bool ParameterBounds(
unsigned int ipar,
double &lower,
double &upper)
const;
354 std::shared_ptr<ROOT::Math::IMultiGenFunction>
fObjFunc;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
class containing the result of the fit and all the related information (fitted parameter values,...
std::vector< double > fGlobalCC
global Correlation coefficient
bool IsValid() const
True if fit successful, otherwise false.
bool IsEmpty() const
True if a fit result does not exist (even invalid) with parameter values.
unsigned int fNFree
number of fit free parameters (total parameters are in size of parameter vector)
std::map< unsigned int, unsigned int > fBoundParams
list of limited parameters
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 ...
double ParError(unsigned int i) const
parameter error by index
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 conf...
double UpperError(unsigned int i) const
upper Minos error. If Minos has not run for parameter i return the parabolic error
double fVal
minimum function value
double fEdm
expected distance from minimum
std::vector< double > fErrors
errors
bool NormalizedErrors() const
flag to check if errors are normalized
const std::vector< double > & Errors() const
parameter errors (return st::vector)
const double * GetErrors() const
parameter errors (return const pointer)
std::shared_ptr< ROOT::Math::Minimizer > fMinimizer
! minimizer object used for fitting
bool fValid
flag for indicating valid fit
bool IsParameterFixed(unsigned int ipar) const
query if a parameter is fixed
unsigned int fNdf
number of degree of freedom
const double * GetParams() const
parameter values (return const pointer)
ROOT::Math::IParamMultiFunction IModelFunction
double Error(unsigned int i) const
parameter error by index
double CovMatrix(unsigned int i, unsigned int j) const
retrieve covariance matrix element
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.
double Value(unsigned int i) const
parameter value by index
int fCovStatus
covariance matrix status code
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.
const std::vector< double > & Parameters() const
parameter values (return std::vector)
FitResult()
Default constructor for an empty (non valid) fit result.
std::shared_ptr< FitData > fFitData
! data set used in the fit
const std::string & MinimizerType() const
minimization quantities
std::string GetParameterName(unsigned int ipar) const
get name of parameter (deprecated)
bool ParameterBounds(unsigned int ipar, double &lower, double &upper) const
retrieve parameter bounds - return false if parameter is not bound
unsigned int Ndf() const
Number of degree of freedom.
double Chi2() const
Return the Chi2 value after fitting In case of unbinned fits (or not defined one, see the documentati...
std::vector< double > fParams
parameter values. Size is total number of parameters
std::vector< double > fCovMatrix
covariance matrix (size is npar*(npar+1)/2) where npar is total parameters
void SetMinosError(unsigned int i, double elow, double eup)
set the Minos errors for parameter i (called by the Fitter class when running Minos)
void Print(std::ostream &os, bool covmat=false) const
print the result and optionally covariance matrix and correlations
double LowerError(unsigned int i) const
lower Minos error. If Minos has not run for parameter i return the parabolic error
virtual ~FitResult()
Destructor.
std::shared_ptr< IModelFunction > ModelFunction()
Return pointer non const pointer to model (fit) function with fitted parameter values.
void PrintCovMatrix(std::ostream &os) const
print error matrix and correlations
unsigned int fNCalls
number of function calls
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 val...
void GetCorrelationMatrix(Matrix &mat) const
fill a correlation matrix elements using a generic symmetric matrix class implementing operator(i,...
bool HasMinosError(unsigned int i) const
query if parameter i has the Minos error
std::vector< std::pair< double, double > > fParamBounds
parameter bounds
int fStatus
minimizer status code
double MinFcnValue() const
Return value of the objective function (chi2 or likelihood) used in the fit.
unsigned int NPar() const
total number of parameters (abbreviation)
int CovMatrixStatus() const
covariance matrix status code using Minuit convention : =0 not calculated, =1 approximated,...
double fChi2
fit chi2 value (different than fval in case of chi2 fits)
double Edm() const
Expected distance from minimum.
std::shared_ptr< IModelFunction > fFitFunc
! model function resulting from the fit.
std::map< unsigned int, bool > fFixedParams
list of fixed parameters
std::string fMinimType
string indicating type of minimizer
unsigned int NCalls() const
Number of function calls to find minimum.
double Correlation(unsigned int i, unsigned int j) const
retrieve correlation elements
std::shared_ptr< ROOT::Math::IMultiGenFunction > fObjFunc
! objective function used for fitting
unsigned int NTotalParameters() const
get total number of parameters
double Prob() const
p value of the fit (chi2 probability)
std::string ParName(unsigned int i) const
name of the parameter
void GetCovarianceMatrix(Matrix &mat) const
fill covariance matrix elements using a generic matrix class implementing operator(i,...
void NormalizeErrors()
normalize errors using chi2/ndf for chi2 fits
void SetModelFunction(const std::shared_ptr< IModelFunction > &func)
unsigned int NFreeParameters() const
get total number of free parameters
bool fNormalized
flag for indicating is errors are normalized
bool IsParameterBound(unsigned int ipar) const
query if a parameter is bound
double Parameter(unsigned int i) const
parameter value by index
int Status() const
minimizer status code
std::vector< std::string > fParNames
parameter names (only with FCN only fits, when fFitFunc=0)
std::map< unsigned int, std::pair< double, double > > fMinosErrors
map contains the two Minos errors
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 on...
const IModelFunction * FittedFunction() const
fitting quantities
double GlobalCC(unsigned int i) const
parameter global correlation coefficient
Fitter class, entry point for performing all type of fits.
Documentation for the abstract class IBaseFunctionMultiDim.
RooCmdArg Minimizer(const char *type, const char *alg=nullptr)
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...