Example Applications
A Geant4 application is a C++ program that calls functions in Geant4 libraries to perform some simulations. It must be compiled into an executable file before one can run it.
The simplest Geant4 example application is MinGLE - Mini Geant4 Learning Example. It is contained in a single C++ file that has less than 70 lines of code, and is ideal for learning how to write your own Geant4 applications.
GEARS is another single-file Geant4 application, yet is powerful enough to deal with most Geant4 simulations.
Both MinGLE and GEARS are regarded as universal Geant4 applications, that is, they are not tied to any specific detector definition, and can be used for most Geant4 simulations without the modification of their source code (See the following YouTube video for more information).
Get GEARS and MinGLE
Both applications can be downloaded from their GitHub pages individually. They are also included in this repository as Git submodules, and can be downloaded the following way if you are familiar with Git:
git clone https://github.com/jintonic/geant4
cd geant4
git submodule update --init --depth 1
where --depth 1
is used to avoid downloading the whole development history of GEARS and MinGLE.
To update, run
cd /path/to/geant4
# update geant4
git pull
# update gears and mingle
git submodule update --remote
Official Geant4 Examples
GEARS and MinGLE are more end-user-friendly than any official geant4 examples. However, if you’ve already grown out of them and want to learn more, the best way to download a single one from official is to follow this StackOverflow post: https://stackoverflow.com/a/70729494/1801749.
For Developers
GEARS and MinGLE are added as Git submodules the following way:
cd /path/to/geant4
git submodule add --depth 1 https://github.com/jintonic/gears examples/gears
git config -f .gitmodules submodule.examples/gears.shallow true
git commit -am 'added gears as submodule'
git push