Rf 5 0 4_Simwstool¶

Organization and simultaneous fits: using RooSimWSTool to construct a simultaneous pdf that is built of variations of an input pdf

Author: Clemens Lange, Wouter Verkerke (C++ version)
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Monday, January 17, 2022 at 10:04 AM.

In [ ]:
import ROOT

Create master pdf¶

Construct gauss(x,m,s)

In [ ]:
x = ROOT.RooRealVar("x", "x", -10, 10)
m = ROOT.RooRealVar("m", "m", 0, -10, 10)
s = ROOT.RooRealVar("s", "s", 1, -10, 10)
gauss = ROOT.RooGaussian("g", "g", x, m, s)

Construct poly(x,p0)

In [ ]:
p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0.0, 1.0)
poly = ROOT.RooPolynomial("p", "p", x, [p0])

model = fgauss(x) + (1-f)poly(x)

In [ ]:
f = ROOT.RooRealVar("f", "f", 0.5, 0.0, 1.0)
model = ROOT.RooAddPdf("model", "model", [gauss, poly], [f])

Create category observables for splitting¶

Define two categories that can be used for splitting

In [ ]:
c = ROOT.RooCategory("c", "c")
c.defineType("run1")
c.defineType("run2")

d = ROOT.RooCategory("d", "d")
d.defineType("foo")
d.defineType("bar")

Set up SimWSTool¶

Import ingredients in a workspace

In [ ]:
w = ROOT.RooWorkspace("w", "w")
w.Import({model, c, d})

Make Sim builder tool

In [ ]:
sct = ROOT.RooSimWSTool(w)

Build a simultaneous model with one split¶

Construct a simultaneous pdf with the following form

model_run1(x) = fgauss_run1(x,m_run1,s) + (1-f)poly model_run2(x) = fgauss_run2(x,m_run2,s) + (1-f)poly simpdf(x,c) = model_run1(x) if c=="run1" = model_run2(x) if c=="run2"

Returned pdf is owned by the workspace

In [ ]:
model_sim = sct.build("model_sim", "model", SplitParam=("m", "c"))

Print tree structure of model

In [ ]:
model_sim.Print("t")

In [ ]:
w.var("m_run1").setVal(-3)
w.var("m_run2").setVal(+3)

Print contents of workspace

In [ ]:
w.Print("v")

Build a simultaneous model with product split¶

Build another simultaneous pdf using a composite split in states c X d

In [ ]:
model_sim2 = sct.build("model_sim2", "model", SplitParam=("p0", "c,d"))

Print tree structure of self model

In [ ]:
model_sim2.Print("t")