Using GDML with the SLAC Installation of the Geant4 Toolkit
Last modified :
Introduction
A recipe for building and running a simulation executable using the Geant4
toolkit and the Geometry Description Markup Language is provided.
Libraries for both of these packages are installed and maintained
by the SLAC Geant4 group so that users need only link their applications
to them. As a starting point for new users, a Geant4 extended example
N03GDML has been provided.
Current Installation
- Geant4 release - the GDML example uses Geant4 6.1 contained in the patch
geant4-06-01-ref-00-patch-00. This is a local patch of the official March 2004 release.
- Supported Platforms:
- Linux - noric
- Solaris - shire, tersk
-
GDML is a markup language which allows the definition of geometry data in XML
format. Further information about GDML is available here.
The Xerces-C++ libraries are needed for GDML. Information about Xerces-C++ is
available here.
Currently both GDML and Xerces-C++ libraries are installed only on noric.
- Supported Platforms:
Accessing the SLAC installations
To compile and link a simulation executable using the current Geant4 toolkit
and the GDML package, several environment variables must first be set. This
can be done as follows:
- choose a work directory, for example, mytestdir
- copy to it the files
/afs/slac/package/geant4/vol3/G4Home/g4setup.env
and
/afs/slac/package/geant4/vol0/xerces/xerces.env
- in g4setup.env modify the line in the file which sets the G4WORKDIR environment variable so that it reads:
setenv G4WORKDIR $HOME/mytestdir
- source g4setup.env
- source xerces.env
The essential variables set by g4setup.env 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 toolkit is 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
The essential variables set by xerces.env file are:
- XERCESCROOT root directory of Xerces-C++
- LD_LIBRARY_PATH - add Runtime Libraries Path to Xerces-C++
Building and Running the Executable
The following steps will lead you to a working executable of the extended
example N03gdml :
- go to your work directory: cd $G4WORKDIR
- from the G4-SLAC installation copy the code for example N03gdml:
- cp -pr $G4INSTALL/examples/extended/gdml/N03gdml N03gdml
- from the G4-SLAC installation copy the default namespace schema directory.
This directory must be located just above the N03gdml directory.
- cp -pr $G4INSTALL/examples/extended/gdml/schema schema
- cd to N03gdml
- gmake clean
- gmake
- gmake will create tmp and bin directories in your work directory. The executable, named N03gogdml, will be in /bin/$G4SYSTEM/
- while in directory N03gdml, run the executable:
- ../bin/$G4SYSTEM/NO3gogdml
- if all goes well, the same detector as novice example N03 will be
constructed by GDML. If you use visualization, an OpenGL window will
appear containing a side view of the detector.
At this point you are ready to add to and modify the code in your copy of
N03gdml.
To learn more about developing your own simulation code using Geant4, see the
Application Developer's Guide .
Tatsumi Koi
Dennis Wright