Merging files with trees in subdirectories


I have several root files of which I’d like to merge a tree
in a subdirectory.

Eg, one file looks like:

root [1] TFile f(“myfile.root”)
root [2] TDirectory subdir = mysubdir
root [3]
root [4] .ls
KEY: TTree mytree;1 Tuple
root [5] mytree->Print()

*Tree :mytree : Tuple
*Entries : 1000 : Total = 1359880 bytes File Size =
646381 *

  •    :          : Tree compression factor =   2.09


However, I tried several examples on the web (expecially several
versions of hadd) and I didn’t manage to get a
final merged file with the merged mytree from all the files.

I mean, I manage to get a merged file with all the subdirectories, but
then if I look at the subdirectory I am interested in (namely mysubdir) I
don’t see mytree filled.

I am using ROOT Version 5.04/00.

Any suggestion on how I can proceed?


PS I can send a private link to my root files to whom asks me

use hadd ($ROOTSYS/bin/hadd)

hadd result.root file1.root … fileN.root

Version 5.10 recommended


[quote=“brun”]use hadd ($ROOTSYS/bin/hadd)

hadd result.root file1.root … fileN.root

Version 5.10 recommended


Hi Rene’, thanks!
However, I was wondering which is the operating system on which you run hadd.
I installed ROOT v 5.10 on my laptop (running Scientific Linux 3) and it crashes:

[lodovico@localhost ntpl]$ /usr/local/root-v5.10/bin/hadd results.root VubBLNP_BP_18.root VubBLNP_BP_19.root
Target file: results.root
Source file 1: VubBLNP_BP_18.root
Source file 2: VubBLNP_BP_19.root
Target path: results.root:/

*** Break *** segmentation violation
Generating stack trace…
0x038dd2d3 in index + 0x63 from /lib/tls/
0x08049af3 in main + 0x69b from /usr/local/root-v5.10/bin/hadd
0x03889e23 in __libc_start_main + 0xd3 from /lib/tls/
0x08049329 in __gxx_personality_v0 + 0x51 from /usr/local/root-v5.10/bin/hadd