Geometry

A geometry represents a Hierarchie of constructive solid geometry primitive elements (shapes or solid). The main functionalities provided are ray model collision detection functionality, visualization, overlap checking and persistency.

It is most commonly used for high energy physics in particle collision simulation and reconstruction.

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 neighbours, 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.

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.

   gGeoManager->SetTopVolume(top);

Now you can close the geometry.

   gGeoManager->CloseGeometry();

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

   top->SetLineColor(kMagenta);
   gGeoManager->SetTopVisible();
   top->Draw();

Figure: A simple geometry.