50 :
TF2(name,formula,xmin,xmax,ymax,ymin,opt)
57 if (ndim < 3)
fNdim = 3;
58 if (ndim > 3 && xmin < xmax && ymin < ymax && zmin < zmax) {
59 Error(
"TF3",
"function: %s/%s has dimension %d instead of 3",name,formula,ndim);
77 TF3::TF3(
const char *
name,
Double_t (*fcn)(
Double_t *,
Double_t *),
Double_t xmin,
Double_t xmax,
Double_t ymin,
Double_t ymax,
Double_t zmin,
Double_t zmax,
Int_t npar,
Int_t ndim)
78 :
TF2(name,fcn,xmin,xmax,ymin,ymax,npar,ndim)
98 TF3::TF3(
const char *name,
Double_t (*fcn)(
const Double_t *,
const Double_t *),
Double_t xmin,
Double_t xmax,
Double_t ymin,
Double_t ymax,
Double_t zmin,
Double_t zmax,
Int_t npar,
Int_t ndim)
99 :
TF2(name,fcn,xmin,xmax,ymin,ymax,npar,ndim),
116 :
TF2(name, f, xmin, xmax, ymin, ymax, npar, ndim),
217 Double_t rsign = (findmax) ? -1. : 1.;
218 TF3 &
function =
const_cast<TF3&
>(*this);
219 Double_t xxmin = 0, yymin = 0, zzmin = 0, ttmin = 0;
229 xx[0]=
fXmin + (i+0.5)*dx;
231 xx[1]=
fYmin+(j+0.5)*dy;
233 xx[2] =
fZmin+(k+0.5)*dz;
235 if (rsign*tt < rsign*ttmin) {xxmin = xx[0], yymin = xx[1]; zzmin = xx[2]; ttmin=
tt;}
248 zzmin =
function(xx);
255 if (rsign*fmin < rsign*zzmin) {
256 if (x) {x[0] = xx[0]; x[1] = xx[1]; x[2] = xx[2];}
260 if (x) { x[0] = xxmin; x[1] = yymin; x[2] = zzmin; }
282 double xx[3] = { 0,0,0 };
285 x = xx[0]; y = xx[1]; z = xx[2];
298 double xx[3] = { 0,0,0 };
301 x = xx[0]; y = xx[1]; z = xx[2];
340 Int_t intNegative = 0;
342 for (k=0;k<
fNpz;k++) {
343 xx[2] =
fZmin+(k+0.5)*dz;
344 for (j=0;j<
fNpy;j++) {
345 xx[1] =
fYmin+(j+0.5)*dy;
346 for (i=0;i<
fNpx;i++) {
347 xx[0] =
fXmin+(i+0.5)*dx;
348 integ =
EvalPar(xx,parameters);
349 if (integ < 0) {intNegative++; integ = -integ;}
355 if (intNegative > 0) {
356 Warning(
"GetRandom3",
"function:%s has %d negative values: abs assumed",
GetName(),intNegative);
359 Error(
"GetRandom3",
"Integral of function is zero");
362 for (i=1;i<=ncells;i++) {
399 if (
fSave.empty())
return 0;
412 if (x < xmin || x > xmax)
return 0;
413 if (dx <= 0)
return 0;
416 if (y < ymin || y > ymax)
return 0;
417 if (dy <= 0)
return 0;
420 if (z < zmin || z > zmax)
return 0;
421 if (dz <= 0)
return 0;
433 Int_t k1 = (ibin ) + (npx+1)*((jbin ) + (npy+1)*(kbin ));
434 Int_t k2 = (ibin+1) + (npx+1)*((jbin ) + (npy+1)*(kbin ));
435 Int_t k3 = (ibin+1) + (npx+1)*((jbin+1) + (npy+1)*(kbin ));
436 Int_t k4 = (ibin ) + (npx+1)*((jbin+1) + (npy+1)*(kbin ));
437 Int_t k5 = (ibin ) + (npx+1)*((jbin ) + (npy+1)*(kbin+1));
438 Int_t k6 = (ibin+1) + (npx+1)*((jbin ) + (npy+1)*(kbin+1));
439 Int_t k7 = (ibin+1) + (npx+1)*((jbin+1) + (npy+1)*(kbin+1));
440 Int_t k8 = (ibin ) + (npx+1)*((jbin+1) + (npy+1)*(kbin+1));
465 Warning(
"Integral",
"failed code=%d, maxpts=%d, epsrel=%g, nfnevl=%d, relerr=%g ",ifail,maxpts,epsrel,nfnevl,relerr);
540 Int_t fNsave = nsave+9;
543 fSave.resize(fNsave);
550 xmin =
fXmin +0.5*dx;
551 xmax =
fXmax -0.5*dx;
555 ymin =
fYmin +0.5*dy;
556 ymax =
fYmax -0.5*dy;
560 zmin =
fZmin +0.5*dz;
561 zmax =
fZmax -0.5*dz;
566 for (k=0;k<=
fNpz;k++) {
568 for (j=0;j<=
fNpy;j++) {
570 for (i=0;i<=
fNpx;i++) {
581 fSave[nsave+4] = zmin;
582 fSave[nsave+5] = zmax;
609 out<<
" "<<
GetName()<<
"->SetFillColor(ci);" << std::endl;
616 out<<
" "<<
GetName()<<
"->SetLineColor(ci);" << std::endl;
631 out<<
" "<<
GetName()<<
"->SetParLimits("<<i<<
","<<parmin<<
","<<parmax<<
");"<<std::endl;
634 <<quote<<option<<quote<<
");"<<std::endl;
669 Warning(
"SetNpz",
"Number of points must be >=4 && <= 10000, fNpz set to 4");
671 }
else if(npz > 10000) {
672 Warning(
"SetNpz",
"Number of points must be >=4 && <= 10000, fNpz set to 10000");
697 void TF3::Streamer(
TBuffer &R__b)
713 if (saved) {
fSave.clear(); }
725 Error(
"Moment3",
"Integral zero over range");
729 TF3 fnc(
"TF3_ExpValHelper",
Form(
"%s*pow(x,%f)*pow(y,%f)*pow(z,%f)",
GetName(),nx,ny,nz));
730 return fnc.
Integral(ax,bx,ay,by,az,bz,epsilon)/norm;
741 Error(
"CentralMoment3",
"Integral zero over range");
750 xbar = fncx.
Integral(ax,bx,ay,by,az,bz,epsilon)/norm;
754 ybar = fncy.
Integral(ax,bx,ay,by,az,bz,epsilon)/norm;
758 zbar = fncz.
Integral(ax,bx,ay,by,az,bz,epsilon)/norm;
760 TF3 fnc(
"TF3_ExpValHelper",
Form(
"%s*pow(x-%f,%f)*pow(y-%f,%f)*pow(z-%f,%f)",
GetName(),xbar,nx,ybar,ny,zbar,nz));
761 return fnc.
Integral(ax,bx,ay,by,az,bz,epsilon)/norm;
virtual const char * GetName() const
Returns name of object.
virtual void Copy(TObject &f3) const
Copy this F3 to a new F3.
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Double_t Moment3(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t nz, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Return x^nx * y^ny * z^nz moment of a 3d function in range [ax,bx],[ay,by],[az,bz].
Param Functor class for Multidimensional functions.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
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 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 TH1 * CreateHistogram()
Create a histogram for axis range.
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754
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 ~TF3()
F3 default destructor.
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 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.
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 SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual Double_t GetMinimumXYZ(Double_t &x, Double_t &y, Double_t &z)
Compute the X, Y and Z values corresponding to the minimum value of the function on its range...
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual void SetClippingBoxOn(Double_t xclip=0, Double_t yclip=0, Double_t zclip=0)
Set the function clipping box (for drawing) "on" and define the clipping box.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a function.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
virtual void Copy(TObject &f2) const
Copy this F2 to a new F2.
virtual Double_t GetMaximumXYZ(Double_t &x, Double_t &y, Double_t &z)
Compute the X, Y and Z values corresponding to the maximum value of the function on its range...
TF3()
F3 default constructor.
virtual void Paint(Option_t *option="")
Paint this 3-D function with its current attributes.
Int_t Finite(Double_t x)
Check if it is finite with a mask in order to be consistent in presence of fast math.
virtual Int_t GetNdim() const
virtual void ProcessMessage(const char *mess, const TObject *obj)=0
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
std::vector< Double_t > fIntegral
virtual Double_t Rndm()
Machine independent random number generator.
TH1 * fHistogram
Parent object hooking this function (if one)
virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsrel=1.e-6)
Return Integral of a 3d function in range [ax,bx],[ay,by],[az,bz] with a desired relative accuracy...
virtual Double_t CentralMoment3(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t nz, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Return x^nx * y^ny * z^nz central moment of a 3d function in range [ax,bx],[ay,by],[az,bz].
A 3-Dim function with parameters.
virtual void GetRange(Double_t &xmin, Double_t &xmax) const
Return range of a 1-D function.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
virtual void GetRandom3(Double_t &xrandom, Double_t &yrandom, Double_t &zrandom)
Return 3 random numbers following this function shape.
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
Return the line color.
TF3 & operator=(const TF3 &rhs)
Operator =.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
Double_t GetChisquare() const
std::vector< Double_t > fSave
virtual Color_t GetFillColor() const
Return the fill area color.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual void SetClippingBoxOff()
Set the function clipping box (for drawing) "off".
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
THist< 3, float, THistStatContent, THistStatUncertainty > TH3F
Mother of all ROOT objects.
you should not use this method at all Int_t Int_t z
TMethodCall * fMethodCall
Pointer to histogram used for visualisation.
virtual Int_t GetNpar() const
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
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 Double_t GetParameter(Int_t ipar) const
virtual Bool_t IsInside(const Double_t *x) const
Return kTRUE is the point is inside the function range.
virtual Double_t FindMinMax(Double_t *x, bool findmax) const
Return minimum/maximum value of the function.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual Double_t * GetParameters() const
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a function.
virtual Double_t GetSave(const Double_t *x)
Get value corresponding to X in array of fSave values.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual const char * GetTitle() const
Returns title of object.
const char * Data() const
virtual void SetNpz(Int_t npz=30)
Set the number of points used to draw the function.