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:
- rhel5-32
- rhel6-32
- rhel5-64
- rhel6-64
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
/afs/slac/package/geant4/g4setup.env
To begin:
- choose a work directory, and in it
- mkdir geant4_workdir
- cd geant4_workdir
- 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. By default, Geant4 scripts set this to $HOME/geant4_workdir.
If you wish to rename or move it, you must add a line to your copy of
g4setup.env which resets G4WORKDIR.
- G4SYSTEM - G4 code for the system architecture
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):
- mkdir geant4_workdir
- cd geant4_workdir
- cp /afs/slac/package/geant4/env-rhel5-32.csh .
- source env-rhel5-32.csh (repeat this line each time you log in to this platform)
.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.
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.
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:
- source env-rhel5-32.csh (.sh)
- source env-rhel5-64.csh (.sh)
- source env-rhel6-32.csh (.sh)
- source env-rhel6-64.csh (.sh)
Next, you may use either gmake or cmake to build an executable:
Using gmake
- go to your work directory
- copy from the Geant4 installation the code for example N03:
- 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
Using cmake
- go to your work directory
- copy from the Geant4 installation the code for example N03:
- cp -r $G4INSTALL/../../../../examples/novice/N03 N03
- cd to N03
- cmake . (note: this is the command cmake followed by a space and a period)
- Within the current directory (in this case N03), cmake will create a
directory named CMakeFiles which includes temporary files.
- MakeFile is also created in this directory.
- while in directory N03, run the executable:
- make -f Makefile
- ./exampleN03
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 N03.
For more information about developing your own simulation code using Geant4, see
the Application Developer's Guide .
Dennis Wright
Tatsumi Koi