22x = ROOT.RooRealVar(
"x",
"x", -10, 10)
25a = ROOT.RooRealVar(
"a",
"a", 0.4, 0, 1)
26b = ROOT.RooRealVar(
"b",
"b", 5)
27c = ROOT.RooRealVar(
"c",
"c", -1, -10, 10)
28effFunc = ROOT.RooFormulaVar(
29 "effFunc",
"(1-a)+a*cos((x-c)/b)", ROOT.RooArgList(a, b, c, x))
35cut = ROOT.RooCategory(
"cut",
"cutr")
36cut.defineType(
"accept", 1)
37cut.defineType(
"reject", 0)
40effPdf = ROOT.RooEfficiency(
"effPdf",
"effPdf", effFunc, cut,
"accept")
47shapePdf = ROOT.RooPolynomial(
48 "shapePdf",
"shapePdf", x, ROOT.RooArgList(ROOT.RooFit.RooConst(-0.095)))
49model = ROOT.RooProdPdf(
52 ROOT.RooArgSet(shapePdf),
53 ROOT.RooFit.Conditional(
54 ROOT.RooArgSet(effPdf),
58data = model.generate(ROOT.RooArgSet(x, cut), 10000)
64effPdf.fitTo(data, ROOT.RooFit.ConditionalObservables(ROOT.RooArgSet(x)))
70frame1 = x.frame(ROOT.RooFit.Bins(
71 20), ROOT.RooFit.Title(
"Data (all, accepted)"))
75 ROOT.RooFit.Cut(
"cut==cut::accept"),
76 ROOT.RooFit.MarkerColor(
78 ROOT.RooFit.LineColor(
82frame2 = x.frame(ROOT.RooFit.Bins(
83 20), ROOT.RooFit.Title(
"Fitted efficiency"))
84data.plotOn(frame2, ROOT.RooFit.Efficiency(cut))
85effFunc.plotOn(frame2, ROOT.RooFit.LineColor(ROOT.kRed))
88ca = ROOT.TCanvas(
"rf701_efficiency",
"rf701_efficiency", 800, 400)
91ROOT.gPad.SetLeftMargin(0.15)
92frame1.GetYaxis().SetTitleOffset(1.6)
95ROOT.gPad.SetLeftMargin(0.15)
96frame2.GetYaxis().SetTitleOffset(1.4)
99ca.SaveAs(
"rf701_efficiencyfit.png")