Skip to content

[hist] Recalculate statistics for width-weighted projections - #23863

Open
Elvand-Lie wants to merge 1 commit into
root-project:masterfrom
Elvand-Lie:fix/projection-width-stats
Open

Elvand-Lie wants to merge 1 commit into
root-project:masterfrom
Elvand-Lie:fix/projection-width-stats

Conversation

@Elvand-Lie

@Elvand-Lie Elvand-Lie commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

This Pull request:

Changes or fixes:

Width-weighted histogram projections can retain statistics from the unweighted source histogram.

double y[] = {0., 1., 4.};
TH2D h("h", "", 2, 0., 2., 2, y);
h.Fill(0.5, 0.5); h.Fill(1.5, 2.);
auto p = h.ProjectionX("px", 1, 2, "width");
// Bin contents: 1, 3. Before: mean 1. After: mean 1.25.

The original statistics cannot be reused when integration includes bin widths. Recalculate the statistics for width-weighted TH2 projections and for both TH3 projection paths, even when the weighted total equals the original total. The recalculated moments use projected bin centers, since width-dependent event-level moments are not retained. Regression tests cover both TH2 projection axes and one- and two-dimensional TH3 projections.

Both regression tests fail on the base and pass with the fix. The full test_projections executable passes (5 tests) on Linux. The full ROOT test suite and other platforms were not run.

Checklist:

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

Codex (gpt-6.1-terra) implemented the fix and the tests. I reviewed the full diff and the tests.

@Elvand-Lie
Elvand-Lie force-pushed the fix/projection-width-stats branch 2 times, most recently from b16ab78 to a5ced24 Compare October 31, 2026 14:04
Bin-width integration changes projected weights, so source histogram statistics cannot be reused even when the total weight matches.

Assisted-by: codex:gpt-6.1-terra
@Elvand-Lie
Elvand-Lie force-pushed the fix/projection-width-stats branch from a5ced24 to 086a1c0 Compare October 31, 2026 14:05
@Elvand-Lie
Elvand-Lie marked this pull request as ready for review October 31, 2026 14:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant