13#ifndef ROOT_Fit_FitResult
14#define ROOT_Fit_FitResult
87 void FillResult(
const std::shared_ptr<ROOT::Math::Minimizer> & min,
const FitConfig & fconfig,
const std::shared_ptr<IModelFunction> &
f,
97 bool Update(
const std::shared_ptr<ROOT::Math::Minimizer> & min,
const ROOT::Fit::FitConfig & fconfig,
bool isValid,
unsigned int ncalls = 0);
186 double Error(
unsigned int i)
const {
195 std::string
ParName(
unsigned int i)
const;
216 double CovMatrix (
unsigned int i,
unsigned int j)
const {
230 return ( tmp > 0) ?
CovMatrix(i,j)/ std::sqrt(tmp) : 0;
235 template<
class Matrix>
237 unsigned int npar =
fErrors.size();
238 if (
fCovMatrix.size() != npar*(npar+1)/2 )
return;
239 for (
unsigned int i = 0; i< npar; ++i) {
240 for (
unsigned int j = 0; j<=i; ++j) {
242 if (i != j) mat(j,i) = mat(i,j);
249 template<
class Matrix>
251 unsigned int npar =
fErrors.size();
252 if (
fCovMatrix.size() != npar*(npar+1)/2)
return;
253 for (
unsigned int i = 0; i< npar; ++i) {
254 for (
unsigned int j = 0; j<=i; ++j) {
256 mat(i,j) = (tmp > 0) ?
fCovMatrix[j + i*(i+1)/2 ] / std::sqrt(tmp) : 0;
257 if (i != j) mat(j,i) = mat(i,j);
275 void GetConfidenceIntervals(
unsigned int n,
unsigned int stride1,
unsigned int stride2,
const double *
x,
double * ci,
double cl=0.95,
bool norm =
false )
const;
294 bool Scan(
unsigned int ipar,
unsigned int &npoints,
double *pntsx,
double *pntsy,
double xmin = 0,
double xmax = 0);
300 bool Contour(
unsigned int ipar,
unsigned int jpar,
unsigned int &npoints,
double *pntsx,
double *pntsy,
double confLevel = 0.683);
303 int Index(
const std::string &
name)
const;
312 void Print(std::ostream & os,
bool covmat =
false)
const;
324 bool ParameterBounds(
unsigned int ipar,
double &lower,
double &upper)
const;
355 std::shared_ptr<ROOT::Math::IMultiGenFunction>
fObjFunc;
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 containg the result of the fit and all the related information (fitted parameter values,...
std::vector< double > fGlobalCC
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.
std::map< unsigned int, unsigned int > fBoundParams
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
double UpperError(unsigned int i) const
upper Minos error. If Minos has not run for parameter i return the parabolic error
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, bool binFit=true, const ROOT::Math::IMultiGenFunction *chi2func=0, unsigned int ncalls=0)
Fill the fit result from a Minimizer instance after fitting Run also Minos if requested from the conf...
FitResult & operator=(const FitResult &rhs)
Assignment operator.
std::vector< double > fErrors
bool NormalizedErrors() const
flag to chek 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
bool IsParameterFixed(unsigned int ipar) const
query if a parameter is fixed
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
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
model function resulting from 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
Chi2 fit value in case of likelihood must be computed ?
std::vector< double > fParams
std::vector< double > fCovMatrix
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 optionaly 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
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
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
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 Edm() const
Expected distance from minimum.
std::shared_ptr< IModelFunction > fFitFunc
objective function used for fitting
std::map< unsigned int, bool > fFixedParams
data set used in the fit
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
minimizer object used for fitting
unsigned int NTotalParameters() const
get total number of parameters
virtual ~FitResult()
Destructor.
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 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
std::map< unsigned int, std::pair< double, double > > fMinosErrors
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=0)
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...