polyVar, how do get the value for a given x?

Hi,

I have a
w.factory(“PolyVar::mHighMass(ycor,{am0[3.1,2.9,3.5],am1[0.0,-1,1],am2[0.0,-1,1]})”)
depending on
y = ROOT.RooRealVar( “ycor”, “rapidity”, 0.0, 0.0, 2.0, “” )
which I used to parametrize a gaussian pdf:
w.factory(‘Gaussian::gaussHighMass(mcor,mHighMass,sigma)’)

I succeeded to make simultaneous fits in the mcor,ycor space. Also able to plot mHighMass:
w.function(‘mHighMass’).plotOn(frameY)

BUT, I have not figured out how to get the value of mHighMass for a given value of y in my macro.
Sorry for this probably trivial question, but after a few hours of searching, trying, I give up. I am probably missing something basic.

best regards,
Thomas

Hi Thomas,

I’m probably missing something, but you can do two things:

  • Set a value for y, and retrieve value for mass:
    y.setVal(3); mHighMass.getVal();
  • And obviously also plotting mass vs y, but I see that you did that.

Dear Stephan,
Thanks for the fast answer. Indeed, this combination was among the many things I tried. Looked to me as the most obvious. However, I always get the same value. Maybe some C++ <–> Python issue?
Do you have an example which works?

y.getVal()
1.0

mHighMass.getVal()
3.1745861462875875

y.setVal(1.5)
mHighMass.getVal()
3.1745861462875875

RooPolyVar::mHighMass[ x=ycor coefList=(am0,am1,am2) ] = 3.17459

thomas

Oh, wait. You seem to be using a different y …
Can you post the full code?

So, the problem is probably that there is a y inside the workspace and you seem to have a y outside, at least telling from the snippet that you posted. The pdfs/functions from the workspace are only connected to the one inside.

It could also be the bug discussed here:

indeed, the y inside and outside workspace are different:

y
<ROOT.RooRealVar object (“ycor”) at 0x557d995eaab0>

w.var(‘ycor’)
<ROOT.RooRealVar object (“ycor”) at 0x557d9e9a0300>

with w.var(‘ycor’), things work as expected.
thanks for your help,
Thomas

1 Like

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