15 from basf2
import create_path
20 """Test case for standard pi0 lists"""
22 def _check_list(self, listtype=None, std_function=stdPi0s.stdPi0s, expected_lists=["all"]):
23 """check that a given listtype function works"""
24 testpath = create_path()
25 if (std_function
is stdPi0s.stdPi0s)
and (listtype
is not None):
26 std_function(listtype, path=testpath)
28 std_function(path=testpath)
31 for module
in testpath.modules():
32 for param
in module.available_params():
33 if module.type() ==
'ParticleLoader' and param.name ==
'decayStrings':
34 name = param.values[0].split(
':')[1]
35 built_lists.append(name)
36 if module.type() ==
'ParticleListManipulator' and param.name ==
'outputListName':
37 name = str(param.values).split(
':')[1]
38 built_lists.append(name)
39 if module.type() ==
'ParticleCombiner' and param.name ==
'decayString':
40 name = param.values.split(
':')[1].split(
' -> ')[0]
41 built_lists.append(name)
44 for a, b
in zip(built_lists, expected_lists):
45 self.assertEqual(a, b,
"Loaded list \'%s\' instead of \'%s\' with function %s" % (a, b, std_function.__name__))
47 print(list(built_lists))
48 result = map(
lambda w1, w2: w1 == w2, built_lists, expected_lists)
52 """check that the builder function raises a ValueError for a non-existing list name"""
53 self.assertRaises(ValueError, self.
_check_list_check_list,
"flibble")
57 Check that the default list type is one of the lists in the cases that are checked for in :func:`stdPi0s.stdPi0s`.
59 This test relies on ``ValueError`` being raised for nonsense list types, which is tested by
60 :func:`test_nonsense_list`. However, :func:`test_nonsense_list` doesn't ensure that the default list works, so
61 for that this test is needed.
63 test_path = create_path()
67 stdPi0s_signature = inspect.signature(stdPi0s.stdPi0s)
68 default_listtype = stdPi0s_signature.parameters[
"listtype"].default
69 self.fail(f
"stdPi0s default listtype {default_listtype} is not in set of allowed list names.")
72 """Check that the default list type works."""
73 stdPi0s_signature = inspect.signature(stdPi0s.stdPi0s)
74 default_listtype = stdPi0s_signature.parameters[
"listtype"].default
86 """check that the builder function works with the all list"""
87 self.
_check_list_check_list(
"all", expected_lists=[
"all",
"all"])
90 """check that the builder function works with the eff10_May2020 list"""
91 self.
_check_list_check_list(
"eff10_May2020", expected_lists=[
"pi0eff10_May2020",
"pi0eff10_May2020",
"eff10_May2020"])
94 """check that the builder function works with the eff20_May2020 list"""
95 self.
_check_list_check_list(
"eff20_May2020", expected_lists=[
"pi0eff20_May2020",
"pi0eff20_May2020",
"eff20_May2020"])
98 """check that the builder function works with the eff30_May2020 list"""
99 self.
_check_list_check_list(
"eff30_May2020", expected_lists=[
"pi0eff30_May2020",
"pi0eff30_May2020",
"eff30_May2020"])
102 """check that the builder function works with the eff40_May2020 list"""
103 self.
_check_list_check_list(
"eff40_May2020", expected_lists=[
"pi0eff40_May2020",
"pi0eff40_May2020",
"eff40_May2020"])
106 """check that the builder function works with the eff50_May2020_nomcmatch list"""
107 self.
_check_list_check_list(
"eff50_May2020_nomcmatch",
108 expected_lists=[
"pi0eff50_May2020",
110 "eff50_May2020_nomcmatch"])
113 """check that the builder function works with the eff50_May2020 list"""
119 "eff50_May2020_nomcmatch",
123 """check that the builder function works with the eff50_May2020_nomcmatch list"""
124 self.
_check_list_check_list(
"eff60_May2020_nomcmatch",
125 expected_lists=[
"pi0eff60_May2020",
127 "eff60_May2020_nomcmatch"])
130 """check that the builder function works with the eff60_May2020 list"""
136 "eff60_May2020_nomcmatch",
140 """check that the builder function works with the allFit list"""
141 self.
_check_list_check_list(
"allFit", expected_lists=[
"all",
"all",
"allFit"])
144 """check that the builder function works with the eff10_May2020Fit list"""
154 """check that the builder function works with the eff20_May2020Fit list"""
164 """check that the builder function works with the eff30_May2020Fit list"""
174 """check that the builder function works with the eff40_May2020Fit list"""
184 """check that the builder function works with the eff50_May2020Fit list"""
190 'eff50_May2020_nomcmatch',
195 """check that the builder function works with the eff60_May2020Fit list"""
201 'eff60_May2020_nomcmatch',
206 """check that the builder function works with the skim list"""
208 std_function=stdPi0s.loadStdSkimPi0,
212 "eff50_May2020_nomcmatch",
216 """check that the builder function works with the skim list"""
218 std_function=stdPi0s.loadStdSkimHighEffPi0,
222 "eff60_May2020_nomcmatch",
226 if __name__ ==
'__main__':
def test_default_list_works(self)
def test_eff20_May2020_list(self)
def test_allfit_list(self)
def test_eff60_May2020fit_list(self)
def test_nonsense_list(self)
def _check_list(self, listtype=None, std_function=stdPi0s.stdPi0s, expected_lists=["all"])
def test_eff50_May2020fit_list(self)
def test_eff20_May2020fit_list(self)
def test_SkimHighEff(self)
def test_eff60_May2020_list(self)
def test_eff50_May2020_nomcmatch_list(self)
def test_eff40_May2020fit_list(self)
def test_eff10_May2020fit_list(self)
def test_eff30_May2020fit_list(self)
def test_eff50_May2020_list(self)
def test_eff30_May2020_list(self)
def test_eff10_May2020_list(self)
def test_default_list_exists(self)
def test_eff40_May2020_list(self)
def test_eff60_May2020_nomcmatch_list(self)
def stdPi0s(listtype="eff60_May2020", path=None, loadPhotonBeamBackgroundMVA=False)