19x = ROOT.RooRealVar(
"x",
"x", -8, 8)
22mean = ROOT.RooRealVar(
"mean",
"mean", 0, -8, 8)
23sigma = ROOT.RooRealVar(
"sigma",
"sigma", 0.3, 0.1, 10)
24gx = ROOT.RooGaussian(
"gx",
"gx", x, mean, sigma)
27a0 = ROOT.RooRealVar(
"a0",
"a0", -0.1, -1, 1)
28a1 = ROOT.RooRealVar(
"a1",
"a1", 0.004, -1, 1)
29px = ROOT.RooChebychev(
"px",
"px", x, ROOT.RooArgList(a0, a1))
32f = ROOT.RooRealVar(
"f",
"f", 0.2, 0., 1.)
33model = ROOT.RooAddPdf(
34 "model",
"model", ROOT.RooArgList(gx, px), ROOT.RooArgList(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(
48 "px_ctl",
"px_ctl", x, ROOT.RooArgList(a0_ctl, a1_ctl))
51f_ctl = ROOT.RooRealVar(
"f_ctl",
"f_ctl", 0.5, 0., 1.)
52model_ctl = ROOT.RooAddPdf(
58 ROOT.RooArgList(f_ctl))
64data = model.generate(ROOT.RooArgSet(x), 100)
65data_ctl = model_ctl.generate(ROOT.RooArgSet(x), 2000)
71sample = ROOT.RooCategory(
"sample",
"sample")
72sample.defineType(
"physics")
73sample.defineType(
"control")
76combData = ROOT.RooDataSet(
80 ROOT.RooFit.Index(sample),
92simPdf = ROOT.RooSimultaneous(
"simPdf",
"simultaneous pdf", sample)
96simPdf.addPdf(model,
"physics")
97simPdf.addPdf(model_ctl,
"control")
103simPdf.fitTo(combData)
109frame1 = x.frame(ROOT.RooFit.Bins(30), ROOT.RooFit.Title(
"Physics sample"))
112combData.plotOn(frame1, ROOT.RooFit.Cut(
"sample==sample::physics"))
120sampleSet = ROOT.RooArgSet(sample)
121simPdf.plotOn(frame1, ROOT.RooFit.Slice(sample,
"physics"), ROOT.RooFit.Components(
122 "px"), ROOT.RooFit.ProjWData(sampleSet, combData), ROOT.RooFit.LineStyle(ROOT.kDashed))
125frame2 = x.frame(ROOT.RooFit.Bins(30), ROOT.RooFit.Title(
"Control sample"))
126combData.plotOn(frame2, ROOT.RooFit.Cut(
"sample==sample::control"))
127simPdf.plotOn(frame2, ROOT.RooFit.Slice(sample,
"control"),
128 ROOT.RooFit.ProjWData(sampleSet, combData))
129simPdf.plotOn(frame2, ROOT.RooFit.Slice(sample,
"control"), ROOT.RooFit.Components(
130 "px_ctl"), ROOT.RooFit.ProjWData(sampleSet, combData), ROOT.RooFit.LineStyle(ROOT.kDashed))
132c = ROOT.TCanvas(
"rf501_simultaneouspdf",
133 "rf501_simultaneouspdf", 800, 400)
136ROOT.gPad.SetLeftMargin(0.15)
137frame1.GetYaxis().SetTitleOffset(1.4)
140ROOT.gPad.SetLeftMargin(0.15)
141frame2.GetYaxis().SetTitleOffset(1.4)
144c.SaveAs(
"rf501_simultaneouspdf.png")