ROOT.jl

CERN ROOT compatiblility for Julia
Popularity
42 Stars
Updated Last
4 Months Ago
Started In
February 2014

ROOT.jl

Linux macOS

๐Ÿ“ฃ New: Support of recent Julia releases!

ROOT.jl was not working with Julia version beyond 1.3 due to limitation of the Cxx.jl C++/Julia interface. Release 0.3.0 brings a new implementation based on the CxxWrap interface that supports recent Julia versions. The counterpart is a smaller coverage of ROOT classes: see Section C++/Julia interface.

Introduction

ROOT.jl is a Julia interface to the C++ ROOT Data analysis framework used in the high energy physics community.

It is a work-in-progress package. It targets persons used to the ROOT framework and wishing to access it from Julia.

The project aims to provide access to the complete ROOT C++ API with a one-to-one mapping. Several ROOT classes are currently supported. Simplification of the API is not in the scope of the package. The API is already very convenient for some functionalities, like histogramming, histogram fit and plotting. The C++ interface to read and write TTree does not map well in Julia. A simplification of the API for I/O with a better Julia integration will be provided by a front end package in the contact of the ROOTIO project.

Function documentation for the Julia help command is not available yet. Please refer to the C++ ROOT reference guide for API documentation.

Since release 0.3.0, ROOT.jl uses CxxWrap to interface to the C++ libraries and the wrappers were generated using WrapIt!. Releases 0.1.0 and 0.2.0 were based on Cxx.jl, providing an access to the full ROOT C++ API, while release 0.3.0+ covers a subset of classes, but requiring use of the outdated Julia version 1.3.

Supported platforms

Linux and MacOS.

Installation

To install the latest release, type from the Julia REPL, type ] to enter in the package manager and then,

add ROOT

The developement version (github HEAD) can be installed using,

dev https://github.com/JuliaHEP/ROOT.jl
build ROOT

โš  Installation can stay several minutes (ten of minutes on macOS) on the following message.

Building ROOT โ†’ `.../build.log`
  Progress [=                  ]1/2

This is due to the installation of ROOT and compilation of the wrapper library. Be patient. You can open the indicated build.log file to see the progress.

๐Ÿ’ก Sometimes the build.jl script is not launched by the package manager. It is for instance the case in the development mode (package added with the dev command). In case of the command add ... command fail, try first to run build ROOT from the package manager prompt before investigating further.

ROOT version

Current ROOT version uses ROOT release 6.30.04. If a ROOT installation is found in the default binary search paths (PATH environment variable) with this version, then it will be used. Otherwise, ROOT will be installed using Conda into $HOME/.julia/Conda/3.

C++ / Julia mapping and symbol export

C++ classes are mapped to Julia struct with the same name. Non-static class methods are mapped to Julia methods, with the same name, taking the class instance as first argument followed by the arguments of the C++ methods. The double column :: used for C++ namespace and for static fields in C++ is mapped to the ! symbol: static function f of class A, A::f() becomes A!f() in Julia.

Non-static methods of C++ classes are exported, the other symbols (classes, global functions, etc) are not.

Use Example

Short demo

import ROOT

ROOT.demo()

Simple example

#Import the module.
using ROOT

# An alias for ROOT
const R = ROOT

# Create a ROOT histogram, fill it with random events, and fit it.
h = R.TH1D("h", "Normal distribution", 100, -5., 5.)
R.FillRandom(h, "gaus")

#Draw the histogram on screen
c = R.TCanvas()
R.Draw(h)

#Fit the histogram wih a normal distribution
R.Fit(h, "gaus")

#Save the Canvas in an image file
R.SaveAs(c, "demo_ROOT.png")

#Save the histogram and the graphic canvas in the demo_ROOT_out.root file.
f = R.TFile!Open("demo_ROOT_out.root", "RECREATE")
R.Write(h)
R.Write(c)
Close(f)

More examples

More examples can be found in the examples directory.

Supported ROOT classes

Classes, whose methods are bound

