Belle II Software development
validationTestColorScheme.py
1#!/usr/bin/env python3
2
3
10
11"""
12<header>
13<output>validationTestColorScheme.root</output>
14<contact>Kilian Lieret, Kilian.Lieret@campus.lmu.de</contact>
15
16
17<description>
18To test the color scheme.
19Set generate_reference = True to generate the reference files.
20</description>
21</header>
22"""
23
24
25import basf2
26from validationtest import add_properties
27from ROOT import TFile, TH1F, TNamed
28
29
30def generate_gaus(title, options, distort=0.0):
31 """ Generate trivial gaus filled histogram.
32 Use the distort parameter (0<=distort<=1) for distortion to get histograms
33 with failing comparisons.
34 """
35 # fix seed, because we need to see failing and passing comparisons
36
37 assert 0 <= distort <= 1
38
39 basf2.set_random_seed(10)
40
41 norm = 300
42
43 name = title.lower().replace(" ", "_")
44
45 gaus = TH1F(name, title, 100, -3, 3)
46
47 gaus.FillRandom("gaus", int((1 - distort) * norm))
48 # add a different histogram
49 basf2.set_random_seed(100)
50 distortion = TH1F(name, title, 100, -3, 3)
51 distortion.FillRandom("gaus", int(distort * norm))
52 gaus.Add(distortion)
53
54 add_properties(gaus, options)
55 gaus.Write()
56
57
58if __name__ == "__main__":
59 tfile = TFile("validationTestColorScheme.root", "RECREATE")
60
61 TNamed(
62 "Description",
63 "These plots test the color scheme. Make sure to also check the 'expert' "
64 "plot checkbox to see the color scheme for expert plots.",
65 ).Write()
66
67 mop_expert = {
68 "Description": "Test color scheme",
69 "Check": "Check color",
70 "Contact": "Kilian Lieret, Kilian.Lieret@campus.lmu.de",
71 "MetaOptions": "pvalue-error=0.6",
72 }
73 mop_shifter = mop_expert.copy()
74 mop_shifter["MetaOptions"] += ", shifter"
75
76 generate_reference = False
77
78 if not generate_reference:
79 # No reference files for the plots that have to be checked manually
80 generate_gaus("manual", mop_shifter)
81 generate_gaus("manual expert", mop_expert)
82
83 if generate_reference:
84 # The reference will contain the normal (undistorted) histogram
85 # always.
86 generate_gaus("pass", mop_shifter)
87 generate_gaus("pass expert", mop_expert)
88 generate_gaus("warn", mop_shifter)
89 generate_gaus("fail", mop_shifter)
90 generate_gaus("warn expert", mop_expert)
91 generate_gaus("fail expert", mop_expert)
92 else:
93 generate_gaus("pass", mop_shifter, distort=0.1)
94 generate_gaus("pass expert", mop_expert, distort=0.1)
95 generate_gaus("warn", mop_shifter, distort=0.5)
96 generate_gaus("fail", mop_shifter, distort=1)
97 generate_gaus("warn expert", mop_expert, distort=0.5)
98 generate_gaus("fail expert", mop_expert, distort=1)
99
100 tfile.Close()