Skip to content

Conversation

@Zeff020
Copy link
Contributor

@Zeff020 Zeff020 commented Jan 10, 2023

This Pull request:

Changes or fixes:

Adds offsetting named argument to RooAbsPdf::fitTo() as requested in #11856. I have decided to use the naming convention for the named argument options that was already present in RooAbsPdf::CreateNLL() to avoid confusion and for the potential case that the other named argument options in the latter will also be added to RooAbsPdf::fitTo()

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #

@phsft-bot
Copy link

Can one of the admins verify this patch?

@guitargeek
Copy link
Contributor

@phsft-bot build

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on mac12/noimt.
Running on macphsft17.dyndns.cern.ch:/Users/sftnight/build/jenkins/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2023-01-10T13:32:09.237Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/core/base/src/TDirectory.cxx:1245:7: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]

Failing tests:

And 63 more

@guitargeek guitargeek changed the title Added offsetting to RooAbsPdf::fitTo [RF] Added offsetting to RooAbsPdf::fitTo Jan 10, 2023
Comment on lines 1567 to 1572
/// <tr><td> `Offset(std::string const& mode)` <td> Likelihood offsetting mode. Can be either:
/// - `"none"` (default): no offsetting
/// - `"initial"`: Offset likelihood by initial value (so that starting value of FCN in minuit is zero).
/// This can improve numeric stability in simultaneous fits with components with large likelihood values.
/// Note that this named argument only works if combined with `modularL` or `Parallelize`. For non-modular
/// likelihoods offsetting is enabled on the likelihood itself.
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
/// <tr><td> `Offset(std::string const& mode)` <td> Likelihood offsetting mode. Can be either:
/// - `"none"` (default): no offsetting
/// - `"initial"`: Offset likelihood by initial value (so that starting value of FCN in minuit is zero).
/// This can improve numeric stability in simultaneous fits with components with large likelihood values.
/// Note that this named argument only works if combined with `modularL` or `Parallelize`. For non-modular
/// likelihoods offsetting is enabled on the likelihood itself.

The RooAbsPdf::fitTo() method already has a place where the offsetting is explained, linking to the documentation of createNLL(). Let's not repeat this here.

I would suggest to not change the documentation in this PR, but instead just trying to make the offsetting work in fitTo().

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.

Hi @Zeff020, thanks for opening PR!

Have you tested this change? If I try out the code now with the basic Gaussian NLL from the rf101 example (as always), if always errors out:

gauss.fitTo(*data, ModularL(true), Offset(true), Parallelize(true));

Gives:

[#0] ERROR:InputArguments -- RooAbsPdf::createNLL(gauss) ERROR: argument ModularL not allowed in this context
[#0] ERROR:InputArguments -- RooAbsPdf::createNLL(gauss) ERROR: argument ModularL not allowed in this context
[#0] ERROR:InputArguments -- RooAbsPdf::createNLL(gauss) ERROR: illegal combination of arguments and/or missing arguments
terminate called after throwing an instance of 'std::logic_error'
  what():  In RooMinimizer constructor: Selected likelihood evaluation but a non-modular likelihood was given. Please supply ModularL(true) as an argument to createNLL for modular likelihoods to use likelihood or gradient parallelization.

And when I don't use Parallelize(true), I even get a segfault.

Do you also see this behavior? If yest, can you fix it please?

@Zeff020
Copy link
Contributor Author

Zeff020 commented Jan 17, 2023

Hi @guitargeek, my most recent commit should fix the issue that you encountered, at least it does for me locally.

@guitargeek
Copy link
Contributor

Cool, thanks! Okay I'll try it

@guitargeek
Copy link
Contributor

@phsft-bot build

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@guitargeek
Copy link
Contributor

Hi @Zeff020! There are some tests failing now. Can you check what's going on there? Let me know on Mattermost if you need help

@Zeff020 Zeff020 force-pushed the rooabspdf-offset-fix branch from 7b03777 to 85cb30b Compare January 24, 2023 16:04
@Zeff020
Copy link
Contributor Author

Zeff020 commented Jan 24, 2023

Hi @guitargeek, I've amended my most recent commit, could you try the build and tests again? All problems should be resolved now.

@guitargeek
Copy link
Contributor

@phsft-bot build

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04/nortcxxmod.
Running on sft-ubuntu-1804-2.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-24T16:23:52.793Z] FAILED: tmva/sofie/test/CMakeFiles/SofieCompileModels_ONNX.util

@phsft-bot
Copy link

Build failed on mac11/cxx14.
Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

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.

LGTM, thanks for the fix! I tried out the fit in the first RooFit tutorial now:

gauss.fitTo(*data, PrintLevel(-1), Save(), ModularL(true), Offset(true), Parallelize(false))->Print();

And I put some printouts in the RooMinimizer to see if the offsetting option is correctly propagated. And it is.

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.

4 participants