13 #ifndef ROOT_Fit_FitResult
14 #define ROOT_Fit_FitResult
88 void FillResult(
const std::shared_ptr<ROOT::Math::Minimizer> & min,
const FitConfig & fconfig,
const std::shared_ptr<IModelFunction> & f,
98 bool Update(
const std::shared_ptr<ROOT::Math::Minimizer> & min,
bool isValid,
unsigned int ncalls = 0 );
187 double Error(
unsigned int i)
const {
217 double CovMatrix (
unsigned int i,
unsigned int j)
const {
231 return ( tmp > 0) ?
CovMatrix(i,j)/ std::sqrt(tmp) : 0;
236 template<
class Matrix>
238 unsigned int npar =
fErrors.size();
239 if (
fCovMatrix.size() != npar*(npar+1)/2 )
return;
240 for (
unsigned int i = 0; i< npar; ++i) {
241 for (
unsigned int j = 0; j<=i; ++j) {
243 if (i != j) mat(j,i) = mat(i,j);
250 template<
class Matrix>
252 unsigned int npar =
fErrors.size();
253 if (
fCovMatrix.size() != npar*(npar+1)/2)
return;
254 for (
unsigned int i = 0; i< npar; ++i) {
255 for (
unsigned int j = 0; j<=i; ++j) {
257 mat(i,j) = (tmp > 0) ?
fCovMatrix[j + i*(i+1)/2 ] / std::sqrt(tmp) : 0;
258 if (i != j) mat(j,i) = mat(i,j);
276 void GetConfidenceIntervals(
unsigned int n,
unsigned int stride1,
unsigned int stride2,
const double * x,
double * ci,
double cl=0.95,
bool norm =
false )
const;
295 bool Scan(
unsigned int ipar,
unsigned int &npoints,
double *pntsx,
double *pntsy,
double xmin = 0,
double xmax = 0);
301 bool Contour(
unsigned int ipar,
unsigned int jpar,
unsigned int &npoints,
double *pntsx,
double *pntsy,
double confLevel = 0.683);
304 int Index(
const std::string & name)
const;
313 void Print(std::ostream & os,
bool covmat =
false)
const;
357 std::shared_ptr<ROOT::Math::IMultiGenFunction>
fObjFunc;
std::vector< double > fGlobalCC
bool IsEmpty() const
True if a fit result does not exist (even invalid) with parameter values.
std::map< unsigned int, unsigned int > fBoundParams
double ParError(unsigned int i) const
parameter error by index
FitResult & operator=(const FitResult &rhs)
const std::string & MinimizerType() const
minimizer type
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)
std::vector< double > fErrors
bool NormalizedErrors() const
flag to chek if errors are normalized
std::shared_ptr< ROOT::Math::Minimizer > fMinimizer
bool IsParameterFixed(unsigned int ipar) const
query if a parameter is fixed
void GetConfidenceIntervals(const BinData &data, double *ci, double cl=0.95, bool norm=false) const
ROOT::Math::IParamMultiFunction IModelFunction
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 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
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)
FitResult(const FitResult &rhs)
std::shared_ptr< FitData > fFitData
model function resulting from the fit.
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
std::vector< double > GetConfidenceIntervals(double cl=0.95, bool norm=false) const
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
void PrintCovMatrix(std::ostream &os) const
print error matrix and correlations
const double * GetErrors() const
parameter errors (return const pointer)
bool Contour(unsigned int ipar, unsigned int jpar, unsigned int &npoints, double *pntsx, double *pntsy, double confLevel=0.683)
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)
FitResult(const FitConfig &fconfig)
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
const std::vector< double > & Errors() const
parameter errors (return st::vector)
unsigned int NCalls() const
Number of function calls to find minimum.
double Correlation(unsigned int i, unsigned int j) const
retrieve correlation elements
bool Update(const std::shared_ptr< ROOT::Math::Minimizer > &min, bool isValid, unsigned int ncalls=0)
std::shared_ptr< ROOT::Math::IMultiGenFunction > fObjFunc
minimizer object used for fitting
unsigned int NTotalParameters() const
get total number of parameters
int Index(const std::string &name) const
get index for parameter name (return -1 if not found)
const IModelFunction * FittedFunction() const
Return pointer to model (fit) function with fitted parameter values. Pointer is managed internally....
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
const std::vector< double > & Parameters() const
parameter values (return std::vector)
bool IsParameterBound(unsigned int ipar) const
query if a parameter is bound
const double * GetParams() const
parameter values (return const pointer)
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
std::shared_ptr< IModelFunction > ModelFunction()
Return pointer non const pointer to model (fit) function with fitted parameter values....
double GlobalCC(unsigned int i) const
parameter global correlation coefficient
Various mathematical functions.