21x = ROOT.RooRealVar(
"x",
"x", -8, 8)
24mean = ROOT.RooRealVar(
"mean",
"mean", 0, -8, 8)
25sigma = ROOT.RooRealVar(
"sigma",
"sigma", 0.3, 0.1, 10)
26gx = ROOT.RooGaussian(
"gx",
"gx", x, mean, sigma)
29a0 = ROOT.RooRealVar(
"a0",
"a0", -0.1, -1, 1)
30a1 = ROOT.RooRealVar(
"a1",
"a1", 0.004, -1, 1)
31px = ROOT.RooChebychev(
"px",
"px", x, [a0, a1])
34f = ROOT.RooRealVar(
"f",
"f", 0.2, 0.0, 1.0)
35model = ROOT.RooAddPdf(
"model",
"model", [gx, px], [f])
42mean_ctl = ROOT.RooRealVar(
"mean_ctl",
"mean_ctl", -3, -8, 8)
43gx_ctl = ROOT.RooGaussian(
"gx_ctl",
"gx_ctl", x, mean_ctl, sigma)
46a0_ctl = ROOT.RooRealVar(
"a0_ctl",
"a0_ctl", -0.1, -1, 1)
47a1_ctl = ROOT.RooRealVar(
"a1_ctl",
"a1_ctl", 0.5, -0.1, 1)
48px_ctl = ROOT.RooChebychev(
"px_ctl",
"px_ctl", x, [a0_ctl, a1_ctl])
51f_ctl = ROOT.RooRealVar(
"f_ctl",
"f_ctl", 0.5, 0.0, 1.0)
52model_ctl = ROOT.RooAddPdf(
"model_ctl",
"model_ctl", [gx_ctl, px_ctl], [f_ctl])
58data = model.generate({x}, 1000)
59data_ctl = model_ctl.generate({x}, 2000)
65sample = ROOT.RooCategory(
"sample",
"sample")
66sample.defineType(
"physics")
67sample.defineType(
"control")
70combData = ROOT.RooDataSet(
75 Import={
"physics": data,
"control": data_ctl},
83simPdf = ROOT.RooSimultaneous(
"simPdf",
"simultaneous pdf", {
"physics": model,
"control": model_ctl}, sample)
89fitResult = simPdf.fitTo(combData, PrintLevel=-1, Save=
True)
96frame1 = x.frame(Title=
"Physics sample")
99combData.plotOn(frame1, Cut=
"sample==sample::physics")
107simPdf.plotOn(frame1, Slice=(sample,
"physics"), ProjWData=(sample, combData))
108simPdf.plotOn(frame1, Slice=(sample,
"physics"), Components=
"px", ProjWData=(sample, combData), LineStyle=
"--")
116frame2 = x.frame(Title=
"Control sample")
117slicedData = combData.reduce(Cut=
"sample==sample::control")
118slicedData.plotOn(frame2)
119simPdf.plotOn(frame2, ProjWData=(sample, slicedData))
120simPdf.plotOn(frame2, Components=
"px_ctl", ProjWData=(sample, slicedData), LineStyle=
"--")
124frame3 = x.frame(Title=
"Both samples")
125combData.plotOn(frame3)
126simPdf.plotOn(frame3, ProjWData=(sample, combData))
127simPdf.plotOn(frame3, Components=
"px,px_ctl", ProjWData=(sample, combData), LineStyle=
"--")
129c = ROOT.TCanvas(
"rf501_simultaneouspdf",
"rf501_simultaneouspdf", 1200, 400)
135 ROOT.gPad.SetLeftMargin(0.15)
136 frame.GetYaxis().SetTitleOffset(1.4)
144c.SaveAs(
"rf501_simultaneouspdf.png")