19x = ROOT.RooRealVar(
"x",
"x", 0, 20)
20p = ROOT.RooPolynomial(
"p",
"p", x, ROOT.RooArgList(ROOT.RooFit.RooConst(
21 0.01), ROOT.RooFit.RooConst(-0.01), ROOT.RooFit.RooConst(0.0004)))
24data1 = p.generate(ROOT.RooArgSet(x), 200)
32kest1 = ROOT.RooKeysPdf(
"kest1",
"kest1", x, data1,
33 ROOT.RooKeysPdf.MirrorBoth)
37kest2 = ROOT.RooKeysPdf(
"kest2",
"kest2", x, data1,
38 ROOT.RooKeysPdf.NoMirror)
42kest3 = ROOT.RooKeysPdf(
"kest1",
"kest1", x, data1,
43 ROOT.RooKeysPdf.MirrorBoth, 2)
47 ROOT.RooFit.Title(
"Adaptive kernel estimation pdf with and w/o mirroring"),
51kest2.plotOn(frame, ROOT.RooFit.LineStyle(
52 ROOT.kDashed), ROOT.RooFit.LineColor(ROOT.kRed))
55frame2 = x.frame(ROOT.RooFit.Title(
56 "Adaptive kernel estimation pdf with regular, bandwidth"))
58kest3.plotOn(frame2, ROOT.RooFit.LineColor(ROOT.kMagenta))
64y = ROOT.RooRealVar(
"y",
"y", 0, 20)
65py = ROOT.RooPolynomial(
"py",
"py", y, ROOT.RooArgList(ROOT.RooFit.RooConst(
66 0.01), ROOT.RooFit.RooConst(0.01), ROOT.RooFit.RooConst(-0.0004)))
67pxy = ROOT.RooProdPdf(
"pxy",
"pxy", ROOT.RooArgList(p, py))
68data2 = pxy.generate(ROOT.RooArgSet(x, y), 1000)
74kest4 = ROOT.RooNDKeysPdf(
"kest4",
"kest4", ROOT.RooArgList(x, y), data2,
"am")
78kest5 = ROOT.RooNDKeysPdf(
79 "kest5",
"kest5", ROOT.RooArgList(
80 x, y), data2,
"am", 2)
83hh_data = ROOT.RooAbsData.createHistogram(
84 data2,
"hh_data", x, ROOT.RooFit.Binning(10), ROOT.RooFit.YVar(
85 y, ROOT.RooFit.Binning(10)))
88hh_pdf = kest4.createHistogram(
"hh_pdf", x, ROOT.RooFit.Binning(
89 25), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(25)))
90hh_pdf2 = kest5.createHistogram(
"hh_pdf2", x, ROOT.RooFit.Binning(
91 25), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(25)))
92hh_pdf.SetLineColor(ROOT.kBlue)
93hh_pdf2.SetLineColor(ROOT.kMagenta)
95c = ROOT.TCanvas(
"rf707_kernelestimation",
96 "rf707_kernelestimation", 800, 800)
99ROOT.gPad.SetLeftMargin(0.15)
100frame.GetYaxis().SetTitleOffset(1.4)
103ROOT.gPad.SetLeftMargin(0.15)
104frame2.GetYaxis().SetTitleOffset(1.8)
107ROOT.gPad.SetLeftMargin(0.15)
108hh_data.GetZaxis().SetTitleOffset(1.4)
111ROOT.gPad.SetLeftMargin(0.20)
112hh_pdf.GetZaxis().SetTitleOffset(2.4)
114hh_pdf2.Draw(
"surfsame")
116c.SaveAs(
"rf707_kernelestimation.png")