import ROOT
x = ROOT.RooRealVar("x", "x", -20, 20)
g1mean = ROOT.RooRealVar("g1mean", "g1mean", -10)
g1 = ROOT.RooGaussian("g1", "g1", x, g1mean, 2.0)
g2 = ROOT.RooPolynomial("g2", "g2", x, [-0.03, -0.001])
alpha = ROOT.RooRealVar("alpha", "alpha", 0, 1.0)
x.setBins(1000, "cache")
alpha.setBins(50, "cache")
lmorph = ROOT.RooIntegralMorph("lmorph", "lmorph", g1, g2, x, alpha)
frame1 = x.frame()
g1.plotOn(frame1)
g2.plotOn(frame1)
alpha.setVal(0.125)
lmorph.plotOn(frame1, LineColor="r")
alpha.setVal(0.25)
lmorph.plotOn(frame1, LineColor="r")
alpha.setVal(0.375)
lmorph.plotOn(frame1, LineColor="r")
alpha.setVal(0.50)
lmorph.plotOn(frame1, LineColor="r")
alpha.setVal(0.625)
lmorph.plotOn(frame1, LineColor="r")
alpha.setVal(0.75)
lmorph.plotOn(frame1, LineColor="r")
alpha.setVal(0.875)
lmorph.plotOn(frame1, LineColor="r")
alpha.setVal(0.95)
lmorph.plotOn(frame1, LineColor="r")
hh = lmorph.createHistogram("hh", x, Binning=40, YVar=dict(var=alpha, Binning=40))
hh.SetLineColor("kBlue")
alpha.setVal(0.8)
data = lmorph.generate(x, 1000)
lmorph.setCacheAlpha(True)
lmorph.fitTo(data, Verbose=True, PrintLevel=-1)
frame2 = x.frame(Bins=100)
data.plotOn(frame2)
lmorph.plotOn(frame2)
frame3 = alpha.frame(Bins=100, Range=(0.1, 0.9))
nll = lmorph.createNLL(data)
nll.plotOn(frame3, ShiftToZero=True)
lmorph.setCacheAlpha(False)
c = ROOT.TCanvas("rf705_linearmorph", "rf705_linearmorph", 800, 800)
c.Divide(2, 2)
c.cd(1)
ROOT.gPad.SetLeftMargin(0.15)
frame1.GetYaxis().SetTitleOffset(1.6)
frame1.Draw()
c.cd(2)
ROOT.gPad.SetLeftMargin(0.20)
hh.GetZaxis().SetTitleOffset(2.5)
hh.Draw("surf")
c.cd(3)
ROOT.gPad.SetLeftMargin(0.15)
frame3.GetYaxis().SetTitleOffset(1.4)
frame3.Draw()
c.cd(4)
ROOT.gPad.SetLeftMargin(0.15)
frame2.GetYaxis().SetTitleOffset(1.4)
frame2.Draw()
c.SaveAs("rf705_linearmorph.png")
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653ae00a1e0 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1dd7270 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1dd7270 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1dd7270 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1dd7270 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1dd7270 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1dd7270 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1dd7270 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b20341d0 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x_alpha for nset (x,alpha) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1fa5800 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b1f6fd20 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0
[#0] PROGRESS:Eval -- RooIntegralMorph::fillCacheObject(lmorph) filling multi-dimensional cache..................................................
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b226df30 with pdf g1_MORPH_g2_CACHE_Obs[alpha,x]_NORM_x for nset (x) with code 0
[#1] INFO:Fitting -- RooAbsPdf::fitTo(lmorph_over_lmorph_Int[x]) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- using generic CPU library compiled with no vectorizations
[#1] INFO:Fitting -- Creation of NLL object took 677.741 ms
[#1] INFO:Fitting -- RooAddition::defaultErrorLevel(nll_lmorph_over_lmorph_Int[x]_lmorphData) Summation contains a RooNLLVar, using its error level
[#0] WARNING:Minimization -- RooAbsMinimizerFcn::synchronize: WARNING: no initial error estimate available for alpha: using 0.1
[#1] INFO:Minimization -- [fitFCN] No discrete parameters, performing continuous minimization only
[#1] INFO:FastEvaluations -- The class RooHistPdf does not implement the faster batch evaluation interface. Consider requesting or implementing it to benefit from a speed up.
prevFCN = 9766.49553 alpha=0.807,
prevFCN = 9765.749972 alpha=0.7929,
prevFCN = 9767.913616 alpha=0.8007,
prevFCN = 9766.391047 alpha=0.7993,
prevFCN = 9766.606778 alpha=0.8111,
prevFCN = 9765.633451 alpha=0.8117,
prevFCN = 9765.644811 alpha=0.8105,
prevFCN = 9765.627438 alpha=0.8101,
prevFCN = 9765.626406 alpha=0.8107,
prevFCN = 9765.628362 alpha=0.8096,
prevFCN = 9765.636381 alpha=0.8105,
prevFCN = 9765.627083 alpha=0.8098,
prevFCN = 9765.631245 alpha=0.8104,
prevFCN = 9765.626865 alpha=0.8102,
prevFCN = 9765.626432 alpha=0.8102,
prevFCN = 9765.626393 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8105,
prevFCN = 9765.627156 alpha=0.8099,
prevFCN = 9765.629591 alpha=0.8103,
prevFCN = 9765.626436 alpha=0.8102,
prevFCN = 9765.6264 alpha=0.8102,
prevFCN = 9765.626393 alpha=0.8102,
prevFCN = 9765.626392 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8105,
prevFCN = 9765.627156 alpha=0.8099,
prevFCN = 9765.629591 alpha=0.8102,
prevFCN = 9765.626422 alpha=0.8101,
prevFCN = 9765.626422 alpha=0.8102,
prevFCN = 9765.626393 alpha=0.8102,
prevFCN = 9765.626393 alpha=0.8102,
prevFCN = 9765.626391 alpha=0.8102,
prevFCN = 9765.626393 alpha=0.8102,
prevFCN = 9765.626393 alpha=0.8103,
prevFCN = 9765.626514 alpha=0.8101,
prevFCN = 9765.626514 alpha=0.8102,
prevFCN = 9765.626396 alpha=0.8102,
prevFCN = 9765.626396 alpha=0.8102,
prevFCN = 9765.626392 alpha=0.8102,
prevFCN = 9765.626392 alpha=0.8102, [#0] PROGRESS:Eval -- RooIntegralMorph::fillCacheObject(lmorph) filling multi-dimensional cache..................................................
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b25b7fd0 with pdf g1_MORPH_g2_CACHE_Obs[alpha,x]_NORM_x for nset (x) with code 0
[#0] PROGRESS:Eval -- RooIntegralMorph::fillCacheObject(lmorph) filling multi-dimensional cache..................................................
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x5653b25b7fd0 with pdf g1_MORPH_g2_CACHE_Obs[alpha,x]_NORM_x for nset (x) with code 0
[#1] INFO:Fitting -- RooAbsPdf::fitTo(lmorph_over_lmorph_Int[x]) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- Creation of NLL object took 691.466 ms