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