import ROOT
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)
p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0.0, 1.0)
poly = ROOT.RooPolynomial("p", "p", x, [p0])
f = ROOT.RooRealVar("f", "f", 0.5, 0.0, 1.0)
model = ROOT.RooAddPdf("model", "model", [gauss, poly], [f])
c = ROOT.RooCategory("c", "c")
c.defineType("run1")
c.defineType("run2")
d = ROOT.RooCategory("d", "d")
d.defineType("foo")
d.defineType("bar")
w = ROOT.RooWorkspace("w", "w")
w.Import({model, c, d})
sct = ROOT.RooSimWSTool(w)
model_sim = sct.build("model_sim", "model", SplitParam=("m", "c"))
model_sim.Print("t")
w.var("m_run1").setVal(-3)
w.var("m_run2").setVal(+3)
w.Print("v")
model_sim2 = sct.build("model_sim2", "model", SplitParam=("p0", "c,d"))
model_sim2.Print("t")