hepconvert.add_histograms

Defined in hepconvert.histogram_adding on line 345.

hepconvert.add_histograms(destination, files, *, progress_bar=False, force=True, append=False, compression='zlib', compression_level=1, skip_bad_files=False, union=True, same_names=False)

Adds together histograms from local ROOT files of a collection of ROOT files, and writes them to a new or existing ROOT file. Similar to ROOT’s hadd function.

Parameters:
  • destination (path-like) – Name of the output file or file path.

  • files (str or list of str) – List of local ROOT files to read histograms from. May contain glob patterns.

  • progress_bar (Bool, tqdm.std.tqdm object) – Displays a progress bar. Can input a custom tqdm progress bar object, or set True for a default tqdm progress bar. Must have tqdm installed.

  • force (bool, optional) – If True, overwrites destination file if it exists. Force and append cannot both be True. Defaults to True. Command line options: -f or --force.

  • append (bool, optional) – If True, appends histograms to an existing file. Force and append cannot both be True. Defaults to False. Command line option: --append.

  • compression (int) – Sets compression level for root file to write to. Can be one of “ZLIB”, “LZMA”, “LZ4”, or “ZSTD”. By default the compression algorithm is “ZLIB”. Command line option: --compression.

  • compression_level – Use a compression level particular to the chosen compressor. By default the compression level is 1. Command line option: --compression-level.

  • skip_bad_files (bool, optional) – If True, skips corrupt or non-existent files without exiting. Command line option: --skip-bad-files.

  • union (bool, optional) – If True, adds the histograms that have the same name and appends all others to the new file. Defaults to True. Command line option: --union.

  • same_names (bool, optional) – If True, only adds together histograms which have the same name (key). If False, histograms are added together based on TTree structure (bins must be equal). Defaults to True. Command line option: --same-names.

Example:

>>> hepconvert.add_histograms("destination.root", ["file1_to_add.root", "file2_to_add.root"])

Command Line Instructions:

This function can be run from the command line. Use command

hepconvert add [options] [OUT_FILE] [IN_FILES]