Undeclared identifier

Hi, I think I have a problem using the TRandom3(0) generator. I’m trying to create a gaussian distributiony using a monte carlo method despite the fact that gaussians distributions are already provided. This is my code:

ran = new TRandom3(0);
TH1* h1 = new TH1F("h1","gaussian, weighted", 100, -3., 3.);
double x;
for(int i=1; i<=10000; i++){
double weight=1/sqrt(2*3.14159)*exp(-1/2*pow(x,2));
h1->Fill(x, weight);

when I go back at the terminal in the linux and type .x and the name of the file, this message appears: error: use of undeclared identifier 'ran’
ran = new TRandom3(0);
and error: use of undeclared identifier 'ran’
what’s going wrong with the declaration of the ran variable? I’m confused…
Thanks in advance

Download this file:
tz.C (300 Bytes)

and execute it in ROOT with .x tz.C

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.