|
|
install on ubuntu |
|
|
\ No newline at end of file |
|
|
# Geant4 Installation Ubuntu 20.04 TLS
|
|
|
|
|
|
In this tutorial we will use Geant4 version 10.6.2, compiled with support of multithreading and Qt5 based Gui. The installation of Root was required
|
|
|
for some exercise in this tutorial.
|
|
|
|
|
|
On Linux systems we use recompiled version of Geant4 and use binary distribution for root installation.
|
|
|
|
|
|
Below we provide detailed instruction for installation on Ubuntu 20.04.
|
|
|
The installation for other Debian and Ubuntu like Linux'es will be similar but the name of libraries can slightly different. On linux you can use GNU *c++*, *clang* or Intel *icc* compilers, we describe only GNU *g++* installation.
|
|
|
|
|
|
The installation 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`
|
|
|
|
|
|
## Installation of external dependancies for Geant4 and Root
|
|
|
|
|
|
Generally we follow installation rules for root described hire:
|
|
|
https://root.cern/install/dependencies/
|
|
|
|
|
|
Some dependancies like kerberos and mysql was dropped because we not use this features in the tutorial.
|
|
|
The libraries which we need for Geant4 compilation additionally installed.
|
|
|
We provide script `ubuntu20_deps.sh` for installation of external dependancies on Ubuntu 20.04 Server. This script must be executed ones.
|
|
|
|
|
|
The code snippet hire:
|
|
|
|
|
|
```
|
|
|
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 \
|
|
|
chmod +x /usr/local/root/bin/thisroot.*
|
|
|
graphviz-dev libxml2-dev libgsl0-dev
|
|
|
|
|
|
```
|
|
|
|
|
|
## Installation of Root application
|
|
|
|
|
|
The root installation was required for some exercise in this tutorial. On Ubuntu20 you may download tar files with root binaries precompiled for Ubuntu-20.04 from https://root.cern/download/
|
|
|
|
|
|
`curl -SLO https://root.cern/download/root_v6.22.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz`
|
|
|
|
|
|
We install both root and geant4 into /usr/local directory:
|
|
|
|
|
|
`sudo tar zxf root_v6.22.02.Linux-ubuntu20-x86_64-gcc9.3.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 summarized in script `ubuntu20_root.sh`.
|
|
|
|
|
|
The root installed in _relocatable_ mode, before use root you must setup root environment sourcing _thisroot.sh_ from
|
|
|
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 use _unitu20_deps.sh_ script to install dependancies.
|
|
|
|
|
|
Not forget to install you favorite editor, e.g _Emacs_ :
|
|
|
|
|
|
`sudo apt install -y emacs`
|
|
|
|
|
|
You can install precompiled version of geant4 which we
|
|
|
provide for this tutorial. You can download tar file with precompiled geant4 `geant4_v10.6.02.Linux-ubuntu20-x86_64-gcc9.3.tar.gz` from this link:
|
|
|
...
|
|
|
|
|
|
The script `ubuntu20_geant4.sh`can be used to downloading and installation of Geant4.
|
|
|
https://llrbox.in2p3.fr/owncloud/index.php/s/uPs1rYmcLXArkPm
|
|
|
|
|
|
N.B. geant4 setup scripts geant4.[c]sh and geant4-config not a relocatable you need install Geant4 into `/usr/local/geant4/10.6.2` or edit this scripts to fix paths to the data.
|
|
|
|
|
|
If you install precompiled version you can skeep **Build Geant4** section and go to **Setup développement environment for tutorial**.
|
|
|
|
|
|
## Build Geant4
|
|
|
|
|
|
You can download geant4 sources from https://geant4.web.cern.ch/support/download
|
|
|
or clone geant4 repository. We use `git clone ...` for installation.
|
|
|
|
|
|
In Terminal window type the commands:
|
|
|
|
|
|
`git clone https://gitlab.cern.ch/geant4/geant4.git`
|
|
|
`cd geant4/`
|
|
|
`git checkout geant4-10.6-release`
|
|
|
|
|
|
This fill make a clone of latest geant4 10.6.x release on local disk.
|
|
|
|
|
|
The root and geant4 installed with current user as owner.
|
|
|
You need create target directory owned my current user:
|
|
|
|
|
|
`sudo mkdir -p /usr/local/geant4/10.6.2`
|
|
|
`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/10.6.2 \
|
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DGEANT4_BUILD_MULTITHREADED=ON \
|
|
|
-DXERCESC_ROOT_DIR=/usr -DXERCESC_LIBRARY=/usr/lib/x86_64-linux-gnu/libxerces-c.so \
|
|
|
-DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_QT=ON \
|
|
|
-DGEANT4_USE_OPENGL_X11=ON -DGEANT4_ENABLE_TESTING=OFF ../geant4
|
|
|
```
|
|
|
|
|
|
```
|
|
|
cmake --build . --target install -- -j4
|
|
|
```
|
|
|
|
|
|
The gant4 installed into `/usr/local/geant4/10.6.2` directory.
|
|
|
The installation script `install-geant4-1062.sh` will do all this steps.
|
|
|
|
|
|
|
|
|
|
|
|
## Setup développement environment for tutorial
|
|
|
|
|
|
In order to use Geant4 you need define variables pointed to Geant4 datasets locations.
|
|
|
This can be done by sourcing geant4.sh script. For homebrew installation the command is:`source /usr/local/bin/geant4.sh`
|
|
|
|
|
|
In git repository you can found bash script `setup_env.sh` with allow setup root and geant4.
|
|
|
|
|
|
The code snippet hire:
|
|
|
```
|
|
|
# Root 6
|
|
|
if [ -x /usr/local/root/bin/thisroot.sh ]; then
|
|
|
. /usr/local/root/bin/thisroot.sh
|
|
|
fi
|
|
|
|
|
|
# Geant4
|
|
|
if [ -x /usr/local/geant4/10.6.2/bin/geant4.sh ]; then
|
|
|
. /usr/local/geant4/10.6.2/bin/geant4.sh
|
|
|
fi
|
|
|
```
|
|
|
|
|
|
You can source this script before start to work with geant4 project or put the line to `.bash_profile` to setup environment automatically on each login.
|
|
|
|
|
|
|
|
|
## Testing of installation
|
|
|
|
|
|
### 1. Open New Terminal Window
|
|
|
|
|
|
### 2. Source `setup_env.sh` if not done with `.bash_profile`
|
|
|
- `source ~/setup_env.sh`
|
|
|
|
|
|
### 3. Start Root and type `.demo`
|
|
|
```
|
|
|
$ 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' |
|
|
|
------------------------------------------------------------------
|
|
|
|
|
|
root [0] .demo
|
|
|
|
|
|
You will see root demo bar and can run some demos clicking on demo menu.
|
|
|
You need go from up to down in menu , some dome depend from previous demo results.
|
|
|
|
|
|
To quit root type .q on root prompt
|
|
|
|
|
|
root [1] .q
|
|
|
|
|
|
Taking a break from ROOT? Hope to see you back!
|
|
|
|
|
|
$
|
|
|
```
|
|
|
|
|
|
### 4. Test Geant4 installation
|
|
|
|
|
|
You can try to compile and run one of geant4 examples.
|
|
|
|
|
|
E.g. basic B5 example.
|
|
|
```
|
|
|
$ cd ~/tmp
|
|
|
$ mkdir B5-build
|
|
|
$ cd B5-build
|
|
|
$ cmake /usr/local/geant4/10.6.2/share/Geant4-10.6.2/examples/basic/B5
|
|
|
-- 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
|
|
|
```
|
|
|
```
|
|
|
$ make
|
|
|
Scanning dependencies of target exampleB5
|
|
|
[ 5%] Building CXX object CMakeFiles/exampleB5.dir/exampleB5.cc.o
|
|
|
[ 11%] Building CXX object CMakeFiles/exampleB5.dir/src/B5ActionInitialization.cc.o
|
|
|
[ 17%] Building CXX object CMakeFiles/exampleB5.dir/src/B5CellParameterisation.cc.o
|
|
|
[ 23%] Building CXX object CMakeFiles/exampleB5.dir/src/B5DetectorConstruction.cc.o
|
|
|
[ 29%] Building CXX object CMakeFiles/exampleB5.dir/src/B5DriftChamberHit.cc.o
|
|
|
[ 35%] Building CXX object CMakeFiles/exampleB5.dir/src/B5DriftChamberSD.cc.o
|
|
|
[ 41%] Building CXX object CMakeFiles/exampleB5.dir/src/B5EmCalorimeterHit.cc.o
|
|
|
[ 47%] Building CXX object CMakeFiles/exampleB5.dir/src/B5EmCalorimeterSD.cc.o
|
|
|
[ 52%] Building CXX object CMakeFiles/exampleB5.dir/src/B5EventAction.cc.o
|
|
|
[ 58%] Building CXX object CMakeFiles/exampleB5.dir/src/B5HadCalorimeterHit.cc.o
|
|
|
[ 64%] Building CXX object CMakeFiles/exampleB5.dir/src/B5HadCalorimeterSD.cc.o
|
|
|
[ 70%] Building CXX object CMakeFiles/exampleB5.dir/src/B5HodoscopeHit.cc.o
|
|
|
[ 76%] Building CXX object CMakeFiles/exampleB5.dir/src/B5HodoscopeSD.cc.o
|
|
|
[ 82%] Building CXX object CMakeFiles/exampleB5.dir/src/B5MagneticField.cc.o
|
|
|
[ 88%] Building CXX object CMakeFiles/exampleB5.dir/src/B5PrimaryGeneratorAction.cc.o
|
|
|
[ 94%] Building CXX object CMakeFiles/exampleB5.dir/src/B5RunAction.cc.o
|
|
|
[100%] Linking CXX executable exampleB5
|
|
|
[100%] Built target exampleB5
|
|
|
|
|
|
The compilation finished successfully
|
|
|
```
|
|
|
|
|
|
Now you can run executable without parameters.
|
|
|
This will open interactive QTGUI window.
|
|
|
|
|
|
You can generate N events typing filed
|
|
|
Session : `/run/beamOn N`
|
|
|
Or use command: `exit` to quit application
|
|
|
|
|
|
|
|
|
Below terminal output:
|
|
|
```
|
|
|
$ ./exampleB5
|
|
|
Available UI session types: [ Qt, GAG, tcsh, csh ]
|
|
|
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-semenjuk'
|
|
|
G4WT0 > Using Root
|
|
|
G4WT1 > Using Root
|
|
|
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
|
|
|
G4WT1 > /control/verbose 2
|
|
|
G4WT0 > /control/verbose 2
|
|
|
|
|
|
...
|
|
|
<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 :)
|
|
|
```
|
|
|
|
|
|
#### You must not see and crash dump!
|
|
|
|
|
|
## Tips ##
|
|
|
|
|
|
- geant4
|
|
|
- you check the geant4 datasets installations using command:
|
|
|
`geant4-config --check-datasets`
|
|
|
- `geant4-config --help` also show geant4 features ( configuration options )
|
|
|
|
|
|
Visit geant4 installation Gide for info:
|
|
|
http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/InstallationGuide/html/
|
|
|
|
|
|
- zsh
|
|
|
- if you use zsh you need use .zprofile on place of .bash_profile
|
|
|
- use *source* not a *.* to source setup scripts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|