23.3. Creating the Detector
Table of Contents
Scintillator crystal
In this example you create a single scintillation detector that can record the energy deposited by incoming gamma rays. The core of this detector is the scintillator crystal. In Geant4, the crystal is just another volume in your geometry, built from the same solids and logical volumes you used for the world.
Conceptually, the scintillator should be a compact block of material with a reasonably high density and atomic number, so that gamma rays have a good chance to interact. In a real system the material could be NaI(Tl), CsI(Tl), LSO, BGO, or many others. For this beginner example you can treat the scintillator simply as a solid volume made of a single Geant4 material, for example a predefined NIST material that approximates a common crystal, or even water if you only want to practice the geometry steps.
The scintillator is usually placed inside the world volume, often centered at the origin so that it is easy to visualize and to align the particle source. To implement it, you define a solid that represents the crystal shape, then a logical volume that combines this shape with the chosen material, and finally a physical volume that places the crystal at a given position and orientation.
A simple and very common choice is a rectangular crystal. You can represent it with a G4Box:
G4double halfX = 25.0 * mm;
G4double halfY = 25.0 * mm;
G4double halfZ = 10.0 * mm;
auto crystalSolid =
new G4Box("CrystalSolid", halfX, halfY, halfZ);
The half lengths define the size of the crystal in the three Cartesian directions, so the full dimensions are $2 \times \text{halfX}$, $2 \times \text{halfY}$, and $2 \times \text{halfZ}$. After you define the solid, you need a material for the scintillator. If you already created a material in your DetectorConstruction, you can reuse it here:
auto nist = G4NistManager::Instance();
auto crystalMat = nist->FindOrBuildMaterial("G4_CESIUM_IODIDE");This gives you a simple CsI crystal material suitable for a basic gamma detector model. Now you create the logical volume:
auto crystalLogical =
new G4LogicalVolume(crystalSolid, crystalMat, "CrystalLogical");The logical volume represents the detector crystal as an object that has both shape and material, and that can later be used for visualization attributes or as a sensitive detector.
Finally, you place the scintillator crystal in the world using a G4PVPlacement. Assuming you have a worldLogical volume already defined, you can put the crystal at the origin:
auto crystalPhysical =
new G4PVPlacement(nullptr,
G4ThreeVector(0., 0., 0.),
crystalLogical,
"CrystalPhysical",
worldLogical,
false,
0,
true);At this stage, your gamma-ray detector is simply a single scintillator crystal in space. Later chapters will connect this logical volume to a sensitive detector, so that each gamma interaction inside the crystal is recorded as energy deposition.
Important: The scintillator crystal must be fully contained inside the world volume, and it must not overlap other volumes. Overlaps can cause incorrect particle transport and unphysical results.
For a single-crystal detector you only need one placement, but you could later create arrays of such crystals using repeated or parameterized geometry. For the first version of this example, focus on having one correctly defined scintillator volume, correctly placed and with a realistic material.
Detector dimensions
The choice of detector dimensions strongly influences the efficiency of your gamma detector, its energy resolution, and the shape of the recorded spectra. In Geant4, you control these dimensions directly through the half lengths you pass to the solid constructor. For a G4Box, the full size in each direction is simply twice the corresponding half length.
For this example, it is convenient to use a crystal that is large enough to absorb a significant fraction of the incoming gamma energy, but still small enough that you can clearly see where it is in the visualization. A typical starting point could be a rectangular block with a few centimeters lateral size and around one or two centimeters thickness along the beam direction.
A common convention is to align the main axis of gamma incidence with the $z$ axis. In that case, the half length halfZ corresponds to half the detector thickness along the beam. If you choose
G4double halfX = 25.0 * mm;
G4double halfY = 25.0 * mm;
G4double halfZ = 10.0 * mm;then the detector has:
| Dimension | Half length | Full size |
|---|---|---|
| X | 25 mm | 50 mm |
| Y | 25 mm | 50 mm |
| Z | 10 mm | 20 mm |
This is a compact detector that can already capture most of the energy of typical medical or laboratory gamma sources in the hundreds of keV range. You can adjust these values later to study geometric effects, such as how detection efficiency increases with crystal thickness.
When choosing detector dimensions you must always respect the constraint that the detector fits comfortably inside the world volume. If your world is a cube created with
G4double worldHalfSize = 50.0 * cm;
auto worldSolid =
new G4Box("WorldSolid", worldHalfSize, worldHalfSize, worldHalfSize);then your crystal of a few centimeters will obviously fit, and you also have space to place sources at some distance from the detector. Keeping the world much larger than the detector simplifies visualization and reduces the risk of inadvertently placing parts outside the world.
It is often useful to define detector dimensions as named variables or class members rather than hard coded numbers. This allows you to modify sizes more easily later:
fCrystalHalfX = 25.0 * mm;
fCrystalHalfY = 25.0 * mm;
fCrystalHalfZ = 10.0 * mm;
auto crystalSolid =
new G4Box("CrystalSolid", fCrystalHalfX, fCrystalHalfY, fCrystalHalfZ);With this approach, you can change the detector size in a single place and immediately rerun the simulation to see the effect on the energy spectrum and detection efficiency.
Key rule: Use Geant4 units explicitly for all dimensions, for example 10.0 mm or 5.0 cm. Never rely on raw numbers without units, because Geant4 uses an internal unit system and assuming default units leads to incorrect geometry sizes.
Once you have chosen reasonable detector dimensions and created the scintillator volume, you have a complete, single-crystal gamma detector geometry. In later chapters you will add the material definition, connect the volume to a sensitive detector, and finally analyze how the detected energy spectrum depends on the detector size.
Views: 9
KAHIBARO