This program will merge compatible ROOT objects, such as histograms, Trees and RNTuples, from a list of root files and write them to a target root file.
In order for a ROOT object to be mergeable, it must implement the Merge() function. Non-mergeable objects will have all instances copied as-is into the target file. The target file must not be identical to one of the source files.
Syntax:
Flags can be passed before or after the positional arguments. The first positional (non-flag) argument will be interpreted as the targetfile. After that, the first sequence of positional arguments will be interpreted as the input files. If two sequences of positional arguments are separated by flags, hadd will emit an error and abort.
By default, any argument starting with -
is interpreted as a flag. If you want to pass filenames starting with -
you need to pass them after --
:
Note that in this case you need to pass ALL positional arguments after --
.
If a flag requires an argument, the argument can be specified in any of these ways:
All equally valid:
-j 16 -j16 -j=16
The first syntax is the preferred one since it's backward-compatible with previous versions of hadd. The -f flag is an exception to this rule: it only supports the -f[0-9]
syntax.
Note that merging multiple flags is NOT supported: -jfa
will be interpreted as -j=fa, which is invalid!
The flags are as follows:
- Parameters
-
-a | Append to the output |
-cachesize | <SIZE> Resize the prefetching cache used to speed up I/O operations (use 0 to disable). |
-d | <DIR> Carry out the partial multiprocess execution in the specified directory |
-dbg | Enable verbosity. If -j was specified, do not not delete partial files stored inside working directory. |
-experimental-io-features | <FEATURES> Enables the corresponding experimental feature for output trees. |
- See also
- ROOT::Experimental::EIOFeatures
- Parameters
-
-f | Force overwriting of output file. |
-f[0-9] | Set target compression level. 0 = uncompressed, 9 = highly compressed. Default is 101 (kDefaultZLIB). You can also specify the full compression algorithm, e.g. -f505. |
-fk | Sets the target file to contain the baskets with the same compression as the input files (unless -O is specified). Compresses the meta data using the compression level specified in the first input or the compression setting after fk (for example 505 when using -fk505) |
-ff | The compression level used is the one specified in the first input |
-j | [N_JOBS] Parallelise the execution in N_JOBS processes. If the number of processes is not specified, or is 0, use the system maximum. |
-k | Skip corrupt or non-existent files, do not exit |
-L | <FILE> Read the list of objects from FILE and either only merge or skip those objects depending on the value of "-Ltype". FILE must contain one object name per line, which cannot contain whitespaces or '/'. You can also pass TDirectory names, which apply to the entire directory content. Lines beginning with '#' are ignored. If this flag is passed, "-Ltype" MUST be passed as well. |
-Ltype | <SkipListed|OnlyListed> Sets the type of operation performed on the objects listed in FILE given with the "-L" flag. "SkipListed" will skip all the listed objects; "OnlyListed" will only merge those objects. If this flag is passed, "-L" must be passed as well. |
-n | <N_FILES> Open at most N files at once (use 0 to request to use the system maximum - which is also the default) |
-O | Re-optimize basket size when merging TTree |
-T | Do not merge Trees |
-v | [LEVEL] Explicitly set the verbosity level: 0 request no output, 99 is the default |
- Returns
- hadd returns a status code: 0 if OK, 1 otherwise
For example assume 3 files f1, f2, f3 containing histograms hn and Trees Tn
- f1 with h1 h2 h3 T1
- f2 with h1 h4 T1 T2
- f3 with h5 the result of will be a file x.root with h1 h2 h3 h4 h5 T1 T2 where
- h1 will be the sum of the 2 histograms in f1 and f2
- T1 will be the merge of the Trees in f1 and f2
The files may contain sub-directories.
If the source files contains histograms and Trees, one can skip the Trees with
Wildcarding and indirect files are also supported
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
will merge all files in myfil*.root
will merge file1.root, file2.root, all files in myfil*.root and all files in the indirect text file list.txt ("@" as the first character of the file indicates an indirect file. An indirect file is a text file containing a list of other files, including other indirect files, one line per file).
If the sources and and target compression levels are identical (default), the program uses the TChain::Merge function with option "fast", ie the merge will be done without unzipping or unstreaming the baskets (i.e. direct copy of the raw byte on disk). The "fast" mode is typically 5 times faster than the mode unzipping and unstreaming the baskets.
If the option -cachesize is used, hadd will resize (or disable if 0) the prefetching cache use to speed up I/O operations.
For options that take a size as argument, a decimal number of bytes is expected. If the number ends with a k
, m
, g
, etc., the number is multiplied by 1000 (1K), 1000000 (1MB), 1000000000 (1G), etc. If this prefix is followed by i
, the number is multiplied by the traditional 1024 (1KiB), 1048576 (1MiB), 1073741824 (1GiB), etc. The prefix can be optionally followed by B whose casing is ignored, eg. 1k, 1K, 1Kb and 1KB are the same.
- Note
- By default histograms are added. However hadd does not support the case where histograms have their bit TH1::kIsAverage set.
- Authors
- Rene Brun, Dirk Geppert, Sven A. Schmidt, Toby Burnett
Definition in file hadd.cxx.