ROOT and Python start-up exercises
- You can find example ROOT files:
/afs/cern.ch/work/s/sfyrla/public/files/
- See documentation on the basic structure inside the ROOT file, the TTree
.
1

Open a root file with the TBrowser and look at the contents:
-bash-4.1$ root -l /afs/cern.ch/work/s/sfyrla/public/files/file1.root
root [1] new TBrowser

See the contents of the file from the command line; e.g.:
root [2] _file0.ls()
root [3] tree= _file0.Get(“susy”)
root [4] tree.Print()
root [5] tree.Print("mc*”)
2

You can use python (PyROOT) to look into the root files. E.g.
/afs/cern.ch/user/s/sfyrla/public/PyROOTExamples/listScriptContents.py
-bash-4.1$ python listScriptContents.py
3

Loop over the entries (just 10 entries) of the tree; Look at the pT, eta and phi of the jets in the events.
/afs/cern.ch/user/s/sfyrla/public/PyROOTExamples/firstScript.py
-bash-4.1$ python firstScript.py
4

Loop over both files:
/afs/cern.ch/work/s/sfyrla/public/files/
E.g.
/afs/cern.ch/user/s/sfyrla/public/PyROOTExamples/secondScript.py
-bash-4.1$ python secondScript.py /afs/cern.ch/work/s/sfyrla/public/files/
5

Plot the pT, eta and phi of central jets only.
Hint:
central_jets_unsorted=[]
for jet in range(tree.jet_AntiKt4LCTopo_n):
if abs(tree.jet_AntiKt4LCTopo_eta[jet])<2.8:
central_jets_unsorted.append(tree.jet_AntiKt4LCTopo_pt[jet]/1000.)
central_jets = sorted(central_jets_unsorted,reverse=True)
6

Plot the DR between the two central leading jets > 80 GeV. DR is defined as:
DR = sqrt(Deta^2 + Dphi^2)
.
7

What is the efficiency of a 100 GeV truth cut? Ie. how is the shape of
tree.jet_AntiKt4LCTopo_pt
affected after a cut on
tree.jet_AntiKt4TruthJets_pt[0] > 100 GeV
?
Hint:
- plot hpT (the pT of the variable without any cut)
- plot hpT_truthCut (the pT of the variable after the truth cut)
- the efficiency is defined as eff = hpT_truthCut / hpT.
- in PyROOT:
efficiency = TGraphAsymmErrors(hpT_truthCut,hpT)
8

Do
7 but for a 120GeV truth cut. Plot both efficiency plots in the same canvas, one in red and the other in green. Write a legend that indicates what each plot shows and add appropriate legends in the axis titles.
/afs/cern.ch/user/s/sfyrla/public/PyROOTExamples/loopTree.py
can be used as a coding example - though it doesn’t give the solution of the above questions.