23x = ROOT.RooRealVar(
"x", 
"x", -10, 10)
 
   26a = ROOT.RooRealVar(
"a", 
"a", 0.4, 0, 1)
 
   27b = ROOT.RooRealVar(
"b", 
"b", 5)
 
   28c = ROOT.RooRealVar(
"c", 
"c", -1, -10, 10)
 
   29effFunc = ROOT.RooFormulaVar(
"effFunc", 
"(1-a)+a*cos((x-c)/b)", [a, b, c, x])
 
   35cut = ROOT.RooCategory(
"cut", 
"cutr", {
"accept": 1, 
"reject": 0})
 
   38effPdf = ROOT.RooEfficiency(
"effPdf", 
"effPdf", effFunc, cut, 
"accept")
 
   45shapePdf = ROOT.RooPolynomial(
"shapePdf", 
"shapePdf", x, [-0.095])
 
   46model = ROOT.RooProdPdf(
"model", 
"model", {shapePdf}, Conditional=({effPdf}, {cut}))
 
   49data = model.generate({x, cut}, 10000)
 
   55effPdf.fitTo(data, ConditionalObservables={x}, PrintLevel=-1)
 
   61frame1 = x.frame(Bins=20, Title=
"Data (all, accepted)")
 
   63data.plotOn(frame1, Cut=
"cut==cut::accept", MarkerColor=
"r", LineColor=
"r")
 
   66frame2 = x.frame(Bins=20, Title=
"Fitted efficiency")
 
   67data.plotOn(frame2, Efficiency=cut)  
 
   68effFunc.plotOn(frame2, LineColor=
"r")
 
   71ca = ROOT.TCanvas(
"rf701_efficiency", 
"rf701_efficiency", 800, 400)
 
   74ROOT.gPad.SetLeftMargin(0.15)
 
   75frame1.GetYaxis().SetTitleOffset(1.6)
 
   78ROOT.gPad.SetLeftMargin(0.15)
 
   79frame2.GetYaxis().SetTitleOffset(1.4)
 
   82ca.SaveAs(
"rf701_efficiencyfit.png")