Belle II Software light-2406-ragdoll
TestStdPhotons Class Reference
Inheritance diagram for TestStdPhotons:
Collaboration diagram for TestStdPhotons:

Public Member Functions

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

Protected Member Functions

def _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()

def _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()

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

Definition at line 77 of file test_std_photons.py.

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

◆ test_belle()

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

Definition at line 125 of file test_std_photons.py.

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

◆ test_cdc_list()

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

Definition at line 81 of file test_std_photons.py.

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

◆ test_default_list()

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

Definition at line 89 of file test_std_photons.py.

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

◆ test_default_list_exists()

def 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 56 of file test_std_photons.py.

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

◆ test_default_list_works()

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

Definition at line 72 of file test_std_photons.py.

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

◆ test_loose_list()

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

Definition at line 85 of file test_std_photons.py.

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

◆ test_nonsense_list()

def 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 self.assertRaises(ValueError, self._check_list, "flibble")
55

◆ test_pi0eff10_May2020_list()

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

Definition at line 117 of file test_std_photons.py.

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

◆ test_pi0eff20_May2020_list()

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

Definition at line 113 of file test_std_photons.py.

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

◆ test_pi0eff30_May2020_list()

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

Definition at line 109 of file test_std_photons.py.

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

◆ test_pi0eff40_May2020_list()

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

Definition at line 105 of file test_std_photons.py.

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

◆ test_pi0eff50_May2020_list()

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

Definition at line 101 of file test_std_photons.py.

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

◆ test_pi0eff60_May2020_list()

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

Definition at line 97 of file test_std_photons.py.

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

◆ test_skim()

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

Definition at line 121 of file test_std_photons.py.

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

◆ test_tight_list()

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

Definition at line 93 of file test_std_photons.py.

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

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