The Geant4 toolkit [SA03][JA09][eal16] uses a combination of the composition and rejection Monte Carlo methods. Only the basic formalism of these methods is outlined here. For a complete account of the Monte Carlo methods, the interested user is referred to the publications of Butcher and Messel, Messel and Crawford, or Ford and Nelson [BM60][MC70][NHR85].

Suppose we wish to sample \(x\) in the interval \([x_1,\ x_2]\) from the distribution \(f(x)\) and the normalised probability density function can be written as :

\[f(x) = \sum_{i=1}^{n} N_{i} f_{i} (x) g_{i} (x)\]

where \(N_i>0\), \(f_i(x)\) are normalised density functions on \([x_1,\ x_2]\) , and \(0 \leq g_i (x) \leq 1\).

According to this method, \(x\) can sampled in the following way:

  1. select a random integer \(i \in \{1,2,\cdots n\}\) with probability proportional to \(N_i \)

  2. select a value \(x_0\) from the distribution \(f_i (x)\)

  3. calculate \(g_i (x_0)\) and accept \(x = x_0\) with probability \(g_i (x_0)\);

  4. if \(x_0\) is rejected restart from step 1.

It can be shown that this scheme is correct and the mean number of tries to accept a value is \(\sum_{i} N_i \).

In practice, a good method of sampling from the distribution \(f(x)\) has the following properties:

  • all the subdistributions \(f_i (x)\) can be sampled easily;

  • the rejection functions \(g_i(x)\) can be evaluated easily/quickly;

  • the mean number of tries is not too large.

Thus the different possible decompositions of the distribution \(f(x)\) are not equivalent from the practical point of view (e.g. they can be very different in computational speed) and it can be useful to optimise the decomposition.

A remark of practical importance : if our distribution is not normalised

\[\int_{x_1}^{x_2} f(x)dx = C > 0\]

the method can be used in the same manner; the mean number of tries in this case is \(\sum_ {i} N_i/C\).

Bibliography

BM60

J.C. Butcher and H. Messel. Nucl. Phys., 20(15):, 1960.

eal16

J. Allison et al. Recent developments in geant4. Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 835:186–225, nov 2016. URL: https://doi.org/10.1016/j.nima.2016.06.125, doi:10.1016/j.nima.2016.06.125.

JA09

et al. J. Apostolakis. Geometry and physics of the geant4 toolkit for high and medium energy applications. Radiation Physics and Chemistry, 78(10):859–873, oct 2009. URL: https://doi.org/10.1016/j.radphyschem.2009.04.026, doi:10.1016/j.radphyschem.2009.04.026.

MC70

H. Messel and D. Crawford. Electron-Photon shower distribution. Pergamon Press, 1970.

NHR85

W.R. Nelson, H. Hirayama, and D.W.O. Rogers. EGS4 code system. SLAC, Dec 1985. SLAC-265, UC-32.

SA03

et al. S. Agostinelli. Geant4—a simulation toolkit. Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 506(3):250–303, jul 2003. URL: https://doi.org/10.1016/S0168-9002(03)01368-8, doi:10.1016/s0168-9002(03)01368-8.