Belle II Software light-2509-fornax
TestStdPhotons Class Reference
Inheritance diagram for TestStdPhotons:
Collaboration diagram for TestStdPhotons:

Public Member Functions

 test_nonsense_list (self)
 
 test_default_list_exists (self)
 
 test_default_list_works (self)
 
 test_all_list (self)
 
 test_cdc_list (self)
 
 test_loose_list (self)
 
 test_default_list (self)
 
 test_tight_list (self)
 
 test_pi0eff60_May2020_list (self)
 
 test_pi0eff50_May2020_list (self)
 
 test_pi0eff40_May2020_list (self)
 
 test_pi0eff30_May2020_list (self)
 
 test_pi0eff20_May2020_list (self)
 
 test_pi0eff10_May2020_list (self)
 
 test_skim (self)
 
 test_belle (self)
 

Protected Member Functions

 _check_list (self, listtype=None, std_function=stdPhotons.stdPhotons, expected_lists=["all"])
 

Detailed Description

Test case for standard photon lists

Definition at line 18 of file test_std_photons.py.

Member Function Documentation

◆ _check_list()

_check_list ( self,
listtype = None,
std_function = stdPhotons.stdPhotons,
expected_lists = ["all"] )
protected
check that a given listtype function works

Definition at line 21 of file test_std_photons.py.

21 def _check_list(self, listtype=None, std_function=stdPhotons.stdPhotons, expected_lists=["all"]):
22 """check that a given listtype function works"""
23 testpath = create_path()
24 if (std_function is stdPhotons.stdPhotons) and (listtype is not None):
25 std_function(listtype, path=testpath)
26 else:
27 std_function(path=testpath)
28
29 # verify that we load only the list-creating modules
30 self.assertEqual(
31 len(testpath.modules()), len(set(expected_lists)) + 1 if listtype == 'all' else len(set(expected_lists)) + 3,
32 f"List {listtype} doesn't work with function {std_function.__name__}")
33 self.assertTrue(all((module.type() == "ParticleLoader") or (module.type() == "ParticleListManipulator")
34 or (module.type() == "ParticleSelector")
35 for module in testpath.modules()))
36
37 #
38 built_list = []
39 for module in testpath.modules():
40 for param in module.available_params():
41 if param.name == 'decayStrings':
42 name = param.values[0].split(':')[1]
43 built_list.append(name)
44 if param.name == 'outputListName':
45 name = str(param.values).split(':')[1]
46 built_list.append(name)
47
48 # we have the particle lists we expect
49 for a, b in zip(built_list, expected_lists):
50 self.assertEqual(a, b, f"Loaded list \'{a}\' instead of \'{b}\' with function {std_function.__name__}")
51

◆ test_all_list()

test_all_list ( self)
check that the builder function works with the all list

Definition at line 79 of file test_std_photons.py.

79 def test_all_list(self):
80 """check that the builder function works with the all list"""
81 self._check_list("all", expected_lists=["all"])
82

◆ test_belle()

test_belle ( self)
check that the builder function works with the belle list

Definition at line 127 of file test_std_photons.py.

127 def test_belle(self):
128 """check that the builder function works with the belle list"""
129 self._check_list("goodBelle", std_function=stdPhotons.loadStdGoodBellePhoton, expected_lists=["goodBelle"])
130
131

◆ test_cdc_list()

test_cdc_list ( self)
check that the builder function works with the cdc list

Definition at line 83 of file test_std_photons.py.

83 def test_cdc_list(self):
84 """check that the builder function works with the cdc list"""
85 self._check_list("cdc", expected_lists=["cdc"])
86

◆ test_default_list()

test_default_list ( self)
check that the builder function works with the default (loose) list

Definition at line 91 of file test_std_photons.py.

91 def test_default_list(self):
92 """check that the builder function works with the default (loose) list"""
93 self._check_list(expected_lists=["cdc", "cdc", "loose"])
94

◆ test_default_list_exists()

test_default_list_exists ( self)
Check that the default list type is one of the lists in the cases that are checked for in :func:`stdPhotons.stdPhotons`.

This test relies on ``ValueError`` being raised for nonsense list types, which is tested by
:func:`test_nonsense_list`.  However, :func:`test_nonsense_list` doesn't ensure that the default list works, so
for that this test is needed.

Definition at line 58 of file test_std_photons.py.

