Skip to content
Maurik Holtrop edited this page Feb 28, 2022 · 6 revisions

hps-analysis

This is some C++ code that creates ROOT files from slcio (output of the HPS reconstruction and simulation codes) files. Please see the Documentation section on how to use the resulting ROOT files.

Building the code.

Required Components:

  • cmake version 3
    • Available for all Linux and Mac versions. On some systems you need to specify "cmake3" instead of just "cmake". Check your version with "cmake --version".
  • c++17 compiler: gcc 7+, clang
    • I recommend you use at least gcc 9.3 (on MacOS, clang 11), which has far better support for lambda functions.
    • Ubuntu 20.04 LTS comes with gcc 9.3 pre-installed.
  • ROOT version 6.18 or better. I recommend 6.25 or better.
    • The RDataFrame component of ROOT is rather new and still seeing active development and bug fixes. I would recommend using 6.25, or the master branch from git.
    • You need to compile ROOT with the C++17 option: -Dcxx17=ON
  • LCIO
    • If you want to cover the LCIO files to ROOT you will need to be able to read the LCIO files. For this you need the LCIO code.
    • The original repository of LCIO is at their GitHub repository: LCIO and contains detailed the installation instructions. Unfortunately, as of August 2020, the master and v02-14-x versions of LCIO have very serious memory leaks for simple event loops, making this branch of the code useless. In addition, there are inconsistencies between the Java and C++ versions of the code.
    • HPS has been using the older v02.07.05 version of LCIO, because that one is still Java compatible.
    • For the code, in this repo you need a c++17 capable version of LCIO. A break-away fork of the LCIO code is put in a sub-directory of the MiniDst directory. So, if you need LCIO to ROOT conversion, first go there and build and install LCIO, see below.

Pre-requisite: ROOT

You will need a function version of ROOT, preferably version 6.22 or later. You can find installation instruction on the ROOT Website After installation, make sure you have executed the ROOT startup script before continuing, eg:

source <path-to-root>/bin/thisroot.sh

Getting the sources

Go to a location below which you want to build this code, (for instance your home directory), and execute the commands below:

git clone https://github.com/JeffersonLab/hps-analysis.git
cd hps-analysis

Building LCIO

If you want to create the root files, you need the "make_mini_dst" program, which requires LCIO. If you just want to use existing ROOT files, you can skip this step.

You can build a C++17 compatible version of LCIO from the MiniDst/lcio subdirectory:

cd MiniDst/lcio
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=<install dir> ..
make
make install

Note that you need to set the path to your own installation location, which could just be ${HOME}

Building MiniDST:

Go to the location of the hps_analysis directory, and execute the commands below:

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=<install dir> ..
make
make install

Note: if you did not install LCIO in the same location as you want these libraries, then you need to add "-DLCIO_DIR=/location/of/lcio/installation"

At JLAB

At JLab, there is a 9.2.0 version of gcc available using "module", however there is no pre-installed ROOT version that is C++17 compatible. This situation is currently resolved by building a "master" version of ROOT with 9.2.0 and C++17 compatibility. I did this already. To use it you can do this:

module use /group/clas12/packages/local/etc/modulefiles
module use /apps/modulefiles
module load cmake/3.5.1
module load gcc/9.2.0
source /home/holtrop/root/bin/thisroot.sh

You will find pre-compiled libraries for LCIO and MiniDst in /home/holtrop/lib


Using the executable make_mini_dst.

The make_mini_dst program, which will be installed in bin in the installation step, is used to transform an LCIO file to a ROOT file. Simple usage:

make_mini_dst infile.slcio  -o my_root_file.root

There are several options to fine tune the ROOT file creation, which are shown when you execute the code with the "-h" switch.