'Merge files using Hadd

I am attempting to merge three ntuples (just an example but there are more) stored in a directory that are labeled as the following:

[1] mc16a_SUSY.root
[2] mc16d_SUSY.root
[3] mc16e_SUSY.root
[4] ......

To do this I am using the command hadd (hadd outputfile inputfiles..)

os.system(hadd -f Combined_SUSY_SAMPLES.root mc16*SUSY*.root)

For the output file I want to combine all files with mc16 and SUSY in the file name

But I receive the error:


hadd Target file: Combined_SUSY_SAMPLES.root

hadd compression setting for all output: 1

hadd Source file 1: mc16*SUSY*.root

Error in <TFile::TFile>: file mc16*SUSY*.root does not exist

Error in <TFileMerger::AddFile>: cannot open file mc16*SUSY*.root

hadd exiting due to error in mc16*SUSY*.root

It states that there aren't any files with mc16*SUSY*.root but these files do exist. Any solutions? Thanks for the help in advance.

I use the "*" because there are to many files to list them individually.



Solution 1:[1]

I'm late to respond here, but could it be that you don't have the full path to the files? Some databases will send you the file names with certain commands, but not the absolute locations. It could be that you need to append the folder to the beginning of the filename.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ryan Dorrill