Skip to content
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

[RF] Several improvements in RooFit chi-square fitting #13651

Merged
merged 4 commits into from Sep 18, 2023

Conversation

guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Sep 15, 2023

The changes in this PR address this forum post...
https://root-forum.cern.ch/t/chi2fito-with-yvar-does-not-support-range-option/56369
...and follows up on the discussion here:
#13638

Short summaries of the commits, more detail in the commit descriptions:

  1. Following up on Revert "Add include directories for externals to ROOT_INCLUDE_DIRS" #1455, the multi-range chi2 creation logic is removed from createChi2(), because for a few months already this can be dealt with in the test statistics base classes
  2. Avoid separate RooXYChi2Var constructors for pdfs and functions: instead of having separate constructors for RooAbsPdf and RooAbsReal, it's better and less code duplication to have one RooAbsReal constructor and dynamically check if it got a RooAbsPdf
  3. Support NumCPU() and Range() in createChi2() for RooDataSets
  4. Bugfix in RooDataSet::reduce() by also copying the stored errors

@guitargeek guitargeek self-assigned this Sep 15, 2023
@root-project root-project deleted a comment from phsft-bot Sep 15, 2023
@root-project root-project deleted a comment from github-actions bot Sep 15, 2023
@root-project root-project deleted a comment from phsft-bot Sep 15, 2023
@root-project root-project deleted a comment from phsft-bot Sep 15, 2023
@root-project root-project deleted a comment from phsft-bot Sep 15, 2023
@root-project root-project deleted a comment from phsft-bot Sep 15, 2023
@guitargeek guitargeek changed the title [RF] Remove multi-range chi-square fit logic from RooAbsPdf [RF] Several improvements in RooFit chi-square fitting Sep 15, 2023
Almost a year ago, I fixed the support for comma-separated normalization
ranges for pdfs, e.g. `pdf.setNormRange("range1,range2")` was fixed also
for RooAddPdfs.

As a result, the logic for multi-range likelihood fits was removed from
`createNLL()`, because the multi-range fit didn't have to be treated as
a special case anymore.

The same applies also to chi-square fits. In fact, the reason why the
`RooChi2Var` constructor and `RooAbsReal::createChi2()` methods had a
`RooAbsPdf` overload was *only* this workaround! For regular
RooAbsReals, the workaround was not necessary, because there is no
normalization.

Therefore, quite a few functions were removed in this commit.

The multi-range chi2 fit is now also validated by the multi-range fit
unit test in `testRooAbsPdf`.

This is a follow-up to PR root-project#11455 (commit fa10523 in particular),
where the same change was already make for regular likelihoods.
It can be checked at runtime if a given `RooAbsReal` is a pdf or not.
Like this, we also don't need a separate override of
`createChi2(RooDataSet &)` in RooAbsPdf.
This is achieved in the same was as in `createNLL()`, by forwarding the
configuration options to the `RooAbsOptTestStatistic` base class.
@root-project root-project deleted a comment from phsft-bot Sep 17, 2023
@root-project root-project deleted a comment from phsft-bot Sep 17, 2023
@root-project root-project deleted a comment from phsft-bot Sep 17, 2023
@root-project root-project deleted a comment from phsft-bot Sep 17, 2023
@root-project root-project deleted a comment from phsft-bot Sep 17, 2023
@root-project root-project deleted a comment from phsft-bot Sep 17, 2023
@root-project root-project deleted a comment from phsft-bot Sep 17, 2023
@root-project root-project deleted a comment from phsft-bot Sep 17, 2023
@root-project root-project deleted a comment from github-actions bot Sep 17, 2023
@phsft-bot
Copy link
Collaborator

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/default
How to customize builds

After adding support for subrange fits with the `RooXYChi2Var`, it
initially didn't work because the y-value errors were missing in the
dataset. This is because `RooDataSet::reduce()` is not copying the
errors over to the reduced dataset, which is a bug.

Fortunately, there is a straighforward solution. To create the reduced
`RooDataSet`, it now doesn't use some buggy private constructor (that is
now removed), but instead the trusty `RooAbsData::emptyClone()` method,
for which I fixed the problem with the errors not being copied already
some time ago.
@phsft-bot
Copy link
Collaborator

Build failed on windows10/default.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Failing tests:

@github-actions
Copy link

Test Results

       10 files         10 suites   2d 3h 23m 50s ⏱️
  2 492 tests   2 487 ✔️ 0 💤 5
23 851 runs  23 846 ✔️ 0 💤 5

For more details on these failures, see this check.

Results for commit dc693dc.

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

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

LGTM!

@guitargeek guitargeek merged commit 6426d90 into root-project:master Sep 18, 2023
9 of 14 checks passed
@guitargeek guitargeek deleted the roofit_chi2 branch September 18, 2023 09:03
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.

None yet

3 participants