51ROOT.gROOT.SetBatch(
True)
57x = ROOT.RooRealVar(
"x",
"x", 10, 100)
58alpha = ROOT.RooRealVar(
"alpha",
"alpha", -0.04, -0.1, -0.0)
59model = ROOT.RooExponential(
"model",
"Exponential model", x, alpha)
62x.setRange(
"LEFT", 10, 20)
63x.setRange(
"RIGHT", 60, 100)
65x.setRange(
"FULL", 10, 100)
67data = model.generate(x, 10000)
83N = ROOT.RooRealVar(
"N",
"Extended term", 0, 20000)
84extmodel = ROOT.RooExtendPdf(
"extmodel",
"Extended model", model, N,
"FULL")
91extmodel.fitTo(data, Range=
"LEFT", PrintLevel=-1)
107c = ROOT.TCanvas(
"c",
"c", 2100, 700)
111r = model.fitTo(data, Range=
"LEFT,RIGHT", PrintLevel=-1, Save=
True)
116model.plotOn(frame, VisualizeError=r)
118model.paramOn(frame, Label=
"Non-extended fit")
123r2 = extmodel.fitTo(data, Range=
"LEFT,RIGHT", PrintLevel=-1, Save=
True)
127extmodel.plotOn(frame2)
128extmodel.plotOn(frame2, VisualizeError=r2)
129extmodel.paramOn(frame2, Label=
"Extended fit", Layout=(0.4, 0.95))
143Nsig = ROOT.RooRealVar(
"Nsig",
"Number of signal events", 1000, 0, 2000)
144Nbkg = ROOT.RooRealVar(
"Nbkg",
"Number of background events", 10000, 0, 20000)
146mean = ROOT.RooRealVar(
"mean",
"Mean of signal model", 40.0)
147width = ROOT.RooRealVar(
"width",
"Width of signal model", 5.0)
148sig = ROOT.RooGaussian(
"sig",
"Signal model", x, mean, width)
150modelsum = ROOT.RooAddPdf(
"modelsum",
"NSig*signal + NBkg*background", [sig, model], [Nsig, Nbkg])
161r3 = modelsum.fitTo(data, Range=
"LEFT,RIGHT", PrintLevel=-1, Save=
True)
166modelsum.plotOn(frame3)
167modelsum.plotOn(frame3, VisualizeError=r3)
168modelsum.paramOn(frame3, Label=
"S+B fit with RooAddPdf", Layout=(0.3, 0.95))
173c.SaveAs(
"rf204b_extendedLikelihood_rangedFit.png")