lovell
August 22, 2018, 10:58am
1
ROOT Version: 6.08/06
Platform, Compiler: x86_64-slc6-gcc62
Hi,
I’m trying to take two TTrees with the same name, each in a different TDirectory in a file, and merge them. I am having trouble figuring out how to do this, either with TChain or hadd. TChain doesn’t like wildcards like
TChain ch("*/TreeName")
ch.Add("file1.root")
ch.Add("file2.root")
ch.Draw("x")
and using hadd doesn’t work given the different directory names.
How would I achieve this? Apologies if this is duplicated somewhere.
Edit: to clarify, the structure is
file.root
1.1 directory1
1.1.1 TreeName
1.2 directory2
1.2.1 TreeName
Many thanks,
George
beojan
August 22, 2018, 1:18pm
2
You can add the trees to a TList
then use TTree::Merge
.
lovell
August 22, 2018, 1:20pm
3
I have since found that the easiest way is to use (here for separate files, I’m sure it works within a single file too):
TChain ch("TreeName")
ch.AddFile("file1.root",TChain::kBigNumber,"directory1/TreeName")
ch.AddFile("file2.root",TChain::kBigNumber,"directory2/TreeName")
ch.Draw("x")
Added this in case anyone else searches this in the future
system
Closed
September 5, 2018, 1:34pm
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.