Joining TChains with Friends [PyRoot]

Hello,
I’m trying to join multiple files with friend trees for each.
Currently I create a »subchain« for each file and add the friends for this file. Then I add the »subchains« to a »mainchain«, but doing so, I lose the added friendchains.
Example:

import ROOT
import numpy as np
treefile = ROOT.TFile("tree.root", "RECREATE")
tree = ROOT.TTree("tree", "tree")
x = np.empty((1), dtype="float32")
tree.Branch("x", x, "x/F")
for i in range(10):
    x[0] = np.random.rand()
    tree.Fill()
treefile.Write()
treefile.Close()
del treefile,tree,x


friendfile = ROOT.TFile("friend.root", "RECREATE")
friendTree = ROOT.TTree("tree", "tree")
y = np.empty((1), dtype="float32")
friendTree.Branch("y", y, "y/F")
for i in range(10):
    y[0] = np.random.rand()
    friendTree.Fill()
friendfile.Write()
friendfile.Close()
del friendfile,friendTree,y


subchain=ROOT.TChain("tree")
subchain.Add("tree.root")
friendChain=ROOT.TChain("tree")
friendChain.Add("friend.root")
subchain.AddFriend(friendChain)
mainchain=ROOT.TChain("tree")
mainchain.Add(subchain)

print ROOT.RDataFrame(subchain).GetColumnNames()
print ROOT.RDataFrame(mainchain).GetColumnNames()

> { "x", "tree.y", "y" }
>{ "x" }

Is this the expected behavior ?

Cheers,
Moritz


ROOT Version: JupyROOT 6.18
Platform: CentOSLinux7
Compiler: gcc8


Did you try to have just 2 chains, a ‘mainchain’ and a ‘friendchain’ containing directly all the main files and all the friend files respectively?

Yes, that would be another possibility.
In my application, converting a chain like this to an RDataFrame and and accessing the values via AsNumpy this yields the error message :

Error in <TTreeReaderValueBase::CreateProxy()>: The tree does not have a branch called m_sv. You could check with TTree::Print() for available branches.

The values that are returned seem to be fine.
I’m currently not able to reproduced this problem in the provided example.