28ROOT.RooMsgService.instance().setGlobalKillBelow(ROOT.RooFit.WARNING)
34 frame1 = x_var.frame()
37 bin_mu_x = ROOT.RooBinning(4, 0.0, 4.0)
38 grid = ROOT.RooMomentMorphFuncND.Grid(bin_mu_x)
44 workspace.factory(f
"Gaussian::g{i}(x, mu{i}[{i}], {sigma})".
format(i=i))
47 hist = workspace[f
"g{i}"].generateBinned([x_var], n_samples * 100)
49 for i_bin
in range(hist.numEntries()):
50 hist.add(hist.get(i_bin), 1.0)
54 workspace.Import(ROOT.RooHistPdf(f
"histpdf{i}", f
"histpdf{i}", [x_var], hist, intOrder=1))
57 grid.addPdf(workspace[f
"histpdf{i}"],
int(i))
58 workspace[f
"histpdf{i}"].plotOn(frame1)
61 morph_func = ROOT.RooMomentMorphFuncND(
"morph_func",
"morph_func", [mu_var], [x_var], grid, setting)
64 morph_func.setPdfMode()
67 morph = ROOT.RooWrapperPdf(
"morph",
"morph", morph_func,
True)
68 workspace.Import(morph)
69 workspace[
"morph"].plotOn(frame1, LineColor=
"r")
75def build_ws(mu_observed, sigma):
76 ws = ROOT.RooWorkspace()
77 ws.factory(f
"Gaussian::gauss(x[-5,15], mu[{mu_observed},0,4], {sigma})".
format(mu_observed=mu_observed))
85workspace = build_ws(mu_observed, sigma)
87mu_var = workspace[
"mu"]
88gauss = workspace.pdf(
"gauss")
89obs_data = gauss.generate(x_var, n_samples)
93nll_gauss = gauss.createNLL(obs_data)
96frame1 = morphing(ROOT.RooMomentMorphFuncND.Linear)
99nll_morph = workspace[
"morph"].createNLL(obs_data, EvalBackend=
"legacy")
102frame2 = mu_var.frame(Title=
"Negative log Likelihood")
103nll_gauss.plotOn(frame2, LineColor=
"b", ShiftToZero=
True, Name=
"gauss")
104nll_morph.plotOn(frame2, LineColor=
"r", ShiftToZero=
True, Name=
"morphed")
106c = ROOT.TCanvas(
"rf616_morphing",
"rf616_morphing", 800, 400)
109ROOT.gPad.SetLeftMargin(0.15)
110frame1.GetYaxis().SetTitleOffset(1.8)
113ROOT.gPad.SetLeftMargin(0.15)
114frame2.GetYaxis().SetTitleOffset(1.8)
119for nll
in [nll_gauss, nll_morph]:
120 minimizer = ROOT.RooMinimizer(nll)
121 minimizer.setPrintLevel(-1)
122 minimizer.minimize(
"Minuit2")
123 result = minimizer.save()
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format