Essentially this project it allows for running PyROOT code through a browser without need to prepare a client machine in any specific way. This is possible due to IPython notebooks infrastructure that can run python (or R, MATLAB, Mathematica) code on a server through the browser. We wrote a simple wrapper for TCanvas objects that could be rendered in IPython-friendly way (more details on how you can wrap whatever you want is available in this notebook). Thanks to this project you can get prototype of LHCb masterclass (part 1, part 2) in a readable and transparent way. Note that you can download these notebooks from nbviewer and execute on your own premises (provided you have IPython with PyROOT installed on your server). The only 2 additions you need to make to existing PyROOT program:
- import small piece of code that you need to download and put in your notebooks folder. Start notebook with
- import rootnotes
- instead of TCanvas use rootnotes.default_canvas
- mycanvas = rootnotes.default_canvas
later on when you'd like to display it inside notebook, just write mycanvas and you get cell output rendered as PNG (see below).
-
-
http://root.cern.ch/drupal/content/ipython-notebooks-and-root-0
Prerequisites:
- IPython (make sure you have support for notebook, it might require jinja2, pyzmq and tornado)
- PyROOT
Actions
- grab rootnotes.py
- put it in the folder from where you start your notebook
Example
In [2]:
from ROOT import TF1
import rootnotes
c1 = rootnotes.default_canvas()
fun1 = TF1( 'fun1', 'abs(sin(x)/x)', 0, 10)
c1.SetGridx()
c1.SetGridy()
fun1.Draw()
c1
Out[2]:
Testing notebook
- Download sample formula1 notebook
- Put it to IPython notebook folder
- Run from server > ipython notebook
- Open dashboard (http://localhost:8888) in your browser and select 'formula1' there
- Select 'Cell' menu and choose 'Run all' item
- You should see plot reproduced
- Enjoy (don't forget to evaluate fascinating IPython features like exporting notebooks to HTML orpresentation and also notebook with Atlas 3D event display)