RooWorkspace import not working with PyROOT 6

Dear all,

I am having some trouble importing objects into RooWorkspace using PyROOT that came with ROOT 6.02.05. The variable x is imported as a “generic object” with no name. Everything work with ROOT 5.34.25.

Both ROOT versions are the ones from ATLAS’s ALRB.

Any idea what could be wrong?

The code is as follows:

#!/usr/bin/env python

from ROOT import *

w=RooWorkspace('w','workspace')

x=RooRealVar("x","x",0,100)

getattr(w,'import')(x)
w.Print()

The ROOT 6 output is:

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt


RooWorkspace(w) workspace contents

generic objects
---------------
RooRealVar::

The ROOT 5 output is:

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::x

RooWorkspace(w) workspace contents

variables
---------
(x)

Hi Karol,

that should not happen.
Is this maybe an issue of PyROOT? In other words, does this work in C++?

Cheers,
Danilo

Dear Danilo,

Yes, it does seem to be a PyROOT issue. The following is the output of the C++ version of the code.

void test()
{
  RooWorkspace w("w","workspace");

  RooRealVar x("x","x",0,100);

  w.import(x);
  w.Print();
}
Processing test.C...                                                                                                                                                                                                                         
                                                                                                                                                                                                                                             
RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby                                                                                                                                                                                
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University                                                                                                                                               
                All rights reserved, please read http://roofit.sourceforge.net/license.txt                                                                                                                                                   
                                                                                                                                                                                                                                             
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::x

RooWorkspace(w) workspace contents

variables
---------
(x)

Also I did a quick check with a version of ROOT 6 that I compiled locally. I noticed that the PyROOT version calls the following import:

Bool_t RooWorkspace::import(TObject& object, Bool_t replaceExisting) 

The C++ version calls the following import:

Bool_t RooWorkspace::import(const RooAbsArg& inArg,
			    const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, 
			    const RooCmdArg& arg4, const RooCmdArg& arg5, const RooCmdArg& arg6, 
			    const RooCmdArg& arg7, const RooCmdArg& arg8, const RooCmdArg& arg9) 

Could PyROOT be getting confused with overloading and inherited classes?

Hello Karol,

thanks a lot for your report: this looks like some kind of method resolution issue.
Could you attach the rootfile and script so that I can open a ticket for our pyroot expert?

Cheers,
Danilo

Dear Danilo,

I’ve attached the Python and C++ versions of the script.

There is no ROOT file. I create a RooRealVar x and RooWorkspace in the code, import the x variable into the workspace and print the contents of the workspace.
test.py (138 Bytes)
test.C (113 Bytes)

Hello Karol,

this has been filed: sft.its.cern.ch/jira/browse/ROOT-7166
It will be fixed soon.
Meanwhile, I tested the script also on the master branch of ROOT and that one is not affected by the issue.

Cheers and thanks,
Danilo

Dear Danilo,

Thank you for opening the ticket!

I tried master and it works for me too.

sft.its.cern.ch/jira/browse/ROOT-6785