| 1 | \chapter{Global Usage}
|
|---|
| 2 |
|
|---|
| 3 | \section{Design Philosophy}
|
|---|
| 4 | The global category covers the system of units, constants, numerics and
|
|---|
| 5 | random number handling. It can be considered a place-holder for
|
|---|
| 6 | "general purpose" classes used by all categories defined in {\sc Geant4}.
|
|---|
| 7 | No back-dependencies to other {\sc Geant4} categories affect the "global"
|
|---|
| 8 | domain. There are direct dependencies of the global category on external
|
|---|
| 9 | packages, such as CLHEP, STL, and miscellaneous system utilities.
|
|---|
| 10 |
|
|---|
| 11 | Within the management sub-category are ``utility'' classes generally used
|
|---|
| 12 | within the {\sc Geant4} kernel. They are, for the most part, uncorrelated
|
|---|
| 13 | with one another and include:
|
|---|
| 14 | \begin{itemize}
|
|---|
| 15 | \item {\it G4Allocator}
|
|---|
| 16 | \item {\it G4FastVector}
|
|---|
| 17 | \item {\it G4ReferenceCountedHandle}
|
|---|
| 18 | \item {\it G4PhysicsVector, G4LPhysicsFreeVector, G4PhysicsOrderedFreeVector}
|
|---|
| 19 | \item {\it G4Timer}
|
|---|
| 20 | \item {\it G4UserLimits}
|
|---|
| 21 | \item {\it G4UnitsTable}
|
|---|
| 22 | \end{itemize}
|
|---|
| 23 | A general description of these classes is given in section 3.2 of the
|
|---|
| 24 | {\sc Geant4} User's Guide for Application Developers.
|
|---|
| 25 |
|
|---|
| 26 | In applications where it is necessary to generate random numbers (normally
|
|---|
| 27 | from the same engine) in many different methods and parts of the program, it
|
|---|
| 28 | is highly desirable not to rely on or require knowledge of the global objects
|
|---|
| 29 | instantiated. By using static methods via a unique generator, the randomness
|
|---|
| 30 | of a sequence of numbers is best assured. Hence the use of a static generator
|
|---|
| 31 | has been introduced in the original design of HEPRandom as a project
|
|---|
| 32 | requirement in {\sc Geant4}.
|
|---|
| 33 |
|
|---|
| 34 | \section{Class Design}
|
|---|
| 35 |
|
|---|
| 36 | Analysis and design of the HEPRandom module have been achieved following
|
|---|
| 37 | the Booch Object-Oriented methodology. Some of the original design
|
|---|
| 38 | diagrams in Booch notation are reported below. Fig. \ref{figure:random-1}
|
|---|
| 39 | is a general picture of the static class diagram.
|
|---|
| 40 |
|
|---|
| 41 | \begin{itemize}
|
|---|
| 42 | \item {\bf HepRandomEngine} -
|
|---|
| 43 | abstract class defining the interface for each Random engine. Its pure
|
|---|
| 44 | virtual methods must be defined by its subclasses representing the
|
|---|
| 45 | concrete Random engines.
|
|---|
| 46 | \item {\bf HepJamesRandom} -
|
|---|
| 47 | class inheriting from HepRandomEngine and defining a flat random number
|
|---|
| 48 | generator according to the algorithm described in
|
|---|
| 49 | "F.James, Comp.Phys.Comm. 60 (1990) 329". This class is instantiated by
|
|---|
| 50 | default as the default random engine.
|
|---|
| 51 | \item {\bf DRand48Engine} -
|
|---|
| 52 | class inheriting from HepRandomEngine and defining a flat random number
|
|---|
| 53 | generator according to the drand48() and srand48() system functions from
|
|---|
| 54 | the C standard library.
|
|---|
| 55 | \item {\bf RandEngine} -
|
|---|
| 56 | class inheriting from HepRandomEngine and defining a flat random number
|
|---|
| 57 | generator according to the rand() and srand() system functions from the
|
|---|
| 58 | C standard library.
|
|---|
| 59 | \item {\bf RanluxEngine} -
|
|---|
| 60 | class inheriting from HepRandomEngine and defining a flat random number
|
|---|
| 61 | generator according to the algorithm described in
|
|---|
| 62 | "F.James, Comp.Phys.Comm. 60 (1990) 329-344" and originally implemented
|
|---|
| 63 | in FORTRAN 77 as part of the MATHLIB HEP library. It provides 5 different
|
|---|
| 64 | "luxury" levels [0..4].
|
|---|
| 65 | \item {\bf RanecuEngine} -
|
|---|
| 66 | class inheriting from HepRandomEngine and defining a flat random number
|
|---|
| 67 | generator according to the algorithm RANECU originally written in
|
|---|
| 68 | FORTRAN 77 as part of the MATHLIB HEP library. It uses a table of seeds
|
|---|
| 69 | which provides uncorrelated couples of seed values.
|
|---|
| 70 | \item {\bf HepRandom} -
|
|---|
| 71 | the main class collecting all the methods defining the different random
|
|---|
| 72 | generators applied to HepRandomEngine. It is a singleton class which all
|
|---|
| 73 | the distribution classes derive from. This singleton is instantiated by
|
|---|
| 74 | default.
|
|---|
| 75 | \item {\bf RandFlat} -
|
|---|
| 76 | distribution class for flat random number generation. It also provides
|
|---|
| 77 | methods to fill an array of flat random values, given its size or shoot
|
|---|
| 78 | bits.
|
|---|
| 79 | \item {\bf RandExponential} -
|
|---|
| 80 | distribution class defining exponential random number distribution, given
|
|---|
| 81 | a mean. It also provides a method to fill an array of flat random values,
|
|---|
| 82 | given its size.
|
|---|
| 83 | \item {\bf RandGauss} -
|
|---|
| 84 | distribution class defining Gauss random number distribution, given a
|
|---|
| 85 | mean or specifying also a deviation. It also provides a method to fill
|
|---|
| 86 | an array of flat random values, given its size.
|
|---|
| 87 | \item {\bf RandBreitWigner} -
|
|---|
| 88 | distribution class defining the Breit-Wigner random number distribution.
|
|---|
| 89 | It also provides a method to fill an array of flat random values, given
|
|---|
| 90 | its size.
|
|---|
| 91 | \item {\bf RandPoisson} -
|
|---|
| 92 | distribution class defining Poisson random number distribution, given a
|
|---|
| 93 | mean. It also provides a method to fill an array of flat random values,
|
|---|
| 94 | given its size.
|
|---|
| 95 | \end{itemize}
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | \begin{figure}[h!]
|
|---|
| 99 | \includegraphics[angle=0,scale=0.6]{OOAnalysisDesign/GlobalUsage/classDgmRandom.eps}
|
|---|
| 100 | \vspace{10pt}
|
|---|
| 101 | \caption{HEPRandom module}
|
|---|
| 102 | \label{figure:random-1}
|
|---|
| 103 | \end{figure}
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | Fig. \ref{figure:random-2} is a dynamic object diagram illustrating the
|
|---|
| 107 | situation when a single random number is thrown by the static generator
|
|---|
| 108 | according to one of the available distributions. Only one engine is
|
|---|
| 109 | assumed to active at a time.
|
|---|
| 110 |
|
|---|
| 111 | \begin{figure}[h!]
|
|---|
| 112 | \includegraphics[angle=0,scale=0.6]{OOAnalysisDesign/GlobalUsage/ObjDiagStat.eps}
|
|---|
| 113 | \vspace{10pt}
|
|---|
| 114 | \caption{Shooting via the generator}
|
|---|
| 115 | \label{figure:random-2}
|
|---|
| 116 | \end{figure}
|
|---|
| 117 |
|
|---|
| 118 | Fig. \ref{figure:random-3} illustrates a random number being thrown by
|
|---|
| 119 | explicitly specifying an engine which can be shared by many distribution
|
|---|
| 120 | objects. The static interface is skipped here.
|
|---|
| 121 |
|
|---|
| 122 | \begin{figure}[h!]
|
|---|
| 123 | \includegraphics[angle=0,scale=0.6]{OOAnalysisDesign/GlobalUsage/ObjDiagDist.eps}
|
|---|
| 124 | \vspace{10pt}
|
|---|
| 125 | \caption{Shooting via distribution objects}
|
|---|
| 126 | \label{figure:random-3}
|
|---|
| 127 | \end{figure}
|
|---|
| 128 |
|
|---|
| 129 | Fig. \ref{figure:random-4} illustrates the situation when many generators are
|
|---|
| 130 | defined, each by a distribution and an engine. The static interface is
|
|---|
| 131 | skipped here.
|
|---|
| 132 |
|
|---|
| 133 | \begin{figure}[h!]
|
|---|
| 134 | \includegraphics[angle=0,scale=0.6]{OOAnalysisDesign/GlobalUsage/ObjDiagEng.eps}
|
|---|
| 135 | \vspace{10pt}
|
|---|
| 136 | \caption{Shooting with arbitrary engines}
|
|---|
| 137 | \label{figure:random-4}
|
|---|
| 138 | \end{figure}
|
|---|
| 139 |
|
|---|
| 140 | For detailed documentation about the HEPRandom classes see the
|
|---|
| 141 | CLHEP Reference Guide\newline
|
|---|
| 142 | (http://cern.ch/clhep/manual/RefGuide)\newline
|
|---|
| 143 | or the CLHEP User Manual\newline
|
|---|
| 144 | (http://cern.ch/clhep/manual/UserGuide).\newline
|
|---|
| 145 | Informations written in this manual are extracted
|
|---|
| 146 | from the original manifesto distributed with the HEPRandom package\newline
|
|---|
| 147 | (http://cern.ch/clhep/manual/UserGuide/Random/Random.html).
|
|---|
| 148 |
|
|---|
| 149 | \paragraph{HEPNumerics}
|
|---|
| 150 | The HEPNumerics module includes a set of classes which implement numerical
|
|---|
| 151 | algorithms for general use in {\sc Geant4}. Section 3.2.3 of the User's Guide
|
|---|
| 152 | for Application Developers contains a description of each class. Most of
|
|---|
| 153 | the algorithms were implemented using methods from the following books:
|
|---|
| 154 | \mbox{}
|
|---|
| 155 | \begin{itemize}
|
|---|
| 156 | \item B.H. Flowers, "An introduction to Numerical Methods In C++",
|
|---|
| 157 | Claredon Press, Oxford 1995.
|
|---|
| 158 | \item M. Abramowitz, I. Stegun, "Handbook of mathematical functions",
|
|---|
| 159 | DOVER Publications INC, New York 1965 ; chapters 9, 10, and 22.
|
|---|
| 160 | \end{itemize}
|
|---|
| 161 |
|
|---|
| 162 | \paragraph{HEPGeometry}
|
|---|
| 163 | Documentation for the HEPGeometry module is provided in the CLHEP
|
|---|
| 164 | Reference Guide\newline
|
|---|
| 165 | (http://cern.ch/clhep/manual/RefGuide)
|
|---|
| 166 | or the CLHEP User Manual\newline
|
|---|
| 167 | (http://cern.ch/clhep/manual/UserGuide)
|
|---|
| 168 |
|
|---|
| 169 | \section{Status of this chapter}
|
|---|
| 170 |
|
|---|
| 171 | 01.12.02 minor update by G. Cosmo \\
|
|---|
| 172 | 18.06.05 introductory paragraphs added and minor grammar changes by D.H. Wright \\
|
|---|