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.4 is now installed on the 32-bit and 64-bit Linux machines:
- rhel4-32
- rhel5-32
- rhel4-64
- rhel5-64
Access to older libraries, including Geant4 9.3 (patch02) is available upon
request.
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
/afs/slac/package/geant4/g4setup.env
To begin:
- choose a work directory, and in it,
- mkdir geant4
- cd geant4
- cp /afs/slac/package/geant4/g4setup.env .
- source g4setup.env
The essential variables set by this file are:
- 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
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
application.
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
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.
Building and Running the Executable
The following steps will lead you to a working executable with visualization using OPENGL:
- 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
- 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:
- ../bin/$G4SYSTEM/exampleN03
- 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.
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