Repository navigation
[hist] Reset all statistics in TProfile2D/3D::Divide - #23775
Draft
Elvand-Lie wants to merge 1 commit into
Draft
Elvand-Lie wants to merge 1 commit into
Elvand-Lie wants to merge 1 commit into
Conversation
Both Divide overloads rebuilt higher-axis moments on top of the target's old statistics. Reset every sum their bin loops accumulate before rebuilding the result. In TProfile3D, use the Z bin index in the two-input overload and accumulate the Z first and second moments correctly in the single-input overload. Cover both overloads with distinct axis centers and previously filled targets. Also check an empty 3D target and the in-place Z variance. Assisted-by: codex:gpt-6.1-sol Assisted-by: claude-code:claude-opus-5-5
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull request:
Changes or fixes:
TProfile2D::DivideandTProfile3D::Dividereturn wrong statistics for the Y and Z axes:If
resalready held a point at (3.5, 9, 5) before the division, master givesGetMean(2) = 5.5andGetMean(3) = 7.5instead of 1 and 25.TProfile2DgivesGetMean(2) = 5.5in the same situation.There are three causes:
Divideoverloads ofTProfile2DandTProfile3Dreset onlyfEntries,fTsumw,fTsumw2,fTsumwxandfTsumwx2. The loop then adds the new Y and Z contributions (in 3D also XZ, YZ and T) to the old sums.Divide(h1)always divides a filled profile, so it is always affected. The 1DTProfile::Divide(h1)already resets all of its sums.TProfile3D::Divide(h1, h2)takes the Z bin center at the Y bin index:fZaxis.GetBinCenter(biny).TProfile3D::Divide(h1)accumulatesfTsumwz += uandfTsumwz2 += u*zinstead ofu*zandu*z*z.The fix resets every sum each loop accumulates, uses
binz, and corrects the two Z moments.Four tests in
hist/hist/test/test_TProfile.cxxcover both classes and both overloads. They divide into filled targets, use axes whose X, Y and Z bin centers differ, and check the Z standard deviation.ctest -R '^gtest-hist-hist-'passes: 32 tests, 0 failures, on Linux with a minimal build.Checklist:
Codex (gpt-6.1-sol) implemented the fix and the tests; Claude Code (claude-opus-5-5) found the bugs and validated them.