22x = ROOT.RooRealVar(
"x",
"x", 0, 20)
23p = ROOT.RooPolynomial(
"p",
"p", x, ROOT.RooArgList(ROOT.RooFit.RooConst(
24 0.01), ROOT.RooFit.RooConst(-0.01), ROOT.RooFit.RooConst(0.0004)))
27data1 = p.generate(ROOT.RooArgSet(x), 200)
35kest1 = ROOT.RooKeysPdf(
"kest1",
"kest1", x, data1,
36 ROOT.RooKeysPdf.MirrorBoth)
40kest2 = ROOT.RooKeysPdf(
"kest2",
"kest2", x, data1,
41 ROOT.RooKeysPdf.NoMirror)
45kest3 = ROOT.RooKeysPdf(
"kest1",
"kest1", x, data1,
46 ROOT.RooKeysPdf.MirrorBoth, 2)
49frame = x.frame(ROOT.RooFit.Title(
50 "Adaptive kernel estimation pdf with and w/o mirroring"), ROOT.RooFit.Bins(20))
53kest2.plotOn(frame, ROOT.RooFit.LineStyle(
54 ROOT.kDashed), ROOT.RooFit.LineColor(ROOT.kRed))
57frame2 = x.frame(ROOT.RooFit.Title(
58 "Adaptive kernel estimation pdf with regular, bandwidth"))
60kest3.plotOn(frame2, ROOT.RooFit.LineColor(ROOT.kMagenta))
66y = ROOT.RooRealVar(
"y",
"y", 0, 20)
67py = ROOT.RooPolynomial(
"py",
"py", y, ROOT.RooArgList(ROOT.RooFit.RooConst(0.01), ROOT.RooFit.RooConst(0.01), ROOT.RooFit.RooConst(-0.0004)))
68pxy = ROOT.RooProdPdf(
"pxy",
"pxy", ROOT.RooArgList(p, py))
69data2 = pxy.generate(ROOT.RooArgSet(x, y), 1000)
75kest4 = ROOT.RooNDKeysPdf(
"kest4",
"kest4", ROOT.RooArgList(x, y), data2,
"am")
79kest5 = ROOT.RooNDKeysPdf(
"kest5",
"kest5", ROOT.RooArgList(x, y), data2,
"am", 2)
82hh_data = ROOT.RooAbsData.createHistogram(data2,
"hh_data", x, ROOT.RooFit.Binning(
83 10), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(10)))
86hh_pdf = kest4.createHistogram(
"hh_pdf", x, ROOT.RooFit.Binning(
87 25), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(25)))
88hh_pdf2 = kest5.createHistogram(
"hh_pdf2", x, ROOT.RooFit.Binning(
89 25), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(25)))
90hh_pdf.SetLineColor(ROOT.kBlue)
91hh_pdf2.SetLineColor(ROOT.kMagenta)
93c = ROOT.TCanvas(
"rf707_kernelestimation",
94 "rf707_kernelestimation", 800, 800)
97ROOT.gPad.SetLeftMargin(0.15)
98frame.GetYaxis().SetTitleOffset(1.4)
101ROOT.gPad.SetLeftMargin(0.15)
102frame2.GetYaxis().SetTitleOffset(1.8)
105ROOT.gPad.SetLeftMargin(0.15)
106hh_data.GetZaxis().SetTitleOffset(1.4)
109ROOT.gPad.SetLeftMargin(0.20)
110hh_pdf.GetZaxis().SetTitleOffset(2.4)
112hh_pdf2.Draw(
"surfsame")
114c.SaveAs(
"rf707_kernelestimation.png")