Issue with `hadd` when first file has empty tree
Describe the bug
It seems hadd is confused by the zero length TTree as a first file. Pls find dummy root files in the attached ZIP to reproduce the issue. In dummyFile0.root, there're 1000 events in the dummyTree; While in dummyFile1.root, the tree is empty. So when hadd 2 files, like
hadd dummyFile01.root dummyFile0.root dummyFile1.root
Everything is okay. While if you do like
hadd dummyFile10.root dummyFile1.root dummyFile0.root
And you open the merged dummyFile10.root to get entries like
root [1] dummyTree->GetEntries()
(long long) 1000
It looks okay. But if you show the first event, like
root [1] dummyTree->Show(0)
======> EVENT:0
index = 0
dummyVariable = 2.13654e-306
The dummyVariable is definitely non-sense. It should be 0.261287 as it is in the dummyFile0.root. I guess if put the empty tree at the first in merging, ROOT is trying get a variable from an empty pointer?
Expected behavior
root [1] dummyTree->Show(0)
======> EVENT:0
index = 0
dummyVariable = 0.261287
Setup
- ROOT version: 6.26/06
- Operating system: macosx64
So far I can not reproduce this issue. I tried master on macos, 6.20 on macos. master on Linux and 6.26.06 on Linux.
Would be able to try with a newer version of ROOT? Or can you try on Linux? If neither are an option, can you provide the file dummyFile??.root that you can produce?
I tried ROOT Version: 6.28/00 on Linux and the issue is still there. So I attached the merged root files here. dummyFiles.zip
Related to https://github.com/root-project/root/issues/14558 . A good solution is to intervene directly in the Merge function of TTree.
@dpiparo We are running into this problem and were wondering If there is an example on how to change the merge function for TTree to avoid the corrupt target file? Our issue is that the files we Hadd contain many trees, so it is not guaranteed that we always find a file where all the trees are non-empty.
Hi @pcanal,
It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.
Sincerely, :robot:
Hi @pcanal,
It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.
Sincerely, :robot:
Hi @pcanal,
It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.
Sincerely, :robot: