Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hadd.cxx File Reference
#include "Compression.h"
#include <ROOT/RConfig.hxx>
#include "ROOT/TIOFeatures.hxx"
#include "TFile.h"
#include "THashList.h"
#include "TKey.h"
#include "TClass.h"
#include "TSystem.h"
#include "TUUID.h"
#include "ROOT/StringConv.hxx"
#include "snprintf.h"
#include <string>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <climits>
#include <sstream>
#include "haddCommandLineOptionsHelp.h"
#include "TFileMerger.h"
#include "ROOT/TProcessExecutor.hxx"
Include dependency graph for hadd.cxx:

Functions

int main (int argc, char **argv)
 

Detailed Description

This program will add histograms (see note) and Trees from a list of root files and write them to a target root file.

The target file is newly created and must not be identical to one of the source files.

Syntax:

hadd targetfile source1 source2 ...

or

hadd -f targetfile source1 source2 ...
#define f(i)
Definition RSha256.hxx:104

(targetfile is overwritten if it exists)

Parameters
-aAppend to the output
-fForce overwriting of output file.
-f[0-9]Set target compression level. 0 = uncompressed, 9 = highly compressed. Default is 1 (kDefaultZLIB). You can also specify the full compresion algorithm, e.g. -f206
-fkSets 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 206 when using -fk206)
-ffThe compression level used is the one specified in the first input
-kSkip corrupt or non-existent files, do not exit
-ORe-optimize basket size when merging TTree
-TDo not merge Trees
-vExplicitly set the verbosity level: 0 request no output, 99 is the default
-jParallelise the execution in J processes. If the number of processes is not specified, use the system maximum.
-dbgEnable verbosity. If -j was specified, do not not delete partial files stored inside working directory.
-dCarry out the partial multiprocess execution in the specified directory
-nOpen at most N files at once (use 0 to request to use the system maximum)
-cachesizeResize the prefetching cache use to speed up I/O operations (use 0 to disable).
-experimental-io-features<feature> Enables the corresponding experimental feature for output trees.
See also
ROOT::Experimental::EIOFeatures
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
    hadd -f x.root f1.root f2.root f3.root
    Double_t x[n]
    Definition legend1.C:17
    TF1 * f1
    Definition legend1.C:11
    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

hadd -T targetfile source1 source2 ...

Wildcarding and indirect files are also supported

hadd result.root myfil*.root
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

hadd result.root file1.root @list.txt file2. root 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.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 122 of file hadd.cxx.