Exercises linked to GaudiPython session
The purpose of these exercises is to allow you to become more familiar with the Python interface to Gaudi and ROOT.
1. Python and Root
The first exercise is concerned with the Python interface to ROOT.
Write a small Python function (e.g. second.py
) which
draws a function, e.g. sin(x)
.
The function should:
- Setup the environment via
SetupProject DaVinci v17r6
(if you didn't do this already). Check that you have the right versions of ROOT (5.13.04c
from the LCG area) and Python (2.4.2
from the LCG area) - Import the ROOT package
- Open a ROOT
TCanvas
- Take the limits between which the functions is drawn as arguments
- Define a new function using
TF1
from ROOT - Draw the function
2. Understand InitGaudi.py and GaudiPyTutorial.py
- Copy the files InitGaudi.py and GaudiPyTutorial.py from
solutions/GaudiPython
to your local working directory - Setup the environment via
SetupProject DaVinci v17r6
(if you didn't do this already). Check that you have the right versions of ROOT (5.13.04c
from the LCG area ) and Python (2.4.2
from the LCG area) - We will use a DST files from the Bs -> J/psi Phi dataset. You can either
make a copy of the file to some scratch area (e.g.
/tmp
via e.g.rfcp /castor/cern.ch/grid/lhcb/production/DC06/v1-lumi2/00001438/DST/0000/00001438_00000001_5.dst /tmp
or use files from CASTOR - Go through the file and understand what happens. Execute the event-loop
for some events and look at the histograms. You can do this following
the steps
- start a Python shell via
python
-
import GaudiPyTutorial
-
GaudiPyTutorial.eventLoop(N)
for N events
- start a Python shell via
Extend the event loop with own histograms and cuts
- Extend the event-loop with own cuts and histograms. Reload the changed
Python script with
reload(GaudiPyTutorial)
and jump back to the beginning of the data-file withGaudiPyTuTorial.sel.rewind()
. For example, you could apply a cut on the combined Particle ID for the muons and compare how the invariant mass distribution changes, apply a cut on the maximal chi**2 of the di-muon vertex fit, ...
Last modified by U. Kerzel, 2007-Jan-04