Skip to content

[RF] RooRealVar setVal() value silently changed #6937

@dcervenkov

Description

@dcervenkov

Explain what you would like to see improved

When RooRealVar::setVal(value) is used with value outside the predefined RooRealVar range, the value is changed to the closest value in the predefined range. This goes against the most basic rules of programming for dealing with unexpected input. To add insult to injury, the behavior is completely silent!

Optional: share how it could be improved

The value should be checked and an error thrown/exception raised if it is out of range.

To Reproduce

Run the following macro. In the end the value of var is 1 which is not what the user asked for.

void mwe() {
    RooRealVar var("var", "var", 0.5, 0, 1);
    std::cout << var.getVal() << std::endl;
    var.setVal(333);
    std::cout << var.getVal() << std::endl;
}

Setup

ROOT 6.22.0
Debian 10 Buster
ROOT built from source

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions