Improve logic to refresh branch addresses of TChain friends #19322
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.
Fixes #16805
Part of the logic of TChain::LoadTree deals with updating the status of friend
trees. First, the current entry is loaded on all friends. In case the friend
tree is a chain that needs to switch to a new tree, the branch addresses of the
friend are also updated.
This logic only considered the case of top-level friends of a TChain. Notably,
it did not consider the case of a main TChain where one (or more) of the trees
in the chain have themselves some friends, but not the main chain itself:
TChain c1
--> TTree t1 TChain c2
This commit condenses the logic that updates friends in a separate method of
TChain. The new method is called in TChain::LoadTree, either in the pre-existing
case of top-level friends or in the new case of friends of the current tree.
The new method, called RefreshFriendAddresses, needs to act:
In the two scenarios, either we load the global entry of the chain on the
friends, or the local entry of the current tree. This is done to conserve proper
alignment.