%%cpp -d #include "RooRealVar.h" #include "RooGaussian.h" #include "RooProdPdf.h" #include "RooAbsReal.h" #include "RooPlot.h" #include "TCanvas.h" #include "TAxis.h" #include "TH1.h" using namespace RooFit; RooRealVar x("x", "x", -10, 10); RooRealVar y("y", "y", -10, 10); RooGaussian gx("gx", "gx", x, -2.0, 3.0); RooGaussian gy("gy", "gy", y, +2.0, 2.0); RooProdPdf gxy("gxy", "gxy", RooArgSet(gx, gy)); cout << "gxy = " << gxy.getVal() << endl; RooArgSet nset_xy(x, y); cout << "gx_Norm[x,y] = " << gxy.getVal(&nset_xy) << endl; std::unique_ptr igxy{gxy.createIntegral(RooArgSet(x, y))}; cout << "gx_Int[x,y] = " << igxy->getVal() << endl; RooArgSet nset_x(x); cout << "gx_Norm[x] = " << gxy.getVal(&nset_x) << endl; RooArgSet nset_y(y); cout << "gx_Norm[y] = " << gxy.getVal(&nset_y) << endl; x.setRange("signal", -5, 5); y.setRange("signal", -3, 3); std::unique_ptr igxy_sig{gxy.createIntegral({x, y}, NormSet(RooArgSet(x, y)), Range("signal"))}; cout << "gx_Int[x,y|signal]_Norm[x,y] = " << igxy_sig->getVal() << endl; std::unique_ptr gxy_cdf{gxy.createCdf(RooArgSet(x, y))}; TH1 *hh_cdf = gxy_cdf->createHistogram("hh_cdf", x, Binning(40), YVar(y, Binning(40))); hh_cdf->SetLineColor(kBlue); new TCanvas("rf308_normintegration2d", "rf308_normintegration2d", 600, 600); gPad->SetLeftMargin(0.15); hh_cdf->GetZaxis()->SetTitleOffset(1.8); hh_cdf->Draw("surf"); gROOT->GetListOfCanvases()->Draw()