Overview Contents Previous Next Geant4 User's Guide
For Application Developers
Getting Started with Geant4

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?

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. You can find an example how to do this in Novice Example N01.

In the detector description in the source file ExN01DetectorConstruction.cc, you will find the following box definition:

  G4double expHall_x = 3.0*m;
  G4double expHall_y = 1.0*m;
  G4double expHall_z = 1.0*m;

  G4Box* experimentalHall_box
     = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z);
Source listing 2.2.1
Creating a box.

This creates a box named "expHall_box" with 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.

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

  G4double innerRadiusOfTheTube = 0.*cm;
  G4double outerRadiusOfTheTube = 60.*cm;
  G4double hightOfTheTube = 25.*cm;
  G4double startAngleOfTheTube = 0.*deg;
  G4double spanningAngleOfTheTube = 360.*deg;

  G4Tubs* tracker_tube
    = new G4Tubs("tracker_tube",
Source listing 2.2.2
Creating a cylinder.

This creates a full cylinder, named "tracker_tube", of radius 60 centimeters and length 50 cm.

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 materials) by entering:
 G4LogicalVolume* experimentalHall_log
    = new G4LogicalVolume(experimentalHall_box,Ar,"expHall_log");
This logical volume is named "expHall_log".

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

  G4LogicalVolume* tracker_log
    = new G4LogicalVolume(tracker_tube,Al,"tracker_log");
and named "tracker_log"

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:

  G4double trackerPos_x = -1.0*meter;
  G4double trackerPos_y =  0.0*meter;
  G4double trackerPos_z =  0.0*meter;

  G4VPhysicalVolume* tracker_phys
    = new G4PVPlacement(0,                       // no rotation
                                                 // translation position
                        tracker_log,             // its logical volume
                        "tracker",               // its name
                        experimentalHall_log,    // its mother (logical) volume
                        false,                   // no boolean operations
                        0);                      // its copy number
Source listing 2.2.3
A simple physical volume.

This places the logical volume tracker_log at the origin of the mother volume experimentalHall_log, 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, and in Example N01, we use the experimental hall:

  G4VPhysicalVolume* experimentalHall_phys
      = new G4PVPlacement(0,                       // no rotation
                          G4ThreeVector(0.,0.,0.), // translation position
                          experimentalHall_log,    // its logical volume
                          "expHall",               // its name
                          0,                       // its mother volume
                          false,                   // no boolean operations
                          0);                      // its copy number
Source listing 2.2.4
The World volume from Example N01.

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 N04.

About the authors