19x = ROOT.RooRealVar(
"x",
"x", -20, 20)
22mean = ROOT.RooRealVar(
"mean",
"mean of g1 and g2", 0, -1, 1)
23sigma_g1 = ROOT.RooRealVar(
"sigma_g1",
"width of g1", 2)
24g1 = ROOT.RooGaussian(
"g1",
"g1", x, mean, sigma_g1)
26sigma_g2 = ROOT.RooRealVar(
"sigma_g2",
"width of g2", 4, 3.0, 5.0)
27g2 = ROOT.RooGaussian(
"g2",
"g2", x, mean, sigma_g2)
29frac = ROOT.RooRealVar(
"frac",
"frac", 0.5, 0.0, 1.0)
30model = ROOT.RooAddPdf(
"model",
"model", [g1, g2], [frac])
33data = model.generate({x}, 1000)
38r = model.fitTo(data, Save=
True)
43parabPdf = r.createHessePdf({frac, mean, sigma_g2})
49d = parabPdf.generate({mean, sigma_g2, frac}, 100000)
53hh_3d = parabPdf.createHistogram(
"mean,sigma_g2,frac", 25, 25, 25)
54hh_3d.SetFillColor(ROOT.kBlue)
59pdf_sigmag2_frac = parabPdf.createProjection({mean})
60pdf_mean_frac = parabPdf.createProjection({sigma_g2})
61pdf_mean_sigmag2 = parabPdf.createProjection({frac})
64hh_sigmag2_frac = pdf_sigmag2_frac.createHistogram(
"sigma_g2,frac", 50, 50)
65hh_mean_frac = pdf_mean_frac.createHistogram(
"mean,frac", 50, 50)
66hh_mean_sigmag2 = pdf_mean_sigmag2.createHistogram(
"mean,sigma_g2", 50, 50)
67hh_mean_frac.SetLineColor(ROOT.kBlue)
68hh_sigmag2_frac.SetLineColor(ROOT.kBlue)
69hh_mean_sigmag2.SetLineColor(ROOT.kBlue)
72ROOT.gStyle.SetCanvasPreferGL(
True)
73ROOT.gStyle.SetPalette(1)
74c1 = ROOT.TCanvas(
"rf608_fitresultaspdf_1",
"rf608_fitresultaspdf_1", 600, 600)
77c1.SaveAs(
"rf608_fitresultaspdf_1.png")
80c2 = ROOT.TCanvas(
"rf608_fitresultaspdf_2",
"rf608_fitresultaspdf_2", 900, 600)
83ROOT.gPad.SetLeftMargin(0.15)
84hh_mean_sigmag2.GetZaxis().SetTitleOffset(1.4)
85hh_mean_sigmag2.Draw(
"surf3")
87ROOT.gPad.SetLeftMargin(0.15)
88hh_sigmag2_frac.GetZaxis().SetTitleOffset(1.4)
89hh_sigmag2_frac.Draw(
"surf3")
91ROOT.gPad.SetLeftMargin(0.15)
92hh_mean_frac.GetZaxis().SetTitleOffset(1.4)
93hh_mean_frac.Draw(
"surf3")
96tmp1 = d.createHistogram(mean, sigma_g2, 50, 50)
97tmp2 = d.createHistogram(sigma_g2, frac, 50, 50)
98tmp3 = d.createHistogram(mean, frac, 50, 50)
101ROOT.gPad.SetLeftMargin(0.15)
102tmp1.GetZaxis().SetTitleOffset(1.4)
105ROOT.gPad.SetLeftMargin(0.15)
106tmp2.GetZaxis().SetTitleOffset(1.4)
109ROOT.gPad.SetLeftMargin(0.15)
110tmp3.GetZaxis().SetTitleOffset(1.4)
113c2.SaveAs(
"rf608_fitresultaspdf_2.png")