Skip to content

Conversation

@guitargeek
Copy link
Contributor

JGCarroll and others added 11 commits January 9, 2023 18:00
There is a problem with the usage of `abs` and not `std::abs`, because `abs`
has no overload for doubles. By passing a double to `abs` without `std::`, it
gets rounded to an `int`, which is a bug.
As noted in d008860, using `abs()` without `std::` can be very dangerous
because there might be no overload for floating point numbers.

To make sure that no bugs associated to this can happen, I suggest to
avoid using `abs()` without `std::` all the way in RooFit.

Also, to go with modern C++ all the way, the occurences of `fabs()` and
`std::fabs()` are also replaced with `std::abs()`.
This is a followup to commit 8679898. In that commit, the RooPlot was
changed to not create an internal clone of the plot variables anymore.

That change was very effective in speeding up RooFit, because it
resulted in huge speedups when plotting complicated pdfs that are
expensive to clone.

However, in rare cases like for the RooUnitTest, it is necessary that
the RooPlot owns the plot plot variables to avoid dangling pointers when
the RooPlot lives longer than the original plot variables.

To support these cases, a new member function
`RooPlot::createInternalPlotVarClone()` is introduced. It can be used to
convert the RooPlot to a plot that owns a clone of the plot variable at
any point in time of the RooPlot lifetime.
In the `rf205` tutorial and the associated stressRooFit test, the `bkg`
RooAddPdf was created using the `sig1frac`, while it is clearly the idea
to use the `bkg1frac` parameter.

This is fixed in this commit, also fixing the name of the `bkg1frac`
parameter, which was accidentally set to `sig1frac` (probably a
copy-paste error).

However, to not change the output of the tutorial and the stressRooFit
test, the value of `bkg1frac` was set to the same value as `sig1frac`,
such that this commit only fixes the model but doesn't change the
tutorial and test output.
As the file will be anyway touched and significantly changed in the
nexts commit.
Since ROOT 6.28, we have a `RooPower` class to represent power laws.

The unit tests in `testTestStatistics` used power laws implemented as
RooGenericPdf everywhere, and we can now use the `RooPower` class to
avoid numeric integrals, which also helps to reduce the logging output.
This is done to avoid some unnecessary info printout.
I recently learned about this trick to make the formulation of large
test matrices more concise.
Add optional `doOffset` option to `RooAbsPdf::extendedTerm()`.

The offsetting adds a counterterm where the expected number of events
equals the observed number of events. This constant shift results in a
term closer to zero that is approximately chi-square distributed. It is
useful to do this also when summing multiple NLL terms to avoid numeric
precision loss that happens if you sum multiple terms of different
orders of magnitude.

It is one of the necessary ingredients to completely implement the new
`Offset("bin")` option.
This commit does the necessary changes to implement the `Offset("bin")`
feature for fits to RooDataHists with both the BatchMode and the old
RooFit.

Some variables and enums are also renamed to be more clear or concise
(for example, the term `Off` to denote no offsetting can be misleading
and was replaced with `None`).
Test the new `Offset("bin")` feature for fits to RooDataHists over the
test matrix that is the tensor product of `BatchMode()`, doing and
extended fit, and SumW2 correction. The test should compute the
likelihood for a template PDF created from the data, and it should be
numerically compatible with zero.
@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 guitargeek merged commit 9308510 into root-project:v6-28-00-patches Jan 9, 2023
@guitargeek guitargeek deleted the v6-28-00-patches_roofit_backports_3 branch January 9, 2023 23:18
@phsft-bot
Copy link

Build failed on ROOT-ubuntu2004/python3.
Running on root-ubuntu-2004-3.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-09T23:55:07.711Z] CMake Error at /home/sftnight/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1138 (message):

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.

3 participants