13from __future__
import print_function
21x = ROOT.RooRealVar(
"x",
"x", 0, 10)
25mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5, -10, 10)
26sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5, 0.1, 10)
27sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1, 0.1, 10)
29sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
30sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
33a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0.0, 1.0)
34a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2)
35bkg = ROOT.RooChebychev(
"bkg",
"Background", x, [a0, a1])
38sig1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in signal", 0.8, 0.0, 1.0)
39sig = ROOT.RooAddPdf(
"sig",
"Signal", [sig1, sig2], [sig1frac])
42bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0.0, 1.0)
43model = ROOT.RooAddPdf(
"model",
"g1+g2+a", [bkg, sig], [bkgfrac])
46data = model.generate({x}, 1000)
52r = model.fitTo(data, Save=
True, PrintLevel=-1)
68ROOT.gStyle.SetOptStat(0)
69ROOT.gStyle.SetPalette(1)
70hcorr = r.correlationHist()
73frame = ROOT.RooPlot(sigma1, sig1frac, 0.45, 0.60, 0.65, 0.90)
74frame.SetTitle(
"Covariance between sigma1 and sig1frac")
75r.plotOn(frame, sigma1, sig1frac,
"ME12ABHV")
81print(
"EDM = ", r.edm())
82print(
"-log(L) minimum = ", r.minNll())
85print(
"final value of floating parameters")
86r.floatParsFinal().
Print(
"s")
89print(
"correlation between sig1frac and a0 is ", r.correlation(sig1frac, a0))
90print(
"correlation between bkgfrac and mean is ", r.correlation(
"bkgfrac",
"mean"))
93cor = r.correlationMatrix()
94cov = r.covarianceMatrix()
97print(
"correlation matrix")
99print(
"covariance matrix")
106f = ROOT.TFile(
"rf607_fitresult.root",
"RECREATE")
113c = ROOT.TCanvas(
"rf607_fitresult",
"rf607_fitresult", 800, 400)
116ROOT.gPad.SetLeftMargin(0.15)
117hcorr.GetYaxis().SetTitleOffset(1.4)
120ROOT.gPad.SetLeftMargin(0.15)
121frame.GetYaxis().SetTitleOffset(1.6)
124c.SaveAs(
"rf607_fitresult.png")
void Print(GNN_Data &d, std::string txt="")