]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * SigmaEffect_thetadegrees * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpeateose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | // | |
18 | //__________________________________________________________________ | |
19 | /// \class AliMUONGeometryMisAligner | |
20 | /// | |
21 | /// This performs the misalignment on an existing muon arm geometry | |
22 | /// based on the standard definition of the detector elements in | |
23 | /// $ALICE_ROOT/MUON/data | |
24 | /// | |
25 | /// --> User has to specify the magnitude of the alignments, in the Cartesian | |
26 | /// co-ordiantes (which are used to apply translation misalignments) and in the | |
27 | /// spherical co-ordinates (which are used to apply angular displacements) | |
28 | /// | |
29 | /// --> If the constructor is used with no arguments, user has to set | |
30 | /// misalignment ranges by hand using the methods : | |
31 | /// SetApplyMisAlig, SetMaxCartMisAlig, SetMaxAngMisAlig, SetXYAngMisAligFactor | |
32 | /// (last method takes account of the fact that the misalingment is greatest in | |
33 | /// the XY plane, since the detection elements are fixed to a support structure | |
34 | /// in this plane. Misalignments in the XZ and YZ plane will be very small | |
35 | /// compared to those in the XY plane, which are small already - of the order | |
36 | /// of microns) | |
37 | /// | |
38 | /// Note : If the detection elements are allowed to be misaligned in all | |
39 | /// directions, this has consequences for the alignment algorithm | |
40 | /// (AliMUONAlignment), which needs to know the number of free parameters. | |
41 | /// Eric only allowed 3 : x,y,theta_xy, but in principle z and the other | |
42 | /// two angles are alignable as well. | |
43 | /// | |
44 | /// \author Bruce Becker, Javier Castillo | |
45 | ||
46 | #include "AliMUONGeometryMisAligner.h" | |
47 | #include "AliMUONGeometryTransformer.h" | |
48 | #include "AliMUONGeometryModuleTransformer.h" | |
49 | #include "AliMUONGeometryDetElement.h" | |
50 | #include "AliMUONGeometryBuilder.h" | |
51 | ||
52 | #include "AliMpExMap.h" | |
53 | ||
54 | #include "AliLog.h" | |
55 | ||
56 | #include <TGeoMatrix.h> | |
57 | #include <TMath.h> | |
58 | #include <TRandom.h> | |
59 | ||
60 | /// \cond CLASSIMP | |
61 | ClassImp(AliMUONGeometryMisAligner) | |
62 | /// \endcond | |
63 | ||
64 | //______________________________________________________________________________ | |
65 | AliMUONGeometryMisAligner::AliMUONGeometryMisAligner(Double_t cartXMisAligM, Double_t cartXMisAligW, Double_t cartYMisAligM, Double_t cartYMisAligW, Double_t angMisAligM, Double_t angMisAligW) | |
66 | : TObject(), | |
67 | fUseUni(kFALSE), | |
68 | fUseGaus(kTRUE), | |
69 | fXYAngMisAligFactor(0.0), | |
70 | fZCartMisAligFactor(0.0), | |
71 | fDisplacementGenerator(0) | |
72 | { | |
73 | /// Standard constructor | |
74 | for (Int_t i=0; i<6; i++){ | |
75 | for (Int_t j=0; j<2; j++){ | |
76 | fDetElemMisAlig[i][j] = 0.0; | |
77 | fModuleMisAlig[i][j] = 0.0; | |
78 | } | |
79 | } | |
80 | fDetElemMisAlig[0][0] = cartXMisAligM; | |
81 | fDetElemMisAlig[0][1] = cartXMisAligW; | |
82 | fDetElemMisAlig[1][0] = cartYMisAligM; | |
83 | fDetElemMisAlig[1][1] = cartYMisAligW; | |
84 | fDetElemMisAlig[5][0] = angMisAligM; | |
85 | fDetElemMisAlig[5][1] = angMisAligW; | |
86 | ||
87 | fDisplacementGenerator = new TRandom(0); | |
88 | } | |
89 | ||
90 | //______________________________________________________________________________ | |
91 | AliMUONGeometryMisAligner::AliMUONGeometryMisAligner(Double_t cartMisAligM, Double_t cartMisAligW, Double_t angMisAligM, Double_t angMisAligW) | |
92 | : TObject(), | |
93 | fUseUni(kFALSE), | |
94 | fUseGaus(kTRUE), | |
95 | fXYAngMisAligFactor(0.0), | |
96 | fZCartMisAligFactor(0.0), | |
97 | fDisplacementGenerator(0) | |
98 | { | |
99 | /// Standard constructor | |
100 | for (Int_t i=0; i<6; i++){ | |
101 | for (Int_t j=0; j<2; j++){ | |
102 | fDetElemMisAlig[i][j] = 0.0; | |
103 | fModuleMisAlig[i][j] = 0.0; | |
104 | } | |
105 | } | |
106 | fDetElemMisAlig[0][0] = cartMisAligM; | |
107 | fDetElemMisAlig[0][1] = cartMisAligW; | |
108 | fDetElemMisAlig[1][0] = cartMisAligM; | |
109 | fDetElemMisAlig[1][1] = cartMisAligW; | |
110 | fDetElemMisAlig[5][0] = angMisAligM; | |
111 | fDetElemMisAlig[5][1] = angMisAligW; | |
112 | ||
113 | fDisplacementGenerator = new TRandom(0); | |
114 | } | |
115 | ||
116 | //______________________________________________________________________________ | |
117 | AliMUONGeometryMisAligner::AliMUONGeometryMisAligner(Double_t cartMisAlig, Double_t angMisAlig) | |
118 | : TObject(), | |
119 | fUseUni(kTRUE), | |
120 | fUseGaus(kFALSE), | |
121 | fXYAngMisAligFactor(0.0), | |
122 | fZCartMisAligFactor(0.0), | |
123 | fDisplacementGenerator(0) | |
124 | { | |
125 | /// Standard constructor | |
126 | for (Int_t i=0; i<6; i++){ | |
127 | for (Int_t j=0; j<2; j++){ | |
128 | fDetElemMisAlig[i][j] = 0.0; | |
129 | fModuleMisAlig[i][j] = 0.0; | |
130 | } | |
131 | } | |
132 | fDetElemMisAlig[0][1] = cartMisAlig; | |
133 | fDetElemMisAlig[1][1] = cartMisAlig; | |
134 | fDetElemMisAlig[5][1] = angMisAlig; | |
135 | ||
136 | fDisplacementGenerator = new TRandom(0); | |
137 | } | |
138 | ||
139 | //_____________________________________________________________________________ | |
140 | AliMUONGeometryMisAligner::AliMUONGeometryMisAligner() | |
141 | : TObject(), | |
142 | fUseUni(kTRUE), | |
143 | fUseGaus(kFALSE), | |
144 | fXYAngMisAligFactor(0.0), | |
145 | fZCartMisAligFactor(0.0), | |
146 | fDisplacementGenerator(0) | |
147 | { | |
148 | /// Default constructor | |
149 | for (Int_t i=0; i<6; i++){ | |
150 | for (Int_t j=0; j<2; j++){ | |
151 | fDetElemMisAlig[i][j] = 0.0; | |
152 | fModuleMisAlig[i][j] = 0.0; | |
153 | } | |
154 | } | |
155 | } | |
156 | ||
157 | //______________________________________________________________________________ | |
158 | AliMUONGeometryMisAligner::~AliMUONGeometryMisAligner() | |
159 | { | |
160 | /// Destructor | |
161 | ||
162 | if (fDisplacementGenerator) delete fDisplacementGenerator; | |
163 | } | |
164 | ||
165 | //_________________________________________________________________________ | |
166 | void | |
167 | AliMUONGeometryMisAligner::SetXYAngMisAligFactor(Double_t factor) | |
168 | { | |
169 | /// Set XY angular misalign factor | |
170 | ||
171 | if (TMath::Abs(factor) > 1.0 && factor > 0.){ | |
172 | fXYAngMisAligFactor = factor; | |
173 | fDetElemMisAlig[3][0] = fDetElemMisAlig[5][0]*factor; // These lines were | |
174 | fDetElemMisAlig[3][1] = fDetElemMisAlig[5][1]*factor; // added to keep | |
175 | fDetElemMisAlig[4][0] = fDetElemMisAlig[5][0]*factor; // backward | |
176 | fDetElemMisAlig[4][1] = fDetElemMisAlig[5][1]*factor; // compatibility | |
177 | } | |
178 | else | |
179 | AliError(Form("Invalid XY angular misalign factor, %d", factor)); | |
180 | } | |
181 | ||
182 | //_________________________________________________________________________ | |
183 | void AliMUONGeometryMisAligner::SetZCartMisAligFactor(Double_t factor) | |
184 | { | |
185 | /// Set XY angular misalign factor | |
186 | if (TMath::Abs(factor)<1.0 && factor>0.) { | |
187 | fZCartMisAligFactor = factor; | |
188 | fDetElemMisAlig[2][0] = fDetElemMisAlig[0][0]; // These lines were added to | |
189 | fDetElemMisAlig[2][1] = fDetElemMisAlig[0][1]*factor; // keep backward compatibility | |
190 | } | |
191 | else | |
192 | AliError(Form("Invalid Z cartesian misalign factor, %d", factor)); | |
193 | } | |
194 | ||
195 | //_________________________________________________________________________ | |
196 | void AliMUONGeometryMisAligner::GetUniMisAlign(Double_t cartMisAlig[3], Double_t angMisAlig[3], const Double_t lParMisAlig[6][2]) const | |
197 | { | |
198 | /// Misalign using uniform distribution | |
199 | /** | |
200 | misalign the centre of the local transformation | |
201 | rotation axes : | |
202 | fAngMisAlig[1,2,3] = [x,y,z] | |
203 | Assume that misalignment about the x and y axes (misalignment of z plane) | |
204 | is much smaller, since the entire detection plane has to be moved (the | |
205 | detection elements are on a support structure), while rotation of the x-y | |
206 | plane is more free. | |
207 | */ | |
208 | cartMisAlig[0] = fDisplacementGenerator->Uniform(-lParMisAlig[0][1]+lParMisAlig[0][0], lParMisAlig[0][0]+lParMisAlig[0][1]); | |
209 | cartMisAlig[1] = fDisplacementGenerator->Uniform(-lParMisAlig[1][1]+lParMisAlig[1][0], lParMisAlig[1][0]+lParMisAlig[1][1]); | |
210 | cartMisAlig[2] = fDisplacementGenerator->Uniform(-lParMisAlig[2][1]+lParMisAlig[2][0], lParMisAlig[2][0]+lParMisAlig[2][1]); | |
211 | ||
212 | angMisAlig[0] = fDisplacementGenerator->Uniform(-lParMisAlig[3][1]+lParMisAlig[3][0], lParMisAlig[3][0]+lParMisAlig[3][1]); | |
213 | angMisAlig[1] = fDisplacementGenerator->Uniform(-lParMisAlig[4][1]+lParMisAlig[4][0], lParMisAlig[4][0]+lParMisAlig[4][1]); | |
214 | angMisAlig[2] = fDisplacementGenerator->Uniform(-lParMisAlig[5][1]+lParMisAlig[5][0], lParMisAlig[5][0]+lParMisAlig[5][1]); // degrees | |
215 | } | |
216 | ||
217 | //_________________________________________________________________________ | |
218 | void AliMUONGeometryMisAligner::GetGausMisAlign(Double_t cartMisAlig[3], Double_t angMisAlig[3], const Double_t lParMisAlig[6][2]) const | |
219 | { | |
220 | /// Misalign using gaussian distribution | |
221 | /** | |
222 | misalign the centre of the local transformation | |
223 | rotation axes : | |
224 | fAngMisAlig[1,2,3] = [x,y,z] | |
225 | Assume that misalignment about the x and y axes (misalignment of z plane) | |
226 | is much smaller, since the entire detection plane has to be moved (the | |
227 | detection elements are on a support structure), while rotation of the x-y | |
228 | plane is more free. | |
229 | */ | |
230 | cartMisAlig[0] = fDisplacementGenerator->Gaus(lParMisAlig[0][0], lParMisAlig[0][1]); | |
231 | cartMisAlig[1] = fDisplacementGenerator->Gaus(lParMisAlig[1][0], lParMisAlig[1][1]); | |
232 | cartMisAlig[2] = fDisplacementGenerator->Gaus(lParMisAlig[2][0], lParMisAlig[2][1]); | |
233 | ||
234 | angMisAlig[0] = fDisplacementGenerator->Gaus(lParMisAlig[3][0], lParMisAlig[3][1]); | |
235 | angMisAlig[1] = fDisplacementGenerator->Gaus(lParMisAlig[4][0], lParMisAlig[4][1]); | |
236 | angMisAlig[2] = fDisplacementGenerator->Gaus(lParMisAlig[5][0], lParMisAlig[5][1]); // degrees | |
237 | } | |
238 | ||
239 | //_________________________________________________________________________ | |
240 | TGeoCombiTrans AliMUONGeometryMisAligner::MisAlignDetElem(const TGeoCombiTrans & transform) const | |
241 | { | |
242 | /// Misalign given transformation and return the misaligned transformation. | |
243 | /// Use misalignment parameters for detection elements. | |
244 | /// Note that applied misalignments are small deltas with respect to the detection | |
245 | /// element own ideal local reference frame. Thus deltaTransf represents | |
246 | /// the transformation to go from the misaligned d.e. local coordinates to the | |
247 | /// ideal d.e. local coordinates. | |
248 | /// Also note that this -is not- what is in the ALICE alignment framework known | |
249 | /// as local nor global (see AliMUONGeometryMisAligner::MisAlign) | |
250 | ||
251 | Double_t cartMisAlig[3] = {0,0,0}; | |
252 | Double_t angMisAlig[3] = {0,0,0}; | |
253 | ||
254 | if (fUseUni) { | |
255 | GetUniMisAlign(cartMisAlig,angMisAlig,fDetElemMisAlig); | |
256 | } | |
257 | else { | |
258 | if (!fUseGaus) { | |
259 | AliWarning("Neither uniform nor gausian distribution is set! Will use gausian..."); | |
260 | } | |
261 | GetGausMisAlign(cartMisAlig,angMisAlig,fDetElemMisAlig); | |
262 | } | |
263 | ||
264 | TGeoTranslation deltaTrans(cartMisAlig[0], cartMisAlig[1], cartMisAlig[2]); | |
265 | TGeoRotation deltaRot; | |
266 | deltaRot.RotateX(angMisAlig[0]); | |
267 | deltaRot.RotateY(angMisAlig[1]); | |
268 | deltaRot.RotateZ(angMisAlig[2]); | |
269 | ||
270 | TGeoCombiTrans deltaTransf(deltaTrans,deltaRot); | |
271 | TGeoHMatrix newTransfMat = transform * deltaTransf; | |
272 | ||
273 | AliInfo(Form("Rotated Module by %f about Z axis.", angMisAlig[2])); | |
274 | ||
275 | return TGeoCombiTrans(newTransfMat); | |
276 | } | |
277 | ||
278 | //_________________________________________________________________________ | |
279 | TGeoCombiTrans AliMUONGeometryMisAligner::MisAlignModule(const TGeoCombiTrans & transform) const | |
280 | { | |
281 | /// Misalign given transformation and return the misaligned transformation. | |
282 | /// Use misalignment parameters for modules. | |
283 | /// Note that applied misalignments are small deltas with respect to the module | |
284 | /// own ideal local reference frame. Thus deltaTransf represents | |
285 | /// the transformation to go from the misaligned module local coordinates to the | |
286 | /// ideal module local coordinates. | |
287 | /// Also note that this -is not- what is in the ALICE alignment framework known | |
288 | /// as local nor global (see AliMUONGeometryMisAligner::MisAlign) | |
289 | ||
290 | Double_t cartMisAlig[3] = {0,0,0}; | |
291 | Double_t angMisAlig[3] = {0,0,0}; | |
292 | ||
293 | if (fUseUni) { | |
294 | GetUniMisAlign(cartMisAlig,angMisAlig,fModuleMisAlig); | |
295 | } | |
296 | else { | |
297 | if (!fUseGaus) { | |
298 | AliWarning("Neither uniform nor gausian distribution is set! Will use gausian..."); | |
299 | } | |
300 | GetGausMisAlign(cartMisAlig,angMisAlig,fModuleMisAlig); | |
301 | } | |
302 | ||
303 | TGeoTranslation deltaTrans(cartMisAlig[0], cartMisAlig[1], cartMisAlig[2]); | |
304 | TGeoRotation deltaRot; | |
305 | deltaRot.RotateX(angMisAlig[0]); | |
306 | deltaRot.RotateY(angMisAlig[1]); | |
307 | deltaRot.RotateZ(angMisAlig[2]); | |
308 | ||
309 | TGeoCombiTrans deltaTransf(deltaTrans,deltaRot); | |
310 | TGeoHMatrix newTransfMat = transform * deltaTransf; | |
311 | ||
312 | AliInfo(Form("Rotated Module by %f about Z axis.", angMisAlig[2])); | |
313 | ||
314 | return TGeoCombiTrans(newTransfMat); | |
315 | } | |
316 | ||
317 | //______________________________________________________________________ | |
318 | AliMUONGeometryTransformer * | |
319 | AliMUONGeometryMisAligner::MisAlign(const AliMUONGeometryTransformer * | |
320 | transformer, Bool_t verbose) | |
321 | { | |
322 | /// Takes the internal geometry module transformers, copies them to | |
323 | /// new geometry module transformers. | |
324 | /// Calculates module misalignment parameters and applies these | |
325 | /// to the new module transformer. | |
326 | /// Calculates the module misalignment delta transformation in the | |
327 | /// Alice Alignment Framework newTransf = delta * oldTransf. | |
328 | /// Add a module misalignment to the new geometry transformer. | |
329 | /// Gets the Detection Elements from the module transformer. | |
330 | /// Calculates misalignment parameters and applies these | |
331 | /// to the local transformation of the Detection Element. | |
332 | /// Obtains the new global transformation by multiplying the new | |
333 | /// module transformer transformation with the new local transformation. | |
334 | /// Applies the new global transform to a new detection element. | |
335 | /// Adds the new detection element to a new module transformer. | |
336 | /// Calculates the d.e. misalignment delta transformation in the | |
337 | /// Alice Alignment Framework (newGlobalTransf = delta * oldGlobalTransf). | |
338 | /// Add a d.e. misalignment to the new geometry transformer. | |
339 | /// Adds the new module transformer to a new geometry transformer. | |
340 | /// Returns the new geometry transformer. | |
341 | ||
342 | ||
343 | AliMUONGeometryTransformer *newGeometryTransformer = | |
344 | new AliMUONGeometryTransformer(kTRUE); | |
345 | for (Int_t iMt = 0; iMt < transformer->GetNofModuleTransformers(); iMt++) | |
346 | { // module transformers | |
347 | const AliMUONGeometryModuleTransformer *kModuleTransformer = | |
348 | transformer->GetModuleTransformer(iMt, true); | |
349 | ||
350 | AliMUONGeometryModuleTransformer *newModuleTransformer = | |
351 | new AliMUONGeometryModuleTransformer(iMt); | |
352 | newGeometryTransformer->AddModuleTransformer(newModuleTransformer); | |
353 | ||
354 | TGeoCombiTrans moduleTransform = | |
355 | TGeoCombiTrans(*kModuleTransformer->GetTransformation()); | |
356 | // New module transformation | |
357 | TGeoCombiTrans newModuleTransform = MisAlignModule(moduleTransform); | |
358 | newModuleTransformer->SetTransformation(newModuleTransform); | |
359 | ||
360 | // Get delta transformation: | |
361 | // Tdelta = Tnew * Told.inverse | |
362 | TGeoHMatrix deltaModuleTransform = | |
363 | AliMUONGeometryBuilder::Multiply( | |
364 | newModuleTransform, | |
365 | kModuleTransformer->GetTransformation()->Inverse()); | |
366 | ||
367 | // Create module mis alignment matrix | |
368 | newGeometryTransformer | |
369 | ->AddMisAlignModule(kModuleTransformer->GetModuleId(), deltaModuleTransform); | |
370 | ||
371 | AliMpExMap *detElements = kModuleTransformer->GetDetElementStore(); | |
372 | ||
373 | if (verbose) | |
374 | AliInfo(Form("%i DEs in old GeometryStore %i",detElements->GetSize(), iMt)); | |
375 | ||
376 | for (Int_t iDe = 0; iDe < detElements->GetSize(); iDe++) | |
377 | { // detection elements. | |
378 | AliMUONGeometryDetElement *detElement = | |
379 | (AliMUONGeometryDetElement *) detElements->GetObject(iDe); | |
380 | ||
381 | if (!detElement) | |
382 | AliFatal("Detection element not found."); | |
383 | ||
384 | /// make a new detection element | |
385 | AliMUONGeometryDetElement *newDetElement = | |
386 | new AliMUONGeometryDetElement(detElement->GetId(), | |
387 | detElement->GetVolumePath()); | |
388 | ||
389 | // local transformation of this detection element. | |
390 | TGeoCombiTrans localTransform | |
391 | = TGeoCombiTrans(*detElement->GetLocalTransformation()); | |
392 | TGeoCombiTrans newLocalTransform = MisAlignDetElem(localTransform); | |
393 | newDetElement->SetLocalTransformation(newLocalTransform); | |
394 | ||
395 | ||
396 | // global transformation | |
397 | TGeoHMatrix newGlobalTransform = | |
398 | AliMUONGeometryBuilder::Multiply(newModuleTransform, | |
399 | newLocalTransform); | |
400 | newDetElement->SetGlobalTransformation(newGlobalTransform); | |
401 | ||
402 | // add this det element to module | |
403 | newModuleTransformer->GetDetElementStore()->Add(newDetElement->GetId(), | |
404 | newDetElement); | |
405 | ||
406 | // In the Alice Alignment Framework misalignment objects store | |
407 | // global delta transformation | |
408 | // Get detection "intermediate" global transformation | |
409 | TGeoHMatrix newOldGlobalTransform = newModuleTransform * localTransform; | |
410 | // Get detection element global delta transformation: | |
411 | // Tdelta = Tnew * Told.inverse | |
412 | TGeoHMatrix deltaGlobalTransform | |
413 | = AliMUONGeometryBuilder::Multiply( | |
414 | newGlobalTransform, | |
415 | newOldGlobalTransform.Inverse()); | |
416 | ||
417 | // Create mis alignment matrix | |
418 | newGeometryTransformer | |
419 | ->AddMisAlignDetElement(detElement->GetId(), deltaGlobalTransform); | |
420 | } | |
421 | ||
422 | ||
423 | if (verbose) | |
424 | AliInfo(Form("Added module transformer %i to the transformer", iMt)); | |
425 | newGeometryTransformer->AddModuleTransformer(newModuleTransformer); | |
426 | } | |
427 | return newGeometryTransformer; | |
428 | } | |
429 | ||
430 | ||
431 | ||
432 |