cppyy.gbl.RooFormulaVar object at ** does not have attribute formula

Following simple syntax not working for latest pyROOT

lxplus$ python3
Python 3.6.8 (default, Apr  2 2020, 13:34:55) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT

>>> x=ROOT.RooRealVar("x", "x", -10, 10)

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

>>> y=ROOT.RooRealVar("y", "y", -10, 10)
>>> roofor=ROOT.RooFormulaVar("gen", "x*y", ROOT.RooArgList(x,y))
>>> roofor.formula()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'RooFormulaVar' object has no attribute 'formula'

Version: root 6.22.02
Platform: lxplus cern

Hi @pkalbhor,

the function’s visibility was changed to private when RooFormula was updated from a ROOT5 formula to a ROOT6 formula.
I guess that can be reverted, but give me a bit of time to check if it’s safe.

One question:
Do you want to change the formula or just read access? I.e., a const & or just a reference to it?

Hi @StephanH
I just want to read the expression of the formula and save it into the string. Like this:

RooFormulaVar roofor
roofor.formula().GetExpFormula().Data()

So yes just read access is fine.
with python2 and ROOT6.18, it used to work just fine.

Here’s what’s happening:

1 Like

It’s merged. Tomorrow, you can test with one of root’s nightly versions.

Thank a lot @StephanH,
I was trying nightly version built on Thursday and for gcc-9.2.0, as below,

source /cvmfs/sft.cern.ch/lcg/nightlies/dev3/Thu/lcgenv/*/x86_64-centos7-gcc9-opt/lcgenv-env.sh
source /cvmfs/sft.cern.ch/lcg/nightlies/dev3/Thu/ROOT/HEAD/x86_64-centos7-gcc9-opt/bin/thisroot.sh

But on lxplus by default gcc-4.8.5 is used and nightly version is not available for this compiler. I tried setting alias for gcc/g++ 9.2.0 as

alias gcc='/cvmfs/sft.cern.ch/lcg/releases/gcc/9.2.0/x86_64-centos7/bin/gcc'
alias g++='/cvmfs/sft.cern.ch/lcg/releases/gcc/9.2.0/x86_64-centos7/bin/g++'

But it doesn’t work, while doing import ROOT in python3, it gives *** Break *** segmentation violation error.
Could give some details on how to correctly use nightly version of ROOT in lxplus?

Somebody updated the nightlies page, and left out the information that you need dev3python3 for python3.
This worked for me:

$ source /cvmfs/sft.cern.ch/lcg/views/dev3python3/latest/x86_64-centos7-gcc8-opt/setup.sh 
$ python3 -c "import ROOT; x = ROOT.RooRealVar('x', 'x', 0); x.Print()"

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

RooRealVar::x = 0 C  L(-INF - +INF) 

(The nightlies page will soon mention an easier way to get ROOT and correct compiler in one go.)

1 Like

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