#ifndef ROOT_Fit_FitResult
#define ROOT_Fit_FitResult
#ifndef ROOT_Fit_IFunctionfwd
#include "Math/IFunctionfwd.h"
#endif
#ifndef ROOT_Fit_IParamFunctionfwd
#include "Math/IParamFunctionfwd.h"
#endif
#include <vector>
#include <string>
#include <cmath>
namespace ROOT {
namespace Math {
class Minimizer;
}
namespace Fit {
class FitConfig;
class FitResult {
public:
typedef ROOT::Math::IParamMultiFunction IModelFunction;
FitResult ();
FitResult(ROOT::Math::Minimizer & min, const FitConfig & fconfig, const IModelFunction & f, bool isValid, unsigned int sizeOfData = 0, const ROOT::Math::IMultiGenFunction * chi2func = 0, bool minosErr = false, unsigned int ncalls = 0);
~FitResult () {}
public:
const std::string & MinimizerType() const { return fMinimType; }
bool IsValid() const { return fValid; }
double MinFcnValue() const { return fVal; }
unsigned int NCalls() const { return fNCalls; }
double Edm() const { return fEdm; }
const IModelFunction * FittedFunction() const { return fFitFunc; }
double Chi2() const { return fChi2; }
unsigned int Ndf() const { return fNdf; }
double Prob() const;
const std::vector<double> & Errors() const { return fErrors; }
const std::vector<double> & Parameters() const { return fParams; }
double Value(unsigned int i) const { return fParams[i]; }
double Error(unsigned int i) const { return fErrors[i]; }
double LowerError(unsigned int i) const { return fMinosErrors[i].first; }
double UpperError(unsigned int i) const { return fMinosErrors[i].second; }
double CovMatrix (unsigned int i, unsigned int j) const {
if ( i >= fErrors.size() || j >= fErrors.size() ) return 0;
if (fCovMatrix.size() == 0) return 0;
if ( j < i )
return fCovMatrix[j + i* (i+1) / 2];
else
return fCovMatrix[i + j* (j+1) / 2];
}
double Correlation(unsigned int i, unsigned int j ) const {
if ( i >= fErrors.size() || j >= fErrors.size() ) return 0;
if (fCovMatrix.size() == 0) return 0;
double tmp = CovMatrix(i,i)*CovMatrix(j,j);
return ( tmp < 0) ? 0 : CovMatrix(i,j)/ std::sqrt(tmp);
}
template<class Matrix>
void GetCovarianceMatrix(Matrix & mat) {
int npar = fErrors.size();
for (int i = 0; i< npar; ++i) {
for (int j = 0; j<=i; ++i) {
mat(i,j) = fCovMatrix[j + i*(i+1)/2 ];
}
}
}
template<class Matrix>
void GetCorrelationMatrix(Matrix & mat) {
int npar = fErrors.size();
for (int i = 0; i< npar; ++i) {
for (int j = 0; j<=i; ++i) {
double tmp = fCovMatrix[i * (i +3)/2 ] * fCovMatrix[ j * (j+3)/2 ];
if (tmp < 0)
mat(i,j) = 0;
else
mat(i,j) = fCovMatrix[j + i*(i+1)/2 ] / std::sqrt(tmp);
}
}
}
int Index(const std::string & name) const;
void NormalizeErrors();
bool NormalizedErrors() { return fNormalized; }
void Print(std::ostream & os, bool covmat = false) const;
void PrintCovMatrix(std::ostream & os) const;
protected:
private:
bool fValid;
bool fNormalized;
double fVal;
double fEdm;
double fChi2;
std::vector<double> fCov;
unsigned int fNdf;
unsigned int fNCalls;
std::vector<double> fParams;
std::vector<double> fErrors;
std::vector<double> fCovMatrix;
std::vector<std::pair<double,double> > fMinosErrors;
unsigned int fDataSize;
const IModelFunction * fFitFunc;
std::string fMinimType;
};
}
}
#endif /* ROOT_Fit_FitResult */
Last change: Wed Jun 25 08:29:15 2008
Last generated: 2008-06-25 08:29
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.