13#ifndef ROOT_Fit_FitUtil
14#define ROOT_Fit_FitUtil
42vecCore::Mask<T> Int2Mask(
unsigned i)
45 for (
unsigned j = 0; j < vecCore::VectorSize<T>(); j++)
46 vecCore::Set<T>(
x, j, j);
47 return vecCore::Mask<T>(
x <
T(i));
127 template <
class ParamFunc = ROOT::Math::IParamMultiFunctionTempl<
double>>
158 }
else if (
fDim > 1) {
206 double dV = *
x2 - *
x1;
210 for (
unsigned int i = 0; i <
fDim; ++i)
211 dV *= (
x2[i] -
x1[i]);
222 inline double ExecFunc(
T *
f,
const double *
x,
const double *p)
const
232 vecCore::Load<ROOT::Double_v>(xx,
x);
233 const double *p0 = p;
234 auto res = (*f)(&xx, (
const double *)p0);
235 return vecCore::Get<ROOT::Double_v>(res, 0);
237 std::vector<ROOT::Double_v> xx(
fDim);
238 for (
unsigned int i = 0; i <
fDim; ++i) {
239 vecCore::Load<ROOT::Double_v>(xx[i],
x + i);
241 auto res = (*f)(xx.data(), p);
242 return vecCore::Get<ROOT::Double_v>(res, 0);
283 unsigned int &nPoints,
285 unsigned nChunks = 0);
299 unsigned int &nPoints,
301 unsigned nChunks = 0);
316 unsigned nChunks = 0);
323 unsigned int &nPoints,
325 unsigned nChunks = 0);
348 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
354 auto fval = func(&
x, p);
356 return vecCore::Get<ROOT::Double_v>(logPdf, 0);
383 unsigned int n = data.
Size();
384 nPoints = data.
Size();
397 Error(
"FitUtil::EvaluateChi2",
"The vectorized implementation doesn't support Integrals, BinVolume or ExpErrors\n. Aborting operation.");
401 double maxResValue = std::numeric_limits<double>::max() /
n;
402 std::vector<double> ones{1, 1, 1, 1};
403 auto vecSize = vecCore::VectorSize<T>();
405 auto mapFunction = [&](
unsigned int i) {
407 T x1,
y, invErrorVec;
409 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
410 const auto invError = data.
ErrorPtr(i * vecSize);
411 auto invErrorptr = (invError !=
nullptr) ? invError : &ones.front();
412 vecCore::Load<T>(invErrorVec, invErrorptr);
416 if(data.
NDim() > 1) {
417 xc.resize(data.
NDim());
419 for (
unsigned int j = 1; j < data.
NDim(); ++j)
434 T tmp = (
y - fval) * invErrorVec;
439 auto m = vecCore::Mask_v<T>(chi2 > maxResValue);
441 vecCore::MaskedAssign<T>(chi2,
m, maxResValue);
446 auto redFunction = [](
const std::vector<T> &objs) {
447 return std::accumulate(objs.begin(), objs.end(),
T{});
455 Warning(
"FitUtil::EvaluateChi2",
"Multithread execution policy requires IMT, which is disabled. Changing "
456 "to ROOT::Fit::ExecutionPolicy::kSerial.");
472 Error(
"FitUtil::EvaluateChi2",
"Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
476 if (data.
Size() % vecSize != 0)
477 vecCore::MaskedAssign(res, vecCore::Int2Mask<T>(data.
Size() % vecSize),
478 res + mapFunction(data.
Size() / vecSize));
480 return vecCore::ReduceAdd(res);
484 int iWeight,
bool extended,
unsigned int &nPoints,
488 unsigned int n = data.
Size();
489 nPoints = data.
Size();
492 bool normalizeFunc =
false;
502 if (!normalizeFunc) {
503 if (data.
NDim() == 1) {
509 std::vector<T>
x(data.
NDim());
510 for (
unsigned int j = 0; j < data.
NDim(); ++j)
521 std::vector<double>
xmin(data.
NDim());
522 std::vector<double>
xmax(data.
NDim());
527 for (
unsigned int ir = 0; ir < data.
Range().
Size(); ++ir) {
536 vecCore::Load<T>(xmin_v,
xmin.data());
537 vecCore::Load<T>(xmax_v,
xmax.data());
538 if (vecCore::ReduceAdd(func(&xmin_v, p)) != 0 || vecCore::ReduceAdd(func(&xmax_v, p)) != 0) {
539 MATH_ERROR_MSG(
"FitUtil::EvaluateLogLikelihood",
"A range has not been set and the function is not zero at +/- inf");
548 auto vecSize = vecCore::VectorSize<T>();
549 unsigned int numVectors =
n / vecSize;
551 auto mapFunction = [ &, p](
const unsigned i) {
560 const T *
x =
nullptr;
561 unsigned int ndim = data.
NDim();
566 for (
unsigned int j = 1; j < ndim; ++j)
580 if (i < 5 || (i > numVectors-5) ) {
581 if (ndim == 1) std::cout << i <<
" x " <<
x[0] <<
" fval = " << fval;
582 else std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1] <<
" fval = " << fval;
586 if (normalizeFunc) fval = fval * (1 / norm);
592 if (data.WeightsPtr(i) ==
nullptr)
595 vecCore::Load<T>(weight, data.WeightsPtr(i*vecSize));
602 W2 = weight * weight;
607 if (i < 5 || (i > numVectors-5) ) {
608 std::cout <<
" " << fval <<
" logfval " << logval << std::endl;
615 auto redFunction = [](
const std::vector<LikelihoodAux<T>> &objs) {
627 Warning(
"FitUtil::EvaluateLogL",
"Multithread execution policy requires IMT, which is disabled. Changing "
628 "to ROOT::Fit::ExecutionPolicy::kSerial.");
647 Error(
"FitUtil::EvaluateLogL",
"Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
655 unsigned int remainingPoints =
n % vecSize;
656 if (remainingPoints > 0) {
657 auto remainingPointsContribution = mapFunction(numVectors);
659 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
660 vecCore::MaskedAssign(logl_v, remainingMask, logl_v + remainingPointsContribution.logvalue);
661 vecCore::MaskedAssign(sumW_v, remainingMask, sumW_v + remainingPointsContribution.weight);
662 vecCore::MaskedAssign(sumW2_v, remainingMask, sumW2_v + remainingPointsContribution.weight2);
667 double logl = vecCore::ReduceAdd(logl_v);
668 double sumW = vecCore::ReduceAdd(sumW_v);
669 double sumW2 = vecCore::ReduceAdd(sumW2_v);
673 double extendedTerm = 0;
677 if (!normalizeFunc) {
679 std::vector<double>
xmin(data.
NDim());
680 std::vector<double>
xmax(data.
NDim());
685 for (
unsigned int ir = 0; ir < data.
Range().
Size(); ++ir) {
694 vecCore::Load<T>(xmin_v,
xmin.data());
695 vecCore::Load<T>(xmax_v,
xmax.data());
696 if (vecCore::ReduceAdd(func(&xmin_v, p)) != 0 || vecCore::ReduceAdd(func(&xmax_v, p)) != 0) {
697 MATH_ERROR_MSG(
"FitUtil::EvaluateLogLikelihood",
"A range has not been set and the function is not zero at +/- inf");
706 extendedTerm = - nuTot;
710 extendedTerm = - (sumW2 / sumW) * nuTot;
719 logl += extendedTerm;
723 std::cout <<
"Evaluated log L for parameters (";
724 for (
unsigned int ip = 0; ip < func.
NPar(); ++ip)
725 std::cout <<
" " << p[ip];
726 std::cout <<
") nll = " << -logl << std::endl;
734 int iWeight,
bool extended,
unsigned int,
755 auto vecSize = vecCore::VectorSize<T>();
759 Error(
"FitUtil::EvaluateChi2",
760 "The vectorized implementation doesn't support Integrals or BinVolume\n. Aborting operation.");
761 bool useW2 = (iWeight == 2);
763 auto mapFunction = [&](
unsigned int i) {
765 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
768 if (data.
NDim() > 1) {
769 std::vector<T>
x(data.
NDim());
770 for (
unsigned int j = 0; j < data.
NDim(); ++j)
773 fval = func(
x.data());
775 fval = func(
x.data(), p);
790 vecCore::MaskedAssign<T>(fval, fval < 0.0, 0.0);
800 assert (data.
GetErrorType() != ROOT::Fit::BinData::ErrorType::kNoError);
802 vecCore::Load<T>(error, data.
ErrorPtr(i * vecSize));
804 auto m = vecCore::Mask_v<T>(
y != 0.0);
807 nloglike = weight * ( fval -
y);
816 if (extended) nloglike = fval -
y;
818 vecCore::MaskedAssign<T>(
826 auto redFunction = [](
const std::vector<T> &objs) {
return std::accumulate(objs.begin(), objs.end(),
T{}); };
832 Warning(
"FitUtil::Evaluate<T>::EvalPoissonLogL",
833 "Multithread execution policy requires IMT, which is disabled. Changing "
834 "to ROOT::Fit::ExecutionPolicy::kSerial.");
841 for (
unsigned int i = 0; i < (data.
Size() / vecSize); i++) {
842 res += mapFunction(i);
852 "FitUtil::Evaluate<T>::EvalPoissonLogL",
853 "Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
857 if (data.
Size() % vecSize != 0)
858 vecCore::MaskedAssign(res, vecCore::Int2Mask<T>(data.
Size() % vecSize),
859 res + mapFunction(data.
Size() / vecSize));
861 return vecCore::ReduceAdd(res);
866 Error(
"FitUtil::Evaluate<T>::EvalChi2Effective",
"The vectorized evaluation of the Chi2 with coordinate errors is still not supported");
873 static vecCore::Mask<T> CheckInfNaNValues(
T &rval)
887 unsigned int &nPoints,
889 unsigned nChunks = 0)
899 "Error on the coordinates are not used in calculating Chi2 gradient");
904 assert(fg !=
nullptr);
910 Error(
"FitUtil::EvaluateChi2Gradient",
"The vectorized implementation doesn't support Integrals,"
911 "BinVolume or ExpErrors\n. Aborting operation.");
913 unsigned int npar = func.
NPar();
914 auto vecSize = vecCore::VectorSize<T>();
915 unsigned initialNPoints = data.
Size();
916 unsigned numVectors = initialNPoints / vecSize;
919 std::vector<vecCore::Mask<T>> validPointsMasks(numVectors + 1);
921 auto mapFunction = [&](
const unsigned int i) {
923 std::vector<T> gradFunc(npar);
924 std::vector<T> pointContributionVec(npar);
929 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
930 const auto invErrorPtr = data.
ErrorPtr(i * vecSize);
932 if (invErrorPtr ==
nullptr)
935 vecCore::Load<T>(invError, invErrorPtr);
941 const T *
x =
nullptr;
943 unsigned int ndim = data.
NDim();
950 for (
unsigned int j = 1; j < ndim; ++j)
960 validPointsMasks[i] = CheckInfNaNValues(fval);
961 if (vecCore::MaskEmpty(validPointsMasks[i])) {
963 return pointContributionVec;
967 for (
unsigned int ipar = 0; ipar < npar; ++ipar) {
970 validPointsMasks[i] = CheckInfNaNValues(gradFunc[ipar]);
972 if (vecCore::MaskEmpty(validPointsMasks[i])) {
977 vecCore::MaskedAssign(pointContributionVec[ipar], validPointsMasks[i],
978 -2.0 * (
y - fval) * invError * invError * gradFunc[ipar]);
981 return pointContributionVec;
985 auto redFunction = [&](
const std::vector<std::vector<T>> &partialResults) {
986 std::vector<T> result(npar);
988 for (
auto const &pointContributionVec : partialResults) {
989 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
990 result[parameterIndex] += pointContributionVec[parameterIndex];
996 std::vector<T> gVec(npar);
997 std::vector<double>
g(npar);
1005 Warning(
"FitUtil::EvaluateChi2Gradient",
1006 "Multithread execution policy requires IMT, which is disabled. Changing "
1007 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1025 "FitUtil::EvaluateChi2Gradient",
1026 "Execution policy unknown. Avalaible choices:\n 0: Serial (default)\n 1: MultiThread (requires IMT)\n");
1030 unsigned int remainingPoints = initialNPoints % vecSize;
1031 if (remainingPoints > 0) {
1032 auto remainingPointsContribution = mapFunction(numVectors);
1034 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
1035 for (
unsigned int param = 0; param < npar; param++) {
1036 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1040 for (
unsigned int param = 0; param < npar; param++) {
1041 grad[param] = vecCore::ReduceAdd(gVec[param]);
1045 nPoints = initialNPoints;
1047 if (std::any_of(validPointsMasks.begin(), validPointsMasks.end(),
1048 [](vecCore::Mask<T> validPoints) { return !vecCore::MaskFull(validPoints); })) {
1049 unsigned nRejected = 0;
1051 for (
const auto &mask : validPointsMasks) {
1052 for (
unsigned int i = 0; i < vecSize; i++) {
1053 nRejected += !vecCore::Get(mask, i);
1057 assert(nRejected <= initialNPoints);
1058 nPoints = initialNPoints - nRejected;
1060 if (nPoints < npar) {
1062 "Too many points rejected for overflow in gradient calculation");
1069 Error(
"FitUtil::Evaluate<T>::EvalChi2Residual",
"The vectorized evaluation of the Chi2 with the ith residual is still not supported");
1076 Error(
"FitUtil::Evaluate<T>::EvaluatePoissonBinPdf",
"The vectorized evaluation of the BinnedLikelihood fit evaluated point by point is still not supported");
1084 unsigned nChunks = 0)
1089 assert(fg !=
nullptr);
1098 Error(
"FitUtil::EvaluatePoissonLogLGradient",
"The vectorized implementation doesn't support Integrals,"
1099 "BinVolume or ExpErrors\n. Aborting operation.");
1101 unsigned int npar = func.
NPar();
1102 auto vecSize = vecCore::VectorSize<T>();
1103 unsigned initialNPoints = data.
Size();
1104 unsigned numVectors = initialNPoints / vecSize;
1106 auto mapFunction = [&](
const unsigned int i) {
1108 std::vector<T> gradFunc(npar);
1109 std::vector<T> pointContributionVec(npar);
1114 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
1118 const T *
x =
nullptr;
1120 unsigned ndim = data.
NDim();
1125 for (
unsigned int j = 1; j < ndim; ++j)
1136 for (
unsigned int ipar = 0; ipar < npar; ++ipar) {
1137 vecCore::Mask<T> positiveValuesMask = fval > 0;
1140 vecCore::MaskedAssign(pointContributionVec[ipar], positiveValuesMask, gradFunc[ipar] * (1. -
y / fval));
1142 vecCore::Mask<T> validNegativeValuesMask = !positiveValuesMask && gradFunc[ipar] != 0;
1144 if (!vecCore::MaskEmpty(validNegativeValuesMask)) {
1147 T gg = kdmax1 * gradFunc[ipar];
1155 if (i < 5 || (i > data.
Size()-5) ) {
1156 if (data.
NDim() > 1) std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1];
1157 else std::cout << i <<
" x " <<
x[0];
1158 std::cout <<
" func " << fval <<
" gradient ";
1159 for (
unsigned int ii = 0; ii < npar; ++ii) std::cout <<
" " << pointContributionVec[ii];
1165 return pointContributionVec;
1169 auto redFunction = [&](
const std::vector<std::vector<T>> &partialResults) {
1170 std::vector<T> result(npar);
1172 for (
auto const &pointContributionVec : partialResults) {
1173 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
1174 result[parameterIndex] += pointContributionVec[parameterIndex];
1180 std::vector<T> gVec(npar);
1188 Warning(
"FitUtil::EvaluatePoissonLogLGradient",
1189 "Multithread execution policy requires IMT, which is disabled. Changing "
1190 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1207 Error(
"FitUtil::EvaluatePoissonLogLGradient",
"Execution policy unknown. Avalaible choices:\n "
1208 "ROOT::Fit::ExecutionPolicy::kSerial (default)\n "
1209 "ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
1214 unsigned int remainingPoints = initialNPoints % vecSize;
1215 if (remainingPoints > 0) {
1216 auto remainingPointsContribution = mapFunction(numVectors);
1218 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
1219 for (
unsigned int param = 0; param < npar; param++) {
1220 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1224 for (
unsigned int param = 0; param < npar; param++) {
1225 grad[param] = vecCore::ReduceAdd(gVec[param]);
1229 std::cout <<
"***** Final gradient : ";
1230 for (
unsigned int ii = 0; ii< npar; ++ii) std::cout << grad[ii] <<
" ";
1237 double *grad,
unsigned int &,
1239 unsigned nChunks = 0)
1244 assert(fg !=
nullptr);
1249 unsigned int npar = func.
NPar();
1250 auto vecSize = vecCore::VectorSize<T>();
1251 unsigned initialNPoints = data.
Size();
1252 unsigned numVectors = initialNPoints / vecSize;
1255 std::cout <<
"\n===> Evaluate Gradient for parameters ";
1256 for (
unsigned int ip = 0; ip < npar; ++ip)
1257 std::cout <<
" " << p[ip];
1266 auto mapFunction = [&](
const unsigned int i) {
1267 std::vector<T> gradFunc(npar);
1268 std::vector<T> pointContributionVec(npar);
1273 const T *
x =
nullptr;
1275 unsigned int ndim = data.
NDim();
1276 std::vector<T> xc(ndim);
1280 for (
unsigned int j = 1; j < ndim; ++j)
1288 T fval = func(
x, p);
1292 if (i < 5 || (i > numVectors-5) ) {
1293 if (ndim > 1) std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1] <<
" gradient " << gradFunc[0] <<
" " << gradFunc[1] <<
" " << gradFunc[3] << std::endl;
1294 else std::cout << i <<
" x " <<
x[0] <<
" gradient " << gradFunc[0] <<
" " << gradFunc[1] <<
" " << gradFunc[3] << std::endl;
1298 vecCore::Mask<T> positiveValues = fval > 0;
1300 for (
unsigned int kpar = 0; kpar < npar; ++kpar) {
1301 if (!vecCore::MaskEmpty(positiveValues))
1302 vecCore::MaskedAssign<T>(pointContributionVec[kpar], positiveValues, -1. / fval * gradFunc[kpar]);
1304 vecCore::Mask<T> nonZeroGradientValues = !positiveValues && gradFunc[kpar] != 0;
1305 if (!vecCore::MaskEmpty(nonZeroGradientValues)) {
1306 T gg = kdmax1 * gradFunc[kpar];
1307 pointContributionVec[kpar] =
1314 return pointContributionVec;
1318 auto redFunction = [&](
const std::vector<std::vector<T>> &pointContributions) {
1319 std::vector<T> result(npar);
1321 for (
auto const &pointContributionVec : pointContributions) {
1322 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
1323 result[parameterIndex] += pointContributionVec[parameterIndex];
1329 std::vector<T> gVec(npar);
1330 std::vector<double>
g(npar);
1338 Warning(
"FitUtil::EvaluateLogLGradient",
1339 "Multithread execution policy requires IMT, which is disabled. Changing "
1340 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1357 Error(
"FitUtil::EvaluateLogLGradient",
"Execution policy unknown. Avalaible choices:\n "
1358 "ROOT::Fit::ExecutionPolicy::kSerial (default)\n "
1359 "ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
1363 unsigned int remainingPoints = initialNPoints % vecSize;
1364 if (remainingPoints > 0) {
1365 auto remainingPointsContribution = mapFunction(numVectors);
1367 auto remainingMask = vecCore::Int2Mask<T>(initialNPoints % vecSize);
1368 for (
unsigned int param = 0; param < npar; param++) {
1369 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1373 for (
unsigned int param = 0; param < npar; param++) {
1374 grad[param] = vecCore::ReduceAdd(gVec[param]);
1378 std::cout <<
"Final gradient ";
1379 for (
unsigned int param = 0; param < npar; param++) {
1380 std::cout <<
" " << grad[param];
1406 int iWeight,
bool extended,
unsigned int &nPoints,
1413 int iWeight,
bool extended,
unsigned int &nPoints,
1424 double *
g,
unsigned int &nPoints,
1426 unsigned nChunks = 0)
1443 unsigned int &nPoints,
1445 unsigned nChunks = 0)
1451 double *
g,
unsigned int &nPoints,
1453 unsigned nChunks = 0)
1465#if defined (R__HAS_VECCORE) && defined(R__HAS_VC)
#define MATH_ERROR_MSG(loc, str)
static const double x2[5]
static const double x1[5]
void Error(const char *location, const char *msgfmt,...)
void Warning(const char *location, const char *msgfmt,...)
R__EXTERN TVirtualMutex * gROOTMutex
typedef void((*Func_t)())
#define R__LOCKGUARD(mutex)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
double SumOfContent() const
compute the total sum of the data content (sum of weights in case of weighted data set)
const double * ErrorPtr(unsigned int ipoint) const
return error on the value for the given fit point Safe (but slower) method returning correctly the er...
ErrorType GetErrorType() const
retrieve the errortype
bool HaveCoordErrors() const
flag to control if data provides error on the coordinates
const double * ValuePtr(unsigned int ipoint) const
return a pointer to the value for the given fit point
double SumOfError2() const
compute the total sum of the error square (sum of weight square in case of a weighted data set)
unsigned int Size(unsigned int icoord=0) const
return range size for coordinate icoord (starts from zero) Size == 0 indicates no range is present [-...
void GetRange(unsigned int irange, unsigned int icoord, double &xmin, double &xmax) const
get the i-th range for given coordinate.
unsigned int Size() const
return number of fit points
const double * GetCoordComponent(unsigned int ipoint, unsigned int icoord) const
returns a single coordinate component of a point.
unsigned int NDim() const
return coordinate data dimension
const DataOptions & Opt() const
access to options
const DataRange & Range() const
access to range
double Integral(const double *x1, const double *x2)
void SetFunction(const ParamFunc &func, const double *p=0)
IntegralEvaluator & operator=(const IntegralEvaluator &rhs)
ROOT::Math::IGenFunction * fFunc1Dim
ROOT::Math::IntegratorMultiDim * fIgNDim
IntegralEvaluator(const IntegralEvaluator &rhs)
IntegralEvaluator(const ParamFunc &func, const double *p, bool useIntegral=true)
double F1(double x) const
ROOT::Math::IntegratorOneDim * fIg1Dim
double FN(const double *x) const
ROOT::Math::IMultiGenFunction * fFuncNDim
void SetParameters(const double *p)
double ExecFunc(T *f, const double *x, const double *p) const
double operator()(const double *x1, const double *x2)
LikelihoodAux(double logv=0.0, double w=0.0, double w2=0.0)
LikelihoodAux & operator+=(const LikelihoodAux &l)
LikelihoodAux operator+(const LikelihoodAux &l) const
LikelihoodAux operator+(const LikelihoodAux &l) const
LikelihoodAux(T logv={}, T w={}, T w2={})
LikelihoodAux & operator+=(const LikelihoodAux &l)
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
Documentation for the abstract class IBaseFunctionMultiDim.
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
virtual void SetParameters(const double *p)=0
Set the parameter values.
virtual unsigned int NPar() const =0
Return the number of Parameters.
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
virtual void ParameterGradient(const T *x, const double *p, T *grad) const
Evaluate the all the derivatives (gradient vector) of the function with respect to the parameters at ...
User class for performing multidimensional integration.
double Integral(const double *xmin, const double *xmax)
evaluate the integral with the previously given function between xmin[] and xmax[]
void SetFunction(Function &f, unsigned int dim)
set integration function using a generic function implementing the operator()(double *x) The dimensio...
User Class for performing numerical integration of a function in one dimension.
void SetFunction(Function &f)
method to set the a generic integration function
double Integral(Function &f, double a, double b)
evaluate the Integral of a function f over the defined interval (a,b)
Template class to wrap any member function of a class taking a double and returning a double in a 1D ...
A pseudo container class which is a generator of indices.
auto MapReduce(F func, unsigned nTimes, R redfunc) -> typename std::result_of< F()>::type
This class provides a simple interface to execute the same task multiple times in parallel,...
auto MapReduce(F func, unsigned nTimes, R redfunc) -> typename std::result_of< F()>::type
This method behaves just like Map, but an additional redfunc function must be provided.
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
ROOT::Math::IParamMultiGradFunction IGradModelFunction
double EvaluateChi2(const IModelFunction &func, const BinData &data, const double *x, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy, unsigned nChunks=0)
Chi2 Functions.
ROOT::Math::IParamMultiFunction IModelFunction
double EvaluateChi2Residual(const IModelFunction &func, const BinData &data, const double *x, unsigned int ipoint, double *g=0)
evaluate the residual contribution to the Chi2 given a model function and the BinPoint data and if th...
void EvaluateLogLGradient(const IModelFunction &func, const UnBinData &data, const double *x, double *grad, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial, unsigned nChunks=0)
evaluate the LogL gradient given a model function and the data at the point x.
double EvaluatePoissonLogL(const IModelFunction &func, const BinData &data, const double *x, int iWeight, bool extended, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy, unsigned nChunks=0)
evaluate the Poisson LogL given a model function and the data at the point x.
double EvaluateChi2Effective(const IModelFunction &func, const BinData &data, const double *x, unsigned int &nPoints)
evaluate the effective Chi2 given a model function and the data at the point x.
double EvaluatePoissonBinPdf(const IModelFunction &func, const BinData &data, const double *x, unsigned int ipoint, double *g=0)
evaluate the pdf contribution to the Poisson LogL given a model function and the BinPoint data.
unsigned setAutomaticChunking(unsigned nEvents)
double EvaluateLogL(const IModelFunction &func, const UnBinData &data, const double *p, int iWeight, bool extended, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy, unsigned nChunks=0)
evaluate the LogL given a model function and the data at the point x.
void EvaluatePoissonLogLGradient(const IModelFunction &func, const BinData &data, const double *x, double *grad, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial, unsigned nChunks=0)
evaluate the Poisson LogL given a model function and the data at the point x.
double EvaluatePdf(const IModelFunction &func, const UnBinData &data, const double *x, unsigned int ipoint, double *g=0)
evaluate the pdf contribution to the LogL given a model function and the BinPoint data.
void EvaluateChi2Gradient(const IModelFunction &func, const BinData &data, const double *x, double *grad, unsigned int &nPoints, ROOT::Fit::ExecutionPolicy executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial, unsigned nChunks=0)
evaluate the Chi2 gradient given a model function and the data at the point x.
T EvalLog(T x)
safe evaluation of log(x) with a protections against negative or zero argument to the log smooth line...
Double_t Sqrt(Double_t x)
Namespace for new ROOT classes and functions.
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)
DataOptions : simple structure holding the options on how the data are filled.
static double EvalPoissonBinPdf(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, unsigned int i, double *g)
evaluate the pdf (Poisson) contribution to the logl (return actually log of pdf) and its gradient
static double EvalPoissonLogL(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, int iWeight, bool extended, unsigned int &nPoints, ::ROOT::Fit::ExecutionPolicy executionPolicy, unsigned nChunks=0)
static void EvalPoissonLogLGradient(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, double *g, unsigned int &nPoints, ::ROOT::Fit::ExecutionPolicy executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial, unsigned nChunks=0)
static double EvalLogL(const IModelFunctionTempl< double > &func, const UnBinData &data, const double *p, int iWeight, bool extended, unsigned int &nPoints, ::ROOT::Fit::ExecutionPolicy executionPolicy, unsigned nChunks=0)
static double EvalChi2Effective(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, unsigned int &nPoints)
static void EvalChi2Gradient(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, double *g, unsigned int &nPoints, ::ROOT::Fit::ExecutionPolicy executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial, unsigned nChunks=0)
static void EvalLogLGradient(const IModelFunctionTempl< double > &func, const UnBinData &data, const double *p, double *g, unsigned int &nPoints, ::ROOT::Fit::ExecutionPolicy executionPolicy=::ROOT::Fit::ExecutionPolicy::kSerial, unsigned nChunks=0)
static double EvalChi2Residual(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, unsigned int i, double *g=0)
static double EvalChi2(const IModelFunction &func, const BinData &data, const double *p, unsigned int &nPoints, ::ROOT::Fit::ExecutionPolicy executionPolicy, unsigned nChunks=0)