Arguments to expression in workspace factory

There seem to be two ways of defining an expression with some arguments in a workspace; one where you use the name of an existing variable, and one where you use @0:

from ROOT import RooRealVar, RooArgSet, RooWorkspace
RooWorkspace.Import = getattr(RooWorkspace,'import')
xvar = RooRealVar('x','x',1,-5,5)
workspace = RooWorkspace('workspace',1)
xvar  = workspace.var('x')
func1 = workspace.function('func1')
func2 = workspace.function('func2')
print "xvar  =",xvar.getVal()
print "func1 =",func1.getVal()
print "func2 =",func2.getVal()
print "xvar  =",xvar.getVal()
print "func1 =",func1.getVal()
print "func2 =",func2.getVal()

Is there is a difference between these two methods? As far as I can tell, they behave the same. Does this difference matter when x is a variable parameter, like when doing a fit?

Hello @IzaakWN,

mathematically, they are equivalent. However

  • Naming the variables prevents errors due to using the wrong index.
  • Numbering the variables allows to rename x to e.g. z, but the formula will still work.

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