TTree::Draw(): compute hash / reproducible rndm()

Hi,

I am wondering whether it is possible to compute the hash of a branch value in TTree::Draw().

Motivation: I need a random number, which I know I can get with rndm(). However, I need the random number to be reproducible on the event level. The value of rndm(), however, depends on how often it has been called. For example, if you do

the result differs from the left column in

I imagine this can be solved using a hash of the event number, but maybe there is another way. Do you have any suggestions?

Best,
Peter

Hi Peter,

You could do something like:double Randomizer(UInt_t eventNumber) { // this or any other 'hashing/randomizing' algorithm. TRandom3 engine(eventNumber); // setting the seed. return engine.Rndm(); }and then

You can also have multiple argument to the function (as long as they are not arrays).

Cheers,
Philippe.

TRandom3 engine(eventNumber + 1); // make sure the seed is > 0

tree->Scan(“MET*Randomizer(Entry$)”);

Hi,

Thanks! Why does the seed need to be positive?

Cheers,
Peter

Hi Peter,

A zero value often means to use a randomized starting point (i.e. it would prevent the full reproducability your are looking for).

Cheers,
Philippe.