12from __future__
import print_function
20x = ROOT.RooRealVar(
"x",
"x", 0, 10)
24mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5, -10, 10)
25sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5, 0.1, 10)
26sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1, 0.1, 10)
28sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
29sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
32a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0., 1.)
33a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2)
34bkg = ROOT.RooChebychev(
"bkg",
"Background", x, ROOT.RooArgList(a0, a1))
37sig1frac = ROOT.RooRealVar(
38 "sig1frac",
"fraction of component 1 in signal", 0.8, 0., 1.)
40 "sig",
"Signal", ROOT.RooArgList(sig1, sig2), ROOT.RooArgList(sig1frac))
43bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0., 1.)
44model = ROOT.RooAddPdf(
45 "model",
"g1+g2+a", ROOT.RooArgList(bkg, sig), ROOT.RooArgList(bkgfrac))
48data = model.generate(ROOT.RooArgSet(x), 1000)
54r = model.fitTo(data, ROOT.RooFit.Save())
70ROOT.gStyle.SetOptStat(0)
71ROOT.gStyle.SetPalette(1)
72hcorr = r.correlationHist()
75frame = ROOT.RooPlot(sigma1, sig1frac, 0.45, 0.60, 0.65, 0.90)
76frame.SetTitle(
"Covariance between sigma1 and sig1frac")
77r.plotOn(frame, sigma1, sig1frac,
"ME12ABHV")
83print(
"EDM = ", r.edm())
84print(
"-log(L) minimum = ", r.minNll())
87print(
"final value of floating parameters")
88r.floatParsFinal().
Print(
"s")
91print(
"correlation between sig1frac and a0 is ", r.correlation(
93print(
"correlation between bkgfrac and mean is ", r.correlation(
97cor = r.correlationMatrix()
98cov = r.covarianceMatrix()
101print(
"correlation matrix")
103print(
"covariance matrix")
110f = ROOT.TFile(
"rf607_fitresult.root",
"RECREATE")
117c = ROOT.TCanvas(
"rf607_fitresult",
"rf607_fitresult", 800, 400)
120ROOT.gPad.SetLeftMargin(0.15)
121hcorr.GetYaxis().SetTitleOffset(1.4)
124ROOT.gPad.SetLeftMargin(0.15)
125frame.GetYaxis().SetTitleOffset(1.6)
128c.SaveAs(
"rf607_fitresult.png")
void Print(std::ostream &os, const OptionType &opt)