21x = ROOT.RooRealVar(
"x",
"x", -10, 10)
24m = ROOT.RooRealVar(
"m",
"m", 0, -10, 10)
25s = ROOT.RooRealVar(
"s",
"s", 2, 0.1, 10)
26g = ROOT.RooGaussian(
"g",
"g", x, m, s)
29p = ROOT.RooPolynomial(
"p",
"p", x)
32f = ROOT.RooRealVar(
"f",
"f", 0.4, 0.0, 1.0)
33sum = ROOT.RooAddPdf(
"sum",
"sum", [g, p], [f])
36fconstraint = ROOT.RooGaussian(
"fconstraint",
"fconstraint", f, ROOT.RooFit.RooConst(0.7), ROOT.RooFit.RooConst(0.1))
39sumc = ROOT.RooProdPdf(
"sumc",
"sum with constraint", [sum, fconstraint])
48 ROOT.RooFit.Constrain({f}),
49 ROOT.RooFit.Silence(),
51 ROOT.RooFit.FitOptions(ROOT.RooFit.PrintLevel(-1)),
57mcs.generateAndFit(500, 2000)
60h_f_gen = ROOT.RooAbsData.createHistogram(mcs.fitParDataSet(),
"f_gen", -40)
63frame1 = mcs.plotParam(f, ROOT.RooFit.Bins(40))
64frame1.SetTitle(
"Distribution of fitted f values")
67frame2 = mcs.plotPull(f, ROOT.RooFit.Bins(40), ROOT.RooFit.FitGauss())
68frame1.SetTitle(
"Distribution of f pull values")
70c = ROOT.TCanvas(
"rf804_mcstudy_constr",
"rf804_mcstudy_constr", 1200, 400)
73ROOT.gPad.SetLeftMargin(0.15)
74h_f_gen.GetYaxis().SetTitleOffset(1.4)
77ROOT.gPad.SetLeftMargin(0.15)
78frame1.GetYaxis().SetTitleOffset(1.4)
81ROOT.gPad.SetLeftMargin(0.15)
82frame2.GetYaxis().SetTitleOffset(1.4)
85c.SaveAs(
"rf804_mcstudy_constr.png")