ROOT Version (root_v6.13.02):
MacOS high Sierra 10.13.3; Xcode Version 8.3.3 (8E3004b)
I’m still a ROOT beginner. I’ve learned how to Draw a user-defined function TF1 function. But I failed to do so for a 2D plot after I tried the same approach as that of TF1.
I resorted to the TF2 Class in cern root, but I couldn’t quite understanding how to use this line:
TF2 (const char *name, Double_t(*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0, Int_t ndim=2)
The following is my attempt:
Double_t myfunction(Double_t *xx, Double_t *yy, Double_t *par)
{ double x=xx[0];double y=yy[0];
double f=sin(x)/x*sin(y)/y;
return f;
}
void myfunc()
{
TF2 *f1 = new TF2("myfunc",myfunction,-6,6,-6,6,0,2);//no paramater, 2-dimensional.
f1->Draw("Surf1");
}
With the error report:
/myfunc.C:8:19: error: call to constructor of 'TF2' is ambiguous
TF2 *f1 = new TF2("myfunc",myfunction,-6,6,-6,6,0,2);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/root_v6.13.02/etc/../include/TF2.h:53:4: note: candidate constructor [with PtrObj = double (double *, double *, double *),
MemFn = int]
TF2(const char *name, const PtrObj& p, MemFn memFn, Double_t xmin, D...
^
/Applications/root_v6.13.02/etc/../include/TF2.h:71:4: note: candidate constructor [with Func = double (*)(double *, double *, double *)]
TF2(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ...
Hope someone could help me out and I think this topic will also be useful to somebody else.
Sincerely