#ifndef ROOT_Fit_PoissonLikelihoodFCN
#define ROOT_Fit_PoissonLikelihoodFCN
#ifndef ROOT_Math_FitMethodunction
#include "Math/FitMethodFunction.h"
#endif
#ifndef ROOT_Math_IParamFunction
#include "Math/IParamFunction.h"
#endif
#ifndef ROOT_Fit_BinData
#include "Fit/BinData.h"
#endif
#ifndef ROOT_Fit_FitUtil
#include "Fit/FitUtil.h"
#endif
namespace ROOT {
namespace Fit {
template<class FunType>
class PoissonLikelihoodFCN : public ::ROOT::Math::BasicFitMethodFunction<FunType> {
public:
typedef ::ROOT::Math::BasicFitMethodFunction<FunType> BaseObjFunction;
typedef typename BaseObjFunction::BaseFunction BaseFunction;
typedef ::ROOT::Math::IParamMultiFunction IModelFunction;
PoissonLikelihoodFCN (const BinData & data, const IModelFunction & func, int weight = 0) :
BaseObjFunction(func.NPar(), data.Size() ),
fData(data),
fFunc(func),
fNEffPoints(0),
fWeight(weight),
fGrad ( std::vector<double> ( func.NPar() ) )
{ }
~PoissonLikelihoodFCN () {}
private:
PoissonLikelihoodFCN(const PoissonLikelihoodFCN &);
PoissonLikelihoodFCN & operator = (const PoissonLikelihoodFCN &);
public:
virtual BaseFunction * Clone() const { return new PoissonLikelihoodFCN(fData,fFunc,fWeight); }
virtual unsigned int NFitPoints() const { return fNEffPoints; }
virtual double DataElement(const double * x, unsigned int i, double * g) const {
if (i==0) this->UpdateNCalls();
return FitUtil::EvaluatePoissonBinPdf(fFunc, fData, x, i, g);
}
virtual void Gradient(const double *x, double *g) const {
FitUtil::EvaluatePoissonLogLGradient(fFunc, fData, x, g );
}
virtual typename BaseObjFunction::Type_t Type() const { return BaseObjFunction::kLogLikelihood; }
virtual const BinData & Data() const { return fData; }
virtual const IModelFunction & ModelFunction() const { return fFunc; }
bool IsWeighted() const { return (fWeight != 0); }
void UseSumOfWeights() {
if (fWeight == 0) return;
fWeight = 1;
}
void UseSumOfWeightSquare() {
if (fWeight == 0) return;
fWeight = 2;
}
protected:
private:
virtual double DoEval (const double * x) const {
this->UpdateNCalls();
return FitUtil::EvaluatePoissonLogL(fFunc, fData, x, fWeight, fNEffPoints);
}
virtual double DoDerivative(const double * x, unsigned int icoord ) const {
Gradient(x, &fGrad[0]);
return fGrad[icoord];
}
const BinData & fData;
const IModelFunction & fFunc;
mutable unsigned int fNEffPoints;
int fWeight;
mutable std::vector<double> fGrad;
};
typedef PoissonLikelihoodFCN<ROOT::Math::IMultiGenFunction> PoissonLLFunction;
typedef PoissonLikelihoodFCN<ROOT::Math::IMultiGradFunction> PoissonLLGradFunction;
}
}
#endif /* ROOT_Fit_PoissonLikelihoodFCN */
PoissonLikelihoodFCN.h:10 PoissonLikelihoodFCN.h:11 PoissonLikelihoodFCN.h:12 PoissonLikelihoodFCN.h:13 PoissonLikelihoodFCN.h:14 PoissonLikelihoodFCN.h:15 PoissonLikelihoodFCN.h:16 PoissonLikelihoodFCN.h:17 PoissonLikelihoodFCN.h:18 PoissonLikelihoodFCN.h:19 PoissonLikelihoodFCN.h:20 PoissonLikelihoodFCN.h:21 PoissonLikelihoodFCN.h:22 PoissonLikelihoodFCN.h:23 PoissonLikelihoodFCN.h:24 PoissonLikelihoodFCN.h:25 PoissonLikelihoodFCN.h:26 PoissonLikelihoodFCN.h:27 PoissonLikelihoodFCN.h:28 PoissonLikelihoodFCN.h:29 PoissonLikelihoodFCN.h:30 PoissonLikelihoodFCN.h:31 PoissonLikelihoodFCN.h:32 PoissonLikelihoodFCN.h:33 PoissonLikelihoodFCN.h:34 PoissonLikelihoodFCN.h:35 PoissonLikelihoodFCN.h:36 PoissonLikelihoodFCN.h:37 PoissonLikelihoodFCN.h:38 PoissonLikelihoodFCN.h:39 PoissonLikelihoodFCN.h:40 PoissonLikelihoodFCN.h:41 PoissonLikelihoodFCN.h:42 PoissonLikelihoodFCN.h:43 PoissonLikelihoodFCN.h:44 PoissonLikelihoodFCN.h:45 PoissonLikelihoodFCN.h:46 PoissonLikelihoodFCN.h:47 PoissonLikelihoodFCN.h:48 PoissonLikelihoodFCN.h:49 PoissonLikelihoodFCN.h:50 PoissonLikelihoodFCN.h:51 PoissonLikelihoodFCN.h:52 PoissonLikelihoodFCN.h:53 PoissonLikelihoodFCN.h:54 PoissonLikelihoodFCN.h:55 PoissonLikelihoodFCN.h:56 PoissonLikelihoodFCN.h:57 PoissonLikelihoodFCN.h:58 PoissonLikelihoodFCN.h:59 PoissonLikelihoodFCN.h:60 PoissonLikelihoodFCN.h:61 PoissonLikelihoodFCN.h:62 PoissonLikelihoodFCN.h:63 PoissonLikelihoodFCN.h:64 PoissonLikelihoodFCN.h:65 PoissonLikelihoodFCN.h:66 PoissonLikelihoodFCN.h:67 PoissonLikelihoodFCN.h:68 PoissonLikelihoodFCN.h:69 PoissonLikelihoodFCN.h:70 PoissonLikelihoodFCN.h:71 PoissonLikelihoodFCN.h:72 PoissonLikelihoodFCN.h:73 PoissonLikelihoodFCN.h:74 PoissonLikelihoodFCN.h:75 PoissonLikelihoodFCN.h:76 PoissonLikelihoodFCN.h:77 PoissonLikelihoodFCN.h:78 PoissonLikelihoodFCN.h:79 PoissonLikelihoodFCN.h:80 PoissonLikelihoodFCN.h:81 PoissonLikelihoodFCN.h:82 PoissonLikelihoodFCN.h:83 PoissonLikelihoodFCN.h:84 PoissonLikelihoodFCN.h:85 PoissonLikelihoodFCN.h:86 PoissonLikelihoodFCN.h:87 PoissonLikelihoodFCN.h:88 PoissonLikelihoodFCN.h:89 PoissonLikelihoodFCN.h:90 PoissonLikelihoodFCN.h:91 PoissonLikelihoodFCN.h:92 PoissonLikelihoodFCN.h:93 PoissonLikelihoodFCN.h:94 PoissonLikelihoodFCN.h:95 PoissonLikelihoodFCN.h:96 PoissonLikelihoodFCN.h:97 PoissonLikelihoodFCN.h:98 PoissonLikelihoodFCN.h:99 PoissonLikelihoodFCN.h:100 PoissonLikelihoodFCN.h:101 PoissonLikelihoodFCN.h:102 PoissonLikelihoodFCN.h:103 PoissonLikelihoodFCN.h:104 PoissonLikelihoodFCN.h:105 PoissonLikelihoodFCN.h:106 PoissonLikelihoodFCN.h:107 PoissonLikelihoodFCN.h:108 PoissonLikelihoodFCN.h:109 PoissonLikelihoodFCN.h:110 PoissonLikelihoodFCN.h:111 PoissonLikelihoodFCN.h:112 PoissonLikelihoodFCN.h:113 PoissonLikelihoodFCN.h:114 PoissonLikelihoodFCN.h:115 PoissonLikelihoodFCN.h:116 PoissonLikelihoodFCN.h:117 PoissonLikelihoodFCN.h:118 PoissonLikelihoodFCN.h:119 PoissonLikelihoodFCN.h:120 PoissonLikelihoodFCN.h:121 PoissonLikelihoodFCN.h:122 PoissonLikelihoodFCN.h:123 PoissonLikelihoodFCN.h:124 PoissonLikelihoodFCN.h:125 PoissonLikelihoodFCN.h:126 PoissonLikelihoodFCN.h:127 PoissonLikelihoodFCN.h:128 PoissonLikelihoodFCN.h:129 PoissonLikelihoodFCN.h:130 PoissonLikelihoodFCN.h:131 PoissonLikelihoodFCN.h:132 PoissonLikelihoodFCN.h:133 PoissonLikelihoodFCN.h:134 PoissonLikelihoodFCN.h:135 PoissonLikelihoodFCN.h:136 PoissonLikelihoodFCN.h:137 PoissonLikelihoodFCN.h:138 PoissonLikelihoodFCN.h:139 PoissonLikelihoodFCN.h:140 PoissonLikelihoodFCN.h:141 PoissonLikelihoodFCN.h:142 PoissonLikelihoodFCN.h:143 PoissonLikelihoodFCN.h:144 PoissonLikelihoodFCN.h:145 PoissonLikelihoodFCN.h:146 PoissonLikelihoodFCN.h:147 PoissonLikelihoodFCN.h:148 PoissonLikelihoodFCN.h:149 PoissonLikelihoodFCN.h:150 PoissonLikelihoodFCN.h:151 PoissonLikelihoodFCN.h:152 PoissonLikelihoodFCN.h:153 PoissonLikelihoodFCN.h:154 PoissonLikelihoodFCN.h:155 PoissonLikelihoodFCN.h:156 PoissonLikelihoodFCN.h:157 PoissonLikelihoodFCN.h:158 PoissonLikelihoodFCN.h:159 PoissonLikelihoodFCN.h:160 PoissonLikelihoodFCN.h:161 PoissonLikelihoodFCN.h:162 PoissonLikelihoodFCN.h:163 PoissonLikelihoodFCN.h:164 PoissonLikelihoodFCN.h:165 PoissonLikelihoodFCN.h:166 PoissonLikelihoodFCN.h:167 PoissonLikelihoodFCN.h:168 PoissonLikelihoodFCN.h:169 PoissonLikelihoodFCN.h:170 PoissonLikelihoodFCN.h:171 PoissonLikelihoodFCN.h:172 PoissonLikelihoodFCN.h:173 PoissonLikelihoodFCN.h:174 PoissonLikelihoodFCN.h:175 PoissonLikelihoodFCN.h:176 PoissonLikelihoodFCN.h:177 PoissonLikelihoodFCN.h:178 PoissonLikelihoodFCN.h:179 PoissonLikelihoodFCN.h:180 PoissonLikelihoodFCN.h:181 PoissonLikelihoodFCN.h:182 PoissonLikelihoodFCN.h:183 PoissonLikelihoodFCN.h:184