115 Error(
"TF2",
"function: %s/%s has dimension %d instead of 2",
name,formula,
GetNdim());
188 rhs.TF2::Copy(*
this);
232 if (distance <= 1)
return distance;
239 if (
gPad->GetView() || strncmp(drawOption,
"cont",4) == 0
240 || strncmp(drawOption,
"CONT",4) == 0) {
241 uxmin=
gPad->GetUxmin();
242 uxmax=
gPad->GetUxmax();
244 uymin=
gPad->GetUymin();
245 uymax=
gPad->GetUymax();
248 if (x < fXmin || x >
fXmax)
return distance;
249 if (y < fYmin || y >
fYmax)
return distance;
340 if (level <0 || level >=
fContour.
fN)
return 0;
368 Double_t rsign = (findmax) ? -1. : 1.;
370 Double_t xxmin = 0, yymin = 0, zzmin = 0;
378 xx[0]=
fXmin + (i+0.5)*dx;
380 xx[1]=
fYmin+(j+0.5)*dy;
382 if (rsign*zz < rsign*zzmin) {xxmin = xx[0], yymin = xx[1]; zzmin = zz;}
398 if (rsign*fmin < rsign*zzmin) {
399 if (
x) {
x[0] = xx[0];
x[1] = xx[1]; }
403 if (
x) {
x[0] = xxmin;
x[1] = yymin; }
427 double xx[2] = { 0,0 };
430 x = xx[0];
y = xx[1];
442 double xx[2] = { 0,0 };
445 x = xx[0];
y = xx[1];
488 const char *snull =
"";
489 if (!
gPad)
return (
char*)snull;
490 static char info[64];
496 if (
gPad->GetView() || strncmp(drawOption,
"cont",4) == 0
497 || strncmp(drawOption,
"CONT",4) == 0) {
498 uxmin=
gPad->GetUxmin();
499 uxmax=
gPad->GetUxmax();
501 uymin=
gPad->GetUymin();
502 uymax=
gPad->GetUymax();
514 Error(
"GetRandom",
"cannot be called for TF2/3, use GetRandom2/3 instead");
524 Error(
"GetRandom",
"cannot be called for TF2/3, use GetRandom2/3 instead");
558 Int_t intNegative = 0;
560 for (j=0;j<
fNpy;j++) {
561 for (i=0;i<
fNpx;i++) {
563 if (integ < 0) {intNegative++; integ = -integ;}
568 if (intNegative > 0) {
569 Warning(
"GetRandom2",
"function:%s has %d negative values: abs assumed",
GetName(),intNegative);
572 Error(
"GetRandom2",
"Integral of function is zero");
575 for (i=1;i<=ncells;i++) {
586 if (dxint > 0) ddx = dx*(
r -
fIntegral[cell])/dxint;
588 ddy = dy*rng->
Rndm();
591 xrandom =
fXmin +dx*i +ddx;
592 yrandom =
fYmin +dy*j +ddy;
625 if (
fSave.size() < 6)
return 0;
635 if (x < xmin || x >
xmax)
return 0;
636 if (dx <= 0)
return 0;
639 if (y < ymin || y >
ymax)
return 0;
640 if (dy <= 0)
return 0;
649 Int_t k1 = jbin*(npx+1) + ibin;
650 Int_t k2 = jbin*(npx+1) + ibin +1;
651 Int_t k3 = (jbin+1)*(npx+1) + ibin +1;
652 Int_t k4 = (jbin+1)*(npx+1) + ibin;
674 Warning(
"Integral",
"failed for %s code=%d, maxpts=%d, epsrel=%g, nfnevl=%d, relerr=%g ",
GetName(),ifail,maxpts,epsrel,nfnevl,relerr);
677 Info(
"Integral",
"Integral of %s using %d and tol=%f is %f , relerr=%f nfcn=%d",
GetName(), maxpts,epsrel,
result,relerr,nfnevl);
706 h->SetDirectory(
nullptr);
711 for (i=1;i<=
fNpx;i++) {
713 for (j=1;j<=
fNpy;j++) {
715 bin = j*(
fNpx + 2) + i;
716 h->SetBinContent(bin,
EvalPar(xv,parameters));
722 if (levels && levels[0] == -9999) levels =
nullptr;
760 for (i=1;i<=
fNpx;i++) {
762 for (j=1;j<=
fNpy;j++) {
764 bin = j*(
fNpx + 2) + i;
772 if (levels && levels[0] == -9999) levels =
nullptr;
801 if ((npx < 2) || (npy < 2))
818 Int_t nsave = (npx + 1) * (npy + 1);
819 fSave.resize(nsave + 6);
823 for (
Int_t j = 0, k = 0; j <= npy; j++) {
825 for (
Int_t i = 0; i <= npx; i++) {
834 fSave[nsave+4] = npx;
835 fSave[nsave+5] = npy;
862 out<<
" "<<f2Name.
Data()<<
"->SetNpx("<<
GetNpx()<<
");"<<std::endl;
864 out<<
" "<<f2Name.
Data()<<
"->SetNpy("<<
GetNpy()<<
");"<<std::endl;
867 out<<
" "<<f2Name.
Data()<<
"->SetChisquare("<<
GetChisquare()<<
");"<<std::endl;
871 out<<
" "<<f2Name.
Data()<<
"->SetParameter("<<i<<
","<<
GetParameter(i)<<
");"<<std::endl;
872 out<<
" "<<f2Name.
Data()<<
"->SetParError("<<i<<
","<<
GetParError(i)<<
");"<<std::endl;
874 out<<
" "<<f2Name.
Data()<<
"->SetParLimits("<<i<<
","<<parmin<<
","<<parmax<<
");"<<std::endl;
876 out<<
" "<<f2Name.
Data()<<
"->Draw("<<quote<<
option<<quote<<
");"<<std::endl;
903 for (level=0; level<nlevels; level++)
fContour.
fArray[level] = levels[level];
930 Warning(
"SetNpy",
"Number of points must be >=4 && <= 10000, fNpy set to 4");
932 }
else if(npy > 10000) {
933 Warning(
"SetNpy",
"Number of points must be >=4 && <= 10000, fNpy set to 10000");
996 if (saved) {
fSave.clear(); }
1008 Error(
"Moment2",
"Integral zero over range");
1013 auto integrand = [&](
double *
x,
double *) {
1014 return std::pow(
x[0], nx) * std::pow(
x[1], ny) * this->
EvalPar(x,
nullptr);
1017 TF2 fnc(
"TF2_ExpValHelper",integrand,ax,bx,ay,by,0);
1021 return fnc.
Integral(ax,bx,ay,by,epsilon)/norm;
1032 Error(
"CentralMoment2",
"Integral zero over range");
1040 auto integrandX = [&](
double *
x,
double *) {
return x[0] * this->
EvalPar(x,
nullptr); };
1041 TF2 fncx(
"TF2_ExpValHelperx",integrandX, ax, bx, ay, by, 0);
1044 xbar = fncx.
Integral(ax,bx,ay,by,epsilon)/norm;
1048 auto integrandY = [&](
double *
x,
double *) {
return x[1] * this->
EvalPar(x,
nullptr); };
1049 TF2 fncy(
"TF2_ExpValHelperx", integrandY, ax, bx, ay, by, 0);
1052 ybar = fncy.
Integral(ax,bx,ay,by,epsilon)/norm;
1055 auto integrand = [&](
double *
x,
double *) {
1056 double xxx = (nx != 0) ? std::pow(
x[0] - xbar, nx) : 1.;
1057 double yyy = (ny != 0) ? std::pow(
x[1] - ybar, ny) : 1.;
1058 return xxx * yyy * this->
EvalPar(x,
nullptr);
1061 TF2 fnc(
"TF2_ExpValHelper", integrand, ax, bx, ay, by, 0);
1064 return fnc.
Integral(ax, bx, ay, by, epsilon) / norm;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
R__EXTERN TRandom * gRandom
static unsigned int DefaultNCalls()
Param Functor class for Multidimensional functions.
void Streamer(TBuffer &) override
Stream a TArrayD object.
void Copy(TArrayD &array) const
void Set(Int_t n) override
Set size of this array to n doubles.
const Double_t * GetArray() const
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
virtual Color_t GetLineColor() const
Return the line color.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual Style_t GetLineStyle() const
Return the line style.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual Style_t GetMarkerStyle() const
Return the marker style.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual Color_t GetMarkerColor() const
Return the marker color.
virtual Size_t GetMarkerSize() const
Return the marker size.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
void SaveAttributes(std::ostream &out, const char *name, const char *subname) override
Save axis attributes as C++ statement(s) on output stream out.
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadArray(Bool_t *&b)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Int_t fNdim
Function dimension.
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
TAxis * GetYaxis() const
Get y axis of the function.
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
Double_t GetChisquare() const
Return the Chisquare after fitting. See ROOT::Fit::FitResult::Chi2()
Double_t fXmin
Lower bounds for the range.
std::unique_ptr< TMethodCall > fMethodCall
! Pointer to MethodCall in case of interpreted function
virtual void Update()
Called by functions such as SetRange, SetNpx, SetParameters to force the deletion of the associated h...
TAxis * GetZaxis() const
Get z axis of the function. (In case this object is a TF2 or TF3)
virtual Int_t GetNpar() const
TH1 * fHistogram
! Pointer to histogram used for visualisation
Double_t fMaximum
Maximum value for plotting.
virtual Double_t * GetParameters() const
Double_t fMinimum
Minimum value for plotting.
void Copy(TObject &f1) const override
Copy this F1 to a new F1.
void Streamer(TBuffer &) override
Stream a class object.
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
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)
This function computes, to an attempted specified accuracy, the value of the integral.
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=nullptr)
Evaluate function with given coordinates and parameters.
Int_t fNpx
Number of points used for the graphical representation.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
std::vector< Double_t > fSave
Array of fNsave function values.
virtual Double_t GetMinMaxNDim(Double_t *x, Bool_t findmax, Double_t epsilon=0, Int_t maxiter=0) const
Find the minimum of a function of whatever dimension.
std::vector< Double_t > fIntegral
! Integral of function binned on fNpx bins
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
@ kFormula
Formula functions which can be stored,.
virtual Int_t GetNpx() const
Double_t fXmax
Upper bounds for the range.
virtual Int_t GetNdim() const
virtual Double_t GetParameter(Int_t ipar) const
TAxis * GetXaxis() const
Get x axis of the function.
A 2-Dim function with parameters.
virtual Double_t GetMaximumXY(Double_t &x, Double_t &y) const
Compute the X and Y values corresponding to the maximum value of the function.
void Streamer(TBuffer &) override
Stream an object of class TF2.
virtual Double_t FindMinMax(Double_t *x, bool findmax) const
Return minimum/maximum value of the function.
~TF2() override
F2 default destructor.
virtual Double_t GetMinimum(Double_t *x) const
Return minimum/maximum value of the function.
void Copy(TObject &f2) const override
Copy this F2 to a new F2.
virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom, TRandom *rng=nullptr)
Return 2 random numbers following this function shape.
Double_t GetSave(const Double_t *x) override
Get value corresponding to X in array of fSave values.
TClass * IsA() const override
void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override
Save values of function in array fSave.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a function.
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr)
Set the number and values of contour levels.
TH1 * CreateHistogram() override
Create a histogram from function.
void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
Return range of a 2-D function.
virtual Int_t GetContour(Double_t *levels=nullptr)
Return contour values into array levels.
Bool_t IsInside(const Double_t *x) const override
Return kTRUE is the point is inside the function range.
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
virtual Double_t Moment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Return x^nx * y^ny moment of a 2d function in range [ax,bx],[ay,by].
TF1 * DrawCopy(Option_t *option="") const override
Draw a copy of this function with its current attributes-*.
virtual Double_t GetMinimumXY(Double_t &x, Double_t &y) const
Compute the X and Y values corresponding to the minimum value of the function.
Int_t fNpy
Number of points along y used for the graphical representation.
void Paint(Option_t *option="") override
Paint this 2-D function with its current attributes.
TArrayD fContour
Array to display contour levels.
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Double_t fYmax
Upper bound for the range in y.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
TF2 & operator=(const TF2 &rhs)
Operator =.
char * GetObjectInfo(Int_t px, Int_t py) const override
Redefines TObject::GetObjectInfo.
virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsrel=1.e-6)
Return Integral of a 2d function in range [ax,bx],[ay,by] with desired relative accuracy (defined by ...
Double_t fYmin
Lower bound for the range in y.
virtual Double_t GetContourLevel(Int_t level) const
Return the number of contour levels.
virtual Double_t CentralMoment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Return x^nx * y^ny central moment of a 2d function in range [ax,bx],[ay,by].
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
virtual void SetContourLevel(Int_t level, Double_t value)
Set value for one contour level.
TF2()
TF2 default constructor.
virtual Double_t GetMaximum(Double_t *x) const
Return maximum value of the function See TF2::GetMinimum.
Double_t GetRandom(TRandom *rng=nullptr, Option_t *opt=nullptr) override
Return a random number following this function shape.
void SetRange(Double_t xmin, Double_t xmax) override
Initialize the upper and lower bounds to draw the function.
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetMinimum(Double_t minimum=-1111)
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
virtual Double_t GetContourLevel(Int_t level) const
Return value of contour number level.
virtual void SetContour(Int_t nlevels, const Double_t *levels=nullptr)
Set the number and values of contour levels.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
2-D histogram with a float per channel (see TH1 documentation)
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
@ kCanDelete
if object in a list can be deleted
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
This is the base class for the ROOT Random number generators.
Double_t Rndm() override
Machine independent random number generator.
void ToLower()
Change string to lower-case.
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Int_t Finite(Double_t x)
Check if it is finite with a mask in order to be consistent in presence of fast math.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.