Skip to content

Commit 02d4544

Browse files
Benedikt Volkelchiarazampolli
authored andcommitted
[RelVal] Update README, add verbosity option
1 parent 5122c40 commit 02d4544

2 files changed

Lines changed: 21 additions & 33 deletions

File tree

RelVal/README.md

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ There are 2 ROOT macros which can in principle be used as-is. Their functionalit
1212

1313
This macro allows to compare 2 ROOT files that contain `TH1` objects. Objects are considered to correspond to each other if they have the same name.
1414
At the moment, 3 different comparisons are implemented:
15-
1. `chi2`: Chi2 test of compared histograms,
16-
1. `bin_cont`: relative difference of normalised bin content of both histograms,
15+
1. `chi2`: Chi2 test of compared histograms (see also the [ROOT documentation](https://root.cern.ch/doc/master/classTH1.html#ab7d63c7c177ccbf879b5dc31f2311b27)),
16+
1. `kolmogorov`: shape comparison using Kolmogorov test (see also the [ROOT documentation](https://root.cern.ch/doc/master/classTH1.html#aeadcf087afe6ba203bcde124cfabbee4)),
1717
1. `num_entries`: relative difference in the number of entries.
1818

1919
The first 2 tests are considered critical, hence if the threshold is exceeded, the comparison result is named `BAD`. Also the third test is considered critical in case efficiencies are compared coming from `TEfficiency` objects.
@@ -59,7 +59,7 @@ python o2dpg_release_validation.py rel-val -i <first-list-of-files> -j <second-l
5959
```
6060
This performs all of the above mentioned tests. If only certain tests should be performed, this can be achieved with the flags `--with-test-<which-test>` where `<which-test>` is one of
6161
1. `chi2`,
62-
1. `bin-cont`,
62+
1. `kolmogorov`,
6363
1. `num-entries`.
6464

6565
By default, all of them are switched on.
@@ -96,10 +96,10 @@ There are various plots created during the RelVal run. For each compared file th
9696

9797
## More details of `rel-val` command
9898

99-
As mentioned above, the basic usage of the `rel-val` sub-command is straightforward. But there are quite a few more options available and some of them will be explained briefly below.
99+
As mentioned above, the basic usage of the `rel-val` sub-command is straightforward. But there are quite a few more options available and some of them will be explained briefly below. In fact, most of them also apply to the `inspect` sub-command.
100100

101101
### Setting new/custom thresholds from another RelVal run
102-
Each RelVal run produces a `Summary.json` file in the corresponding output directories. Among other things, it contains the computed values of all tests for each compared histogram pair. Such a `Summary.json` can now be used as a input file for a future RelVal to set all thresholds according to the values. In fact, multiple such files can be passed and for each historgam-test combination, the mean or max of the previously calculated values can be used to set the new thresholds.
102+
Each RelVal run produces a `Summary.json` file in the corresponding output directories. Among other things, it contains the computed values of all tests for each compared histogram pair. Such a `Summary.json` can now be used as a input file for a future RelVal to set all thresholds according to the values. In fact, multiple such files can be passed and for each histogram-test combination, the mean or max of the previously calculated values can be used to set the new thresholds.
103103

104104
```bash
105105
python ${O2DPG_ROOT}/RelVal/o2dpg_release_validation.py rel-val -i <first-list-of-files> -j <second-list-of-files> --use-values-as-thresholds <list-of-summaries> [--combine-thresholds {mean,max}] [--test-<name>-threshold-margin <value>]
@@ -114,23 +114,5 @@ There is an ongoing effort to unify the names of QC objects inside MC and data Q
114114

115115
MC QC objects are usually distributed over multiple files while those from data are all contained in one single file. It is possible to directly compare them with
116116
```bash
117-
python ${O2DPG_ROOT}/RelVal/o2dpg_release_validation.py rel-val -i ${MC_PRODUCTION}/QC/*.root -j ${DATA_PRODUCTION}/QC.root [--inlcude-dirs <include-directories]
117+
python ${O2DPG_ROOT}/RelVal/o2dpg_release_validation.py rel-val -i ${MC_PRODUCTION}/QC/*.root -j ${DATA_PRODUCTION}/QC.root [--include-dirs <include-directories>]
118118
```
119-
120-
### Apply to entire simulation outcome
121-
122-
**This is still under development and does not yet work when e.g. comparing an MC directory to a data directory.**
123-
124-
In addition to simply comparing 2 ROOT files, the script offers the possibility of comparing 2 corresponding directories that contain simulation artifacts (and potentially QC and analysis results). It is not foreseen to run over everything inside those directories but the files must be specifiec via a small config file. See [this example](config/rel_val_sim_dirs_default.json). It is passed via the option `--dirs-config`. In addition, top-level keys can be enabled(disabled) with `--dirs-config-enable <keys>`(`dirs-config-disable <keys>`) where disabling takes precedence.
125-
126-
**NOTE** That each single one of the comparisons is only done if mutual files were found in the 2 corresponding directories. As an example, one could do
127-
```bash
128-
cd ${DIR1}
129-
python o2dpg_workflow_runner.py -f <workflow-json1>
130-
cd ${DIR2}
131-
# potentially something has changed in the software or the simulation/reconstruction parameters
132-
python o2dpg_workflow_runner.py -f <workflow-json2>
133-
python ${O2DPG_ROOT}/RelVal/o2dpg_release_validation.py rel-val -i ${DIR1} -j ${DIR2} --dirs-config ${O2DPG_ROOT}/RelVal/config/rel_val_sim_dirs_default.json --dirs-config-enable QC [-o <output/dir>] [<test-flags>]
134-
```
135-
This would run the RelVal von everything specified under the top key `QC`.
136-

RelVal/o2dpg_release_validation.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
ROOT_MACRO_EXTRACT=join(O2DPG_ROOT, "RelVal", "ExtractAndFlatten.C")
107107
ROOT_MACRO_RELVAL=join(O2DPG_ROOT, "RelVal", "ReleaseValidation.C")
108108

109-
from ROOT import TFile, gDirectory, gROOT, TChain, TH1D
109+
from ROOT import gROOT
110110

111111
DETECTORS_OF_INTEREST_HITS = ["ITS", "TOF", "EMC", "TRD", "PHS", "FT0", "HMP", "MFT", "FDD", "FV0", "MCH", "MID", "CPV", "ZDC", "TPC"]
112112

@@ -300,7 +300,7 @@ def plot_pie_charts(summary, out_dir, title, include_patterns=None, exclude_patt
300300
continue
301301
# loop over tests done
302302
for test in tests:
303-
test_name = test["test_name"];
303+
test_name = test["test_name"]
304304
if test_name not in test_n_hist_map:
305305
test_n_hist_map[test_name] = {}
306306
result = test["result"]
@@ -340,7 +340,7 @@ def extract_from_summary(summary, fields, include_patterns=None, exclude_pattern
340340
continue
341341
# loop over tests done
342342
for test in tests:
343-
test_name = test["test_name"];
343+
test_name = test["test_name"]
344344
if test_name not in test_histo_value_map:
345345
test_histo_value_map[test_name] = {field: [] for field in fields}
346346
test_histo_value_map[test_name]["histograms"] = []
@@ -728,7 +728,7 @@ def map_histos_to_severity(summary, include_patterns=None, exclude_patterns=None
728728
return test_n_hist_map
729729

730730

731-
def print_summary(summary, include_patterns=None, exclude_patterns=None):
731+
def print_summary(summary, include_patterns=None, exclude_patterns=None, long=False):
732732
"""
733733
Check if any 2 histograms have a given severity level after RelVal
734734
"""
@@ -739,6 +739,9 @@ def print_summary(summary, include_patterns=None, exclude_patterns=None):
739739
print(f"\n#####\nNumber of compared histograms: {n_all}\nBased on critical tests, severities are\n")
740740
for sev, histos in test_n_hist_map.items():
741741
print(f" {sev}: {len(histos)}")
742+
if long:
743+
for i, h in enumerate(histos, start=1):
744+
print(f" {i}. {h}")
742745
print("#####\n")
743746

744747

@@ -854,7 +857,7 @@ def rel_val(args):
854857
func(args)
855858
global_summary, meta_info = make_global_summary(args.output)
856859
write_single_summary(global_summary, meta_info, join(args.output, "SummaryGlobal.json"))
857-
print_summary(global_summary)
860+
print_summary(global_summary, long=args.long)
858861
return 0
859862

860863

@@ -907,7 +910,7 @@ def inspect(args):
907910
current_summary, meta_info = read_single_summary(path)
908911
summary = make_single_summary(current_summary, args, output_dir, include_patterns, exclude_patterns, flags, flags_summary)
909912
write_single_summary(summary, meta_info, join(output_dir, "Summary.json"))
910-
print_summary(summary, include_patterns)
913+
print_summary(summary, include_patterns, long=args.long)
911914

912915
if args.plot:
913916
plot_pie_charts(summary, output_dir, "", include_patterns, exclude_patterns)
@@ -1095,17 +1098,20 @@ def main():
10951098
common_flags_parser.add_argument("--flags", nargs="*", help="extract all objects which have at least one test with this severity flag", choices=list(REL_VAL_SEVERITY_MAP.keys()))
10961099
common_flags_parser.add_argument("--flags-summary", dest="flags_summary", nargs="*", help="extract all objects which have this severity flag as overall test result", choices=list(REL_VAL_SEVERITY_MAP.keys()))
10971100

1101+
common_verbosity_parser = argparse.ArgumentParser(add_help=False)
1102+
common_verbosity_parser.add_argument("--long", action="store_true", help="enhance verbosity")
1103+
10981104
sub_parsers = parser.add_subparsers(dest="command")
1099-
rel_val_parser = sub_parsers.add_parser("rel-val", parents=[common_file_parser, common_threshold_parser])
1105+
rel_val_parser = sub_parsers.add_parser("rel-val", parents=[common_file_parser, common_threshold_parser, common_verbosity_parser])
11001106
rel_val_parser.add_argument("--dir-config", dest="dir_config", help="What to take into account in a given directory")
11011107
rel_val_parser.add_argument("--dir-config-enable", dest="dir_config_enable", nargs="*", help="only enable these top keys in your dir-config")
11021108
rel_val_parser.add_argument("--dir-config-disable", dest="dir_config_disable", nargs="*", help="disable these top keys in your dir-config (precedence over dir-config-enable)")
1103-
rel_val_parser.add_argument("--include-dirs", dest="include_dirs", nargs="*", help="only inlcude directories; note that each pattern is assumed to start in the top-directory (at the moment no regex or *)")
1109+
rel_val_parser.add_argument("--include-dirs", dest="include_dirs", nargs="*", help="only include directories; note that each pattern is assumed to start in the top-directory (at the moment no regex or *)")
11041110
rel_val_parser.add_argument("--add", action="store_true", help="If given and there is already a RelVal in the output directory, extracted objects will be added to the existing ones")
11051111
rel_val_parser.add_argument("--output", "-o", help="output directory", default="rel_val")
11061112
rel_val_parser.set_defaults(func=rel_val)
11071113

1108-
inspect_parser = sub_parsers.add_parser("inspect", parents=[common_threshold_parser, common_pattern_parser, common_flags_parser])
1114+
inspect_parser = sub_parsers.add_parser("inspect", parents=[common_threshold_parser, common_pattern_parser, common_flags_parser, common_verbosity_parser])
11091115
inspect_parser.add_argument("path", help="either complete file path to a Summary.json or SummaryGlobal.json or directory where one of the former is expected to be")
11101116
inspect_parser.add_argument("--plot", action="store_true", help="Plot the summary grid")
11111117
inspect_parser.add_argument("--output", "-o", help="output directory, by default points to directory where the Summary.json was found")

0 commit comments

Comments
 (0)