21x = ROOT.RooRealVar(
"x",
"x", -10, 10)
24a = ROOT.RooRealVar(
"a",
"a", 0.4, 0, 1)
25b = ROOT.RooRealVar(
"b",
"b", 5)
26c = ROOT.RooRealVar(
"c",
"c", -1, -10, 10)
27effFunc = ROOT.RooFormulaVar(
"effFunc",
"(1-a)+a*cos((x-c)/b)", [a, b, c, x])
33cut = ROOT.RooCategory(
"cut",
"cutr", {
"accept": 1,
"reject": 0})
36effPdf = ROOT.RooEfficiency(
"effPdf",
"effPdf", effFunc, cut,
"accept")
43shapePdf = ROOT.RooPolynomial(
"shapePdf",
"shapePdf", x, [-0.095])
44model = ROOT.RooProdPdf(
"model",
"model", {shapePdf}, Conditional=({effPdf}, {cut}))
47data = model.generate({x, cut}, 10000)
53effPdf.fitTo(data, ConditionalObservables={x})
59frame1 = x.frame(Bins=20, Title=
"Data (all, accepted)")
61data.plotOn(frame1, Cut=
"cut==cut::accept", MarkerColor=
"r", LineColor=
"r")
64frame2 = x.frame(Bins=20, Title=
"Fitted efficiency")
65data.plotOn(frame2, Efficiency=cut)
66effFunc.plotOn(frame2, LineColor=
"r")
69ca = ROOT.TCanvas(
"rf701_efficiency",
"rf701_efficiency", 800, 400)
72ROOT.gPad.SetLeftMargin(0.15)
73frame1.GetYaxis().SetTitleOffset(1.6)
76ROOT.gPad.SetLeftMargin(0.15)
77frame2.GetYaxis().SetTitleOffset(1.4)
80ca.SaveAs(
"rf701_efficiencyfit.png")