0% found this document useful (0 votes)
3 views

Geant4 Install Tutorial

The Geant4 installation tutorial outlines the steps to install Geant4 on a Linux distribution, specifically Ubuntu 24.04, including setting up the environment, downloading the package, and configuring the build using CMake. It details commands for installing necessary dependencies, compiling the software, and setting up the environment for future use. Finally, it guides users on running example B1 to verify the installation's success.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Geant4 Install Tutorial

The Geant4 installation tutorial outlines the steps to install Geant4 on a Linux distribution, specifically Ubuntu 24.04, including setting up the environment, downloading the package, and configuring the build using CMake. It details commands for installing necessary dependencies, compiling the software, and setting up the environment for future use. Finally, it guides users on running example B1 to verify the installation's success.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

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.

2. Go to https://geant4.web.cern.ch/download/11.2.2.html and download the Geant4


package.
3. Open a terminal and create a folder for installing Geant4. Create a directory called
Software by using the command mkdir Software, then go into the Software directory
with the command cd Software. After that, create a folder named geant4 by using the
command mkdir geant4 and go into the geant4 directory with the command cd geant4.

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.

8. Create a build directory (mkdir build), enter to build (cd build)

9. Configured the Geant4 build using CMake's curses interface (ccmake..), here's what it
looked like after running the command:

Press the "c" key for configuration


Press the "e" key and the following display appears:

After that, modify the CMAKE_INSTALL_PREFIX section to


/home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install according to your
system's path. To configure the Geant4 installation, you need to adjust available options
as per your requirements. Use the arrow keys to navigate to the options you want to
change. Press Enter to select an option, then use the up and down arrow keys to toggle
between ON and OFF values. For example, if you want to enable Qt support, navigate to
the option GEANT4_USE_QT, press Enter, and change its value to ON.
After finishing configuration, press 'c' to configure and 'g' to generate the build files,
then exit from ccmake.

If you look at the generating results (ls) as follows:

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 ..)

19. After that run (make)

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.

23. Here's how it looks after executing the command:

You might also like