43 TF2::
TF2():
TF1(),fYmin(0),fYmax(0),fNpy(100)
58 :
TF1(name,formula,xmax,xmin)
70 if (
GetNdim() != 2 && xmin < xmax && ymin < ymax) {
71 Error(
"TF2",
"function: %s/%s has dimension %d instead of 2",name,formula,
GetNdim());
88 :
TF1(name,
fcn, xmin, xmax, npar,ndim)
109 :
TF1(name,
fcn, xmin, xmax, npar,ndim)
128 :
TF1(name, f, xmin, xmax, npar,ndim)
196 if (
gPad->GetView() || strncmp(drawOption,
"cont",4) == 0
197 || strncmp(drawOption,
"CONT",4) == 0) {
198 uxmin=
gPad->GetUxmin();
199 uxmax=
gPad->GetUxmax();
201 uymin=
gPad->GetUymin();
202 uymax=
gPad->GetUymax();
297 if (level <0 || level >=
fContour.
fN)
return 0;
325 Double_t rsign = (findmax) ? -1. : 1.;
326 TF2 &
function =
const_cast<TF2&
>(*this);
327 Double_t xxmin = 0, yymin = 0, zzmin = 0;
335 xx[0]=
fXmin + (i+0.5)*dx;
337 xx[1]=
fYmin+(j+0.5)*dy;
339 if (rsign*zz < rsign*zzmin) {xxmin = xx[0], yymin = xx[1]; zzmin = zz;}
349 zzmin =
function(xx);
355 if (rsign*fmin < rsign*zzmin) {
356 if (x) {x[0] = xx[0]; x[1] = xx[1]; }
360 if (x) { x[0] = xxmin; x[1] = yymin; }
384 double xx[2] = { 0,0 };
387 x = xx[0]; y = xx[1];
399 double xx[2] = { 0,0 };
402 x = xx[0]; y = xx[1];
445 const char *snull =
"";
446 if (!
gPad)
return (
char*)snull;
447 static char info[64];
453 if (
gPad->GetView() || strncmp(drawOption,
"cont",4) == 0
454 || strncmp(drawOption,
"CONT",4) == 0) {
455 uxmin=
gPad->GetUxmin();
456 uxmax=
gPad->GetUxmax();
458 uymin=
gPad->GetUymin();
459 uymax=
gPad->GetUymax();
462 snprintf(info,64,
"(x=%g, y=%g, f=%.18g)",x,y,((
TF2*)
this)->
Eval(x,y));
471 Error(
"GetRandom",
"cannot be called for TF2/3, use GetRandom2/3 instead");
481 Error(
"GetRandom",
"cannot be called for TF2/3, use GetRandom2/3 instead");
515 Int_t intNegative = 0;
517 for (j=0;j<
fNpy;j++) {
518 for (i=0;i<
fNpx;i++) {
520 if (integ < 0) {intNegative++; integ = -integ;}
525 if (intNegative > 0) {
526 Warning(
"GetRandom2",
"function:%s has %d negative values: abs assumed",
GetName(),intNegative);
529 Error(
"GetRandom2",
"Integral of function is zero");
532 for (i=1;i<=ncells;i++) {
542 if (dxint > 0) ddx = dx*(r - fIntegral[cell])/dxint;
547 xrandom =
fXmin +dx*i +ddx;
548 yrandom =
fYmin +dy*j +ddy;
582 if (
fSave.empty())
return 0;
593 if (x < xmin || x > xmax)
return 0;
594 if (dx <= 0)
return 0;
597 if (y < ymin || y > ymax)
return 0;
598 if (dy <= 0)
return 0;
607 Int_t k1 = jbin*(npx+1) + ibin;
608 Int_t k2 = jbin*(npx+1) + ibin +1;
609 Int_t k3 = (jbin+1)*(npx+1) + ibin +1;
610 Int_t k4 = (jbin+1)*(npx+1) + ibin;
632 Warning(
"Integral",
"failed code=%d, maxpts=%d, epsrel=%g, nfnevl=%d, relerr=%g ",ifail,maxpts,epsrel,nfnevl,relerr);
666 for (i=1;i<=
fNpx;i++) {
668 for (j=1;j<=
fNpy;j++) {
670 bin = j*(
fNpx + 2) + i;
677 if (levels && levels[0] == -9999) levels = 0;
715 for (i=1;i<=
fNpx;i++) {
717 for (j=1;j<=
fNpy;j++) {
719 bin = j*(
fNpx + 2) + i;
727 if (levels && levels[0] == -9999) levels = 0;
756 Int_t fNsave = nsave+6;
757 if (fNsave <= 6) {fNsave=0;
return;}
759 fSave.resize(fNsave);
765 xmin =
fXmin +0.5*dx;
766 xmax =
fXmax -0.5*dx;
770 ymin =
fYmin +0.5*dy;
771 ymax =
fYmax -0.5*dy;
776 for (j=0;j<=
fNpy;j++) {
778 for (i=0;i<=
fNpx;i++) {
813 out<<
" "<<
GetName()<<
"->SetFillColor(ci);" << std::endl;
823 out<<
" "<<
GetName()<<
"->SetMarkerColor(ci);" << std::endl;
836 out<<
" "<<
GetName()<<
"->SetLineColor(ci);" << std::endl;
857 out<<
" "<<
GetName()<<
"->SetParLimits("<<i<<
","<<parmin<<
","<<parmax<<
");"<<std::endl;
860 <<quote<<option<<quote<<
");"<<std::endl;
883 for (level=0; level<nlevels; level++)
fContour.
fArray[level] = levels[level];
910 Warning(
"SetNpy",
"Number of points must be >=4 && <= 10000, fNpy set to 4");
912 }
else if(npy > 10000) {
913 Warning(
"SetNpy",
"Number of points must be >=4 && <= 10000, fNpy set to 10000");
936 void TF2::Streamer(
TBuffer &R__b)
976 if (saved) {
fSave.clear(); }
988 Error(
"Moment2",
"Integral zero over range");
992 TF2 fnc(
"TF2_ExpValHelper",
Form(
"%s*pow(x,%f)*pow(y,%f)",
GetName(),nx,ny));
1004 Error(
"CentralMoment2",
"Integral zero over range");
1018 TF2 fnc(
"TF2_ExpValHelper",
Form(
"%s*pow(x-%f,%f)*pow(y-%f,%f)",
GetName(),xbar,nx,ybar,ny));
virtual const char * GetTitle() const
Returns title of object.
virtual Style_t GetLineStyle() const
virtual Style_t GetFillStyle() const
virtual void SetLineWidth(Width_t lwidth)
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
virtual void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Return range of a 2-D function.
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
virtual void SetMaximum(Double_t maximum=-1111)
virtual Double_t GetMinimum(Double_t *x) const
Return minimum/maximum value of the function.
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
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].
virtual void SetContour(Int_t nlevels, const Double_t *levels=0)
Set the number and values of contour levels.
Double_t distance(const TPoint2 &p1, const TPoint2 &p2)
static void SaveColor(std::ostream &out, Int_t ci)
Save a color with index > 228 as a C++ statement(s) on output stream out.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Buffer base class used for serializing objects.
virtual Double_t GetMaximum(Double_t *x) const
Return maximum value of the function See TF2::GetMinimum.
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 void SetMinimum(Double_t minimum=-1111)
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
virtual void SetFillStyle(Style_t fstyle)
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a function.
virtual Double_t FindMinMax(Double_t *x, bool findmax) const
Return minimum/maximum value of the function.
virtual Double_t GetContourLevel(Int_t level) const
Return the number of contour levels.
void Copy(TArrayD &array) const
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 (default val...
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
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 AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual void SetContourLevel(Int_t level, Double_t value)
Set value for one contour level.
Double_t GetChisquare() const
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
virtual void Copy(TObject &f1) const
Copy this F1 to a new F1.
virtual void SetMarkerColor(Color_t mcolor=1)
virtual TH1 * CreateHistogram()
Create a histogram from function.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual TF1 * DrawCopy(Option_t *option="") const
Draw a copy of this function with its current attributes-*.
std::vector< Double_t > fIntegral
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
virtual Int_t GetContour(Double_t *levels=0)
Return contour values into array levels.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
virtual void SetLineColor(Color_t lcolor)
virtual Size_t GetMarkerSize() const
TH1 * fHistogram
Parent object hooking this function (if one)
virtual void SetFillColor(Color_t fcolor)
2-D histogram with a float per channel (see TH1 documentation)}
Double_t GetRandom()
Return a random number following this function shape.
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...
virtual Color_t GetFillColor() const
virtual ~TF2()
F2 default destructor.
virtual Int_t GetNdim() const
char * Form(const char *fmt,...)
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
virtual void Copy(TObject &f2) const
Copy this F2 to a new F2.
virtual const char * GetName() const
Returns name of object.
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void Update()
Called by functions such as SetRange, SetNpx, SetParameters to force the deletion of the associated h...
A 2-Dim function with parameters.
R__EXTERN TRandom * gRandom
virtual Color_t GetLineColor() const
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
TF2 & operator=(const TF2 &rhs)
Operator =.
virtual void SetMarkerSize(Size_t msize=1)
const Double_t * GetArray() const
virtual Int_t GetNpx() const
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom)
Return 2 random numbers following this function shape.
std::vector< Double_t > fSave
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.
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
virtual void Paint(Option_t *option="")
Paint this 2-D function with its current attributes.
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Redefines TObject::GetObjectInfo.
virtual void SetLineStyle(Style_t lstyle)
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
virtual Double_t GetParameter(Int_t ipar) const
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Mother of all ROOT objects.
virtual Double_t * GetParameters() const
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.
TMethodCall * fMethodCall
Pointer to histogram used for visualisation.
virtual Color_t GetMarkerColor() const
virtual Double_t GetSave(const Double_t *x)
Get value corresponding to X in array of fSave values.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
Param Functor class for Multidimensional functions.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
virtual Bool_t IsInside(const Double_t *x) const
Return kTRUE is the point is inside the function range.
virtual Style_t GetMarkerStyle() const
Int_t Fill(Double_t)
Invalid Fill method.
virtual Width_t GetLineWidth() const
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
double norm(double *x, double *p)
void Set(Int_t n)
Set size of this array to n doubles.
virtual Int_t GetNpar() const
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
virtual Double_t GetContourLevel(Int_t level) const
Return value of contour number level use GetContour to return the array of all contour levels...
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax)
Save values of function in array fSave.
virtual Int_t ReadArray(Bool_t *&b)=0
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].
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.