import ROOT
x = ROOT.RooRealVar("x", "x", -5, 5)
y = ROOT.RooRealVar("y", "y", -5, 5)
meanx = ROOT.RooRealVar("mean1", "mean of gaussian x", 2)
meany = ROOT.RooRealVar("mean2", "mean of gaussian y", -2)
sigmax = ROOT.RooRealVar("sigmax", "width of gaussian x", 1)
sigmay = ROOT.RooRealVar("sigmay", "width of gaussian y", 5)
gaussx = ROOT.RooGaussian("gaussx", "gaussian PDF", x, meanx, sigmax)
gaussy = ROOT.RooGaussian("gaussy", "gaussian PDF", y, meany, sigmay)
gaussxy = ROOT.RooProdPdf(
"gaussxy", "gaussx*gaussy", ROOT.RooArgList(gaussx, gaussy))
data = gaussxy.generate(ROOT.RooArgSet(x, y), 10000)
xframe = x.frame(ROOT.RooFit.Title("X projection of gauss(x)*gauss(y)"))
data.plotOn(xframe)
gaussxy.plotOn(xframe)
yframe = y.frame(ROOT.RooFit.Title("Y projection of gauss(x)*gauss(y)"))
data.plotOn(yframe)
gaussxy.plotOn(yframe)
c = ROOT.TCanvas("rf304_uncorrprod", "rf304_uncorrprod", 800, 400)
c.Divide(2)
c.cd(1)
ROOT.gPad.SetLeftMargin(0.15)
xframe.GetYaxis().SetTitleOffset(1.4)
xframe.Draw()
c.cd(2)
ROOT.gPad.SetLeftMargin(0.15)
yframe.GetYaxis().SetTitleOffset(1.4)
yframe.Draw()
c.SaveAs("rf304_uncorrprod.png")