5 from svd
import add_svd_unpacker, add_svd_reconstruction
24 test_successful =
True
25 test_message = [
'successful',
'FAILED']
28 if __name__ ==
"__main__":
32 basf2.B2INFO(
'Test 1. \nBehaviour with residual digits\n')
34 basf2.B2INFO(
'1/5 \nSet up: Using ParticleGun and SVDPacker, we generate\n' +
35 'a file with RawSVDs and residual digits.')
37 create_input = basf2.create_path()
38 create_input.add_module(
'EventInfoSetter', expList=[0], runList=[0], evtNumList=[1])
39 create_input.add_module(
'Gearbox')
40 create_input.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
41 create_input.add_module(
'ParticleGun')
42 create_input.add_module(
'FullSim')
44 create_input.add_module(
'SVDDigitizer')
45 create_input.add_module(
'SVDPacker')
46 create_input.add_module(
'RootOutput', outputFileName=
'rawPlusDigits.root')
50 test_successful = test_successful
and (result == 0)
51 basf2.B2INFO(
'Generation {0}.\n'.format(test_message[result]))
53 basf2.B2INFO(
'2/5\nRead shaper digits using default settings of SVDUnpacker.' +
54 '\nWe should see FATAL with message for SVDShaperDigits.')
56 read_shapers_default = basf2.create_path()
57 read_shapers_default.add_module(
'RootInput', inputFileName=
'rawPlusDigits.root')
58 read_shapers_default.add_module(
'Gearbox')
59 read_shapers_default.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
60 read_shapers_default.add_module(
'SVDUnpacker')
61 add_svd_reconstruction(read_shapers_default)
66 test_successful = test_successful
and (result == 1)
67 basf2.B2INFO(
'Test {0}.\n'.format(test_message[1 - result]))
69 basf2.B2INFO(
'3/5\nRead the safe way, excluding branches.\nWe should see no errors.')
71 read_safe_way = basf2.create_path()
72 read_safe_way.add_module(
'RootInput',
73 inputFileName=
'rawPlusDigits.root',
74 branchNames=[
'EventMetaData',
'RawSVDs'])
75 read_safe_way.add_module(
'Gearbox')
76 read_safe_way.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
77 read_safe_way.add_module(
'SVDUnpacker')
78 add_svd_reconstruction(read_safe_way)
83 test_successful = test_successful
and (result == 0)
84 basf2.B2INFO(
'Test {0}.\n'.format(test_message[result]))
86 basf2.B2INFO(
'4/5\nRead with the Unpacker silentlyAppend switch on.\n' +
87 'We also include the SVDShaperDigitSorter.\n' +
88 'We should see no errors.')
90 read_append_sort = basf2.create_path()
91 read_append_sort.add_module(
'RootInput',
92 inputFileName=
'rawPlusDigits.root',
93 branchNames=[
'EventMetaData',
'RawSVDs',
'SVDShaperDigits'])
94 read_append_sort.add_module(
'Gearbox')
95 read_append_sort.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
96 read_append_sort.add_module(
'SVDUnpacker', silentlyAppend=
True)
97 read_append_sort.add_module(
'SVDShaperDigitSorter')
98 add_svd_reconstruction(read_append_sort)
103 test_successful = test_successful
and (result == 0)
104 basf2.B2INFO(
'Test {0}.\n'.format(test_message[result]))
106 basf2.B2INFO(
'5/5\nRead with the Unpacker silentAppend switch on.\n' +
107 'We don\'t include the SVDShaperDigitSorter.\n' +
108 'THERE WILL BE NO ERRORS, but digits and clusters may be duplicated!')
110 read_append_nosort = basf2.create_path()
111 read_append_nosort.add_module(
'RootInput',
112 inputFileName=
'rawPlusDigits.root',
113 branchNames=[
'EventMetaData',
'RawSVDs',
'SVDShaperDigits'])
114 read_append_nosort.add_module(
'Gearbox')
115 read_append_nosort.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
116 read_append_nosort.add_module(
'SVDUnpacker', silentlyAppend=
True)
117 add_svd_reconstruction(read_append_nosort)
122 test_successful = test_successful
and (result == 0)
123 basf2.B2INFO(
'Test {0}.\n'.format(test_message[result]))
125 basf2.B2INFO(
'6 tasks of Test 1 completed\n\n')
127 basf2.B2INFO(
'Test 2\nBehaviour when data absent\n')
129 basf2.B2INFO(
'1/2\nRun unpacking and reconstruction with data.' +
130 '\nAll settings are standard.' +
131 '\nWe should see no errors. ')
133 unpack_with_data = basf2.create_path()
134 unpack_with_data.add_module(
136 inputFileName=
'rawPlusDigits.root',
137 excludeBranchNames=[
'SVDShaperDigits'])
138 unpack_with_data.add_module(
'Gearbox')
139 unpack_with_data.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
140 add_svd_unpacker(unpack_with_data)
141 add_svd_reconstruction(unpack_with_data)
146 test_successful = test_successful
and (result == 0)
147 basf2.B2INFO(
'Test {0}.\n'.format(test_message[result]))
149 basf2.B2INFO(
'2/2\nRun unpacking and reconstruction without data.' +
150 '\nAll settings are standard.' +
151 '\nWe should see no errors. ')
153 unpack_without_data = basf2.create_path()
154 unpack_without_data.add_module(
'EventInfoSetter', expList=[0], runList=[0], evtNumList=[1])
155 unpack_without_data.add_module(
'Gearbox')
156 unpack_without_data.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
157 add_svd_unpacker(unpack_without_data)
158 add_svd_reconstruction(unpack_without_data)
163 test_successful = test_successful
and (result == 0)
164 basf2.B2INFO(
'Test {0}.\n'.format(test_message[result]))
166 basf2.B2INFO(
'2 tasks of Test 2 completed\n')
168 basf2.B2INFO(
'Summary result:\nTests {0}.\n'.format(
169 test_message[0
if test_successful
else 1]))