KAHIBARO
Discord Login Register

24.6 Recording Transmitted Particles

Tracking Particles Through the Shield

Recording transmitted particles means identifying which particles have passed through the shielding geometry and reached a region where you want to measure transmission. In a Geant4 shielding simulation this is usually done with a sensitive detector placed just behind the shield and by storing information about the particles that enter this detector region.

You do not need to modify the primary generator or the physics list for this. Instead, you focus on geometry, sensitive detectors, and user actions that let you see what crosses a chosen plane or volume.

Choosing What “Transmitted” Means

Before you write any code, decide what you want to count as a transmitted particle in this shielding example. Common choices are:

A particle that crosses a fixed plane behind the shield, for example a detector slab placed at some distance after the shield.

A particle that enters a thin scoring volume, for example a box or slab just beyond the shield.

A particle that leaves the shield and still has at least some energy, for example above a threshold.

For an attenuation study you usually define transmission in terms of a detector plane. The simplest approach is to place a thin detector volume behind the shield and treat every track that enters that volume as “transmitted.” You can refine this later with energy thresholds or particle type selections.

Important: Always define your transmission region as a real Geant4 volume, for example a thin box or slab, not as an abstract plane in space. This lets you use sensitive detectors and step information directly.

Creating a Detector Behind the Shield

To record transmitted particles, add a scoring detector volume behind the shield in your detector construction. This volume should be large enough to intercept all particles that could emerge from the shield for your range of incident angles and beam size, and thin enough so that it does not significantly alter the flux you want to measure.

In the shielding example, you typically have:

A world volume.

A source region where the gamma beam starts.

A shielding block, for example lead, aluminum, or concrete.

A detector volume just downstream of the shield.

Conceptually, the detector volume is another ordinary Geant4 volume defined with a solid and a logical volume, then placed into the world with a physical placement. For example, you might define a thin rectangular box aligned with the beam direction and placed immediately after the shield. The material can be air or a lightweight material, since its purpose is to count particles and possibly record their energy and direction, not to absorb them.

Once you have such a volume, you can attach a sensitive detector to its logical volume so that every step inside it can be examined and used to fill statistics on transmitted particles.

Important: Do not forget to make the detector volume large enough to contain any scattered particles that exit the shield at nonzero angles. If the detector is too small, your measured transmission will be artificially low.

Using a Sensitive Detector to Record Transmission

The most direct way to record transmitted particles is to assign a sensitive detector to the logical volume behind the shield. The sensitive detector’s ProcessHits method will then be called for each step inside this scoring region. From this information you can decide whether the particle counts as transmitted and what information you want to store.

To do this, you typically:

Create a class that derives from G4VSensitiveDetector, for example ShieldDetectorSD.

Implement the ProcessHits method to inspect the G4Step and its associated G4Track.

Register the sensitive detector with the G4SDManager, then attach it to the logical volume of the scoring detector in your detector construction.

Inside ProcessHits you can record data such as:

The particle type and track ID.

The total energy or kinetic energy of the particle when it enters the detector.

The position where it first enters the scoring volume.

The event ID, which you can obtain from G4RunManager or from user actions.

For a pure transmission count you do not usually want to record every step inside the detector, only the first time a particle enters that region. The pre step point of the first step in the volume is the natural place to record this. You can detect the first step in the scoring volume by checking the step status of the pre step point.

For example, you can check that the pre step point has status fGeomBoundary. That means the track is crossing a geometry boundary into the detector volume. At that point you can increment a counter or fill a hit object to mark a transmitted particle.

Rule: In a transmission detector, count a particle when the pre step point is at a geometry boundary (status fGeomBoundary) and the current volume is your scoring volume. This avoids double counting multiple steps inside the detector.

Counting Transmitted Particles per Event

To study shielding performance, you usually want the number of transmitted particles per event. An event in this context is often one primary particle history, so event based counting gives you a clear definition of transmission probability.

There are two main approaches.

You can use hits and hit collections. The sensitive detector creates a hit every time a new track enters the detector volume. The event action then retrieves the hit collection at the end of the event, counts the number of hits, and stores that number for later analysis.

You can use simple counters in user actions. The stepping action or the sensitive detector increments a per event counter every time it detects a new transmitted track. The event action then reads that counter at the end of the event, records it in an ntuple or histogram, and resets it for the next event.

Hits are more flexible if you want to record details of each transmitted particle, such as energy and angle. Simple counters are effective if you only need the overall transmission or the number of transmitted particles above a certain energy threshold.

A common pattern is:

Initialize a per event counter in EventAction at the beginning of the event.

