Hi,
There is one of useful methods under TH1 or TF1 called GetRandom(), if looking into this method, it is based on gRandom->Rndm() to generate random numbers. However, this is further based on the class TRandom addessed to have defects. I am wondering if any choice to use TRandom3 to generate random numbers obeying given histograms or functions.
[quote=“zhiyiliu”]Hi,
There is one of useful methods under TH1 or TF1 called GetRandom(), if looking into this method, it is based on gRandom->Rndm() to generate random numbers. However, this is further based on the class TRandom addessed to have defects. I am wondering if any choice to use TRandom3 to generate random numbers obeying given histograms or functions. [/quote]
Here’s what I do at the beginning of all of my programs that use random numbers (for exactly the reason you stated).
delete gRandom;
gRandom = new TRandom3;
This is a nop. The default random generator (pointed by gRandom) is TRandom3 (unless you use a very old version).
[quote=“brun”]delete gRandom;
gRandom = new TRandom3;
This is a nop. The default random generator (pointed by gRandom) is TRandom3 (unless you use a very old version).
[/quote]
[quote=“brun”]your version is about 12 production releases old. :
[/quote]
Yes, that’s what happens when you have (a lot of) data. It can be particularly painful to switch when a fair bit of the API has changed (as is the case with Root).
Seeing as that would be a sequential and not even a binary search, it hardly seems worthwhile. Without a it’s version xxx, it seems safer to just
delete gRandom;
gRandom = new TRandom3;
Which is at worst a no-op and at best the right thing to do.
There are others that we found when trying to move to Root 5. If you are really interested, I can ask the people who spent the time porting the code.
Charles
p.s. One of our “favorites” is that we have no problem accessing data from our rootd servers from root 4, but it does not work if we run root 5. We still have no solution for this.
To be blunt, it hardly matters at ALL if the changes are documented. CDF is a running experiment with literally millions of lines of code that were written by many hundreds of different people. Every time you change the API, you make it extremely difficult for an experiment to change versions of Root.
Changing underlying structure is fine. Adding new features is great. Changing the API is bad.
Cheers,
Charles
p.s. O.k. If you change the API and don’t document it, I agree that that is worse. But not by as much as you might think.
[quote]p.s. One of our “favorites” is that we have no problem accessing data from our rootd servers from root 4, but it does not work if we run root 5. We still have no solution for this.[/quote]Note that in this case, the rootd server has actually been customized by CDF. And CDF and the developer supporting rootd have not been able to close the loop on the cause of the issue (in our test rootd is backward compatible …).
[quote]would work in Root 4, but not Root 5. It now needs to be…
treePtr->Branch (“electrons”, (void*) elecCLPTcaPtr); [/quote]Actually better yet:treePtr->Branch ("electrons", elecCLPTcaPtr);which, if I remember correctly, was actually the recommend syntax in root v4 (as opposed to the explicitly void* cast).
My point being, that unfortunately this is a slightly corner case, where we do support the old interface as it was intended but some legal (but more or so unexpected) use are not