Merging ROOT files with hadd

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.19.02
Platform: Windows 10
Compiler: Virtual Studio 2019

Trying to merge to root analysis files using hadd but when I do I am getting the following error.


I’ve double checked for mistakes in the file name and path so I’m pretty certain I’ve got that right, and I can’t think of any other reason I’d be getting this error. Any help would be much appreciated.

I can’t reproduce the problem with ROOT master:

C:\Users\bellenot\build\release\bin>hadd C:\Users\bellenot\Temp\test_hadd.root C:\Users\bellenot\build\release\tutorials\hsimple-test.12345-10 C:\Users\bellenot\build\debug\tutorials\hsimple-test.12345-09
Warning in <TClassTable::Add>: class ROOT::Detail::TTypedIter<class TEnumConstant> already in TClassTable
hadd Target file: C:\Users\bellenot\Temp\test_hadd.root
hadd compression setting for all output: 1
hadd Source file 1: C:\Users\bellenot\build\release\tutorials\hsimple-test.12345-10
hadd Source file 2: C:\Users\bellenot\build\debug\tutorials\hsimple-test.12345-09
hadd Target path: C:\Users\bellenot\Temp\test_hadd.root:/

Can you try to open the file in a ROOT session?

Yeah seems to work fine

And from the ROOT prompt, with TFile::Open() ?

Oh, I’m running hadd in one folder and the files are located in another. Do I need to place them in the same folder?

Nope. Just check the example I posted before…

I can’t seem to find it, can you link me or give me the name of the post? Thanks for the help

Well, that was an example with the regular hsimple.root files that I renamed to match (more or less) your file names…

Oh sorry you meant as part of this thread. I thought you were referring to another post you had made. Thanks I’ll try that

Yes, this one

And did you manage to open the file in the ROOT command prompt?

No, I think I might be using TFile::Open() incorrectly, I’m pretty new to ROOT. This is the error I’m getting


You forgot the quotes (it is a string), and please try with the full path. Something like:

auto f = TFile::Open("C:\\Users\\Stephen\\root_v6.19.02\\test\\GetDetector-60Co1.3325MeV-50000")


auto f = TFile::Open("C:/Users/Stephen/root_v6.19.02/test/GetDetector-60Co1.3325MeV-50000")

Ah of course. when I run root in the test folder it opens no problem, but running root in the bin folder where hadd is I’m still getting the error that the file does not exist

And you have the error with both backslashes \\ and forward slashes /?

Hadn’t tried \ \ , one minute

Yes the same issue

Wait works with / / just needed to include .root extension

hadd is working now using those file paths. Thank you very much, really appreciate it!

Oh yes, indeed, the file extension is needed…