13#ifndef ROOT_Fit_FitUtil
14#define ROOT_Fit_FitUtil
41vecCore::Mask<T> Int2Mask(
unsigned i)
44 for (
unsigned j = 0; j < vecCore::VectorSize<T>(); j++)
45 vecCore::Set<T>(
x, j, j);
46 return vecCore::Mask<T>(
x <
T(i));
126 template <
class ParamFunc = ROOT::Math::IParamMultiFunctionTempl<
double>>
159 }
else if (
fDim > 1) {
207 double dV = *
x2 - *
x1;
211 for (
unsigned int i = 0; i <
fDim; ++i)
212 dV *= (
x2[i] -
x1[i]);
223 inline double ExecFunc(
T *
f,
const double *
x,
const double *p)
const
233 vecCore::Load<ROOT::Double_v>(xx,
x);
234 const double *p0 = p;
235 auto res = (*f)(&xx, (
const double *)p0);
236 return vecCore::Get<ROOT::Double_v>(res, 0);
238 std::vector<ROOT::Double_v> xx(
fDim);
239 for (
unsigned int i = 0; i <
fDim; ++i) {
240 vecCore::Load<ROOT::Double_v>(xx[i],
x + i);
242 auto res = (*f)(xx.data(), p);
243 return vecCore::Get<ROOT::Double_v>(res, 0);
284 unsigned int &nPoints,
286 unsigned nChunks = 0);
300 unsigned int &nPoints,
302 unsigned nChunks = 0);
317 unsigned nChunks = 0);
324 unsigned int &nPoints,
326 unsigned nChunks = 0);
349 template <
class NotCompileIfScalarBackend = std::enable_if<!(std::is_same<
double, ROOT::Double_v>::value)>>
355 auto fval = func(&
x, p);
357 return vecCore::Get<ROOT::Double_v>(logPdf, 0);
384 unsigned int n = data.
Size();
385 nPoints = data.
Size();
398 Error(
"FitUtil::EvaluateChi2",
"The vectorized implementation doesn't support Integrals, BinVolume or ExpErrors\n. Aborting operation.");
402 double maxResValue = std::numeric_limits<double>::max() /
n;
403 std::vector<double> ones{1, 1, 1, 1};
404 auto vecSize = vecCore::VectorSize<T>();
406 auto mapFunction = [&](
unsigned int i) {
408 T x1,
y, invErrorVec;
410 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
411 const auto invError = data.
ErrorPtr(i * vecSize);
412 auto invErrorptr = (invError !=
nullptr) ? invError : &ones.front();
413 vecCore::Load<T>(invErrorVec, invErrorptr);
417 if(data.
NDim() > 1) {
418 xc.resize(data.
NDim());
420 for (
unsigned int j = 1; j < data.
NDim(); ++j)
435 T tmp = (
y - fval) * invErrorVec;
440 auto m = vecCore::Mask_v<T>(chi2 > maxResValue);
442 vecCore::MaskedAssign<T>(chi2,
m, maxResValue);
447 auto redFunction = [](
const std::vector<T> &objs) {
448 return std::accumulate(objs.begin(), objs.end(),
T{});
456 Warning(
"FitUtil::EvaluateChi2",
"Multithread execution policy requires IMT, which is disabled. Changing "
457 "to ROOT::Fit::ExecutionPolicy::kSerial.");
473 Error(
"FitUtil::EvaluateChi2",
"Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
477 if (data.
Size() % vecSize != 0)
478 vecCore::MaskedAssign(res, vecCore::Int2Mask<T>(data.
Size() % vecSize),
479 res + mapFunction(data.
Size() / vecSize));
481 return vecCore::ReduceAdd(res);
485 int iWeight,
bool extended,
unsigned int &nPoints,
489 unsigned int n = data.
Size();
490 nPoints = data.
Size();
493 bool normalizeFunc =
false;
503 if (!normalizeFunc) {
504 if (data.
NDim() == 1) {
510 std::vector<T>
x(data.
NDim());
511 for (
unsigned int j = 0; j < data.
NDim(); ++j)
522 std::vector<double>
xmin(data.
NDim());
523 std::vector<double>
xmax(data.
NDim());
528 for (
unsigned int ir = 0; ir < data.
Range().
Size(); ++ir) {
537 vecCore::Load<T>(xmin_v,
xmin.data());
538 vecCore::Load<T>(xmax_v,
xmax.data());
539 if (vecCore::ReduceAdd(func(&xmin_v, p)) != 0 || vecCore::ReduceAdd(func(&xmax_v, p)) != 0) {
540 MATH_ERROR_MSG(
"FitUtil::EvaluateLogLikelihood",
"A range has not been set and the function is not zero at +/- inf");
549 auto vecSize = vecCore::VectorSize<T>();
550 unsigned int numVectors =
n / vecSize;
552 auto mapFunction = [ &, p](
const unsigned i) {
561 const T *
x =
nullptr;
562 unsigned int ndim = data.
NDim();
567 for (
unsigned int j = 1; j < ndim; ++j)
581 if (i < 5 || (i > numVectors-5) ) {
582 if (ndim == 1) std::cout << i <<
" x " <<
x[0] <<
" fval = " << fval;
583 else std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1] <<
" fval = " << fval;
587 if (normalizeFunc) fval = fval * (1 / norm);
593 if (data.WeightsPtr(i) ==
nullptr)
596 vecCore::Load<T>(weight, data.WeightsPtr(i*vecSize));
603 W2 = weight * weight;
608 if (i < 5 || (i > numVectors-5) ) {
609 std::cout <<
" " << fval <<
" logfval " << logval << std::endl;
616 auto redFunction = [](
const std::vector<LikelihoodAux<T>> &objs) {
628 Warning(
"FitUtil::EvaluateLogL",
"Multithread execution policy requires IMT, which is disabled. Changing "
629 "to ROOT::Fit::ExecutionPolicy::kSerial.");
648 Error(
"FitUtil::EvaluateLogL",
"Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
656 unsigned int remainingPoints =
n % vecSize;
657 if (remainingPoints > 0) {
658 auto remainingPointsContribution = mapFunction(numVectors);
660 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
661 vecCore::MaskedAssign(logl_v, remainingMask, logl_v + remainingPointsContribution.logvalue);
662 vecCore::MaskedAssign(sumW_v, remainingMask, sumW_v + remainingPointsContribution.weight);
663 vecCore::MaskedAssign(sumW2_v, remainingMask, sumW2_v + remainingPointsContribution.weight2);
668 double logl = vecCore::ReduceAdd(logl_v);
669 double sumW = vecCore::ReduceAdd(sumW_v);
670 double sumW2 = vecCore::ReduceAdd(sumW2_v);
674 double extendedTerm = 0;
678 if (!normalizeFunc) {
680 std::vector<double>
xmin(data.
NDim());
681 std::vector<double>
xmax(data.
NDim());
686 for (
unsigned int ir = 0; ir < data.
Range().
Size(); ++ir) {
695 vecCore::Load<T>(xmin_v,
xmin.data());
696 vecCore::Load<T>(xmax_v,
xmax.data());
697 if (vecCore::ReduceAdd(func(&xmin_v, p)) != 0 || vecCore::ReduceAdd(func(&xmax_v, p)) != 0) {
698 MATH_ERROR_MSG(
"FitUtil::EvaluateLogLikelihood",
"A range has not been set and the function is not zero at +/- inf");
707 extendedTerm = - nuTot;
711 extendedTerm = - (sumW2 / sumW) * nuTot;
720 logl += extendedTerm;
724 std::cout <<
"Evaluated log L for parameters (";
725 for (
unsigned int ip = 0; ip < func.
NPar(); ++ip)
726 std::cout <<
" " << p[ip];
727 std::cout <<
") nll = " << -logl << std::endl;
735 int iWeight,
bool extended,
unsigned int,
756 auto vecSize = vecCore::VectorSize<T>();
760 Error(
"FitUtil::EvaluateChi2",
761 "The vectorized implementation doesn't support Integrals or BinVolume\n. Aborting operation.");
762 bool useW2 = (iWeight == 2);
764 auto mapFunction = [&](
unsigned int i) {
766 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
769 if (data.
NDim() > 1) {
770 std::vector<T>
x(data.
NDim());
771 for (
unsigned int j = 0; j < data.
NDim(); ++j)
774 fval = func(
x.data());
776 fval = func(
x.data(), p);
791 vecCore::MaskedAssign<T>(fval, fval < 0.0, 0.0);
801 assert (data.
GetErrorType() != ROOT::Fit::BinData::ErrorType::kNoError);
803 vecCore::Load<T>(error, data.
ErrorPtr(i * vecSize));
805 auto m = vecCore::Mask_v<T>(
y != 0.0);
808 nloglike = weight * ( fval -
y);
817 if (extended) nloglike = fval -
y;
819 vecCore::MaskedAssign<T>(
827 auto redFunction = [](
const std::vector<T> &objs) {
return std::accumulate(objs.begin(), objs.end(),
T{}); };
833 Warning(
"FitUtil::Evaluate<T>::EvalPoissonLogL",
834 "Multithread execution policy requires IMT, which is disabled. Changing "
835 "to ROOT::Fit::ExecutionPolicy::kSerial.");
842 for (
unsigned int i = 0; i < (data.
Size() / vecSize); i++) {
843 res += mapFunction(i);
853 "FitUtil::Evaluate<T>::EvalPoissonLogL",
854 "Execution policy unknown. Avalaible choices:\n ROOT::Fit::ExecutionPolicy::kSerial (default)\n ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
858 if (data.
Size() % vecSize != 0)
859 vecCore::MaskedAssign(res, vecCore::Int2Mask<T>(data.
Size() % vecSize),
860 res + mapFunction(data.
Size() / vecSize));
862 return vecCore::ReduceAdd(res);
867 Error(
"FitUtil::Evaluate<T>::EvalChi2Effective",
"The vectorized evaluation of the Chi2 with coordinate errors is still not supported");
874 static vecCore::Mask<T> CheckInfNaNValues(
T &rval)
888 unsigned int &nPoints,
890 unsigned nChunks = 0)
900 "Error on the coordinates are not used in calculating Chi2 gradient");
905 assert(fg !=
nullptr);
911 Error(
"FitUtil::EvaluateChi2Gradient",
"The vectorized implementation doesn't support Integrals,"
912 "BinVolume or ExpErrors\n. Aborting operation.");
914 unsigned int npar = func.
NPar();
915 auto vecSize = vecCore::VectorSize<T>();
916 unsigned initialNPoints = data.
Size();
917 unsigned numVectors = initialNPoints / vecSize;
920 std::vector<vecCore::Mask<T>> validPointsMasks(numVectors + 1);
922 auto mapFunction = [&](
const unsigned int i) {
924 std::vector<T> gradFunc(npar);
925 std::vector<T> pointContributionVec(npar);
930 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
931 const auto invErrorPtr = data.
ErrorPtr(i * vecSize);
933 if (invErrorPtr ==
nullptr)
936 vecCore::Load<T>(invError, invErrorPtr);
942 const T *
x =
nullptr;
944 unsigned int ndim = data.
NDim();
951 for (
unsigned int j = 1; j < ndim; ++j)
961 validPointsMasks[i] = CheckInfNaNValues(fval);
962 if (vecCore::MaskEmpty(validPointsMasks[i])) {
964 return pointContributionVec;
968 for (
unsigned int ipar = 0; ipar < npar; ++ipar) {
971 validPointsMasks[i] = CheckInfNaNValues(gradFunc[ipar]);
973 if (vecCore::MaskEmpty(validPointsMasks[i])) {
978 vecCore::MaskedAssign(pointContributionVec[ipar], validPointsMasks[i],
979 -2.0 * (
y - fval) * invError * invError * gradFunc[ipar]);
982 return pointContributionVec;
986 auto redFunction = [&](
const std::vector<std::vector<T>> &partialResults) {
987 std::vector<T> result(npar);
989 for (
auto const &pointContributionVec : partialResults) {
990 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
991 result[parameterIndex] += pointContributionVec[parameterIndex];
997 std::vector<T> gVec(npar);
998 std::vector<double>
g(npar);
1006 Warning(
"FitUtil::EvaluateChi2Gradient",
1007 "Multithread execution policy requires IMT, which is disabled. Changing "
1008 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1026 "FitUtil::EvaluateChi2Gradient",
1027 "Execution policy unknown. Avalaible choices:\n 0: Serial (default)\n 1: MultiThread (requires IMT)\n");
1031 unsigned int remainingPoints = initialNPoints % vecSize;
1032 if (remainingPoints > 0) {
1033 auto remainingPointsContribution = mapFunction(numVectors);
1035 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
1036 for (
unsigned int param = 0; param < npar; param++) {
1037 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1041 for (
unsigned int param = 0; param < npar; param++) {
1042 grad[param] = vecCore::ReduceAdd(gVec[param]);
1046 nPoints = initialNPoints;
1048 if (std::any_of(validPointsMasks.begin(), validPointsMasks.end(),
1049 [](vecCore::Mask<T> validPoints) { return !vecCore::MaskFull(validPoints); })) {
1050 unsigned nRejected = 0;
1052 for (
const auto &mask : validPointsMasks) {
1053 for (
unsigned int i = 0; i < vecSize; i++) {
1054 nRejected += !vecCore::Get(mask, i);
1058 assert(nRejected <= initialNPoints);
1059 nPoints = initialNPoints - nRejected;
1061 if (nPoints < npar) {
1063 "Too many points rejected for overflow in gradient calculation");
1070 Error(
"FitUtil::Evaluate<T>::EvalChi2Residual",
"The vectorized evaluation of the Chi2 with the ith residual is still not supported");
1077 Error(
"FitUtil::Evaluate<T>::EvaluatePoissonBinPdf",
"The vectorized evaluation of the BinnedLikelihood fit evaluated point by point is still not supported");
1085 unsigned nChunks = 0)
1090 assert(fg !=
nullptr);
1099 Error(
"FitUtil::EvaluatePoissonLogLGradient",
"The vectorized implementation doesn't support Integrals,"
1100 "BinVolume or ExpErrors\n. Aborting operation.");
1102 unsigned int npar = func.
NPar();
1103 auto vecSize = vecCore::VectorSize<T>();
1104 unsigned initialNPoints = data.
Size();
1105 unsigned numVectors = initialNPoints / vecSize;
1107 auto mapFunction = [&](
const unsigned int i) {
1109 std::vector<T> gradFunc(npar);
1110 std::vector<T> pointContributionVec(npar);
1115 vecCore::Load<T>(
y, data.
ValuePtr(i * vecSize));
1119 const T *
x =
nullptr;
1121 unsigned ndim = data.
NDim();
1126 for (
unsigned int j = 1; j < ndim; ++j)
1137 for (
unsigned int ipar = 0; ipar < npar; ++ipar) {
1138 vecCore::Mask<T> positiveValuesMask = fval > 0;
1141 vecCore::MaskedAssign(pointContributionVec[ipar], positiveValuesMask, gradFunc[ipar] * (1. -
y / fval));
1143 vecCore::Mask<T> validNegativeValuesMask = !positiveValuesMask && gradFunc[ipar] != 0;
1145 if (!vecCore::MaskEmpty(validNegativeValuesMask)) {
1148 T gg = kdmax1 * gradFunc[ipar];
1156 if (i < 5 || (i > data.
Size()-5) ) {
1157 if (data.
NDim() > 1) std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1];
1158 else std::cout << i <<
" x " <<
x[0];
1159 std::cout <<
" func " << fval <<
" gradient ";
1160 for (
unsigned int ii = 0; ii < npar; ++ii) std::cout <<
" " << pointContributionVec[ii];
1166 return pointContributionVec;
1170 auto redFunction = [&](
const std::vector<std::vector<T>> &partialResults) {
1171 std::vector<T> result(npar);
1173 for (
auto const &pointContributionVec : partialResults) {
1174 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
1175 result[parameterIndex] += pointContributionVec[parameterIndex];
1181 std::vector<T> gVec(npar);
1189 Warning(
"FitUtil::EvaluatePoissonLogLGradient",
1190 "Multithread execution policy requires IMT, which is disabled. Changing "
1191 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1208 Error(
"FitUtil::EvaluatePoissonLogLGradient",
"Execution policy unknown. Avalaible choices:\n "
1209 "ROOT::Fit::ExecutionPolicy::kSerial (default)\n "
1210 "ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
1215 unsigned int remainingPoints = initialNPoints % vecSize;
1216 if (remainingPoints > 0) {
1217 auto remainingPointsContribution = mapFunction(numVectors);
1219 auto remainingMask = vecCore::Int2Mask<T>(remainingPoints);
1220 for (
unsigned int param = 0; param < npar; param++) {
1221 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1225 for (
unsigned int param = 0; param < npar; param++) {
1226 grad[param] = vecCore::ReduceAdd(gVec[param]);
1230 std::cout <<
"***** Final gradient : ";
1231 for (
unsigned int ii = 0; ii< npar; ++ii) std::cout << grad[ii] <<
" ";
1238 double *grad,
unsigned int &,
1240 unsigned nChunks = 0)
1245 assert(fg !=
nullptr);
1250 unsigned int npar = func.
NPar();
1251 auto vecSize = vecCore::VectorSize<T>();
1252 unsigned initialNPoints = data.
Size();
1253 unsigned numVectors = initialNPoints / vecSize;
1256 std::cout <<
"\n===> Evaluate Gradient for parameters ";
1257 for (
unsigned int ip = 0; ip < npar; ++ip)
1258 std::cout <<
" " << p[ip];
1267 auto mapFunction = [&](
const unsigned int i) {
1268 std::vector<T> gradFunc(npar);
1269 std::vector<T> pointContributionVec(npar);
1274 const T *
x =
nullptr;
1276 unsigned int ndim = data.
NDim();
1277 std::vector<T> xc(ndim);
1281 for (
unsigned int j = 1; j < ndim; ++j)
1289 T fval = func(
x, p);
1293 if (i < 5 || (i > numVectors-5) ) {
1294 if (ndim > 1) std::cout << i <<
" x " <<
x[0] <<
" y " <<
x[1] <<
" gradient " << gradFunc[0] <<
" " << gradFunc[1] <<
" " << gradFunc[3] << std::endl;
1295 else std::cout << i <<
" x " <<
x[0] <<
" gradient " << gradFunc[0] <<
" " << gradFunc[1] <<
" " << gradFunc[3] << std::endl;
1299 vecCore::Mask<T> positiveValues = fval > 0;
1301 for (
unsigned int kpar = 0; kpar < npar; ++kpar) {
1302 if (!vecCore::MaskEmpty(positiveValues))
1303 vecCore::MaskedAssign<T>(pointContributionVec[kpar], positiveValues, -1. / fval * gradFunc[kpar]);
1305 vecCore::Mask<T> nonZeroGradientValues = !positiveValues && gradFunc[kpar] != 0;
1306 if (!vecCore::MaskEmpty(nonZeroGradientValues)) {
1307 T gg = kdmax1 * gradFunc[kpar];
1308 pointContributionVec[kpar] =
1315 return pointContributionVec;
1319 auto redFunction = [&](
const std::vector<std::vector<T>> &pointContributions) {
1320 std::vector<T> result(npar);
1322 for (
auto const &pointContributionVec : pointContributions) {
1323 for (
unsigned int parameterIndex = 0; parameterIndex < npar; parameterIndex++)
1324 result[parameterIndex] += pointContributionVec[parameterIndex];
1330 std::vector<T> gVec(npar);
1331 std::vector<double>
g(npar);
1339 Warning(
"FitUtil::EvaluateLogLGradient",
1340 "Multithread execution policy requires IMT, which is disabled. Changing "
1341 "to ROOT::Fit::ExecutionPolicy::kSerial.");
1358 Error(
"FitUtil::EvaluateLogLGradient",
"Execution policy unknown. Avalaible choices:\n "
1359 "ROOT::Fit::ExecutionPolicy::kSerial (default)\n "
1360 "ROOT::Fit::ExecutionPolicy::kMultithread (requires IMT)\n");
1364 unsigned int remainingPoints = initialNPoints % vecSize;
1365 if (remainingPoints > 0) {
1366 auto remainingPointsContribution = mapFunction(numVectors);
1368 auto remainingMask = vecCore::Int2Mask<T>(initialNPoints % vecSize);
1369 for (
unsigned int param = 0; param < npar; param++) {
1370 vecCore::MaskedAssign(gVec[param], remainingMask, gVec[param] + remainingPointsContribution[param]);
1374 for (
unsigned int param = 0; param < npar; param++) {
1375 grad[param] = vecCore::ReduceAdd(gVec[param]);
1379 std::cout <<
"Final gradient ";
1380 for (
unsigned int param = 0; param < npar; param++) {
1381 std::cout <<
" " << grad[param];
1407 int iWeight,
bool extended,
unsigned int &nPoints,
1414 int iWeight,
bool extended,
unsigned int &nPoints,
1425 double *
g,
unsigned int &nPoints,
1427 unsigned nChunks = 0)
1444 unsigned int &nPoints,
1446 unsigned nChunks = 0)
1452 double *
g,
unsigned int &nPoints,
1454 unsigned nChunks = 0)
1466#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)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
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)