A Python -- ROOT Bridge

Wim Lavrijsen

Lawrence Berkeley National Laboratory
National Energy Research Scientific Computing Center

1, Cyclotron Road

Revision History
Revision 1.1.1October 2008wlav
Minor fixes in the text.
Revision 1.1June 2006wlav
Updates for ROOT production release 5.12.
Revision 0.1 -- 1.0June 2004 -- December 2005wlav
Details removed.



The document describes PyROOT as shipped with ROOT production release 5.12.

The python programming language is a popular, open-source, dynamic language with an interactive interpreter. Its interoperability with other programming languages, both for extending python as well as embedding it, is excellent and many existing third-party applications and libraries have therefore so-called "python bindings." PyROOT provides python bindings for ROOT: it enables cross-calls from ROOT/CINT into python and vice versa, the intermingling of the two interpreters, and the transport of user-level objects from one interpreter to the other. PyROOT enables access from ROOT to any application or library that itself has python bindings, and it makes all ROOT functionality directly available from the python interpreter.

Table of Contents

1. Introduction
2. Overview
3. Installation
4. Using PyROOT
5. Memory handling
6. Performance
A. Recipes
A.1. Use of python functions
A.2. Working with TTrees
A.3. Using your own classes
Explanation of terms

1. Introduction

It is assumed that the reader has a working knowledge of both ROOT and python. If not, then their respective websites ( and, respectively) offer sufficient introductory material not to repeat it here.

This document starts out by setting the stage with an overview of what PyROOT enables you, in general terms, to do. The overview can be read like an executive summary: it is self-contained, sufficient for a rough understanding, and all the details are taken care of in subsequent parts of the text. The article then moves on to some practical details: how to obtain, compile, and setup PyROOT (see Section 3, “Installation”), as well as how to use it in your python sessions and scripts. With the basics covered, there are several sections that address the boundary cases of the bindings, and how they have been resolved with, hopefully, the minimum amount of surprises and gotcha's. These sections are required reading if you plan to write more complicated scripts or want to do more than running simple interactive sessions.

The article concludes with recipes on how to work with certain ROOT specific features, and how to perform common ROOT tasks in python. These recipes double as reference material. A glossary and a brief bibliography are provided as well.