Explore two models used to teach radiation transport and gamma-ray spectroscopy. Adjust the parameters, interpret the graphs, then inspect the code behind each example.
Photon attenuation
For a narrow monoenergetic beam in a homogeneous slab, the uncollided fraction follows I/I₀ = exp(−μx), where μ is the linear attenuation coefficient and x is thickness. The marker shows the result at your selected thickness.
Transmitted fraction: 13.5%
Try it At μ = 0.20 cm⁻¹, compare 5 cm and 10 cm. Doubling thickness squares the transmitted fraction. This analytical benchmark assumes scattered photons are excluded.
Gamma-ray spectrum
A synthetic 661.7 keV peak is sampled from a Gaussian distribution and added to a uniform background. Change the detector resolution, expressed as full width at half maximum (FWHM). Each run uses the same seed to make the change easier to compare.
Synthetic counts in 10 keV bins
Try it Compare 20 keV with 80 keV. The peak spreads over more bins while the model starts with the same number of signal events. This synthetic example omits a realistic Compton continuum and detector response.
Code examples
Geant4
Configure a monoenergetic photon source in an existing G4ParticleGun application. The macro sets the source only. In your application, define the slab, enable electromagnetic interactions, and score uncollided primary photons at the exit before comparing with the analytical curve.
View source
# For a Geant4 application that uses G4ParticleGun.
# Example geometry assumption: a slab normal to z, downstream of z = -10 cm.
# Change source position to match your geometry.
/run/initialize
/gun/particle gamma
/gun/energy 661.7 keV
/gun/position 0 0 -10 cm
/gun/direction 0 0 1
/run/beamOn 100000
Fill a TH1D histogram with a Gaussian peak and flat background, then display it in ROOT. The macro uses the same model as the browser demonstration, with ROOT’s own random-number generator.
root -l gamma_spectrum.C
View source
#include <TCanvas.h>
#include <TH1D.h>
#include <TRandom3.h>
// Run with: root -l gamma_spectrum.C
void gamma_spectrum() {
constexpr double peakEnergyKeV = 661.7;
constexpr double fwhmKeV = 40.0;
TRandom3 random(42);
auto* spectrum = new TH1D("synthetic_gamma", "Synthetic spectrum;Energy (keV);Counts / 10 keV", 80, 0, 800);
for (int event = 0; event < 1800; ++event)
spectrum->Fill(random.Gaus(peakEnergyKeV, fwhmKeV / 2.35482));
// A uniform background makes the peak easier to study independently.
for (int event = 0; event < 5000; ++event)
spectrum->Fill(random.Uniform(0.0, 800.0));
auto* canvas = new TCanvas("gamma_spectrum_canvas", "Gamma spectrum", 820, 460);
spectrum->SetLineColor(kBlue + 2);
spectrum->Draw("HIST");
canvas->Update();
}
Use these exercises to apply methods from the papers to your own data.
Geant4 and XCOM · Coated cotton gabardine
Keep composition and areal density fixed, then compare a homogeneous slab with a geometry that resolves the coating and fabric. Score uncollided photons separately from detector counts.
Export XCOM coefficients for water and lead. In ROOT, divide each partial coefficient by the same material’s total at each energy. Plot the fractions on a log energy axis and identify where the largest contribution changes.
The paper studied coated fabrics and glass at the two cobalt-60 gamma energies, 1173 and 1332 keV. Use two acquisition windows and compute background-corrected transmission separately for each energy.
C++ and ROOT · Charged-particle stopping and range
Use stopping-power tables for two particle types in the same medium. In C++, numerically integrate the reciprocal of stopping power over a shared energy interval, then plot the ranges in ROOT. Use consistent units and report the energy interval.