Decouple random number generators from random number distributions
As we discussed at the last meeting, it is probably not a good idea to have the RandomNumbersSvc care about random number distributions. Instead, we should follow in the footsteps of the C++11 and decouple the notion of a random number generator from that of a random number distribution, with the following separation of concerns:
- An algorithm execution (call to Algorithm::execute()) should spawn a single random number generator, if needed, reuse it for all of its random number generation needs, and pass it down to any other entity which needs random numbers (such as Tools).
- Individual code which uses random numbers should spawn an STL-like random number distribution object and use it with the above Alg-local generator as a source of randomness.
This merge request attempts to implement this design. What do you think about it? In particular, I'm not too sure about the design of the new LandauDist, additional input would be really appreciated here.
Fixes ACTSFW-37.
Merge request reports
Activity
The general changes look good to me. If have some questions regarding the
LandauDist
- Why does it need the extra
uniform_parameters
? - Can we make the interface a bit more STL-like, i.e.
operator()
templated on generator, constructor from parameters and from config object, same naming for sub_types
Edited by Moritz Kiehn- Why does it need the extra
Thanks for looking into this. The LandauDist was basically copy-pasted from the original drawLandau() method of the Generator without attempting to understand it, and could certainly use more work from someone more familiar with it.
Looking at the landau_quantile source code, I get the impression that it expects z to originate specifically from the standard uniform distribution operating in the [0, 1] range, with a per-mille resolution. Is that the case? If so, I can indeed get rid of the uniform_parameters and simplify further.
I'll try to move to an STL-compatible interface as well, however that may take more time as the STL has an extremely precise and elaborate idea of what a random number distribution should be like.
Edited by Hadrien Benjamin Graslandmentioned in merge request !39 (merged)
I just saw that the Fatras example (https://gitlab.cern.ch/acts/acts-test-fw/blob/master/Examples/Fatras/src/FatrasExampleBase.hpp#L74) needs to be adjusted - there are still three random number services initialized.
...and this is done as well. Now, LandauDist is pretty close to STL compliance (it only misses the serialization features to be a true STL RandomNumberDistribution), and it does not have the uniform parameters anymore.
Edited by Hadrien Benjamin Graslandadded 1 commit
- e2ed55ce - Extracted random number distributions to a dedicated code unit
mentioned in commit f0906b3f