Installation of PandaRoot for Developers

Working with GIT for development

For a detailed description of the git workflow in PandaRoot, see this talk. Please install FairSoft and FairRoot as described in the user [guide](Install_PandaRoot.md).

Set up your fork

Only once you need to go to https://git.panda.gsi.de and fork PandaRootGroup/PandaRoot into your private repository on GitLab.

Set up your local repository

Create a local copy of the forked repo. The url_of_the_fork is written on the project page of the GitLab server. Usually it is https://git.panda.gsi.de<first_name><last_name>/PandaRoot. Here we call the target folder source.

mkdir PandaRoot
cd PandaRoot
git clone url_of_the_fork source

The origin of your local repository points to your fork. However, you want to follow the changes on the original repository (PandaRootGroup/PandaRoot). Therefore you have to add it, which we will shortcut with mainrepo.

cd source
git remote add mainrepo https://git.panda.gsi.de/PandaRootGroup/PandaRoot.git
git fetch mainrepo

Create a local feature branch for development

This will be the branch you can work on. It is recommended to separate features in different branches. It is best to create a copy of the latest development branch (here called myfeature) and to upload it to your forked repository:

git fetch mainrepo
git checkout -b myfeature mainrepo/dev
git push -u origin myfeature

Develop on your feature branch

Do some work and submit it to your forked repository.

git add <files>
git commit -m "commit message"
git push origin

It is likely that the dev branch in the main repository was updated. As often as you can you should rebase and if necessary fix any conflicts.

git fetch mainrepo
git rebase mainrepo/dev
# ... maybe fix some conflicts
git push -f origin

Installation process

First you need to set the environment variables SIMPATH and FAIRROOTPATH, which are the folders where you have the installed the external packages and FairRoot. If the installation was done with Spack, both folders may be the same. On a cluster this may be already pre-installed for you, e.g. on a CVMFS.

export FAIRROOTPATH=/home/pandauser/FairRoot-vXX.X/install
export SIMPATH=/home/pandauser/fairsoft_XXX/build/

If you are at a GSI machine, you should have access to the CVMFS. You can find Installations of FairSoft and FairRoot at /cvmfs/fairsoft.gsi.de. Mind the correct operating system.

Build PandaRoot

Create a build directory and build the sources (here in ../source):

mkdir build
cd build
cmake ../source
make -j4

You can change the -j4 to the number of CPU cores you have available to speed up the process.

If your CMake installation on your system is too old, then the external packages installed a new one. You can use this line instead:

$SIMPATH/bin/cmake ../PandaRoot

To setup PandaRoot in a new shell, just source the configuration script:

. build/config.sh -a

You can provide a flag -a to append or -p to prepend to the current PATH and LD_LIBRARY_PATH variables. Appending is the least invasive to your environment, prepend is to prefer installed executables & libraries form FairSoft, FairRoot and PandaRoot. Giving no option will overwrite the environment.

Out-of-build installation

There is the possibility to copy the build products into an installation folder, which allows to delete the build and source folders. You need to provide the installation folder at the configuration stage, build and install:

mkdir build
mkdir install
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ../PandaRoot
make -j4
make install

You will find all the necessary input and parameter files in install/share. In order to load PandaRoot in a shell you need to source the configuration from here:

. install/bin/config.sh -p

Build with Visual Studio Code

VS Code is a free integrated development platform which offers many extensions and can handle git, cmake, c++, python, jupyter notebooks and even rudimentary root file access.

If you want to build PandaRoot with VS Code you should install a few extensions first. Most important are “C/C++” and “C/C++ Themes” as well as “CMake” and “CMake Tools”.

It is recommended to tweak the CMake tool settings to build somewhere else than the default location (<source>/build/) in the “Cmake: Build Directory” setting. Also you may want to set the correct environment variables to the FairRoot & FairSoft installations in the “Cmake: Build Environment” and “Cmake: Configure Environment”. This may not be necessary if your shell profile or bashrc already set these.

You can load your source directory in a fresh workspace (don’t forget to save it as a workspace) and then make use of cmake and/or building e.g. from the bottom bar of the application. Also VS Code comes built-in with an easy way to manage and review your changes with git.

A very useful extension is “clangd”, which enables a lot of features to improve code navigation and much more. You have to add an additional the build argument -DCMAKE_EXPORT_COMPILE_COMMANDS=1 in your Cmake extension settings. Then symlink the file compile_commands.json from your build directory to your source directory.