Hi, I’m trying to plot a function (Compton scattering) and I am trying to use TF1.
My function is defined in a header file
double E_1(double theta);
And in my main file I am trying to recall it like this:
TApplication app("App",0,0);
TF1 *g = new TF1("E(theta)","E_1(x)",0.,2*M_PI);
TCanvas * c1 = new TCanvas("E_gamma","Energia Fotone uscente",600,600);
c1->cd();
g->SetTitle("E_gamma;Theta [rad];Energy [KeV]");
g->Draw();
app.Run();
Since my custom formula (for another case I have to implement) can be very long I would like to keep its definition outside of the TF1 declaration and the recall it there. Is there any way I can do it?
SOLVED:
The function needs the proper definition to be accepted by TF1:
double E_1(double *x,double *params){
double theta = x[0];
return 511/(2-cos(theta));
}
And then the recall within TF1:
TF1 *g = new TF1("E(x)",E_2,0.,M_PI,0);
//where there are 0 additional parameters in my formula
ROOT Version: 6.30/04
Platform: Linux Mint
Compiler: g++