How to get an alert when putting a RooRealVar out of his scope?

Here is a stupid example of the problem.

RooRealVar abc(“abc”,“abc”,10,-100,100);
abc.setVal(500);
abc.getVal();
(double) 100.00000

Why root is not “alerting” the user that he tried to give a value outside the range of the variable ? Of course, the user could make all the checks by himself, but is there a kind of “option” to get automaticly informed ?

Hi @escalier,

I have quickly checked through the sources and RooRealVar::setVal() clamps the value, but, as you said does not emit any warning. I am inviting @jonas to this topic; he might consider adding a warning if that is useful to enough RooFit users.

Cheers,
J.

thank you. ok, let’s see the point of view of @jonas.

Hi @escalier,

thanks for your post, indeed this is something that behavior needs to be changed. We already have an open GitHub issue about this: RooRealVar setVal() value silently changed · Issue #6937 · root-project/root · GitHub

As @jalopezg said, currently there is no way to get such warning. I will do something about this, but I don’t know what exactly. I think there should at least be a warning, but then there needs to be also a recommendation for people who want the clamping behavior and then get rid of the warning.

I put this on the agenda for the next RooFit developers meeting, and once we converged to a solution I will follow up on the GitHub issue thread.

Cheers,
Jonas

thank you @jonas and @jalopezg. I mark the question as solved. Thanks and good luck.

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