Geant4
On this page... (hide)
1. Links
- Geant4
The main page for Geant4 - Geant4 at INFN Genova
Plenty of tutorials, papers, talks and links - 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. Geant4 Course
- Geant4 Course at the 15th Seminar on Software for Nuclear, Sub-nuclear and Applied Physics, Porto Conte, Alghero (Italy), 27 May - 1 June, 2018.
4. 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)
5. 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 :
- See the following page for a tutorial on using Swift:
- Swift tutorial.
- Note that this uses the modifications as for the rdecay02 example for the passing arguments on the command line and using the messenger class technology, so that you can do parameter scans etc. (See the redcay02 example discussion above).
6. Installing GEANT4
- Download the sources and the data libraries here
- The Installation guides are here, use of the default names for the source, install and build directories, and also the path to the data files, is recommended.
- Building Geant4 on Windows
- see ROOT and GEANT4 in CYGWIN on Windows XP (not sure if this works anymore)
- Building Geant4 on Linux
- See instructions at the GEANT4 and then do ...
sudo yum install qt-devel
sudo yum install motif-devel
sudo yum install libXmu-devel
cmake -DCMAKE_INSTALL_PREFIX=/path/to/geant4.10.00.p01-install/ \\ -DCMAKE_BUILD_TYPE=RelWithDebInfo \\ -DGEANT4_INSTALL_DATA=ON \\ -DGEANT4_USE_QT=ON \\ -DQT_QMAKE_EXECUTABLE=/usr/lib64/qt4/bin/qmake <--- not doing this now -DGEANT4_USE_XM=ON \\ <--- not doing this now -DGEANT4_USE_OPENGL_X11=ON \\ -DGEANT4_USE_RAYTRACER_X11=ON \\ -DMOTIF_INCLUDE_DIR=/usr/include/Xm/ \\ <--- not doing this now -DMOTIF_LIBRARIES=/usr/lib64/libXm.so \\ <--- not doing this now /path/to/geant4.10.00.p01
make -jN (N = number of cores)
make install
- See instructions at the GEANT4 and then do ...
- 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 (a la Martin) ....
- tested on 4.9.3 and 4.9.5
- 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) ....:
cmake -DCMAKE_INSTALL_PREFIX=/path/to/geant4.9.5-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 \\ <--- if you have it -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.9.5.p01/
make -j4
to compile with support for 4 cores. Thenmake install
- Update for OSX 10.9.2 (Mavericks) and Geant4.10.00.p01 :
- Install Xcode (latest), the command line tools and XQuartz
- Install Macports and use that to instal openmotif (sudo port install openmotif).
- Install Qt version 4.8.5.
- For Geant4.10.00.p01 ... the data directory is by default /(path-to-geant)/geant4.10.0-install/share/Geant4-10.0.1/data, so if you do a manual install of the data, place them in this folder.
- Don't forget to source the geant4.sh script in your bashrc file from geant4.10.0-install/bin folder.
- The rest of the current instructions for the Installation of Geant and also the template application code (rdecay02) is pretty similar. The CmakeLists file is now already set for using ROOT ... so just add
export $G4ANALYSIS_USE_ROOT 1
in your bashrc file as well.
- Update for OS X 10.10.5 (Yosemite) and Geant4.10.01.p02 :
- Followed instructions at
http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/ch01s02.html
- First installed Qt… uninstalled previous version using script in /Developer/Tools
brew install qt
(qt4 sounds like it is more widely used than qt5)brew install homebrew/x11/openmotif
( installed stable 2.3.4 )
- Made sure my xquartz was up to date (just ran
Xquartz
, it automatically gave a notice about an update). - Go into a separate build directory, out of source tree
cmake -DCMAKE_INSTALL_PREFIX=/path/to/geant4.10.01-install/ \\ -DCMAKE_BUILD_TYPE=RelWithDebInfo \\ -DGEANT4_INSTALL_DATA=ON \\ -DGEANT4_USE_QT=ON -DGEANT4_USE_OPENGL_X11=ON \\ -DGEANT4_USE_RAYTRACER_X11=ON \\ /path/to/geant4.10.01.p02
make -j4
... your number of coresmake install
- Followed instructions at
- 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. - Don't forget to source the environment configuration script ... its [@/path/to/geant4.10.01.p02-install/bin/geant4.sh]
- tested on 4.9.3 and 4.9.5
7. Physics Lists for after 4.9.5
- We start from "Shielding" for MinPET Physics lists from the Use Cases.