Running the examples
The examples are ports of the Geant4 basic, extended and advanced examples, plus some that show features specific to Julia. Their source is in the G4Examples.jl repository, kept separate from this package because the examples use extra packages for plotting and visualization (Makie, Plots, FHist, ...).
The pages in this section are generated from those sources and run with the current version of Geant4.jl when the documentation is built. They show the code together with its output and plots. Each page has links to download the example as a Jupyter notebook or a plain Julia script.
Setting up an environment
The simplest way to run the examples is to clone G4Examples.jl, which includes a Julia environment with all the dependencies:
git clone https://github.com/JuliaHEP/G4Examples.jl.git
cd G4Examples.jl
julia --project=. -e 'import Pkg; Pkg.instantiate()'
julia --project=. basic/B1/B1.jlTo run an example downloaded from these pages instead, use the Project.toml of this documentation, which lists every package that the examples need:
- Put
Project.tomlin an empty directory, together with the downloaded example and any files it includes (for example,B2aDetector.jl). - Run
julia --project=. -e 'import Pkg; Pkg.instantiate()'. The first time, this takes a while: it downloads the Geant4 data files and compiles Makie. - Run the example with
julia --project=. <example>.jl, or open the notebook in Jupyter.
The interactive visualization uses GLMakie, which needs a display. On a headless Linux machine, run the examples under xvfb-run.
Available examples
- Basic/B1 Example
- Basic/B2a Example
- Basic/B2a Event Display Example
- Basic/B3a Example
- Basic/B4a Example
- Extended/GPS Example
- Extended/RE03 Example
- Extended/TestEm3 Example
- Geant4 Solids
- GDML rendering example (CMS)
- GDML rendering example (ODD)
- Extended/field02 Example
- OpNovice2 Example
- Simulation of the Aleph TPC
- CERN Liquid Hydrogen Bubble Chamber
- Water Phantom with Scoring
- Calling Custom C++ library
- Calling G4 actions in Julia
- Scintillation Example
- RICH Detector