20x = ROOT.RooRealVar(
"x",
"x", -20, 20)
23mean = ROOT.RooRealVar(
"mean",
"mean of g1 and g2", 0, -1, 1)
24sigma_g1 = ROOT.RooRealVar(
"sigma_g1",
"width of g1", 2)
25g1 = ROOT.RooGaussian(
"g1",
"g1", x, mean, sigma_g1)
27sigma_g2 = ROOT.RooRealVar(
"sigma_g2",
"width of g2", 4, 3.0, 5.0)
28g2 = ROOT.RooGaussian(
"g2",
"g2", x, mean, sigma_g2)
30frac = ROOT.RooRealVar(
"frac",
"frac", 0.5, 0.0, 1.0)
31model = ROOT.RooAddPdf(
32 "model",
"model", ROOT.RooArgList(
33 g1, g2), ROOT.RooArgList(frac))
36data = model.generate(ROOT.RooArgSet(x), 1000)
41r = model.fitTo(data, ROOT.RooFit.Save())
46parabPdf = r.createHessePdf(ROOT.RooArgSet(frac, mean, sigma_g2))
52d = parabPdf.generate(ROOT.RooArgSet(mean, sigma_g2, frac), 100000)
56hh_3d = parabPdf.createHistogram(
"mean,sigma_g2,frac", 25, 25, 25)
57hh_3d.SetFillColor(ROOT.kBlue)
62pdf_sigmag2_frac = parabPdf.createProjection(ROOT.RooArgSet(mean))
63pdf_mean_frac = parabPdf.createProjection(ROOT.RooArgSet(sigma_g2))
64pdf_mean_sigmag2 = parabPdf.createProjection(ROOT.RooArgSet(frac))
67hh_sigmag2_frac = pdf_sigmag2_frac.createHistogram(
"sigma_g2,frac", 50, 50)
68hh_mean_frac = pdf_mean_frac.createHistogram(
"mean,frac", 50, 50)
69hh_mean_sigmag2 = pdf_mean_sigmag2.createHistogram(
"mean,sigma_g2", 50, 50)
70hh_mean_frac.SetLineColor(ROOT.kBlue)
71hh_sigmag2_frac.SetLineColor(ROOT.kBlue)
72hh_mean_sigmag2.SetLineColor(ROOT.kBlue)
75ROOT.gStyle.SetCanvasPreferGL(
True)
76ROOT.gStyle.SetPalette(1)
77c1 = ROOT.TCanvas(
"rf608_fitresultaspdf_1",
"rf608_fitresultaspdf_1", 600, 600)
80c1.SaveAs(
"rf608_fitresultaspdf_1.png")
83c2 = ROOT.TCanvas(
"rf608_fitresultaspdf_2",
84 "rf608_fitresultaspdf_2", 900, 600)
87ROOT.gPad.SetLeftMargin(0.15)
88hh_mean_sigmag2.GetZaxis().SetTitleOffset(1.4)
89hh_mean_sigmag2.Draw(
"surf3")
91ROOT.gPad.SetLeftMargin(0.15)
92hh_sigmag2_frac.GetZaxis().SetTitleOffset(1.4)
93hh_sigmag2_frac.Draw(
"surf3")
95ROOT.gPad.SetLeftMargin(0.15)
96hh_mean_frac.GetZaxis().SetTitleOffset(1.4)
97hh_mean_frac.Draw(
"surf3")
100tmp1 = d.createHistogram(mean, sigma_g2, 50, 50)
101tmp2 = d.createHistogram(sigma_g2, frac, 50, 50)
102tmp3 = d.createHistogram(mean, frac, 50, 50)
105ROOT.gPad.SetLeftMargin(0.15)
106tmp1.GetZaxis().SetTitleOffset(1.4)
109ROOT.gPad.SetLeftMargin(0.15)
110tmp2.GetZaxis().SetTitleOffset(1.4)
113ROOT.gPad.SetLeftMargin(0.15)
114tmp3.GetZaxis().SetTitleOffset(1.4)
117c2.SaveAs(
"rf608_fitresultaspdf_2.png")