Geant4 Geometry XML Convertor

Introduction

The Geant4 geometry XML convertor is a small set of C++ classes that are included in the Geant4 Virtual Monte Carlo . It enables to generate XML files with geometry description in the AGDD or GDML format. The geometry can be then browsed and visualized using GraXML tool .


How to generate XML files from Geant4 VMC

  1. Start root and run example E02:
    cd geant4_vmc/examples/E02
    root.exe
    root[0] .x run_g4.C


  2. Go to Geant4 UI:
    root [1] ((TGeant4*)gMC)->StartGeantUI()

  3. Invoke Geant4 UI command:
    Idle> /xml/generateAGDD [volName] or
    Idle> /xml/generateGDML [volName]

    A file "WRLD.xml" or "WRLD.gdml" will be generated. If a volume name is specified after the command:
    the XML file "volName.xml" or "volName.gdml" will be then genarated for the specified volume and its daughters tree.

How to include XML convertor in standard Geant4 application

E.g. in the Geant4 novice example N02:

  1. Add these lines to GNUmakefile:
    # added lines
    CPPFLAGS   +=  -I/mypath/geant4_vmc/convertors/g4toxml/include
    EXTRALIBS   +=  -L/mypath/geant4_vmc/lib/tgt_Linux   -lg4toxml

  2. Include TG4AGDDGeometryGenerator and/or TG4GDMLGeometryGenerator instance in ExN02DetectorConstruction.hh:

    #include "TG4AGDDGeometryGenerator.h"
    #include "TG4GDMLGeometryGenerator.h"
       // ... skipped
    private:
       // ... skipped

       TG4AGDDGeometryGenerator    fAGDDGeometryGenerator;
       TG4GDMLGeometryGenerator    fGDMLGeometryGenerator;
    };
This will add Geant4 UI directory /xml with /xml/generateAGDD and/or /xml/generateGDML commands.

How to browse and visualize XML files with GraXML

GraXML is a program for the 3D visualization of the Event and Detector description data. It uses Java3D to create, render and manipulate SceneGraph and can be run as a standalone application.
Variety of pictures created by GraXML can be found in the GraXML Gallery .

In order to view a file (or files) generated by Geant4 VMC XML convertor in GraXML do the following steps:

  1. If using AGDD, copy the AGDD.dtd file from the GraXML distribution (GraXML/misc/Test/AGDD.dtd) to your current directory

  2. Set the Java environment and run GraXML following the instructions in the GraXML Guide .

  3. In the GraXML window type command:
    w.show("myfile.xml"); or
    w.show("myfile.gdml");

A few tips how to start:


XML Formats


Differences in GEANT3, Geant4 and XML Geometry Description


XML Web pages



Page maintained by: Ivana Hrivnacova
Last update: 26/04/2004