Write a python macro ExerciseHist.py
.
Zmumu.root
file and load the tree called physics
.lep1_m
and lep2_m
.Bonus questions:
import ROOT
%jsroot on
Welcome to JupyROOT 6.28/00
from ROOT import gStyle, TCanvas, TFile, TH1D
gStyle.SetOptStat(0)
file = TFile("Zmumu.root")
tree = file.Get("physics")
canvas = TCanvas("canvas", "", 800, 600)
hist_1 = TH1D("hist_1", "Leading lepton mass", 40, 0, 0.2)
hist_2 = TH1D("hist_2", "Subleading lepton mass", 40, 0, 0.2)
tree.Draw("lep1_m >> hist_1", "", "PLC")
tree.Draw("lep2_m >> hist_2", "", "PLC same")
canvas.Draw()
print(f"Leading muon mass: mean={hist_1.GetMean():.6f}; rms={hist_1.GetRMS():.6f}")
print(f"Subleading muon mass: mean={hist_2.GetMean():.6f}; rms={hist_2.GetRMS():.6f}")
print(f"Leading muon mass integral: {hist_1.Integral()}")
print(f"Subleading muon mass integral: {hist_2.Integral()}")
Leading muon mass: mean=0.105476; rms=0.007434 Subleading muon mass: mean=0.105479; rms=0.005120 Leading muon mass integral: 2495706.0 Subleading muon mass integral: 2496792.0
Last update: 06 March 2023