Merging TTrees from different TDirectorys

ROOT Version: 6.08/06
Platform, Compiler: x86_64-slc6-gcc62

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")

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

  1. file.root
    1.1 directory1
    1.1.1 TreeName
    1.2 directory2
    1.2.1 TreeName

Many thanks,

You can add the trees to a TList then use TTree::Merge.

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")

Added this in case anyone else searches this in the future

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