18x = ROOT.RooRealVar(
"x",
"x", 0, 20)
19p = ROOT.RooPolynomial(
"p",
"p", x, [0.01, -0.01, 0.0004])
22data1 = p.generate({x}, 200)
30kest1 = ROOT.RooKeysPdf(
"kest1",
"kest1", x, data1, ROOT.RooKeysPdf.MirrorBoth)
34kest2 = ROOT.RooKeysPdf(
"kest2",
"kest2", x, data1, ROOT.RooKeysPdf.NoMirror)
38kest3 = ROOT.RooKeysPdf(
"kest1",
"kest1", x, data1, ROOT.RooKeysPdf.MirrorBoth, 2)
41frame = x.frame(Title=
"Adaptive kernel estimation pdf with and w/o mirroring", Bins=20)
44kest2.plotOn(frame, LineStyle=
"--", LineColor=
"r")
47frame2 = x.frame(Title=
"Adaptive kernel estimation pdf with regular, bandwidth")
49kest3.plotOn(frame2, LineColor=
"m")
55y = ROOT.RooRealVar(
"y",
"y", 0, 20)
56py = ROOT.RooPolynomial(
60 [0.01, 0.01, -0.0004],
62pxy = ROOT.RooProdPdf(
"pxy",
"pxy", [p, py])
63data2 = pxy.generate({x, y}, 1000)
69kest4 = ROOT.RooNDKeysPdf(
"kest4",
"kest4", [x, y], data2,
"am")
73kest5 = ROOT.RooNDKeysPdf(
"kest5",
"kest5", [x, y], data2,
"am", 2)
76hh_data = ROOT.RooAbsData.createHistogram(data2,
"hh_data", x, Binning=10, YVar=dict(var=y, Binning=10))
79hh_pdf = kest4.createHistogram(
"hh_pdf", x, Binning=25, YVar=dict(var=y, Binning=25))
80hh_pdf2 = kest5.createHistogram(
"hh_pdf2", x, Binning=25, YVar=dict(var=y, Binning=25))
81hh_pdf.SetLineColor(ROOT.kBlue)
82hh_pdf2.SetLineColor(ROOT.kMagenta)
84c = ROOT.TCanvas(
"rf707_kernelestimation",
"rf707_kernelestimation", 800, 800)
87ROOT.gPad.SetLeftMargin(0.15)
88frame.GetYaxis().SetTitleOffset(1.4)
91ROOT.gPad.SetLeftMargin(0.15)
92frame2.GetYaxis().SetTitleOffset(1.8)
95ROOT.gPad.SetLeftMargin(0.15)
96hh_data.GetZaxis().SetTitleOffset(1.4)
99ROOT.gPad.SetLeftMargin(0.20)
100hh_pdf.GetZaxis().SetTitleOffset(2.4)
102hh_pdf2.Draw(
"surfsame")
104c.SaveAs(
"rf707_kernelestimation.png")