Geant4: 2.2.  How to Define a Detector Geometry

2.2.  How to Define a Detector Geometry

2.2.1.  Basic Concepts

A detector geometry in Geant4 is made of a number of volumes. The largest volume is called the World volume. It must contain, with some margin, all other volumes in the detector geometry. The other volumes are created and placed inside previous volumes, included in the World volume. The most simple (and efficient) shape to describe the World is a box.

Each volume is created by describing its shape and its physical characteristics, and then placing it inside a containing volume.

When a volume is placed within another volume, we call the former volume the daughter volume and the latter the mother volume. The coordinate system used to specify where the daughter volume is placed, is the coordinate system of the mother volume.

To describe a volume's shape, we use the concept of a solid. A solid is a geometrical object that has a shape and specific values for each of that shape's dimensions. A cube with a side of 10 centimeters and a cylinder of radius 30 cm and length 75 cm are examples of solids.

To describe a volume's full properties, we use a logical volume. It includes the geometrical properties of the solid, and adds physical characteristics: the material of the volume; whether it contains any sensitive detector elements; the magnetic field; etc.

We have yet to describe how to position the volume. To do this you create a physical volume, which places a copy of the logical volume inside a larger, containing, volume.

2.2.2.  Create a Simple Volume

What do you need to do to create a volume?

  • Create a solid.
  • Create a logical volume, using this solid, and adding other attributes.

Each of the volume types (solid, logical, and physical) has an associated registry (VolumeStore) which contains a list of all the objects of that type constructed so far. The registries will automatically delete those objects when requested; users should not deleted geometry objects manually.

2.2.3. Choose a Solid

To create a simple box, you only need to define its name and its extent along each of the Cartesian axes.

Example 2.4.  Creating a box.

  G4double world_hx = 3.0*m;
  G4double world_hy = 1.0*m;
  G4double world_hz = 1.0*m;

  G4Box* worldBox
     = new G4Box("World", world_hx, world_hy, world_hz);

This creates a box named "World" with the extent from -3.0 meters to +3.0 meters along the X axis, from -1.0 to 1.0 meters in Y, and from -1.0 to 1.0 meters in Z. Note that the G4Box constructor takes as arguments the halfs of the total box size.

It is also very simple to create a cylinder. To do this, you can use the G4Tubs class.

Example 2.5.  Creating a cylinder.

  G4double innerRadius = 0.*cm;
  G4double outerRadius = 60.*cm;
  G4double hz = 25.*cm;
  G4double startAngle = 0.*deg;
  G4double spanningAngle = 360.*deg;

  G4Tubs* trackerTube
    = new G4Tubs("Tracker",

This creates a full cylinder, named "Tracker", of radius 60 centimeters and length 50 cm (the hz parameter represents the half length in Z).

2.2.4.  Create a Logical Volume

To create a logical volume, you must start with a solid and a material. So, using the box created above, you can create a simple logical volume filled with argon gas (see Section 2.3) by entering:

 G4LogicalVolume* worldLog
    = new G4LogicalVolume(worldBox, Ar, "World");

This logical volume is named "World".

Similarly we create a logical volume with the cylindrical solid filled with aluminium

  G4LogicalVolume* trackerLog
    = new G4LogicalVolume(trackerTube, Al, "Tracker");

and named "Tracker"

2.2.5.  Place a Volume

How do you place a volume? You start with a logical volume, and then you decide the already existing volume inside of which to place it. Then you decide where to place its center within that volume, and how to rotate it. Once you have made these decisions, you can create a physical volume, which is the placed instance of the volume, and embodies all of these atributes.

2.2.6. Create a Physical Volume

You create a physical volume starting with your logical volume. A physical volume is simply a placed instance of the logical volume. This instance must be placed inside a mother logical volume. For simplicity it is unrotated:

Example 2.6.  A simple physical volume.

  G4double pos_x = -1.0*meter;
  G4double pos_y =  0.0*meter;
  G4double pos_z =  0.0*meter;

  G4VPhysicalVolume* trackerPhys
    = new G4PVPlacement(0,                       // no rotation
                        G4ThreeVector(pos_x, pos_y, pos_z),
                                                 // translation position
                        trackerLog,              // its logical volume
                        "Tracker",               // its name
                        worldLog,                // its mother (logical) volume
                        false,                   // no boolean operations
                        0);                      // its copy number

This places the logical volume trackerLog at the origin of the mother volume worldLog, shifted by one meter along X and unrotated. The resulting physical volume is named "Tracker" and has a copy number of 0.

An exception exists to the rule that a physical volume must be placed inside a mother volume. That exception is for the World volume, which is the largest volume created, and which contains all other volumes. This volume obviously cannot be contained in any other. Instead, it must be created as a G4PVPlacement with a null mother pointer. It also must be unrotated, and it must be placed at the origin of the global coordinate system.

Generally, it is best to choose a simple solid as the World volume, the G4Box solid type is used in all basic examples.

2.2.7.  Coordinate Systems and Rotations

In Geant4, the rotation matrix associated to a placed physical volume represents the rotation of the reference system of this volume with respect to its mother.

A rotation matrix is normally constructed as in CLHEP, by instantiating the identity matrix and then applying a rotation to it. This is also demonstrated in Example B3.

<-- Chapter 2. Getting Started with Geant4 - Running a Simple Example  2.3. How to Specify Materials in the Detector --> "