import ROOT
x = ROOT.RooRealVar("x", "x", -10, 10)
y = ROOT.RooRealVar("y", "y", -10, 10)
gx = ROOT.RooGaussian("gx", "gx", x, -2.0, 3.0)
gy = ROOT.RooGaussian("gy", "gy", y, +2.0, 2.0)
gxy = ROOT.RooProdPdf("gxy", "gxy", [gx, gy])
print("gxy = ", gxy.getVal())
nset_xy = {x, y}
print("gx_Norm[x,y] = ", gxy.getVal(nset_xy))
x_and_y = {x, y}
igxy = gxy.createIntegral(x_and_y)
print("gx_Int[x,y] = ", igxy.getVal())
nset_x = {x}
print("gx_Norm[x] = ", gxy.getVal(nset_x))
nset_y = {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, NormSet=x_and_y, Range="signal")
print("gx_Int[x,y|signal]_Norm[x,y] = ", igxy_sig.getVal())
gxy_cdf = gxy.createCdf({x, y})
hh_cdf = gxy_cdf.createHistogram("hh_cdf", x, Binning=40, YVar=dict(var=y, 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")
[#0] FATAL:Eval -- calling RooAbsReal::getVal() with r-value references to the normalization set is not allowed, because it breaks RooFits caching logic and potentially introduces significant overhead. Please explicitly create the RooArgSet outside the call to getVal().
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'signal' created with bounds [-5,5]
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'signal' created with bounds [-3,3]
gxy = 0.4856717852477124
gx_Norm[x,y] = 0.012933200957206766
gx_Int[x,y] = 37.552326516436096
gx_Norm[x] = 0.1068955044839622
gx_Norm[y] = 0.12098919425696865
gx_Int[x,y|signal]_Norm[x,y] = 0.5720351351990984