Geant4 GDML HOWTO |
|||||||||||||||
Introduction |
GDML 1.0 is
the markup language to allow definition of geometry data in XML format.
The structure of GDML is defined by its corresponding GDML Schema.
Having the schema allows the both the developers and users to learn what
is available and at the same time what is forbidden in the GDML data
files. For users it means at first security, as XML parser can
immediately warn about all deviations from the prescribed GDML
"syntax". On the other hand developers can make use of the knowledge gathered from schema for translation into programming language abstractions describing concepts in the schema. The domain of GDML is targeting the geometry description of HEP detectors. This does not prevents its possible applications to other fields where such a language is needed. It complements the very often used way of data input in form of a source code. What users gain is the reduced time when writing their geometry description as no need for re-compilation and re-linking of their applications is required even for one number change. The other advantage is that it allows them easy exchange of geometry data without a need to reveal their source code and makes life easier for developers as well because they can use the GDML data for tracing bugs and problems in geometry processing code. This document provides a brief introduction to what GDML 1.0 offers and provides an introduction to its use described by annotated example. |
||||||||||||||
Features |
The
features in the GDML 1.0 cover the set of basic elements needed to
describe geometry. This set of features is not the final one and some
extensions are already planned, see later in section Future.
|
||||||||||||||
Annotated
|
XML Declaration |
<?xml version="1.0" encoding="UTF-8"?> |
|||||||||||||
| GDML Namespace XML Schema Instance Namespace GDML Schema location |
<gdml xmlns:gdml="http://cern.ch/2001/Schemas/GDML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="gdml_1.0.xsd"> |
||||||||||||||
| Numerical
definitions: constant PI NOTE: require the CLHEP built-in pi! position center( 0.0, 0.0, 0.0 ) rotation identity equals to identity.rotateX( 0.0 ) identity.rotateY( 0.0 ) identity.rotateZ( 0.0 ) NOTE: GDML rotation is axial rotation |
<define> <constant name="HALFPI" value="pi/2."/> <constant name="PI" value="1.*pi"/> <constant name="TWOPI" value="2.*pi"/> <position name="center"/> <rotation name="identity"/> <position name="shiftbyx" x="20.0"/> <position name="px10" x="10.0"/> <position name="px250" x="250.0"/> <position name="px200" x="200.0"/> <rotation name="rotatebyx" x="HALFPI/2."/> <rotation name="rotatebyall" x="HALFPI" y="PI" z="TWOPI"/> </define> |
||||||||||||||
Density quantity definition Isotopes and their use to create an element Simple elements type definitions NOTE: elements can't be associated with a volume, only materials can! Simple material a la element way Simple material created from two elements by number of atoms Material mixture created by fractional mass |
<materials> <define> <quantity type="density" name="ro" unit="g/cm3" value="1234.00"/> </define> <isotope name="U235" Z="92" N="235"> <atom type="A" value="235.01"/> </isotope> <isotope name="U238" Z="92.0" N="238"> <atom type="A" value="238.03"/> </isotope> <element name="enriched_Uranium"> <fraction ref="U235" n="0.9"/> <fraction ref="U238" n="0.1"/> </element> <element name="Hydrogen" formula="H" Z="1."> <atom value="1.01"/> </element> <element name="Oxygen" formula="O" Z="8."> <atom value="16.0"/> </element> <element name="Nitrogen" formula="N" Z="7."> <atom value="14.01"/> </element> <element name="Lead" formula="Pb" Z="82."> <atom value="207.20"/> </element> <material name="Al" Z="13.0"> <D value="2.70"/> <atom value="26.98"/> </material> <material name="Water" formula="H20"> <D value="1.0"/> <composite n="2" ref="Hydrogen"/> <composite n="1" ref="Oxygen"/> </material> <material name="Air"> <D value="1.290" unit="mg/cm3"/> <fraction n="0.7" ref="Nitrogen"/> <fraction n="0.3" ref="Oxygen"/> </material> </materials> |
||||||||||||||
| Examples
of all available CSG solids One can place numeric definitions here as well as into materials and structure section. NOTE: All numeric definitions are global! Boxes Cone Parallelepiped Sphere General trapezoid Trapezoid Tubes |
<solids> <define> <quantity type="length" name="sizeoft500" unit="mm" value="500.0"/> <position name="shiftbysizeoft500" x="500.0"/> </define> <box name="WorldBox" x="10000.0" y="10000.0" z="10000.0"/> <box name="b100" x="100.0" y="100.0" z="100.0"/> <box name="b500" x="500.0" y="500.0" z="500.0"/> <cone name="c1" z="111.0" rmax1="22.0" rmax2="33.0" deltaphi="TWOPI"/> <para name="p1" x="10.0" y="10.0" z="10.0" alpha="30.0" theta="30.0" phi="30.0"/> <sphere name="s1" rmax="200.0" deltaphi="TWOPI" deltatheta="PI"/> <trap name="trap1" z="100.0" theta="60.0" phi="60.0" y1="10.0" x1="10.0" x2="10.0" alpha1="30.0" y2="10.0" x3="10.0" x4="10.0" alpha2="30.0"/> <trd name="trd1" x1="10.0" x2="10.0" y1="10.0" y2="20.0" z="30.0"/> <tube name="t1000" z="1000.0" rmax="100.0" deltaphi="TWOPI"/> <tube name="t900" z="900.0" rmax="100.0" deltaphi="TWOPI"/> <tube name="t100" z="102.0" rmax="30.0" deltaphi="TWOPI"/> |
||||||||||||||
| Make
a union where tube "t100" is moved 250.0 mm along x-axis from
center of the box "b500" Subtract the non-rotated tube "t100" from the center of box "b100" Intersection of box "b100" and tube "t100" where tube is moved by 10.0mm in x and rotated by 45 degrees around x-axis |
<union name="u2"> <first ref="b500"/> <second ref="t100"/> <positionref ref="px450"/> </union> <subtraction name="sub2"> <first ref="b100"/> <second ref="t100"/> <positionref ref="center"/> <rotationref ref="identity"/> </subtraction> <intersection name="intersec1"> <first ref="b100"/> <second ref="b100"/> <positionref ref="px10"/> <rotationref ref="rotatebyx"/> </intersection> </solids> |
||||||||||||||
| Simple geometry setup Volume definitions2 World volume definition Place child volume "v2" at the center Place the child volume "v1" moved by 200.0 mm along x-axis from the center |
<structure> <volume name="v1"> <materialref ref="Lead"/> <solidref ref="t1000"/> </volume> <volume name="v2"> <materialref ref="Lead"/> <solidref ref="sub2"/> </volume> <volume name="World"> <materialref ref="Air"/> <solidref ref="WorldBox"/> <child> <volumeref ref="v2"/> <positionref ref="center"/> <rotationref ref="identity"/> </child> <child> <volumeref ref="v1"/> <positionref ref="px200"/> <rotationref ref="identity"/> </child> </volume> </structure> |
||||||||||||||
| Only one setup is defined here, however it is possible define multiple geometry setups choosing different volumes as world volumes from all the already defined volumes |
<setup name="Test1" version="1.0"> <world ref="World"/> </setup> |
||||||||||||||
</gdml> |
|||||||||||||||
Geant4/GDML
|
Having
some GDML data is fine. Now it is needed to marry the Geant4 and GDML
processing engine to let them together build the wanted geometry
marked-up in XML. The idea is simple. There is G4VUserDetectorConstruction abstract class expected by Geant4 run-time which one has
to inherit from and implement its
Construct() method which is responsible
for actual geometry construction and returns the pointer to a world
volume. In standard Geant4 application its implementation contains
direct calls to Geant4 materials and geometry APIs and few others. In
case of GDML this task is simplified in sense it gets rid of materials
& geometry APIs. The following code listing demonstrates GDML way of
implementing user detector construction:
|
||||||||||||||
Practical
|
|
||||||||||||||
Future |
Current
set of GDML features is already rich and usable for practical
applications. Of course is far from being exhaustive or complete. The
following list of features is planned to be implemented in the near
future:
Well, I am sure the list can be extended. Any suggestions are welcome and can be submitted either to my e-mail bellow or to mailing list shown on the GDML main web page. |
||||||||||||||
| 1. Constructive
Solid Geometry
2. Assembly volumes are not shown, they will be described in GDML Specification and User's Guide |
|||||||||||||||
|
|
|||||||||||||||
|
|
|
||||||||||||||