Running the examples

The pages in this section are generated from the Literate sources in docs/src/examples and run with the current version of Geom4hep.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.

ExampleContent
ShapesCreating shapes, calling the shape functions and drawing them
VolumesBuilding a hierarchy of volumes and drawing it
NavigationClosing a geometry, following rays through it and X-ray images
GDMLReading GDML files: the CMS 2018 detector
GDML RenderingRendering the CMS and LHCb detectors with GLMakie
RoundCubePorting a Geant4 solid built from boolean operations, and checking it
BenchmarksTiming the shape functions with the methodology of VecGeom

Setting up an environment

The examples use extra packages for plotting (CairoMakie or GLMakie). The simplest way to run them is with the environment of this documentation, which lists every package they need:

git clone https://github.com/JuliaHEP/Geom4hep.jl.git
cd Geom4hep.jl
julia --project=docs -e 'import Pkg; Pkg.develop(path="."); Pkg.instantiate()'
julia --project=docs docs/src/examples/Shapes.jl

To run an example downloaded from these pages instead, put it in a directory with the Project.toml of the documentation, run julia --project=. -e 'import Pkg; Pkg.instantiate()' (which installs the registered Geom4hep), and then the example, or open the notebook in Jupyter.

The repository has more examples in the examples directory, with their own environment: X-ray images on GPUs (XRay.jl), density slices of the CMS detector (Render.jl), interactive drawing of a detector (DrawDetector.jl) and the comparison of the shape benchmarks with VecGeom (Benchmarks.jl).