58 if (ndim < 3)
fNdim = 3;
60 Error(
"TF3",
"function: %s/%s has dimension %d instead of 3",
name,formula,ndim);
78TF3::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)
99TF3::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)
218 Double_t rsign = (findmax) ? -1. : 1.;
219 TF3 & function =
const_cast<TF3&
>(*this);
220 Double_t xxmin = 0, yymin = 0, zzmin = 0, ttmin = 0;
230 xx[0]=
fXmin + (i+0.5)*dx;
232 xx[1]=
fYmin+(j+0.5)*dy;
234 xx[2] =
fZmin+(k+0.5)*dz;
236 if (rsign*
tt < rsign*ttmin) {xxmin = xx[0], yymin = xx[1]; zzmin = xx[2]; ttmin=
tt;}
249 zzmin = function(xx);
256 if (rsign*fmin < rsign*zzmin) {
257 if (
x) {
x[0] = xx[0];
x[1] = xx[1];
x[2] = xx[2];}
261 if (
x) {
x[0] = xxmin;
x[1] = yymin;
x[2] = zzmin; }
283 double xx[3] = { 0,0,0 };
286 x = xx[0];
y = xx[1]; z = xx[2];
299 double xx[3] = { 0,0,0 };
302 x = xx[0];
y = xx[1]; z = xx[2];
341 Int_t intNegative = 0;
343 for (k=0;k<
fNpz;k++) {
344 xx[2] =
fZmin+(k+0.5)*dz;
345 for (j=0;j<
fNpy;j++) {
346 xx[1] =
fYmin+(j+0.5)*dy;
347 for (i=0;i<
fNpx;i++) {
348 xx[0] =
fXmin+(i+0.5)*dx;
349 integ =
EvalPar(xx,parameters);
350 if (integ < 0) {intNegative++; integ = -integ;}
356 if (intNegative > 0) {
357 Warning(
"GetRandom3",
"function:%s has %d negative values: abs assumed",
GetName(),intNegative);
360 Error(
"GetRandom3",
"Integral of function is zero");
363 for (i=1;i<=ncells;i++) {
401 if (
fSave.empty())
return 0;
414 if (x < xmin || x >
xmax)
return 0;
415 if (dx <= 0)
return 0;
418 if (y < ymin || y >
ymax)
return 0;
419 if (dy <= 0)
return 0;
422 if (z < zmin || z > zmax)
return 0;
423 if (dz <= 0)
return 0;
435 Int_t k1 = (ibin ) + (npx+1)*((jbin ) + (npy+1)*(kbin ));
436 Int_t k2 = (ibin+1) + (npx+1)*((jbin ) + (npy+1)*(kbin ));
437 Int_t k3 = (ibin+1) + (npx+1)*((jbin+1) + (npy+1)*(kbin ));
438 Int_t k4 = (ibin ) + (npx+1)*((jbin+1) + (npy+1)*(kbin ));
439 Int_t k5 = (ibin ) + (npx+1)*((jbin ) + (npy+1)*(kbin+1));
440 Int_t k6 = (ibin+1) + (npx+1)*((jbin ) + (npy+1)*(kbin+1));
441 Int_t k7 = (ibin+1) + (npx+1)*((jbin+1) + (npy+1)*(kbin+1));
442 Int_t k8 = (ibin ) + (npx+1)*((jbin+1) + (npy+1)*(kbin+1));
467 Warning(
"Integral",
"failed for %s code=%d, maxpts=%d, epsrel=%g, nfnevl=%d, relerr=%g ",
GetName(),ifail,maxpts,epsrel,nfnevl,relerr);
470 Info(
"Integral",
"Integral of %s using %d and tol=%f is %f , relerr=%f nfcn=%d",
GetName(),maxpts,epsrel,result,relerr,nfnevl);
539 Int_t fNsave = nsave+9;
542 fSave.resize(fNsave);
559 zmin =
fZmin +0.5*dz;
560 zmax =
fZmax -0.5*dz;
565 for (k=0;k<=
fNpz;k++) {
567 for (j=0;j<=
fNpy;j++) {
569 for (i=0;i<=
fNpx;i++) {
580 fSave[nsave+4] = zmin;
581 fSave[nsave+5] = zmax;
594 if (
gROOT->ClassSaved(TF3::Class())) {
608 out<<
" "<<
GetName()<<
"->SetFillColor(ci);" << std::endl;
615 out<<
" "<<
GetName()<<
"->SetLineColor(ci);" << std::endl;
630 out<<
" "<<
GetName()<<
"->SetParLimits("<<i<<
","<<parmin<<
","<<parmax<<
");"<<std::endl;
633 <<quote<<option<<quote<<
");"<<std::endl;
660 Warning(
"SetNpz",
"Number of points must be >=4 && <= 10000, fNpz set to 4");
662 }
else if(npz > 10000) {
663 Warning(
"SetNpz",
"Number of points must be >=4 && <= 10000, fNpz set to 10000");
688void TF3::Streamer(
TBuffer &R__b)
704 if (saved) {
fSave.clear(); }
716 Error(
"Moment3",
"Integral zero over range");
721 auto integrand = [&](
double *
x,
double *) {
722 return std::pow(
x[0], nx) * std::pow(
x[1], ny) * std::pow(
x[2], nz) * this->
EvalPar(x,
nullptr);
725 TF3 fnc(
"TF3_ExpValHelper", integrand, ax, bx, ay, by, az, bz, 0);
741 Error(
"CentralMoment3",
"Integral zero over range");
750 auto integrandX = [&](
double *
x,
double *) {
return x[0] * this->
EvalPar(x,
nullptr); };
751 TF3 fncx(
"TF3_ExpValHelperx", integrandX, ax, bx, ay, by, az, bz, 0);
758 auto integrandY = [&](
double *
x,
double *) {
return x[1] * this->
EvalPar(x,
nullptr); };
759 TF3 fncy(
"TF3_ExpValHelpery", integrandY, ax, bx, ay, by, az, bz, 0);
766 auto integrandZ = [&](
double *
x,
double *) {
return x[2] * this->
EvalPar(x,
nullptr); };
767 TF3 fncz(
"TF3_ExpValHelperz", integrandZ, ax, bx, ay, by, az, bz, 0);
774 auto integrand = [&](
double *
x,
double *) {
775 double xxx = (nx != 0) ? std::pow(
x[0] - xbar, nx) : 1.;
776 double yyy = (ny != 0) ? std::pow(
x[1] - ybar, ny) : 1.;
777 double zzz = (nz != 0) ? std::pow(
x[2] - zbar, nz) : 1.;
778 return xxx * yyy * zzz * this->
EvalPar(x,
nullptr);
781 TF3 fnc(
"TF3_ExpValHelper",integrand,ax,bx,ay,by,az,bz,0) ;
R__EXTERN TRandom * gRandom
static unsigned int DefaultNCalls()
Param Functor class for Multidimensional functions.
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Color_t GetLineColor() const
Return the line color.
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
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 GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
Double_t GetChisquare() const
std::unique_ptr< TMethodCall > fMethodCall
Pointer to histogram used for visualisation.
virtual void Update()
Called by functions such as SetRange, SetNpx, SetParameters to force the deletion of the associated h...
virtual Int_t GetNpar() const
TH1 * fHistogram
Parent object hooking this function (if one)
virtual Double_t * GetParameters() const
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a function.
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
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.
std::vector< Double_t > fSave
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
virtual Int_t GetNdim() const
virtual Double_t GetParameter(Int_t ipar) const
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
A 2-Dim function with parameters.
virtual void Copy(TObject &f2) const
Copy this F2 to a new F2.
A 3-Dim function with parameters.
TF3()
coordinates of clipbox
virtual void GetRandom3(Double_t &xrandom, Double_t &yrandom, Double_t &zrandom, TRandom *rng=nullptr)
Return 3 random numbers following this function shape.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
TF3 & operator=(const TF3 &rhs)
Operator =.
virtual void SetNpz(Int_t npz=30)
Set the number of points used to draw the function.
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.
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
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],...
virtual Double_t FindMinMax(Double_t *x, bool findmax) const
Return minimum/maximum value of the function.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
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 Paint(Option_t *option="")
Paint this 3-D function with its current attributes.
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 Double_t GetSave(const Double_t *x)
Get value corresponding to X in array of fSave values.
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].
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 void Copy(TObject &f3) const
Copy this F3 to a new F3.
virtual void SetClippingBoxOff()
Set the function clipping box (for drawing) "off".
virtual Bool_t IsInside(const Double_t *x) const
Return kTRUE is the point is inside the function range.
virtual ~TF3()
F3 default destructor.
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 void Draw(Option_t *option="")
Draw this function with its current attributes.
virtual void GetRange(Double_t &xmin, Double_t &xmax) const
Return range of a 1-D function.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a function.
virtual TH1 * CreateHistogram()
Create a histogram for axis range.
Double_t fClipBox[3]
is clip box on
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
3-D histogram with a float per channel (see TH1 documentation)}
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
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.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
This is the base class for the ROOT Random number generators.
virtual Double_t Rndm()
Machine independent random number generator.
void ToLower()
Change string to lower-case.
const char * Data() const
TString & Append(const char *cs)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual void ProcessMessage(const char *mess, const TObject *obj)=0
Short_t Max(Short_t a, Short_t 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)
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.