23.5. Creating a Gamma Source
Table of Contents
Choosing a Simple Gamma Source
For a first gamma detector simulation, the source should be as simple and controlled as possible. The goal is not to reproduce a specific radioactive isotope in detail, but to create a well defined beam or point source of monoenergetic gamma rays.
In this chapter you only define how, where, and with what energy your gamma particles are generated. The actual transport and interactions of those gammas in the detector will be handled by the physics list and by Geant4 itself.
You can create the gamma source either with a G4ParticleGun in your PrimaryGeneratorAction class, or with the General Particle Source (GPS) using macro commands. For a minimal working gamma detector example, a single G4ParticleGun shooting monoenergetic gamma rays is usually the clearest approach.
For a basic gamma detector example, use a single, monoenergetic, point-like gamma source unless there is a strong reason to do otherwise.
Implementing the Gamma Source in PrimaryGeneratorAction
In your gamma detector example you will already have a PrimaryGeneratorAction class. Creating the gamma source means configuring this class so that each event produces one gamma with a chosen energy, position, and direction.
Inside the constructor of PrimaryGeneratorAction, you typically create and configure a G4ParticleGun object. For a gamma source, you set the particle definition to the gamma particle and choose energy and direction. The position should be consistent with the geometry you already defined for the world and detector.
You do not need to handle any tracking logic in this class. The particle gun just defines the initial conditions of primary particles at the start of each event. Geant4 will then take over.
The PrimaryGeneratorAction is only responsible for initial particle properties at event start, not for their subsequent motion or interactions.
Selecting the Gamma Particle
Geant4 provides the gamma particle as a predefined particle type. You do not create a gamma yourself. Instead, you ask G4ParticleTable for the existing gamma definition and give it to your particle gun.
In code, this usually means retrieving the particle table singleton and requesting the gamma particle by name. The gamma is a neutral photon, so you do not need to worry about charge or rest mass parameters here. Those are built into the particle definition and are correctly used by the physics processes.
Always obtain the gamma definition from G4ParticleTable; never invent your own particle parameters for standard particles.
Choosing the Gamma Energy
For a pedagogical gamma detector example, you typically use a single, fixed photon energy. Common choices are values that correspond to well known gamma lines, such as 511 keV or 662 keV, but you are free to pick any energy that is appropriate for your detector size and materials.
In the code, you specify the energy in Geant4 units, for example using MeV or keV. The unit constants come from the Geant4 units system and must be included in your source file. Later chapters will describe detector resolution and realistic line broadening. Here you only care that every primary gamma starts with the same well defined energy.
Use a fixed, monoenergetic gamma energy for the basic example, such as $E_\gamma = 0.5 \,\text{MeV}$ or $E_\gamma = 0.662 \,\text{MeV}$, expressed with Geant4 units like 0.662 * MeV.
Positioning the Gamma Source
The spatial origin of the gamma source must be chosen in relation to your detector geometry. In a simple setup, you often place the source on the central axis of the detector, at a known distance from the scintillator crystal, or even at the crystal center if you want to test energy deposition without geometric complications.
The position is specified in world coordinates. For a point source, you set exactly one position vector, which will be used for every event. If your world is centered at the global origin and your crystal is also centered, you may place the source slightly in front of the crystal along one axis so that particles travel toward the detector.
Later, you can move the source by editing either the code or a macro variable to study geometric effects. For the first implementation, keep it fixed and simple.
Use a single, fixed position in world coordinates for the gamma source for the initial detector study.
Setting the Gamma Direction
The direction determines where the gamma rays travel relative to your detector. For a simple detector test, you often want a narrow beam pointing directly into the active volume, usually along the positive or negative $z$ axis.
In the primary generator, you provide a direction unit vector, such as $(0, 0, 1)$ for a beam along +z in world coordinates. If your source is placed in front of the detector crystal, a fixed direction makes interpretation of the energy spectrum straightforward.
You can also create isotropic emission, where gamma directions are uniformly distributed over angles, but that complicates interpretation of the first spectrum. For the basic gamma detector example, keep the direction fixed.
Start with a fixed beam direction pointing toward the detector, for example a unit vector along the detector axis.
Using Macros to Control the Gamma Source
Although you can hard code the energy, position, and direction of the gamma source in C++, it is often convenient to expose some of these as macro controllable parameters. Even when you use a simple G4ParticleGun, you may still control it through macro commands provided by Geant4.
For the gamma detector example this allows you to adjust gamma energy, move the source, or change particle type without recompiling the code. You will typically load a macro file at the beginning of an interactive session that sets these properties. When you later switch to the General Particle Source, macro control becomes even more powerful.
At this stage, it is enough to understand that once your gamma source is correctly configured in PrimaryGeneratorAction, you can refine and steer its parameters through macros to perform systematic studies of detector response.
Views: 9
KAHIBARO