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(
28 "effFunc",
"(1-a)+a*cos((x-c)/b)", ROOT.RooArgList(a, b, c, x))
34cut = ROOT.RooCategory(
"cut",
"cutr")
35cut.defineType(
"accept", 1)
36cut.defineType(
"reject", 0)
39effPdf = ROOT.RooEfficiency(
"effPdf",
"effPdf", effFunc, cut,
"accept")
46shapePdf = ROOT.RooPolynomial(
47 "shapePdf",
"shapePdf", x, ROOT.RooArgList(ROOT.RooFit.RooConst(-0.095)))
48model = ROOT.RooProdPdf(
51 ROOT.RooArgSet(shapePdf),
52 ROOT.RooFit.Conditional(
53 ROOT.RooArgSet(effPdf),
57data = model.generate(ROOT.RooArgSet(x, cut), 10000)
63effPdf.fitTo(data, ROOT.RooFit.ConditionalObservables(ROOT.RooArgSet(x)))
69frame1 = x.frame(ROOT.RooFit.Bins(
70 20), ROOT.RooFit.Title(
"Data (all, accepted)"))
74 ROOT.RooFit.Cut(
"cut==cut::accept"),
75 ROOT.RooFit.MarkerColor(
77 ROOT.RooFit.LineColor(
81frame2 = x.frame(ROOT.RooFit.Bins(
82 20), ROOT.RooFit.Title(
"Fitted efficiency"))
83data.plotOn(frame2, ROOT.RooFit.Efficiency(cut))
84effFunc.plotOn(frame2, ROOT.RooFit.LineColor(ROOT.kRed))
87ca = ROOT.TCanvas(
"rf701_efficiency",
"rf701_efficiency", 800, 400)
90ROOT.gPad.SetLeftMargin(0.15)
91frame1.GetYaxis().SetTitleOffset(1.6)
94ROOT.gPad.SetLeftMargin(0.15)
95frame2.GetYaxis().SetTitleOffset(1.4)
98ca.SaveAs(
"rf701_efficiencyfit.png")