Hi y’all,
I think I may be doing something stupid with TRandom.
I am trying to build a quite complex distribution of random numbers composed of several Lorentzians on top of a polynomial background.
However, the output of GetRandom() seems to be getting weird distributions for any peak function.
For example, the code below should generate a gaussian, but instead is generating this:
Is that any obvious what I am doing wrong?
Double_t VelocityDistribution(Double_t *f, Double_t *par)
{
double xc,w;
xc = par[0];
w = par[1];
double x = f[0];
// return TMath::BreitWigner(x,xc,w);
return TMath::Gaus(x,xc,w);
}
void vel(){
int c;
TH1* h1 = new TH1F("h1", "Velocity Distribution", 10000, 80.0, 100.0);
TF1 *f1 = new TF1("ionvelocity",VelocityDistribution,0.0,165.0,2);
f1->SetParameter( 0 , 90.0 );
f1->SetParameter( 1 , 0.09 );
for(c=0;c<1000000;c++)
h1->Fill(f1->GetRandom());
TCanvas *c1 = new TCanvas("c1","c1",1000,1000);
h1->Draw();
}
ROOT Version: 6.24/06
Platform: Windows 10 pro