| 66 |
Constructor from unbin data set and model function (pdf) |
Constructor from unbin data set and model function (pdf) |
| 67 |
*/ |
*/ |
| 68 |
LogLikelihoodFCN (const UnBinData & data, IModelFunction & func) : |
LogLikelihoodFCN (const UnBinData & data, IModelFunction & func) : |
| 69 |
|
BaseObjFunction(func.NPar(), data.Size() ), |
| 70 |
fData(data), |
fData(data), |
| 71 |
fFunc(func), |
fFunc(func), |
|
fNDim(func.NPar() ), |
|
|
fNPoints(data.Size()), |
|
| 72 |
fNEffPoints(0), |
fNEffPoints(0), |
|
fNCalls(0), |
|
| 73 |
fGrad ( std::vector<double> ( func.NPar() ) ) |
fGrad ( std::vector<double> ( func.NPar() ) ) |
| 74 |
{} |
{} |
| 75 |
|
|
| 99 |
/// clone the function (need to return Base for Windows) |
/// clone the function (need to return Base for Windows) |
| 100 |
BaseFunction * Clone() const { return new LogLikelihoodFCN(fData,fFunc); } |
BaseFunction * Clone() const { return new LogLikelihoodFCN(fData,fFunc); } |
| 101 |
|
|
|
unsigned int NDim() const { return fNDim; } |
|
| 102 |
|
|
| 103 |
//using BaseObjFunction::operator(); |
//using BaseObjFunction::operator(); |
| 104 |
|
|
|
// count number of function calls |
|
|
unsigned int NCalls() const { return fNCalls; } |
|
|
|
|
|
// size of the data |
|
|
unsigned int NPoints() const { return fNPoints; } |
|
|
|
|
| 105 |
// effective points used in the fit |
// effective points used in the fit |
| 106 |
unsigned int NFitPoints() const { return fNEffPoints; } |
unsigned int NFitPoints() const { return fNEffPoints; } |
| 107 |
|
|
|
void ResetNCalls() { fNCalls = 0; } |
|
|
|
|
| 108 |
/// i-th likelihood contribution and its gradient |
/// i-th likelihood contribution and its gradient |
| 109 |
double DataElement(const double * x, unsigned int i, double * g) const { |
double DataElement(const double * x, unsigned int i, double * g) const { |
| 110 |
return FitUtil::EvaluatePdf(fFunc, fData, x, i, g); |
return FitUtil::EvaluatePdf(fFunc, fData, x, i, g); |
| 120 |
/// get type of fit method function |
/// get type of fit method function |
| 121 |
virtual typename BaseObjFunction::Type GetType() const { return BaseObjFunction::kLogLikelihood; } |
virtual typename BaseObjFunction::Type GetType() const { return BaseObjFunction::kLogLikelihood; } |
| 122 |
|
|
| 123 |
|
/// access to const reference to the data |
| 124 |
|
virtual const UnBinData & Data() const { return fData; } |
| 125 |
|
|
| 126 |
|
/// access to const reference to the model function |
| 127 |
|
virtual const IModelFunction & ModelFunction() const { return fFunc; } |
| 128 |
|
|
| 129 |
protected: |
protected: |
| 130 |
|
|
| 135 |
Evaluation of the function (required by interface) |
Evaluation of the function (required by interface) |
| 136 |
*/ |
*/ |
| 137 |
double DoEval (const double * x) const { |
double DoEval (const double * x) const { |
| 138 |
fNCalls++; |
this->UpdateNCalls(); |
| 139 |
#ifdef PARALLEL |
#ifdef PARALLEL |
| 140 |
return FitUtilParallel::EvaluateLogL(fFunc, fData, x, fNEffPoints); |
return FitUtilParallel::EvaluateLogL(fFunc, fData, x, fNEffPoints); |
| 141 |
#else |
#else |
| 155 |
const UnBinData & fData; |
const UnBinData & fData; |
| 156 |
mutable IModelFunction & fFunc; |
mutable IModelFunction & fFunc; |
| 157 |
|
|
|
unsigned int fNDim; |
|
|
unsigned int fNPoints; // size of the data |
|
| 158 |
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; |
|
| 159 |
|
|
| 160 |
mutable std::vector<double> fGrad; // for derivatives |
mutable std::vector<double> fGrad; // for derivatives |
| 161 |
|
|