20x = ROOT.RooRealVar(
"x",
"x", -10, 10)
23a = ROOT.RooRealVar(
"a",
"a", 0.4, 0, 1)
24b = ROOT.RooRealVar(
"b",
"b", 5)
25c = ROOT.RooRealVar(
"c",
"c", -1, -10, 10)
26effFunc = ROOT.RooFormulaVar(
27 "effFunc",
"(1-a)+a*cos((x-c)/b)", ROOT.RooArgList(a, b, c, x))
33cut = ROOT.RooCategory(
"cut",
"cutr")
34cut.defineType(
"accept", 1)
35cut.defineType(
"reject", 0)
38effPdf = ROOT.RooEfficiency(
"effPdf",
"effPdf", effFunc, cut,
"accept")
45shapePdf = ROOT.RooPolynomial(
46 "shapePdf",
"shapePdf", x, ROOT.RooArgList(ROOT.RooFit.RooConst(-0.095)))
47model = ROOT.RooProdPdf(
50 ROOT.RooArgSet(shapePdf),
51 ROOT.RooFit.Conditional(
52 ROOT.RooArgSet(effPdf),
56data = model.generate(ROOT.RooArgSet(x, cut), 10000)
62effPdf.fitTo(data, ROOT.RooFit.ConditionalObservables(ROOT.RooArgSet(x)))
68frame1 = x.frame(ROOT.RooFit.Bins(
69 20), ROOT.RooFit.Title(
"Data (all, accepted)"))
73 ROOT.RooFit.Cut(
"cut==cut::accept"),
74 ROOT.RooFit.MarkerColor(
76 ROOT.RooFit.LineColor(
80frame2 = x.frame(ROOT.RooFit.Bins(
81 20), ROOT.RooFit.Title(
"Fitted efficiency"))
82data.plotOn(frame2, ROOT.RooFit.Efficiency(cut))
83effFunc.plotOn(frame2, ROOT.RooFit.LineColor(ROOT.kRed))
86ca = ROOT.TCanvas(
"rf701_efficiency",
"rf701_efficiency", 800, 400)
89ROOT.gPad.SetLeftMargin(0.15)
90frame1.GetYaxis().SetTitleOffset(1.6)
93ROOT.gPad.SetLeftMargin(0.15)
94frame2.GetYaxis().SetTitleOffset(1.4)
97ca.SaveAs(
"rf701_efficiencyfit.png")