This snippet uses Monte Carlo simulations to study the response of nuclear physics detectors to radiation. It uses the C++ libraries package Geant4.
The program to run is
sim1/test.cc. It defines and creates all the necessary tools to launch a simulation. It also checks for certain environment variables that you may define when you work with Geant4. The relevant subroutines are in the
include folders, where the source and header files are, respectively.
Once the program is compiled with the Geant4 libraries, the executable is generated in the
bin/Linux-g++/ folder. You can run it by typing:
$ . ./bin/Linux-g++/test
The detailed information of the tracks can be studied with the macro
print-track.mac. The spectra of deposited energy can be obtained with
spec-eff.mac and then visualized with
hplot.cpp in ROOT, to calculate the total and peak efficiency.
Before you compile and run this program, you will need to install the Geant4 libraries.
This short set of instructions are written to help in an individual installation of GEANT4. A file .geant_myconfig containing environment variables for GEANT4 should be used with this instructions. Please, check the additional documentation in the GEANT4 pages.
The guide has been elaborated using Fedora Core 3 with gcc3.4.2 and gcc3.4.3 and GEANT4.7.0.p01 with CLHEP 220.127.116.11. Please, note that paths and installation details could be different using other Linux flavours, compilers...
example (Fedora Core 1 with gcc 3.3.2):
$ gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
It is stated in the GEANT4 documentation that some versions are not supported. In particular, gcc-2.96 distributed in RedHat 7.X is NOT supported.
and check the velocity with:
A velocity above 500 FPS usually indicates a correct hardware installation.
The libraries for OpenGL could be in different locations (usually in
usr/X11R6/lib). Try with the command:
$ locate libGL.so
if you cannot find them.
If you do not have OpenGL you should disable it in the configuration file (
.geant_myconfig). Comment the line:
and use another graphics system.
.gitignore, there is a configuration file for ROOT variables, check out root-configure.
Most of them available from the GEANT4 main web, section download:
/usr/local/clhepdirectory for the installation. You might need to create two symbolic links to the CLHEP library in the
/usr/local/clhep/libdirectory; for instance, if your library is libCLHEP-g++.18.104.22.168.a, go to the directory where the file is and type the commands:
$ ln -s libCLHEP-g++.22.214.171.124.a libCLHEP-g++.a
$ ln -s libCLHEP-g++.126.96.36.199.a libCLHEP.a
to have these two symbolic links to the library.
I normally use the directory name G4 in my local account.
/datawithin the GEANT4 structure (for instance, in my local installation it is:
Now you have two possibilities:
.geant_myconfig) in the directory created by the GEANT4 source code (for instance in my case it is
G4/geant4.6.2.p02/). Type the command:
$ ./Configure -build
and follow the on-screen instructions. It will configure a set of environment variables which are already defined in the
.geant_myconfigto set the directories where the GEANT4 installation was performed. Also check the OpenGL directory (variable
.geant_myconfigto set the environment variables and go to the source directory (
$G4INSTALL/source) and type:
.geant_myconfig) to your main directory (or under
/myusername/bin, for instance) and run it as a script each time you want to use GEANT4. A good idea is to include the script in the
.profilefiles (whatever you use).
and check the output to see the variables defined in the script). It is possible that you have to modify some variables in the file, if the paths do not match those in your installation.
Once the process of building the libraries has been completed successfully, the Geant4 toolkit can be installed in the specified (already existing) installation area by typing:
(I do not use this command and I stay with the program in the directory where it was compiled).
Test the available GEANT4 examples, following the instruction in their README.
OPTIONAL: If you want a user interface for Geant4, download the G4UIROOT program and follow the installation instructions
#! /bin/tcsh export G4SYSTEM = Linux-g++ export G4INSTALL = /home/admin/G4/geant4.7.0.p01 export CLHEP_BASE_DIR = /usr/local/clhep export CLHEP_NAME = CLHEP export CLHEP_LIB_DIR = $CLHEP_BASE_DIR/lib export CLHEP_INCLUDE_DIR = $CLHEP_BASE_DIR/include #optionals... see manuals export G4WORKDIR = /home/admin/G4/geant4.7.0.p01 export G4TMP = $G4WORKDIR/tmp export G4BIN = $G4WORKDIR/bin export G4INCLUDE = $G4INSTALL/include export G4UI_USE_TCSH = 1 export G4LEVELGAMMADATA = $G4WORKDIR/data/PhotonEvaporation export G4RADIOACTIVEDATA = $G4WORKDIR/data/RadiativeDecay export G4LEDATA = $G4WORKDIR/data/G4EMLOW2.3 export NeutronHPCrossSections = $G4WORKDIR/data/G4NDL3.7 export G4ELASTICDATA = $G4WORKDIR/data/Elastic export G4ANALYSIS_USE = 1 export G4DEBUG = 1 export G4LIB_BUILD_G3TOG4 = 1 export G4USE_G3TOG4 = 1 export G4LIB_BUILD_SHARED = 1 export G4LIB_BUILD_STATIC = 1 export G4LIB_USE_GRANULAR = 1 #visualization #export G4UI_BUILD_XAW_SESSION = 1 #export G4UI_BUILD_XM_SESSION = 1 export G4VIS_BUILD_OPENGLX_DRIVER = 1 #export G4VIS_BUILD_OPENGLXM_DRIVER = 1 #export G4VIS_BUILD_DAWN_DRIVER = 1 #export G4UI_USE_XAW = 1 #export G4UI_USE_XM = 1 export G4VIS_USE_OPENGLX = 1 #export G4VIS_USE_OPENGLXM = 1 #export G4VIS_USE_DAWN = 1 #ROOT INTERFACE TO G4 export G4UI_BUILD_ROOT_SESSION = 1 export G4UI_USE_ROOT = 1 export OGLHOME = /usr/X11R6/lib LD_LIBRARY_PATH = $G4WORKDIR/lib/Linux-g++:$LD_LIBRARY_PATH export LD_LIBRARY_PATH LD_LIBRARY_PATH = /usr/local/clhep/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH PATH = $G4INSTALL/bin/Linux-g++:$PATH export PATH echo GEANT4 Variables Configured...
#! /bin/tcsh # Variables setenv ROOTSYS /afs/ific.uv.es/project/gamma/root_v3.10.02.Linux.RH7.3.gcc296 # Paths set path = ($path $ROOTSYS/bin) # Library paths setenv LD_LIBRARY_PATH $ROOTSYS/lib
Check out the official Geant4 installation guide
Published: 2006-04-28 15:56:04