26 using namespace RooFit;
28 void rf701_efficiencyfit()
34 RooRealVar x(
"x",
"x", -10, 10);
37 RooRealVar a(
"a",
"a", 0.4, 0, 1);
38 RooRealVar b(
"b",
"b", 5);
39 RooRealVar c(
"c",
"c", -1, -10, 10);
40 RooFormulaVar effFunc(
"effFunc",
"(1-a)+a*cos((x-c)/b)", RooArgList(a, b, c, x));
46 RooCategory cut(
"cut",
"cutr");
47 cut.defineType(
"accept", 1);
48 cut.defineType(
"reject", 0);
51 RooEfficiency effPdf(
"effPdf",
"effPdf", effFunc, cut,
"accept");
58 RooPolynomial shapePdf(
"shapePdf",
"shapePdf", x, RooConst(-0.095));
59 RooProdPdf model(
"model",
"model", shapePdf, Conditional(effPdf, cut));
62 RooDataSet *data = model.generate(RooArgSet(x, cut), 10000);
68 effPdf.fitTo(*data, ConditionalObservables(x));
74 RooPlot *frame1 = x.frame(Bins(20), Title(
"Data (all, accepted)"));
76 data->plotOn(frame1, Cut(
"cut==cut::accept"), MarkerColor(kRed), LineColor(kRed));
79 RooPlot *frame2 = x.frame(Bins(20), Title(
"Fitted efficiency"));
80 data->plotOn(frame2, Efficiency(cut));
81 effFunc.plotOn(frame2, LineColor(kRed));
84 TCanvas *ca =
new TCanvas(
"rf701_efficiency",
"rf701_efficiency", 800, 400);
87 gPad->SetLeftMargin(0.15);
88 frame1->GetYaxis()->SetTitleOffset(1.6);
91 gPad->SetLeftMargin(0.15);
92 frame2->GetYaxis()->SetTitleOffset(1.4);