Skip to content

[treeplayer] Fix TTreeFormula vector index into vector-of-vectors#22601

Open
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:issue-19290
Open

[treeplayer] Fix TTreeFormula vector index into vector-of-vectors#22601
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:issue-19290

Conversation

@guitargeek

@guitargeek guitargeek commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

When a vector-type branch was used as the index of a vector-of-vectors branch, TTreeFormula computed the wrong number of instances and emitted out-of-bounds errors. For example, with v2 a vector used as an index:

vv1[v2][0] looped over the summed size of all sub-vectors of vv1
instead of the length of v2, printing a spurious extra
instance and "index out of bound" errors.
vv1[0][v2] silently dropped its last instance.

Two issues in the multi-variable-dimension machinery:

  1. DefineDimensions registered the inner jagged dimension as a variable dimension even when the outer dimension is selected through a variable "gather" index (-2) and the inner dimension is pinned to a constant. In that configuration the formula does not iterate over the jagged sub-dimension, so the manager must not sum the physical sub-sizes; the number of instances is simply the length of the index variable.

  2. GetRealInstance performed a premature out-of-bounds check against the physical sub-size for a variable inner index (-2), using the raw instance number (the index of the index variable) rather than the evaluated index. The real bounds are already checked after evaluating the index variable.

Adds regression tests to treeplayer_regressions.

Closes #19290 (originally JIRA ROOT-8726).

🤖 Done with the help of Claude Code (Claude Opus 4.8)

When a vector-type branch was used as the index of a vector-of-vectors
branch, TTreeFormula computed the wrong number of instances and emitted
out-of-bounds errors. For example, with v2 a vector<int> used as an index:

  vv1[v2][0]  looped over the summed size of all sub-vectors of vv1
              instead of the length of v2, printing a spurious extra
              instance and "index out of bound" errors.
  vv1[0][v2]  silently dropped its last instance.

Two issues in the multi-variable-dimension machinery:

1. DefineDimensions registered the inner jagged dimension as a variable
   dimension even when the outer dimension is selected through a variable
   "gather" index (-2) and the inner dimension is pinned to a constant.
   In that configuration the formula does not iterate over the jagged
   sub-dimension, so the manager must not sum the physical sub-sizes; the
   number of instances is simply the length of the index variable.

2. GetRealInstance performed a premature out-of-bounds check against the
   physical sub-size for a variable inner index (-2), using the raw
   instance number (the index of the index variable) rather than the
   evaluated index. The real bounds are already checked after evaluating
   the index variable.

Adds regression tests to treeplayer_regressions.

Closes root-project#19290 (originally JIRA ROOT-8726).

🤖 Done with the help of [Claude Code](https://claude.com/claude-code) (Claude Opus 4.8)
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.

TTreeFormula: Using vector branch value as index in vector of vectors gives unexpected results

1 participant