Geant4 Install Tutorial
Geant4 Install Tutorial
1. The first step in installing Geant4 is to set up a Linux distribution. Here, I am using
Ubuntu 24.04. You can follow the installation guide for Ubuntu 24.04 either for dual boot
(Tutorial Dual Boot Ubunu dan Windows) or on a virtual machine (Tutorial Install
Ubuntu in Virtual Machine) through the following links: Tutorial Install Ubuntu in
Virtual Machine and Tutorial Dual Boot Ubuntu and Windows. If you are using Ubuntu,
make sure to set it to Xorg mode. This is very important for the Geant4 GUI display.
The setting is in the bottom left corner. Choose the "Ubuntu on Xorg" mode.
4. Now that you are in the Software/geant4 directory, extract the archive file with the .tar.gz
or .tgz extension using the command tar xzfv ~/Download/geant4-v11.2.2.tar.gz. Make
sure that ~/Download/geant4-v11.2.2.tar.gz is the path where you downloaded the
Geant4 package.
5. After running the comment, the file will be extracted and appear as follows:
6. And you can see the results of the geant4-v11.2.2.tar.gz folder extract by running the
comment (ls), geant4-v11.2.2 is the directory of the geant4-v11.2.2.tar.gz folder extract
results. After that you can enter the folder (cd):
7. After that, run the following command: sudo apt install cmake cmake-curses-gui gcc
g++ libexpat1-dev qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libxmu-dev
libmotif-dev. This command will install CMake, GCC, G++, and various development
libraries needed, including the Qt5 libraries required for the Geant4 graphical user
interface.
9. Configured the Geant4 build using CMake's curses interface (ccmake..), here's what it
looked like after running the command:
10. Next, compile Geant4 using four threads simultaneously with the command make -j4.
This can significantly speed up the compilation process compared to running it serially.
Make sure you have a good internet connection, because connection can cause the
compilation to fail and result in errors.
11. Next, if the compilation is 100%, then continue with the make install comment
12. After that, we need to set up the source so that Geant4 can be used every time. Exit the
build directory (cd ..), then exit the geant4-v11.2.2 directory (cd ..), and enter the
geant4-v11.2.2-install directory (cd geant4-v11.2.2-install). You can view the contents
of the geant4-v11.2.2-install directory (ls), navigate into the share directory (cd share),
check what's inside (ls), then enter the directory within share (e.g., cd Geant4, which
might have a different name in your case). After that, list the directories inside Geant4
(ls), where you will find a directory named geant4make. Enter geant4make (cd
geant4make), then check your current path (pwd) and copy this path
(/home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/Geant4/gea
nt4make) for sourcing every time you want to use Geant4.
13. From the copied path you can add geant4make.sh at the end of the path.
/home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/Geant4/gean
t4make/geant4make.sh
14. The source can now be used by running the command
(./home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/Geant4/gea
nt4make/geant4make.sh) or alternatively (source
home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/Geant4/geant
4make/geant4make.sh).
15. At this stage, your Geant4 installation is complete. To ensure that the installation was
successful, you can try running example B1. The first step to run example B1 is to source
Geant4 by executing the command (.
/home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/Geant4/gean
t4make/geant4make.sh) or alternatively (source
home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/Geant4/geant
4make/geant4make.sh).
16. Exit geant4make (cd..), exit Geant4 (cd..), exit share (cd..) exit geant4-v11.2.2-install
(cd..).
17. Go into geant4-v11.2.2 (cd geant4-v11.2.2), see the directories in geant4-v11.2.2 (ls),
and enter examples/basic/B1 (cd examples/basic/B1). After that, check the directories
in B1, create a new directory named build (mkdir build). You can see if build exists or
not (ls), then enter build (cd build).
18. Now you are in the build and to run it you can run the command (cmake ..)
20. See at the end of the make command that the target of example B1 is exampleB1, run the
command (./exampleB1).
21. And after running the ./exampleB1 command, the GUI of example B1 will come out,
here is the GUI display of example B1:
22. If you want to fire a particle beam you can run the /run/beamOn [number of particles]
command in the session section and enter to run.