I am trying to plot this formula.
Here is my code:
TCanvas *c = new TCanvas();
double_t x;
TF1* f1 = new TF1("f1", "132*TMath::Sqrt(((1-TMath::Exp(-4.49*TMath::Power(10,-3)*(TMath::Sqrt(4*TMath::Sq(x)-TMath::Sq(0.14)))*(-194)/(TMath::Sq(x)))/(1-TMath::Exp(-4.49*TMath::(10,-3)*(TMath::Sqrt(4*TMath::Sq(x)-TMath::Sq(0.14)))*(-50)/TMath::Sq(x))))",0, 30);
f1->SetLineColor(kBlue);
c->SetGrid();
f1->SetTitle("#NRHF S/#sqrt{B} ; E_{#nu} [Gev]; f(L=50m, E_{#nu})");
f1->Draw();
I am messing up something here. The error message shows near TMath::Power.
Thank you.
yus
2
Hi Aayush,
the problem is here:
You forgot the Power
. You can simplify things a lot by defining b
separately. Also, you do not have to define x
. The following works:
float boostFactor(float x) {return -4.49e-3*TMath::Sqrt(4*TMath::Sq(x)-TMath::Sq(0.14))/TMath::Sq(x);}
void fo()
{
TCanvas *c = new TCanvas();
TF1* f1 = new TF1("f1", "132*TMath::Sqrt((1-TMath::Exp(-194*boostFactor(x)))/(1-TMath::Exp(-50*boostFactor(x))))", 0, 30);
f1->SetLineColor(kBlue);
c->SetGrid();
f1->SetTitle("#NRHF S/#sqrt{B} ; E_{#nu} [Gev]; f(L=50m, E_{#nu})");
f1->Draw();
}
You save both these functions into a fo.cxx
, then you do
root -l fo.cxx
1 Like
system
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.