TRandom3 initialization

Hi all,

I have a question about the initialization of the TRandom3 random number generator.

I have a code that generates a set of N random numbers with TRandom3 (N is a parameter that can be chosen by the user, and TRandom3 is initialized in the code with SetSeed).

If for instance I set N=100 events, the code will generate a given sequence of 100 random numbers (that depends on the seed of TRandom3). Now, I want to obtain the same sequence of random numbers by running the code twice with N=50. To do that, I guess that the first time TRandom3 has to be initialized with the same seed that I used in the run with N=100, but what about the second initialization?

I believe it is sufficient that you do not call “SetSeed” after you finished your first half (i.e. after the first 50 randoms). Then the second half will simply “proceed” as in the “full case” (of 100 randoms).

Well, the problem is that the code is not a ROOT macro that can be ran within a ROOT interactive session. It is a c++ code that includes ROOT (and also makes a lot of other things, this is why I need to run it several times).

You could store the TRandom3 object in the ROOT file … see also … [url]Question about gRandom and TUUID

Thanks, now it works.