The class TF1 supports several constructors:
- constructor where you pass the function as one single string.
examples:
"sin(x)/x" , "[0]*x/sin([1]*x)"
- constructor where you pass a pointer to a function
of type double(double*x, double*params)
I have modified your macro to use the second and more general form:
{
// macro wouter
double distribution(double *x, double *par)
{
double pbar = par[0];
double pt = x[0];
double pzbar = sqrt(pbar*pbar-pt*pt) ;
float Norm = 1. ;
return (pbar*pt/2* (pbar*pzbar + pt*pt*log(pbar+pzbar))
- pt/3 * pzbar*pzbar*pzbar - pt*pt*pt * pzbar) /Norm ;
}
int main()
{
double pbar = 4. ;
TF1 *func = new TF1("func",distribution,0,pbar,1) ;
func->SetParameter(0,pbar);
func->Draw();
}
}
To execute this macro:
Root > .L wouter.C
Root > main()
Note that in your original macro, you add an additional problem>
Your TF1 object func was automatically deleted when exiting
from the scope of main(). You should create the TF1 object via new.
Rene Brun