Getting started
NOTE: This page is obsolete and no longer maintained.
Refer to the main GDML Home Page
for the latest version of GDML
What's needed
- In order to use GDML with Geant4 one needs to have:
- Geant4 installed (together with the appropriate CLHEP), with all the Geant4 header
files copied to one directory (an option during the Geant4 installation)
- XercesC parser installed (GDML has been successfuly tested with versions 2.3.0 and 2.7.0 of XercesC)
- GDML binding for Geant4 installed (see next section)
- In order to use GDML with ROOT one needs to have ROOT v5.12.00 or newer. The GDML binding
is integrated within the ROOT framework and no additional installation is needed.
Installing GDML
In order to install the GDML binding for Geant4 one needs to:
- Get one of the GDML releases either by downloading the tarfile (see GDML page)
or by checking it out from GDML2 CVS repository using the anonnymous access
mode 'cvs -d :pserver:anonymous@simu.cvs.cern.ch:/cvs/simu co -r <version> -d <destination> GDML2'
where <version> should be
replaced by the GDML version number in the form GDML_X_Y_Z (for example GDML_2_8_0) and <destination> should be replaced
by the destination directory (for example src)
- For the first-time users an installation script (GDMLSetup in CPPGDML directory)
has been implemented to guide through the installation procedure.
More advanced users can configure the build system by directly executing the 'configure' script in the
CPPGDML directory with all the options properly set.
The options should specify the platform (for instance Linux-g++), the location of the CLHEP,
Geant4 and XercesC installations, the type of Geant4 libraries (global by default, or granular) as well as the kind of GDML
libraries to be build (dynamic or static). The configure script can also extract all the necessary information from
the environment variables if they have been set beforehead (for instance by executing the env.csh script from the
Geant4 installation). Please have a look at the README file in CPPGDML directory for additional information on the
GDML configuration system.
An example of the configuration is given in CERNConfigure.(c)sh
scripts which can be modified and used for the local user's system
configuration. The full list of options can be obtained by issueing
'./configure -help'.
- Once the configuration is properly done,
you can build the GDML libraries by issueing the 'make' (or 'gmake')
command in CPPGDML directory. The built libraries can be found in
CPPGDML/build/$PLATFORM/lib, where libgdml is the global library
containing all the modules for both the Geant4 GDML reader as well as
the writer. The last, optional step is to install the libraries, the
binaries (the examples) as well as the includes in some specific
place (following, for instance, some local software installation
rules) using 'make install' command. The installation directories
should be specified beforehead using --libdir=DIR --includedir=DIR
and --bindir=DIR options of the configure script.
No additional installation (except the ROOT system itself) is needed in order to use GDML with ROOT.
Using GDML
- Using GDML with Geant4
In order to use the GDML file as geometry source for a Geant4 application one needs
to instanciate and call the GDML processor. This can, for instance, be done within
a special G4VUserDetectorConstruction class implementation.
The g4gogdml example (in CPPGDML/g4gogdml directory) provides an implementation
of such a detector construction class. Some more information can be found
in the following section.
In order to export the Geant4 geometry in the form of the GDML file, one needs to instanciate
the G4GDMLWriter class and then call its DumpGeometryInfo method providing the pointer
to the top volume of the geomety tree. This can be done anywhere in the user code provided only
that the Geant4 geometry tree is already instanciated in the memory. The example code can be found
in CPPGDML/Examples/g4N02gdml directory. For more information please refer to
section.
- Using GDML with ROOT
GDML reader and writer is fully integrated within the TGeoManager::Import and TGeoManager::Export methods
which automatically call the appropriate GDML processing code whenever the file extension is .gdml.