44 invMass = ROOT.RooRealVar(
"invMass",
"M_inv", lowRange, highRange,
"GeV")
48 mH = ROOT.RooRealVar(
"mH",
"Higgs Mass", 130, 90, 160)
49 sigma1 = ROOT.RooRealVar(
"sigma1",
"Width of Gaussian", 12.0, 2, 100)
50 sigModel = ROOT.RooGaussian(
"sigModel",
"Signal Model", invMass, mH, sigma1)
58 mZ = ROOT.RooRealVar(
"mZ",
"Z Mass", 91.2, 0, 100)
59 sigma1_z = ROOT.RooRealVar(
"sigma1_z",
"Width of Gaussian", 10.0, 6, 100)
60 zjjModel = ROOT.RooGaussian(
"zjjModel",
"Z+jets Model", invMass, mZ, sigma1_z)
64 sigma1_z.setConstant()
68 a0 = ROOT.RooRealVar(
"a0",
"a0", 0.26, -1, 1)
69 a1 = ROOT.RooRealVar(
"a1",
"a1", -0.17596, -1, 1)
70 a2 = ROOT.RooRealVar(
"a2",
"a2", 0.018437, -1, 1)
71 a3 = ROOT.RooRealVar(
"a3",
"a3", 0.02, -1, 1)
72 qcdModel = ROOT.RooChebychev(
"qcdModel",
"A Polynomial for QCD", invMass, [a0, a1, a2])
83 fzjj = ROOT.RooRealVar(
"fzjj",
"fraction of zjj background events", 0.4, 0.0, 1)
86 fsigExpected = ROOT.RooRealVar(
"fsigExpected",
"expected fraction of signal events", 0.2, 0.0, 1)
87 fsigExpected.setConstant()
91 mu = ROOT.RooRealVar(
"mu",
"signal strength in units of SM expectation", 1, 0.0, 2)
95 ratioSigEff = ROOT.RooRealVar(
"ratioSigEff",
"ratio of signal efficiency to nominal signal efficiency", 1.0, 0.0, 2)
96 ratioSigEff.setConstant(
True)
99 fsig = ROOT.RooProduct(
"fsig",
"fraction of signal events", [mu, ratioSigEff, fsigExpected])
102 model = ROOT.RooAddPdf(
"model",
"sig+zjj+qcd background shapes", [sigModel, zjjModel, qcdModel], [fsig, fzjj])
117 model = wks.pdf(
"model")
118 invMass = wks.var(
"invMass")
120 data = model.generate(invMass, nEvents)
122 wks.Import(data, Rename=
"data")
126def DoHypothesisTest(wks):
129 model = ROOT.RooFit.ModelConfig()
130 model.SetWorkspace(wks)
131 model.SetPdf(
"model")
135 plc = ROOT.RooStats.ProfileLikelihoodCalculator()
136 plc.SetData((wks.data(
"data")))
143 poi = ROOT.RooArgSet(mu)
144 nullParams = poi.snapshot()
145 nullParams.setRealValue(
"mu", 0)
154 plc.SetNullParameters(nullParams)
157 htr = plc.GetHypoTest()
158 print(f
"-------------------------------------------------")
159 print(f
"The p-value for the null is ", htr.NullPValue())
160 print(f
"Corresponding to a significance of ", htr.Significance())
161 print(f
"-------------------------------------------------\n\n")
173 model = wks.pdf(
"model")
174 sigModel = wks.pdf(
"sigModel")
175 zjjModel = wks.pdf(
"zjjModel")
176 qcdModel = wks.pdf(
"qcdModel")
179 invMass = wks.var(
"invMass")
180 data = wks.data(
"data")
185 mu.setConstant(
False)
187 model.fitTo(data, Save=
True, Minos=
False, Hesse=
False, PrintLevel=-1)
191 frame = invMass.frame()
194 model.plotOn(frame, Components=sigModel, LineStyle=
"--", LineColor=
"r")
195 model.plotOn(frame, Components=zjjModel, LineStyle=
"--", LineColor=
"b")
196 model.plotOn(frame, Components=qcdModel, LineStyle=
"--", LineColor=
"g")
198 frame.SetTitle(
"An example fit to the signal + background model")
202 c1.SaveAs(
"rs102_hypotestwithshapes.1.png")
211 model.fitTo(data, Save=
True, Minos=
False, Hesse=
False, PrintLevel=-1)
215 xframe2 = invMass.frame()
216 data.plotOn(xframe2, DataError=
"SumW2")
217 model.plotOn(xframe2)
218 model.plotOn(xframe2, Components=zjjModel, LineStyle=
"--", LineColor=
"b")
219 model.plotOn(xframe2, Components=qcdModel, LineStyle=
"--", LineColor=
"g")
221 xframe2.SetTitle(
"An example fit to the background-only model")
225 c2.SaveAs(
"rs102_hypotestwithshapes.1.png")
235 wspace = ROOT.RooWorkspace(
"myWS")
247 DoHypothesisTest(wspace)