Skip to content

[RF] RooFormulaVar is too eager in variable name substitution #11992

@elusian

Description

@elusian
  • Checked for duplicates

Describe the bug

When passing a argument to a formula based RooFit function (e.g. RooFormulaVar or RooGenericPdf), RooFit will search for all occurrences of the object name in the formula and replace them with an ordinal parameter (needed for the underling TFormula). However, when the argument is a RooConst the name is just a string containing the value and this can break if there are numeric literals inside the formula.
For example

RooFormulaVar f("f", "2.7*@0", RooFit::RooConst(2.))

becomes inside the TFormula

x[0].7*x[0]

because the name 2 of the RooConst matched the 2 of the numeric literal. This of course breaks during formula compilation.

Expected behavior

The variables do not replace numeric literals no matter the name. Possibly RooConsts should be matched only by index?

To Reproduce

RooFormulaVar f("f", "2.7*@0", RooFit::RooConst(2.))

Setup

HEAD of ROOT 6.26 from LCG dev4

Additional context

RooFormulaVar f("f", "2.7*@0", RooFit::RooConst(2.7)) creates x[0]*x[0], which is mostly fine but may break if servers are redirected

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions