Belle II Software  release-08-01-10
test_geotools.py
1 
8 
9 import basf2
10 from ROOT import Belle2
11 import b2test_utils
12 
13 # ====================================================================
14 # This test checks the numberingg schemes used in VXD DQM utility class.
15 # It builds a single event to have geometry in place, and only checks
16 # that ID->list index->ID works for sensor and chip lists.
17 # ====================================================================
18 
19 
20 class CheckNumbering(basf2.Module):
21  """This module creates a DQMCommonUtils object and tests sensor
22  and chip numbering schemes."""
23 
24  def __init__(self):
25  """ constructor """
26  super().__init__()
27 
28  def initialize(self):
29  """ Initialize the DQMCommonUtils class here. It builds
30  its lookup arrrays, so we want to do it only once."""
31 
32  self.gToolsgTools = Belle2.VXD.GeoCache.getInstance().getGeoTools()
33  if not self.gToolsgTools:
34  basf2.B2FATAL("GeoTools not available!")
35 
36  def event(self):
37  """ We test sensor and chip numbering by going from ID to
38  list number to ID."""
39  #
40  # 0. General parameters
41  #
42  # 0a. Layer counts
43  if (self.gToolsgTools.getNumberOfLayers() != 6):
44  basf2.B2ERROR('Layer count failure: \n {0} layers reported, 6 actually.'.format(self.gToolsgTools.getNumberOfLayers()))
45  if (self.gToolsgTools.getNumberOfPXDLayers() != 2):
46  basf2.B2ERROR('PXD layer count failure: \n {0} layers reported, 2 actually.'.format(self.gToolsgTools.getNumberOfPXDLayers()))
47  if (self.gToolsgTools.getNumberOfSVDLayers() != 4):
48  basf2.B2ERROR('SVD layer count failure: \n {0} layers reported, 4 actually.'.format(self.gToolsgTools.getNumberOfSVDLayers()))
49  # 0b. Layer numbers
50  layers = self.gToolsgTools.getLayers()
51  expected_layers = [1, 2, 3, 4, 5, 6]
52  match = True
53  for l1, l2 in zip(layers, expected_layers):
54  if l1 != l2:
55  match = False
56  break
57  if not match:
58  l1_string = ' '.join([str(x) for x in layers])
59  l2_string = ' '.join([str(x) for x in expected_layers])
60  basf2.B2ERROR('Layer numbers do not match, expected {0}, got {1}!'.format(l2_string, l1_string))
61 
62  layers = self.gToolsgTools.getPXDLayers()
63  expected_layers = [1, 2]
64  match = True
65  for l1, l2 in zip(layers, expected_layers):
66  if l1 != l2:
67  match = False
68  break
69  if not match:
70  l1_string = ' '.join([str(x) for x in layers])
71  l2_string = ' '.join([str(x) for x in expected_layers])
72  basf2.B2ERROR('PXD layer numbers do not match, expected {0}, got {1}!'.format(l2_string, l1_string))
73 
74  layers = self.gToolsgTools.getSVDLayers()
75  expected_layers = [3, 4, 5, 6]
76  match = True
77  for l1, l2 in zip(layers, expected_layers):
78  if l1 != l2:
79  match = False
80  break
81  if not match:
82  l1_string = ' '.join([str(x) for x in layers])
83  l2_string = ' '.join([str(x) for x in expected_layers])
84  basf2.B2ERROR('SVD layer numbers do not match, expected {0}, got {1}!'.format(l2_string, l1_string))
85 
86  # 0c. Layer ranges
87  if (self.gToolsgTools.getFirstLayer() != 1):
88  basf2.B2ERROR('First layer number is 1, reported {0}.'.format(self.gToolsgTools.getFirstLayer()))
89  if (self.gToolsgTools.getLastLayer() != 6):
90  basf2.B2ERROR('Last layer number is 6, reported {0}.'.format(self.gToolsgTools.getLastLayer()))
91  if (self.gToolsgTools.getFirstPXDLayer() != 1):
92  basf2.B2ERROR('First PXD layer number is 1, reported {0}.'.format(self.gToolsgTools.getFirstPXDLayer()))
93  if (self.gToolsgTools.getLastPXDLayer() != 2):
94  basf2.B2ERROR('Last PXD layer number is 2, reported {0}.'.format(self.gToolsgTools.getLastPXDLayer()))
95  if (self.gToolsgTools.getFirstSVDLayer() != 3):
96  basf2.B2ERROR('First SVD layer number is 3, reported {0}.'.format(self.gToolsgTools.getFirstSVDLayer()))
97  if (self.gToolsgTools.getLastSVDLayer() != 6):
98  basf2.B2ERROR('Last SVD layer number is 6, reported {0}.'.format(self.gToolsgTools.getLastSVDLayer()))
99  # 0d. Sensor indexing range
100  # PXD
101  # First PXD sensor should be (first PXD layer)/1/1,
102  idOfFirstPXDSensor = self.gToolsgTools.getSensorIDFromPXDIndex(0)
103  layer = idOfFirstPXDSensor.getLayerNumber()
104  ladder = idOfFirstPXDSensor.getLadderNumber()
105  sensor = idOfFirstPXDSensor.getSensorNumber()
106  if layer != self.gToolsgTools.getFirstPXDLayer() or ladder != 1 or sensor != 1:
107  basf2.B2ERROR('Mismatch in first PXD sensor placement:\n' +
108  'Expected {0}/{1}/{2}\nGot: {3}/{4}/{5}'.format(
109  layer, ladder, sensor,
110  self.gToolsgTools.getFirstPXDLayer(), 1, 1))
111  idOfLastPXDSensor = self.gToolsgTools.getSensorIDFromPXDIndex(self.gToolsgTools.getNumberOfPXDSensors() - 1)
112  layer = idOfLastPXDSensor.getLayerNumber()
113  if layer != self.gToolsgTools.getLastPXDLayer():
114  basf2.B2ERROR('Mismatch in last PXD sensor placement:\n' +
115  'Expected layer {0} got layer {1}'.format(
116  layer, self.gToolsgTools.getLastPXDLayer()))
117  # SVD
118  # First SVD sensor should be (first PXD layer)/1/1,
119  idOfFirstSVDSensor = self.gToolsgTools.getSensorIDFromSVDIndex(0)
120  layer = idOfFirstSVDSensor.getLayerNumber()
121  ladder = idOfFirstSVDSensor.getLadderNumber()
122  sensor = idOfFirstSVDSensor.getSensorNumber()
123  if layer != self.gToolsgTools.getFirstSVDLayer() or ladder != 1 or sensor != 1:
124  basf2.B2ERROR('Mismatch in first SVD sensor placement:\n' +
125  'Expected {0}/{1}/{2}\nGot: {3}/{4}/{5}'.format(
126  layer, ladder, sensor,
127  self.gToolsgTools.getFirstSVDLayer(), 1, 1))
128  idOfLastSVDSensor = self.gToolsgTools.getSensorIDFromSVDIndex(self.gToolsgTools.getNumberOfSVDSensors() - 1)
129  layer = idOfLastSVDSensor.getLayerNumber()
130  if layer != self.gToolsgTools.getLastSVDLayer():
131  basf2.B2ERROR('Mismatch in last SVD sensor placement:\n' +
132  'Expected layer {0} got layer {1}'.format(
133  layer, self.gToolsgTools.getLastSVDLayer()))
134  #
135  # 1. General sensor indexing
136  #
137  # 1a. Basic loop
138  init_sensorID = Belle2.VxdID(3, 1, 1)
139  init_sensor_index = self.gToolsgTools.getSensorIndex(init_sensorID)
140  ret_sensorID = self.gToolsgTools.getSensorIDFromIndex(init_sensor_index)
141  if init_sensorID.getID() != ret_sensorID.getID():
142  basf2.B2ERROR(
143  "Sensor index failure: \n Initial id: {0} \n VXD index: {1} \n Retrieved id: {2}.".format(
144  init_sensorID, init_sensor_index, ret_sensorID))
145  # 1b. Neighbourhood test
146  next_sensorID = self.gToolsgTools.getSensorIDFromIndex(init_sensor_index + 1)
147  next_expected_sensorID = Belle2.VxdID(init_sensorID)
148  next_expected_sensorID.setSensorNumber(init_sensorID.getSensorNumber() + 1)
149  if next_expected_sensorID.getID() != next_sensorID.getID():
150  basf2.B2ERROR('Sensor index neighbourhood test failure: \n' +
151  'Initial id: {0} \n Expected id: {1} \n Actaul id: {2} \n Index: {3}.'.format(
152  init_sensorID, next_expected_sensorID,
153  next_sensorID, init_sensor_index + 1
154  ))
155 
156  # 1c. Sensor counting
157  num_sensors_expected = 212
158  if (self.gToolsgTools.getNumberOfSensors() != num_sensors_expected):
159  basf2.B2ERROR('Number of sensors mismatch: \n' +
160  'Expected: {0}, got {1}.'.format(
161  num_sensors_expected, self.gToolsgTools.getNumberOfSensors()
162  ))
163  #
164  # 2. PXD sensor indexing
165  #
166  # 2a. Basic loop
167  init_sensorID = Belle2.VxdID(1, 2, 1)
168  init_sensor_index = self.gToolsgTools.getPXDSensorIndex(
169  init_sensorID.getLayerNumber(),
170  init_sensorID.getLadderNumber(),
171  init_sensorID.getSensorNumber())
172  ret_sensorID = self.gToolsgTools.getSensorIDFromPXDIndex(init_sensor_index)
173  if init_sensorID.getID() != ret_sensorID.getID():
174  basf2.B2ERROR(
175  "PXD sensor index failure: \n Initial id: {0} \n VXD index: {1} \n Retrieved id: {2}.".format(
176  init_sensorID, init_sensor_index, ret_sensorID))
177  # 2b. Neighbourhood test
178  next_sensorID = self.gToolsgTools.getSensorIDFromPXDIndex(init_sensor_index + 1)
179  next_expected_sensorID = Belle2.VxdID(init_sensorID)
180  next_expected_sensorID.setSensorNumber(init_sensorID.getSensorNumber() + 1)
181  if next_expected_sensorID.getID() != next_sensorID.getID():
182  basf2.B2ERROR(
183  'PXD sensor index neighbourhood test failure: \n' +
184  f'Initial id: {init_sensorID} \n Expected id: {next_expected_sensorID} \n Actual id: {next_sensorID} \n ' +
185  f'Index: {init_sensor_index + 1}.')
186  # 2c. Sensor counting
187  num_sensors_expected = 40
188  if (self.gToolsgTools.getNumberOfPXDSensors() != num_sensors_expected):
189  basf2.B2ERROR('Number of PXD sensors mismatch: \n' +
190  'Expected: {0}, got {1}.'.format(
191  num_sensors_expected, self.gToolsgTools.getNumberOfPXDSensors()
192  ))
193  #
194  # 3. SVD sensor indexing
195  #
196  # 2a. Basic loop
197  init_sensorID = Belle2.VxdID(4, 2, 1)
198  init_sensor_index = self.gToolsgTools.getSVDSensorIndex(
199  init_sensorID.getLayerNumber(),
200  init_sensorID.getLadderNumber(),
201  init_sensorID.getSensorNumber())
202  ret_sensorID = self.gToolsgTools.getSensorIDFromSVDIndex(init_sensor_index)
203  if init_sensorID.getID() != ret_sensorID.getID():
204  basf2.B2ERROR(
205  "SVD sensor index failure: \n Initial id: {0} \n VXD index: {1} \n Retrieved id: {2}.".format(
206  init_sensorID, init_sensor_index, ret_sensorID))
207  # 2b. Neighbourhood test
208  next_sensorID = self.gToolsgTools.getSensorIDFromSVDIndex(init_sensor_index + 1)
209  next_expected_sensorID = Belle2.VxdID(init_sensorID)
210  next_expected_sensorID.setSensorNumber(init_sensorID.getSensorNumber() + 1)
211  if next_expected_sensorID.getID() != next_sensorID.getID():
212  basf2.B2ERROR(
213  'SVD sensor index neighbourhood test failure: \n'
214  'Initial id: {0} \n Expected id: {1} \n Actaul id: {2} \n '
215  'Index: {3}.'.format(init_sensorID, next_expected_sensorID,
216  next_sensorID, init_sensor_index + 1))
217  # 3c. Sensor counting
218  num_sensors_expected = 172
219  if (self.gToolsgTools.getNumberOfSVDSensors() != num_sensors_expected):
220  basf2.B2ERROR('Number of SVD sensors mismatch: \n' +
221  'Expected: {0}, got {1}.'.format(
222  num_sensors_expected, self.gToolsgTools.getNumberOfSVDSensors()
223  ))
224  #
225  # 4. Layer indexing
226  #
227  # 4a. Basic loop
228  init_layer = 4
229  init_layer_index = self.gToolsgTools.getLayerIndex(init_layer)
230  ret_layer = self.gToolsgTools.getLayerNumberFromLayerIndex(init_layer_index)
231  if init_layer != ret_layer:
232  basf2.B2ERROR(
233  "Layer index failure: \n Initial: {0} \n Index: {1} \n Retrieved: {2}.".format(
234  init_layer, init_layer_index, ret_layer))
235  # 2b. Neighbourhood test
236  next_layer = self.gToolsgTools.getLayerNumberFromLayerIndex(init_layer_index + 1)
237  next_expected_layer = init_layer + 1
238  if next_layer != next_expected_layer:
239  basf2.B2ERROR(
240  "Layer index neighbourhood test failure: \n Initial id: {0} \n Expected: {1} \n Actaul: {2} \n Index: {3}.".format(
241  init_layer,
242  next_expected_layer,
243  next_layer,
244  init_layer_index +
245  1))
246  #
247  # 5. PXD chip indexing
248  #
249  # 5a. Chip-on-sensor counts
250  if self.gToolsgTools.getTotalPXDChips() != 400:
251  basf2.B2ERROR('PXD chip count mismatch: \n' +
252  'Expected: {0}, got {1}.'.format(
253  2120, self.gToolsgTools.getTotalPXDChips())
254  )
255  if self.gToolsgTools.getNumberOfPXDUSideChips() != 4:
256  basf2.B2ERROR('PXD u-side chip count mismatch: \n' +
257  'Expected: {0}, got {1}.'.format(
258  4, self.gToolsgTools.getNumberOfPXDUSideChips())
259  )
260  if self.gToolsgTools.getNumberOfPXDVSideChips() != 6:
261  basf2.B2ERROR('PXD v-side chip count mismatch: \n' +
262  'Expected: {0}, got {1}.'.format(
263  6, self.gToolsgTools.getNumberOfPXDVSideChips())
264  )
265  if self.gToolsgTools.getTotalSVDChips() != 1748:
266  basf2.B2ERROR('SVD chip count mismatch: \n' +
267  'Expected: {0}, got {1}.'.format(
268  2148, self.gToolsgTools.getTotalSVDChips())
269  )
270  if self.gToolsgTools.getNumberOfSVDUSideChips() != 6:
271  basf2.B2ERROR('SVD u-side chip count mismatch: \n' +
272  'Expected: {0}, got {1}.'.format(
273  6, self.gToolsgTools.getNumberOfSVDUSideChips())
274  )
275  if self.gToolsgTools.getNumberOfSVDVSideChips(3) != 6:
276  basf2.B2ERROR('SVD v-side chip count mismatch: \n' +
277  'Expected: {0}, got {1}.'.format(
278  6, self.gToolsgTools.getNumberOfSVDVSideChips(3))
279  )
280  if self.gToolsgTools.getNumberOfSVDVSideChips(4) != 4:
281  basf2.B2ERROR('SVD v-side chip count mismatch: \n' +
282  'Expected: {0}, got {1}.'.format(
283  4, self.gToolsgTools.getNumberOfSVDVSideChips(4))
284  )
285  # 5b. PXD chip indexing - loop
286  init_layer = 1
287  init_ladder = 2
288  init_sensor = 1
289  init_uSide = True
290  init_chipNo = 4
291  index_with_vxdid = self.gToolsgTools.getPXDChipIndex(Belle2.VxdID(init_layer, init_ladder, init_sensor), init_uSide, init_chipNo)
292  index_with_llss = self.gToolsgTools.getPXDChipIndex(init_layer, init_ladder, init_sensor, init_uSide, init_chipNo)
293  if index_with_vxdid != index_with_llss:
294  basf2.B2ERROR('Mismatch between VxdID-based and layer-ladder-sensor based index:\n' +
295  'VxdID-based: {0}\nlayer-ladder-sensor: {1}'.format(
296  index_with_vxdid, index_with_llss)
297  )
298  returned_chipID = self.gToolsgTools.getChipIDFromPXDIndex(index_with_vxdid)
299  returned_layer = returned_chipID.getLayerNumber()
300  returned_ladder = returned_chipID.getLadderNumber()
301  returned_sensor = returned_chipID.getSensorNumber()
302  returned_uSide = self.gToolsgTools.isPXDSideU(returned_chipID)
303  returned_chipNo = self.gToolsgTools.getPXDChipNumber(returned_chipID)
304  match = (init_layer == returned_layer) and \
305  (init_ladder == returned_ladder) and \
306  (init_sensor == returned_sensor) and \
307  (init_uSide == returned_uSide) and \
308  (init_chipNo == returned_chipNo)
309  if not match:
310  basf2.B2ERROR('Mismatch in PXD chip indexing:\n' +
311  'Initial: {0} {1} {2} {3} {4}\n'.format(
312  init_layer, init_ladder, init_sensor, init_uSide, init_chipNo) +
313  'Final: {0} {1} {2} {3} {4}.'.format(
314  returned_layer, returned_ladder, returned_sensor, returned_uSide, returned_chipNo)
315  )
316  # 5c. PXD chip indexing - neighbourhood
317  # We are expecting same sensor, v-side, chip 0
318  expected_layer = init_layer
319  expected_ladder = init_ladder
320  expected_sensor = init_sensor
321  expected_uSide = False
322  expected_chipNo = 1
323  neighbour_chipID = self.gToolsgTools.getChipIDFromPXDIndex(index_with_vxdid + 1)
324  neighbour_layer = neighbour_chipID.getLayerNumber()
325  neighbour_ladder = neighbour_chipID.getLadderNumber()
326  neighbour_sensor = neighbour_chipID.getSensorNumber()
327  neighbour_uSide = self.gToolsgTools.isPXDSideU(neighbour_chipID)
328  neighbour_chipNo = self.gToolsgTools.getPXDChipNumber(neighbour_chipID)
329  match = (expected_layer == neighbour_layer) and \
330  (expected_ladder == neighbour_ladder) and \
331  (expected_sensor == neighbour_sensor) and \
332  (expected_uSide == neighbour_uSide) and \
333  (expected_chipNo == neighbour_chipNo)
334  if not match:
335  basf2.B2ERROR('Mismatch in PXD chip index neighbourship:\n' +
336  'Expected: {0} {1} {2} {3} {4}\n'.format(
337  expected_layer, expected_ladder, expected_sensor, expected_uSide, expected_chipNo) +
338  'Obtained: {0} {1} {2} {3} {4}.'.format(
339  neighbour_layer, neighbour_ladder, neighbour_sensor, neighbour_uSide, neighbour_chipNo)
340  )
341 
342  # 5d. SVD chip indexing - loop
343  init_layer = 3
344  init_ladder = 2
345  init_sensor = 1
346  init_uSide = True
347  init_chipNo = 6
348  index_with_vxdid = self.gToolsgTools.getSVDChipIndex(Belle2.VxdID(init_layer, init_ladder, init_sensor), init_uSide, init_chipNo)
349  index_with_llss = self.gToolsgTools.getSVDChipIndex(init_layer, init_ladder, init_sensor, init_uSide, init_chipNo)
350  if index_with_vxdid != index_with_llss:
351  basf2.B2ERROR('Mismatch between VxdID-based and layer-ladder-sensor based index:\n' +
352  'VxdID-based: {0}\nlayer-ladder-sensor: {1}'.format(
353  index_with_vxdid, index_with_llss)
354  )
355  returned_chipID = self.gToolsgTools.getChipIDFromSVDIndex(index_with_vxdid)
356  returned_layer = returned_chipID.getLayerNumber()
357  returned_ladder = returned_chipID.getLadderNumber()
358  returned_sensor = returned_chipID.getSensorNumber()
359  returned_uSide = self.gToolsgTools.isSVDSideU(returned_chipID)
360  returned_chipNo = self.gToolsgTools.getSVDChipNumber(returned_chipID)
361  match = (init_layer == returned_layer) and \
362  (init_ladder == returned_ladder) and \
363  (init_sensor == returned_sensor) and \
364  (init_uSide == returned_uSide) and \
365  (init_chipNo == returned_chipNo)
366  if not match:
367  basf2.B2ERROR('Mismatch in SVD chip indexing:\n' +
368  'Initial: {0} {1} {2} {3} {4}\n'.format(
369  init_layer, init_ladder, init_sensor, init_uSide, init_chipNo) +
370  'Final: {0} {1} {2} {3} {4}.'.format(
371  returned_layer, returned_ladder, returned_sensor, returned_uSide, returned_chipNo)
372  )
373  # 5e. SVD chip indexing - neighbourhood
374  # We are expecting same sensor, v-side, chip 0
375  expected_layer = init_layer
376  expected_ladder = init_ladder
377  expected_sensor = init_sensor
378  expected_uSide = False
379  expected_chipNo = 1
380  neighbour_chipID = self.gToolsgTools.getChipIDFromSVDIndex(index_with_vxdid + 1)
381  neighbour_layer = neighbour_chipID.getLayerNumber()
382  neighbour_ladder = neighbour_chipID.getLadderNumber()
383  neighbour_sensor = neighbour_chipID.getSensorNumber()
384  neighbour_uSide = self.gToolsgTools.isSVDSideU(neighbour_chipID)
385  neighbour_chipNo = self.gToolsgTools.getSVDChipNumber(neighbour_chipID)
386  match = (expected_layer == neighbour_layer) and \
387  (expected_ladder == neighbour_ladder) and \
388  (expected_sensor == neighbour_sensor) and \
389  (expected_uSide == neighbour_uSide) and \
390  (expected_chipNo == neighbour_chipNo)
391  if not match:
392  basf2.B2ERROR('Mismatch in SVD chip index neighbourship:\n' +
393  'Expected: {0} {1} {2} {3} {4}\n'.format(
394  expected_layer, expected_ladder, expected_sensor, expected_uSide, expected_chipNo) +
395  'Obtained: {0} {1} {2} {3} {4}.'.format(
396  neighbour_layer, neighbour_ladder, neighbour_sensor, neighbour_uSide, neighbour_chipNo)
397  )
398  # 5f. Test of PXD chip assignment
399  # We want to see that the first and last chips have correct placement.
400  indexOfFirstPXDChip = 0
401  # First chip must be on first PXD layer, 1st ladder, 1st sensor, u-sie,
402  # chip 0.
403  idOfFirstPXDChip = self.gToolsgTools.getChipIDFromPXDIndex(indexOfFirstPXDChip)
404  firstChipLayer = idOfFirstPXDChip.getLayerNumber()
405  firstChipLadder = idOfFirstPXDChip.getLadderNumber()
406  firstChipSensor = idOfFirstPXDChip.getSensorNumber()
407  firstChipUSide = self.gToolsgTools.isPXDSideU(idOfFirstPXDChip)
408  firstChipNo = self.gToolsgTools.getPXDChipNumber(idOfFirstPXDChip)
409  if (firstChipLayer != self.gToolsgTools.getFirstPXDLayer() or
410  firstChipLadder != 1 or
411  firstChipSensor != 1 or
412  not firstChipUSide or
413  firstChipNo != 1):
414  basf2.B2ERROR(
415  'Wrong 1st PXD chip assignment:\nExpected {0}/{1}/{2} side {3} chip {4},\nGot {5}/{6}/{7} side {8} chip {9}'.format(
416  self.gToolsgTools.getFirstPXDLayer(),
417  1,
418  1,
419  'u',
420  1,
421  firstChipLayer,
422  firstChipLadder,
423  firstChipSensor,
424  'u' if firstChipUSide else 'v',
425  firstChipNo))
426  indexOfLastPXDChip = self.gToolsgTools.getTotalPXDChips() - 1
427  # Last chip must be on last PXD layer, v-sie, chip 6.
428  idOfLastPXDChip = self.gToolsgTools.getChipIDFromPXDIndex(indexOfLastPXDChip)
429  lastChipLayer = idOfLastPXDChip.getLayerNumber()
430  lastChipUSide = self.gToolsgTools.isPXDSideU(idOfLastPXDChip)
431  lastChipNo = self.gToolsgTools.getPXDChipNumber(idOfLastPXDChip)
432  expectedLastChipNo = self.gToolsgTools.getNumberOfPXDVSideChips(self.gToolsgTools.getLastPXDLayer())
433  if (lastChipLayer != self.gToolsgTools.getLastPXDLayer() or
434  lastChipUSide or
435  lastChipNo != expectedLastChipNo):
436  basf2.B2ERROR(
437  'Wrong last PXD chip assignment:\n' +
438  'Expected layer {0} side {1} chip {2},\nGot layer {3} side {4} chip {5}'.format(
439  self.gToolsgTools.getLastPXDLayer(),
440  'v',
441  expectedLastChipNo,
442  lastChipLayer,
443  'u' if lastChipUSide else 'v',
444  lastChipNo))
445  # 5g. Test of SVD chip assignment
446  # We want to see that the first and last chips have correct placement.
447  indexOfFirstSVDChip = 0
448  # First chip must be on first SVD layer, 1st ladder, 1st sensor, u-sie,
449  # chip 0.
450  idOfFirstSVDChip = self.gToolsgTools.getChipIDFromSVDIndex(indexOfFirstSVDChip)
451  firstChipLayer = idOfFirstSVDChip.getLayerNumber()
452  firstChipLadder = idOfFirstSVDChip.getLadderNumber()
453  firstChipSensor = idOfFirstSVDChip.getSensorNumber()
454  firstChipUSide = self.gToolsgTools.isSVDSideU(idOfFirstSVDChip)
455  firstChipNo = self.gToolsgTools.getSVDChipNumber(idOfFirstSVDChip)
456  if (firstChipLayer != self.gToolsgTools.getFirstSVDLayer() or
457  firstChipLadder != 1 or
458  firstChipSensor != 1 or
459  not firstChipUSide or
460  firstChipNo != 1):
461  basf2.B2ERROR(
462  'Wrong 1st SVD chip assignment:\nExpected {0}/{1}/{2} side {3} chip {4},\nGot {5}/{6}/{7} side {8} chip {9}'.format(
463  self.gToolsgTools.getFirstSVDLayer(),
464  1,
465  1,
466  'u',
467  1,
468  firstChipLayer,
469  firstChipLadder,
470  firstChipSensor,
471  'u' if firstChipUSide else 'v',
472  firstChipNo))
473  indexOfLastSVDChip = self.gToolsgTools.getTotalSVDChips() - 1
474  # Last chip must be on last SVD layer, v-sie, chip 6.
475  idOfLastSVDChip = self.gToolsgTools.getChipIDFromSVDIndex(indexOfLastSVDChip)
476  lastChipLayer = idOfLastSVDChip.getLayerNumber()
477  lastChipUSide = self.gToolsgTools.isSVDSideU(idOfLastSVDChip)
478  lastChipNo = self.gToolsgTools.getSVDChipNumber(idOfLastSVDChip)
479  expectedLastChipNo = self.gToolsgTools.getNumberOfSVDVSideChips(self.gToolsgTools.getLastSVDLayer())
480  if (lastChipLayer != self.gToolsgTools.getLastSVDLayer() or
481  lastChipUSide or
482  lastChipNo != expectedLastChipNo):
483  basf2.B2ERROR(
484  'Wrong last SVD chip assignment:\n' +
485  'Expected layer {0} side {1} chip {2},\nGot layer {3} side {4} chip {5}'.format(
486  self.gToolsgTools.getLastSVDLayer(),
487  'v',
488  expectedLastChipNo,
489  lastChipLayer,
490  'u' if lastChipUSide else 'v',
491  lastChipNo))
492 
493  # END OF TESTS
494 
495 
496 if __name__ == "__main__":
497 
499 
500  basf2.B2INFO('Setting up a basf2 run...')
501 
502  check_numbering = basf2.create_path()
503  check_numbering.add_module('EventInfoSetter', expList=[0], runList=[0], evtNumList=[1])
504  check_numbering.add_module('Gearbox')
505  check_numbering.add_module('Geometry', components=['MagneticField', 'PXD', 'SVD'])
506  check_numbering.add_module(CheckNumbering())
507  # with b2test_utils.show_only_errors():
508  b2test_utils.safe_process(check_numbering)
509 
510  basf2.B2INFO('Test complete.')
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
gTools
Reference to GeoTools class.
def clean_working_directory()
Definition: __init__.py:189
def safe_process(*args, **kwargs)
Definition: __init__.py:236