In ProcessHits, when a track first enters the scoring volume, increment the per event counter and, if desired, create a hit object that stores additional information.

At the end of the event, read the per event counter in EventAction and fill a histogram or ntuple column with that value.

Reset the per event counter to zero for the next event.

Important: Always reset per event counters at the start of each event. Otherwise your transmitted particle count will accumulate across events and the result will be wrong.

Selecting Particle Types and Energies

In a radiation shielding study, you may not want to count every particle that reaches the detector. For example, you might only be interested in transmitted gamma rays, or in gammas above a certain energy threshold that are relevant for a dose calculation or an instrument background.

Inside your sensitive detector’s ProcessHits method, you can access the current track and its kinetic energy, particle type, and other properties. You can then apply selections such as:

Count only tracks whose particle definition name is “gamma”.

Apply an energy threshold, for example count only tracks with kinetic energy greater than some $E_{\text{min}}$.

Ignore secondary particles that originated in the detector region itself.

For example, you might define:

$$E_{\text{min}} = 100 \text{ keV}$$

and then count a transmitted particle only if its kinetic energy at the boundary is greater than $E_{\text{min}}$. This allows you to study how the shield attenuates particles that would still be significant for your application.

Rule: Always be explicit about which particles you count as transmitted, including both particle type and any energy thresholds. Record these conditions, since changing them will change your measured transmission.

Avoiding Double Counting of Transmitted Particles

A key detail in counting transmitted particles is to avoid counting the same particle more than once. The same track might cross the detector volume more than one time, for instance if it scatters and re-enters the volume, or it might take several steps in the detector region.

There are several ways to avoid double counting.

If you only count when the pre step point is at a geometry boundary with status fGeomBoundary, and you have a single boundary crossing into the scoring volume, you will usually count each entering track once.

If a track can enter and leave the detector multiple times, you can store a flag in the track’s user information or in a per event data structure, such as a set of track IDs that have already been counted. When you see a track, check whether it is in this set. If not, count it and add its track ID to the set.

You can also design the geometry so that each transmitted track crosses the scoring volume only once. For example, you can place a thin detector slab far enough away that backscattering into the detector volume is rare.

In most simple shielding examples, using the fGeomBoundary status check in the sensitive detector is sufficient.

Important: Never count steps in the middle of the detector volume as transmitted particles. Always count at the boundary crossing to avoid double counting and to measure the correct flux entering the detector.

Distinguishing Incident and Transmitted Particles

To compute transmission or attenuation later, you will need not only the number of transmitted particles but also the number of incident particles that reached the shield. In many studies, the incident number is simply the number of primary particles you generate.

For example, if you simulate $N_{\text{prim}}$ gamma rays directed at the shield, and $N_{\text{trans}}$ of them are recorded in the detector behind the shield, then the transmission is:

$$T = \frac{N_{\text{trans}}}{N_{\text{prim}}}$$

However, if your primary source has a spread in angle or position, some primaries may not actually hit the shield. In that case, you may want to record how many particles intersect a plane at the entrance of the shield. You can do this with an additional scoring volume in front of the shield, or by using geometry information in a stepping action.

In the simplest case for this course’s shielding example, you can define:

$N_{\text{incident}}$ as the total number of primary events you simulate.

$N_{\text{transmitted}}$ as the total number of tracks that crossed into the detector volume behind the shield, counted once per track.

These two numbers are enough to compute transmission and attenuation, which you will use in the following sections of the example.

Formula: Transmission and attenuation
Transmission:
$$T = \frac{N_{\text{transmitted}}}{N_{\text{incident}}}$$
Attenuation (fraction removed):
$$A = 1 - T$$

Storing Transmission Data for Later Analysis

Once you have a mechanism for counting transmitted particles, you should record the results in a way that is convenient for later analysis. For a shielding study, you often want to vary shield thickness or material and compare the resulting transmission.

Using the Geant4 analysis system, you can:

Create an ntuple with columns for shield material, shield thickness, number of incident particles, and number of transmitted particles.

Fill a row in the ntuple at the end of each run or at the end of each parameter configuration.

Save the ntuple in a ROOT or CSV file for analysis with external tools.

For finer detail, you can also record the energy of each transmitted particle in a histogram, or store the energies in an ntuple column. This lets you study not only the total transmission but also how the energy spectrum changes after the shield.

By combining per event counts, total run statistics, and energy distributions of transmitted particles, you will have all the information you need for the later steps in this example that compute transmission, attenuation, and comparisons between materials and thicknesses.

Views: 7

Comments

Please login to add a comment.

Don't have an account? Register now!