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.0, 1.0)
33a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2)
34bkg = ROOT.RooChebychev(
"bkg",
"Background", x, [a0, a1])
37sig1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in signal", 0.8, 0.0, 1.0)
38sig = ROOT.RooAddPdf(
"sig",
"Signal", [sig1, sig2], [sig1frac])
41bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0.0, 1.0)
42model = ROOT.RooAddPdf(
"model",
"g1+g2+a", [bkg, sig], [bkgfrac])
45data = model.generate({x}, 1000)
51r = model.fitTo(data, Save=
True, PrintLevel=-1)
67ROOT.gStyle.SetOptStat(0)
68ROOT.gStyle.SetPalette(1)
69hcorr = r.correlationHist()
72frame = ROOT.RooPlot(sigma1, sig1frac, 0.45, 0.60, 0.65, 0.90)
73frame.SetTitle(
"Covariance between sigma1 and sig1frac")
74r.plotOn(frame, sigma1, sig1frac,
"ME12ABHV")
80print(
"EDM = ", r.edm())
81print(
"-log(L) minimum = ", r.minNll())
84print(
"final value of floating parameters")
85r.floatParsFinal().
Print(
"s")
88print(
"correlation between sig1frac and a0 is ", r.correlation(sig1frac, a0))
89print(
"correlation between bkgfrac and mean is ", r.correlation(
"bkgfrac",
"mean"))
92cor = r.correlationMatrix()
93cov = r.covarianceMatrix()
96print(
"correlation matrix")
98print(
"covariance matrix")
105f = ROOT.TFile(
"rf607_fitresult.root",
"RECREATE")
112c = ROOT.TCanvas(
"rf607_fitresult",
"rf607_fitresult", 800, 400)
115ROOT.gPad.SetLeftMargin(0.15)
116hcorr.GetYaxis().SetTitleOffset(1.4)
119ROOT.gPad.SetLeftMargin(0.15)
120frame.GetYaxis().SetTitleOffset(1.6)
123c.SaveAs(
"rf607_fitresult.png")
void Print(GNN_Data &d, std::string txt="")