19def getWorkspace(mode):
27 w = ROOT.RooWorkspace()
31 w = ROOT.RooWorkspace(
"w", 1)
36 "EXPR::model('1/((x-a)*(x-a)+0.01)+1/((y-a)*(y-a)+0.01)+1/((z-a)*(z-a)+0.01)',x[-1,1],y[-1,1],z[-1,1],a[-5,5])")
46 w.pdf(
"model").setStringAttribute(
"CACHEPARMINT",
"x:y:z")
49 normSet = ROOT.RooArgSet(w.var(
"x"), w.var(
"y"), w.var(
"z"))
50 w.pdf(
"model").getVal(normSet)
51 w.writeToFile(
"rf903_numintcache.root")
55 f = ROOT.TFile(
"rf903_numintcache.root")
78 hhcache = w.expensiveObjectCache().getObj(1)
80 ROOT.TCanvas(
"rf903_numintcache",
"rf903_numintcache", 600, 600)
81 hhcache.createHistogram(
"a").
Draw()
83 ROOT.RooFit.Error(
"rf903_numintcache",
84 "Cached histogram is not existing in workspace")
92d = w.pdf(
"model").generate(ROOT.RooArgSet(w.var(
"x"), w.var(
"y"), w.var(
"z")), 1000)
95w.pdf(
"model").fitTo(d, ROOT.RooFit.Verbose(ROOT.kTRUE), ROOT.RooFit.Timer(ROOT.kTRUE))
99framex = w.var(
"x").frame(ROOT.RooFit.Title(
"Projection of 3D model on X"))
101w.pdf(
"model").plotOn(framex)
104c = ROOT.TCanvas(
"rf903_numintcache",
"rf903_numintcache", 600, 600)
107c.SaveAs(
"rf903_numintcache.png")
110ROOT.gDirectory.Add(w)