Issue with `hadd`

Hello,

I found a strange issue when I tried to hadd 2 root files with TTrees. You may find my dummy root files attached. In dummyFile0.root, there’re 1000 events in the dummyTree; While in dummyFile1.root, the tree is empty. So when I hadd 2 files, like

hadd dummyFile01.root dummyFile0.root dummyFile1.root

Everything is okay, and I can get what I want in the merged tree. While if I do like

hadd dummyFile10.root dummyFile1.root dummyFile0.root

I open the merged dummyFile10.root, and tried to do get entries like

root [1] dummyTree->GetEntries()
(long long) 1000

It looks okay. But if I 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 it may be due to I merge an empty tree with others, and I put the empty tree in the first place in merging, so ROOT is trying get a variable from an empty pointer? Would you pls take a look? Thanks! The reason I ask the question is in reality I wanted to merge multiple files, and I can’t always confirm in merging the first tree is empty or not.

Cheers,
Kunlin


_ROOT Version: 6.26/06
_Platform: macosx64


It seems I can’t upload root files as I’m a new user…

Attach the output of:
root -b -q dummyFile0.root -e 'dummyTree->Print();'
root -b -q dummyFile1.root -e 'dummyTree->Print();'

Thanks lot! Here it is:

Attaching file dummyFile0.root as _file0...
(TFile *) 0x7f9675f2df60
******************************************************************************
*Tree    :dummyTree :                                                        *
*Entries :     1000 : Total =           17539 bytes  File  Size =      10707 *
*        :          : Tree compression factor =   1.73                       *
******************************************************************************
*Br    0 :index     : index/L                                                *
*Entries :     1000 : Total  Size=       8570 bytes  File Size  =       1650 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   4.90     *
*............................................................................*
*Br    1 :dummyVariable : dummyVariable/D                                    *
*Entries :     1000 : Total  Size=       8610 bytes  File Size  =       7672 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.05     *
*............................................................................*
Attaching file dummyFile1.root as _file0...
(TFile *) 0x7fe267fd73b0
******************************************************************************
*Tree    :dummyTree :                                                        *
*Entries :        0 : Total =            1539 bytes  File  Size =       1547 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************
*Br    0 :index     : index/L                                                *
*Entries :        0 : Total  Size=        570 bytes  File Size  =         77 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :dummyVariable : dummyVariable/D                                    *
*Entries :        0 : Total  Size=        610 bytes  File Size  =         85 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*

This output looks fine (the second tree has 0 entries). Try:
root -b -q dummyFile0.root -e 'dummyTree->Show(0);'
root -b -q dummyFile1.root -e 'dummyTree->Show(0);'

Well it looks also normal to me:

Attaching file dummyFile0.root as _file0...
(TFile *) 0x7f9b7781ca50
======> EVENT:0
 index           = 0
 dummyVariable   = 0.261287
Attaching file dummyFile1.root as _file0...
(TFile *) 0x7f7a51b85ff0
Error in <TTree::Show()>: Cannot read entry 0 (entry does not exist)

It does seem that hadd is indeed ‘confused’ by the zero length TTree as a first file. Can you please open an issue on github?

Thx! So the Issue with hadd” #12510 is posted on github.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.