Using the SLAC Installation of the Geant4 Toolkit
Last modified :
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 9.4 is now installed on the 32-bit and 64-bit Linux machines:
Access to older libraries, including Geant4 9.3 (patch02) is available upon
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 and CLHEP libraries appropriate
to the computing platform. The script can be found in
The essential variables set by this file are:
- choose a work directory, and in it,
- mkdir geant4
- cd geant4
- cp /afs/slac/package/geant4/g4setup.env .
- source g4setup.env
g4setup.env must be sourced each time you log in and want to rebuild or run the executable.
If you log in to a generic machine (e.g. noric) as opposed to a specific one (e.g. noric10),
the machine, and hence the libraries may be different. In this case, clean and rebuild your
- G4WORKDIR - working directory which will contain your specific code and the binary application
- G4INSTALL - location of the installed code and libraries
- G4SYSTEM - G4 code for the system architecture
- CLHEP_BASE_DIR - base directory of the CLHEP libraries against which the toolkitis linked and
against which your code should be linked
- CLHEP_LIB - location in the SLAC directory structure of CLHEP libraries built for a given platform
Alternate method: if you know the specific platform you are using (rhel4-32, for example):
- mkdir geant4
- cd geant4
- cp /afs/slac/package/geant4/9.4/env-rhel4-32.csh .
- source env-rhel4-32.csh (repeat this line each time you log in to this platform)
- .sh versions of this script are also available
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.
Building and Running the Executable
The following steps will lead you to a working executable with visualization using OPENGL:
At this point you are ready to add to and modify the code in your copy of N03.
For more information about developing your own simulation code using Geant4, see
the Application Developer's Guide .
- go to your work directory (in the above example, geant4)
- from the Geant4 installation copy the code for example 3:
- cp -r $G4INSTALL/examples/novice/N03 N03
- cd to N03
- gmake will create tmp and bin directories in your work directory. The executable, named exampleN03, will be in /bin/$G4SYSTEM/
- while in directory N03, run the executable:
- if everything goes according to plan, you should see the Idle> prompt on your screen (after some preliminary output). From this prompt type
to see an event displayed. Repeat until you get tired or bored.
- when finished type
at the Idle> prompt.