The ROOT geometry package is a tool for building, browsing, navigating and visualizing detector geometries.

→ Geometry tutorials

Main geometry class

The main geometry class in ROOT is TGeoManager . It provides the user interface for geometry creation, navigation, state querying, visualization, IO, geometry checking and other utilities.

Rules for building a valid geometry

The basic bricks for building-up a geometrical model are called “volumes”. These represent the un-positioned pieces of the geometry. The relationship between the pieces, this is volumes, is not defined by neighbors, but by “containment”. Volumes are put one inside another to create an in-depth hierarchy.

There are the following general rules for building a valid geometry:

  • Volumes needs media and shapes in order to be created.
  • Both, container and containee volumes must be created before linking them together, and a relative transformation matrix must be provided.
  • All branches must have an upper link point. Otherwise they will not be considered as part of the geometry.
  • Visibility or tracking properties of volumes can be provided both at build time or after geometry is closed.
  • Global visualization settings (see TGeoPainter ) should not be provided at build time, otherwise the drawing package will be loaded.

There are the following specific rules for building a valid geometry:

  • Positioned daughters should not extrude their mother or intersect with sisters unless this is specified (see TGeoVolume::AddNodeOverlap()).
  • The top volume (containing the whole geometry tree) must be specified before closing the geometry and must not be positioned - it represents the global reference frame.
  • After building the full geometry tree, the geometry must be closed (see TGeoManager::CloseGeometry()).
  • Voxelization can be redone per volume after this process.

Creating a simple geometry

  • Use the TGeoManager class to create an instance of the geometry manager class.
   new TGeoManager("world", "A simples geometry.");

You can access the geometry manager class with the global variable gGeoManager.

In the next step, a volume (TGeoVolume ) is created. Any volume needs to have a material (TGeoMaterial ) and a medium (TGeoMedium ).

   TGeoMaterial *mat = new TGeoMaterial("Vacuum",0,0,0);
   TGeoMedium *med = new TGeoMedium("Vacuum",1,mat);

In the next step the volume gets a shape. Boxes and tubes are the most recommended shapes. Note that the world volume (the volume containing all other volumes) can have any shape.

For example, you can make your volume having a box shape. The default units are in centimeters.

   TGeoVolume *top=gGeoManager->MakeBox("Top",med,10.,10.,10.);

Now the volume is set as our world volume. Do this before closing the geometry.


Now you can close the geometry.


With Draw() you can draw the simple geometry, for example:


Figure: A simple geometry.