See input list in misc/ROOT.wit

  • TSystem, TROOT
  • TTree,TBranch, TLeaf
  • TTreeReader
  • TCanvas
  • TH1, TH2
  • TProfile, TProfile2D
  • TRandom
  • TAxis
  • TGraph
  • TF1, TFormula
  • TFile, TDirectoryFile, TDirectory
  • TTreeReader, TTreeReaderValue, TTreeReaderArray
  • TVectorD, TVectorF
  • TObject, TNamed
  • TEntryList, Key

Complete list of bound ROOT types, including classes whose methods are not exposed to Julia

See also misc/jlROOT-report.txt.

  • TObject
  • TBrowser
  • TObjArray
  • TTimer
  • TClass
  • TBuffer
  • TVectorT
  • TVectorT
  • TVectorT
  • TNamed
  • TString
  • TDirectory
  • TDirectory::TContext
  • TKey
  • TFile
  • TList
  • TUUID
  • TVirtualMutex
  • TROOT
  • TApplication
  • TInterpreter
  • std::type_info
  • TCollection
  • TSeqCollection
  • TDataType
  • TVirtualPad
  • TCanvas
  • TBrowserImp
  • TBranch
  • TTree
  • TLeaf
  • TClonesArray
  • ROOT::TIOFeatures
  • TTree::TClusterIterator
  • TStreamerInfo
  • TEntryList
  • TH1
  • TIterator
  • TVirtualTreePlayer
  • TTreeFriendLeafIter
  • TBranchPtr
  • TLeaf::GetValueHelper
  • FileStat_t
  • UserGroup_t
  • SysInfo_t
  • CpuInfo_t
  • MemInfo_t
  • ProcInfo_t
  • RedirectHandle_t
  • TProcessEventTimer
  • TSystem
  • TFileHandler
  • TSignalHandler
  • TStdExceptionHandler
  • TTime
  • _IO_FILE
  • TInetAddress
  • TPad
  • TObjLink
  • TAxis
  • TArrayD
  • Foption_t
  • TF1
  • TRandom
  • TFitResultPtr
  • TH1C
  • TH1S
  • TH1I
  • TH1F
  • TH1D
  • TH2
  • TProfile
  • TH2C
  • TH2S
  • TH2I
  • TH2F
  • TH2D
  • TProfile2D
  • TApplicationImp
  • TDirectoryFile
  • TDatime
  • TArrayC
  • TUrl
  • TFileOpenHandle
  • TGraph
  • TF1Parameters
  • TF1::TF1FunctorPointer
  • TFormula
  • TMethodCall
  • TTreeReaderValue
  • TTreeReader
  • TTreeReader::Iterator_t
  • TTreeReaderArray

Missing a ROOT class?

If you miss a ROOT class and have a minimum of programming skills, we invite you to check out the code from the ROOTjl-generator repository. The generate.jl script of ROOTjl-generator is used to generate the contents of the src directory, deps directory and Project.toml file of the ROOT.jl package.

The class should be added in the list defined by the input parameter of the src/ROOT.wit.in configuration file. At best, it will work out of the box. With a bit less luck, it will fail but it can be fixed by adding few methods in the src/jlROOT-veto.h to exclude them from the Julia binding. At worst, it will require changes in the Wrapit! wrapper generator.

A wish list will also be added in the ROOTjl-generator to prioritize the ROOT classes to add.

How to contribute?

New contribution is welcome. Here is a list of contributions ideas:

  1. Add support for a not-yet-supported ROOT class: see previous section.
  2. Develop a Julia script that converts the ROOT Doxygen API documentation into Julia documentation (docstring. The xml output format of Doxygen, designed to be parsed by a program, will be used. Contact @grasph if you are interested in this project or send a message to Julia discourse - HEP category
  3. Contribute to WrapIt!, the engine that generates the wrapping code needed by CxxWrap C++/Julia interface.
  4. Port a ROOT tutorial into Julia to be be added to the examples.

Used By Packages

No packages found.