11from svd
import add_svd_unpacker, add_svd_reconstruction
31test_message = [
'successful',
'FAILED']
34if __name__ ==
"__main__":
38 basf2.B2INFO(
'Test 1. \nBehaviour with residual digits\n')
40 basf2.B2INFO(
'1/5 \nSet up: Using ParticleGun and SVDPacker, we generate\n' +
41 'a file with RawSVDs and residual digits.')
43 create_input = basf2.create_path()
44 create_input.add_module(
'EventInfoSetter', expList=[0], runList=[0], evtNumList=[1])
45 create_input.add_module(
'Gearbox')
46 create_input.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
47 create_input.add_module(
'ParticleGun')
48 create_input.add_module(
'FullSim')
50 create_input.add_module(
'SVDDigitizer')
51 create_input.add_module(
'SVDPacker')
52 create_input.add_module(
'RootOutput', outputFileName=
'rawPlusDigits.root')
56 test_successful = test_successful
and (result == 0)
57 basf2.B2INFO(f
'Generation {test_message[result]}.\n')
59 basf2.B2INFO(
'2/5\nRead shaper digits using default settings of SVDUnpacker.' +
60 '\nWe should see FATAL with message for SVDShaperDigits.')
62 read_shapers_default = basf2.create_path()
63 read_shapers_default.add_module(
'RootInput', inputFileName=
'rawPlusDigits.root')
64 read_shapers_default.add_module(
'Gearbox')
65 read_shapers_default.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
66 read_shapers_default.add_module(
'SVDUnpacker')
67 add_svd_reconstruction(read_shapers_default)
72 test_successful = test_successful
and (result == 1)
73 basf2.B2INFO(f
'Test {test_message[1 - result]}.\n')
75 basf2.B2INFO(
'3/5\nRead the safe way, excluding branches.\nWe should see no errors.')
77 read_safe_way = basf2.create_path()
78 read_safe_way.add_module(
'RootInput',
79 inputFileName=
'rawPlusDigits.root',
80 branchNames=[
'EventMetaData',
'RawSVDs'])
81 read_safe_way.add_module(
'Gearbox')
82 read_safe_way.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
83 read_safe_way.add_module(
'SVDUnpacker')
84 add_svd_reconstruction(read_safe_way)
89 test_successful = test_successful
and (result == 0)
90 basf2.B2INFO(f
'Test {test_message[result]}.\n')
92 basf2.B2INFO(
'4/5\nRead with the Unpacker silentlyAppend switch on.\n' +
93 'We also include the SVDShaperDigitSorter.\n' +
94 'We should see no errors.')
96 read_append_sort = basf2.create_path()
97 read_append_sort.add_module(
'RootInput',
98 inputFileName=
'rawPlusDigits.root',
99 branchNames=[
'EventMetaData',
'RawSVDs',
'SVDShaperDigits'])
100 read_append_sort.add_module(
'Gearbox')
101 read_append_sort.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
102 read_append_sort.add_module(
'SVDUnpacker', silentlyAppend=
True)
103 read_append_sort.add_module(
'SVDShaperDigitSorter')
104 add_svd_reconstruction(read_append_sort)
109 test_successful = test_successful
and (result == 0)
110 basf2.B2INFO(f
'Test {test_message[result]}.\n')
112 basf2.B2INFO(
'5/5\nRead with the Unpacker silentAppend switch on.\n' +
113 'We don\'t include the SVDShaperDigitSorter.\n' +
114 'THERE WILL BE NO ERRORS, but digits and clusters may be duplicated!')
116 read_append_nosort = basf2.create_path()
117 read_append_nosort.add_module(
'RootInput',
118 inputFileName=
'rawPlusDigits.root',
119 branchNames=[
'EventMetaData',
'RawSVDs',
'SVDShaperDigits'])
120 read_append_nosort.add_module(
'Gearbox')
121 read_append_nosort.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
122 read_append_nosort.add_module(
'SVDUnpacker', silentlyAppend=
True)
123 add_svd_reconstruction(read_append_nosort)
128 test_successful = test_successful
and (result == 0)
129 basf2.B2INFO(f
'Test {test_message[result]}.\n')
131 basf2.B2INFO(
'6 tasks of Test 1 completed\n\n')
133 basf2.B2INFO(
'Test 2\nBehaviour when data absent\n')
135 basf2.B2INFO(
'1/2\nRun unpacking and reconstruction with data.' +
136 '\nAll settings are standard.' +
137 '\nWe should see no errors. ')
139 unpack_with_data = basf2.create_path()
140 unpack_with_data.add_module(
142 inputFileName=
'rawPlusDigits.root',
143 excludeBranchNames=[
'SVDShaperDigits'])
144 unpack_with_data.add_module(
'Gearbox')
145 unpack_with_data.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
146 add_svd_unpacker(unpack_with_data)
147 add_svd_reconstruction(unpack_with_data)
152 test_successful = test_successful
and (result == 0)
153 basf2.B2INFO(f
'Test {test_message[result]}.\n')
155 basf2.B2INFO(
'2/2\nRun unpacking and reconstruction without data.' +
156 '\nAll settings are standard.' +
157 '\nWe should see no errors. ')
159 unpack_without_data = basf2.create_path()
160 unpack_without_data.add_module(
'EventInfoSetter', expList=[0], runList=[0], evtNumList=[1])
161 unpack_without_data.add_module(
'Gearbox')
162 unpack_without_data.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
163 add_svd_unpacker(unpack_without_data)
164 add_svd_reconstruction(unpack_without_data)
169 test_successful = test_successful
and (result == 0)
170 basf2.B2INFO(f
'Test {test_message[result]}.\n')
172 basf2.B2INFO(
'2 tasks of Test 2 completed\n')
174 basf2.B2INFO(f
'Summary result:\nTests {test_message[0 if test_successful else 1]}.\n')
def clean_working_directory()
def safe_process(*args, **kwargs)