Skip to content

[RF] Implement checking param range #19258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Ban42
Copy link
Contributor

@Ban42 Ban42 commented Jul 2, 2025

This Pull request:

Changes or fixes:

As requested in #7210, adds parameters checks to:

  • Breit-Wigner distribution
  • Chi-Square distribution
  • Decay distribution
  • Exponential distribution

Checklist:

  • tested changes locally: I haven't, I am running into some problems when running roottest, will try to fix those problems and run the test locally in future PRs. This PR looked easy enough to skip them, at least locally.
  • updated the docs (if necessary): Tell me if I should.

Questions from me

  • I know there is more distributions to check the param of, I just wanted to be sure I was doing what requested before submitting 10+ commits.
  • My statistics knowledge is not the best, so I hope I did not make mistakes on parameters ranges 🙈
  • I used [skip-CI] tag just because I wanted to trigger Jenkins just once after I have created parameter checks on all (or more) distributions. I guess that when removing the tag it will run the tests on the full PR and not only on the last commit, correct?
  • I have also inserted the [skip-CI] tag in the commit messages, is this correct or unnecessary?

This PR (partially) fixes #7210

Thanks!

@Ban42 Ban42 requested review from lmoneta and guitargeek as code owners July 2, 2025 18:08
@pcanal
Copy link
Member

pcanal commented Jul 2, 2025

I have also inserted the [skip-CI] tag in the commit messages, is this correct or unnecessary?

It would be misleading. '[skip-CI]' indicates changes that have no functional effect, which is not the case for this commit/PR.

@pcanal pcanal changed the title [skip-CI][RF] Implement checking param range [RF] Implement checking param range Jul 2, 2025
@pcanal pcanal marked this pull request as draft July 2, 2025 18:25
@pcanal
Copy link
Member

pcanal commented Jul 2, 2025

I used [skip-CI] tag just because I wanted to trigger Jenkins just once after I have created parameter checks on all (or more) distributions. I guess that when removing the tag it will run the tests on the full PR and not only on the last commit, correct?

I don't think we have a trigger on removing the tag.

Since this PR is still awaiting more changes (including tests?), I move the PR is draft mode.

For this PR, the CI will run only with one the maintainer launching it. Please let us know when it is ready to run the CI, for example by marking it as ready for review.

@guitargeek
Copy link
Contributor

Thank you very much for making the first step towards closing that PR!

Personally, I have not addressed this issue because of two reasons:

  1. Not every PDF class in RooFit gets used a lot, so going through all classes is not necessarily effort well spent
  2. The mechanism to check for invalid ranges is fragile, because ranges of parameters can be changed at any time.

But you are right, it's of course better to do something rather than to do nothing :)

So let's maybe implement the checks for 2 or 3 more commonly used classes so we can claim success. What about RooPoisson and RooBifurGauss for example? Could you do this in this PR too?

@@ -39,6 +40,7 @@ RooChiSquarePdf::RooChiSquarePdf(const char* name, const char* title,
_x("x", "Dependent", this, x),
_ndof("ndof","ndof", this, ndof)
{
RooHelpers::checkRangeOfParameters(this, {&_ndof}, 0.);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RooHelpers::checkRangeOfParameters(this, {&_ndof}, 0.);
RooHelpers::checkRangeOfParameters(this, {&_x, &_ndof}, 0.);

Also the x variable for the chi2 pdf should be positive. If not, users will get NaN pdf/likelihood values, so it's good to warn about this too!

@@ -45,6 +46,7 @@ RooExponential::RooExponential(const char *name, const char *title, RooAbsReal &
c{"c", "Exponent", this, coefficient},
_negateCoefficient{negateCoefficient}
{
RooHelpers::checkRangeOfParameters(this, {&coefficient}, 0.);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RooHelpers::checkRangeOfParameters(this, {&coefficient}, 0.);

This should not be done, as the class can be used to model both exponential decreases and increases

@@ -64,6 +65,7 @@ RooDecay::RooDecay(const char *name, const char *title,
_basisExp = declareBasis("exp(-abs(@0)/@1)",tau) ;
break ;
}
RooHelpers::checkRangeOfParameters(this, {&_tau}, 0.);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RooHelpers::checkRangeOfParameters(this, {&_tau}, 0.);

I would not do this check either (yes, the name RooDecay suggests that tau should be positive, but I have no reason to assume that this class technically doesn't work for negative tau as well).

Copy link
Contributor

@guitargeek guitargeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the initiative! Just a few comments, and let's maybe so this for some more common classes so we can wrap up the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RF] Implement checking of parameter ranges
3 participants