Belle II Software development
TestValidationMetadataSetter Class Reference
Inheritance diagram for TestValidationMetadataSetter:

Public Member Functions

def setUp (self)
 
def tearDown (self)
 
def test (self)
 

Public Attributes

 tmp_dir
 Temporary directory.
 

Detailed Description

 This test tests the ValidationMetadataSetter module via its interface
:func:`validation_tools.metadata.create_validation_histograms`

Definition at line 39 of file test_validation_metadata_tools.py.

Member Function Documentation

◆ setUp()

def setUp (   self)
 Open temporary directory to work in. 

Definition at line 44 of file test_validation_metadata_tools.py.

44 def setUp(self):
45 """ Open temporary directory to work in. """
46
47 self.tmp_dir = tempfile.TemporaryDirectory()
48

◆ tearDown()

def tearDown (   self)
 Clean up temporary directory 

Definition at line 49 of file test_validation_metadata_tools.py.

49 def tearDown(self):
50 """ Clean up temporary directory """
51 self.tmp_dir.cleanup()
52

◆ test()

def test (   self)
 Perform tests 

Definition at line 53 of file test_validation_metadata_tools.py.

53 def test(self):
54 """ Perform tests """
55 tmp_dir_path = pathlib.Path(self.tmp_dir.name)
56
57 dec_path = tmp_dir_path / "test_y4s_trivial.dec"
58 with dec_path.open("w") as decfile:
59 decfile.write(TRIVIAL_DECFILE)
60
61 # Run basf2
62 # ----------------------------------------------------------------------
63
64 path = basf2.create_path()
65 modularAnalysis.setupEventInfo(noEvents=10, path=path)
66 ge.add_evtgen_generator(
67 path=path,
68 finalstate="signal",
69 signaldecfile=basf2.find_file(str(dec_path)),
70 )
71
72 modularAnalysis.fillParticleListFromMC("Upsilon(4S)", "", path=path)
73
74 out_file_path = tmp_dir_path / "out.root"
75 create_validation_histograms(
76 path,
77 out_file_path,
78 "Upsilon(4S)",
79 variables_1d=[
80 (
81 "M",
82 100,
83 5,
84 15,
85 "mass",
86 "me <wontreply@dont.try>",
87 "description of M",
88 "nothing to check",
89 "x label",
90 )
91 ],
92 variables_2d=[
93 (
94 "M",
95 100,
96 5,
97 15,
98 "M",
99 100,
100 5,
101 15,
102 "mass vs mass",
103 "me <wontreply@dont.try>",
104 "some description nobody reads",
105 "nothing to check",
106 "x label",
107 "why label?",
108 "mop1, mop2",
109 )
110 ],
111 description="Overall description of plots in this package.",
112 )
113
114 basf2.process(path=path)
115
116 # Test outcome
117 # ----------------------------------------------------------------------
118
119 tf = ROOT.TFile(str(out_file_path))
120
121 # Overall
122 # *******
123
124 d = tf.Get("Description")
125 self.assertEqual(
126 d.GetTitle(), "Overall description of plots in this package."
127 )
128
129 # 1D Histogram
130 # ************
131
132 md = get_metadata(tf.Get("M"))
133 self.assertEqual(md["description"], "description of M")
134 self.assertEqual(md["check"], "nothing to check")
135 self.assertEqual(md["metaoptions"], [])
136 self.assertEqual(md["contact"], "me <wontreply@dont.try>")
137
138 # 2D Histogram
139 # ************
140
141 md = get_metadata(tf.Get("MM"))
142 self.assertEqual(md["description"], "some description nobody reads")
143 self.assertEqual(md["check"], "nothing to check")
144 self.assertEqual(md["metaoptions"], ["mop1", "mop2"])
145 self.assertEqual(md["contact"], "me <wontreply@dont.try>")
146
147
def setupEventInfo(noEvents, path)
def fillParticleListFromMC(decayString, cut, addDaughters=False, skipNonPrimaryDaughters=False, writeOut=False, path=None, skipNonPrimary=False, skipInitial=True)

Member Data Documentation

◆ tmp_dir

tmp_dir

Temporary directory.

Definition at line 47 of file test_validation_metadata_tools.py.


The documentation for this class was generated from the following file: