Generating Histograms with Formula and Random Gaussian


I’m pretty new to ROOT and i’m trying to code in the following, I was wondering if anyone could give me some guidance?

First of all, if I generate a histogram for a Gaussian could I then randomly pull out values off this histogram to use in another equation?

I want to plot an equation (or histogram i guess?) in the form of

S = (x/a)^2 (y^2 + z^2)/2b where a and b are constants and x,y,z are randomly generated from a Gaussian.

y and z should have values randomly generated from “theta” with a peak at 0 and a variance calculated elsewhere, I have tried;

TF1 * variance = new TF1 ("variance", "(13.6*13.6)/[0]/[1]");
	variance->SetParameter(0, 3);
	variance->SetParameter(1, 0.98);
	TF1 * theta = new TF1("theta", gaus(0,variance));

but keep getting errors saying “gaus(0,variance) is not defined”

x should also have values randomly generated in a similar manner but with a user inputted variance and peak.

If anyone could give me guidance on how to start I would be extremely thankful,


I do not know wha you want to do but you could generate the gauss distributed random numbers and fill the histogram. Something like this:

a = 1.
b = 1.
h = ROOT.TH1F('h','h',100,0.,10.)
gauss = ROOT.gRandom.Gaus    
for i in xrange( 100000 ):
  # Generate random values.
  x,y,z = gauss(), gauss(), gauss()
  S = (x/a)**2 *(y**2 + z**2)/(2*b)