Software/Geant4/Installation
Installation Of Geant4 And Supporting Packages
The CERN Geant4 Installation Guide provides extensive instructions on installing Geant4. This provides an overview of the installation procedure, as well as a list of prerequisites and additional software that need to be installed alongside Geant4.
In addition, information is given on the installation procedure for this additional software and the location the software is installed on the UCL HEP Linux Cluster.
The environment
described here is the combination of files, folders, settings and user interface that allow users to make use of Geant4
and related software packages for particle beam therapy simulations.
Accessing the environment requires the following:
- Access to the filesystem and required folders.
- Terminal access to run simulations.
- A visualisation engine such as OpenGL on X (optional).
- Setting environment variables to point to installed software and scripts.
The order of installation is important, as some packages depend on having the other packages first. In some cases, installations will be successful if carried out in the wrong order, but some features will be disabled that should be enabled. The order of packages described below is the order in which these packages were installed into the PBT environment.
Required Software
The list of required software is split into 2 categories:
- Prerequisites are those components that are required in order for some part of
Geant4
or the resulting simulation visualisations to function correctly; - Add Ons are optional pieces of software — normally visualisation software — that are installed on the UCL HEP Linux Cluster.
See the individually linked pages for information on building each of the components that do not ship by default.
Prerequisites
The CERN Geant4 Installation Guide provides extensive information on software that must be installed to compile Geant4 itself and software required in order to compile optional components of Geant4.
These are:
- A C++11 compatible compiler: on Linux, this is
GCC
: the GNU Compiler Collection which is installed by default. CMake
required for building the variousGeant4
simulations throughcmake
files.- The
CLHEP
Class Library that provides a range of foundation and utility classes needed forGeant4
simulations.
OpenGL
headers and libraries to provide support forOpenGL
graphics (graphics card specific; installed by default on most Operating Systems).X11
headers and libraries to provide support for theX
-Window system (installed by default on *nix systemsQt4
orQt5
headers and libraries to provide support for the Qt user interface and visualisation.Xerces-C++
headers and libraries compiled against the C++11 standard to provide support for GDML geometry descriptions.Motif
and X11 headers and libraries to provide support for the Motif user interface and visualisation (installed by default on Linux)Coin3D
for Open Inventor visualisation (Coin3D
is a free implementation of Open Inventor). This requires the following libraries to be installed:- The
simage
library with image format loaders and front-ends to common import libraries.simage
is meant for use with applications which read image files as textures.simage
must be installed beforeCoin3D
. - The
SoXt
open source InventorXt library, which is a GUI binding for using Open Inventor with Xt/Motif.SoXt
must be installed afterCoin3D
. SoQt
open sourceQt
GUI component toolkit library forCoin3D
.SoQt
must be installed afterCoin3D
.
- The
By default some of these will ship pre-installed with most modern Linux distributions: however the expat
and mesa
generally need to be installed alongside the software listed above.
Add Ons
The CERN Geant4 Installation Guide provides a range of
software suggested for use with Geant4
.
While none of these need to be installed for Geant4
to compile and run, they are useful for visualising the resulting simulations.
The following subset is installed on the UCL HEP Cluster:
- The
DAWN
postscript renderer to support the DAWN visualisation driver. - The
HepRApp
Browser for use with the HepRep visualisation driver. - The
Java Analysis Studio
(JAS3
), along with theWIRED4 JAS Plug-IN
for use with the HepRep visualisation driver. - The
gMocren
volume visualiser forGeant4
medical simulations.
Details
- Website
- http://geant4.web.cern.ch/geant4/
- Source URL
- http://geant4.web.cern.ch/geant4/support/download.shtml
- Latest Production version
- 10.2.p01 (26 Feb 2016)
- Source tarball
src/geant4/geant4.10.02.p01.tar.gz
- Latest Development version
- 10.3.02.p02 (20 October 2017)
- Central Repository
- https://github.com/Geant4/geant4
Installation Instructions
The installation process follows the general process described on the UCL HEP Linux Cluster page. The basic method used is as follows:
- Check that all the prerequisites for building
Geant4
are installed (see above); - Download the latest version of the source code;
- Extract the source code from the downloaded tarball;
- Create a build folder;
- Configure, build and install
Geant4
from within the build folder.
Configure, Build and Install Geant4
Installation from Central Repository
After the latest version has been pulled from its central repository and placed within /unix/pbt/software/src/geant4, create a build directory within the PBT software directory from which you can compile the code:
cd /unix/pbt/software/build/ mkdir geant4 cd geant4
CMake can then be used to configure and install Geant4
.
cmake ../../src/geant4/ ccmake .
The command ccmake .
opens an interactive GUI that can be used to specify installation options. From within this you can define your installation directory and configure any other options as required. On the PBT cluster it is required that the software is installed to the development directory and certain options are set, and so the configuration is defined as follows:
CMAKE_INSTALL_PREFIX /unix/pbt/dev/geant-4.10.3.p02 CMAKE_INSTALL_CONFIG_NAME RelWithDebInfo GEANT4_BUILD_MULTITHREADED OFF GEANT4_INSTALL_DATA ON GEANT4_BUILD_EXAMPLES OFF GEANT4_BUILD_TESTS OFF GEANT4_BUILD_STORE_TRAJECTORY ON GEANT4_BUILD_VERBOSE_CODE ON GEANT4_USE_G3TOG4 ON GEANT4_USE_GDML ON GEANT4_USE_INVENTOR ON GEANT4_USE_NETWORKDAWN ON GEANT4_USE_NETWORKVRML ON GEANT4_USE_OPENGL_X11 ON GEANT4_USE_QT ON GEANT4_USE_RAYTRACER_X11 ON GEANT4_USE_SYSTEM_CLHEP ON GEANT4_USE_SYSTEM_EXPAT ON GEANT4_USE_SYSTEM_ZLIB ON GEANT4_USE_XM ON
Note: The option GEANT4_BUILD_MULTITHREADED
is set to OFF
to allow compatibility with BDSIM
.
- c to configure
At this point, often the configuration is interrupted as the system cannot find all the necessary prerequisites. Enter any required base directories manually, e.g.
CLHEP_BASE_DIR /unix/pbt/software/dev/clhep-2.3.4.5
- c to configure
- g to generate and exit
The software can then be installed using the usual commands:
make make install
Installation from source code
The Geant4
source code can be downloaded from the Geant4 Download Page of the Geant4 website given above.
Unless there is a very good reason for not doing so, it is always recommended to use the latest version: each version features incremental improvements and bug fixes over earlier version and normally also features superior physics modelling.
Alongside the Geant4
download, there are also a number of data files available for modelling particular processes.
These do not need to be downloaded separately as they can be added during Geant4
installation by setting the -DGEANT4_INSTALL_DATA=ON
compilation flag when running cmake
(see below).
The Geant4
source code is normally downloaded as a single gzipped tar
-file.
This needs to be extracted with the following command:
tar -xvz -f geant4.10.02.p01.tar.gz
This will extract the Geant4
source code into a directory alongside the tar
-file.
This directory can be renamed: it does not need to be kept the same for the installation described below to work, although the correct directory name should be substituted for the default name used below.
Once the source code has been extracted, a build
directory should be created alongside the src
to hold the compiled Geant4
files before they are moved to their final installation location.
On the UCL HEP Linux Cluster, the build
directory should be created in /unix/pbt/software/build
:
cd /unix/pbt/software/build mkdir geant4 cd geant4 mkdir geant4.10.02.p01-build cd geant4.10.02.p01-build
Unlike other software installed on the UCL HEP Linux Cluster, there are a number of ways to configure the software before building.
Using the ccmake
command, each configuration option can be set interactively.
Alternatively, the cmake
command below configures with the recommended options.
Note that the -DCMAKE_INSTALL_PREFIX="/unix/pbt/software/prod-sl6"
flag specifies that the resulting Geant4
should be installed in the directory /unix/pbt/software/prod-sl6
after compilation: this should be changed to suit the particular installation in question.
Installation commands:
cd /unix/pbt/software/build/geant4/geant4.10.02.p01-prod-sl6 cmake \ -DCMAKE_INSTALL_PREFIX="/unix/pbt/software/prod-sl6" \ -DCMAKE_INSTALL_CONFIG_NAME="ReleaseWithDebInfo" \ -DGEANT4_BUILD_MULTITHREADED=ON \ -DGEANT4_INSTALL_DATA=ON \ -DGEANT4_BUILD_EXAMPLES=OFF \ -DGEANT4_BUILD_TESTS=OFF \ -DGEANT4_ENABLE_TESTING=OFF \ -DGEANT4_BUILD_STORE_TRAJECTORY=ON \ -DGEANT4_BUILD_VERBOSE_CODE=ON \ -DGEANT4_USE_G3TOG4=ON \ -DGEANT4_USE_GDML=ON \ -DGEANT4_USE_INVENTOR=ON \ -DGEANT4_USE_NETWORKDAWN=ON \ -DGEANT4_USE_NETWORKVRML=ON \ -DGEANT4_USE_OPENGL_X11=ON \ -DGEANT4_USE_QT=ON \ -DGEANT4_USE_RAYTRACER_X11=ON \ -DGEANT4_USE_SYSTEM_CLHEP=ON \ -DGEANT4_USE_SYSTEM_EXPAT=ON \ -DGEANT4_USE_SYSTEM_ZLIB=ON \ -DGEANT4_USE_XM=ON \ /unix/pbt/software/src/geant4/geant4.10.02.p01-source make make install
Testing
Software package tests
GEANT4 built-in tests
The GEANT4
software includes some system tests, which can be included in the installation command via the options -DGEANT4_BUILD_TESTS=ON -DGEANT4_ENABLE_TESTING=ON
.
However, these tests are only used for testing of the system, and are not included in the distributed source tarballs, nor supported for use by end-users.
Therefore, these cannot easily be used for validation of the production system installation.
GEANT4 examples
One test of the GEANT4
software after installation is to make sure that all examples can be run and produce the expected results.
Notes:
- The examples can be built at installation time using the command
-DGEANT4_BUILD_EXAMPLES=ON
, but this throws up a number of problems because not all installation requirements are met. It is easier to build and run the examples after the installation is complete. - Environment variable
G4SHARE
is defined in the environment scriptspbt.bashrc
andpbt-dev.bashrc
, along with the variableG4VERSION
. For the current installation, the location stored in this variable is/unix/pbt/software/dev/share/Geant4-10.0.2
The following errors and warnings were seen while configuring examples:
- Cannot find
AIDA
package - Cannot find
HBOOK
package - Cannot find
HepMC
package - Cannot find
Pythia6
package - Cannot find
GCCXML
These packages are optional, but some of the examples are designed to demonstrate the connection with these packages. Note that some filetypes, such asAIDA
andHBOOK
, do in fact have viewers installed in the PBT environments, but these are not available to theGEANT4
system. This what the errors are reporting.
Basic examples
B1
cp -r ${G4SHARE}/examples/basic/B1 . mkdir build cd build cmake ../B1 make ./exampleB1 exampleB1.in | tee exampleB1.new.out grep -B0 -A3 "End of Global Run" exampleB1.out > exampleB1.old.results grep -B0 -A3 "End of Global Run" exampleB1.new.out > exampleB1.new.results diff exampleB1.old.results exampleB1.new.results
The newly generated simulation results contain similar but not identical values to those in the included exampleB1.out
file.
This is due to the fact that the results depend on the initial state of the random number generator. The random seed used to generate the example output is unknown.
B1 visualisation
The example, when run without arguments, opens in interactive mode using the visualisation driver selected in the file vis.mac:
./exampleB1
The various visualisation packages can be tested by editing vis.mac to select the appropriate package. Some drivers create an interactive view of the simulation geometry. Others write to a file which can be viewed using an external software package e.g. DAWN - see the geant manual for details.
Most packages are listed in the file in lines beginning /vis/open
and can be uncommented to select, e.g.
/vis/open OGL 600x600-0+0
RayTracerX is not listed in the file but can be enabled by uncommenting the other /vis/open lines and adding the following line:
/vis/open RayTracerX