14from ROOT
import Belle2
21 Base class to calculate global deformation of the detector
25 """ Constructor, sets the scale of the transformation """
31 """ Return TVector3 with difference in global position induced by the deformation,
32 given the original x,y,z position as TVector3 or a list with length of 3.
36 d_rphiz = self.
_transform(rphiz[0], rphiz[1], rphiz[2])
38 rphiz[0] += d_rphiz[0]
39 rphiz[1] += d_rphiz[1]
40 rphiz[2] += d_rphiz[2]
44 d_xyz = ROOT.TVector3(new_xyz[0] - xyz[0], new_xyz[1] - xyz[1], new_xyz[2] - xyz[2])
49 """ Fcn to be overridden by child classes, return vector (list of 3 numbers) of displacement """
52 """ Convert (x,y,z) to (r,phi,z) """
57 r = math.sqrt(x * x + y * y)
58 phi = math.atan2(y, x)
63 """ Convert (r,phi,z) to (x,y,z) """
66 y = rphiz[0] * math.sin(rphiz[1])
67 x = rphiz[0] * math.cos(rphiz[1])
72 """ radial expansion """
79 """ the transformation """
80 return [self.
scale * r, 0., 0.]
87 """ init with scale, optionally scale2 for 1/r dependency """
94 """ the transformation """
106 """ the transformation """
107 return [0., 0., self.
scale * r]
111 """ Elliptical distortion """
118 """ the transformation """
120 return [self.
scale * 1. / 2. * math.cos(2 * phi) * r, 0., 0.]
124 """ Clamshell deformation """
131 """ the transformation """
134 return [0., self.
scale * math.cos(phi), 0.]
138 """ Skew distortion """
145 """ the transformation """
146 return [0., 0., self.
scale * math.cos(phi) * r]
157 """ the transformation """
158 return [self.
scale * abs(z), 0., 0.]
162 """ Twist deformation """
169 """ the transformation """
170 return [0., self.
scale * z, 0.]
181 """ the transformation """
182 return [0., 0., self.
scale * z]
186 """ Module to create misalignment (first reads real sensor positions, then applies misalignment and returns DB payload)
187 TODO: random misalignment not finished...
190 def __init__(self, global_deformations=None, random_misalignments=None, iov=Belle2.IntervalOfValidity(0, 0, -1, -1)):
191 """ Constructor with with input misalignment """
203 """ module initialize - read geometry, apply misalignment, create and store payloads """
206 txt = open(
'generated_misalignment.txt',
'w')
207 txt.write(
'layer ladder sensor x_orig y_orig z_orig x y z u v w\n')
211 global_pos = info.pointToGlobal(ROOT.TVector3(0., 0., 0.))
213 delta = ROOT.TVector3(0., 0., 0.)
216 if global_deformations
is not None:
217 if not isinstance(global_deformations, list):
218 global_deformations = [global_deformations]
221 for deformation
in global_deformations:
222 delta += deformation(global_pos)
225 delta = ROOT.TVector3(0., 0., 0.)
227 new_global_pos = global_pos + delta
228 new_local_pos = info.pointToLocal(new_global_pos)
237 for i
in range(0, 3):
238 if abs(new_local_pos[i]) < 1.e-14:
239 new_local_pos[i] = 0.
241 alignment.set(sensor.getID(), i + 1, new_local_pos[i])
249 '{} {} {} {} {} {} {} {} {} {} {} {}\n'.format(
250 str(sensor.getLayerNumber()),
251 str(sensor.getLadderNumber()),
252 str(sensor.getSensorNumber()),
256 str(new_global_pos[0]),
257 str(new_global_pos[1]),
258 str(new_global_pos[2]),
259 str(new_local_pos[0]),
260 str(new_local_pos[1]),
261 str(new_local_pos[2])
VXD alignment (and maybe some calibration) parameters.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Class to uniquely identify a any structure of the PXD and SVD.
_transform(self, r, phi, z)
_transform(self, r, phi, z)
global_deformations
systematic deformations
list random_misalignments
random misalignments
__init__(self, global_deformations=None, random_misalignments=None, iov=Belle2.IntervalOfValidity(0, 0, -1, -1))
iov
interval of validity for the generated payload
scale2
second scale for 1/r member
__init__(self, scale, scale2=0.)
_transform(self, r, phi, z)
_transform(self, r, phi, z)
_transform(self, r, phi, z)
_transform(self, r, phi, z)
_transform(self, r, phi, z)
_transform(self, r, phi, z)
_transform(self, r, phi, z)
static Database & Instance()
Instance of a singleton Database.