]>
Commit | Line | Data |
---|---|---|
21dd83fc | 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 | // | |
21dd83fc | 18 | //__________________________________________________________________ |
a9aad96e | 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 | /// \authors Bruce Becker, Javier Castillo | |
21dd83fc | 45 | |
21dd83fc | 46 | #include "AliMUONGeometryMisAligner.h" |
47 | #include "AliMUONGeometryTransformer.h" | |
48 | #include "AliMUONGeometryModuleTransformer.h" | |
49 | #include "AliMUONGeometryDetElement.h" | |
50 | #include "AliMUONGeometryStore.h" | |
51 | #include "AliMUONGeometryBuilder.h" | |
ef79ed3a | 52 | |
53 | #include "AliLog.h" | |
54 | ||
328e160e | 55 | #include <TGeoMatrix.h> |
21dd83fc | 56 | #include <TMath.h> |
57 | #include <TRandom.h> | |
58 | ||
a9aad96e | 59 | /// \cond CLASSIMP |
21dd83fc | 60 | ClassImp(AliMUONGeometryMisAligner) |
a9aad96e | 61 | /// \endcond |
62 | ||
328e160e | 63 | //______________________________________________________________________________ |
64 | AliMUONGeometryMisAligner::AliMUONGeometryMisAligner(Double_t cartXMisAligM, Double_t cartXMisAligW, Double_t cartYMisAligM, Double_t cartYMisAligW, Double_t angMisAligM, Double_t angMisAligW) | |
8395bff1 | 65 | : TObject(), |
66 | fUseUni(kFALSE), | |
67 | fUseGaus(kTRUE), | |
68 | fCartXMisAligM(cartXMisAligM), | |
69 | fCartXMisAligW(cartXMisAligW), // 0.5 mm. Perhaps this should go into AliMUONConstants.h ? | |
70 | fCartYMisAligM(cartYMisAligM), | |
71 | fCartYMisAligW(cartYMisAligW), // 0.5 mm. Perhaps this should go into AliMUONConstants.h ? | |
72 | fAngMisAligM(angMisAligM), | |
73 | fAngMisAligW(angMisAligW), | |
74 | fXYAngMisAligFactor(0.0), | |
75 | fZCartMisAligFactor(0.0), | |
76 | fDisplacementGenerator(0) | |
328e160e | 77 | { |
78 | /// Standard constructor | |
328e160e | 79 | fDisplacementGenerator = new TRandom(0); |
328e160e | 80 | } |
81 | ||
82 | //______________________________________________________________________________ | |
83 | AliMUONGeometryMisAligner::AliMUONGeometryMisAligner(Double_t cartMisAligM, Double_t cartMisAligW, Double_t angMisAligM, Double_t angMisAligW) | |
8395bff1 | 84 | : TObject(), |
85 | fUseUni(kFALSE), | |
86 | fUseGaus(kTRUE), | |
87 | fCartXMisAligM(cartMisAligM), | |
88 | fCartXMisAligW(cartMisAligW), // 0.5 mm. Perhaps this should go into AliMUONConstants.h ? | |
89 | fCartYMisAligM(cartMisAligM), | |
90 | fCartYMisAligW(cartMisAligW), // 0.5 mm. Perhaps this should go into AliMUONConstants.h ? | |
91 | fAngMisAligM(angMisAligM), | |
92 | fAngMisAligW(angMisAligW), | |
93 | fXYAngMisAligFactor(0.0), | |
94 | fZCartMisAligFactor(0.0), | |
95 | fDisplacementGenerator(0) | |
328e160e | 96 | { |
97 | /// Standard constructor | |
328e160e | 98 | fDisplacementGenerator = new TRandom(0); |
328e160e | 99 | } |
100 | ||
21dd83fc | 101 | //______________________________________________________________________________ |
102 | AliMUONGeometryMisAligner::AliMUONGeometryMisAligner(Double_t cartMisAlig, Double_t angMisAlig) | |
8395bff1 | 103 | : TObject(), |
104 | fUseUni(kTRUE), | |
105 | fUseGaus(kFALSE), | |
106 | fCartXMisAligM(0.), | |
107 | fCartXMisAligW(cartMisAlig), // 0.5 mm. Perhaps this should go into AliMUONConstants.h ? | |
108 | fCartYMisAligM(0.), | |
109 | fCartYMisAligW(cartMisAlig), // 0.5 mm. Perhaps this should go into AliMUONConstants.h ? | |
110 | fAngMisAligM(0.), | |
111 | fAngMisAligW(angMisAlig), | |
112 | fXYAngMisAligFactor(0.0), | |
113 | fZCartMisAligFactor(0.0), | |
114 | fDisplacementGenerator(0) | |
21dd83fc | 115 | { |
116 | /// Standard constructor | |
21dd83fc | 117 | fDisplacementGenerator = new TRandom(0); |
118 | } | |
119 | ||
120 | //_____________________________________________________________________________ | |
121 | AliMUONGeometryMisAligner::AliMUONGeometryMisAligner() | |
8395bff1 | 122 | : TObject(), |
123 | fUseUni(kTRUE), | |
124 | fUseGaus(kFALSE), | |
125 | fCartXMisAligM(0.), | |
126 | fCartXMisAligW(0.), | |
127 | fCartYMisAligM(0.), | |
128 | fCartYMisAligW(0.), | |
129 | fAngMisAligM(0.), | |
130 | fAngMisAligW(0.), | |
131 | fXYAngMisAligFactor(0.0), | |
132 | fZCartMisAligFactor(0.0), | |
133 | fDisplacementGenerator(0) | |
21dd83fc | 134 | { |
8395bff1 | 135 | /// Default constructor |
21dd83fc | 136 | } |
137 | ||
21dd83fc | 138 | //______________________________________________________________________________ |
139 | AliMUONGeometryMisAligner::~AliMUONGeometryMisAligner() | |
140 | { | |
141 | /// Destructor | |
142 | ||
8395bff1 | 143 | if (fDisplacementGenerator) delete fDisplacementGenerator; |
21dd83fc | 144 | } |
145 | ||
490da820 | 146 | //_________________________________________________________________________ |
21dd83fc | 147 | void |
148 | AliMUONGeometryMisAligner::SetXYAngMisAligFactor(Double_t factor) | |
149 | { | |
328e160e | 150 | /// Set XY angular misalign factor |
490da820 | 151 | |
21dd83fc | 152 | if (TMath::Abs(factor) > 1.0 && factor > 0.) |
153 | fXYAngMisAligFactor = factor; | |
154 | else | |
328e160e | 155 | AliError(Form("Invalid XY angular misalign factor, %d", factor)); |
156 | } | |
157 | ||
158 | //_________________________________________________________________________ | |
159 | void AliMUONGeometryMisAligner::SetZCartMisAligFactor(Double_t factor) | |
160 | { | |
161 | /// Set XY angular misalign factor | |
162 | if (TMath::Abs(factor)<1.0 && factor>0.) | |
163 | fZCartMisAligFactor = factor; | |
164 | else | |
165 | AliError(Form("Invalid Z cartesian misalign factor, %d", factor)); | |
166 | } | |
167 | ||
168 | //_________________________________________________________________________ | |
a9aad96e | 169 | void AliMUONGeometryMisAligner::GetUniMisAlign(Double_t cartMisAlig[3], Double_t angMisAlig[3]) const |
328e160e | 170 | { |
171 | /// Misalign using uniform distribution | |
a9aad96e | 172 | /** |
328e160e | 173 | misalign the centre of the local transformation |
174 | rotation axes : | |
175 | fAngMisAlig[1,2,3] = [x,y,z] | |
176 | Assume that misalignment about the x and y axes (misalignment of z plane) | |
177 | is much smaller, since the entire detection plane has to be moved (the | |
178 | detection elements are on a support structure), while rotation of the x-y | |
179 | plane is more free. | |
180 | */ | |
181 | cartMisAlig[0] = fDisplacementGenerator->Uniform(-fCartXMisAligW+fCartXMisAligM, fCartXMisAligM+fCartXMisAligW); | |
182 | cartMisAlig[1] = fDisplacementGenerator->Uniform(-fCartYMisAligW+fCartYMisAligM, fCartYMisAligM+fCartYMisAligW); | |
183 | cartMisAlig[2] = fDisplacementGenerator->Uniform(-fZCartMisAligFactor*(fCartXMisAligW+fCartXMisAligM), fZCartMisAligFactor*(fCartXMisAligM+fCartXMisAligW)); | |
184 | ||
185 | angMisAlig[0] = fDisplacementGenerator->Uniform(-fXYAngMisAligFactor*(fAngMisAligW+fAngMisAligM), fXYAngMisAligFactor*(fAngMisAligM+fAngMisAligW)); | |
186 | angMisAlig[1] = fDisplacementGenerator->Uniform(-fXYAngMisAligFactor*(fAngMisAligW+fAngMisAligM), fXYAngMisAligFactor*(fAngMisAligM+fAngMisAligW)); | |
187 | angMisAlig[2] = fDisplacementGenerator->Uniform(-fAngMisAligW+fAngMisAligM, fAngMisAligM+fAngMisAligW); // degrees | |
188 | } | |
189 | ||
190 | //_________________________________________________________________________ | |
191 | void AliMUONGeometryMisAligner::GetGausMisAlign(Double_t cartMisAlig[3], Double_t angMisAlig[3]) const | |
192 | { | |
193 | /// Misalign using gaussian distribution | |
a9aad96e | 194 | /** |
328e160e | 195 | misalign the centre of the local transformation |
196 | rotation axes : | |
197 | fAngMisAlig[1,2,3] = [x,y,z] | |
198 | Assume that misalignment about the x and y axes (misalignment of z plane) | |
199 | is much smaller, since the entire detection plane has to be moved (the | |
200 | detection elements are on a support structure), while rotation of the x-y | |
201 | plane is more free. | |
202 | */ | |
203 | cartMisAlig[0] = fDisplacementGenerator->Gaus(fCartXMisAligM, fCartXMisAligW); | |
204 | cartMisAlig[1] = fDisplacementGenerator->Gaus(fCartYMisAligM, fCartYMisAligW); | |
205 | cartMisAlig[2] = fDisplacementGenerator->Gaus(fCartXMisAligM, fZCartMisAligFactor*fCartXMisAligW); | |
206 | ||
207 | angMisAlig[0] = fDisplacementGenerator->Gaus(fAngMisAligM, fXYAngMisAligFactor*fAngMisAligW); | |
208 | angMisAlig[1] = fDisplacementGenerator->Gaus(fAngMisAligM, fXYAngMisAligFactor*fAngMisAligW); | |
209 | angMisAlig[2] = fDisplacementGenerator->Gaus(fAngMisAligM, fAngMisAligW); // degrees | |
21dd83fc | 210 | } |
211 | ||
212 | //_________________________________________________________________________ | |
213 | TGeoCombiTrans AliMUONGeometryMisAligner::MisAlign(const TGeoCombiTrans & transform) const | |
214 | { | |
215 | /// Misalign given transformation and return the misaligned transformation | |
216 | ||
217 | Double_t cartMisAlig[3] = {0,0,0}; | |
218 | Double_t angMisAlig[3] = {0,0,0}; | |
219 | const Double_t *trans = transform.GetTranslation(); | |
220 | TGeoRotation *rot; | |
221 | // check if the rotation we obtain is not NULL | |
222 | if (transform.GetRotation()) | |
223 | { | |
224 | rot = transform.GetRotation(); | |
225 | } | |
226 | else | |
227 | { | |
228 | rot = new TGeoRotation("rot"); | |
229 | } // default constructor. | |
328e160e | 230 | |
231 | if (fUseUni) { | |
232 | GetUniMisAlign(cartMisAlig,angMisAlig); | |
233 | } | |
234 | else { | |
235 | if (!fUseGaus) { | |
236 | AliWarning("Neither uniform nor gausian distribution is set! Will use gausian..."); | |
237 | } | |
238 | GetGausMisAlign(cartMisAlig,angMisAlig); | |
239 | } | |
240 | ||
21dd83fc | 241 | TGeoTranslation newTrans(cartMisAlig[0] + trans[0], cartMisAlig[1] + trans[1], cartMisAlig[2] + trans[2]); |
242 | ||
21dd83fc | 243 | AliInfo(Form("Rotated by %f about Z axis.", angMisAlig[2])); |
244 | rot->RotateX(angMisAlig[0]); | |
245 | rot->RotateY(angMisAlig[1]); | |
246 | rot->RotateZ(angMisAlig[2]); | |
247 | ||
248 | return TGeoCombiTrans(newTrans, *rot); | |
249 | } | |
250 | ||
21dd83fc | 251 | //______________________________________________________________________ |
252 | AliMUONGeometryTransformer * | |
253 | AliMUONGeometryMisAligner::MisAlign(const AliMUONGeometryTransformer * | |
254 | transformer, Bool_t verbose) | |
255 | { | |
a9aad96e | 256 | /// Takes the internal geometry module transformers, copies them |
257 | /// and gets the Detection Elements from them. | |
258 | /// Calculates misalignment parameters and applies these | |
259 | /// to the local transform of the Detection Element | |
260 | /// Obtains the global transform by multiplying the module transformer | |
261 | /// transformation with the local transformation | |
262 | /// Applies the global transform to a new detection element | |
263 | /// Adds the new detection element to a new module transformer | |
264 | /// Adds the new module transformer to a new geometry transformer | |
265 | /// Returns the new geometry transformer | |
21dd83fc | 266 | |
267 | ||
268 | AliMUONGeometryTransformer *newGeometryTransformer = | |
269 | new AliMUONGeometryTransformer(kTRUE); | |
270 | for (Int_t iMt = 0; iMt < transformer->GetNofModuleTransformers(); iMt++) | |
271 | { // module transformers | |
272 | ||
273 | const AliMUONGeometryModuleTransformer *kModuleTransformer = | |
274 | transformer->GetModuleTransformer(iMt, true); | |
275 | ||
276 | AliMUONGeometryModuleTransformer *newModuleTransformer = | |
277 | new AliMUONGeometryModuleTransformer(iMt); | |
278 | newGeometryTransformer->AddModuleTransformer(newModuleTransformer); | |
279 | ||
ef79ed3a | 280 | TGeoCombiTrans moduleTransform = |
281 | TGeoCombiTrans(*kModuleTransformer->GetTransformation()); | |
282 | TGeoCombiTrans *newModuleTransform = new TGeoCombiTrans(moduleTransform); | |
283 | // same module transform as the previous one | |
284 | // no mis align object created | |
285 | newModuleTransformer->SetTransformation(moduleTransform); | |
21dd83fc | 286 | |
287 | AliMUONGeometryStore *detElements = | |
288 | kModuleTransformer->GetDetElementStore(); | |
289 | ||
290 | if (verbose) | |
291 | AliInfo(Form | |
292 | ("%i DEs in old GeometryStore %i", | |
293 | detElements->GetNofEntries(), iMt)); | |
294 | ||
295 | for (Int_t iDe = 0; iDe < detElements->GetNofEntries(); iDe++) | |
296 | { // detection elements. | |
297 | AliMUONGeometryDetElement *detElement = | |
298 | (AliMUONGeometryDetElement *) detElements->GetEntry(iDe); | |
299 | if (!detElement) | |
300 | AliFatal("Detection element not found."); | |
301 | ||
ef79ed3a | 302 | /// make a new detection element |
21dd83fc | 303 | AliMUONGeometryDetElement *newDetElement = |
304 | new AliMUONGeometryDetElement(detElement->GetId(), | |
ef79ed3a | 305 | detElement->GetVolumePath()); |
21dd83fc | 306 | |
ef79ed3a | 307 | // local transformation of this detection element. |
308 | TGeoCombiTrans localTransform | |
309 | = TGeoCombiTrans(*detElement->GetLocalTransformation()); | |
310 | TGeoCombiTrans newLocalTransform = MisAlign(localTransform); | |
311 | newDetElement->SetLocalTransformation(newLocalTransform); | |
21dd83fc | 312 | |
ef79ed3a | 313 | // global transformation |
314 | TGeoHMatrix newGlobalTransform = | |
315 | AliMUONGeometryBuilder::Multiply(*newModuleTransform, | |
316 | newLocalTransform); | |
21dd83fc | 317 | newDetElement->SetGlobalTransformation(newGlobalTransform); |
ef79ed3a | 318 | |
319 | // add this det element to module | |
320 | newModuleTransformer->GetDetElementStore()->Add(newDetElement->GetId(), | |
21dd83fc | 321 | newDetElement); |
ef79ed3a | 322 | // Get delta transformation: |
323 | // Tdelta = Tnew * Told.inverse | |
324 | TGeoHMatrix deltaTransform | |
325 | = AliMUONGeometryBuilder::Multiply( | |
326 | newGlobalTransform, | |
327 | detElement->GetGlobalTransformation()->Inverse()); | |
328 | ||
329 | // Create mis alignment matrix | |
330 | newGeometryTransformer | |
331 | ->AddMisAlignDetElement(detElement->GetId(), deltaTransform); | |
21dd83fc | 332 | } |
333 | if (verbose) | |
334 | AliInfo(Form("Added module transformer %i to the transformer", iMt)); | |
335 | newGeometryTransformer->AddModuleTransformer(newModuleTransformer); | |
336 | } | |
337 | return newGeometryTransformer; | |
338 | } | |
339 | ||
340 | ||
341 | ||
342 |