Athena Developer Guide
Athena Developer Guide
Athena Developer Guide
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Athena</strong><br />
Chapter 13 Framework services Version/Issue: 2.0.0<br />
13.8 The Random Numbers Service<br />
When generating random numbers two issues must be considered:<br />
• reproducibility and<br />
• randomness of the generated numbers.<br />
In order to ensure both, <strong>Athena</strong> implements a single service ensuring that these criteria are met. The<br />
encapsulation of the actual random generator into a service has several advantages:<br />
• Random seeds are set by the framework. When debugging the detector simulation, the<br />
program could start at any event independent of the events simulated before. Unlike the<br />
random number generators that were known from CERNLIB, the state of modern generators<br />
is no longer defined by one or two numbers, but rather by a fairly large set of numbers. To<br />
ensure reproducibility the random number generator must be initialized for every event.<br />
• The distribution of the random numbers generated is independent of the random number<br />
engine behind. Any distribution can be generated starting from a flat distribution.<br />
• The actual number generator can easily be replaced if at some time in the future better<br />
generators become available, without affecting any user code.<br />
The implementation of both generators and random number engines are taken from CLHEP. The<br />
default random number engine used by <strong>Athena</strong> is the RanLux engine of CLHEP with a luxury level of<br />
3, which is also the default for Geant4, so as to use the same mechanism to generate random numbers as<br />
the detector simulation.<br />
Figure 13.1 shows the general architecture of the <strong>Athena</strong> random number service. The client interacts<br />
with the service in the following way:<br />
• The client requests a generator from the service, which is able to produce a generator<br />
according to a requested distribution. The client then retrieves the requested generator.<br />
• Behind the scenes, the generator service creates the requested generator and initializes the<br />
object according to the parameters. The service also supplies the shared random number<br />
engine to the generator.<br />
• After the client has finished using the generator, the object must be released in order to inhibit<br />
resource leaks<br />
Distribution:<br />
Gauss<br />
RndmGenSvc<br />
owns & initializes<br />
owns<br />
RndmGen<br />
uses<br />
RndmEngine<br />
Figure 13.1 The architecture of the random number service. The client requests from the service a random<br />
number generator satisfying certain criteria<br />
page 115