2.11.  Global Usage

2.11.1.  Design Philosophy

The global category covers the system of units, constants, numerics and random number handling. It can be considered a place-holder for "general purpose" classes used by all categories defined in Geant4. No back-dependencies to other Geant4 categories affect the "global" domain. There are direct dependencies of the global category on external packages, such as CLHEP, STL, and miscellaneous system utilities.

Within the management sub-category are ``utility'' classes generally used within the Geant4 kernel. They are, for the most part, uncorrelated with one another and include:

  • G4Allocator

  • G4FastVector

  • G4ReferenceCountedHandle

  • G4PhysicsVector, G4LPhysicsFreeVector, G4PhysicsOrderedFreeVector

  • G4Timer

  • G4UserLimits

  • G4UnitsTable

A general description of these classes is given in section 3.2 of the Geant4 User's Guide for Application Developers.

In applications where it is necessary to generate random numbers (normally from the same engine) in many different methods and parts of the program, it is highly desirable not to rely on or require knowledge of the global objects instantiated. By using static methods via a unique generator, the randomness of a sequence of numbers is best assured. Hence the use of a static generator has been introduced in the original design of HEPRandom as a project requirement in Geant4.

2.11.2.  Class Design

Analysis and design of the HEPRandom module have been achieved following the Booch Object-Oriented methodology. Some of the original design diagrams in Booch notation are reported below. Figure 2.17 is a general picture of the static class diagram.

  • HepRandomEngine - abstract class defining the interface for each Random engine. Its pure virtual methods must be defined by its subclasses representing the concrete Random engines.

  • HepJamesRandom - class inheriting from HepRandomEngine and defining a flat random number generator according to the algorithm described in "F.James, Comp.Phys.Comm. 60 (1990) 329". This class is instantiated by default as the default random engine.

  • DRand48Engine - class inheriting from HepRandomEngine and defining a flat random number generator according to the drand48() and srand48() system functions from the C standard library.

  • RandEngine - class inheriting from HepRandomEngine and defining a flat random number generator according to the rand() and srand() system functions from the C standard library.

  • RanluxEngine - class inheriting from HepRandomEngine and defining a flat random number generator according to the algorithm described in "F.James, Comp.Phys.Comm. 60 (1990) 329-344" and originally implemented in FORTRAN 77 as part of the MATHLIB HEP library. It provides 5 different "luxury" levels [0..4].

  • RanecuEngine - class inheriting from HepRandomEngine and defining a flat random number generator according to the algorithm RANECU originally written in FORTRAN 77 as part of the MATHLIB HEP library. It uses a table of seeds which provides uncorrelated couples of seed values.

  • HepRandom - the main class collecting all the methods defining the different random generators applied to HepRandomEngine. It is a singleton class which all the distribution classes derive from. This singleton is instantiated by default.

  • RandFlat - distribution class for flat random number generation. It also provides methods to fill an array of flat random values, given its size or shoot bits.

  • RandExponential - distribution class defining exponential random number distribution, given a mean. It also provides a method to fill an array of flat random values, given its size.

  • RandGauss - distribution class defining Gauss random number distribution, given a mean or specifying also a deviation. It also provides a method to fill an array of flat random values, given its size.

  • RandBreitWigner - distribution class defining the Breit-Wigner random number distribution. It also provides a method to fill an array of flat random values, given its size.

  • RandPoisson - distribution class defining Poisson random number distribution, given a mean. It also provides a method to fill an array of flat random values, given its size.

HEPRandom module

Figure 2.17.  HEPRandom module


Figure 2.18 is a dynamic object diagram illustrating the situation when a single random number is thrown by the static generator according to one of the available distributions. Only one engine is assumed to active at a time.

Shooting via the generator

Figure 2.18.  Shooting via the generator


Figure 2.19 illustrates a random number being thrown by explicitly specifying an engine which can be shared by many distribution objects. The static interface is skipped here.

Shooting via distribution objects

Figure 2.19.  Shooting via distribution objects


Figure 2.20 illustrates the situation when many generators are defined, each by a distribution and an engine. The static interface is skipped here.

Shooting with arbitrary engines

Figure 2.20.  Shooting with arbitrary engines


For detailed documentation about the HEPRandom classes see the CLHEP Reference Guide(http://cern.ch/clhep/manual/RefGuide) or the CLHEP User Manua(http://cern.ch/clhep/manual/UserGuide).

Informations written in this manual are extracted from the original manifesto distributed with the HEPRandom package (http://cern.ch/clhep/manual/UserGuide/Random/Random.html).

HEPNumerics

The HEPNumerics module includes a set of classes which implement numerical algorithms for general use in Geant4. The User's Guide for Application Developers contains a description of each class. Most of the algorithms were implemented using methods from the following books:

  • B.H. Flowers, "An introduction to Numerical Methods In C++", Claredon Press, Oxford 1995.

  • M. Abramowitz, I. Stegun, "Handbook of mathematical functions", DOVER Publications INC, New York 1965 ; chapters 9, 10, and 22.

HEPGeometry

Documentation for the HEPGeometry module is provided in the CLHEP Reference Guide(http://cern.ch/clhep/manual/RefGuide) or the CLHEP User Manual(http://cern.ch/clhep/manual/UserGuide).

[Status of this chapter]

01.12.02 minor update by G. Cosmo
18.06.05 introductory paragraphs added and minor grammar changes by D.H. Wright
Dec. 2006 Conversion from latex to Docbook verson by K. Amako