24#include "RConfigure.h"
61 for (
int i = 0; i < npar; ++i) {
73 if (&rhs ==
this)
return *
this;
116 template <
typename... Args>
128 template <
typename... Args>
145template <
typename... Args>
149 for (
double val : {arg1,
static_cast<Double_t>(args)...}) {
156template <
typename... Args>
160 for (
auto name : {
static_cast<std::string const&
>(args)...}) {
255 TString &formula,
int termStart,
int termEnd,
347 template <
typename Func>
363 template <
class PtrObj,
typename MemFn>
492 else std::copy(
fParams->ParamsVec().begin(),
fParams->ParamsVec().end(), params);
586 template <
class PtrObj,
typename MemFn>
588 template <
typename Func>
635 if (
fFormula)
fFormula->SetParameters(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
636 else fParams->SetParameters(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
640 virtual void SetParNames(
const char *name0 =
"",
const char *name1 =
"",
const char *name2 =
"",
641 const char *name3 =
"",
const char *name4 =
"",
const char *name5 =
"",
642 const char *name6 =
"",
const char *name7 =
"",
const char *name8 =
"",
643 const char *name9 =
"",
const char *name10 =
"");
659 fFormula->SetVectorized(vectorized);
661 Warning(
"SetVectorized",
"Can only set vectorized flag on formula-based TF1");
676 return Moment(1,
a,
b, params, epsilon);
704#ifdef R__HAS_STD_EXPERIMENTAL_SIMD
705 if constexpr(std::is_invocable_r_v<Double_v, Func, Double_v*, double *>) {
715 f->fParams = std::make_unique<TF1Parameters>(
f->fNpar);
722#ifdef R__HAS_STD_EXPERIMENTAL_SIMD
723 if constexpr(std::is_invocable_r_v<Double_v, Func, Double_v*, double *>) {
733 f->fParams = std::make_unique<TF1Parameters>(
f->fNpar);
743 f->fFormula = std::make_unique<TFormula>(
"tf1lambda", formula,
f->fNdim,
f->fNpar,
false);
744 TString formulaExpression(formula);
745 Ssiz_t first = formulaExpression.
Index(
"return") + 7;
747 TString title = formulaExpression(first, last - first);
755 for (
size_t i = 0; i < rows; i++) {
822template <
typename Func>
829template <
class PtrObj,
typename MemFn>
852 if (eps < 1e-10 || eps > 1) {
853 Warning(
"Derivative",
"parameter esp=%g out of allowed range[1e-10,1], reset to 0.01", eps);
861 std::vector<Double_t> parametersCopy(parameters, parameters +
GetNpar());
862 parameters = parametersCopy.data();
865 T
f1, f2, g1, g2, d0, d2;
867 ((
TF1 *)
this)->GetParLimits(ipar, al, bl);
868 if (al * bl != 0 && al >= bl) {
882 parameters[ipar] = par0 +
h;
884 parameters[ipar] = par0 -
h;
886 parameters[ipar] = par0 +
h / 2;
888 parameters[ipar] = par0 -
h / 2;
896 T grad = h2 * (4 * d2 - d0) / 3.;
899 parameters[ipar] = par0;
916 if (eps < 1e-10 || eps > 1) {
917 Warning(
"Derivative",
"parameter esp=%g out of allowed range[1e-10,1], reset to 0.01", eps);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
int Ssiz_t
String size (currently int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
#define ClassDef(name, id)
#define ClassDefOverride(name, id)
TMatrixTSym< Double_t > TMatrixDSym
class containing the result of the fit and all the related information (fitted parameter values,...
Param Functor class for Multidimensional functions.
Class to manage histogram axis.
Using a TBrowser one can browse all ROOT objects.
std::vector< Double_t > fParameters
const char * GetParName(Int_t iparam) const
const std::vector< double > & ParamsVec() const
Double_t GetParameter(const char *name) const
Double_t GetParameter(Int_t iparam) const
void SetParName(Int_t iparam, const char *name)
TF1Parameters & operator=(const TF1Parameters &rhs)
void SetParameter(Int_t iparam, Double_t value)
void SetParameter(const char *name, Double_t value)
TF1Parameters(Int_t npar)
std::vector< std::string > fParNames
bool CheckIndex(Int_t i) const
void SetParNames(Args &&... args)
Set parameter names.
void SetParameters(const Double_t *params)
Int_t GetParNumber(const char *name) const
TF1Parameters(const TF1Parameters &rhs)
const Double_t * GetParameters() const
virtual void SetParNames(const char *name0="", const char *name1="", const char *name2="", const char *name3="", const char *name4="", const char *name5="", const char *name6="", const char *name7="", const char *name8="", const char *name9="", const char *name10="")
std::unique_ptr< TF1FunctorPointer > fFunctor
! Functor object to wrap any C++ callable object
virtual Double_t GetXmax() const
static void RejectPoint(Bool_t reject=kTRUE)
EAddToList
Add to list behavior.
virtual Double_t Mean(Double_t a, Double_t b, const Double_t *params=nullptr, Double_t epsilon=0.000001)
T GradientParTempl(Int_t ipar, const T *x, Double_t eps=0.01) const
virtual Double_t Derivative2(Double_t x, Double_t *params=nullptr, Double_t epsilon=0.001) const
virtual const Double_t * GetParErrors() const
virtual Int_t GetNumber() const
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
std::vector< Double_t > fParErrors
Array of errors of the fNpar parameters.
Int_t fNdim
Function dimension.
virtual Double_t GetMinMaxNDim(Double_t *x, Bool_t findmax, Double_t epsilon=0, Int_t maxiter=0) const
virtual void SetNDF(Int_t ndf)
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
virtual const TFormula * GetFormula() const
virtual Double_t GetMaximumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetProb() const
Int_t fNpar
Number of parameters.
virtual void GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const
virtual Double_t IntegralFast(Int_t num, Double_t *x, Double_t *w, Double_t a, Double_t b, Double_t *params=nullptr, Double_t epsilon=1e-12)
virtual Double_t GetParameter(const TString &name) const
virtual void GetParameters(Double_t *params)
static std::atomic< Bool_t > fgAddToGlobList
static void SetCurrent(TF1 *f1)
virtual Bool_t IsEvalNormalized() const
virtual void SetParError(Int_t ipar, Double_t error)
virtual Double_t GetVariable(const TString &name)
virtual Double_t GetRandom(Double_t xmin, Double_t xmax, TRandom *rng=nullptr, Option_t *opt=nullptr)
virtual void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax)
virtual void SetChisquare(Double_t chi2)
TF1(const char *name, Double_t(*fcn)(const Double_t *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Int_t npar=0, Int_t ndim=1, EAddToList addToGlobList=EAddToList::kDefault)
Double_t fNormIntegral
Integral of the function before being normalized.
virtual Double_t GetX(Double_t y, Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t IntegralError(Int_t n, const Double_t *a, const Double_t *b, const Double_t *params=nullptr, const Double_t *covmat=nullptr, Double_t epsilon=1.E-2)
static Bool_t RejectedPoint()
virtual Double_t Derivative(Double_t x, Double_t *params=nullptr, Double_t epsilon=0.001) const
Double_t GetChisquare() const
Return the Chisquare after fitting. See ROOT::Fit::FitResult::Chi2().
void Print(Option_t *option="") const override
This method must be overridden when a class wants to print itself.
virtual TH1 * CreateHistogram()
Double_t fXmin
Lower bounds for the range.
std::unique_ptr< TMethodCall > fMethodCall
! Pointer to MethodCall in case of interpreted function
TF1(const char *name, const char *formula, Double_t xmin, Double_t xmax, Option_t *option)
void IntegrateForNormalization()
TF1(const char *name, std::function< T(const T *data, const Double_t *param)> &fcn, Double_t xmin=0, Double_t xmax=1, Int_t npar=0, Int_t ndim=1, EAddToList addToGlobList=EAddToList::kDefault)
virtual void GradientPar(const Double_t *x, Double_t *grad, Double_t eps=0.01) const
virtual void InitArgs(const Double_t *x, const Double_t *params)
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
virtual Double_t GetMaximumStored() const
virtual Int_t GetNpar() const
virtual TString GetExpFormula(Option_t *option="") const
std::vector< Double_t > fBeta
! Array beta. is approximated by x = alpha +beta*r *gamma*r**2
virtual void GetRange(Double_t &xmin, Double_t &xmax) const
virtual void SetNpx(Int_t npx=100)
virtual Double_t GetMinimum(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
Double_t EvalUncertainty(Double_t x, const TMatrixDSym *covMatrix=nullptr) const
TString ProvideSaveName(Option_t *option)
virtual Double_t GetRandom(TRandom *rng=nullptr, Option_t *opt=nullptr)
Int_t fNDF
Number of degrees of freedom in the fit.
TH1 * fHistogram
! Pointer to histogram used for visualisation
virtual Double_t IntegralMultiple(Int_t n, const Double_t *a, const Double_t *b, Int_t, Int_t maxpts, Double_t epsrel, Double_t &relerr, Int_t &nfnevl, Int_t &ifail)
std::unique_ptr< TF1AbsComposition > fComposition
Pointer to composition (NSUM or CONV).
TObject * GetParent() const
Int_t fNpfits
Number of points used in the fit.
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
void SetFunction(PtrObj &p, MemFn memFn)
virtual void SetParent(TObject *p=nullptr)
std::vector< Double_t > fAlpha
! Array alpha. for each bin in x the deconvolution r of fIntegral
void SetTitle(const char *title="") override
Set the title of the TNamed.
virtual Int_t GetNumberFitPoints() const
std::unique_ptr< TFormula > fFormula
Pointer to TFormula in case when user define formula.
virtual Int_t GetNumberFreeParameters() const
std::vector< Double_t > fParMin
Array of lower limits of the fNpar parameters.
virtual Double_t GetMinimumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
Double_t fMaximum
Maximum value for plotting.
virtual Double_t * GetParameters() const
Double_t fMinimum
Minimum value for plotting.
int TermCoeffLength(TString &term)
static Bool_t fgRejectPoint
void Copy(TObject &f1) const override
Copy this to obj.
virtual Int_t GetQuantiles(Int_t n, Double_t *xp, const Double_t *p)
static void AbsValue(Bool_t reject=kTRUE)
virtual Double_t Derivative3(Double_t x, Double_t *params=nullptr, Double_t epsilon=0.001) const
virtual void DrawF1(Double_t xmin, Double_t xmax, Option_t *option="")
virtual Double_t CentralMoment(Double_t n, Double_t a, Double_t b, const Double_t *params=nullptr, Double_t epsilon=0.000001)
virtual void SetNumberFitPoints(Int_t npfits)
double EvalParVec(const Double_t *data, const Double_t *params)
virtual Double_t GetMinimumStored() const
virtual void SetNormalized(Bool_t flag)
void Paint(Option_t *option="") override
This method must be overridden if a class wants to paint itself.
virtual Double_t IntegralMultiple(Int_t n, const Double_t *a, const Double_t *b, Double_t epsrel, Double_t &relerr)
TF1 & operator=(const TF1 &rhs)
TF1(const char *name, const PtrObj &p, MemFn memFn, Double_t xmin, Double_t xmax, Int_t npar, Int_t ndim=1, EAddToList addToGlobList=EAddToList::kDefault)
Template constructors from a pointer to any C++ class of type PtrObj with a specific member function ...
Double_t fChisquare
Function fit chisquare.
virtual Double_t GradientPar(Int_t ipar, const Double_t *x, Double_t eps=0.01) const
TF1(const char *name, const char *formula, Double_t xmin=0, Double_t xmax=1, EAddToList addToGlobList=EAddToList::kDefault, bool vectorize=false)
virtual TFormula * GetFormula()
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
TMethodCall * GetMethodCall() const
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
virtual Double_t operator()(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
virtual void SetRange(Double_t xmin, Double_t xmax)
Bool_t fNormalized
Normalization option (false by default).
void Draw(Option_t *option="") override
Default Draw method for all objects.
virtual Bool_t IsValid() const
virtual Double_t Variance(Double_t a, Double_t b, const Double_t *params=nullptr, Double_t epsilon=0.000001)
virtual Double_t GetParError(Int_t ipar) const
virtual Double_t IntegralOneDim(Double_t a, Double_t b, Double_t epsrel, Double_t epsabs, Double_t &err)
virtual TObject * DrawIntegral(Option_t *option="al")
TF1(const char *name, Double_t xmin, Double_t xmax, Int_t npar, Int_t ndim=1, EAddToList addToGlobList=EAddToList::kDefault)
virtual void AddParameter(const TString &name, Double_t value)
void Browse(TBrowser *b) override
Browse object. May be overridden for another default action.
virtual void SetMaximum(Double_t maximum=-1111)
virtual Double_t IntegralError(Double_t a, Double_t b, const Double_t *params=nullptr, const Double_t *covmat=nullptr, Double_t epsilon=1.E-2)
virtual const char * GetParName(Int_t ipar) const
static TF1 * GetCurrent()
TF1(EFType functionType, const char *name, Double_t xmin, Double_t xmax, Int_t npar, Int_t ndim, EAddToList addToGlobList, TF1Parameters *params=nullptr, TF1FunctorPointer *functor=nullptr)
General constructor for TF1. Most of the other constructors delegate on it.
Int_t fNpx
Number of points used for the graphical representation.
TF1(const char *name, Double_t(*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Int_t npar=0, Int_t ndim=1, EAddToList addToGlobList=EAddToList::kDefault)
void DoInitialize(EAddToList addToGlobList)
char * GetObjectInfo(Int_t px, Int_t py) const override
Returns string containing info about the object at position (px,py).
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to an event at (px,py).
static std::atomic< Bool_t > fgAbsValue
virtual Double_t GetMaximum(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Bool_t IsLinear() const
virtual void SetParameters(double p0, double p1=TMath::QuietNaN(), double p2=TMath::QuietNaN(), double p3=TMath::QuietNaN(), double p4=TMath::QuietNaN(), double p5=TMath::QuietNaN(), double p6=TMath::QuietNaN(), double p7=TMath::QuietNaN(), double p8=TMath::QuietNaN(), double p9=TMath::QuietNaN(), double p10=TMath::QuietNaN())
Set parameter values.
virtual void ReleaseParameter(Int_t ipar)
std::vector< Double_t > fParMax
Array of upper limits of the fNpar parameters.
virtual Int_t GetNDF() const
virtual void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
static Double_t DerivativeError()
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
TF1(const char *name, ROOT::Math::ParamFunctor f, Double_t xmin=0, Double_t xmax=1, Int_t npar=0, Int_t ndim=1, EAddToList addToGlobList=EAddToList::kDefault)
std::vector< Double_t > fSave
Array of fNsave function values.
virtual Double_t IntegralMultiple(Int_t n, const Double_t *a, const Double_t *b, Int_t maxpts, Double_t epsrel, Double_t epsabs, Double_t &relerr, Int_t &nfnevl, Int_t &ifail)
virtual Double_t GetParError(const char *name) const
void DefineNSUMTerm(TObjArray *newFuncs, TObjArray *coeffNames, TString &fullFormula, TString &formula, int termStart, int termEnd, Double_t xmin, Double_t xmax)
std::vector< Double_t > fGamma
! Array gamma.
virtual TH1 * GetHistogram() const
static Bool_t DefaultAddToGlobalList(Bool_t on=kTRUE)
TObject * fParent
! Parent object hooking this function (if one)
Bool_t ComputeCdfTable(Option_t *opt)
virtual void SetParameters(const Double_t *params)
T EvalParTempl(const T *data, const Double_t *params=nullptr)
Eval for vectorized functions.
static void InitStandardFunctions()
virtual Double_t GetSave(const Double_t *x)
std::vector< Double_t > fIntegral
! Integral of function binned on fNpx bins
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=nullptr)
virtual TF1 * DrawCopy(Option_t *option="") const
virtual void SetMinimum(Double_t minimum=-1111)
virtual Double_t Moment(Double_t n, Double_t a, Double_t b, const Double_t *params=nullptr, Double_t epsilon=0.000001)
virtual void SetFitResult(const ROOT::Fit::FitResult &result, const Int_t *indpar=nullptr)
virtual void FixParameter(Int_t ipar, Double_t value)
std::unique_ptr< TF1Parameters > fParams
Pointer to Function parameters object (exists only for not-formula functions).
virtual void SetParameter(const TString &name, Double_t value)
virtual void SetParameter(Int_t param, Double_t value)
virtual void SetParName(Int_t ipar, const char *name)
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
@ kFormula
Formula functions which can be stored,.
@ kPtrScalarFreeFcn
Pointer to scalar free function,.
@ kTemplScalar
TemplScalar functors evaluating on scalar parameters.
@ kTemplVec
Vectorized free functions or TemplScalar functors evaluating on vectorized parameters,...
@ kInterpreted
Interpreted functions constructed by name,.
virtual void SetParErrors(const Double_t *errors)
virtual Bool_t IsInside(const Double_t *x) const
return kTRUE if the point is inside the function range
virtual TObject * DrawDerivative(Option_t *option="al")
virtual Int_t GetNpx() const
Double_t fXmax
Upper bounds for the range.
virtual Int_t GetNdim() const
virtual Double_t GetXmin() const
virtual TH1 * DoCreateHistogram(Double_t xmin, Double_t xmax, Bool_t recreate=kFALSE)
virtual const TObject * GetLinearPart(Int_t i) const
virtual void SetVectorized(Bool_t vectorized)
TF1(const char *name, Func f, Double_t xmin, Double_t xmax, Int_t npar, Int_t ndim=1, EAddToList addToGlobList=EAddToList::kDefault)
Template constructors from any C++ callable object, defining the operator() (double * ,...
virtual Double_t GetParameter(Int_t ipar) const
virtual Int_t GetParNumber(const char *name) const
TF1(const char *name, T(*fcn)(const T *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Int_t npar=0, Int_t ndim=1, EAddToList addToGlobList=EAddToList::kDefault)
Constructor using a pointer to function.
static void CalcGaussLegendreSamplingPoints(Int_t num, Double_t *x, Double_t *w, Double_t eps=3.0e-11)
Bool_t HasSave() const
Return true if function has data in fSave buffer.
virtual void SetSavedPoint(Int_t point, Double_t value)
virtual Bool_t AddToGlobalList(Bool_t on=kTRUE)
TH1 is the base class of all histogram classes in ROOT.
Method or function calling interface.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
TObject()
TObject constructor.
This is the base class for the ROOT Random number generators.
Ssiz_t Last(char c) const
Find last occurrence of a character c.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Namespace for new Math classes and functions.
Namespace for the fitting classes.
void EvalParMultiDim(TF1 *func, Double_t *out, const Double_t *x, std::size_t size, std::size_t rows, Double_t *params)
ParamFunctorTempl< double > ParamFunctor
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Double_t SignalingNaN()
Returns a signaling NaN as defined by IEEE 754](http://en.wikipedia.org/wiki/NaN#Signaling_NaN).
static void Build(TF1 *f, Func *func)
static void Build(TF1 *f, const char *formula)
Internal class used by TF1 for defining template specialization for different TF1 constructors
static void Build(TF1 *f, Func func)
TF1FunctorPointer * Clone() const override
ROOT::Math::ParamFunctorTempl< T > fImpl
TF1FunctorPointerImpl(const std::function< T(const T *f, const Double_t *param)> &func)
~TF1FunctorPointerImpl() override
TF1FunctorPointerImpl(const ROOT::Math::ParamFunctorTempl< T > &func)
virtual ~TF1FunctorPointer()
virtual TF1FunctorPointer * Clone() const =0