I’ve come across a very strange problem involving TLatex, which affects the standard C++ random number generator. (I’m using Root 5.34.32).
When drawing a TLatex object to a canvas, and then printing that canvas, the state of the C++ random number generator is somehow affected. Here is a minimal program to demonstrate what happens:
If I run that multiple times, I get different random numbers in the second lot of 10 each time I run the program.
This behaviour only seems to occur for some print options (I’ve tested PDF, JPG and PNG files). If print out a root macro (.C), the sequence of random numbers is not affected.
It seems to be fine w/ the current major version of ROOT, i.e. ROOT 6. It is fine as well when using ROOT in batch mode. Maybe that helps circumventing your problem for now.
From my reading of that page, if you require reproducible random numbers with library calls in between, you can’t rely on std::rand(). There are other options that have better guarantees: http://en.cppreference.com/w/cpp/numeric/random
Disclaimer: This is just after a few minutes of googling about this problem, I am not an official C++ expert. = )
Jean-François