Random number generator

Hi,

I’ve created a class in ROOT and I’m trying to add a different random number to each entry of a variable in my ntuple but I get the same number added to each one.

The skeleton provided by the generated class already loops over the entries so I assumed that if I created a new variable, which is the original variable plus a random number:
TRandom random
double newVar = origVar + random.Gaus(0,3)

then this would generate a different random number for each of the entries in my original variable but it doesn’t. Why is this?

Thanks,

Lisa

First, I recommend the use of TRandom3 instead of TRandom.

When calling TRandom (or TRandom3) constructor with no argument, a default seed is used. If you want to have a different seed each time you call the constructor, use
TRandom3 r(0); //instead of new TRandom3()

Rene

Thanks for your help, Rene.