82TF2::TF2(): fYmin(0),fYmax(0),fNpy(100)
110 if (GetNdim() < 2) fNdim = 2;
114 Error(
"TF2",
"function: %s/%s has dimension %d instead of 2",
name,formula,GetNdim());
129 EAddToList addToGlobList,
bool vectorize)
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();
303 TString opt = option;
382 if (level <0 || level >=
fContour.fN)
return 0;
410 Double_t rsign = (findmax) ? -1. : 1.;
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++) {
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;
811 TString opt = option;
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())
910 fSave[point] = value;
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;
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.
float Float_t
Float 4 bytes (float).
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 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)
virtual Color_t GetLineColor() const
Return the line color.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
virtual Style_t GetLineStyle() const
Return the line style.
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.
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 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
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
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.
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
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 to obj.
void Streamer(TBuffer &) override
Stream an object of class TObject.
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 SetSavedPoint(Int_t point, Double_t value) override
void Streamer(TBuffer &) override
Stream an object of class TObject.
virtual Double_t GetMinimumXY(Double_t &x, Double_t &y) const
void Copy(TObject &f2) const override
Copy this to obj.
Double_t GetSave(const Double_t *x) override
virtual Double_t GetMaximumXY(Double_t &x, Double_t &y) const
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr)
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
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
TH1 * CreateHistogram() override
void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
Bool_t IsInside(const Double_t *x) const override
return kTRUE if the point is inside the function range
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)
TF1 * DrawCopy(Option_t *option="") const override
Int_t fNpy
Number of points along y used for the graphical representation.
void Paint(Option_t *option="") override
This method must be overridden if a class wants to paint itself.
virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom, TRandom *rng=nullptr)
TArrayD fContour
Array to display contour levels.
void Draw(Option_t *option="") override
Default Draw method for all objects.
Double_t fYmax
Upper bound for the range in y.
virtual Double_t FindMinMax(Double_t *x, bool findmax) const
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
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)
TF2 & operator=(const TF2 &rhs)
char * GetObjectInfo(Int_t px, Int_t py) const override
Returns string containing info about the object at position (px,py).
Double_t fYmin
Lower bound for the range in y.
virtual void SetNpy(Int_t npy=100)
static void InitStandardFunctions()
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to an event at (px,py).
virtual Int_t GetContour(Double_t *levels=nullptr)
virtual void SetContourLevel(Int_t level, Double_t value)
virtual Double_t GetMaximum(Double_t *x) const
Double_t GetRandom(TRandom *rng=nullptr, Option_t *opt=nullptr) override
virtual Double_t GetContourLevel(Int_t level) const
void SetRange(Double_t xmin, Double_t xmax) override
virtual Double_t GetMinimum(Double_t *x) const
virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsrel=1.e-6)
TH1 is the base class of all histogram classes in ROOT.
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.
Mother of all ROOT objects.
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.
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.
Bool_t Contains(const char *pat, 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.