Adding trees with different names using TChain

Dear ROOT experts,

I am trying to add trees with different names using TChain. For eg, I want to add ‘SUSYGluGluToHToAA_AToGG_M_60_TuneCUETP8M1_13TeV_pythia8_13TeV’ and SUSYGluGluToHToAA_AToGG_M_55_TuneCUETP8M1_13TeV_pythia8_13TeV’ together.

Is the following allowed?

for fi,f in enumerate(Files):
     ch = TChain('SUSYGluGluToHToAA_AToGG_M_*_TuneCUETP8M1_13TeV_pythia8_13TeV')
     ch.Add(f[0])

If this is not allowed, then would an easier solution be to rename the trees, such that it is consistent for all files?

Thanks in advance!
Tanvi

Hi,
I checked the TChain page and what you are proposing shouldn’t work.
Rename the tree instead for sure will work.

Cheers,
Stefano

Thanks Stefano! I will try that solution.

Hi Tanvi,
like @Dilicus says TChain does not support glob patterns for tree names (e.g. no * wildcard allowed).
Renaming the Trees would certainly make things easier.

Otherwise, the way to add trees with different names (but compatible structure) to a TChain is:

TChain c;
c.Add("file1.root/tree1");
c.Add("file2.root/treename2");

(see the doc).

Cheers,
Enrico

Thanks Enrico! This worked perfectly for my case.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.