import ROOT

"""
Explanation: Access TTree in Python using PyROOT
<hr style="border-top-width: 4px; border-top-color: #34609b;">
End of explanation
"""


f = ROOT.TFile.Open("http://indico.cern.ch/event/395198/material/0/0.root")

"""
Explanation: Open a file which is located on the web. No type is to be specified for "f".
End of explanation
"""


maxPt=-1
for event in f.events:
    maxPt=-1
    for track in event.tracks:
        pt = track.Pt()
        if pt > maxPt: maxPt = pt
    if event.evtNum % 100 == 0:
        print "Processing event number %i" %event.evtNum
        print "Max pt is %f" %maxPt

"""
Explanation: Loop over the TTree called "events" in the file. It is accessed with the dot operator.
Same holds for the access to the branches: no need to set them up - they are just accessed by name, again with the dot operator.
End of explanation
"""


