RooWorkspace (RooFit) not importing in PyRoot

Hi all (Wim),

I was trying to use the RooWorkspace object today with PyRoot and to test it out, I converted one of the tutorials, rf502_wspacewrite.C, to PyRoot.

Unfortunately, I’m getting an error when I try to import one of the PDF’s.

File "./rf502_wspacewrite.py", line 57 w.import(model) ^ SyntaxError: invalid syntax

I’m attaching my code. Any help would be greatly appreciated.

Matt
rf502_wspacewrite.py (2.38 KB)

Matt,

yes, “import” is a keyword and can thus not be used as a method. Easiest workaround would be:[code]# Import model and all its components into the workspace
getattr(w,‘import’)(model)

Import data into the workspace

getatr(w,‘import’)(data)[/code]
HTH,
Wim

Awesome!

Thanks, Wim. Worked like a charm. I had some other parts of the script that were not properly PyRoot’ed. I fixed those and it seems to be swinging. I’m attaching the corrected script for completeness sake.

Matt
rf502_wspacewrite.py (2.43 KB)