Skip to content

Add a simple compareFlatTrees utility targeting analysis usage

Tadej Novak requested to merge tadej/athena:tree-compare into master

Add a simple compareFlatTrees utility targeting analysis usage. It's using RDataFrame to produce TRatioPlots and based on them decide if a branch has changed or not. Originally made by @jcatmore, I RDataFrameified it a bit more, and it's now reasonably fast (2k branches and 3.5k events in less than a minute).

"Smart" rebinning still needs a bit of work and is disabled by default.

Help output:

Usage: compareFlatTrees [OPTION] tree-name reference-file test-file [branch-name]

Common options:
  --help                 produce help message
  --tree-name arg        tree name
  --reference-file arg   reference file(s), wildcards supported
  --test-file arg        test file(s), wildcards supported
  --branch-name arg      base branch name (optional)

Advanced options:
  --scale                scale histograms that both have the same event count
  --rebin                do smart rebinning
  --benchmark            benchmark the code
  --verbose              verbose logging

Example log:

Will attempt to plot the following columns:
   el_pt_NOSYS ROOT::VecOps::RVec<float>
   jet_pt_NOSYS ROOT::VecOps::RVec<float>
   mu_pt_NOSYS ROOT::VecOps::RVec<float>
Preparing ranges...
Preparing histograms...
Running comparisons...
Processing column 1 of 3 : el_pt_NOSYS ... FAILED
Processing column 2 of 3 : jet_pt_NOSYS ... FAILED
Processing column 3 of 3 : mu_pt_NOSYS ... FAILED
========================
Reference events: 3641
Test events: 3629
Ratio: 1.00331
========================
Tested columns: 3
Passed: 0
Failed: 3
========================

Example output (only for different branches): Screenshot_2022-10-11_at_16.30.03

/cc @krumnack @akraszna

Edited by Tadej Novak

Merge request reports