Geant4

From NEClusterWiki
(Redirected from GEANT4)
Jump to navigation Jump to search

About Geant4

Geant4 is a software toolkit for the simulation of the passage of particles through matter. It is used by a large number of experiments and projects in a variety of application domains, including high energy physics, astrophysics and space science, medical physics and radiation protection. It is free to install and run, and does not require RSICC approval.

Using Geant4

Geant4 is a simulation toolkit in which the user implements various classes in order to run their simulation; it is not like MCNP or other programs in which there is an input deck. The user needs to compile and link their code before running a simulation. This tutorial will describe using Geant4 on an implemented example from the toolkit.

Geant4 is installed in /opt/geant4.9.5. The data files are located in /opt/geant4.9.5/share/Geant4-9.5.1/data, and the examples in /opt/geant4.9.5/share/Geant4-9.5.1/examples.Please compile your Geant4 code on the head node necluster. Compute nodes do not have all the development libraries needed.

Example

First create a directory in which you plan to do your Geant4 Development:

mkdir Geant4WorkDir

It is recommended to use cmake with both a build and a source directory:

mkdir Geant4WorkDir/basic-src Geant4WorkDir/basic-build

Setup of the Geant4 variables is done with:

source /opt/geant4.9.5/bin/geant4.sh, and can be checked with printenv | grep G4.

Next, we will copy all of the basic examples into our source directory:

cd Geant4WorkDir/

cp -r /opt/geant4.9.5/share/Geant4-9.5.1/examples/basic/* basic-src/

ls basic-src/

Finally, we compile the code by building a makefile with cmake, and then running make.

cd basic-build/

cmake -i /home/murffer/Geant4WorkDir/basic-src/

The -i option to cmake runs in interactive mode. Select the Debug option, and change the install directory to something other than /usr/bin. I changed mine to /home/murffer/Geant4WorkDir/basic-src. make

make install The example can then be executed: cd ../basic-src/B4/B4d /home/murffer/Geant4WorkDir/basic-src/bin/exampleB4d run1.mac with the final lines of the output being:

----> print histograms statistic
EAbs : mean = 22.425706304686 MeV rms = 22.026959205583 MeV
EGap : mean = 207.54521746955 keV rms = 417.49822664632 keV
LAbs : mean = 1.5516788317101 cm  rms = 1.7340235417956 cm
LGap : mean = 1.0939232182903 mm  rms = 2.1946830757275 mm

Graphics systems deleted. Visualization Manager deleting...