18x = ROOT.RooRealVar(
"x",
"x", 0, 20)
19p = ROOT.RooPolynomial(
"p",
"p", x, ROOT.RooArgList(ROOT.RooFit.RooConst(
20 0.01), ROOT.RooFit.RooConst(-0.01), ROOT.RooFit.RooConst(0.0004)))
23data1 = p.generate(ROOT.RooArgSet(x), 200)
31kest1 = ROOT.RooKeysPdf(
"kest1",
"kest1", x, data1,
32 ROOT.RooKeysPdf.MirrorBoth)
36kest2 = ROOT.RooKeysPdf(
"kest2",
"kest2", x, data1,
37 ROOT.RooKeysPdf.NoMirror)
41kest3 = ROOT.RooKeysPdf(
"kest1",
"kest1", x, data1,
42 ROOT.RooKeysPdf.MirrorBoth, 2)
46 ROOT.RooFit.Title(
"Adaptive kernel estimation pdf with and w/o mirroring"),
50kest2.plotOn(frame, ROOT.RooFit.LineStyle(
51 ROOT.kDashed), ROOT.RooFit.LineColor(ROOT.kRed))
54frame2 = x.frame(ROOT.RooFit.Title(
55 "Adaptive kernel estimation pdf with regular, bandwidth"))
57kest3.plotOn(frame2, ROOT.RooFit.LineColor(ROOT.kMagenta))
63y = ROOT.RooRealVar(
"y",
"y", 0, 20)
64py = ROOT.RooPolynomial(
"py",
"py", y, ROOT.RooArgList(ROOT.RooFit.RooConst(
65 0.01), ROOT.RooFit.RooConst(0.01), ROOT.RooFit.RooConst(-0.0004)))
66pxy = ROOT.RooProdPdf(
"pxy",
"pxy", ROOT.RooArgList(p, py))
67data2 = pxy.generate(ROOT.RooArgSet(x, y), 1000)
73kest4 = ROOT.RooNDKeysPdf(
"kest4",
"kest4", ROOT.RooArgList(x, y), data2,
"am")
77kest5 = ROOT.RooNDKeysPdf(
78 "kest5",
"kest5", ROOT.RooArgList(
79 x, y), data2,
"am", 2)
82hh_data = ROOT.RooAbsData.createHistogram(
83 data2,
"hh_data", x, ROOT.RooFit.Binning(10), ROOT.RooFit.YVar(
84 y, ROOT.RooFit.Binning(10)))
87hh_pdf = kest4.createHistogram(
"hh_pdf", x, ROOT.RooFit.Binning(
88 25), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(25)))
89hh_pdf2 = kest5.createHistogram(
"hh_pdf2", x, ROOT.RooFit.Binning(
90 25), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(25)))
91hh_pdf.SetLineColor(ROOT.kBlue)
92hh_pdf2.SetLineColor(ROOT.kMagenta)
94c = ROOT.TCanvas(
"rf707_kernelestimation",
95 "rf707_kernelestimation", 800, 800)
98ROOT.gPad.SetLeftMargin(0.15)
99frame.GetYaxis().SetTitleOffset(1.4)
102ROOT.gPad.SetLeftMargin(0.15)
103frame2.GetYaxis().SetTitleOffset(1.8)
106ROOT.gPad.SetLeftMargin(0.15)
107hh_data.GetZaxis().SetTitleOffset(1.4)
110ROOT.gPad.SetLeftMargin(0.20)
111hh_pdf.GetZaxis().SetTitleOffset(2.4)
113hh_pdf2.Draw(
"surfsame")
115c.SaveAs(
"rf707_kernelestimation.png")