26x = ROOT.RooRealVar(
"x",
"x", -10, 10)
29a = ROOT.RooRealVar(
"a",
"a", 0.4, 0, 1)
30b = ROOT.RooRealVar(
"b",
"b", 5)
31c = ROOT.RooRealVar(
"c",
"c", -1, -10, 10)
32effFunc = ROOT.RooFormulaVar(
33 "effFunc",
"(1-a)+a*cos((x-c)/b)", ROOT.RooArgList(a, b, c, x))
39cut = ROOT.RooCategory(
"cut",
"cutr")
40cut.defineType(
"accept", 1)
41cut.defineType(
"reject", 0)
44effPdf = ROOT.RooEfficiency(
"effPdf",
"effPdf", effFunc, cut,
"accept")
51shapePdf = ROOT.RooPolynomial(
"shapePdf",
"shapePdf", x, ROOT.RooArgList(ROOT.RooFit.RooConst(-0.095)))
52model = ROOT.RooProdPdf(
"model",
"model", ROOT.RooArgSet(shapePdf), ROOT.RooFit.Conditional(ROOT.RooArgSet(effPdf), ROOT.RooArgSet(cut)))
55data = model.generate(ROOT.RooArgSet(x, cut), 10000)
61effPdf.fitTo(data, ROOT.RooFit.ConditionalObservables(ROOT.RooArgSet(x)))
67frame1 = x.frame(ROOT.RooFit.Bins(
68 20), ROOT.RooFit.Title(
"Data (all, accepted)"))
70data.plotOn(frame1, ROOT.RooFit.Cut(
"cut==cut::accept"), ROOT.RooFit.MarkerColor(
71 ROOT.kRed), ROOT.RooFit.LineColor(ROOT.kRed))
74frame2 = x.frame(ROOT.RooFit.Bins(
75 20), ROOT.RooFit.Title(
"Fitted efficiency"))
76data.plotOn(frame2, ROOT.RooFit.Efficiency(cut))
77effFunc.plotOn(frame2, ROOT.RooFit.LineColor(ROOT.kRed))
80ca = ROOT.TCanvas(
"rf701_efficiency",
"rf701_efficiency", 800, 400)
83ROOT.gPad.SetLeftMargin(0.15)
84frame1.GetYaxis().SetTitleOffset(1.6)
87ROOT.gPad.SetLeftMargin(0.15)
88frame2.GetYaxis().SetTitleOffset(1.4)
91ca.SaveAs(
"rf701_efficiencyfit.png")