A system geometry is a collection of volume definitions. The volumes can be native Geant4 objects or imported from CAD or GDML files.

Before continuing, make sure you have read the systems documentation and are working within a system directory.

Quickstart: build native Geant4 Volumes

To build native Geant4 volumes, a set of functions and templates to build the Geant4 volumes1 can be used.

The following command displays the code needed to build a volume, for example a G4Box of 30 x 40 x 50 cm:

gemc-system-template -gv G4Box -gvp '30 40 50 cm'
from gvolume import GVolume

gvolume = GVolume('my_volume')
gvolume.make_box(30, 40, 50, 'cm')
gvolume.material = 'G4_AIR'
# gvolume.mother     = 'root'
# gvolume.position   = '0*cm, 0*cm, 0*cm'
# gvolume.set_rotation(0, 0, 0)
# gvolume.color      = '778899'
# gvolume.style      = 1
# gvolume.visible    = 1
# gvolume.digitization = 'none'
# gvolume.set_identifier('id', 1)
gvolume.publish(cfg)

You can paste it in geometry.py and modify it as needed with your desired parameters.

Use the -silent option to omit the printout of the lines commented out with #.

Let’s go over each line. The lines commented out with # set the default values as shown below.

  1. volume constructor. The argument is the name of the volume
  2. solid type builder . The arguments are its dimensions
  3. volume’s material name
  4. the name of the volume that contains this volume
  5. volume’s description
  6. volume’s position. The default unit is mm, but an optional fourth argument with the unit can be added
  7. volume’s rotation. The default unit is deg, but an optional fourth argument with the unit can be added
  8. volume’s magnetic field
  9. volume’s color. This is a six-digit hexadecimal number. For example, ff0000 is red, 0x00ff00 is green, 0x0000ff is blue, 0xffffff is white, and 0x000000 is black. An optional integer (0-5) 7th argument can be added to set the transparency, where 0 is opaque and 5 is transparent
  10. volume’s style
  11. volume’s visibility
  12. volume’s sensitivity: this is the name of the digitization plugin associated with the volume
  13. volume’s identifier: unique set of pairs (string, id) that identifies the volume

The type builders can be listed with gemc-system-template -sl and can be found here.


In the following recording, a system forward is created and a G4Box is added to the build_target routine in geometry.py using the template script:

For more information on how to build native Geant4 volumes, see the native geometry documentation.




How to build import CAD volumes





  1. a Geant4 volume is usually 3 objects: a. a solid, that defines the dimensions. b. a logical volume, that includes materials and fields. c. a physical volume, that places the volume within its mother volume.