14from basf2
import create_path
19 """Test case for standard pi0 lists"""
21 def _check_list(self, listtype=None, std_function=stdPi0s.stdPi0s, expected_lists=["all"]):
22 """check that a given listtype function works"""
23 testpath = create_path()
24 if (std_function
is stdPi0s.stdPi0s)
and (listtype
is not None):
25 std_function(listtype, path=testpath)
27 std_function(path=testpath)
30 for module
in testpath.modules():
31 for param
in module.available_params():
32 if module.type() ==
'ParticleLoader' and param.name ==
'decayStrings':
33 name = param.values[0].split(
':')[1]
34 built_lists.append(name)
35 if module.type() ==
'ParticleListManipulator' and param.name ==
'outputListName':
36 name = str(param.values).split(
':')[1]
37 built_lists.append(name)
38 if module.type() ==
'ParticleCombiner' and param.name ==
'decayString':
39 name = param.values.split(
':')[1].split(
' -> ')[0]
40 built_lists.append(name)
43 for a, b
in zip(built_lists, expected_lists):
44 self.assertEqual(a, b, f
"Loaded list \'{a}\' instead of \'{b}\' with function {std_function.__name__}")
46 print(list(built_lists))
47 result = map(
lambda w1, w2: w1 == w2, built_lists, expected_lists)
51 """check that the builder function raises a ValueError for a non-existing list name"""
52 self.assertRaises(ValueError, self.
_check_list,
"flibble")
56 Check that the default list type is one of the lists
in the cases that are checked
for in :func:`stdPi0s.stdPi0s`.
58 This test relies on ``ValueError`` being raised
for nonsense list types, which
is tested by
59 :func:`test_nonsense_list`. However, :func:`test_nonsense_list` doesn
't ensure that the default list works, so
60 for that this test
is needed.
62 test_path = create_path()
66 stdPi0s_signature = inspect.signature(stdPi0s.stdPi0s)
67 default_listtype = stdPi0s_signature.parameters[
"listtype"].default
68 self.fail(f
"stdPi0s default listtype {default_listtype} is not in set of allowed list names.")
71 """Check that the default list type works."""
72 stdPi0s_signature = inspect.signature(stdPi0s.stdPi0s)
73 default_listtype = stdPi0s_signature.parameters[
"listtype"].default
85 """check that the builder function works with the all list"""
86 self.
_check_list(
"all", expected_lists=[
"all",
"all"])
89 """check that the builder function works with the eff10_May2020 list"""
90 self.
_check_list(
"eff10_May2020", expected_lists=[
"pi0eff10_May2020",
"pi0eff10_May2020",
"eff10_May2020"])
93 """check that the builder function works with the eff20_May2020 list"""
94 self.
_check_list(
"eff20_May2020", expected_lists=[
"pi0eff20_May2020",
"pi0eff20_May2020",
"eff20_May2020"])
97 """check that the builder function works with the eff30_May2020 list"""
98 self.
_check_list(
"eff30_May2020", expected_lists=[
"pi0eff30_May2020",
"pi0eff30_May2020",
"eff30_May2020"])
101 """check that the builder function works with the eff40_May2020 list"""
102 self.
_check_list(
"eff40_May2020", expected_lists=[
"pi0eff40_May2020",
"pi0eff40_May2020",
"eff40_May2020"])
105 """check that the builder function works with the eff50_May2020_nomcmatch list"""
107 expected_lists=[
"pi0eff50_May2020",
109 "eff50_May2020_nomcmatch"])
112 """check that the builder function works with the eff50_May2020 list"""
118 "eff50_May2020_nomcmatch",
122 """check that the builder function works with the eff50_May2020_nomcmatch list"""
124 expected_lists=[
"pi0eff60_May2020",
126 "eff60_May2020_nomcmatch"])
129 """check that the builder function works with the eff60_May2020 list"""
135 "eff60_May2020_nomcmatch",
139 """check that the builder function works with the allFit list"""
140 self.
_check_list(
"allFit", expected_lists=[
"all",
"all",
"allFit"])
143 """check that the builder function works with the eff10_May2020Fit list"""
153 """check that the builder function works with the eff20_May2020Fit list"""
163 """check that the builder function works with the eff30_May2020Fit list"""
173 """check that the builder function works with the eff40_May2020Fit list"""
183 """check that the builder function works with the eff50_May2020Fit list"""
189 'eff50_May2020_nomcmatch',
194 """check that the builder function works with the eff60_May2020Fit list"""
200 'eff60_May2020_nomcmatch',
205 """check that the builder function works with the skim list"""
207 std_function=stdPi0s.loadStdSkimPi0,
211 "eff50_May2020_nomcmatch",
215 """check that the builder function works with the skim list"""
217 std_function=stdPi0s.loadStdSkimHighEffPi0,
221 "eff60_May2020_nomcmatch",
225if __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, beamBackgroundMVAWeight="", fakePhotonMVAWeight="", biasCorrectionTable="")