In this section, we describe how to compile Root and Geant4 from source. We are taking the sources from the official repo, which makes updating to the new version easier. To speed up compilation, we recommend using ninja instead of make. You can replace the ninja command with the make command as needed.

Installing ninja

Ninja is a high-performance equivalent to make. It considerably reduces the build time for Root, Geant4, and nptool and is highly recommended. It is available through most package managers, including yum, apt, and conda.

Root

cd <path_to_root>
git clone  https://github.com/root-project/root.git 
cd root
git checkout v6-32-16  (change tag as needed)

Here are the recommended options for your Root installation. Both gdlm and minuit2 options could be switched off, but are highly recommended as some nptool plugins are using them.

cmake -GNinja -B mybuild -DCMAKE_INSTALL_PREFIX=install -Dminuit2=ON -Dgdml=ON
ninja -C mybuild install
source <path_to_root>/root/install/bin/thisroot.sh 

Restart your shell so Root is configured.

Geant4

cd <path_to_geant4>
git clone  https://github.com/Geant4/geant4.git
cd geant4
git checkout v11.4.1 (change tag as needed)

Here are the recommended options for your Geant4 installation.

cmake -GNinja -B build -DCMAKE_INSTALL_PREFIX=install -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_QT=ON -DGEANT4_USE_GDML=ON -DGEANT4_BUILD_MULTITHREADED=OFF -DGEANT4_BUILD_BUILTIN_BACKTRACE=ON
ninja -C build install
source <path_to_geant4>/geant4/install/share/Geant4/geant4make/geant4make.sh  

Restart your shell so Geant4 is configured.

Install nptool v4 Geant4 plugin:

nptool --install geant4

Known issue:

On some Linux systems, compiling Geant4 with GEANT4_BUILD_MULTITHREADED=ON causes the library to be compiled with a TLS (Thread Local Storage) strategy incompatible with the nptool architecture.