Merging NTuples - jniedzie/SVJanalysis_wiki GitHub Wiki

Overview

Code in directory nTuplesMerger

Allowed merging strategies (-m/--mergingAlgo flag) are:

  • events: appends together trees with different events but same branches (the number of events in the tree changes, but not the number of branches)
  • branches: appends together trees with different branches but same trees (the number of branches in the tree changes, but not the number of events)
  • sum: sums together the branches (the number of branches and their size does not change)
  • firstFound: takes the first found tree from the input files list (ordered as it is after the -i flag)

Usage

Latest usage using python mergeNTuples.py -h.

usage: mergeNTuples.py [-h] -i INPUTFILES -t TREES -m {branches,events,sum,firstFound}
                       -o OUTPUTFILE [-bd BRANCHES_TO_DROP] [-bdf FILES_FOR_WHICH_TO_DROP_BRANCHES]

optional arguments:
  -h, --help            show this help message and exit
  -i INPUTFILES, --inputfiles INPUTFILES
                        Input ROOT file used to make new branches
  -t TREES, --trees TREES
                        Trees to merge
  -m {branches,events,sum,firstFound}, --mergingAlgo {branches,events,sum,firstFound}
                        Merging algorithm. Choices=branches, events, sum, firstFound.
  -o OUTPUTFILE, --outputfile OUTPUTFILE
                        Output ROOT file name
  -bd BRANCHES_TO_DROP, --branches_to_drop BRANCHES_TO_DROP
                        Optional comma-separated list or python list of regexes matching
                        branches to ignore/not store.
                        Example: -bd '^n(Electron|Muon)_.*,^L1_.*' or -bd ["^n(Electron|Muon)_.*", "^L1_.*"]
  -bdf FILES_FOR_WHICH_TO_DROP_BRANCHES, --files_for_which_to_drop_branches FILES_FOR_WHICH_TO_DROP_BRANCHES
                        Optional comma-separated list of integers pointing to the files
                        for which to drop the branches. By default, branches are dropped
                        from all files.

Example

python mergeNTuples.py --i ${input_file_1},${input_file_2} --trees Events,CutFlow,Metadata,LuminosityBlocks,Runs --mergingAlgo branches,firstFound,firstFound,firstFound,firstFound -o ${output_file}