So, I’ve got an interview later in the week, and the job spec asks for experience in MCNP or Geant4. Since I have used MCNP in the past, I thought I’d install and get to grips with Geant4 before the interview. Well, that’s easier said than done. There isn’t really a single webpage which gives you all the info, if you’re installing Geant4 from scratch with no particular experience in using it before.
I’m installing Geant4 on an Ubuntu 16.04 virtual machine, running through VMWare. I’ve also set this up using CentOS 7, and the only main difference is that the version of cmake which you can install on CentOS via the repository is not sufficiently recent enough, so you have to go and hunt that out. There is a cmake website, which is useful in this regard.
Also of use are the following packages, which can be installed using
sudo apt-get install [..]
The answer to this forum post (which I will reproduce here) is what I shall refer to as a ‘dependencies goldmine’, although there was one slight change required (libXmu-dev from the original post only works if you change it to libxmu-dev, as I have done below. I’ve also included xauth and freeglut3.)
sudo apt-get install cmake build-essential libgl1-mesa-dev libqt4-dev libxmu-dev zlibc libxerces-c-dev root-system xauth freeglut3 qt-sdk
Anyway, Geant4 downloads are found here. I’m using the GNU/Linux tar source file, which I’ve downloaded to a new folder in my home directory, which I’ve imaginatively named GEANT4. As well as the tarball, I’ve also made two new directories within this folder, namely build and install. Unzip the tarball via the terminal:
tar xvzf geant4.10.02.p1.tar.gz
This will create a new folder (geant4.10.02.p1). After this, the real fun begins.
Now, move into the build directory:
cd build cmake -DCMAKE_INSTALL_PREFIX=/home/[user]/GEANT4/install /home/[user]/GEANT4/geant4.10.02.p1 -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_SYSTEM_EXPAT=OFF -DGEANT4_USE_OPENGL_X11=ON
The INSTALL_DATA bit will download and install the Geant4 datasets, which I believe are useful if you want to actually do anything.
[NB: the dependencies goldmine used:
cmake -DCMAKE_INSTALL_PREFIX=/yourpath/g4install -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_SYSTEM_EXPAT=OFF /yourpath/geant4.10.01
Now for the bit that will take a while (I’m not kidding, this took around 8-9 hours, so make sure you have the time [although on my quicker work machine this only took ~2.5 hours]). Type in the terminal:
where N is the number of cores on a multi-core system. I personally set N to be 2, although if you can commit more, this should speed up this bit. Once this is (finally) completed:
So that’s the basic installation.
The thought has occurred that a bash script would be a simple way to download and install Geant4. Once I’ve made an installation that I’m happy with, I’ll see about making a simple bash script for this purpose, such that the end user would merely having to make some simple changes to the script and run a single terminal command.
[Edit 25/04/17: I’ve just installed Geant4-10.3.1 on a new Ubuntu virtual machine, and the method detailed here still works.]
In part two, I’ll explain how to run the example codes given in the install, once I’ve figured out how to do it myself.
Oh, and here’s some webpages I’ve found useful in all this:
(Edited 07/06/16: info on visualisation.)
(Edited 09/06/16: dependencies goldmine added. Should make it possible to use visualisation.)
(Edited 10/06/16: Bit of tidying up. Thoughts on bash scripts added.)
(Edited 26/08/16: Repetition of ‘cmake’ removed from dependencies install.)
(Edited 05/09/16: included qt-sdk in dependencies.)