Error in <TChain::LoadTree>: Cannot find tree in root file

hello experts
i got this error when use rdataframe to add new column to dataset:
Error in <TChain::LoadTree>: Cannot find tree with name fitter_tree in file DYJetsToLL_LHEFilterPtZ-650ToInf_MatchEWPDG20_TuneCP5_13TeV-amcatnloFXFX-pythia8.root

the code is here:
import ROOT
fileName = "DYJetsToLL_LHEFilterPtZ-650ToInf_MatchEWPDG20_TuneCP5_13TeV-amcatnloFXFX-pythia8.root"
treeName = "tnpEleTrig"
d = ROOT.RDataFrame(treeName, fileName)
df=d.Define("weight_new", "2")

the root file structure is like this:
Screen Shot 2022-09-13 at 14.41.30
i’m not sure get the tree here since there’s another layer tnpEleTrig?

Hi @yiruole ,

looking at the picture, the tree name is fitter_tree, inside directory tnpEleTrig. Have you tried with treeName="tnpEleTrig/fitter_tree"?

If that does not work, can you please share the file with us so we can take a look?

Cheers,
Enrico

thanks, this works.
there’s another question about Snapshot in RDataFrame.
i defined a new branch weight_new and trying to save in tree tnpEleTrig/fitter_tree by doing this:
fileName = "DYJetsToLL_LHEFilterPtZ-650ToInf_MatchEWPDG20_TuneCP5_13TeV-amcatnloFXFX-pythia8.root"
treeName = "tnpEleTrig/fitter_tree"
d = ROOT.RDataFrame(treeName, fileName)
df=d.Define("weight_new", "2")
df.Snapshot("tnpEleTrig/fitter_tree", "newfile.root")

but i got error like this:

i dont know what the ‘third argument’ should be? thank you

I saw you opened Save new root file with Snapshot in RDataFrame ,
I guess we can continue the discussion there.

1 Like

Thank you, but I don’t see any reply on that, is it my network wrong