Ilker Can CELIK

Geant4 · C++ · ROOT

Computational Nuclear Physics

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.

0.2
10
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.

40
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
Download · geant4_gamma_source.mac

Geant4 basic examples

C++

Compute the same attenuation curve and export 21 points as CSV. Enter μ in cm⁻¹ and the maximum thickness in cm.

c++ -std=c++17 attenuation.cpp -o attenuation
printf '0.20 10\n' | ./attenuation > curve.csv
View source
#include <cmath>
#include <iomanip>
#include <iostream>

int main() {
    double mu = 0.0;
    double thickness = 0.0;
    if (!(std::cin >> mu >> thickness) || !std::isfinite(mu) ||
        !std::isfinite(thickness) || mu < 0.0 || thickness < 0.0) {
        std::cerr << "Enter a nonnegative coefficient (cm^-1) and thickness (cm).\n";
        return 1;
    }

    std::cout << "thickness_cm,transmitted_fraction\n" << std::setprecision(8);
    for (int step = 0; step <= 20; ++step) {
        const double depth = thickness * (step / 20.0);
        std::cout << depth << ',' << std::exp(-mu * depth) << '\n';
    }
}
Download · attenuation.cpp

ROOT

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();
}
Download · gamma_spectrum.C

ROOT TH1D

Exercises based on recent publications

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.

Read the article ↗ · Radiation Physics and Chemistry

ROOT and XCOM · Photon interaction dominance

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.

Read the article ↗ · Harran University Journal of Engineering · 2026

Gamma transmission · Cerium oxide coatings

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.

Read the article ↗ · Radiation Effects and Defects in Solids · 2026

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.

Read the article ↗ · The European Physical Journal Plus · 2025

Related research