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>>
160 }
else if (
fDim > 1) {
208 double dV = *
x2 - *
x1;
212 for (
unsigned int i = 0; i <
fDim; ++i)
213 dV *= (
x2[i] -
x1[i]);
224 inline double ExecFunc(
T *
f,
const double *
x,
const double *p)
const
234 vecCore::Load<ROOT::Double_v>(xx,
x);
235 const double *p0 = p;
236 auto res = (*f)(&xx, (
const double *)p0);
237 return vecCore::Get<ROOT::Double_v>(res, 0);
239 std::vector<ROOT::Double_v> xx(
fDim);
240 for (
unsigned int i = 0; i <
fDim; ++i) {
241 vecCore::Load<ROOT::Double_v>(xx[i],
x + i);
243 auto res = (*f)(xx.data(), p);
244 return vecCore::Get<ROOT::Double_v>(res, 0);
285 unsigned int &nPoints,
287 unsigned nChunks = 0);
301 unsigned int &nPoints,
303 unsigned nChunks = 0);
318 unsigned nChunks = 0);
325 unsigned int &nPoints,
327 unsigned nChunks = 0);
350 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
356 auto fval = func(&
x, p);
358 return vecCore::Get<ROOT::Double_v>(logPdf, 0);
385 unsigned int n = data.
Size();
386 nPoints = data.
Size();
399 Error(
"FitUtil::EvaluateChi2",
"The vectorized implementation doesn't support Integrals, BinVolume or ExpErrors\n. Aborting operation.");
403 double maxResValue = std::numeric_limits<double>::max() /
n;
404 std::vector<double> ones{1, 1, 1, 1};
405 auto vecSize = vecCore::VectorSize<T>();
407 auto mapFunction = [&](
unsigned int i) {
409 T x1,
y, invErrorVec;
411 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
412 const auto invError = data.
ErrorPtr(i * vecSize);
413 auto invErrorptr = (invError !=
nullptr) ? invError : &ones.front();
414 vecCore::Load<T>(invErrorVec, invErrorptr);
418 if(data.
NDim() > 1) {
419 xc.resize(data.
NDim());
421 for (
unsigned int j = 1; j < data.
NDim(); ++j)
436 T tmp = (
y - fval) * invErrorVec;
441 auto m = vecCore::Mask_v<T>(chi2 > maxResValue);
443 vecCore::MaskedAssign<T>(chi2,
m, maxResValue);
448 auto redFunction = [](
const std::vector<T> &objs) {
449 return std::accumulate(objs.begin(), objs.end(),
T{});
457 Warning(
"FitUtil::EvaluateChi2",
"Multithread execution policy requires IMT, which is disabled. Changing "
458 "to ROOT::Fit::ExecutionPolicy::kSerial.");
474 Error(
"FitUtil::EvaluateChi2",
"Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
478 if (data.
Size() % vecSize != 0)
479 vecCore::MaskedAssign(res, vecCore::Int2Mask<T>(data.
Size() % vecSize),
480 res + mapFunction(data.
Size() / vecSize));
482 return vecCore::ReduceAdd(res);
486 int iWeight,
bool extended,
unsigned int &nPoints,
490 unsigned int n = data.
Size();
491 nPoints = data.
Size();
494 bool normalizeFunc =
false;
504 if (!normalizeFunc) {
505 if (data.
NDim() == 1) {
511 std::vector<T>
x(data.
NDim());
512 for (
unsigned int j = 0; j < data.
NDim(); ++j)
523 std::vector<double>
xmin(data.
NDim());
524 std::vector<double>
xmax(data.
NDim());
529 for (
unsigned int ir = 0; ir < data.
Range().
Size(); ++ir) {
538 vecCore::Load<T>(xmin_v,
xmin.data());
539 vecCore::Load<T>(xmax_v,
xmax.data());
540 if (vecCore::ReduceAdd(func(&xmin_v, p)) != 0 || vecCore::ReduceAdd(func(&xmax_v, p)) != 0) {
541 MATH_ERROR_MSG(
"FitUtil::EvaluateLogLikelihood",
"A range has not been set and the function is not zero at +/- inf");
550 auto vecSize = vecCore::VectorSize<T>();
551 unsigned int numVectors =
n / vecSize;
553 auto mapFunction = [ &, p](
const unsigned i) {
562 const T *
x =
nullptr;
563 unsigned int ndim = data.
NDim();
568 for (
unsigned int j = 1; j < ndim; ++j)
582 if (i < 5 || (i > numVectors-5) ) {
583 if (ndim == 1) std::cout << i <<
" x " <<
x[0] <<
" fval = " << fval;
584 else std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1] <<
" fval = " << fval;
588 if (normalizeFunc) fval = fval * (1 / norm);
594 if (data.WeightsPtr(i) ==
nullptr)
597 vecCore::Load<T>(weight, data.WeightsPtr(i*vecSize));
604 W2 = weight * weight;
609 if (i < 5 || (i > numVectors-5) ) {
610 std::cout <<
" " << fval <<
" logfval " << logval << std::endl;
617 auto redFunction = [](
const std::vector<LikelihoodAux<T>> &objs) {
629 Warning(
"FitUtil::EvaluateLogL",
"Multithread execution policy requires IMT, which is disabled. Changing "
630 "to ROOT::Fit::ExecutionPolicy::kSerial.");
649 Error(
"FitUtil::EvaluateLogL",
"Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
657 unsigned int remainingPoints =
n % vecSize;
658 if (remainingPoints > 0) {
659 auto remainingPointsContribution = mapFunction(numVectors);
661 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
662 vecCore::MaskedAssign(logl_v, remainingMask, logl_v + remainingPointsContribution.logvalue);
663 vecCore::MaskedAssign(sumW_v, remainingMask, sumW_v + remainingPointsContribution.weight);
664 vecCore::MaskedAssign(sumW2_v, remainingMask, sumW2_v + remainingPointsContribution.weight2);
669 double logl = vecCore::ReduceAdd(logl_v);
670 double sumW = vecCore::ReduceAdd(sumW_v);
671 double sumW2 = vecCore::ReduceAdd(sumW2_v);
675 double extendedTerm = 0;
679 if (!normalizeFunc) {
681 std::vector<double>
xmin(data.
NDim());
682 std::vector<double>
xmax(data.
NDim());
687 for (
unsigned int ir = 0; ir < data.
Range().
Size(); ++ir) {
696 vecCore::Load<T>(xmin_v,
xmin.data());
697 vecCore::Load<T>(xmax_v,
xmax.data());
698 if (vecCore::ReduceAdd(func(&xmin_v, p)) != 0 || vecCore::ReduceAdd(func(&xmax_v, p)) != 0) {
699 MATH_ERROR_MSG(
"FitUtil::EvaluateLogLikelihood",
"A range has not been set and the function is not zero at +/- inf");
708 extendedTerm = - nuTot;
712 extendedTerm = - (sumW2 / sumW) * nuTot;
721 logl += extendedTerm;
725 std::cout <<
"Evaluated log L for parameters (";
726 for (
unsigned int ip = 0; ip < func.
NPar(); ++ip)
727 std::cout <<
" " << p[ip];
728 std::cout <<
") nll = " << -logl << std::endl;
736 int iWeight,
bool extended,
unsigned int,
757 auto vecSize = vecCore::VectorSize<T>();
761 Error(
"FitUtil::EvaluateChi2",
762 "The vectorized implementation doesn't support Integrals or BinVolume\n. Aborting operation.");
763 bool useW2 = (iWeight == 2);
765 auto mapFunction = [&](
unsigned int i) {
767 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
770 if (data.
NDim() > 1) {
771 std::vector<T>
x(data.
NDim());
772 for (
unsigned int j = 0; j < data.
NDim(); ++j)
775 fval = func(
x.data());
777 fval = func(
x.data(), p);
792 vecCore::MaskedAssign<T>(fval, fval < 0.0, 0.0);
802 assert (data.
GetErrorType() != ROOT::Fit::BinData::ErrorType::kNoError);
804 vecCore::Load<T>(error, data.
ErrorPtr(i * vecSize));
806 auto m = vecCore::Mask_v<T>(
y != 0.0);
809 nloglike = weight * ( fval -
y);
818 if (extended) nloglike = fval -
y;
820 vecCore::MaskedAssign<T>(
828 auto redFunction = [](
const std::vector<T> &objs) {
return std::accumulate(objs.begin(), objs.end(),
T{}); };
834 Warning(
"FitUtil::Evaluate<T>::EvalPoissonLogL",
835 "Multithread execution policy requires IMT, which is disabled. Changing "
836 "to ROOT::Fit::ExecutionPolicy::kSerial.");
843 for (
unsigned int i = 0; i < (data.
Size() / vecSize); i++) {
844 res += mapFunction(i);
854 "FitUtil::Evaluate<T>::EvalPoissonLogL",
855 "Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
859 if (data.
Size() % vecSize != 0)
860 vecCore::MaskedAssign(res, vecCore::Int2Mask<T>(data.
Size() % vecSize),
861 res + mapFunction(data.
Size() / vecSize));
863 return vecCore::ReduceAdd(res);
868 Error(
"FitUtil::Evaluate<T>::EvalChi2Effective",
"The vectorized evaluation of the Chi2 with coordinate errors is still not supported");
875 static vecCore::Mask<T> CheckInfNaNValues(
T &rval)
889 unsigned int &nPoints,
891 unsigned nChunks = 0)
901 "Error on the coordinates are not used in calculating Chi2 gradient");
906 assert(fg !=
nullptr);
912 Error(
"FitUtil::EvaluateChi2Gradient",
"The vectorized implementation doesn't support Integrals,"
913 "BinVolume or ExpErrors\n. Aborting operation.");
915 unsigned int npar = func.
NPar();
916 auto vecSize = vecCore::VectorSize<T>();
917 unsigned initialNPoints = data.
Size();
918 unsigned numVectors = initialNPoints / vecSize;
921 std::vector<vecCore::Mask<T>> validPointsMasks(numVectors + 1);
923 auto mapFunction = [&](
const unsigned int i) {
925 std::vector<T> gradFunc(npar);
926 std::vector<T> pointContributionVec(npar);
931 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
932 const auto invErrorPtr = data.
ErrorPtr(i * vecSize);
934 if (invErrorPtr ==
nullptr)
937 vecCore::Load<T>(invError, invErrorPtr);
943 const T *
x =
nullptr;
945 unsigned int ndim = data.
NDim();
952 for (
unsigned int j = 1; j < ndim; ++j)
962 validPointsMasks[i] = CheckInfNaNValues(fval);
963 if (vecCore::MaskEmpty(validPointsMasks[i])) {
965 return pointContributionVec;
969 for (
unsigned int ipar = 0; ipar < npar; ++ipar) {
972 validPointsMasks[i] = CheckInfNaNValues(gradFunc[ipar]);
974 if (vecCore::MaskEmpty(validPointsMasks[i])) {
979 vecCore::MaskedAssign(pointContributionVec[ipar], validPointsMasks[i],
980 -2.0 * (
y - fval) * invError * invError * gradFunc[ipar]);
983 return pointContributionVec;
987 auto redFunction = [&](
const std::vector<std::vector<T>> &partialResults) {
988 std::vector<T> result(npar);
990 for (
auto const &pointContributionVec : partialResults) {
991 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
992 result[parameterIndex] += pointContributionVec[parameterIndex];
998 std::vector<T> gVec(npar);
999 std::vector<double>
g(npar);
1007 Warning(
"FitUtil::EvaluateChi2Gradient",
1008 "Multithread execution policy requires IMT, which is disabled. Changing "
1009 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1027 "FitUtil::EvaluateChi2Gradient",
1028 "Execution policy unknown. Avalaible choices:\n 0: Serial (default)\n 1: MultiThread (requires IMT)\n");
1032 unsigned int remainingPoints = initialNPoints % vecSize;
1033 if (remainingPoints > 0) {
1034 auto remainingPointsContribution = mapFunction(numVectors);
1036 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
1037 for (
unsigned int param = 0; param < npar; param++) {
1038 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1042 for (
unsigned int param = 0; param < npar; param++) {
1043 grad[param] = vecCore::ReduceAdd(gVec[param]);
1047 nPoints = initialNPoints;
1049 if (std::any_of(validPointsMasks.begin(), validPointsMasks.end(),
1050 [](vecCore::Mask<T> validPoints) { return !vecCore::MaskFull(validPoints); })) {
1051 unsigned nRejected = 0;
1053 for (
const auto &mask : validPointsMasks) {
1054 for (
unsigned int i = 0; i < vecSize; i++) {
1055 nRejected += !vecCore::Get(mask, i);
1059 assert(nRejected <= initialNPoints);
1060 nPoints = initialNPoints - nRejected;
1062 if (nPoints < npar) {
1064 "Too many points rejected for overflow in gradient calculation");
1071 Error(
"FitUtil::Evaluate<T>::EvalChi2Residual",
"The vectorized evaluation of the Chi2 with the ith residual is still not supported");
1078 Error(
"FitUtil::Evaluate<T>::EvaluatePoissonBinPdf",
"The vectorized evaluation of the BinnedLikelihood fit evaluated point by point is still not supported");
1086 unsigned nChunks = 0)
1091 assert(fg !=
nullptr);
1100 Error(
"FitUtil::EvaluatePoissonLogLGradient",
"The vectorized implementation doesn't support Integrals,"
1101 "BinVolume or ExpErrors\n. Aborting operation.");
1103 unsigned int npar = func.
NPar();
1104 auto vecSize = vecCore::VectorSize<T>();
1105 unsigned initialNPoints = data.
Size();
1106 unsigned numVectors = initialNPoints / vecSize;
1108 auto mapFunction = [&](
const unsigned int i) {
1110 std::vector<T> gradFunc(npar);
1111 std::vector<T> pointContributionVec(npar);
1116 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
1120 const T *
x =
nullptr;
1122 unsigned ndim = data.
NDim();
1127 for (
unsigned int j = 1; j < ndim; ++j)
1138 for (
unsigned int ipar = 0; ipar < npar; ++ipar) {
1139 vecCore::Mask<T> positiveValuesMask = fval > 0;
1142 vecCore::MaskedAssign(pointContributionVec[ipar], positiveValuesMask, gradFunc[ipar] * (1. -
y / fval));
1144 vecCore::Mask<T> validNegativeValuesMask = !positiveValuesMask && gradFunc[ipar] != 0;
1146 if (!vecCore::MaskEmpty(validNegativeValuesMask)) {
1149 T gg = kdmax1 * gradFunc[ipar];
1157 if (i < 5 || (i > data.
Size()-5) ) {
1158 if (data.
NDim() > 1) std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1];
1159 else std::cout << i <<
" x " <<
x[0];
1160 std::cout <<
" func " << fval <<
" gradient ";
1161 for (
unsigned int ii = 0; ii < npar; ++ii) std::cout <<
" " << pointContributionVec[ii];
1167 return pointContributionVec;
1171 auto redFunction = [&](
const std::vector<std::vector<T>> &partialResults) {
1172 std::vector<T> result(npar);
1174 for (
auto const &pointContributionVec : partialResults) {
1175 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
1176 result[parameterIndex] += pointContributionVec[parameterIndex];
1182 std::vector<T> gVec(npar);
1190 Warning(
"FitUtil::EvaluatePoissonLogLGradient",
1191 "Multithread execution policy requires IMT, which is disabled. Changing "
1192 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1209 Error(
"FitUtil::EvaluatePoissonLogLGradient",
"Execution policy unknown. Avalaible choices:\n "
1210 "ROOT::Fit::ExecutionPolicy::kSerial (default)\n "
1211 "ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
1216 unsigned int remainingPoints = initialNPoints % vecSize;
1217 if (remainingPoints > 0) {
1218 auto remainingPointsContribution = mapFunction(numVectors);
1220 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
1221 for (
unsigned int param = 0; param < npar; param++) {
1222 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1226 for (
unsigned int param = 0; param < npar; param++) {
1227 grad[param] = vecCore::ReduceAdd(gVec[param]);
1231 std::cout <<
"***** Final gradient : ";
1232 for (
unsigned int ii = 0; ii< npar; ++ii) std::cout << grad[ii] <<
" ";
1239 double *grad,
unsigned int &,
1241 unsigned nChunks = 0)
1246 assert(fg !=
nullptr);
1251 unsigned int npar = func.
NPar();
1252 auto vecSize = vecCore::VectorSize<T>();
1253 unsigned initialNPoints = data.
Size();
1254 unsigned numVectors = initialNPoints / vecSize;
1257 std::cout <<
"\n===> Evaluate Gradient for parameters ";
1258 for (
unsigned int ip = 0; ip < npar; ++ip)
1259 std::cout <<
" " << p[ip];
1268 auto mapFunction = [&](
const unsigned int i) {
1269 std::vector<T> gradFunc(npar);
1270 std::vector<T> pointContributionVec(npar);
1275 const T *
x =
nullptr;
1277 unsigned int ndim = data.
NDim();
1278 std::vector<T> xc(ndim);
1282 for (
unsigned int j = 1; j < ndim; ++j)
1290 T fval = func(
x, p);
1294 if (i < 5 || (i > numVectors-5) ) {
1295 if (ndim > 1) std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1] <<
" gradient " << gradFunc[0] <<
" " << gradFunc[1] <<
" " << gradFunc[3] << std::endl;
1296 else std::cout << i <<
" x " <<
x[0] <<
" gradient " << gradFunc[0] <<
" " << gradFunc[1] <<
" " << gradFunc[3] << std::endl;
1300 vecCore::Mask<T> positiveValues = fval > 0;
1302 for (
unsigned int kpar = 0; kpar < npar; ++kpar) {
1303 if (!vecCore::MaskEmpty(positiveValues))
1304 vecCore::MaskedAssign<T>(pointContributionVec[kpar], positiveValues, -1. / fval * gradFunc[kpar]);
1306 vecCore::Mask<T> nonZeroGradientValues = !positiveValues && gradFunc[kpar] != 0;
1307 if (!vecCore::MaskEmpty(nonZeroGradientValues)) {
1308 T gg = kdmax1 * gradFunc[kpar];
1309 pointContributionVec[kpar] =
1316 return pointContributionVec;
1320 auto redFunction = [&](
const std::vector<std::vector<T>> &pointContributions) {
1321 std::vector<T> result(npar);
1323 for (
auto const &pointContributionVec : pointContributions) {
1324 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
1325 result[parameterIndex] += pointContributionVec[parameterIndex];
1331 std::vector<T> gVec(npar);
1332 std::vector<double>
g(npar);
1340 Warning(
"FitUtil::EvaluateLogLGradient",
1341 "Multithread execution policy requires IMT, which is disabled. Changing "
1342 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1359 Error(
"FitUtil::EvaluateLogLGradient",
"Execution policy unknown. Avalaible choices:\n "
1360 "ROOT::Fit::ExecutionPolicy::kSerial (default)\n "
1361 "ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
1365 unsigned int remainingPoints = initialNPoints % vecSize;
1366 if (remainingPoints > 0) {
1367 auto remainingPointsContribution = mapFunction(numVectors);
1369 auto remainingMask = vecCore::Int2Mask<T>(initialNPoints % vecSize);
1370 for (
unsigned int param = 0; param < npar; param++) {
1371 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1375 for (
unsigned int param = 0; param < npar; param++) {
1376 grad[param] = vecCore::ReduceAdd(gVec[param]);
1380 std::cout <<
"Final gradient ";
1381 for (
unsigned int param = 0; param < npar; param++) {
1382 std::cout <<
" " << grad[param];
1408 int iWeight,
bool extended,
unsigned int &nPoints,
1415 int iWeight,
bool extended,
unsigned int &nPoints,
1426 double *
g,
unsigned int &nPoints,
1428 unsigned nChunks = 0)
1445 unsigned int &nPoints,
1447 unsigned nChunks = 0)
1453 double *
g,
unsigned int &nPoints,
1455 unsigned nChunks = 0)
1467#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)
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, ROOT::Math::IntegrationOneDim::Type igType=ROOT::Math::IntegrationOneDim::kDEFAULT)
double F1(double x) const
ROOT::Math::IntegratorOneDim * fIg1Dim
void SetFunction(const ParamFunc &func, const double *p=0, ROOT::Math::IntegrationOneDim::Type igType=ROOT::Math::IntegrationOneDim::kDEFAULT)
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.
Type
enumeration specifying the integration types.
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)
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)