13from lxml.etree
import Element
14from lxml.etree
import SubElement
16svd_layers = [3, 4, 5, 6]
17svd_nsensors = {3: 2, 4: 3, 5: 4, 6: 5}
18svd_nladders = {3: 7, 4: 10, 5: 12, 6: 16}
20misalignment_shifts = [
'du',
'dv',
'dw']
22misalignment_rotations = [
'dalpha',
'dbeta',
'dgamma']
26svd_misalignment = Element(
'SVD', name=
'Random misalignment')
30for i_layer
in svd_layers:
31 layer_id = str(i_layer) +
'.0.0'
32 layer = SubElement(svd_misalignment,
'layer', id=layer_id)
34 for i_ladder
in range(svd_nladders[i_layer]):
35 ladder_id = str(i_layer) +
'.' + str(i_ladder + 1) +
'.0'
36 ladder = SubElement(layer,
'ladder', id=ladder_id)
38 for i_sensor
in range(svd_nsensors[i_layer]):
39 sensor_id = str(i_layer) +
'.' + str(i_ladder + 1) +
'.' + str(i_sensor + 1)
40 sensor = SubElement(ladder,
'sensor', id=sensor_id)
42 for param
in misalignment_shifts:
43 dx = random.normalvariate(0.0, sigma_shifts)
44 p = SubElement(sensor, param, unit=
'um', sigma=str(sigma_shifts))
46 for param
in misalignment_rotations:
47 dx = random.normalvariate(0.0, sigma_rotations)
48 p = SubElement(sensor, param, unit=
'mrad', sigma=str(sigma_rotations))
51tree = etree.ElementTree(svd_misalignment)
53tree.write(
'SVDMisalignment.xml', pretty_print=
True, xml_declaration=
True, encoding=
'utf-8', method=
'xml')