35.11. Validate the Simulation
Table of Contents
Checking That Your Final Project Is Trustworthy
Your final project should not only compile and run. It must also produce results that you can trust. Validation is the process of checking that your simulation is physically reasonable, numerically stable, and consistent with known information. In the context of this course, you will perform a practical, lightweight validation, not a complete professional validation campaign, but you should still follow a clear and systematic procedure.
Validation comes after you have created the geometry, defined materials, configured the source, selected the physics list, implemented sensitive detectors, and recorded data. Here you confirm that the overall detector simulation behaves as expected before you present or publish any results.
Define What “Correct” Means For Your Project
Validation always starts with a clear statement of what you expect. For your final project, you have already defined a simulation goal. Use that goal to decide which quantities you must validate.
If your goal is a gamma detector, you might focus on energy spectra and detection efficiency. For a shielding study, you might focus on transmission and attenuation. For a proton beam in water, you might focus on the depth dose and Bragg peak position. Each case suggests different checks, but the logic is the same: identify a few key observables that directly reflect whether the simulation is behaving correctly.
Important rule: Do not validate by looking only at pretty plots. Always identify at least one quantitative check, such as a peak position, a ratio, or a slope, that you can compare to a known value or independent calculation.
Write down your expected behavior before you run large simulations. This prevents you from “tuning” your expectations to match whatever output you get.
Step 1: Internal Consistency Checks
Begin validation by checking that the simulation is internally consistent. These checks use only information from within your Geant4 application and do not require external data.
Check geometry and materials
By this stage of the course you have built complex geometry and materials. For validation, you do not re-derive everything, but you verify that what you implemented matches your design.
Use visualization and macro commands to:
View the full geometry and confirm that all key volumes are present, correctly oriented, and in the right positions relative to each other. Check that sensitive volumes appear where you expect. For segmented detectors, make sure that the number of detector elements, their spacing, and overall extent match your design choices.
Print or log material information for critical regions. For example, confirm that the detector crystal has the intended density and composition, and that passive components such as shielding are made of the correct materials.
A simple table like this can be helpful in your notes:
| Component | Intended material | Implemented material (name) | Density check |
|---|---|---|---|
| Detector crystal | NaI(Tl) | G4_SODIUM_IODIDE | Ok |
| Shield | Lead | G4_Pb | Ok |
| Phantom | Water | G4_WATER | Ok |
If you spot something inconsistent here, you must fix it before any further validation.
Check event and energy accounting
Next, check the basic accounting of events and energy in your application.
Confirm that the number of simulated events corresponds to what you requested with /run/beamOn. If you use filters or classification of tracks, check that they do not silently discard all events of interest.
For energy, you want to be sure that your sensitive detectors record something physically sensible and that the recorded energy is not systematically biased by a coding mistake. You can:
Print a few events to the console with detailed stepping or tracking verbosity. Verify that particles entering a sensitive volume produce hits and that the recorded energy and positions are plausible.
Check that no impossible values appear in your analysis output, such as negative deposited energy, times far outside the expected range, or energy values exceeding the total particle energy.
Perform a simple energy balance if it is meaningful for your project. For example, for a monoenergetic gamma beam, the sum of deposited energy across all volumes plus escaped energy should be close to the incident energy multiplied by the number of primaries, within statistical fluctuations.
Important rule: If you see negative energies, impossible times, or no hits at all in key detectors, treat this as a validation failure, not just a curiosity. Fix the underlying cause before you proceed.
Step 2: Compare With Simple Analytical Expectations
After internal checks, compare your Geant4 results with at least one simple analytical or semi-analytical calculation. The goal is not to reproduce the full complexity of the simulation, but to confirm that the overall scale and shape of your results make sense.
Identify a simple quantity to calculate
Choose a quantity that both your simulation and a simple theory can predict. Some examples:
For a gamma detector, the position of a photopeak or Compton edge in an energy spectrum.
For a shielding study, the exponential decrease of intensity with thickness, using a linear attenuation coefficient $\mu$.
For a proton beam in water, the approximate depth of the Bragg peak, from range tables or literature values.
For PET or coincidence detection, the number of events passing a simple energy window compared to the total number of decays.
Once you select a quantity, write down the corresponding formula or reference relationship. For instance, for attenuation:
$$
I(x) = I_0 e^{-\mu x}
$$
or for the probability that a gamma interacts before a distance $x$:
$$
P(\text{interaction before } x) = 1 - e^{-\mu x}.
$$
Perform the comparison
Run your simulation with enough events for a rough comparison. Then extract the observable from your analysis output and overlay it with the simple expectation.
Examples of practical comparisons:
If you simulate transmission through a shield, plot the simulated transmission fraction versus thickness and compare with the theoretical exponential using a known $\mu$ for your gamma energy and material.
If you simulate a monoenergetic gamma detector, measure the peak position in your energy histogram and compare it to the expected energy, taking into account any known detector scale or resolution smearing you applied.
If you simulate a proton beam in water, calculate the average depth of maximum deposited energy and compare it to a tabulated range for that proton energy.
Important rule: A 10 to 20 percent mismatch in a simple, basic quantity is usually a warning sign for a beginner-level project. Either your analytical estimate is too crude, or more often, something is inconsistent in geometry, materials, or physics.
In your project report, show at least one such plot or table that clearly compares simulation to analytical expectations, and briefly discuss any differences.
Step 3: Compare With External or Reference Data
When possible, validate your simulation by comparing to existing data or mature calculations. For an introductory course project, you are not expected to access complex experimental datasets, but you can often find simple reference values in textbooks, lab manuals, or published figures.
Choose appropriate reference data
Look for data that matches your scenario reasonably well:
Attenuation curves for gamma rays in common shielding materials such as lead, aluminum, or concrete.
Published energy spectra for standard gamma calibration sources in typical detectors.
Depth dose curves or Bragg peak positions for proton beams in water.
Simple detector response curves, such as efficiency versus energy, from existing measurements.
Make sure you understand the conditions of the reference data, especially energy, geometry, and materials. Your simulation does not have to copy them exactly, but large differences in setup can make a direct comparison misleading.
Adjust expectations for your simplified model
Your final project uses simplified geometry, materials, and physics lists. Reference data from real experiments often include more complexity, such as detailed electronics response or incomplete knowledge of materials. Expect some discrepancy.
When comparing, ask:
Is the overall trend the same? For example, does transmission decrease in the same way with thickness or energy?
Are the key features, such as peak positions or approximate magnitudes, reasonably close?
Can you explain any differences based on known simplifications in your model, such as missing dead layers, simplified resolution smearing, or no optical photon simulation?
In your report, clearly separate what your simulation includes from what the reference data include. This helps you and the reader judge whether the agreement is acceptable.
Important rule: Never force your simulation to “fit” the reference data by arbitrary tweaking. Only adjust parameters that represent genuine physical uncertainties or known design choices, and document each change.
Step 4: Check Statistical Uncertainties and Convergence
Even a perfectly implemented simulation will not match analytical formulas or data exactly, because it uses random sampling. To validate properly, you must understand how statistical uncertainty affects your results.
Estimate statistical uncertainties
For simple quantities like counts, the standard deviation is approximately $\sqrt{N}$ for $N$ independent events. For an efficiency $\epsilon$ estimated as $\epsilon = N_{\text{detected}} / N_{\text{incident}}$, a common approximation for the uncertainty is
$$
\sigma_\epsilon \approx \sqrt{\frac{\epsilon(1 - \epsilon)}{N_{\text{incident}}}}.
$$
Important formula: For large counts, a simple rule is that the relative uncertainty is
$$
\frac{\sigma_N}{N} \approx \frac{1}{\sqrt{N}}.
$$
So $10^4$ events give roughly 1 percent statistical uncertainty.
In histograms, each bin has its own count and therefore its own uncertainty. When comparing a simulated spectrum to a model, remember that fluctuations from bin to bin are expected.
Check convergence with more events
A practical way to validate is to run multiple simulations with increasing numbers of events, for example $10^3, 10^4, 10^5$, and see how a key observable behaves.
Track a quantity such as:
The position of a peak.
The mean energy deposited in a detector.
The transmission fraction through a shield.
If your implementation is correct, the value should stabilize as you increase the event count, with the variations decreasing roughly as $1 / \sqrt{N}$.
If the quantity drifts systematically as you simulate more events, inspect your analysis and bookkeeping. You might be accumulating variables incorrectly or have an overflow or reset problem.
In your final report, you do not need an exhaustive study, but you should run at least one higher-statistics test to show that your main conclusion does not change dramatically when you increase the number of events.
Step 5: Document Validation Results
Validation is only complete when it is documented. For the final project, your documentation does not need to be long, but it should be clear and honest.
Include a dedicated section where you:
List the main quantities you validated, such as energy spectra shape, transmission, or depth dose.
Summarize the internal checks you performed, including geometry inspection and basic energy accounting.
Show at least one comparison to an analytical estimate or external data, with a short discussion of agreement or disagreement.
Comment on the level of statistical uncertainty in your key results and how you chose the number of simulated events.
Explicitly mention any known limitations of your simulation, such as missing physical effects, simplified materials, or coarse geometry, and explain how they might affect the comparison.
Important rule: A clearly documented imperfection is better than a hidden one. For an educational project, it is acceptable to state that results agree only at the 20 percent level, provided you explain why and what you would improve next.
This validation section will be an important part of your final grade, because it shows that you understand not only how to run a simulation, but also how to judge its reliability.
Using Validation To Guide Improvements
Validation is not a one-time checkbox. The differences you observe between simulation and expectations can guide you toward meaningful improvements.
If your shielding transmission is consistently too high, you might revisit material densities or compositions.
If your detector spectrum is shifted in energy, you might check your unit usage, detector thickness, or physics list choice.
If your proton Bragg peak is at the wrong depth, you might confirm that your phantom material truly matches water and that your beam energy is correctly defined.
Each validation step gives you feedback. You can decide whether to refine the model during the course or simply record the limitation in your report. The important skill is to use validation results to make informed decisions, not to ignore them.
By following this structured validation procedure in your final project, you will demonstrate that your Geant4 simulation is not just a set of C++ classes, but a physically meaningful model whose results can be interpreted with confidence.
Views: 10
KAHIBARO