19x = ROOT.RooRealVar(
"x",
"x", -5, 5)
20y = ROOT.RooRealVar(
"y",
"y", -5, 5)
21z = ROOT.RooRealVar(
"z",
"z", -5, 5)
24gx = ROOT.RooGaussian(
"gx",
"gx", x, 0.0, 1.0)
25gy = ROOT.RooGaussian(
"gy",
"gy", y, 0.0, 1.0)
26gz = ROOT.RooGaussian(
"gz",
"gz", z, 0.0, 1.0)
27sig = ROOT.RooProdPdf(
"sig",
"sig", [gx, gy, gz])
30px = ROOT.RooPolynomial(
"px",
"px", x, [-0.1, 0.004])
31py = ROOT.RooPolynomial(
"py",
"py", y, [0.1, -0.004])
32pz = ROOT.RooPolynomial(
"pz",
"pz", z)
33bkg = ROOT.RooProdPdf(
"bkg",
"bkg", [px, py, pz])
36fsig = ROOT.RooRealVar(
"fsig",
"signal fraction", 0.1, 0.0, 1.0)
37model = ROOT.RooAddPdf(
"model",
"model", [sig, bkg], [fsig])
39data = model.generate({x, y, z}, 20000)
45frame = x.frame(Title=
"Projection of 3D data and pdf on X", Bins=40)
53y.setRange(
"sigRegion", -1, 1)
54z.setRange(
"sigRegion", -1, 1)
57frame2 = x.frame(Title=
"Same projection on X in signal range of (Y,Z)", Bins=40)
63data.plotOn(frame2, CutRange=
"sigRegion")
66model.plotOn(frame2, ProjectionRange=
"sigRegion")
68c = ROOT.TCanvas(
"rf311_rangeplot",
"rf310_rangeplot", 800, 400)
71ROOT.gPad.SetLeftMargin(0.15)
72frame.GetYaxis().SetTitleOffset(1.4)
75ROOT.gPad.SetLeftMargin(0.15)
76frame2.GetYaxis().SetTitleOffset(1.4)
79c.SaveAs(
"rf311_rangeplot.png")