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