Geant4 for Dummies (Part 3)

So, that job I was talking about in part 1: I got it. Now I’m two months in, and need to use Geant4 for models.

So, one of the useful things about the Geant4 installation is that it comes with several examples which can be changed to be more relevant to your model. Unfortunately, this is not the most simple thing in the world.

So, to begin, with any single example, create a build directory in your main Geant4 folder.

cd Geant4
mkdir B1-build
cd B1-build

After this, you may need to specify the location of the geant4.(c)sh file, as well as use cmake, and then make, in a similar manner to the installation. For cmake, you specify this Geant4-10.2.1 folder (or whatever version you’re using; the latest is currently 10.2.2), and the original directory of the example of interest.

source /home/[user]/GEANT4/install/bin/
cmake -DGEANT4_DIR=/home/[user]/GEANT4/install/lib/Geant4-10.2.1 
make -j2

This should take a few minutes. There are then a number of ways to run the executable. One is:


This opens a visualisation window, into which commands can be written (I’ll expand on this in a later edit).

Another option is:

./exampleB1 example.mac

Here, a macro file exists which will run a model. This should produce an *.out file, and possibly a *.root file, and will take a few minutes, depending on the complexity of the model and the number of runs specified.

In a later edit, I’ll go into the details of the necessary files to create a viable Geant4 simulation, as well as a discussion of the outputs (both *.out and *.root).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s