|
|
|
## Geant4 Installation on Ubuntu 20.04 TLS
|
|
|
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
|
|
In this tutorial we will use Geant4 version 11.1.1, compiled with the support of multithreading, GDML and Qt5 based Gui.
|
|
|
|
|
|
|
|
On Linux systems we use a compiled version of Geant4 and a binary distribution for ROOT installations.
|
|
|
|
|
|
|
|
Below we provide detailed instructions for the installation on Ubuntu 20.04.
|
|
|
|
The installation for other Debian and Ubuntu like Linux'es will be similar but the names of libraries can be slightly different. On Linux you can use GNU *c++*, *clang* or Intel *icc* compilers, we describe only the GNU *g++* installation.
|
|
|
|
|
|
|
|
The installation was tested on VirtualBox VM running *Ubuntu 20.04* and Windows 10 WLS2 *Ubuntu 20.04* application.
|
|
|
|
|
|
|
|
## Ubuntu 20.04 Requirements
|
|
|
|
|
|
|
|
* Ubuntu 20.04 LTS Server or Desktop installation
|
|
|
|
* *build-essential*, *curl*, *g++*, *git* and *cmake* packages
|
|
|
|
* A Bourne-compatible shell for installation (e.g. *bash* or *zsh*)
|
|
|
|
* `sudo` for library installation and directory creation under `/usr/local`
|
|
|
|
|
|
|
|
## External Dependencies Installation
|
|
|
|
|
|
|
|
Generally we follow the installation rules for ROOT described here:
|
|
|
|
https://root.cern/install/dependencies/
|
|
|
|
|
|
|
|
Some dependancies like kerberos and mysql were dropped because we do not use these features in the tutorial.
|
|
|
|
The libraries which we need for Geant4 compilation need to be installed first. For this, the `ubuntu20_deps.sh` script is provided on the Ubuntu 20.04 server. This script must be executed only once.
|
|
|
|
|
|
|
|
See below the code snippet:
|
|
|
|
|
|
|
|
```
|
|
|
|
apt install -y qt5-default
|
|
|
|
apt install -y libxerces-c-dev
|
|
|
|
|
|
|
|
apt install -y gfortran
|
|
|
|
apt install -y python3-dev python3-numpy-dev
|
|
|
|
|
|
|
|
apt install -y libxpm-dev libxft-dev libxmu-dev
|
|
|
|
apt install -y libssl-dev
|
|
|
|
|
|
|
|
apt-get install -y libpcre3-dev xlibmesa-glu-dev \
|
|
|
|
libglew1.5-dev libftgl-dev libfftw3-dev libcfitsio-dev \
|
|
|
|
graphviz-dev libxml2-dev libgsl0-dev
|
|
|
|
|
|
|
|
apt install -y libfreetype6-dev
|
|
|
|
|
|
|
|
```
|
|
|
|
**N.B. Upgrade you system before installation:**
|
|
|
|
```
|
|
|
|
sudo apt update
|
|
|
|
sudo apt upgrade
|
|
|
|
```
|
|
|
|
On Ubuntu 22.04 qt-defaults package not exist use the `ubuntu22_deps.sh` script to install dependancies.
|
|
|
|
|
|
|
|
## ROOT Installation
|
|
|
|
|
|
|
|
The ROOT installation is required for some exercises in this tutorial.
|
|
|
|
|
|
|
|
The tar files with precompiled ROOT binaries for Ubuntu-20.04 can be downloaded from
|
|
|
|
https://root.cern/download/:
|
|
|
|
|
|
|
|
`curl -SLO https://root.cern/download/root_v6.28.02.Linux-ubuntu20-x86_64-gcc9.4.tar.gz`
|
|
|
|
|
|
|
|
We will install both ROOT and Geant4 into /usr/local directory:
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo tar zxf root_v6.28.02.Linux-ubuntu20-x86_64-gcc9.4.tar.gz -C /usr/local/
|
|
|
|
sudo chown -R `id -un`:`id -gn` /usr/local/root
|
|
|
|
chmod +x /usr/local/root/bin/thisroot.*
|
|
|
|
```
|
|
|
|
|
|
|
|
All installation steps are summarized in the `install-root-62208-ubuntu20.sh` script.
|
|
|
|
|
|
|
|
ROOT is installed in _relocatable_ mode.
|
|
|
|
To use ROOT, you must set its environment sourcing the *thisroot.sh* script from
|
|
|
|
the ROOT installation directory:
|
|
|
|
|
|
|
|
`source /usr/local/root/bin/thisroot.sh`
|
|
|
|
|
|
|
|
Visit http://root.cern.ch for more information about ROOT.
|
|
|
|
|
|
|
|
## Geant4 Installation
|
|
|
|
|
|
|
|
Install development tools and compilers packages _build-essential_, _cmake_:
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo apt install -y build-essential
|
|
|
|
sudo install -y cmake
|
|
|
|
```
|
|
|
|
|
|
|
|
This is already done if you have used the _ubuntu20_deps.sh_ script to install dependancies.
|
|
|
|
|
|
|
|
Do not forget to install your favorite editor, e.g _Emacs_ :
|
|
|
|
|
|
|
|
`sudo apt install -y emacs`
|
|
|
|
|
|
|
|
You can install the precompiled version of Geant4 provided for this tutorial. You can download the tar file with precompiled Geant4 `geant4_v11.1.1.Linux-ubuntu20-x86_64-gcc9.4.tar.gz` from `cernbox.cern.ch` server. The script `install-geant4-ubuntu20.sh` can be used for downloading and installation of Geant4.
|
|
|
|
|
|
|
|
The tar file with Geant4 11.1.1 binaries for Ubuntu placed on owncloud server
|
|
|
|
https://cernbox.cern.ch/s/gxJhYs7a97CCTAw
|
|
|
|
|
|
|
|
N.B. As the Geant4 setup scripts, geant4.[c]sh and geant4-config, are not relocatable, you need to install Geant4 into `/usr/local/geant4/11.1.1` or to edit these scripts to fix the paths to the data.
|
|
|
|
|
|
|
|
If you install the precompiled version you can skip **Build Geant4** section and go directly to **Environment**.
|
|
|
|
|
|
|
|
## Build Geant4
|
|
|
|
|
|
|
|
You can download the Geant4 sources from https://geant4.web.cern.ch/support/download
|
|
|
|
or clone Geant4 repository. We use `git clone ...` in the instructions below.
|
|
|
|
|
|
|
|
In the Terminal window type the commands:
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone https://gitlab.cern.ch/geant4/geant4.git
|
|
|
|
cd geant4/
|
|
|
|
git checkout v11.1.1
|
|
|
|
```
|
|
|
|
For Geant4 version 11.1.1 you can also apply pathch 3477.path
|
|
|
|
which you can found in installg4/install/Ubuntu-20.04/ directory.
|
|
|
|
This path suppress warning abou Qt5 slot/signals.
|
|
|
|
|
|
|
|
`patch -p1 < 3477.patch`
|
|
|
|
|
|
|
|
This will create a clone of the Geant4 11.1.1 release on your local disk.
|
|
|
|
|
|
|
|
The ROOT and Geant4 are installed with the current user as owner.
|
|
|
|
You need to create a target directory owned by my current user:
|
|
|
|
|
|
|
|
`sudo mkdir -p /usr/local/geant4/11.1.1`
|
|
|
|
|
|
|
|
`sudo chown -R `id -un`:`id -gn` /usr/local/geant4`
|
|
|
|
|
|
|
|
Now you can compile and install Geant4:
|
|
|
|
```
|
|
|
|
mkdir geant4-build
|
|
|
|
cd geant4-build
|
|
|
|
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/geant4/11.1.1 \
|
|
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo [ -DGEANT4_BUILD_MULTITHREADED=ON ] \
|
|
|
|
-DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_QT=ON \
|
|
|
|
-DGEANT4_USE_OPENGL_X11=ON [-DGEANT4_USE_FREETYPE=ON] ../geant4
|
|
|
|
```
|
|
|
|
The multithreading enabled by default and FREETYPE was optional commpnent
|
|
|
|
|
|
|
|
```
|
|
|
|
cmake --build . --target install -- -j4
|
|
|
|
```
|
|
|
|
|
|
|
|
Geant4 is now installed in the `/usr/local/geant4/11.1.1` directory.
|
|
|
|
|
|
|
|
The installation script `build-geant4-ubuntu20.sh` will do all these steps.
|
|
|
|
|
|
|
|
## Environment
|
|
|
|
|
|
|
|
In order to use Geant4 you need to define the environment variables pointing to the Geant4 datasets locations. This can be done by sourcing the _geant4.sh_ script.
|
|
|
|
|
|
|
|
In the git repository you can find the bash script `setup_env.sh` with setup both for ROOT and Geant4.
|
|
|
|
|
|
|
|
See below the code snippet:
|
|
|
|
```
|
|
|
|
# ROOT 6
|
|
|
|
if [ -x /usr/local/root/bin/thisroot.sh ]; then
|
|
|
|
. /usr/local/root/bin/thisroot.sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Geant4
|
|
|
|
if [ -x /usr/local/geant4/11.1.1/bin/geant4.sh ]; then
|
|
|
|
. /usr/local/geant4/11.1.1/bin/geant4.sh
|
|
|
|
fi
|
|
|
|
```
|
|
|
|
|
|
|
|
You can source this script before starting to work with your Geant4 project or
|
|
|
|
add these lines in your .bash_profile to get the environment set automatically when you log in.
|
|
|
|
|
|
|
|
## Testing of installation
|
|
|
|
|
|
|
|
### 1. Open new Terminal window
|
|
|
|
|
|
|
|
### 2. Source `setup_env.sh` if not done with `.bash_profile`
|
|
|
|
- `source ~/setup_env.sh`
|
|
|
|
|
|
|
|
### 3. Test Geant4 installation
|
|
|
|
|
|
|
|
You can try to compile and run one of the Geant4 examples.
|
|
|
|
|
|
|
|
E.g. basic B1 example.
|
|
|
|
```
|
|
|
|
$ cd ~/tmp
|
|
|
|
$ mkdir B1-build
|
|
|
|
$ cd B1-build
|
|
|
|
$ cmake /usr/local/geant4/11.1.1/share/Geant4-11.1.1/examples/basic/B1
|
|
|
|
```
|
|
|
|
|
|
|
|
You should see something like the output below. Watch for eventual configuration errors.
|
|
|
|
```
|
|
|
|
-- The C compiler identification is GNU 9.3.0
|
|
|
|
-- The CXX compiler identification is GNU 9.3.0
|
|
|
|
-- Check for working C compiler: /usr/bin/cc
|
|
|
|
-- Check for working C compiler: /usr/bin/cc -- works
|
|
|
|
-- Detecting C compiler ABI info
|
|
|
|
-- Detecting C compiler ABI info - done
|
|
|
|
-- Detecting C compile features
|
|
|
|
-- Detecting C compile features - done
|
|
|
|
-- Check for working CXX compiler: /usr/bin/c++
|
|
|
|
-- Check for working CXX compiler: /usr/bin/c++ -- works
|
|
|
|
-- Detecting CXX compiler ABI info
|
|
|
|
-- Detecting CXX compiler ABI info - done
|
|
|
|
-- Detecting CXX compile features
|
|
|
|
-- Detecting CXX compile features - done
|
|
|
|
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found suitable version "2.2.9", minimum required is "2.2.9")
|
|
|
|
-- Found XercesC: /usr/lib/x86_64-linux-gnu/libxerces-c.so (found suitable version "3.2.2", minimum required is "3.2.2")
|
|
|
|
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so
|
|
|
|
-- Found X11: /usr/include
|
|
|
|
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
|
|
|
|
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
|
|
|
|
-- Looking for gethostbyname
|
|
|
|
-- Looking for gethostbyname - found
|
|
|
|
-- Looking for connect
|
|
|
|
-- Looking for connect - found
|
|
|
|
-- Looking for remove
|
|
|
|
-- Looking for remove - found
|
|
|
|
-- Looking for shmat
|
|
|
|
-- Looking for shmat - found
|
|
|
|
-- Looking for IceConnectionNumber in ICE
|
|
|
|
-- Looking for IceConnectionNumber in ICE - found
|
|
|
|
-- Configuring done
|
|
|
|
-- Generating done
|
|
|
|
-- Build files have been written to: /home/semenjuk/tmp/B5-build
|
|
|
|
```
|
|
|
|
Now you can build the application with `make -j4` where -j4 is the number of parallel make processes.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ make
|
|
|
|
Scanning dependencies of target exampleB1
|
|
|
|
[ 12%] Building CXX object CMakeFiles/exampleB1.dir/exampleB1.cc.o
|
|
|
|
[ 25%] Building CXX object CMakeFiles/exampleB1.dir/src/B1ActionInitialization.cc.o
|
|
|
|
[ 37%] Building CXX object CMakeFiles/exampleB1.dir/src/B1DetectorConstruction.cc.o
|
|
|
|
[ 50%] Building CXX object CMakeFiles/exampleB1.dir/src/B1EventAction.cc.o
|
|
|
|
[ 62%] Building CXX object CMakeFiles/exampleB1.dir/src/B1PrimaryGeneratorAction.cc.o
|
|
|
|
[ 75%] Building CXX object CMakeFiles/exampleB1.dir/src/B1RunAction.cc.o
|
|
|
|
[ 87%] Building CXX object CMakeFiles/exampleB1.dir/src/B1SteppingAction.cc.o
|
|
|
|
[100%] Linking CXX executable exampleB1
|
|
|
|
[100%] Built target exampleB1
|
|
|
|
|
|
|
|
The compilation finished successfully
|
|
|
|
```
|
|
|
|
|
|
|
|
Now you can run the executable:
|
|
|
|
```
|
|
|
|
./exampleB1
|
|
|
|
```
|
|
|
|
|
|
|
|
This will open an interactive QT GUI window.
|
|
|
|
To generate N events type in the Session window:
|
|
|
|
To generate N events type in the Session window:
|
|
|
|
```
|
|
|
|
/run/beamOn N
|
|
|
|
```
|
|
|
|
|
|
|
|
To quit application type:
|
|
|
|
```
|
|
|
|
exit
|
|
|
|
```
|
|
|
|
|
|
|
|
See below the expected program output in the terminal.
|
|
|
|
*You should not see a crash dump!*
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
$ ./exampleB1
|
|
|
|
Available UI session types: [ Qt, GAG, tcsh, csh ]
|
|
|
|
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-semenjuk'
|
|
|
|
G4WT1 > /control/saveHistory
|
|
|
|
G4WT0 > /control/saveHistory
|
|
|
|
G4WT1 > /run/verbose 2
|
|
|
|
G4WT0 > /run/verbose 2
|
|
|
|
G4WT1 > /run/initialize
|
|
|
|
G4WT0 > /run/initialize
|
|
|
|
G4WT0 > /run/physicsModified
|
|
|
|
G4WT1 > /run/physicsModified
|
|
|
|
|
|
|
|
...
|
|
|
|
<snip>
|
|
|
|
...
|
|
|
|
|
|
|
|
================== Deleting memory pools ===================
|
|
|
|
Pool ID '20G4NavigationLevelRep', size : 0.00288 MB
|
|
|
|
Pool ID '24G4ReferenceCountedHandleIvE', size : 0.000961 MB
|
|
|
|
Pool ID '15G4CountedObjectIvE', size : 0.000961 MB
|
|
|
|
Number of memory pools allocated: 3; of which, static: 0
|
|
|
|
Dynamic pools deleted: 3 / Total memory freed: 0.0048 MB
|
|
|
|
============================================================
|
|
|
|
G4Allocator objects are deleted.
|
|
|
|
UImanager deleted.
|
|
|
|
StateManager deleted.
|
|
|
|
RunManagerKernel is deleted. Good bye :)
|
|
|
|
```
|
|
|
|
|
|
|
|
### 4. Test ROOT Installation
|
|
|
|
|
|
|
|
Example of root v6.22/02.
|
|
|
|
|
|
|
|
Start the ROOT interactive session:
|
|
|
|
```
|
|
|
|
$ root
|
|
|
|
------------------------------------------------------------------
|
|
|
|
| Welcome to ROOT 6.22/02 https://root.cern |
|
|
|
|
| (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
|
|
|
|
| Built for linuxx8664gcc on Aug 17 2020, 12:46:52 |
|
|
|
|
| From tags/v6-22-02@v6-22-02 |
|
|
|
|
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
|
|
|
|
------------------------------------------------------------------
|
|
|
|
```
|
|
|
|
|
|
|
|
and type `.demo` after the ROOT prompt:
|
|
|
|
```
|
|
|
|
root [0] .demo
|
|
|
|
```
|
|
|
|
|
|
|
|
You will see the ROOT demo bar and can run some demos by clicking on the demo menu.
|
|
|
|
You need to go from up to down in the menu, some demos depend on the previous demos results.
|
|
|
|
|
|
|
|
To quit ROOT type .q on the ROOT prompt
|
|
|
|
```
|
|
|
|
root [1] .q
|
|
|
|
|
|
|
|
Taking a break from ROOT? Hope to see you back!
|
|
|
|
|
|
|
|
$
|
|
|
|
```
|
|
|
|
|
|
|
|
## Tips ##
|
|
|
|
|
|
|
|
- Geant4
|
|
|
|
- You check the Geant4 datasets installation using the command:
|
|
|
|
`geant4-config --check-datasets`
|
|
|
|
- `geant4-config --help` also shows the Geant4 features (configuration options)
|
|
|
|
|
|
|
|
Visit Geant4 installation Guide for more info:
|
|
|
|
http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/InstallationGuide/html/
|
|
|
|
|
|
|
|
- zsh
|
|
|
|
- If you use zsh you need to use .zprofile instead of .bash_profile
|
|
|
|
- Use *source* not *.* to source setup scripts
|
|
|
|
|
|
|
|
- git
|
|
|
|
- for latest git enable repository before installing git
|
|
|
|
|
|
|
|
`sudo add-apt-repository ppa:git-core/ppa` |