root
root copied to clipboard
[RF] Vectorize weight evaluation with ```RooDataHist::weights()```
This PR improves the speed for evaluating weights in RooHistPdf
and RooHistFunc for one dimensional histograms with no interpolation.
In the future, RooDataHist::weights() will be extended to cover
cases with higher dimensions and interpolation.
The function RooDataHist::weights() was implemented to enable
vectorized evaluations of bin weights. In RooHistPdf it is implemented
using the new function RooHistPdf::computeBatch(), which calls
RooDataHist::weights() in the case of no interpolation and 1D
histograms, and RooAbsReal::computeBatch() otherwise. In
RooHistFunc::computeBatch, RooDataHist::weights() is called in the
case of no interpolation and 1D histograms and is unchanged in the other cases.
RooDataHist::weights() splits the weight evaluation into two cases,
depending on whether the bins have uniform width. When the bins are uniform,
the bin width and thus the bin index are easily calculated. When they are not
uniform, bin indices are stored as a vector using RooAbsBinning::binNumbers,
(implemented in #11151) while the bin width is calculated using
RooAbsBinning::array().
This Pull request:
Changes or fixes:
Checklist:
- [x] tested changes locally
- [ ] updated the docs (if necessary)
Can one of the admins verify this patch?
@phsft-bot build
Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac1015/cxx17, mac11/cxx14, windows10/cxx14
How to customize builds
Build failed on ROOT-debian10-i386/soversion. Running on pcepsft10.dyndns.cern.ch:/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-performance-centos8-multicore/cxx17. Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-ubuntu18.04/nortcxxmod. Running on sft-ubuntu-1804-2.cern.ch:/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-ubuntu2004/python3. Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on windows10/cxx14. Running on null:C:\build\workspace\root-pullrequests-build See console output.
Failing tests:
Build failed on mac11/cxx14. Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on mac1015/cxx17. Running on macitois22.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Hello @HannaOlvhammar,
the ``` don't work in commit messages (at least the terminal and github don't react to them). I would recommend to remove them to make the commit message more readable. They are good for markdown-enabled things like the discussion on github or mattermost, though. 🙂 You're doing great with the commit message BTW. It's very informative. Maybe don't promise to do xxx in the message, though. If you don't manage to do it for some reason, the message will for all eternity promise that you will. You could e.g. say "this change will allow for vectorising xxxx"
Thank you both for your comments! While making the changes I found better way to write RooDataHistweights(), mainly removing the check for uniform bins since, in the end, both the uniform and non-uniform binning cases were equally fast when applied to a histogram with uniform bins.
@phsft-bot build
Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac1015/cxx17, mac11/cxx14, windows10/cxx14
How to customize builds
Build failed on ROOT-performance-centos8-multicore/cxx17. Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build See console output.