18x = ROOT.RooRealVar(
"x",
"x", 0, 11)
21mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5)
22sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5)
23sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1)
25sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
26sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
29a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0.0, 1.0)
30a1 = ROOT.RooRealVar(
"a1",
"a1", 0.2, 0.0, 1.0)
31bkg = ROOT.RooChebychev(
"bkg",
"Background", x, [a0, a1])
34sig1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in signal", 0.8, 0.0, 1.0)
35sig = ROOT.RooAddPdf(
"sig",
"Signal", [sig1, sig2], sig1frac)
42x.setRange(
"signalRange", 4, 6)
45nsig = ROOT.RooRealVar(
"nsig",
"number of signal events in signalRange", 500, 0.0, 10000)
46nbkg = ROOT.RooRealVar(
"nbkg",
"number of background events in signalRange", 500, 0, 10000)
49model = ROOT.RooAddPdf(
"model",
"(g1+g2)+a", [bkg, sig], [nbkg, nsig])
55data = model.generate(x, 1000)
57canv = ROOT.TCanvas(
"Canvas",
"Canvas", 1500, 600)
71model1 = ROOT.RooAddPdf(model)
72r = model1.fitTo(data, Save=
True)
75frame = x.frame(Title=
"Full range fitted")
77model1.plotOn(frame, VisualizeError=r)
87x.setRange(
"left", 0.0, 4.0)
88x.setRange(
"right", 6.0, 10.0)
90model2 = ROOT.RooAddPdf(model)
91r2 = model2.fitTo(data, Range=
"left,right", Save=
True)
94frame2 = x.frame(Title=
"Fit in left/right sideband")
96model2.plotOn(frame2, VisualizeError=r2)
108x.setRange(
"leftToMiddle", 0.0, 5.0)
110model3 = ROOT.RooAddPdf(model)
111r3 = model3.fitTo(data, Range=
"leftToMiddle", Save=
True)
114frame3 = x.frame(Title=
"Fit from left to middle")
116model3.plotOn(frame3, VisualizeError=r3)
118model3.paramOn(frame3)
123canv.SaveAs(
"rf204a_extendedLikelihood.png")