from __future__ import print_function
import ROOT
x = ROOT.RooRealVar("x", "x", -10, 10)
y = ROOT.RooRealVar("y", "y", -10, 10)
gx = ROOT.RooGaussian(
"gx", "gx", x, ROOT.RooFit.RooConst(-2), ROOT.RooFit.RooConst(3))
gy = ROOT.RooGaussian(
"gy", "gy", y, ROOT.RooFit.RooConst(+2), ROOT.RooFit.RooConst(2))
gxy = ROOT.RooProdPdf("gxy", "gxy", ROOT.RooArgList(gx, gy))
print("gxy = ", gxy.getVal())
nset_xy = ROOT.RooArgSet(x, y)
print("gx_Norm[x,y] = ", gxy.getVal(nset_xy))
x_and_y = ROOT.RooArgSet(x, y)
igxy = gxy.createIntegral(x_and_y)
print("gx_Int[x,y] = ", igxy.getVal())
nset_x = ROOT.RooArgSet(x)
print("gx_Norm[x] = ", gxy.getVal(nset_x))
nset_y = ROOT.RooArgSet(y)
print("gx_Norm[y] = ", gxy.getVal(nset_y))
x.setRange("signal", -5, 5)
y.setRange("signal", -3, 3)
igxy_sig = gxy.createIntegral(x_and_y, ROOT.RooFit.NormSet(
x_and_y), ROOT.RooFit.Range("signal"))
print("gx_Int[x,y|signal]_Norm[x,y] = ", igxy_sig.getVal())
gxy_cdf = gxy.createCdf(ROOT.RooArgSet(x, y))
hh_cdf = gxy_cdf.createHistogram("hh_cdf", x, ROOT.RooFit.Binning(
40), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(40)))
hh_cdf.SetLineColor(ROOT.kBlue)
c = ROOT.TCanvas("rf308_normintegration2d",
"rf308_normintegration2d", 600, 600)
ROOT.gPad.SetLeftMargin(0.15)
hh_cdf.GetZaxis().SetTitleOffset(1.8)
hh_cdf.Draw("surf")
c.SaveAs("rf308_normintegration2d.png")