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