11from __future__
import print_function
19x = ROOT.RooRealVar(
"x",
"x", 0, 10)
23mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5, -10, 10)
24sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5, 0.1, 10)
25sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1, 0.1, 10)
27sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
28sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
31a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0., 1.)
32a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2)
33bkg = ROOT.RooChebychev(
"bkg",
"Background", x, ROOT.RooArgList(a0, a1))
36sig1frac = ROOT.RooRealVar(
37 "sig1frac",
"fraction of component 1 in signal", 0.8, 0., 1.)
39 "sig",
"Signal", ROOT.RooArgList(sig1, sig2), ROOT.RooArgList(sig1frac))
42bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0., 1.)
43model = ROOT.RooAddPdf(
44 "model",
"g1+g2+a", ROOT.RooArgList(bkg, sig), ROOT.RooArgList(bkgfrac))
47data = model.generate(ROOT.RooArgSet(x), 1000)
53r = model.fitTo(data, ROOT.RooFit.Save())
69ROOT.gStyle.SetOptStat(0)
70ROOT.gStyle.SetPalette(1)
71hcorr = r.correlationHist()
74frame = ROOT.RooPlot(sigma1, sig1frac, 0.45, 0.60, 0.65, 0.90)
75frame.SetTitle(
"Covariance between sigma1 and sig1frac")
76r.plotOn(frame, sigma1, sig1frac,
"ME12ABHV")
82print(
"EDM = ", r.edm())
83print(
"-log(L) minimum = ", r.minNll())
86print(
"final value of floating parameters")
87r.floatParsFinal().Print(
"s")
90print(
"correlation between sig1frac and a0 is ", r.correlation(
92print(
"correlation between bkgfrac and mean is ", r.correlation(
96cor = r.correlationMatrix()
97cov = r.covarianceMatrix()
100print(
"correlation matrix")
102print(
"covariance matrix")
109f = ROOT.TFile(
"rf607_fitresult.root",
"RECREATE")
116c = ROOT.TCanvas(
"rf607_fitresult",
"rf607_fitresult", 800, 400)
119ROOT.gPad.SetLeftMargin(0.15)
120hcorr.GetYaxis().SetTitleOffset(1.4)
123ROOT.gPad.SetLeftMargin(0.15)
124frame.GetYaxis().SetTitleOffset(1.6)
127c.SaveAs(
"rf607_fitresult.png")