'RooWorkspace' object is not subscriptable

Dear Experts,
I am trying to persist a workspace. Reading it gives an error

  File "read.py", line 17, in <module>
    x = w["x"]
TypeError: 'RooWorkspace' object is not subscriptable

This happens directly executing the tutorials wspacewrite and wspaceread with version 6.22/08 (pyRoot)

I managed to make it work using

x = w.var("x")
model = w.pdf("model")
data = w.data("modelData")

instead of

x = w["x"]
model = w["model"]
data = w["modelData"]

I also had to use RooArgList explicitly, e.g. replacing

bkg = ROOT.RooChebychev(“bkg”, “Background”, x, [a0, a1])


bkg = ROOT.RooChebychev(“bkg”, “Background”, x, ROOT.RooArgList(a0,a1))

and changing the keywords sintax e.g. replacing

model.plotOn(xframe, Components=“bkg”, LineStyle="–")


model.plotOn(xframe, ROOT.RooFit.Components(“bkg”), ROOT.RooFit.LineStyle(10))

Is this a version problem? or maybe the tutorials are outdated?


I believe the features shown in these tutorials need current ROOT master (they have not been released yet).

You can either wait for ROOT 6.26 to be out or install the bleeding edge ROOT with:



This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.