Installation Guide for GEANT4 (short version)

Build Geant4 on Ubuntu

  1. Install GUI package manager synaptic
sudo apt-get update  
sudo apt-get install synaptic  
  1. Open synaptic, search for the following packages and install them if not already installed.
git  
dpkg-dev  
cmake  
g++  
gcc  
binutils  
libx11-dev  
libxpm-dev  
libxft-dev  
libxext-dev  
libxmu-dev  
libpng  
libjpeg  
python

gfortran  
libssl-dev  
libpcre3-dev  
libglew-dev  
libftgl-dev  
libmysqlclient-dev  
libfftw3-dev  
libcfitsio-dev  
graphviz-dev  
libavahi-compat-libdnssd-dev  
libldap2-dev  
python-dev  
libxml2-dev  
libkrb5-dev  
libgsl-dev  
libqt4-dev

libxerces-c-dev  
libmotif-dev  
libglw1-mesa-dev  
opticalraytracer  
  1. fetch the newest tar package from CERN and build.
# make a directory to store files
cd <where-you-want-to-keep-geant4> e.g. /softwares or /home/tom/apps ...  
mkdir geant4  
cd geant4

# download and extract geant4 source code
wget http://geant4.web.cern.ch/geant4/support/source/geant4.10.03.p03.tar.gz  
tar zxvf geant4.10.03.p03.tar.gz

# prepare for installation
mkdir geant4.10.03-install # built binary files will be move to this directory  
cd geant4.10.03.p03  
mkdir build

# save cmake command with options into a file
# CHANGE <where-you-want-to-keep-geant4> to your directory
echo cmake -DCMAKE_INSTALL_PREFIX=<where-you-want-to-keep-geant4>/geant4/geant4.10.03-install -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_QT=ON <where-you-want-to-keep-geant4>/geant4/geant4.10.03.p03 > cmakeCommand.txt

# execute cmake command and save log output into a file
cd build  
`cat ../cmakeCommand.txt` >& cmake.log

# read cmake.log using your favourite reader/editor.
# **check everything looks okay (NO ERROR)**
# most ERRORs are related to missing packages / development files
# use `synaptic` to install them
less cmake.log


# build geant4, may take more than half an hour.
make -j2  
make install  
  1. add geant4 configure script to your start-up script (~/.bashrc)
# append these two lines into ~/.bashrc
source <where-you-want-to-keep-geant4>/geant4/geant4.10.03-install/bin/geant4.sh  
source <where-you-want-to-keep-geant4>/geant4/geant4.10.03-install/share/Geant4-10.3.3/geant4make/geant4make.sh  
  1. verify installation with built-in example
cd <where-you-want-to-keep-geant4>/geant4/geant4.10.03-install/share/Geant4-10.3.3/examples/basic/B1  
mkdir build && cd build

cmake ..  
make

# check the output of make and run the program
./exampleB1

You should see a window like this:

exampleB1

Use Docker Image

1. Install docker

2. Test docker installation

docker run hello-world  

3. Pull GEANT4 Image from DockerHub

docker pull nmtzwh/scistack  

If you are interested, this repository contains all the dockerfiles for this image.

4. Run Image as a Container

# use the bash entry point to test
docker run -it --rm nmtzwh/scistack

# run with local directory mounted
docker run -it --rm -v <full-path-to-input>:/input nmtzwh/scistack  

You can build and run GEANT4 code inside this container. NOTE: modifications inside container will be deleted after you exit, thus you should mount your local directory and then edit your files in local directory.