Using the SLAC Installation of the Geant4 Toolkit
Last modified :
Current Installation
The latest Geant4 libraries are centrally maintained and installed so that users
may build and link their applications to them, rather than build and maintain
their own libraries.
Geant4 10.2 is now installed on the 32-bit and 64-bit Linux machines:
- rhel5-32
- rhel6-32
- rhel5-64
- rhel6-64
Older libraries, from Geant4 9.0 (patch02) onward, may also be accessed.
The previous version of this
document is also available.
Various data files required for optional Geant4 processes and models are also
centrally maintained and automatically accessed by the setup scripts.
Accessing the SLAC installation
To compile and link a simulation executable using the current Geant4 toolkit,
several environment variables must first be set. This is done in a script
which also chooses the combination of Geant4 libraries appropriate to the
computing platform. The scripts available for each machine are:
- /afs/slac/package/geant4/env-rhel5-32.csh (.sh)
- /afs/slac/package/geant4/env-rhel5-64.csh (.sh)
- /afs/slac/package/geant4/env-rhel6-32.csh (.sh)
- /afs/slac/package/geant4/env-rhel6-64.csh (.sh)
To begin:
- choose a work directory, and in it
- mkdir geant4_workdir
- cd geant4_workdir
- cp /afs/slac/package/geant4/env-rhel6-64.csh .
- source env-rhel6-64.csh (repeat this line each time you log in to this platform)
Here rhel6-64 was chosen as it is likely the most used platform.
The essential variables set by this file are:
- G4WORKDIR - working directory which will contain your specific code and the
binary application. By default, Geant4 scripts set this to $HOME/geant4_workdir.
If you wish to rename or move it, you must reset G4WORKDIR.
- G4SYSTEM - G4 code for the system architecture
Setup scripts for old versions are also available in /afs/slac/package/geant4/9.4.p03,
9.3.p02, and so on.
Visualization
Interfaces for several visualization drivers have been compiled into the toolkit
libraries. Currently the setup scripts choose OPENGL, but the user may choose
another driver by setting the appropriate environment variable before building
the executable. File-based visualization (that which writes output to .jpg,
.gif, etc.) is also supported.
Building and Running the Executable
The following steps will lead you to a working executable with visualization using
OPENGL. First, be sure that the environment is set. If you haven't already done
so, do one of the following:
- source env-rhel5-32.csh (.sh)
- source env-rhel5-64.csh (.sh)
- source env-rhel6-32.csh (.sh)
- source env-rhel6-64.csh (.sh)
The multithreading and debug libraries are available on the rhel6-64 system.
They may be accessed as follows:
- source env-rhel6-64-mt.csh (.sh)
- source env-rhel6-64-debug.csh (.sh)
Next, you may use either cmake or gmake to build an executable:
Using cmake
- go to your work directory
- copy from the Geant4 installation the code for example B4:
- cp -r $G4INSTALL/../examples/basic/B4 B4
- cd B4/B4a (B4a is chosen here but B4b through B4d are also available)
- cmake . (note: this is the command cmake followed by a space and a period)
- Within the current directory (in this case B4a), cmake will create a
directory named CMakeFiles which includes temporary files.
- MakeFile is also created in this directory.
- while in directory B4a, build the executable:
- then run it
Using gmake
- go to your work directory
- copy from the Geant4 installation the code for example B4:
- cp -r $G4INSTALL/../examples/basic/B4 B4
- cd B4/B4a
- gmake
- gmake will create tmp and bin directories in your work directory.
The executable, named exampleB4a, will be in $G4WORKDIR/bin/$G4SYSTEM/
- while in directory B4a, run the executable:
- $G4WORKDIR/bin/$G4SYSTEM/exampleB4a
If everything goes according to plan, you should see the Idle> prompt on your
screen (after some preliminary output). From this prompt type
- /run/beamOn 1
to see an event displayed. Repeat until you get tired or bored. Then:
- exit
to finish.
At this point you are ready to add to and modify the code in your copy of B4a.
For more information about developing your own simulation code using Geant4, see
the Application Developer's Guide .
Dennis Wright
Tatsumi Koi