Annotated
Example

XML Declaration
<?xml version="1.0" encoding="UTF-8"?>
GDML Namespace
XML Schema Instance Namespace
GDML Schema location
<gdml
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/Schema/gdml.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 some of the 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 definitions





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"/>
   <physvol>
    <volumeref ref="v2"/> <positionref ref="center"/>
                          <rotationref ref="identity"/>
   </physvol>
   <physvol>
    <volumeref ref="v1"/> <positionref ref="px200"/>
                          <rotationref ref="identity"/>
   </physvol>
  </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>

Back to GDML web page.