 # Simple pyROOT notebook example using TLorentz Vectors

In :
import ROOT

Welcome to JupyROOT 6.08/04

In :
## f = ROOT.TFile.Open("mc_105986.ZZ.root")
## f = ROOT.TFile.Open("mc_147770.Zee.root")
f = ROOT.TFile.Open("http://opendata.atlas.cern/release/samples/MC/mc_147770.Zee.root")

In :
c = ROOT.TCanvas("testCanvas","a first way to plot a variable",800,600)

In :
t = f.Get("mini")

In :
h = ROOT.TH1F("variable","Example plot: Number of Leptons",4,0,4)

In [ ]:
h_Mll = ROOT.TH1F("h_Mll","Invariant mass of the two Leptons",50,0,200)

In [ ]:
for event in t:
"""This is the cut #1: request at least 2 leptons"""
if t.lep_n > 1:
"""Let's define one TLorentz vector for each, e.i. two vectors!"""
leadingLep = ROOT.TLorentzVector(t.lep_pt, t.lep_eta, t.lep_phi, t.lep_E)
secondLep  = ROOT.TLorentzVector(t.lep_pt, t.lep_eta, t.lep_phi, t.lep_E)

"""Next line does the addition of the two TLorentz vectors above and so,
we can ask the mass very easy"""
TL_ll = leadingLep + secondLep

"""We devide the value of the combined vector by 1000 to get the value in GeV"""
mll = TL_ll.M()/1000.
h_Mll.Fill(mll,w)

print "Done!"

In [ ]:
"""Now les't plot the mass of the lepton-lepton system"""
h_Mll.Draw()
c.Draw()

In [ ]: