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

Checked checkbox, round 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

Checked checkbox, round 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

Checked checkbox, round 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

Checked checkbox, round 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

Checked checkbox, round 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

Checked checkbox, round 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

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

7

Checked checkbox, round 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

Checked checkbox, round 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.


tip.gif /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.
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2013-06-24 - AnnaSfyrla
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback