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(
31 "model",
"model", ROOT.RooArgList(
32 g1, g2), ROOT.RooArgList(frac))
35data = model.generate(ROOT.RooArgSet(x), 1000)
40r = model.fitTo(data, ROOT.RooFit.Save())
45parabPdf = r.createHessePdf(ROOT.RooArgSet(frac, mean, sigma_g2))
51d = parabPdf.generate(ROOT.RooArgSet(mean, sigma_g2, frac), 100000)
55hh_3d = parabPdf.createHistogram(
"mean,sigma_g2,frac", 25, 25, 25)
56hh_3d.SetFillColor(ROOT.kBlue)
61pdf_sigmag2_frac = parabPdf.createProjection(ROOT.RooArgSet(mean))
62pdf_mean_frac = parabPdf.createProjection(ROOT.RooArgSet(sigma_g2))
63pdf_mean_sigmag2 = parabPdf.createProjection(ROOT.RooArgSet(frac))
66hh_sigmag2_frac = pdf_sigmag2_frac.createHistogram(
"sigma_g2,frac", 50, 50)
67hh_mean_frac = pdf_mean_frac.createHistogram(
"mean,frac", 50, 50)
68hh_mean_sigmag2 = pdf_mean_sigmag2.createHistogram(
"mean,sigma_g2", 50, 50)
69hh_mean_frac.SetLineColor(ROOT.kBlue)
70hh_sigmag2_frac.SetLineColor(ROOT.kBlue)
71hh_mean_sigmag2.SetLineColor(ROOT.kBlue)
74ROOT.gStyle.SetCanvasPreferGL(
True)
75ROOT.gStyle.SetPalette(1)
76c1 = ROOT.TCanvas(
"rf608_fitresultaspdf_1",
"rf608_fitresultaspdf_1", 600, 600)
79c1.SaveAs(
"rf608_fitresultaspdf_1.png")
82c2 = ROOT.TCanvas(
"rf608_fitresultaspdf_2",
83 "rf608_fitresultaspdf_2", 900, 600)
86ROOT.gPad.SetLeftMargin(0.15)
87hh_mean_sigmag2.GetZaxis().SetTitleOffset(1.4)
88hh_mean_sigmag2.Draw(
"surf3")
90ROOT.gPad.SetLeftMargin(0.15)
91hh_sigmag2_frac.GetZaxis().SetTitleOffset(1.4)
92hh_sigmag2_frac.Draw(
"surf3")
94ROOT.gPad.SetLeftMargin(0.15)
95hh_mean_frac.GetZaxis().SetTitleOffset(1.4)
96hh_mean_frac.Draw(
"surf3")
99tmp1 = d.createHistogram(mean, sigma_g2, 50, 50)
100tmp2 = d.createHistogram(sigma_g2, frac, 50, 50)
101tmp3 = d.createHistogram(mean, frac, 50, 50)
104ROOT.gPad.SetLeftMargin(0.15)
105tmp1.GetZaxis().SetTitleOffset(1.4)
108ROOT.gPad.SetLeftMargin(0.15)
109tmp2.GetZaxis().SetTitleOffset(1.4)
112ROOT.gPad.SetLeftMargin(0.15)
113tmp3.GetZaxis().SetTitleOffset(1.4)
116c2.SaveAs(
"rf608_fitresultaspdf_2.png")