In [1]:
import ROOT
from ROOT import gROOT, TCanvas, TF1, TFile, TTree, gRandom, TH1F
import rootnotes
import rootprint
import utils
Welcome to JupyROOT 6.22/02

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

In [2]:
%jsroot on
In [3]:
f = ROOT.TFile.Open("http://opendata.atlas.cern/release/samples/MC/mc_105987.WZ.root") ## 8 TeV sample
In [4]:
#canvas = ROOT.TCanvas("Canvas","a first way to plot a variable",800,600)
c1 = rootnotes.canvas("Example with Formula", (800, 600))
In [5]:
tree = f.Get("mini")
tree.GetEntries()
Out[5]:
500000
In [6]:
hist = ROOT.TH1F("variable","Example plot: Number of leptons; Number of leptons ; Events ",5,-0.5,4.5)
In [7]:
for event in tree:
    hist.Fill(tree.lep_n)
    
print("Done!")
Done!
In [8]:
hist.SetFillColor(2)
hist.Draw()
In [10]:
#c1.Draw()
c1
Out[10]:
Info in <TCanvas::Print>: png file /tmp/tmpuxcu4p5i.png has been created
In [14]:
scale = hist.Integral()
hist.Scale(1/scale)
hist.SetFillColor(2)

hist.Draw()
#canvas.Draw("hist")
c1
Out[14]:
Info in <TCanvas::Print>: png file /tmp/tmp_03_ws2y.png has been created
In [ ]: