[tree] Use the counter of the same object for variable-size arrays #24183
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 367 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.353
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #24183"
general
weight: 0.35
pcanal
AI DESCRIPTION BELOW
This Pull request:
Fixes counted arrays (
Double_t fX; //[fN]) in split objects that read the wrong number of elements when two objects of the same class are stored in top-level branches without a trailing dot. In that layout both objects have a sub-branch calledfN, andb.fXends up usinga.fNas its counter.Two bugs share one cause, looking the counter up by its short name. Each commit fixes one of them:
1.
[tree], write side: when the sub-branches are created,TBranchElement::Initfinds the counter withfTree->GetBranch("fN"), which returns the firstfNin the tree. The wrong link (fBranchCountand the leaf'sfLeafCount) is then stored in the file.2.
[treeplayer],TTreeReaderArray: even when the stored link is correct,TTreeReaderArraytakes only the counter's short name ("fN") and looks it up again, so it still findsa.fN. This bug stays hidden until commit 1 is applied. With commit 1 alone,Draw("b.fX")is correct butTTreeReaderArraystill reads 0 elements.Changes or fixes:
TBranchElement.cxx: a new helper,FindBranchCount(), looks for the counter among the sub-branches of the array's parent and falls back to the tree-wide search only if it isn't there. Basic-type arrays (TStreamerBasicPointer), arrays of objects (TStreamerLoop) and the MakeClass recovery path inReadLeavesMakeClassall use it.TTreeReaderArray.cxx:TArrayParameterSizeReadergets a constructor that takes the counter branch itself and creates the size reader from the counter's full name (b.fN,b.fV.fN). The size-reader setup inTDynamicArrayReadermoves intoSetSizeReader()so both constructors share it.testTBranchElementBranchCount(tree/tree/test/TBranchElementBranchCount.cxx, dictionaryBranchCountStruct.h):- unprefixed basic-type array, array of objects, and an array inside an embedded split member (
b.fV.fX): checks the stored counter (branch and leaf),TTreeReaderArraysize and values, andDraw;- controls that pass with and without the fix: prefixed names, a single object; and counted arrays inside
TClonesArray/std::vector, whose counters must stay the collection branch.The
Unprefixedtests fail on master. With only the first commit, they fail on theTTreeReaderArraychecks.Not in this PR: files written before this change still store the wrong counter, so they are still read incorrectly. The data on disk is complete pointing
b.fX's counter back tob.fNafter opening an old file reads0 1 2, so the file could be repaired when it is read. The options are discussed in #24146, and I'd do the repair as a follow-up once we agree on an approach.I can split the two commits into two PRs if you prefer.
Used Claude Opus 5.5, at High Effort
Checklist:
This PR fixes #24146