Geant4
On this page... (hide)
- 1. Links
- 2. Documentation
- 3. Examples
- 4. Hints and changes
- 5. Physics Lists for after 4.9.5
1. Links
- Geant4
The main page for Geant4 - Latest nice Geant 4 Course
- 16th Seminar on Software for Nuclear, Sub-nuclear and Applied Physics , Porto Conte, Alghero (Italy), 26-31 May 2019.
- KISTI2019
- Nice YouTube tutorial ... Geant4-movie
Also has Python and machine learning
- Documentation
- Go to the GEANT4 home-page and get the latest documentation (make sure you have installed the latest version)
- Class list
- Geant4 Source reference
- CLHEP 1.9.2.2 Source reference (local, with search)
- Cross-reference of the complete Geant4 sources
- GATE - Geant4 Application for Tomographic Emission
Geant4 and PET, with sophisticated support for time (movement of the detectors, decaying of the sources). - PDG info on materials
- Parallel Geant4
- ParGeant4
- ParGeant4 @CERN
- Notes on Parallel Geant4
- TOP-C Task Oriented Parallel C/C++ library
- DAWN (Drawer for Academic WritiNgs) visualization - best for papers
- Visualisation tricks
2. Documentation
3. Examples
- Examples from Sergio (Updated to work with Geant4.8):
- A simple source and scintillator setup, with only minimal EM processes, and a proper G4SensitiveDetector that saves data in a Root TTree. Attach:MineralPET_scint.tgz
- A simple setup to test different converter target materials for e- -> gamma beam. Uses a SteppingAction to save (to a Root TTree) info about generated particles. Includes a more complete and modular PhysicsList, excluding processes that need the additional data files. Attach:MineralPET_target.tgz
- Newer versions of the same examples are available from the PSI Subversion repository:
svn checkout svn+ssh://psi.phys.wits.ac.za:/SVN/psi/scint
- Examples from Jonathan
- Example Of The Implementation Of Electromagnetic Fields In Geant 4
- This example shows how to add electromagnetic fields to a Geant 4 simulation.
- Benchmark example <-- important
- This is the template example we are using for incorporation of ROOT and for adding the Cluster Computing Capacity.
- Step-by-step guide to getting radioactive decay example working with Geant4.9.5 and 4.10.0 (p01)
4. Hints and changes
- RNG Seeding : G4.8.2 uses the new CLHEP 2, which requires the CLHEP:: namespace - just specify it or add some "using" statements
- To re-seed the Random Number Generator for many repeats of a MC from GEANT4 on differnt cores. In the
main
program of the GEANT4 application -
- To re-seed the Random Number Generator for many repeats of a MC from GEANT4 on differnt cores. In the
choose the Random engine CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); if (argc>=3) { CLHEP::HepRandom::setTheSeed(atoi(argv[2])); }
in this way you can run, for example
./<geant4app> <macro>.mac 1
./<geant4app> <macro>.mac 2
- cmake : Discussion about using cmake or make to compile projects.
- GEANT on the Cluster :
The cluster has CVMFS available on all nodes. LCG releases include Geant4, ROOT and many other HEP software packages. The setup script can be sourced like so:
source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_104 x86_64-centos7-gcc11-opt
Omit the target triplet to see a list of all triplets available for a given release or omit the release name to list all available releases. LCG releases are described at lcginfo.cern.ch (CERN account required).
- Building Geant4 on Ubuntu
- Install the following
sudo apt-get install cmake git
sudo apt-get install libx11-dev libxpm-dev libxft-dev libxext-dev
sudo apt-get install qt4-qmake libqt4-dev libxmu-dev
- Download tar file from Geant4 website: for example geant4.10.02.p03.tar.gz
- Extract files (it will place them into a dir such as "geant4.10.02.p03")
- Create a build dir:
mkdir geant4.10.02.p03-build
cd geant4.10.02.p03-build
- Then cmake as below: (NOTE there are two ways to do this depending if you let cmake AUTOMATICALLY download the required datafiles for you or if you MANUALLY do this)
- AUTOMATIC way enter:
cmake -DCMAKE_INSTALL_PREFIX=/<PATH_TO_your_yet_to_be_created_install_dir>/geant4.10.02.p03-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGEANT4_INSTALL_DATA=ON \\ -DGEANT4_USE_QT=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_RAYTRACER_X11=ON ../geant4.10.02.p03
make
make install
- (NOTE: If anything stops due to errors, you are usually missing some libraries so install them: $ sudo apt-get install library-dev for some library)
- Edit .bachrc to include:
Geant4_DIR=/<PATH_TO>/geant4.10.02.p03-install
. $Geant4_DIR/bin/geant4.sh
- MANUAL way:
- Download the data tar files from GEANT4 site then from build_dir:
cmake -DCMAKE_INSTALL_PREFIX=/<PATH_TO_your_yet_to_be_created_install_dir>/geant4.10.02.p03-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGEANT4_INSTALL_DATA=OFF \\ -DGEANT4_USE_QT=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_RAYTRACER_X11=ON ../geant4.10.02.p03
make
make install
- (NOTE: If anything stops due to errors, you are usually missing some libraries so install them: $ sudo apt-get install library-dev for some library)
- Extract downloaded datafiles and put them into a dir called "data" then place this dir into /install_dir/share/Geant4-10.2.3
- Edit .bashrc to include:
Geant4_DIR=/<PATH_TO>/geant4.10.02.p03-install
. $Geant4_DIR/bin/geant4.sh
- Download the data tar files from GEANT4 site then from build_dir:
- Install the following
- Building Geant4 on a Mac ....
- tested on Geant4.10.05 and OSX 10.13 to 10.15
- Follow instructions at
http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/InstallationGuide/html/
- Install Xcode (latest), the command line tools and XQuartz.
- Google how to install just the command line tools, not the whole X11, which takes over 10G space and is hardly used.
- Check xquartz was up to date (just ran
Xquartz
, it automatically gave a notice about an update).
- To have the visualisation tools, automatically download and install the data libraries (make sure you have x11, Qt, openmotif, expat) .... do the following (from your build directory) ....:
- Install Qt version 5 ****
brew install qt
- Check xquartz was up to date (just ran
Xquartz
, it automatically gave a notice about an update).
- If you want Motif
brew install homebrew/x11/openmotif
( installed stable 2.3.4 )
- Go into a separate build directory, out of source tree
cmake -DCMAKE_INSTALL_PREFIX=/path/to/geant4.10.05-install/\\ -DCMAKE_BUILD_TYPE=RelWithDebInfo \\ -DGEANT4_INSTALL_DATA=ON \\ -DGEANT4_USE_QT=ON \\ -DGEANT4_USE_XM=ON \\ <--- if you have it -DGEANT4_USE_OPENGL_X11=ON \\ -DGEANT4_USE_RAYTRACER_X11=ON \\ -DMOTIF_INCLUDE_DIR=/usr/OpenMotif/include \\ <--- if you have it -DMOTIF_LIBRARIES=/usr/OpenMotif/lib/libXm.3.1.dylib \\ <--- if you have it /path to your source of geant4.10.05/
make -j4
to compile with support for 4 cores. Thenmake install
- Don't forget to source the geant4.sh script in your bashrc file from geant4.10.0-install/bin folder.
- for zsh of Catalina you need to first cd to the file and then source it.
current_dir=$PWD cd ~connell/sw/geant4/geant4.10.05-install/bin source geant4.sh cd $current_dir
- Install Xcode (latest), the command line tools and XQuartz.
- The CmakeLists file is now already set for using ROOT ... so just add
export $G4ANALYSIS_USE_ROOT 1
in your bashrc file as well. - Note on the datasets. You can download them manually and place them in
/path/to/geant4.10.01.p02-install/share/Geant4-10.1.2/data
as that is where they are preconfigured to be. Then don't use the switch-DGEANT4_INSTALL_DATA=ON
... this is easier for slow networks. - For the MULTITHREADED version, use
-DGEANT4_BUILD_MULTITHREADED=ON
when you build Geant4 and then use/run/numberOfThreads n
in your macro file. - If there are problems finding qt5, use
-DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/
or wherever you have qt5.
5. Physics Lists for after 4.9.5
- We start from "Shielding" for MinPET Physics lists from the Use Cases.