0% found this document useful (0 votes)
122 views13 pages

Geant4 Install Tutorial

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
122 views13 pages

Geant4 Install Tutorial

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 13

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.

1
3. Open a terminal and create a folder for installing Geant4
a. Create a directory Software (mkdir Software)

b. Go into the Software directory with the command (cd Software)

c. create a folder named geant4 (mkdir geant4)

d. go into the geant4 directory with the command (cd geant4)

4. Now that you are in the Software/geant4 directory, then extract the downloaded geant4
package tar xzfv ~/Download/geant4-v11.2.2.tar.gz.

2
Make sure that ~/Download/geant4-v11.2.2.tar.gz is the path where you downloaded the
Geant4 package.

After running the comment, the file will be extracted and appear as follows:

5. Look the results of the geant4-v11.2.2.tar.gz extract (ls),

geant4-v11.2.2 is the directory of the geant4-v11.2.2.tar.gz folder extract results.

6. After that, go to the geant4-v11.2.2 folder (cd geant4-v11.2.2)

7. After that, run this comman: sudo apt install cmake cmake-curses-gui gcc g++
libexpat1-dev qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libxmu-dev
libmotif-dev

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

9. enter to build (cd build)

10. After that, run (ccmake..)

here's what it looked like after running the command:

4
a. Press the "c" key for configuration

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

5
c. Change CMAKE_INSTALL_PREFIX to
/home/dadan-hidayatuloh/Sorfware/geant4/geant4-v11.2.2-install to match
your system path.

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.

6
d. Press c to configure
e. Press g to generate

Jika dilihat hasil generating (ls) seperti berikut:

11. Next, run make -j4.

Make sure you have a good internet connection, because connection can cause the
compilation to fail and result in errors.

7
12. If the compilation is 100%, then continue with the make install comment

13. After that, we need to set up the source so that Geant4 can be used every time.
a. Exit the build directory (cd ..)

b. Exit the geant4-v11.2.2 directory (cd ..)

c. Enter the geant4-v11.2.2-install directory (cd geant4-v11.2.2-install)

d. You can view the contents of the geant4-v11.2.2-install directory (ls)

e. Navigate into the share directory (cd share)

f. Check what's inside (ls)

g. Then enter the directory within share (cd Geant4)

(which might have a different name in your case)

8
h. After that, list the directories inside Geant4 (ls)

where you will find a directory named geant4make

i. Enter geant4make (cd geant4make)

j. then check your current path (pwd)

k. copy this path (/home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-


install/share/Geant4/geant4make) for sourcing every time you want to use
Geant4.

l. 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/geant4make/geant4make.sh
m. The source can now be used (.
/home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/
Geant4/geant4make/geant4make.sh)
or alternatively
(source
home/dadan-hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/
Geant4/geant4make/geant4make.sh)

9
14. At this stage, your Geant4 installation is complete. To ensure that the installation was
successful, you can try running example B1.
a. 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/geant4make/geant4make.sh) or alternatively (source home/dadan-
hidayatuloh/Software/geant4/geant4-v11.2.2-install/share/Geant4/
geant4make/geant4make.sh).

b. Exit geant4make (cd ..)

c. exit Geant4 (cd ..)

d. exit share (cd ..)

e. exit geant4-v11.2.2-install (cd ..)

f. Go into geant4-v11.2.2 (cd geant4-v11.2.2)

g. Look the directories in geant4-v11.2.2 (ls)

10
h. Enter examples/basic/B1 (cd examples/basic/B1)

i. Create a new directory named build (mkdir build)

j. You can see if build exists or not (ls)

k. then enter build (cd build)

l. run the command (cmake ..)

m. After that run (make)

n. Run the command (./exampleB1).

11
And after running the ./exampleB1 command, the GUI of example B1 will come
out, here is the GUI display of example B1:

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

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

12
13

You might also like