58 def test_default_list_exists(self):
59 """
60 Check that the default list type is one of the lists in the cases that are checked for in :func:`stdPhotons.stdPhotons`.
61
62 This test relies on ``ValueError`` being raised for nonsense list types, which is tested by
63 :func:`test_nonsense_list`. However, :func:`test_nonsense_list` doesn't ensure that the default list works, so
64 for that this test is needed.
65 """
66 test_path = create_path()
67 try:
68 stdPhotons.stdPhotons(path=test_path)
69 except ValueError:
70 stdPhotons_signature = inspect.signature(stdPhotons.stdPhotons)
71 default_listtype = stdPhotons_signature.parameters["listtype"].default
72 self.fail(f"stdPhotons default listtype {default_listtype} is not in set of allowed list names.")
73
stdPhotons(listtype='loose', path=None, beamBackgroundMVAWeight="", fakePhotonMVAWeight="", biasCorrectionTable="")
Definition stdPhotons.py:20

◆ test_default_list_works()

test_default_list_works ( self)
Check that the default list type (loose) works.

Definition at line 74 of file test_std_photons.py.

74 def test_default_list_works(self):
75 """Check that the default list type (loose) works."""
76 # basically a duplicate of test_loose_list
77 self._check_list(expected_lists=["cdc", "cdc", "loose"])
78

◆ test_loose_list()

test_loose_list ( self)
check that the builder function works with the loose list

Definition at line 87 of file test_std_photons.py.

87 def test_loose_list(self):
88 """check that the builder function works with the loose list"""
89 self._check_list("loose", expected_lists=["cdc", "cdc", "loose"])
90

◆ test_nonsense_list()

test_nonsense_list ( self)
Check that the builder function raises a ValueError for a non-existing list name.

Definition at line 52 of file test_std_photons.py.

52 def test_nonsense_list(self):
53 """Check that the builder function raises a ValueError for a non-existing list name."""
54 # \cond false positive doxygen warning
55 self.assertRaises(ValueError, self._check_list, "flibble")
56 # \endcond
57

◆ test_pi0eff10_May2020_list()

test_pi0eff10_May2020_list ( self)
check that the builder function works with the pi0eff10_May2020 list

Definition at line 119 of file test_std_photons.py.

119 def test_pi0eff10_May2020_list(self):
120 """check that the builder function works with the pi0eff10_May2020 list"""
121 self._check_list("pi0eff10_May2020", expected_lists=["pi0eff10_May2020"])
122

◆ test_pi0eff20_May2020_list()

test_pi0eff20_May2020_list ( self)
check that the builder function works with the pi0eff20_May2020 list

Definition at line 115 of file test_std_photons.py.

115 def test_pi0eff20_May2020_list(self):
116 """check that the builder function works with the pi0eff20_May2020 list"""
117 self._check_list("pi0eff20_May2020", expected_lists=["pi0eff20_May2020"])
118

◆ test_pi0eff30_May2020_list()

test_pi0eff30_May2020_list ( self)
check that the builder function works with the pi0eff30_May2020 list

Definition at line 111 of file test_std_photons.py.

111 def test_pi0eff30_May2020_list(self):
112 """check that the builder function works with the pi0eff30_May2020 list"""
113 self._check_list("pi0eff30_May2020", expected_lists=["pi0eff30_May2020"])
114

◆ test_pi0eff40_May2020_list()

test_pi0eff40_May2020_list ( self)
check that the builder function works with the pi0eff40_May2020 list

Definition at line 107 of file test_std_photons.py.

107 def test_pi0eff40_May2020_list(self):
108 """check that the builder function works with the pi0eff40_May2020 list"""
109 self._check_list("pi0eff40_May2020", expected_lists=["pi0eff40_May2020"])
110

◆ test_pi0eff50_May2020_list()

test_pi0eff50_May2020_list ( self)
check that the builder function works with the pi0eff50_May2020 list

Definition at line 103 of file test_std_photons.py.

103 def test_pi0eff50_May2020_list(self):
104 """check that the builder function works with the pi0eff50_May2020 list"""
105 self._check_list("pi0eff50_May2020", expected_lists=["pi0eff50_May2020"])
106

◆ test_pi0eff60_May2020_list()

test_pi0eff60_May2020_list ( self)
check that the builder function works with the pi0eff60_May2020 list

Definition at line 99 of file test_std_photons.py.

99 def test_pi0eff60_May2020_list(self):
100 """check that the builder function works with the pi0eff60_May2020 list"""
101 self._check_list("pi0eff60_May2020", expected_lists=["pi0eff60_May2020"])
102

◆ test_skim()

test_skim ( self)
check that the builder function works with the skim list

Definition at line 123 of file test_std_photons.py.

123 def test_skim(self):
124 """check that the builder function works with the skim list"""
125 self._check_list("skim", std_function=stdPhotons.loadStdSkimPhoton, expected_lists=["cdc", "cdc", "loose", "skim"])
126

◆ test_tight_list()

test_tight_list ( self)
check that the builder function works with the tight list

Definition at line 95 of file test_std_photons.py.

95 def test_tight_list(self):
96 """check that the builder function works with the tight list"""
97 self._check_list("tight", expected_lists=["cdc", "cdc", "loose", "tight"])
98

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