Creating and filling AIDA histograms and plotting them in a ROOT Canvas
using PyROOT
Description
Histograms of 1 and 2 dimensions are created ("booked"), and filled
with different random number distributions available from the Python
random package and then plotted in a Root canvas.
Python program
Click to retrieve the Python script of the example.
After having setup correctly your environment, you can run the example typing :
python -i rootDemo.py
Program flow
- The Python module AidaProxy is imported. This module loads the dictionary for the PI classes, making them available in the Python environment in the global namespace.
- 1D and 2D Histograms are booked
- The histograms are filled with random data. The random data are generated with gaussian, exponential, log normal, gamma distributions using functions available from the Python random package
- The Python module rootPlotter is imported. The module imports first the Python binding to ROOT, PyROOT. The rootPlotter module defines a python class, RootPlotter, which implements the plotting of AIDA histograms in a Root canvas, using PyROOT
- An instance of the RootPlotter class is created. This class creates a Root canvas.
- The canvas is divided in 2 x 3 zones
- The histograms are plotted in each zone. The histograms are copied, in the rootPlotter module from AIDA to Root object and then drawn in the canvas.