<h1><b>Python example to read a ROOT file</b></h1>
import ROOT
Welcome to ROOTaaS 6.06/00
f = ROOT.TFile.Open("/home/adminuser/Dropbox/Public/CEVALE_Tarea_3/input_MC_samples_Tarea4_cevale2ven.root")
t = f.Get("tree")
h = ROOT.TH1F("variable","Example variable from the mini tree",40,0,200)
c = ROOT.TCanvas("testCanvas","a first way to plot a variable",800,600)
t.Draw("lepZ_m:realZ_LJ_m","lepZ_m>0.","colz")
797827L
c.Draw()
for event in t:
if t.RunNumber==167809 or t.RunNumber==167812:
h.Fill(t.lepZ_m/1000)
print "Done!"
Done!
h.Draw()
c.Draw()
scale = h.Integral()
h.Scale(1/scale)
h.Draw()
c.Draw()
h.Fit("gaus","S")
## h.Fit("gaus","S")
<ROOT.TFitResultPtr object at 0x7eeb0d0>
FCN=0.130725 FROM MIGRAD STATUS=CONVERGED 119 CALLS 120 TOTAL EDM=1.49134e-08 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 Constant 4.02352e-01 6.25378e-01 2.23778e-04 -3.82700e-04 2 Mean 9.04647e+01 4.67614e+00 2.40089e-03 -1.01752e-05 3 Sigma 4.30916e+00 4.80556e+00 7.48278e-05 -9.47525e-04
%%cpp
variable->SetFillColor(kBlue);
variable->Fit("gaus","S");
testCanvas->Draw();
FCN=0.130725 FROM MIGRAD STATUS=CONVERGED 119 CALLS 120 TOTAL EDM=1.49134e-08 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 Constant 4.02352e-01 6.25378e-01 2.23778e-04 -3.82700e-04 2 Mean 9.04647e+01 4.67614e+00 2.40089e-03 -1.01752e-05 3 Sigma 4.30916e+00 4.80556e+00 7.48278e-05 -9.47525e-04