13#ifndef ROOT_Fit_FitUtil
14#define ROOT_Fit_FitUtil
109 template <
class ParamFunc = ROOT::Math::IParamMultiFunctionTempl<
double>>
122 void SetFunction(
const ParamFunc &func,
const double *p =
nullptr,
132 assert(
fFunc !=
nullptr);
142 }
else if (
fDim > 1) {
180 double Integral(
const double *x1,
const double *x2)
190 double dV = *x2 - *x1;
191 return fIg1Dim->Integral(*x1, *x2) / dV;
194 for (
unsigned int i = 0; i <
fDim; ++i)
195 dV *= (x2[i] - x1[i]);
196 return fIgNDim->Integral(x1, x2) / dV;
206 inline double ExecFunc(T *
f,
const double *
x,
const double *p)
const
211#ifdef R__HAS_STD_EXPERIMENTAL_SIMD
213#if __clang_major__ > 16
214#pragma clang diagnostic push
215#pragma clang diagnostic ignored "-Wvla-cxx-extension"
220 ROOT::Double_v xx[
fDim];
221 for (
unsigned int i = 0; i <
fDim; ++i) {
223 for (std::size_t j = 1; j < ROOT::Double_v::size(); ++j) {
227 auto res = (*f)(xx, p);
231#if __clang_major__ > 16
232#pragma clang diagnostic pop
273 unsigned int &nPoints,
275 unsigned nChunks = 0);
289 unsigned int &nPoints,
291 unsigned nChunks = 0);
306 unsigned nChunks = 0);
313 unsigned int &nPoints,
315 unsigned nChunks = 0);
326 double *
g =
nullptr,
double *
h =
nullptr,
bool hasGrad =
false,
bool fullHessian =
false);
335 EvaluatePdf(
const IModelFunction &func,
const UnBinData &data,
const double *p,
unsigned int ipoint,
double *
g =
nullptr,
double *
h =
nullptr,
bool hasGrad =
false,
bool fullHessian =
false);
351#ifdef R__HAS_STD_EXPERIMENTAL_SIMD
358 int iWeight,
bool extended,
unsigned int &nPoints,
363 unsigned nChunks = 0);
368 Error(
"FitUtil::Evaluate<T>::EvalChi2Effective",
"The vectorized evaluation of the Chi2 with coordinate errors is still not supported");
373 double *grad,
unsigned int &nPoints,
375 unsigned nChunks = 0);
378 unsigned int,
double *,
double *,
bool,
bool)
380 Error(
"FitUtil::Evaluate<T>::EvalChi2Residual",
"The vectorized evaluation of the Chi2 with the ith residual is still not supported");
387 unsigned int,
double *,
double *,
bool,
bool)
389 Error(
"FitUtil::Evaluate<T>::EvaluatePoissonBinPdf",
"The vectorized evaluation of the BinnedLikelihood fit evaluated point by point is still not supported");
394 double *,
double *,
bool,
bool)
396 Error(
"FitUtil::Evaluate<T>::EvalPdf",
"The vectorized evaluation of the LogLikelihood fit evaluated point by point is still not supported");
402 double *grad,
unsigned int &,
404 unsigned nChunks = 0);
407 double *grad,
unsigned int &,
409 unsigned nChunks = 0);
431 int iWeight,
bool extended,
unsigned int &nPoints,
438 int iWeight,
bool extended,
unsigned int &nPoints,
449 double *
g,
unsigned int &nPoints,
451 unsigned nChunks = 0)
457 bool hasGrad,
bool fullHessian)
474 unsigned int &nPoints,
476 unsigned nChunks = 0)
482 double *
g,
unsigned int &nPoints,
484 unsigned nChunks = 0)
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
double Integral(const double *x1, const double *x2)
ROOT::Math::IGenFunction * fFunc1Dim
ROOT::Math::IntegratorMultiDim * fIgNDim
void SetFunction(const ParamFunc &func, const double *p=nullptr, ROOT::Math::IntegrationOneDim::Type igType=ROOT::Math::IntegrationOneDim::kDEFAULT)
IntegralEvaluator(const IntegralEvaluator &rhs)=delete
IntegralEvaluator(const ParamFunc &func, const double *p, bool useIntegral=true, ROOT::Math::IntegrationOneDim::Type igType=ROOT::Math::IntegrationOneDim::kDEFAULT)
IntegralEvaluator & operator=(const IntegralEvaluator &rhs)=delete
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 un-binned data sets (just x coordinates values) of any dimensions.
User class for performing multidimensional integration.
User Class for performing numerical integration of a function in one dimension.
Template class to wrap any member function of a class taking a double and returning a double in a 1D ...
Type
enumeration specifying the integration types.
@ kDEFAULT
default type specified in the static options
namespace defining utility free functions using in Fit for evaluating the various fit method function...
ROOT::Math::IParamMultiGradFunction IGradModelFunction
ROOT::Math::IParamMultiFunction IModelFunction
double EvaluatePoissonBinPdf(const IModelFunction &func, const BinData &data, const double *x, unsigned int ipoint, double *g=nullptr, double *h=nullptr, bool hasGrad=false, bool fullHessian=false)
evaluate the pdf contribution to the Poisson LogL given a model function and the BinPoint data.
ROOT::Math::IParamMultiFunctionTempl< T > IModelFunctionTempl
void EvaluatePoissonLogLGradient(const IModelFunction &func, const BinData &data, const double *p, double *grad, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy=::ROOT::EExecutionPolicy::kSequential, unsigned nChunks=0)
evaluate the Poisson LogL given a model function and the data at the point p.
double EvaluateChi2Residual(const IModelFunction &func, const BinData &data, const double *p, unsigned int ipoint, double *g=nullptr, double *h=nullptr, bool hasGrad=false, bool fullHessian=false)
evaluate the residual contribution to the Chi2 given a model function and the BinPoint data and if th...
double EvaluatePoissonLogL(const IModelFunction &func, const BinData &data, const double *p, int iWeight, bool extended, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy, unsigned nChunks=0)
evaluate the Poisson LogL given a model function and the data at the point p.
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.
void EvaluateLogLGradient(const IModelFunction &func, const UnBinData &data, const double *p, double *grad, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy=::ROOT::EExecutionPolicy::kSequential, unsigned nChunks=0)
evaluate the LogL gradient given a model function and the data at the point p.
double EvaluatePdf(const IModelFunction &func, const UnBinData &data, const double *p, unsigned int ipoint, double *g=nullptr, double *h=nullptr, bool hasGrad=false, bool fullHessian=false)
evaluate the pdf contribution to the LogL given a model function and the BinPoint data.
ROOT::Math::IParamMultiGradFunctionTempl< T > IGradModelFunctionTempl
unsigned setAutomaticChunking(unsigned nEvents)
double EvaluateLogL(const IModelFunction &func, const UnBinData &data, const double *p, int iWeight, bool extended, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy, unsigned nChunks=0)
evaluate the LogL given a model function and the data at the point x.
double EvaluateChi2(const IModelFunction &func, const BinData &data, const double *p, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy, unsigned nChunks=0)
Chi2 Functions.
void EvaluateChi2Gradient(const IModelFunction &func, const BinData &data, const double *p, double *grad, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy=::ROOT::EExecutionPolicy::kSequential, unsigned nChunks=0)
evaluate the Chi2 gradient given a model function and the data at the point p.
IMultiGenFunctionTempl< double > IMultiGenFunction
IParametricFunctionMultiDim IParamMultiFunction
IParametricGradFunctionMultiDimTempl< T > IParamMultiGradFunctionTempl
IParametricFunctionMultiDimTempl< T > IParamMultiFunctionTempl
IParametricGradFunctionMultiDim IParamMultiGradFunction
IBaseFunctionOneDim IGenFunction
static double EvalLogL(const IModelFunctionTempl< double > &func, const UnBinData &data, const double *p, int iWeight, bool extended, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy, unsigned nChunks=0)
static double EvalChi2(const IModelFunction &func, const BinData &data, const double *p, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy, unsigned nChunks=0)
static double EvalPoissonBinPdf(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, unsigned int i, double *g, double *h, bool hasGrad, bool fullHessian)
evaluate the pdf (Poisson) contribution to the logl (return actually log of pdf) and its gradient
static double EvalChi2Residual(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, unsigned int i, double *g, double *h, bool hasGrad, bool fullHessian)
static double EvalPdf(const IModelFunctionTempl< double > &func, const UnBinData &data, const double *p, unsigned int i, double *g, double *h, bool hasGrad, bool fullHessian)
static double EvalPoissonLogL(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, int iWeight, bool extended, unsigned int &nPoints, ::ROOT::EExecutionPolicy 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::EExecutionPolicy executionPolicy=::ROOT::EExecutionPolicy::kSequential, unsigned nChunks=0)
static void EvalLogLGradient(const IModelFunctionTempl< double > &func, const UnBinData &data, const double *p, double *g, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy=::ROOT::EExecutionPolicy::kSequential, unsigned nChunks=0)
static void EvalPoissonLogLGradient(const IModelFunctionTempl< double > &func, const BinData &data, const double *p, double *g, unsigned int &nPoints, ::ROOT::EExecutionPolicy executionPolicy=::ROOT::EExecutionPolicy::kSequential, unsigned nChunks=0)