import ROOT
x = ROOT.RooRealVar("x", "x", -5, 5)
y = ROOT.RooRealVar("y", "y", -5, 5)
a0 = ROOT.RooRealVar("a0", "a0", -0.5, -5, 5)
a1 = ROOT.RooRealVar("a1", "a1", -0.5, -1, 1)
fy = ROOT.RooPolyVar("fy", "fy", y, ROOT.RooArgList(a0, a1))
sigmax = ROOT.RooRealVar("sigma", "width of gaussian", 0.5)
gaussx = ROOT.RooGaussian(
"gaussx", "Gaussian in x with shifting mean in y", x, fy, sigmax)
gaussy = ROOT.RooGaussian(
"gaussy",
"Gaussian in y",
y,
ROOT.RooFit.RooConst(0),
ROOT.RooFit.RooConst(3))
model = ROOT.RooProdPdf(
"model",
"gaussx(x|y)*gaussy(y)",
ROOT.RooArgSet(gaussy),
ROOT.RooFit.Conditional(
ROOT.RooArgSet(gaussx),
ROOT.RooArgSet(x)))
data = model.generate(ROOT.RooArgSet(x, y), 10000)
xframe = x.frame()
data.plotOn(xframe)
model.plotOn(xframe)
yframe = y.frame()
data.plotOn(yframe)
model.plotOn(yframe)
hh_model = model.createHistogram("hh_model", x, ROOT.RooFit.Binning(
50), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(50)))
hh_model.SetLineColor(ROOT.kBlue)
c = ROOT.TCanvas("rf305_condcorrprod", "rf05_condcorrprod", 1200, 400)
c.Divide(3)
c.cd(1)
ROOT.gPad.SetLeftMargin(0.15)
xframe.GetYaxis().SetTitleOffset(1.6)
xframe.Draw()
c.cd(2)
ROOT.gPad.SetLeftMargin(0.15)
yframe.GetYaxis().SetTitleOffset(1.6)
yframe.Draw()
c.cd(3)
ROOT.gPad.SetLeftMargin(0.20)
hh_model.GetZaxis().SetTitleOffset(2.5)
hh_model.Draw("surf")
c.SaveAs("rf305_condcorrprod.png")