27.5. Applying Detector Effects
Table of Contents
From Ideal Quantities to Measured Signals
In a basic Geant4 simulation you usually record ideal quantities such as exact deposited energy, exact interaction position, and exact time. Real detectors do not measure these values perfectly. They introduce uncertainties, thresholds, nonlinearity, and sometimes missing events. Applying detector effects means transforming the ideal Geant4 output into realistic, detector-like observables.
This chapter focuses on how to apply these effects at the analysis or user-action level, without modifying the underlying physics. You will see how to combine the individual resolutions introduced earlier into a consistent workflow.
Key idea: Never confuse true physical quantities (from Geant4 steps and tracks) with measured quantities (after detector effects). Always keep them conceptually and programmatically separate.
Where to Apply Detector Effects
The most practical place to apply detector effects is after you have collected the information you need for one event or one detector element. Common locations in your code are the end of event, or just before you fill histograms or ntuples.
A typical sequence is: Geant4 computes deposits and positions and times, your sensitive detector records ideal hits, then in your EventAction or RunAction you transform the ideal values into smeared ones and record only the smeared values into histograms and ntuples.
This separation keeps your simulation physics clean and makes it easier to adjust or turn off detector effects without recompiling the whole code.
Random Numbers and Gaussian Smearing
Most resolution effects are modeled as random fluctuations around a true value. The most common model is a Gaussian distribution characterized by a mean and a standard deviation.
If $x_{\text{true}}$ is the ideal quantity, and $\sigma$ is the resolution, then a smeared value is generated as
$$
x_{\text{meas}} = x_{\text{true}} + \mathcal{N}(0, \sigma),
$$
where $\mathcal{N}(0, \sigma)$ is a random number drawn from a normal distribution with mean 0 and standard deviation $\sigma$.
In Geant4, this is typically done with
G4RandGauss::shoot( mean , sigma ) or with a similar random generator.
Rule: Use a Gaussian model for resolution unless you have a specific reason to use another distribution. The standard deviation $\sigma$ must be chosen to match your detector performance.
Combining Multiple Detector Effects
A real detector measurement often includes several independent effects at the same time. For example an energy measurement can include intrinsic statistical fluctuations, electronic noise, and digitization to discrete ADC channels.
A practical way to handle this is to apply the effects in a consistent order:
- Start from the ideal quantity from Geant4.
- Apply intrinsic resolution smearing.
- Apply thresholds or saturation.
- Apply digitization or binning.
- Optionally apply nonlinearity corrections or calibration factors.
Each effect transforms the quantity further from the ideal, and you should store only the final result as the measured value.
Applying Energy Resolution
You already saw how to define an energy resolution as a Gaussian width that may depend on energy. To apply this to a simulated deposit, first collect the total energy deposit for a detector element in one event. Then, once the event is complete, smear the total.
If $E_{\text{true}}$ is the total deposited energy, and your detector has a relative resolution of $\sigma_E / E = r$ at that energy, then
$$
\sigma_E = r \, E_{\text{true}},
$$
and you generate a smeared value
$$
E_{\text{meas}} = \mathcal{N}(E_{\text{true}}, \sigma_E).
$$
When you fill energy spectra, you should generally fill them with $E_{\text{meas}}$, not $E_{\text{true}}$, if you want to compare directly with experimental data.
Rule: Always apply energy smearing after summing all contributions that belong to one detector channel in one event. Do not smear each step separately and then sum, or you will overestimate the resolution.
If your energy resolution model includes terms such as a stochastic and a constant contribution, you compute $\sigma_E$ from your formula first, then use the same Gaussian approach.
Applying Position Resolution
Position resolution is applied in exactly the same way, but separately for each coordinate. Let the true hit position in detector coordinates be $(x_{\text{true}}, y_{\text{true}}, z_{\text{true}})$. If your detector reconstructs position with standard deviations $\sigma_x$, $\sigma_y$, and $\sigma_z$, you define
$$
x_{\text{meas}} = \mathcal{N}(x_{\text{true}}, \sigma_x),
$$
$$
y_{\text{meas}} = \mathcal{N}(y_{\text{true}}, \sigma_y),
$$
$$
z_{\text{meas}} = \mathcal{N}(z_{\text{true}}, \sigma_z).
$$
Often, only certain coordinates are measured. For example:
- In a strip detector you may only smear one coordinate that is associated with the strip index, and keep the others fixed if they are known by construction.
- In a segmented scintillator you may discretize the position to the center of the fired crystal and then optionally apply a small smearing inside that volume if the crystal itself has some internal resolution.
Position smearing is typically applied when you decide that a hit is detected and you want to record its reconstructed position rather than the exact simulation position.
Applying Time Resolution
Detectors also have finite timing resolution. If $t_{\text{true}}$ is the true time from Geant4, and $\sigma_t$ is the time resolution, you generate a measured time
$$
t_{\text{meas}} = \mathcal{N}(t_{\text{true}}, \sigma_t).
$$
You use $t_{\text{meas}}$ when you compute time of flight, coincidence windows, or timing spectra.
Timing effects often come together with time thresholds and selection. For example, in coincidence measurements for PET you may only consider hits whose measured times differ by less than some window. You must use the smeared times in that decision if you want realistic coincidence behavior.
Rule: Use smeared times to decide if events are in coincidence or pass timing cuts. Using ideal times produces unrealistically sharp coincidences.
Thresholds, Saturation, and Detection Efficiency
Resolution is only one part of detector response. Real detectors have detection probabilities, noise thresholds, and sometimes maximum response.
A simple model of detection efficiency is to accept each ideal hit with a certain probability. For example, if the efficiency is $\epsilon$, you draw a uniform random number $u$ between 0 and 1, and keep the hit only if $u < \epsilon$.
Energy or signal thresholds are modeled by cutting on the measured quantity. For a lower threshold $E_{\text{thr}}$, you ignore any measured signal with $E_{\text{meas}} < E_{\text{thr}}$. Similarly, you can include an upper threshold to model saturation, where any signal above a maximum is clipped or assigned a fixed maximum channel.
It is important to apply thresholds after smearing. If you apply them to the true quantity, you remove the possibility that fluctuations move signals across the threshold, which is a real effect in experiments.
Digitization and Discrete Channels
Many detectors and readout systems measure discrete channels rather than continuous values. For example, an analog energy signal might be converted into an integer ADC channel, or a time might be recorded in discrete clock ticks.
To model digitization you convert the smeared analog quantity into a bin or integer channel. For an energy ADC with bin width $\Delta E$ and offset $E_0$ you can define
$$
\text{ADC} = \left\lfloor \frac{E_{\text{meas}} - E_0}{\Delta E} \right\rfloor,
$$
where $\lfloor \cdot \rfloor$ is the floor operation. You then store this integer channel instead of the continuous energy. A similar approach works for time and position if your readout is discretized.
Digitization is usually the last effect you apply, after resolution and thresholds. It transforms your variables into the same form as your experimental data, which makes a direct comparison easier.
Nonlinearity and Calibration
Some detectors are not perfectly linear. The relation between true energy and measured signal can deviate from a straight line. You can model this by applying a non-linear transformation to the true energy before you apply resolution. A basic example is
$$
S_{\text{true}} = a E_{\text{true}} + b E_{\text{true}}^2,
$$
where $S_{\text{true}}$ is an internal signal, $a$ is a linear coefficient, and $b$ represents a quadratic nonlinearity. You first compute $S_{\text{true}}$, then apply smearing to get $S_{\text{meas}}$, and finally convert back to an energy scale if needed.
Calibration is the inverse problem. If you know how the measured channel relates to a physical quantity, you can transform from channel to calibrated units. In a simulation you may directly simulate calibrated quantities, or you can simulate raw channels and then apply the same calibration procedure as in the experiment. The second approach is often more realistic.
Where to Store True and Measured Quantities
When you analyze your simulation output it is helpful to keep both true and measured values, at least while you are developing your model. You can put both into separate columns in your ntuples. For example you can store the true deposited energy in one column and the smeared, thresholded, and digitized energy in another.
This allows you to study the effect of your detector model and to tune its parameters. It also helps you debug the simulation. Once you are satisfied with your model you can reduce output to only the measured quantities to save disk space.
Rule: During development, record both ideal and smeared values in your analysis. Use them to verify that your detector model behaves as expected before you rely on the smeared output alone.
Summary of a Typical Workflow
In practice, for each detector channel and each event, you can follow a consistent recipe:
Start by summing ideal quantities such as total deposited energy, ideal hit position, and ideal time. Apply energy resolution smearing to the total deposit to obtain a measured energy. Apply position and time smearing to ideal positions and times if the detector measures these observables. Then apply thresholds, efficiencies, and possible saturation, rejecting or clipping signals as needed. Finally, convert analog smeared values into discrete readout channels if your detector and electronics are digitized.
By layering energy, position, and time resolution together with thresholds and digitization, you transform the perfect Geant4 output into realistic detector signals that you can compare directly with real experimental data.
Views: 0
Where to Move
Move chapter:
- ☰ 1. Introduction to Geant4
- ☰ 1.1. What Is Geant4?
- ☰ 1.2. How Geant4 Works
- ☰ 1.3. Geant4 Simulation Structure
- ☰ 1.4. Geant4 and C++
-
- ☰ 2. Installing Geant4
- ☰ 2.1. Geant4 Requirements
- ☰ 2.2. Installing Geant4 on Linux
- ☰ 2.3. Installing Visualization Libraries
- ☰ 2.4. Verifying the Installation
- ☰ 2.5. Geant4 Example Applications
-
- ☰ 3. C++ Basics for Geant4
- ☰ 3.1. Classes and Objects
- ☰ 3.2. Inheritance
- ☰ 3.3. Pointers and References
- ☰ 3.4. Header and Source Files
- ☰ 3.5. Standard Library Containers
-
- ☰ 4. Creating Your First Geant4 Project
- ☰ 4.1. Project Structure
- ☰ 4.2. CMake Configuration
- ☰ 4.3. The Main Program
- ☰ 4.4. User Initialization Classes
- ☰ 4.5. Building and Running
-
- ☰ 5. Geant4 Units and Constants
- ☰ 5.1. Geant4 Unit System
- ☰ 5.2. Using Units in C++
- ☰ 5.3. Physical Constants
- ☰ 5.4. Printing Values with Units
-
- ☰ 6. Creating the Simulation World
- ☰ 6.1. DetectorConstruction
- ☰ 6.2. Solids
- ☰ 6.3. Logical Volumes
- ☰ 6.4. Physical Volumes
- ☰ 6.5. Creating the World Volume
-
- ☰ 7. Materials
- ☰ 7.1. Geant4 Materials
- ☰ 7.2. NIST Material Database
- ☰ 7.3. Common Materials
- ☰ 7.4. Creating Custom Materials
- ☰ 7.5. Detector Materials
-
- ☰ 8. Building Detector Geometry
- ☰ 8.1. Basic Geometrical Shapes
- ☰ 8.2. Boolean Solids
- ☰ 8.3. Positioning Volumes
- ☰ 8.4. Repeated Geometry
- ☰ 8.5. Detector Arrays
- ☰ 8.6. Geometry Overlap Checking
-
- ☰ 9. Geometry Visualization
- ☰ 9.1. Visualization in Geant4
- ☰ 9.2. Starting the Visualization System
- ☰ 9.3. Changing the View
- ☰ 9.4. Visualization Attributes
- ☰ 9.5. Displaying Particle Tracks
-
- ☰ 10. Primary Particle Generation
- ☰ 10.1. PrimaryGeneratorAction
- ☰ 10.2. Particle Gun
- ☰ 10.3. Particle Energy
- ☰ 10.4. Particle Position
- ☰ 10.5. Particle Direction
- ☰ 10.6. Common Particle Sources
-
- ☰ 11. General Particle Source
- ☰ 11.1. Introduction to GPS
- ☰ 11.2. Position Distributions
- ☰ 11.3. Angular Distributions
- ☰ 11.4. Energy Distributions
- ☰ 11.5. Configuring Sources with Macros
-
- ☰ 12. Physics Lists
- ☰ 12.1. What Is a Physics List?
- ☰ 12.2. Reference Physics Lists
- ☰ 12.3. Electromagnetic Physics
- ☰ 12.4. Gamma Interactions
- ☰ 12.5. Positron Physics
- ☰ 12.6. Hadronic Physics
- ☰ 12.7. Choosing a Physics List
-
- ☰ 13. Particle Tracking
- ☰ 13.1. Tracks
- ☰ 13.2. Steps
- ☰ 13.3. Energy Deposition
- ☰ 13.4. Track Status
- ☰ 13.5. Parent and Secondary Particles
-
- ☰ 14. User Actions
- ☰ 14.1. RunAction
- ☰ 14.2. EventAction
- ☰ 14.3. SteppingAction
- ☰ 14.4. TrackingAction
- ☰ 14.5. StackingAction
- ☰ 14.6. ActionInitialization
-
- ☰ 15. Sensitive Detectors
- ☰ 15.1. What Is a Sensitive Detector?
- ☰ 15.2. Creating a Sensitive Detector
- ☰ 15.3. Hits
- ☰ 15.4. Hit Collections
- ☰ 15.5. Assigning Sensitive Detectors
-
- ☰ 16. Recording Energy Deposition
- ☰ 16.1. Energy Deposition
- ☰ 16.2. Energy per Event
- ☰ 16.3. Energy per Detector
- ☰ 16.4. Energy Spectra
- ☰ 16.5. Detector Efficiency
-
- ☰ 17. Particle Position and Timing
- ☰ 17.1. Particle Position
- ☰ 17.2. Interaction Position
- ☰ 17.3. Global Time
- ☰ 17.4. Time of Flight
- ☰ 17.5. Detector Timing
-
- ☰ 18. Geant4 Analysis System
- ☰ 18.1. Introduction to G4AnalysisManager
- ☰ 18.2. Histograms
- ☰ 18.3. Ntuples
- ☰ 18.4. Filling Ntuples
- ☰ 18.5. Writing Output Files
- ☰ 18.6. Closing Analysis Files
-
- ☰ 19. Geant4 and ROOT
- ☰ 19.1. ROOT Output from Geant4
- ☰ 19.2. Reading Geant4 Output with ROOT
- ☰ 19.3. Plotting Energy Spectra
- ☰ 19.4. Event Analysis
- ☰ 19.5. Simulation-to-Analysis Workflow
-
- ☰ 20. Geant4 Macro Commands
- ☰ 20.1. Macro Files
- ☰ 20.2. Run Commands
- ☰ 20.3. Particle Source Commands
- ☰ 20.4. Visualization Commands
- ☰ 20.5. Controlling Simulations Without Recompiling
-
- ☰ 21. Random Numbers and Reproducibility
- ☰ 21.1. Monte Carlo Random Numbers
- ☰ 21.2. Setting Random Seeds
- ☰ 21.3. Running Independent Simulations
- ☰ 21.4. Reproducing an Event
-
- ☰ 22. Multithreading
- ☰ 22.1. Geant4 Multithreading
- ☰ 22.2. Running with Multiple Threads
- ☰ 22.3. Thread-Safe User Code
- ☰ 22.4. Analysis with Multithreading
- ☰ 22.5. Performance Considerations
-
- ☰ 23. Practical Example: Gamma-Ray Detector
- ☰ 23.1. Project Overview
- ☰ 23.2. Creating the World
- ☰ 23.3. Creating the Detector
- ☰ 23.4. Adding the Material
- ☰ 23.5. Creating a Gamma Source
- ☰ 23.6. Selecting Electromagnetic Physics
- ☰ 23.7. Recording Energy Deposition
- ☰ 23.8. Creating an Energy Spectrum
- ☰ 23.9. Simulating Detector Resolution
- ☰ 23.10. Analyzing the Spectrum with ROOT
-
- ☰ 24. Practical Example: Radiation Shielding
- ☰ 24.1. Project Overview
- ☰ 24.2. Creating the Source
- ☰ 24.3. Creating the Shield
- ☰ 24.4. Comparing Shielding Materials
- ☰ 24.5. Varying Shield Thickness
- ☰ 24.6. Recording Transmitted Particles
- ☰ 24.7. Calculating Transmission
- ☰ 24.8. Calculating Attenuation
- ☰ 24.9. Comparing Simulation Results
-
- ☰ 25. Practical Example: PET Scanner
- ☰ 25.1. Introduction to PET Simulation
- ☰ 25.2. Creating a PET Detector Ring
- ☰ 25.3. Creating Detector Crystals
- ☰ 25.4. Assigning Detector IDs
- ☰ 25.5. Creating a Positron Source
- ☰ 25.6. Simulating Positron Annihilation
- ☰ 25.7. Recording Detector Hits
- ☰ 25.8. Applying an Energy Window
- ☰ 25.9. Finding Coincidence Events
- ☰ 25.10. Recording Detector Positions
- ☰ 25.11. Creating Lines of Response
- ☰ 25.12. Saving PET Events to ROOT
- ☰ 25.13. Analyzing PET Data with ROOT
-
- ☰ 26. Practical Example: Proton Beam in Water
- ☰ 26.1. Project Overview
- ☰ 26.2. Creating the Water Phantom
- ☰ 26.3. Creating a Proton Beam
- ☰ 26.4. Selecting the Physics List
- ☰ 26.5. Recording Energy Deposition
- ☰ 26.6. Dividing the Phantom into Slices
- ☰ 26.7. Calculating Depth Dose
- ☰ 26.8. Observing the Bragg Peak
- ☰ 26.9. Plotting the Depth-Dose Curve
-
- ☰ 27. Detector Resolution and Smearing
- ☰ 27.1. Ideal vs Realistic Detector Response
- ☰ 27.2. Energy Resolution
- ☰ 27.3. Position Resolution
- ☰ 27.4. Time Resolution
- ☰ 27.5. Applying Detector Effects
- ☰ 27.6. Comparing Ideal and Smeared Results
-
- ☰ 28. Simulation Validation
- ☰ 28.1. Why Validate a Simulation?
- ☰ 28.2. Checking Geometry
- ☰ 28.3. Checking Energy Conservation
- ☰ 28.4. Comparing with Analytical Calculations
- ☰ 28.5. Comparing with Reference Data
- ☰ 28.6. Statistical Uncertainties
- ☰ 28.7. Number of Simulated Events
-
- ☰ 29. Improving Simulation Performance
- ☰ 29.1. Geometry Performance
- ☰ 29.2. Physics List Performance
- ☰ 29.3. Production Cuts
- ☰ 29.4. Reducing Unnecessary Output
- ☰ 29.5. Multithreading
- ☰ 29.6. Running Large Simulations
- ☰ 29.7. Parameter Scans
-
- ☰ 30. Debugging Geant4 Simulations
- ☰ 30.1. Compilation Errors
- ☰ 30.2. Geometry Errors
- ☰ 30.3. Overlapping Volumes
- ☰ 30.4. Missing Particles
- ☰ 30.5. Missing Energy Deposition
- ☰ 30.6. Physics List Problems
- ☰ 30.7. Sensitive Detector Problems
- ☰ 30.8. Empty Output Files
- ☰ 30.9. Segmentation Faults
- ☰ 30.10. Using Geant4 Verbose Output
-
- ☰ 31. Writing Better Geant4 Applications
- ☰ 31.1. Organizing Source Code
- ☰ 31.2. Separating Geometry and Analysis
- ☰ 31.3. Using Configuration Parameters
- ☰ 31.4. Avoiding Hard-Coded Values
- ☰ 31.5. Creating Reusable Detector Components
- ☰ 31.6. Naming Conventions
- ☰ 31.7. Documentation
- ☰ 31.8. Version Control with Git
-
- ☰ 32. Advanced Geometry
- ☰ 32.1. Parameterized Geometry
- ☰ 32.2. Replica Volumes
- ☰ 32.3. Nested Geometry
- ☰ 32.4. Complex Detector Arrays
- ☰ 32.5. Importing CAD Geometry
- ☰ 32.6. Exporting Geometry with GDML
-
- ☰ 33. Optical Photons
- ☰ 33.1. Introduction to Optical Physics
- ☰ 33.2. Optical Photons
- ☰ 33.3. Material Optical Properties
- ☰ 33.4. Scintillation Light
- ☰ 33.5. Optical Surfaces
- ☰ 33.6. Photodetectors
- ☰ 33.7. Counting Optical Photons
-
- ☰ 34. Medical Physics Applications
- ☰ 34.1. Geant4 in Medical Physics
- ☰ 34.2. Radiation Dose Simulation
- ☰ 34.3. PET Simulation
- ☰ 34.4. SPECT Simulation
- ☰ 34.5. Radiotherapy Simulation
- ☰ 34.6. Proton Therapy Simulation
- ☰ 34.7. Biological Tissue Materials
-
- ☰ 35. Final Project
- ☰ 35.1. Project Overview
- ☰ 35.2. Define the Simulation Goal
- ☰ 35.3. Create the Geometry
- ☰ 35.4. Define Materials
- ☰ 35.5. Configure the Particle Source
- ☰ 35.6. Select the Physics List
- ☰ 35.7. Implement Sensitive Detectors
- ☰ 35.8. Record Simulation Data
- ☰ 35.9. Run the Simulation
- ☰ 35.10. Analyze the Results with ROOT
- ☰ 35.11. Validate the Simulation
- ☰ 35.12. Create Scientific Figures
- ☰ 35.13. Document the Simulation
-
- ☰ 36. Appendices
- ☰ 36.1. Geant4 Class Cheat Sheet
- ☰ 36.2. Geant4 Units Cheat Sheet
- ☰ 36.3. Common Geant4 Macro Commands
- ☰ 36.4. Common Geometry Classes
- ☰ 36.5. Common Particle Definitions
- ☰ 36.6. Common Physics Lists
- ☰ 36.7. G4AnalysisManager Cheat Sheet
- ☰ 36.8. Common Visualization Commands
- ☰ 36.9. Common Geant4 Errors and Solutions
- ☰ 36.10. Recommended Geant4 Project Structure
- ☰ 36.11. Recommended Geant4 Simulation Workflow
-
Comments
Please login to add a comment.
Don't have an account? Register now!