| 65 |
Constructor from unbin data set and model function (pdf) |
Constructor from unbin data set and model function (pdf) |
| 66 |
*/ |
*/ |
| 67 |
PoissonLikelihoodFCN (const BinData & data, IModelFunction & func) : |
PoissonLikelihoodFCN (const BinData & data, IModelFunction & func) : |
| 68 |
|
BaseObjFunction(func.NPar(), data.Size() ), |
| 69 |
fData(data), |
fData(data), |
| 70 |
fFunc(func), |
fFunc(func), |
|
fNDim(func.NPar() ), |
|
|
fNPoints(data.Size()), |
|
| 71 |
fNEffPoints(0), |
fNEffPoints(0), |
|
fNCalls(0), |
|
| 72 |
fGrad ( std::vector<double> ( func.NPar() ) ) |
fGrad ( std::vector<double> ( func.NPar() ) ) |
| 73 |
{ } |
{ } |
| 74 |
|
|
| 96 |
/// clone the function (need to return Base for Windows) |
/// clone the function (need to return Base for Windows) |
| 97 |
BaseFunction * Clone() const { return new PoissonLikelihoodFCN(fData,fFunc); } |
BaseFunction * Clone() const { return new PoissonLikelihoodFCN(fData,fFunc); } |
| 98 |
|
|
|
unsigned int NDim() const { return fNDim; } |
|
|
|
|
|
// count number of function calls |
|
|
unsigned int NCalls() const { return fNCalls; } |
|
|
|
|
|
// size of the data |
|
|
unsigned int NPoints() const { return fNPoints; } |
|
|
|
|
| 99 |
// effective points used in the fit |
// effective points used in the fit |
| 100 |
unsigned int NFitPoints() const { return fNEffPoints; } |
unsigned int NFitPoints() const { return fNEffPoints; } |
| 101 |
|
|
|
void ResetNCalls() { fNCalls = 0; } |
|
|
|
|
| 102 |
/// i-th likelihood element and its gradient |
/// i-th likelihood element and its gradient |
| 103 |
double DataElement(const double * x, unsigned int i, double * g) const { |
double DataElement(const double * x, unsigned int i, double * g) const { |
| 104 |
return FitUtil::EvaluatePoissonBinPdf(fFunc, fData, x, i, g); |
return FitUtil::EvaluatePoissonBinPdf(fFunc, fData, x, i, g); |
| 113 |
/// get type of fit method function |
/// get type of fit method function |
| 114 |
virtual typename BaseObjFunction::Type GetType() const { return BaseObjFunction::kLogLikelihood; } |
virtual typename BaseObjFunction::Type GetType() const { return BaseObjFunction::kLogLikelihood; } |
| 115 |
|
|
| 116 |
|
/// access to const reference to the data |
| 117 |
|
virtual const BinData & Data() const { return fData; } |
| 118 |
|
|
| 119 |
|
/// access to const reference to the model function |
| 120 |
|
virtual const IModelFunction & ModelFunction() const { return fFunc; } |
| 121 |
|
|
| 122 |
|
|
| 123 |
protected: |
protected: |
| 124 |
|
|
| 125 |
|
|
| 129 |
Evaluation of the function (required by interface) |
Evaluation of the function (required by interface) |
| 130 |
*/ |
*/ |
| 131 |
double DoEval (const double * x) const { |
double DoEval (const double * x) const { |
| 132 |
fNCalls++; |
this->UpdateNCalls(); |
| 133 |
return FitUtil::EvaluatePoissonLogL(fFunc, fData, x, fNEffPoints); |
return FitUtil::EvaluatePoissonLogL(fFunc, fData, x, fNEffPoints); |
| 134 |
} |
} |
| 135 |
|
|