75 Int_t ndim = GetNdim();
77 if (ndim < 3) fNdim = 3;
79 Error(
"TF3",
"function: %s/%s has dimension %d instead of 3",
name,formula,ndim);
97 Int_t ndim = GetNdim();
102 Error(
"TF3",
"function: %s/%s has dimension %d instead of 3",
name, formula, ndim);
126TF3::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, EAddToList addToGlobList)
153TF3::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, EAddToList addToGlobList)
176TF3::TF3(
const char *
name,
ROOT::Math::ParamFunctor f,
Double_t xmin,
Double_t xmax,
Double_t ymin,
Double_t ymax,
Double_t zmin,
Double_t zmax,
Int_t npar,
Int_t ndim, EAddToList addToGlobList)
190 rhs.TF3::Copy(*
this);
238 TString opt = option;
277 Double_t rsign = (findmax) ? -1. : 1.;
279 Double_t xxmin = 0, yymin = 0, zzmin = 0, ttmin = 0;
289 xx[0]=
fXmin + (i+0.5)*dx;
291 xx[1]=
fYmin+(j+0.5)*dy;
293 xx[2] =
fZmin+(k+0.5)*dz;
295 if (rsign*
tt < rsign*ttmin) {xxmin = xx[0], yymin = xx[1]; zzmin = xx[2]; ttmin=
tt;}
315 if (rsign*fmin < rsign*zzmin) {
316 if (
x) {
x[0] = xx[0];
x[1] = xx[1];
x[2] = xx[2];}
320 if (
x) {
x[0] = xxmin;
x[1] = yymin;
x[2] = zzmin; }
342 double xx[3] = { 0,0,0 };
345 x = xx[0];
y = xx[1]; z = xx[2];
358 double xx[3] = { 0,0,0 };
361 x = xx[0];
y = xx[1]; z = xx[2];
400 Int_t intNegative = 0;
402 for (k=0;k<
fNpz;k++) {
403 xx[2] =
fZmin+(k+0.5)*dz;
404 for (j=0;j<
fNpy;j++) {
405 xx[1] =
fYmin+(j+0.5)*dy;
406 for (i=0;i<
fNpx;i++) {
407 xx[0] =
fXmin+(i+0.5)*dx;
408 integ =
EvalPar(xx,parameters);
409 if (integ < 0) {intNegative++; integ = -integ;}
415 if (intNegative > 0) {
416 Warning(
"GetRandom3",
"function:%s has %d negative values: abs assumed",
GetName(),intNegative);
419 Error(
"GetRandom3",
"Integral of function is zero");
422 for (i=1;i<=ncells;i++) {
459 if (
fSave.size() < 9)
return 0;
473 if (dx <= 0)
return 0;
477 if (dy <= 0)
return 0;
480 if (z < zmin || z > zmax)
return 0;
481 if (dz <= 0)
return 0;
493 Int_t k1 = (ibin ) + (npx+1)*((jbin ) + (npy+1)*(kbin ));
494 Int_t k2 = (ibin+1) + (npx+1)*((jbin ) + (npy+1)*(kbin ));
495 Int_t k3 = (ibin+1) + (npx+1)*((jbin+1) + (npy+1)*(kbin ));
496 Int_t k4 = (ibin ) + (npx+1)*((jbin+1) + (npy+1)*(kbin ));
497 Int_t k5 = (ibin ) + (npx+1)*((jbin ) + (npy+1)*(kbin+1));
498 Int_t k6 = (ibin+1) + (npx+1)*((jbin ) + (npy+1)*(kbin+1));
499 Int_t k7 = (ibin+1) + (npx+1)*((jbin+1) + (npy+1)*(kbin+1));
500 Int_t k8 = (ibin ) + (npx+1)*((jbin+1) + (npy+1)*(kbin+1));
513 if (!
gROOT->GetListOfFunctions()->FindObject(
"xyzgaus")) {
514 f3 =
new TF3(
"xyzgaus",
"xyzgaus", -1, 1, -1, 1, -1, 1);
538 Warning(
"Integral",
"failed for %s code=%d, maxpts=%d, epsrel=%g, nfnevl=%d, relerr=%g ",
GetName(),ifail,maxpts,epsrel,nfnevl,relerr);
541 Info(
"Integral",
"Integral of %s using %d and tol=%f is %f , relerr=%f nfcn=%d",
GetName(),maxpts,epsrel,result,relerr,nfnevl);
565 h->SetDirectory(
nullptr);
575 TString opt = option;
586 fHistogram->GetPainter(option)->ProcessMessage(
"SetF3",
this);
610 if ((npx < 2) || (npy < 2) || (npz < 2))
631 zmin =
fZmin + 0.5*dz;
632 zmax =
fZmax - 0.5*dz;
634 Int_t nsave = (npx + 1)*(npy + 1)*(npz + 1);
635 fSave.resize(nsave + 9);
639 for (
Int_t k = 0,
l = 0; k <= npz; k++) {
641 for (
Int_t j = 0; j <= npy; j++) {
643 for (
Int_t i = 0; i <= npx; i++) {
653 fSave[nsave+4] = zmin;
654 fSave[nsave+5] = zmax;
655 fSave[nsave+6] = npx;
656 fSave[nsave+7] = npy;
657 fSave[nsave+8] = npz;
670 out << f3Name <<
" = new TF3(\"" <<
GetName() <<
"\", \"" << TString(
GetTitle()).ReplaceSpecialCppChars() <<
"\","
681 out <<
" " << f3Name <<
"->SetNpx(" <<
GetNpx() <<
");\n";
683 out <<
" " << f3Name <<
"->SetNpy(" <<
GetNpy() <<
");\n";
685 out <<
" " << f3Name <<
"->SetNpz(" <<
GetNpz() <<
");\n";
688 out <<
" " << f3Name <<
"->SetChisquare(" <<
GetChisquare() <<
");\n";
692 out <<
" " << f3Name <<
"->SetParameter(" << i <<
"," <<
GetParameter(i) <<
");\n";
693 out <<
" " << f3Name <<
"->SetParError(" << i <<
"," <<
GetParError(i) <<
");\n";
695 out <<
" " << f3Name <<
"->SetParLimits(" << i <<
"," << parmin <<
"," << parmax <<
");\n";
732 Warning(
"SetNpz",
"Number of points must be >=4 && <= 10000, fNpz set to 4");
734 }
else if(npz > 10000) {
735 Warning(
"SetNpz",
"Number of points must be >=4 && <= 10000, fNpz set to 10000");
776 if (saved) {
fSave.clear(); }
788 Error(
"Moment3",
"Integral zero over range");
793 auto integrand = [&](
double *
x,
double *) {
794 return std::pow(
x[0], nx) * std::pow(
x[1], ny) * std::pow(
x[2], nz) * this->
EvalPar(
x,
nullptr);
797 TF3 fnc(
"TF3_ExpValHelper", integrand, ax, bx, ay, by, az, bz, 0);
802 return fnc.Integral(ax, bx, ay, by, az, bz, epsilon) / norm;
813 Error(
"CentralMoment3",
"Integral zero over range");
822 auto integrandX = [&](
double *
x,
double *) {
return x[0] * this->
EvalPar(
x,
nullptr); };
823 TF3 fncx(
"TF3_ExpValHelperx", integrandX, ax, bx, ay, by, az, bz, 0);
827 xbar = fncx.Integral(ax, bx, ay, by, az, bz, epsilon) / norm;
830 auto integrandY = [&](
double *
x,
double *) {
return x[1] * this->
EvalPar(
x,
nullptr); };
831 TF3 fncy(
"TF3_ExpValHelpery", integrandY, ax, bx, ay, by, az, bz, 0);
835 ybar = fncy.Integral(ax,bx,ay,by,az,bz,epsilon)/norm;
838 auto integrandZ = [&](
double *
x,
double *) {
return x[2] * this->
EvalPar(
x,
nullptr); };
839 TF3 fncz(
"TF3_ExpValHelperz", integrandZ, ax, bx, ay, by, az, bz, 0);
843 zbar = fncz.Integral(ax,bx,ay,by,az,bz,epsilon)/norm;
846 auto integrand = [&](
double *
x,
double *) {
847 double xxx = (nx != 0) ? std::pow(
x[0] - xbar, nx) : 1.;
848 double yyy = (ny != 0) ? std::pow(
x[1] - ybar, ny) : 1.;
849 double zzz = (nz != 0) ? std::pow(
x[2] - zbar, nz) : 1.;
850 return xxx * yyy * zzz * this->
EvalPar(
x,
nullptr);
853 TF3 fnc(
"TF3_ExpValHelper",integrand,ax,bx,ay,by,az,bz,0) ;
857 return fnc.Integral(ax,bx,ay,by,az,bz,epsilon)/norm;
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).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
const char Option_t
Option string (const char).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
externTVirtualMutex * gROOTMutex
#define R__LOCKGUARD(mutex)
static unsigned int DefaultNCalls()
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
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 ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Double_t GetMinMaxNDim(Double_t *x, Bool_t findmax, Double_t epsilon=0, Int_t maxiter=0) const
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 InitArgs(const Double_t *x, const Double_t *params)
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
virtual Int_t GetNpar() const
TString ProvideSaveName(Option_t *option)
TH1 * fHistogram
! Pointer to histogram used for visualisation
virtual Double_t * GetParameters() const
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
virtual Double_t GetParError(Int_t ipar) const
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 an event at (px,py).
std::vector< Double_t > fSave
Array of fNsave function values.
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)
virtual void SetParameters(const Double_t *params)
std::vector< Double_t > fIntegral
! Integral of function binned on fNpx bins
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=nullptr)
@ kFormula
Formula functions which can be stored,.
virtual Int_t GetNpx() const
Double_t fXmax
Upper bounds for the range.
virtual Double_t GetParameter(Int_t ipar) const
void Copy(TObject &f2) const override
Copy this to obj.
Int_t fNpy
Number of points along y used for the graphical representation.
Double_t fYmax
Upper bound for the range in y.
Double_t fYmin
Lower bound for the range in y.
virtual void SetClippingBoxOff()
void GetRange(Double_t &xmin, Double_t &xmax) const override
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)
void Paint(Option_t *option="") override
This method must be overridden if a class wants to paint itself.
Bool_t IsInside(const Double_t *x) const override
return kTRUE if the point is inside the function range
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)
virtual Double_t GetMaximumXYZ(Double_t &x, Double_t &y, Double_t &z)
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to an event at (px,py).
Double_t fZmin
Lower bound for the range in z.
TF3 & operator=(const TF3 &rhs)
virtual Double_t GetMinimumXYZ(Double_t &x, Double_t &y, Double_t &z)
static void InitStandardFunctions()
void Copy(TObject &f3) const override
Copy this to obj.
Double_t FindMinMax(Double_t *x, bool findmax) const override
virtual void GetRandom3(Double_t &xrandom, Double_t &yrandom, Double_t &zrandom, TRandom *rng=nullptr)
Bool_t fClipBoxOn
! Is clip box on
Int_t fNpz
Number of points along z used for the graphical representation.
void Draw(Option_t *option="") override
Default Draw method for all objects.
virtual void SetClippingBoxOn(Double_t xclip=0, Double_t yclip=0, Double_t zclip=0)
Double_t fZmax
Upper bound for the range in z.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
virtual void SetNpz(Int_t npz=30)
void Streamer(TBuffer &) override
Stream an object of class TObject.
TH1 * CreateHistogram() override
void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override
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)
Double_t GetSave(const Double_t *x) override
Double_t fClipBox[3]
! Coordinates of clipbox
void SetRange(Double_t xmin, Double_t xmax) override
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
TH1 is the base class of all histogram classes in ROOT.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title 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.
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.
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
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
ParamFunctorTempl< double > ParamFunctor
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
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.