I have four files (Ci.root, i = 1,2,3,4) each with a single tree called Ci. These trees each contain only a single branch (called ampl) of std:: objects. The way that these files are produced, they have identical numbers of entries (indeed, the same-numbered entries in each tree are from the same physical event).
I would like a short program that can combine the ampl branches from the four trees into different branches of a single tree, in a single file. This could be by adding branches to one of the original Ci trees, or making an entirely new file with a new tree.
I am having trouble writing such a program myself, and I’m thinking that there must be a simple way to accomplish this. For example once I tried writing my own program to add histograms from different files, but then I learned of the “hadd” program provided by ROOT. Is there an equivalent program for trees and branches? Or perhaps someone has already done this and can provide code?