25 using namespace RooFit;
27 void rf702_efficiencyfit_2D(Bool_t flat = kFALSE)
33 RooRealVar x(
"x",
"x", -10, 10);
34 RooRealVar y(
"y",
"y", -10, 10);
37 RooRealVar ax(
"ax",
"ay", 0.6, 0, 1);
38 RooRealVar bx(
"bx",
"by", 5);
39 RooRealVar cx(
"cx",
"cy", -1, -10, 10);
41 RooRealVar ay(
"ay",
"ay", 0.2, 0, 1);
42 RooRealVar by(
"by",
"by", 5);
43 RooRealVar cy(
"cy",
"cy", -1, -10, 10);
45 RooFormulaVar effFunc(
"effFunc",
"((1-ax)+ax*cos((x-cx)/bx))*((1-ay)+ay*cos((y-cy)/by))",
46 RooArgList(ax, bx, cx, x, ay, by, cy, y));
49 RooCategory cut(
"cut",
"cutr");
50 cut.defineType(
"accept", 1);
51 cut.defineType(
"reject", 0);
57 RooEfficiency effPdf(
"effPdf",
"effPdf", effFunc, cut,
"accept");
64 RooPolynomial shapePdfX(
"shapePdfX",
"shapePdfX", x, RooConst(flat ? 0 : -0.095));
65 RooPolynomial shapePdfY(
"shapePdfY",
"shapePdfY", y, RooConst(flat ? 0 : +0.095));
66 RooProdPdf shapePdf(
"shapePdf",
"shapePdf", RooArgSet(shapePdfX, shapePdfY));
67 RooProdPdf model(
"model",
"model", shapePdf, Conditional(effPdf, cut));
70 RooDataSet *data = model.generate(RooArgSet(x, y, cut), 10000);
76 effPdf.fitTo(*data, ConditionalObservables(RooArgSet(x, y)));
82 TH1 *hh_data_all = data->createHistogram(
"hh_data_all", x, Binning(8), YVar(y, Binning(8)));
83 TH1 *hh_data_sel = data->createHistogram(
"hh_data_sel", x, Binning(8), YVar(y, Binning(8)), Cut(
"cut==cut::accept"));
84 TH1 *hh_eff = effFunc.createHistogram(
"hh_eff", x, Binning(50), YVar(y, Binning(50)));
87 hh_data_all->SetMinimum(0);
88 hh_data_sel->SetMinimum(0);
89 hh_eff->SetMinimum(0);
90 hh_eff->SetLineColor(kBlue);
93 TCanvas *ca =
new TCanvas(
"rf702_efficiency_2D",
"rf702_efficiency_2D", 1200, 400);
96 gPad->SetLeftMargin(0.15);
97 hh_data_all->GetZaxis()->SetTitleOffset(1.8);
98 hh_data_all->Draw(
"lego");
100 gPad->SetLeftMargin(0.15);
101 hh_data_sel->GetZaxis()->SetTitleOffset(1.8);
102 hh_data_sel->Draw(
"lego");
104 gPad->SetLeftMargin(0.15);
105 hh_eff->GetZaxis()->SetTitleOffset(1.8);
106 hh_eff->Draw(
"surf");