root icon indicating copy to clipboard operation
root copied to clipboard

Issue with `hadd` when first file has empty tree

Open rankunlin opened this issue 2 years ago • 4 comments

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

  1. ROOT version: 6.26/06
  2. Operating system: macosx64

dummyFiles.zip

rankunlin avatar Mar 20 '23 15:03 rankunlin

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?

pcanal avatar Mar 28 '23 19:03 pcanal

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

rankunlin avatar Apr 26 '23 13:04 rankunlin

Related to https://github.com/root-project/root/issues/14558 . A good solution is to intervene directly in the Merge function of TTree.

dpiparo avatar Feb 28 '24 06:02 dpiparo

@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.

MoAly98 avatar Jun 20 '24 09:06 MoAly98

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:

github-actions[bot] avatar Mar 03 '25 06:03 github-actions[bot]

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:

github-actions[bot] avatar Mar 04 '25 06:03 github-actions[bot]

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:

github-actions[bot] avatar Mar 05 '25 06:03 github-actions[bot]