If you are on lxplus, all the necessary software is preinstalled if you use a recent LCG or FCC stack release.
On Mac OS or Ubuntu, you need to install the following software.
Install ROOT 6.08.06 (or later) and set up your ROOT environment:
source <root_path>/bin/thisroot.sh
Podio works with both python 2 and python3. Check your python version by doing:
python --version
Podio requires the yaml
and jinja2
python modules.
Check that the yaml
and jinja2
python modules are available
python
>>> import yaml
>>> import jinja2
If the import goes fine (no message), you're all set. If not, the necessary modules need to be installed. This is most easily done via (first install pip if you don't have it yet)
pip install -r requirements.txt
In order for the yaml
module to be working it might also be necessary to install the C++ yaml library. On Mac OS, The easiest way to do that is to use homebrew (install homebrew if you don't have it yet):
brew install libyaml
Check that you can now import the yaml
and jinja2
modules in python.
Full use of PODIO requires you to set the PODIO
environment variable
and modify LD_LIBRARY_PATH
and PYTHONPATH
. Some convenience scripts
are provided:
# Set PODIO install area to `./install` and setup environment accordingly
source ./init.sh
or
# Setup environment based on current value of `PODIO`
source ./env.sh
Or you can setup the environment entirely under your control: see init.sh
and env.sh
.
If you are using the easy setup from init.sh
then create separate build
and install areas, and trigger the build:
mkdir build
mkdir install
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
make -j 4 install
To see a list of options, do this in the build-directory:
cmake -LH ..
The examples are for creating a file "example.root",
tests/write
and reading it again in C++,
tests/read
It is also possible to read the file again using the
tests/read.py
script. Make sure to have run init.sh
and env.sh
first. Additionally you have to make ROOT
aware of
libTestDataModel.so
to be able to read in the data types defined there. There
are two ways to do that. First it is possible to add the directory to the
LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$(pwd)/tests
Secondly it is also possible to explicitly load the library via ROOT
in the
script by adding the following lines after the imports from __future__
import os
BUILD_PATH = os.getcwd()
import ROOT
ROOT.gSystem.Load(os.path.join(BUILD_PATH, 'tests/libTestDataModel.so'))
Either of the two versions allows you to now read the example.root
file again
using
python ../tests/read.py
A recipe for building podio is included with the spack package manager, so podio can also installed with:
spack install podio
Note that if you do not have any previous installations or registered system packages, this will compile ROOT and all its dependencies, which may be time-consuming.
Podio features an example event data model, fully described in the yaml file tests/datalayout.yaml. The C++ in tests/datamodel/ has been fully generated by a code generation script, python/podio_class_generator.py.
To run the code generation script, do
mkdir ../Tmp
mkdir ../Tmp/data
mkdir ../Tmp/src
python ../python/podio_class_generator.py ../examples/datalayout.yaml ../Tmp data ROOT
The generation script has the following additional options:
--clangformat
(-c
): Apply clang-format after file creation (uses option-style=file
with llvm as backup style), needs clang-format in$PATH
.--quiet
(-q
): Suppress all print out to STDOUT--dryrun
(-d
): Only run the generation logic and validate yaml, do not write files to disk
After compilation you can run rudimentary tests with
make test