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(ROOT.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 0x38e0610 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 0x38e0610 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 0x38e0610 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 0x38e0610 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 0x38e0610 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 0x38e0610 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 0x38e0610 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 0x38e0610 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 0x7bd6a60 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x_alpha for nset (x,alpha) with code 0 from preexisting content.
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x7bd6a60 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 0x84c9820 with pdf g1_MORPH_g2_CACHE_Obs[x]_NORM_x for nset (x) with code 0 from preexisting content.
[#0] PROGRESS:Eval -- RooIntegralMorph::fillCacheObject(lmorph) filling multi-dimensional cache..................................................
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x8121250 with pdf g1_MORPH_g2_CACHE_Obs[alpha,x]_NORM_x for nset (x) with code 0
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#1] INFO:Minimization -- The following expressions have been identified as constant and will be precalculated and cached: (g1,g2)
[#0] WARNING:Minimization -- RooAbsMinimizerFcn::synchronize: WARNING: no initial error estimate available for alpha: using 0.1
prevFCN = 2639.749221 alpha=0.8036,
prevFCN = 2639.293411 alpha=0.7963,
prevFCN = 2640.372665 alpha=0.8004,
prevFCN = 2639.696142 alpha=0.7996,
prevFCN = 2639.803979 alpha=0.8116,
prevFCN = 2638.919067 alpha=0.8119,
prevFCN = 2638.930988 alpha=0.8113,
prevFCN = 2638.90877 alpha=0.8094,
prevFCN = 2638.901287 alpha=0.8102,
prevFCN = 2638.885142 alpha=0.8103,
prevFCN = 2638.886672 alpha=0.8101,
prevFCN = 2638.883909 alpha=0.8095,
prevFCN = 2638.898442 alpha=0.8098,
prevFCN = 2638.889204 alpha=0.8099,
prevFCN = 2638.884962 alpha=0.8104,
prevFCN = 2638.887231 alpha=0.8098,
prevFCN = 2638.888592 alpha=0.8102,
prevFCN = 2638.885076 alpha=0.81,
prevFCN = 2638.883889 alpha=0.8098,
prevFCN = 2638.888746 alpha=0.81,
prevFCN = 2638.883589 alpha=0.81,
prevFCN = 2638.883345 alpha=0.8095,
prevFCN = 2638.898453 alpha=0.8098,
prevFCN = 2638.89011 alpha=0.8099,
prevFCN = 2638.886243 alpha=0.81,
prevFCN = 2638.884385 alpha=0.81,
prevFCN = 2638.883475 alpha=0.8101,
prevFCN = 2638.884457 alpha=0.8099,
prevFCN = 2638.885716 alpha=0.8101,
prevFCN = 2638.883988 alpha=0.81,
prevFCN = 2638.884446 alpha=0.81,
prevFCN = 2638.883552 alpha=0.81,
prevFCN = 2638.883372 alpha=0.81,
prevFCN = 2638.883349 alpha=0.81,
prevFCN = 2638.883345 alpha=0.81,
prevFCN = 2638.883345 alpha=0.8101,
prevFCN = 2638.883988 alpha=0.81,
prevFCN = 2638.884446 alpha=0.81,
prevFCN = 2638.883467 alpha=0.81,
prevFCN = 2638.883226 alpha=0.81,
prevFCN = 2638.883369 alpha=0.81,
prevFCN = 2638.883321 alpha=0.81,
prevFCN = 2638.883345 alpha=0.81,
prevFCN = 2638.883369 alpha=0.81,
prevFCN = 2638.883321 alpha=0.81,
prevFCN = 2638.883592 alpha=0.81,
prevFCN = 2638.883318 alpha=0.8103,
prevFCN = 2638.886384 alpha=0.8097,
prevFCN = 2638.890375 alpha=0.8127,
prevFCN = 2638.970069 alpha=0.8073,
prevFCN = 2638.999987 alpha=0.8168,
prevFCN = 2639.341686 alpha=0.8031,
prevFCN = 2639.351365 alpha=0.8102,
prevFCN = 2638.885198 alpha=0.8098,
prevFCN = 2638.887596 alpha=0.8101,
prevFCN = 2638.883672 alpha=0.81,
prevFCN = 2638.883552 alpha=0.81, [#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x89123c0 with pdf g1_MORPH_g2_CACHE_Obs[alpha,x]_NORM_x for nset (x) with code 0 from preexisting content.
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x8b13680 with pdf g1_MORPH_g2_CACHE_Obs[alpha,x]_NORM_x for nset (x) with code 0 from preexisting content.
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x3811800 with pdf g1_MORPH_g2_CACHE_Obs[alpha,x]_NORM_x for nset (x) with code 0 from preexisting content.
[#1] INFO:Caching -- RooAbsCachedPdf::getCache(lmorph) creating new cache 0x3811800 with pdf g1_MORPH_g2_CACHE_Obs[alpha,x]_NORM_x for nset (x) with code 0 from preexisting content.