| 87 |
Constructor from data set (binned ) and model function |
Constructor from data set (binned ) and model function |
| 88 |
*/ |
*/ |
| 89 |
Chi2FCN (const BinData & data, IModelFunction & func) : |
Chi2FCN (const BinData & data, IModelFunction & func) : |
| 90 |
|
BaseObjFunction(func.NPar(), data.Size() ), |
| 91 |
fData(data), |
fData(data), |
| 92 |
fFunc(func), |
fFunc(func), |
|
fNDim(func.NPar() ), |
|
|
fNPoints(data.Size()), |
|
| 93 |
fNEffPoints(0), |
fNEffPoints(0), |
|
fNCalls(0), |
|
| 94 |
fGrad ( std::vector<double> ( func.NPar() ) ) |
fGrad ( std::vector<double> ( func.NPar() ) ) |
| 95 |
{ } |
{ } |
| 96 |
|
|
| 124 |
} |
} |
| 125 |
|
|
| 126 |
|
|
|
virtual unsigned int NDim() const { return fNDim; } |
|
| 127 |
|
|
| 128 |
using BaseObjFunction::operator(); |
using BaseObjFunction::operator(); |
| 129 |
|
|
|
// count number of function calls |
|
|
virtual unsigned int NCalls() const { return fNCalls; } |
|
|
|
|
|
// size of the fit data points (required by interface) |
|
|
virtual unsigned int NPoints() const { return fNPoints; } |
|
| 130 |
|
|
| 131 |
// effective points used in the fit (exclude the rejected one) |
// effective points used in the fit (exclude the rejected one) |
| 132 |
virtual unsigned int NFitPoints() const { return fNEffPoints; } |
virtual unsigned int NFitPoints() const { return fNEffPoints; } |
| 133 |
|
|
|
virtual void ResetNCalls() { fNCalls = 0; } |
|
| 134 |
|
|
| 135 |
/// i-th chi-square residual |
/// i-th chi-square residual |
| 136 |
virtual double DataElement(const double * x, unsigned int i, double * g) const { |
virtual double DataElement(const double * x, unsigned int i, double * g) const { |
| 153 |
virtual const IModelFunction & ModelFunction() const { return fFunc; } |
virtual const IModelFunction & ModelFunction() const { return fFunc; } |
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
protected: |
protected: |
| 158 |
|
|
| 159 |
|
|
| 166 |
Evaluation of the function (required by interface) |
Evaluation of the function (required by interface) |
| 167 |
*/ |
*/ |
| 168 |
virtual double DoEval (const double * x) const { |
virtual double DoEval (const double * x) const { |
| 169 |
fNCalls++; |
this->UpdateNCalls(); |
| 170 |
#ifdef ROOT_FIT_PARALLEL |
#ifdef ROOT_FIT_PARALLEL |
| 171 |
return FitUtilParallel::EvaluateChi2(fFunc, fData, x, fNEffPoints); |
return FitUtilParallel::EvaluateChi2(fFunc, fData, x, fNEffPoints); |
| 172 |
#else |
#else |
| 186 |
const BinData & fData; |
const BinData & fData; |
| 187 |
mutable IModelFunction & fFunc; |
mutable IModelFunction & fFunc; |
| 188 |
|
|
|
unsigned int fNDim; |
|
|
unsigned int fNPoints; // size of the data |
|
| 189 |
mutable unsigned int fNEffPoints; // number of effective points used in the fit |
mutable unsigned int fNEffPoints; // number of effective points used in the fit |
|
mutable unsigned int fNCalls; |
|
| 190 |
|
|
| 191 |
mutable std::vector<double> fGrad; // for derivatives |
mutable std::vector<double> fGrad; // for derivatives |
| 192 |
|
|