Merging ntuples

Hi all,

How can I merge lots of (2000) root files (ntuples)? I tried two different things:

hadd g4numiv6_minervame_me000z200iALL.root g4numiv6_minervame_me000z200i_^ast.root and hadd g4numiv6_minervame_me000z200iALL.root `ls g4numiv6_minervame_me000z200i_^ast.root …

After compiling, these gave same error:

‘‘Warning in TFile::Init: no keys recovered, file has been made a Zombie’’

Do you have any idea about this?

Best,
Nilay

Hi,

You should be able to use the hadd command line tool

Do hadd --help to see more

Lorenzo

Hi moneta,

Thank you for your reply.

after using hadd --help, this is the result :

Usage: hadd [-f[0-9]] [-k] [-T] [-O] [-n maxopenedfiles] [-v verbosity] targetfile source1 [source2 source3 …]
This program will add histograms from a list of root files and write them
to a target root file. The target file is newly created and must not
exist, or if -f (“force”) is given, must not be one of the source files.
Supply at least two source files for this to make sense… :wink:
If the option -k is used, hadd will not exit on corrupt or non-existant input files but skip the offending files instead.
If the option -T is used, Trees are not merged
If the option -O is used, when merging TTree, the basket size is re-optimized
If the option -v is used, explicitly set the verbosity level; 0 request no output, 99 is the default
If the option -n is used, hadd will open at most ‘maxopenedfiles’ at once, use 0 to request to use the system maximum.
When -the -f option is specified, one can also specify the compression
level of the target file. By default the compression level is 1, but
if “-f0” is specified, the target file will not be compressed.
if “-f6” is specified, the compression level 6 will be used.
if Target and source files have different compression levels
a slower method is used

These are the other error:

Error in TFile::ReadBuffer: error reading all requested bytes from file g4numiv6_minervame_me000z200iALL.root, got 0 of 94105
Error in TKey::ReadFile: Failed to read data.
Error R__unzip_header: error in header
R__unzip: error -5 in inflate (zlib)
Info in TFileMerger::MergeRecursive: could not read object for key {dk2nuTree, g4numi Neutrino ntuple}

Try: ls -al g4numiv6_minervame_me000z200iALL.root

my apologies but after hadd g4numiv6_minervame_me000z200iALL.root `ls g4numiv6_minervame_me000z200i_^ast.root commands, should I use this one: ls -al g4numiv6_minervame_me000z200iALL.root

Try:

rm -f g4numiv6_minervame_me000z200iALL.root
hadd g4numiv6_minervame_me000z200iALL.root `ls g4numiv6_minervame_me000z200i_^ast.root`

Unfortunately, it did not work and these are the errors:

Error in TBasket::Streamer: The value of fKeylen is incorrect (-12469) ; trying to recover by setting it to zero
Error in TBasket::Streamer: The value of fObjlen is incorrect (-966485925) ; trying to recover by setting it to zero
Error in TBasket::Streamer: The value of fNbytes is incorrect (-293273683) ; trying to recover by setting it to zero
Error in TBasket::Streamer: The value of fObjlen is incorrect (-1007292795) ; trying to recover by setting it to zero
Error in TBasket::Streamer: The value of fNbytes is incorrect (-590605459) ; trying to recover by setting it to zero
*** glibc detected *** hadd: malloc(): memory corruption: 0x0000000002f2b040

Do not have enough free disk space for the new file?

I think yes this seems memory corruption. Now, I understand the problem but I don’t know how to solve. Thank you for your time.

I think yes this seems memory corruption.Now, I understand the problem but I don’t know how to solve.

Humm … are the input file corrupted or is hadd producing wrong files?

I solved the problem by using

TChain dk2nuTree = new TChain(“dk2nuTree”);
dk2nuTree->Add("/pnfs/dune/…_
.root");

in my script. But I also noticed that hadd produced wrong files, the input file is not corrupted.

Best,
N.

It is not clear why hadd would have failed then.

But using TChain is actually as performance and save you a lot of disk space (no need to duplicate the files).

1 Like

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