114 Error(
"TF2",
"function: %s/%s has dimension %d instead of 2",
name,formula,
GetNdim());
149 Error(
"TF2",
"function: %s/%s has dimension %d instead of 2",
name, formula,
GetNdim());
230 rhs.TF2::Copy(*
this);
274 if (distance <= 1)
return distance;
281 if (
gPad->GetView() || strncmp(drawOption,
"cont",4) == 0
282 || strncmp(drawOption,
"CONT",4) == 0) {
283 uxmin=
gPad->GetUxmin();
284 uxmax=
gPad->GetUxmax();
286 uymin=
gPad->GetUymin();
287 uymax=
gPad->GetUymax();
382 if (level <0 || level >=
fContour.fN)
return 0;
410 Double_t rsign = (findmax) ? -1. : 1.;
411 TF2 & function =
const_cast<TF2&
>(*this);
412 Double_t xxmin = 0, yymin = 0, zzmin = 0;
420 xx[0]=
fXmin + (i+0.5)*dx;
422 xx[1]=
fYmin+(j+0.5)*dy;
424 if (rsign*zz < rsign*zzmin) {xxmin = xx[0], yymin = xx[1]; zzmin = zz;}
440 if (rsign*fmin < rsign*zzmin) {
441 if (
x) {
x[0] = xx[0];
x[1] = xx[1]; }
445 if (
x) {
x[0] = xxmin;
x[1] = yymin; }
469 double xx[2] = { 0,0 };
472 x = xx[0];
y = xx[1];
484 double xx[2] = { 0,0 };
487 x = xx[0];
y = xx[1];
530 const char *snull =
"";
531 if (!
gPad)
return (
char*)snull;
532 static char info[64];
538 if (
gPad->GetView() || strncmp(drawOption,
"cont",4) == 0
539 || strncmp(drawOption,
"CONT",4) == 0) {
540 uxmin=
gPad->GetUxmin();
541 uxmax=
gPad->GetUxmax();
543 uymin=
gPad->GetUymin();
544 uymax=
gPad->GetUymax();
556 Error(
"GetRandom",
"cannot be called for TF2/3, use GetRandom2/3 instead");
566 Error(
"GetRandom",
"cannot be called for TF2/3, use GetRandom2/3 instead");
600 Int_t intNegative = 0;
602 for (j=0;j<
fNpy;j++) {
603 for (i=0;i<
fNpx;i++) {
605 if (integ < 0) {intNegative++; integ = -integ;}
610 if (intNegative > 0) {
611 Warning(
"GetRandom2",
"function:%s has %d negative values: abs assumed",
GetName(),intNegative);
614 Error(
"GetRandom2",
"Integral of function is zero");
617 for (i=1;i<=ncells;i++) {
628 if (dxint > 0) ddx = dx*(
r -
fIntegral[cell])/dxint;
630 ddy = dy*rng->
Rndm();
633 xrandom =
fXmin +dx*i +ddx;
634 yrandom =
fYmin +dy*j +ddy;
667 if (
fSave.size() < 6)
return 0;
678 if (dx <= 0)
return 0;
682 if (dy <= 0)
return 0;
691 Int_t k1 = jbin*(npx+1) + ibin;
692 Int_t k2 = jbin*(npx+1) + ibin +1;
693 Int_t k3 = (jbin+1)*(npx+1) + ibin +1;
694 Int_t k4 = (jbin+1)*(npx+1) + ibin;
706 if (!
gROOT->GetListOfFunctions()->FindObject(
"xygaus")) {
707 f2 =
new TF2(
"xygaus",
"xygaus", -1, 1, -1, 1);
709 f2 =
new TF2(
"bigaus",
"bigaus", -1, 1, -1, 1);
711 f2 =
new TF2(
"xyexpo",
"xyexpo", -1, 1, -1, 1);
713 f2 =
new TF2(
"xylandau",
"xylandau", -1, 1, -1, 1);
715 f2 =
new TF2(
"xylandaun",
"xylandaun", -1, 1, -1, 1);
737 Warning(
"Integral",
"failed for %s code=%d, maxpts=%d, epsrel=%g, nfnevl=%d, relerr=%g ",
GetName(),ifail,maxpts,epsrel,nfnevl,relerr);
740 Info(
"Integral",
"Integral of %s using %d and tol=%f is %f , relerr=%f nfcn=%d",
GetName(), maxpts,epsrel,
result,relerr,nfnevl);
769 h->SetDirectory(
nullptr);
774 for (i=1;i<=
fNpx;i++) {
776 for (j=1;j<=
fNpy;j++) {
778 bin = j*(
fNpx + 2) + i;
779 h->SetBinContent(bin,
EvalPar(xv,parameters));
785 if (levels && levels[0] == -9999) levels =
nullptr;
823 for (i=1;i<=
fNpx;i++) {
825 for (j=1;j<=
fNpy;j++) {
827 bin = j*(
fNpx + 2) + i;
835 if (levels && levels[0] == -9999) levels =
nullptr;
853 else if (opt ==
"same")
fHistogram->Paint(
"cont2same");
865 if ((npx < 2) || (npy < 2))
882 Int_t nsave = (npx + 1) * (npy + 1);
883 fSave.resize(nsave + 6);
887 for (
Int_t j = 0, k = 0; j <= npy; j++) {
889 for (
Int_t i = 0; i <= npx; i++) {
898 fSave[nsave+4] = npx;
899 fSave[nsave+5] = npy;
909 if (point >= 0 && point < (
Int_t)
fSave.size())
921 out <<
" TF2 *" << f2Name <<
" = new TF2(\"" <<
GetName() <<
"\", \""
925 out <<
" TF2 *" << f2Name <<
" = new TF2(\"" <<
"*" <<
GetName() <<
"\", " <<
fXmin <<
"," <<
fXmax <<
","
931 out <<
" " << f2Name <<
"->SetNpx(" <<
GetNpx() <<
");\n";
933 out <<
" " << f2Name <<
"->SetNpy(" <<
GetNpy() <<
");\n";
936 out <<
" " << f2Name <<
"->SetChisquare(" <<
GetChisquare() <<
");\n";
940 out <<
" " << f2Name <<
"->SetParameter(" << i <<
"," <<
GetParameter(i) <<
");\n";
941 out <<
" " << f2Name <<
"->SetParError(" << i <<
"," <<
GetParError(i) <<
");\n";
943 out <<
" " << f2Name <<
"->SetParLimits(" << i <<
"," << parmin <<
"," << parmax <<
");\n";
953 if (!
fSave.empty()) {
955 out <<
" for (int n = 0; n < " <<
fSave.size() <<
"; n++)\n";
956 out <<
" " << f2Name <<
"->SetSavedPoint(n, " << vect <<
"[n]);\n";
966 out <<
" " << f2Name <<
"->SetContour(" <<
fContour.fN;
968 out <<
", " << vectname <<
".data()";
1003 for (level=0; level<nlevels; level++)
fContour.fArray[level] = levels[level];
1015 if (level <0 || level >=
fContour.fN)
return;
1030 Warning(
"SetNpy",
"Number of points must be >=4 && <= 10000, fNpy set to 4");
1032 }
else if(npy > 10000) {
1033 Warning(
"SetNpy",
"Number of points must be >=4 && <= 10000, fNpy set to 10000");
1096 if (saved) {
fSave.clear(); }
1108 Error(
"Moment2",
"Integral zero over range");
1113 auto integrand = [&](
double *
x,
double *) {
1114 return std::pow(
x[0], nx) * std::pow(
x[1], ny) * this->
EvalPar(x,
nullptr);
1117 TF2 fnc(
"TF2_ExpValHelper",integrand,ax,bx,ay,by,0);
1121 return fnc.
Integral(ax,bx,ay,by,epsilon)/norm;
1132 Error(
"CentralMoment2",
"Integral zero over range");
1140 auto integrandX = [&](
double *
x,
double *) {
return x[0] * this->
EvalPar(x,
nullptr); };
1141 TF2 fncx(
"TF2_ExpValHelperx",integrandX, ax, bx, ay, by, 0);
1144 xbar = fncx.
Integral(ax,bx,ay,by,epsilon)/norm;
1148 auto integrandY = [&](
double *
x,
double *) {
return x[1] * this->
EvalPar(x,
nullptr); };
1149 TF2 fncy(
"TF2_ExpValHelperx", integrandY, ax, bx, ay, by, 0);
1152 ybar = fncy.
Integral(ax,bx,ay,by,epsilon)/norm;
1155 auto integrand = [&](
double *
x,
double *) {
1156 double xxx = (nx != 0) ? std::pow(
x[0] - xbar, nx) : 1.;
1157 double yyy = (ny != 0) ? std::pow(
x[1] - ybar, ny) : 1.;
1158 return xxx * yyy * this->
EvalPar(x,
nullptr);
1161 TF2 fnc(
"TF2_ExpValHelper", integrand, ax, bx, ay, by, 0);
1164 return fnc.
Integral(ax, bx, ay, by, epsilon) / norm;
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
short Version_t
Class version identifier (short)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char)
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
externTVirtualMutex * gROOTMutex
R__EXTERN TRandom * gRandom
#define R__LOCKGUARD(mutex)
static unsigned int DefaultNCalls()
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Style_t GetFillStyle() const
Return 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 Width_t GetLineWidth() const
Return the line width.
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 Color_t GetMarkerColor() const
Return the marker color.
virtual Size_t GetMarkerSize() const
Return 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
EAddToList
Add to list behavior.
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.
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
TString ProvideSaveName(Option_t *option)
Provide variable name for function for saving as primitive When TH1 or TGraph stores list of function...
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.
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.
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.
virtual void SetParameters(const Double_t *params)
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.
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 SetSavedPoint(Int_t point, Double_t value) override
Restore value of function saved at point.
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.
static void InitStandardFunctions()
Create the basic function objects.
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.
2-D histogram with a float per channel (see TH1 documentation)
void SavePrimitiveNameTitle(std::ostream &out, const char *variable_name)
Save object name and title into the output stream "out".
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
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.
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
TObject()
TObject constructor.
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag=0)
Save array in the output stream "out" as vector.
@ 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.
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
ParamFunctorTempl< double > ParamFunctor
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.