Hi ROOTers,
I wrote a code in order to plot Betfhe-Bloch function, it works but if i change range it doesn’t work, I don’t understand why. I post code and output.
#include<string>
#include<iostream>
Double_t bethe_bloch(Double_t *x, Double_t *par)
{
Double_t E=x[0];
Double_t S; //MeV/cm
Double_t phi;
Double_t rap = par[1]/par[2];
Double_t I= (9.76*par[4])+pow(58.8*par[4],0.19);
//phi = ((par[2])/(2*E))*(log((4*par[1]*E/(par[2]-2*E))/(I + I*sqrt(par[2]/(par[2]-2*E))*rap)) - (2*E)/(par[2]));
phi=(par[2]/(2*E))*log(((4*par[1]*E)/(par[2]-2*E))/(I+I*sqrt(par[2]/(par[2]-2*E))*rap)+2*E/par[2]);
S = -par[0]*(par[4]/par[5])*par[6]*par[3]*phi;
return S;
}
void bethe()
{
TF1 *f1= new TF1("f1",bethe_bloch, 0,100,7);
f1->FixParameter(0,0.30707);// D in (MeV*cm^2)/(mol)
f1->FixParameter(1, 0.510998928); //mec2 in MeV
f1->FixParameter(2,105);// Mc2 in MeV
f1->FixParameter(3, 1); // z2
f1->FixParameter(4, 53); // Z
f1->FixParameter(5, 139); // A
f1->FixParameter(6, 2.266); //densità
f1->GetXaxis()->SetTitle("E");
f1->GetYaxis()->SetTitle("#frac{N_{S}}{cm}");
f1->SetTitle("Curva teorica Bethe-Bloch");
TCanvas *c1 = new TCanvas();
f1->Draw();
c1->SaveAs("bethe.pdf");
}
Warning in <TCanvas::ResizePad>: Inf/NaN propagated to the pad. Check drawn objects.
Warning in <TCanvas::ResizePad>: c1 height changed from 0 to 10
Info in <TCanvas::Print>: pdf file bethe.pdf has been created
root [1] Warning in <TCanvas::ResizePad>: Inf/NaN propagated to the pad. Check drawn objects.
Warning in <TCanvas::ResizePad>: c1 height changed from 0 to 10
Warning in <TCanvas::ResizePad>: Inf/NaN propagated to the pad. Check drawn objects.
Warning in <TCanvas::ResizePad>: c1 height changed from 0 to 10
_ROOT Version: 6.13/03
_Platform: Xubuntu 18.04
_Compiler: gcc 7.2.0