Geant4.jl Examples
Examples for Geant4.jl, the Julia bindings to the Geant4 simulation toolkit. They range from simple geometries to optical photons, scoring, magnetic fields, event displays and offloading to GPUs.
Every page in this documentation is generated from the source of an example in the G4Examples.jl repository, and the example is run when the documentation is built. The pages show the code together with its output and plots, produced with the current versions of Geant4.jl and Geant4. Each page has links to download the example as a Jupyter notebook or as a plain Julia script.
Running the examples
Clone the repository and install the dependencies:
git clone https://github.com/JuliaHEP/G4Examples.jl.git
cd G4Examples.jl
julia --project=. -e 'using Pkg; Pkg.instantiate()'The first installation downloads the Geant4 libraries and data files, so it takes a while. Then run an example as a script, or open its notebook (.ipynb) in Jupyter or VS Code:
julia --project=. basic/B1/B1.jlThe scripts with visualization use GLMakie and open a window. On a Linux machine without a display, run them with xvfb-run. The notebooks and these pages use CairoMakie.
Examples
The examples are grouped like the examples of the Geant4 C++ distribution.
- Basic/B1 Example
- Basic/B2a Example
- Basic/B2a Event Display Example
- Basic/B3a Example
- Basic/B4a Example
- Extended/GPS Example
- OpNovice2 Example
- Extended/RE03 Example
- Geant4 Solids
- Extended/TestEm3 Example
- Extended/field02 Example
- Simulation of the Aleph TPC
- Calling Custom C++ library
- Calling G4 actions in Julia
- CERN Liquid Hydrogen Bubble Chamber
- Medical Linac
- RICH Detector
- RICH Detector with Offloaded Optical Photons
- RICH Detector with Optical Photons Offloaded to a GPU
- Scintillation Example
- Water Phantom with Scoring
- X-ray TES Detector