CERN Root - A modular scientific software toolkit.

CERN Root is a comprehensive C++ library and class hierarchy framework for analysis and visualization of complex data – originally for the high-energy-physics community. Objects are graphs, functions, histograms, fitting routines, trees, own data file format, etc.

Getting Started

On the LRZ clusters, use the Environment Modules to find and set the environment.

> module av root
------- /lrz/sys/spack/staging/20.1/modules/haswell/linux-sles15-haswell -------
root/6.20.02-gcc8  
> module load root
> root -l
root [0] TF1 f("f","x*exp(-x)",0,10);
root [1] f.Draw();
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

To leave the session:

root [2] .q

Documentation

Simple Compile Example

CERN Root allows for different modes: interactive (as shown above), scripted (and interpreted), and compiled and linked into own C++ applications. For instance, the above short example in a compiled application using CMake (CMAKE_PREFIX_PATH is set by the module) via:

main.cxx
#include <TCanvas.h>
#include <TF1.h>
int main() {
    TCanvas c("c","c",800,600);
    TF1 f("f","x*exp(-x)",0,10);
    f.Draw();
    c.SaveAs("test.pdf");
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(root-test)
find_package(ROOT REQUIRED) include_directories(${ROOT_INCLUDE_DIRS})
add_executable(main main.cxx)
target_link_libraries(main PUBLIC ${ROOT_LIBRARIES})

This example can be built and run as follows.

> ls
CMakeLists.txt     main.cxx
> mkdir build && cd build
> cmake ..
> make
> ./main

This creates a PDF file test.pdf with the plotted function graph.

Official Documentation

CERN Root supplies a rather comprehensive User Guide, which we can really recommend to read and consult, and a Doxygen-generated Reference Guide.