5 from basf2
import create_path
10 """Test case for standard pi0 lists"""
12 def _check_list(self, listtype=None, std_function=stdPi0s.stdPi0s, expected_lists=["all"]):
13 """check that a given listtype function works"""
14 testpath = create_path()
15 if (std_function
is stdPi0s.stdPi0s)
and (listtype
is not None):
16 std_function(listtype, path=testpath)
18 std_function(path=testpath)
21 for module
in testpath.modules():
22 for param
in module.available_params():
23 if module.type() ==
'ParticleLoader' and param.name ==
'decayStringsWithCuts':
24 name = param.values[0][0].split(
':')[1]
25 built_lists.append(name)
26 if module.type() ==
'ParticleListManipulator' and param.name ==
'outputListName':
27 name = str(param.values).split(
':')[1]
28 built_lists.append(name)
29 if module.type() ==
'ParticleCombiner' and param.name ==
'decayString':
30 name = param.values.split(
':')[1].split(
' -> ')[0]
31 built_lists.append(name)
34 for a, b
in zip(built_lists, expected_lists):
35 self.assertEqual(a, b,
"Loaded list \'%s\' instead of \'%s\' with function %s" % (a, b, std_function.__name__))
37 print(list(built_lists))
38 result = map(
lambda w1, w2: w1 == w2, built_lists, expected_lists)
42 """check that the builder function raises a ValueError for a non-existing list name"""
43 self.assertRaises(ValueError, self.
_check_list,
"flibble")
46 """check that the builder function works with the all list"""
47 self.
_check_list(
"all", expected_lists=[
"all",
"all"])
50 """check that the builder function works with the eff10_Jan2020 list"""
51 self.
_check_list(
"eff10_Jan2020", expected_lists=[
"pi0eff10_Jan2020",
"eff10_Jan2020"])
54 """check that the builder function works with the eff20_Jan2020 list"""
55 self.
_check_list(
"eff20_Jan2020", expected_lists=[
"pi0eff20_Jan2020",
"eff20_Jan2020"])
58 """check that the builder function works with the eff30_Jan2020 list"""
59 self.
_check_list(
"eff30_Jan2020", expected_lists=[
"pi0eff30_Jan2020",
"eff30_Jan2020"])
62 """check that the builder function works with the eff40_Jan2020 list"""
63 self.
_check_list(
"eff40_Jan2020", expected_lists=[
"pi0eff40_Jan2020",
"eff40_Jan2020"])
66 """check that the builder function works with the eff50_Jan2020_nomcmatch list"""
67 self.
_check_list(
"eff50_Jan2020_nomcmatch", expected_lists=[
"pi0eff50_Jan2020",
"eff50_Jan2020_nomcmatch"])
70 """check that the builder function works with the eff50_Jan2020 list"""
71 self.
_check_list(
"eff50_Jan2020", expected_lists=[
"pi0eff50_Jan2020",
"eff50_Jan2020_nomcmatch",
"eff50_Jan2020"])
74 """check that the builder function works with the eff60_Jan2020 list"""
75 self.
_check_list(
"eff60_Jan2020", expected_lists=[
"pi0eff60_Jan2020",
"eff60_Jan2020"])
78 """check that the builder function works with the allFit list"""
79 self.
_check_list(
"allFit", expected_lists=[
"all",
"all",
"allFit"])
82 """check that the builder function works with the eff10_Jan2020Fit list"""
83 self.
_check_list(
"eff10_Jan2020Fit", expected_lists=[
"pi0eff10_Jan2020",
"eff10_Jan2020",
"eff10_Jan2020Fit"])
86 """check that the builder function works with the eff20_Jan2020Fit list"""
87 self.
_check_list(
"eff20_Jan2020Fit", expected_lists=[
"pi0eff20_Jan2020",
"eff20_Jan2020",
"eff20_Jan2020Fit"])
90 """check that the builder function works with the eff30_Jan2020Fit list"""
91 self.
_check_list(
"eff30_Jan2020Fit", expected_lists=[
"pi0eff30_Jan2020",
"eff30_Jan2020",
"eff30_Jan2020Fit"])
94 """check that the builder function works with the eff40_Jan2020Fit list"""
95 self.
_check_list(
"eff40_Jan2020Fit", expected_lists=[
"pi0eff40_Jan2020",
"eff40_Jan2020",
"eff40_Jan2020Fit"])
98 """check that the builder function works with the eff50_Jan2020Fit list"""
103 'eff50_Jan2020_nomcmatch',
108 """check that the builder function works with the eff60_Jan2020Fit list"""
109 self.
_check_list(
"eff60_Jan2020Fit", expected_lists=[
"pi0eff60_Jan2020",
"eff60_Jan2020",
"eff60_Jan2020Fit"])
112 """check that the builder function works with the skim list"""
114 std_function=stdPi0s.loadStdSkimPi0,
117 "eff50_Jan2020_nomcmatch",
120 if __name__ ==
'__main__':