[hist] function to get sum of weights including under/overflows#18232
[hist] function to get sum of weights including under/overflows#18232hageboeck merged 6 commits intoroot-project:masterfrom
Conversation
Test Results 19 files 19 suites 5d 4h 17m 43s ⏱️ For more details on these failures, see this check. Results for commit 3ea90b0. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Hello @ferdymercury,
I would try to copy as few code as possible, so I find the suggestion of the person that opened the issue quite reasonable:
GetSumOfWeights(bool includeOverflow = false)
The function continues to work, and internally, you change:
- Int_t binx,biny,binz;
- for(binz=1; binz<=fZaxis.GetNbins(); binz++) {
+ const auto zMax = overflow ? fZaxis.GetNbins()+2 : fZaxis.GetNbins()+1;
+ for(Int_t binz = overflow ? 0 : 1; binz < zMax; binz++) {This would even reduce the calls to GetNbins() during the loops.
What do you think?
|
Thanks for the review! |
as suggested by stephan
Yes, that's a good approach! But don't make the implementation virtual, so the compiler can do the best job. You could call it |
…to header as suggested by hageboeck
hageboeck
left a comment
There was a problem hiding this comment.
Less code, less variables. What do you think?
Co-authored-by: Stephan Hageboeck <[email protected]>
Agreed and pushed, thanks for the idea ! :) |
hageboeck
left a comment
There was a problem hiding this comment.
Thanks, LGTM! Let's see what the CI says.
Thanks to you! Looking green. |
This Pull request:
Changes or fixes:
Fixes #8951
Checklist: