20x = ROOT.RooRealVar(
"x",
"x", -8, 8)
23mean = ROOT.RooRealVar(
"mean",
"mean", 0, -8, 8)
24sigma = ROOT.RooRealVar(
"sigma",
"sigma", 0.3, 0.1, 10)
25gx = ROOT.RooGaussian(
"gx",
"gx", x, mean, sigma)
28a0 = ROOT.RooRealVar(
"a0",
"a0", -0.1, -1, 1)
29a1 = ROOT.RooRealVar(
"a1",
"a1", 0.004, -1, 1)
30px = ROOT.RooChebychev(
"px",
"px", x, [a0, a1])
33f = ROOT.RooRealVar(
"f",
"f", 0.2, 0.0, 1.0)
34model = ROOT.RooAddPdf(
"model",
"model", [gx, px], [f])
41mean_ctl = ROOT.RooRealVar(
"mean_ctl",
"mean_ctl", -3, -8, 8)
42gx_ctl = ROOT.RooGaussian(
"gx_ctl",
"gx_ctl", x, mean_ctl, sigma)
45a0_ctl = ROOT.RooRealVar(
"a0_ctl",
"a0_ctl", -0.1, -1, 1)
46a1_ctl = ROOT.RooRealVar(
"a1_ctl",
"a1_ctl", 0.5, -0.1, 1)
47px_ctl = ROOT.RooChebychev(
"px_ctl",
"px_ctl", x, [a0_ctl, a1_ctl])
50f_ctl = ROOT.RooRealVar(
"f_ctl",
"f_ctl", 0.5, 0.0, 1.0)
51model_ctl = ROOT.RooAddPdf(
"model_ctl",
"model_ctl", [gx_ctl, px_ctl], [f_ctl])
57data = model.generate({x}, 1000)
58data_ctl = model_ctl.generate({x}, 2000)
64sample = ROOT.RooCategory(
"sample",
"sample")
65sample.defineType(
"physics")
66sample.defineType(
"control")
69combData = ROOT.RooDataSet(
74 Import={
"physics": data,
"control": data_ctl},
82simPdf = ROOT.RooSimultaneous(
"simPdf",
"simultaneous pdf", {
"physics": model,
"control": model_ctl}, sample)
88fitResult = simPdf.fitTo(combData, PrintLevel=-1, Save=
True)
95frame1 = x.frame(Title=
"Physics sample")
98slicedData1 = combData.reduce(Cut=
"sample==sample::physics")
99slicedData1.plotOn(frame1)
102simPdf.getPdf(
"physics").plotOn(frame1)
103simPdf.getPdf(
"physics").plotOn(frame1, Components=
"px", LineStyle=
"--")
115frame2 = x.frame(Title=
"Control sample")
116slicedData2 = combData.reduce(Cut=
"sample==sample::control")
117slicedData2.plotOn(frame2)
118simPdf.plotOn(frame2, ProjWData=(sample, slicedData2))
119simPdf.plotOn(frame2, Components=
"px_ctl", ProjWData=(sample, slicedData2), LineStyle=
"--")
123frame3 = x.frame(Title=
"Both samples")
124combData.plotOn(frame3)
125simPdf.plotOn(frame3, ProjWData=(sample, combData))
126simPdf.plotOn(frame3, Components=
"px,px_ctl", ProjWData=(sample, combData), LineStyle=
"--")
128c = ROOT.TCanvas(
"rf501_simultaneouspdf",
"rf501_simultaneouspdf", 1200, 400)
134 ROOT.gPad.SetLeftMargin(0.15)
135 frame.GetYaxis().SetTitleOffset(1.4)
143c.SaveAs(
"rf501_simultaneouspdf.png")