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 9.5 is now installed on the 32-bit and 64-bit Linux machines: Access to older libraries, including Geant4 9.3 (patch02) and 9.4 (patch03), are available upon request. 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 and CLHEP libraries appropriate to the computing platform. The script can be found in


To begin: The essential variables set by this file are: g4setup.env must be sourced each time you log in and want to rebuild or run the executable.

This script decides which generic machine (rhel5-32, etc.) is being used and chooses Geant4 libraries accordingly. If you build user code on one type of generic machine and later log on to a different one and try to run, you may have problems. In that case, either switch back to the original machine type or clean and re-build your code on the current one.

Alternate method: if you know the specific platform you are using (rhel5-32, for example): .sh versions of this script are also available. Setup scripts for old versions are also available in /afs/slac/package/geant4/9.4.p03, 9.3.p02, and so on.


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.

Note that on rhel6 machines, there are problems with visualizations using pop-up windows. This feature failed on the central unix machines when using a local desktop X-server (XWIN32). This issue is currently being investigated. If you need this type of visualization, please use the rhel5 machines. File-based visualizations, that is, those which are written to .jpg, .gif, etc., work well on either rhel5 or rhel6 systems.

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 or, if you followed the alternate method above, do one of the following: Next, you may use either gmake or cmake to build an executable: If everything goes according to plan, you should see the Idle> prompt on your screen (after some preliminary output). From this prompt type 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 .
Dennis Wright
Tatsumi Koi