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., 1.)
poly = ROOT.RooPolynomial("p", "p", x, ROOT.RooArgList(p0))
f = ROOT.RooRealVar("f", "f", 0.5, 0., 1.)
model = ROOT.RooAddPdf("model", "model", ROOT.RooArgList(
gauss, poly), ROOT.RooArgList(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")
getattr(w, 'import')(ROOT.RooArgSet(model, c, d))
sct = ROOT.RooSimWSTool(w)
model_sim = sct.build("model_sim", "model",
ROOT.RooFit.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",
ROOT.RooFit.SplitParam("p0", "c,d"))
model_sim2.Print("t")