f7336fa3 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
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 purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
afc51ac2 |
16 | /* $Id$ */ |
f7336fa3 |
17 | |
18 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // |
20 | // TRD geometry class // |
21 | // // |
22 | /////////////////////////////////////////////////////////////////////////////// |
23 | |
793ff80c |
24 | |
bdbb05bb |
25 | #include <TError.h> |
b4a9cd27 |
26 | #include <TGeoManager.h> |
27 | #include <TGeoPhysicalNode.h> |
28 | #include <TGeoMatrix.h> |
29 | |
bdbb05bb |
30 | |
31 | #include "AliRunLoader.h" |
f7336fa3 |
32 | #include "AliTRDgeometry.h" |
a5cadd36 |
33 | #include "AliTRDpadPlane.h" |
f7336fa3 |
34 | |
b4a9cd27 |
35 | #include "AliAlignObj.h" |
36 | #include "AliAlignObjAngles.h" |
37 | |
ecb36af7 |
38 | #include "AliRun.h" |
39 | #include "AliTRD.h" |
3551db50 |
40 | #include "AliTRDcalibDB.h" |
41 | #include "AliTRDCommonParam.h" |
ecb36af7 |
42 | |
f7336fa3 |
43 | ClassImp(AliTRDgeometry) |
44 | |
793ff80c |
45 | //_____________________________________________________________________________ |
46 | |
47 | // |
48 | // The geometry constants |
49 | // |
50 | const Int_t AliTRDgeometry::fgkNsect = kNsect; |
51 | const Int_t AliTRDgeometry::fgkNplan = kNplan; |
52 | const Int_t AliTRDgeometry::fgkNcham = kNcham; |
53 | const Int_t AliTRDgeometry::fgkNdet = kNdet; |
54 | |
55 | // |
56 | // Dimensions of the detector |
57 | // |
0a770ac9 |
58 | |
59 | // Inner and outer radius of the mother volumes |
793ff80c |
60 | const Float_t AliTRDgeometry::fgkRmin = 294.0; |
61 | const Float_t AliTRDgeometry::fgkRmax = 368.0; |
62 | |
0a770ac9 |
63 | // Upper and lower length of the mother volumes |
793ff80c |
64 | const Float_t AliTRDgeometry::fgkZmax1 = 378.35; |
65 | const Float_t AliTRDgeometry::fgkZmax2 = 302.0; |
66 | |
0a770ac9 |
67 | // Parameter of the BTR mother volumes |
793ff80c |
68 | const Float_t AliTRDgeometry::fgkSheight = 74.0; |
69 | const Float_t AliTRDgeometry::fgkSwidth1 = 99.613; |
70 | const Float_t AliTRDgeometry::fgkSwidth2 = 125.707; |
71 | const Float_t AliTRDgeometry::fgkSlenTR1 = 751.0; |
72 | const Float_t AliTRDgeometry::fgkSlenTR2 = 313.5; |
73 | const Float_t AliTRDgeometry::fgkSlenTR3 = 159.5; |
74 | |
73ae7b59 |
75 | // The super module side plates |
287c5d50 |
76 | const Float_t AliTRDgeometry::fgkSMpltT = 0.2; |
77 | const Float_t AliTRDgeometry::fgkSMgapT = 0.5; |
73ae7b59 |
78 | |
0a770ac9 |
79 | // Height of different chamber parts |
80 | // Radiator |
81 | const Float_t AliTRDgeometry::fgkCraH = 4.8; |
82 | // Drift region |
83 | const Float_t AliTRDgeometry::fgkCdrH = 3.0; |
84 | // Amplification region |
85 | const Float_t AliTRDgeometry::fgkCamH = 0.7; |
86 | // Readout |
73ae7b59 |
87 | const Float_t AliTRDgeometry::fgkCroH = 2.316; |
0a770ac9 |
88 | // Total height |
89 | const Float_t AliTRDgeometry::fgkCH = AliTRDgeometry::fgkCraH |
90 | + AliTRDgeometry::fgkCdrH |
91 | + AliTRDgeometry::fgkCamH |
92 | + AliTRDgeometry::fgkCroH; |
93 | |
94 | // Vertical spacing of the chambers |
73ae7b59 |
95 | const Float_t AliTRDgeometry::fgkVspace = 1.784; |
0a770ac9 |
96 | |
97 | // Horizontal spacing of the chambers |
98 | const Float_t AliTRDgeometry::fgkHspace = 2.0; |
99 | |
100 | // Thicknesses of different parts of the chamber frame |
101 | // Lower aluminum frame |
102 | const Float_t AliTRDgeometry::fgkCalT = 0.3; |
103 | // Lower G10 frame sides |
104 | const Float_t AliTRDgeometry::fgkCclsT = 0.3; |
105 | // Lower G10 frame front |
106 | const Float_t AliTRDgeometry::fgkCclfT = 1.0; |
107 | // Upper G10 frame |
108 | const Float_t AliTRDgeometry::fgkCcuT = 0.9; |
109 | // Upper Al frame |
110 | const Float_t AliTRDgeometry::fgkCauT = 1.5; |
111 | |
112 | // Additional width of the readout chamber frames |
113 | const Float_t AliTRDgeometry::fgkCroW = 0.9; |
114 | |
115 | // Difference of outer chamber width and pad plane width |
73ae7b59 |
116 | //const Float_t AliTRDgeometry::fgkCpadW = 1.0; |
117 | const Float_t AliTRDgeometry::fgkCpadW = 0.0; |
de6df1b1 |
118 | const Float_t AliTRDgeometry::fgkRpadW = 1.0; |
793ff80c |
119 | |
120 | // |
121 | // Thickness of the the material layers |
122 | // |
db30bf0f |
123 | const Float_t AliTRDgeometry::fgkRaThick = 0.3646; |
793ff80c |
124 | const Float_t AliTRDgeometry::fgkMyThick = 0.005; |
0a770ac9 |
125 | const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH; |
126 | const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH; |
127 | const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick |
128 | + AliTRDgeometry::fgkAmThick; |
793ff80c |
129 | const Float_t AliTRDgeometry::fgkCuThick = 0.001; |
130 | const Float_t AliTRDgeometry::fgkSuThick = 0.06; |
131 | const Float_t AliTRDgeometry::fgkFeThick = 0.0044; |
132 | const Float_t AliTRDgeometry::fgkCoThick = 0.02; |
db30bf0f |
133 | const Float_t AliTRDgeometry::fgkWaThick = 0.02; |
793ff80c |
134 | |
135 | // |
136 | // Position of the material layers |
137 | // |
0a770ac9 |
138 | const Float_t AliTRDgeometry::fgkRaZpos = -1.50; |
139 | const Float_t AliTRDgeometry::fgkMyZpos = 0.895; |
140 | const Float_t AliTRDgeometry::fgkDrZpos = 2.4; |
141 | const Float_t AliTRDgeometry::fgkAmZpos = 0.0; |
142 | const Float_t AliTRDgeometry::fgkCuZpos = -0.9995; |
793ff80c |
143 | const Float_t AliTRDgeometry::fgkSuZpos = 0.0000; |
0a770ac9 |
144 | const Float_t AliTRDgeometry::fgkFeZpos = 0.0322; |
145 | const Float_t AliTRDgeometry::fgkCoZpos = 0.97; |
146 | const Float_t AliTRDgeometry::fgkWaZpos = 0.99; |
3551db50 |
147 | |
148 | const Double_t AliTRDgeometry::fgkTime0Base = Rmin() + CraHght() + CdrHght() + CamHght()/2.; |
149 | const Float_t AliTRDgeometry::fgkTime0[6] = { fgkTime0Base + 0 * (Cheight() + Cspace()), |
150 | fgkTime0Base + 1 * (Cheight() + Cspace()), |
151 | fgkTime0Base + 2 * (Cheight() + Cspace()), |
152 | fgkTime0Base + 3 * (Cheight() + Cspace()), |
153 | fgkTime0Base + 4 * (Cheight() + Cspace()), |
154 | fgkTime0Base + 5 * (Cheight() + Cspace()) }; |
793ff80c |
155 | |
f7336fa3 |
156 | //_____________________________________________________________________________ |
157 | AliTRDgeometry::AliTRDgeometry():AliGeometry() |
158 | { |
159 | // |
160 | // AliTRDgeometry default constructor |
161 | // |
b4a9cd27 |
162 | fMatrixArray =0; |
163 | fMatrixCorrectionArray= 0; |
f7336fa3 |
164 | Init(); |
f7336fa3 |
165 | } |
166 | |
167 | //_____________________________________________________________________________ |
168 | AliTRDgeometry::~AliTRDgeometry() |
169 | { |
8230f242 |
170 | // |
171 | // AliTRDgeometry destructor |
172 | // |
b4a9cd27 |
173 | delete fMatrixArray; |
174 | delete fMatrixCorrectionArray; |
f7336fa3 |
175 | } |
176 | |
177 | //_____________________________________________________________________________ |
178 | void AliTRDgeometry::Init() |
179 | { |
180 | // |
181 | // Initializes the geometry parameter |
182 | // |
f7336fa3 |
183 | // The maximum number of pads |
184 | // and the position of pad 0,0,0 |
185 | // |
186 | // chambers seen from the top: |
187 | // +----------------------------+ |
188 | // | | |
793ff80c |
189 | // | | ^ |
190 | // | | rphi| |
191 | // | | | |
192 | // |0 | | |
193 | // +----------------------------+ +------> |
f7336fa3 |
194 | // z |
793ff80c |
195 | // chambers seen from the side: ^ |
196 | // +----------------------------+ drift| |
197 | // |0 | | |
198 | // | | | |
199 | // +----------------------------+ +------> |
f7336fa3 |
200 | // z |
201 | // |
a2b90f83 |
202 | // IMPORTANT: time bin 0 is now the first one in the drift region |
203 | // closest to the readout !!! |
793ff80c |
204 | // |
f7336fa3 |
205 | |
0a770ac9 |
206 | Int_t icham; |
207 | Int_t iplan; |
208 | Int_t isect; |
209 | |
210 | // The outer width of the chambers |
e0d47c25 |
211 | // |
212 | // Changed with the introduction of |
213 | // the new layer 0. The old layer 6 |
214 | // is removed. |
287c5d50 |
215 | fCwidth[0] = 90.4; |
e0d47c25 |
216 | fCwidth[1] = 94.8; |
217 | fCwidth[2] = 99.3; |
218 | fCwidth[3] = 103.7; |
219 | fCwidth[4] = 108.1; |
220 | fCwidth[5] = 112.6; |
221 | // Old layer 6 |
222 | // fCwidth[5] = 117.0; |
0a770ac9 |
223 | |
224 | // The outer lengths of the chambers |
73ae7b59 |
225 | // Includes the spacings between the chambers! |
e0d47c25 |
226 | // Changed with the introduction of |
227 | // the new layer 0. The old layer 6 |
228 | // is removed. |
8737e16f |
229 | Float_t length[kNplan][kNcham] = { { 124.0, 124.0, 110.0, 124.0, 124.0 } |
e0d47c25 |
230 | , { 124.0, 124.0, 110.0, 124.0, 124.0 } |
8737e16f |
231 | , { 131.0, 131.0, 110.0, 131.0, 131.0 } |
232 | , { 138.0, 138.0, 110.0, 138.0, 138.0 } |
233 | , { 145.0, 145.0, 110.0, 145.0, 145.0 } |
e0d47c25 |
234 | , { 147.0, 147.0, 110.0, 147.0, 147.0 } }; |
235 | // Old layer 6 |
236 | // , { 147.0, 147.0, 110.0, 147.0, 147.0 } }; |
0a770ac9 |
237 | |
238 | for (icham = 0; icham < kNcham; icham++) { |
239 | for (iplan = 0; iplan < kNplan; iplan++) { |
240 | fClength[iplan][icham] = length[iplan][icham]; |
241 | fClengthPH[iplan][icham] = 0.0; |
242 | fClengthRH[iplan][icham] = 0.0; |
243 | } |
244 | } |
245 | |
793ff80c |
246 | // The rotation matrix elements |
247 | Float_t phi = 0; |
248 | for (isect = 0; isect < fgkNsect; isect++) { |
5443e65e |
249 | phi = -2.0 * TMath::Pi() / (Float_t) fgkNsect * ((Float_t) isect + 0.5); |
793ff80c |
250 | fRotA11[isect] = TMath::Cos(phi); |
251 | fRotA12[isect] = TMath::Sin(phi); |
252 | fRotA21[isect] = TMath::Sin(phi); |
253 | fRotA22[isect] = TMath::Cos(phi); |
254 | phi = -1.0 * phi; |
255 | fRotB11[isect] = TMath::Cos(phi); |
256 | fRotB12[isect] = TMath::Sin(phi); |
257 | fRotB21[isect] = TMath::Sin(phi); |
258 | fRotB22[isect] = TMath::Cos(phi); |
259 | } |
260 | |
261 | } |
262 | |
f7336fa3 |
263 | //_____________________________________________________________________________ |
73ae7b59 |
264 | void AliTRDgeometry::CreateGeometry(Int_t* ) |
f7336fa3 |
265 | { |
266 | // |
0a770ac9 |
267 | // Create TRD geometry |
268 | // |
f7336fa3 |
269 | |
270 | } |
271 | |
272 | //_____________________________________________________________________________ |
a5cadd36 |
273 | Bool_t AliTRDgeometry::Local2Global(Int_t idet, Double_t *local |
dde59437 |
274 | , Double_t *global) const |
f7336fa3 |
275 | { |
276 | // |
277 | // Converts local pad-coordinates (row,col,time) into |
278 | // global ALICE reference frame coordinates (x,y,z) |
279 | // |
280 | |
793ff80c |
281 | Int_t icham = GetChamber(idet); // Chamber info (0-4) |
282 | Int_t isect = GetSector(idet); // Sector info (0-17) |
283 | Int_t iplan = GetPlane(idet); // Plane info (0-5) |
f7336fa3 |
284 | |
dde59437 |
285 | return Local2Global(iplan,icham,isect,local,global); |
f7336fa3 |
286 | |
287 | } |
288 | |
289 | //_____________________________________________________________________________ |
290 | Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect |
dde59437 |
291 | , Double_t *local, Double_t *global) const |
f7336fa3 |
292 | { |
293 | // |
294 | // Converts local pad-coordinates (row,col,time) into |
295 | // global ALICE reference frame coordinates (x,y,z) |
296 | // |
297 | |
3551db50 |
298 | AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance(); |
299 | if (!commonParam) |
300 | return kFALSE; |
5443e65e |
301 | |
3551db50 |
302 | AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); |
303 | if (!calibration) |
304 | return kFALSE; |
305 | |
306 | AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham); |
f7336fa3 |
307 | |
a5cadd36 |
308 | // calculate (x,y,z) position in rotated chamber |
309 | Int_t row = ((Int_t) local[0]); |
310 | Int_t col = ((Int_t) local[1]); |
311 | Float_t timeSlice = local[2] + 0.5; |
3551db50 |
312 | Float_t time0 = GetTime0(iplan); |
f7336fa3 |
313 | |
7754cd1f |
314 | Int_t idet = GetDetector(iplan, icham, isect); |
315 | |
a5cadd36 |
316 | Double_t rot[3]; |
7754cd1f |
317 | rot[0] = time0 - (timeSlice - calibration->GetT0(idet, col, row)) |
318 | * calibration->GetVdrift(idet, col, row)/calibration->GetSamplingFrequency(); |
a5cadd36 |
319 | rot[1] = padPlane->GetColPos(col) - 0.5 * padPlane->GetColSize(col); |
320 | rot[2] = padPlane->GetRowPos(row) - 0.5 * padPlane->GetRowSize(row); |
f7336fa3 |
321 | |
322 | // Rotate back to original position |
323 | return RotateBack(idet,rot,global); |
324 | |
325 | } |
326 | |
3d7b6a24 |
327 | //_____________________________________________________________________________ |
a5cadd36 |
328 | Bool_t AliTRDgeometry::Global2Local(Int_t mode, Double_t *local, Double_t *global |
7754cd1f |
329 | , Int_t* index) const |
3d7b6a24 |
330 | { |
331 | // |
332 | // Converts local pad-coordinates (row,col,time) into |
333 | // global ALICE reference frame coordinates (x,y,z) |
334 | // |
e0d47c25 |
335 | // index[0] = plane number |
336 | // index[1] = chamber number |
337 | // index[2] = sector number |
3d7b6a24 |
338 | // |
339 | // mode=0 - local coordinate in y, z, x - rotated global |
340 | // mode=2 - local coordinate in pad, and pad row, x - rotated global |
341 | // |
e0d47c25 |
342 | |
3d7b6a24 |
343 | //Int_t idet = GetDetector(iplan,icham,isect); // Detector number |
344 | Int_t idet = GetDetector(index[0],index[1],index[2]); // Detector number |
b4a9cd27 |
345 | RotateBack(idet,global,local); |
3d7b6a24 |
346 | if (mode==0) return kTRUE; |
347 | // |
348 | // Float_t row0 = par->GetRow0(iplan,icham,isect); |
349 | //Float_t col0 = par->GetCol0(iplan); |
3551db50 |
350 | //Float_t time0 = GetTime0(iplan); |
3d7b6a24 |
351 | // |
352 | // mode 1 to be implemented later |
353 | // calculate (x,y,z) position in time bin pad row pad |
354 | // |
355 | //rot[0] = time0 - (timeSlice - par->GetTimeBefore()) |
ccb4315c |
356 | // * par->GetDriftVelocity()/par->GetSamplingFrequency(); |
3d7b6a24 |
357 | //rot[1] = col0 + padCol |
358 | // * par->GetColPadSize(iplan); |
359 | //rot[2] = row0 + padRow |
360 | // * par->GetRowPadSize(iplan,icham,isect); |
361 | |
362 | return kTRUE; |
363 | |
364 | } |
365 | |
a5cadd36 |
366 | //_____________________________________________________________________________ |
3551db50 |
367 | Bool_t AliTRDgeometry::Global2Detector(Double_t global[3], Int_t index[3]) |
3d7b6a24 |
368 | { |
369 | // |
b4a9cd27 |
370 | // Find detector for given global point - Ideal geometry |
371 | // |
372 | // |
e0d47c25 |
373 | // input = global position |
374 | // output = index |
375 | // index[0] = plane number |
376 | // index[1] = chamber number |
377 | // index[2] = sector number |
3d7b6a24 |
378 | // |
3d7b6a24 |
379 | // |
b4a9cd27 |
380 | // Find sector |
381 | // |
382 | Float_t fi = TMath::ATan2(global[1],global[0]); |
3d7b6a24 |
383 | if (fi<0) fi += 2*TMath::Pi(); |
b4a9cd27 |
384 | index[2] = fgkNsect-1-TMath::Nint((fi - GetAlpha()/2.)/GetAlpha()); |
3d7b6a24 |
385 | // |
b4a9cd27 |
386 | // Find plane |
3d7b6a24 |
387 | // |
388 | Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]]; |
389 | index[0] = 0; |
3551db50 |
390 | Float_t max = locx - GetTime0(0); |
3d7b6a24 |
391 | for (Int_t iplane=1; iplane<fgkNplan;iplane++){ |
3551db50 |
392 | Float_t dist = TMath::Abs(locx - GetTime0(iplane)); |
3d7b6a24 |
393 | if (dist < max){ |
394 | index[0] = iplane; |
395 | max = dist; |
396 | } |
397 | } |
b4a9cd27 |
398 | // |
399 | // Find chamber |
400 | // |
401 | if (TMath::Abs(global[2]) < 0.5*GetChamberLength(index[0],2)){ |
402 | index[1]=2; |
403 | }else{ |
404 | Double_t localZ = global[2]; |
405 | if (global[2]>0){ |
406 | localZ -= 0.5*(GetChamberLength(index[0],2)+GetChamberLength(index[0],1)); |
407 | index[1] = (TMath::Abs(localZ) < 0.5*GetChamberLength(index[0],3)) ? 1:0; |
408 | } |
409 | else{ |
410 | localZ += 0.5*(GetChamberLength(index[0],2)+GetChamberLength(index[0],3)); |
411 | index[1] = (TMath::Abs(localZ) < 0.5*GetChamberLength(index[0],1)) ? 3:4; |
412 | } |
413 | } |
3d7b6a24 |
414 | return kTRUE; |
3d7b6a24 |
415 | } |
416 | |
417 | |
f7336fa3 |
418 | //_____________________________________________________________________________ |
a5cadd36 |
419 | Bool_t AliTRDgeometry::Rotate(Int_t d, Double_t *pos, Double_t *rot) const |
f7336fa3 |
420 | { |
421 | // |
422 | // Rotates all chambers in the position of sector 0 and transforms |
423 | // the coordinates in the ALICE restframe <pos> into the |
424 | // corresponding local frame <rot>. |
425 | // |
426 | |
793ff80c |
427 | Int_t sector = GetSector(d); |
f7336fa3 |
428 | |
793ff80c |
429 | rot[0] = pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector]; |
430 | rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector]; |
f7336fa3 |
431 | rot[2] = pos[2]; |
432 | |
433 | return kTRUE; |
434 | |
435 | } |
436 | |
437 | //_____________________________________________________________________________ |
a5cadd36 |
438 | Bool_t AliTRDgeometry::RotateBack(Int_t d, Double_t *rot, Double_t *pos) const |
f7336fa3 |
439 | { |
440 | // |
441 | // Rotates a chambers from the position of sector 0 into its |
442 | // original position and transforms the corresponding local frame |
443 | // coordinates <rot> into the coordinates of the ALICE restframe <pos>. |
444 | // |
445 | |
793ff80c |
446 | Int_t sector = GetSector(d); |
f7336fa3 |
447 | |
793ff80c |
448 | pos[0] = rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector]; |
449 | pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector]; |
6f1e466d |
450 | pos[2] = rot[2]; |
f7336fa3 |
451 | |
452 | return kTRUE; |
453 | |
454 | } |
455 | |
456 | //_____________________________________________________________________________ |
3551db50 |
457 | Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c) |
0a770ac9 |
458 | { |
459 | // |
460 | // Convert plane / chamber into detector number for one single sector |
461 | // |
462 | |
463 | return (p + c * fgkNplan); |
464 | |
465 | } |
466 | |
467 | //_____________________________________________________________________________ |
3551db50 |
468 | Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s) |
f7336fa3 |
469 | { |
470 | // |
471 | // Convert plane / chamber / sector into detector number |
472 | // |
473 | |
793ff80c |
474 | return (p + c * fgkNplan + s * fgkNplan * fgkNcham); |
f7336fa3 |
475 | |
476 | } |
477 | |
478 | //_____________________________________________________________________________ |
afc51ac2 |
479 | Int_t AliTRDgeometry::GetPlane(Int_t d) const |
f7336fa3 |
480 | { |
481 | // |
482 | // Reconstruct the plane number from the detector number |
483 | // |
484 | |
793ff80c |
485 | return ((Int_t) (d % fgkNplan)); |
f7336fa3 |
486 | |
487 | } |
488 | |
489 | //_____________________________________________________________________________ |
afc51ac2 |
490 | Int_t AliTRDgeometry::GetChamber(Int_t d) const |
f7336fa3 |
491 | { |
492 | // |
493 | // Reconstruct the chamber number from the detector number |
494 | // |
495 | |
793ff80c |
496 | return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan); |
f7336fa3 |
497 | |
498 | } |
499 | |
500 | //_____________________________________________________________________________ |
afc51ac2 |
501 | Int_t AliTRDgeometry::GetSector(Int_t d) const |
f7336fa3 |
502 | { |
503 | // |
504 | // Reconstruct the sector number from the detector number |
505 | // |
506 | |
793ff80c |
507 | return ((Int_t) (d / (fgkNplan * fgkNcham))); |
f7336fa3 |
508 | |
509 | } |
510 | |
bdbb05bb |
511 | //_____________________________________________________________________________ |
512 | AliTRDgeometry* AliTRDgeometry::GetGeometry(AliRunLoader* runLoader) |
513 | { |
514 | // |
515 | // load the geometry from the galice file |
516 | // |
517 | |
518 | if (!runLoader) runLoader = AliRunLoader::GetRunLoader(); |
519 | if (!runLoader) { |
520 | ::Error("AliTRDgeometry::GetGeometry", "No run loader"); |
521 | return NULL; |
522 | } |
523 | |
524 | TDirectory* saveDir = gDirectory; |
525 | runLoader->CdGAFile(); |
526 | |
ecb36af7 |
527 | // Try from the galice.root file |
bdbb05bb |
528 | AliTRDgeometry* geom = (AliTRDgeometry*) gDirectory->Get("TRDgeometry"); |
ecb36af7 |
529 | |
530 | if (!geom) { |
531 | // It is not in the file, try to get it from gAlice, |
532 | // which corresponds to the run loader |
533 | AliTRD * trd = (AliTRD*)runLoader->GetAliRun()->GetDetector("TRD"); |
534 | geom = trd->GetGeometry(); |
535 | } |
bdbb05bb |
536 | if (!geom) ::Error("AliTRDgeometry::GetGeometry", "Geometry not found"); |
537 | |
538 | saveDir->cd(); |
539 | return geom; |
540 | } |
b4a9cd27 |
541 | |
542 | |
543 | //_____________________________________________________________________________ |
544 | Bool_t AliTRDgeometry::ReadGeoMatrices(){ |
545 | // |
546 | // Read geo matrices from current gGeoManager for each TRD sector |
547 | // |
548 | |
549 | // |
550 | // fMatrixArray - |
551 | // |
552 | |
553 | // |
554 | // fMatrixCorrectionArray - |
555 | // |
556 | |
557 | |
558 | if (!gGeoManager) return kFALSE; |
559 | fMatrixArray = new TObjArray(kNdet); |
560 | fMatrixCorrectionArray = new TObjArray(kNdet); |
561 | fMatrixGeo = new TObjArray(kNdet); |
562 | AliAlignObjAngles o; |
563 | // |
564 | for (Int_t iLayer = AliAlignObj::kTRD1; iLayer <= AliAlignObj::kTRD6; iLayer++) { |
565 | for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(iLayer); iModule++) { |
566 | UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iModule); |
567 | const char *path = AliAlignObj::GetVolPath(volid); |
568 | if (!gGeoManager->cd(path)) return kFALSE; |
569 | TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); |
570 | Int_t iLayerTRD = iLayer-AliAlignObj::kTRD1; |
571 | Int_t isector = Nsect()-1-(iModule/Ncham()); |
572 | Int_t ichamber = Ncham()-1-(iModule%Ncham()); |
573 | Int_t lid = GetDetector(iLayerTRD,ichamber,isector); |
574 | // |
575 | // |
576 | // |
577 | // local geo system z-x-y to x-y--z |
578 | // |
579 | fMatrixGeo->AddAt(new TGeoHMatrix(*m),lid); |
580 | |
581 | TGeoRotation mchange; |
582 | mchange.RotateY(90); mchange.RotateX(90); |
583 | // |
584 | TGeoHMatrix gMatrix(mchange.Inverse()); |
585 | gMatrix.MultiplyLeft(m); |
586 | fMatrixArray->AddAt(new TGeoHMatrix(gMatrix),lid); |
587 | // |
588 | // Cluster transformation matrix |
589 | // |
590 | TGeoHMatrix rotMatrix(mchange.Inverse()); |
591 | rotMatrix.MultiplyLeft(m); |
592 | Double_t sectorAngle = 20.*(isector%18)+10; |
593 | TGeoHMatrix rotSector; |
594 | rotSector.RotateZ(sectorAngle); |
595 | rotMatrix.MultiplyLeft(&rotSector); |
596 | // |
597 | fMatrixCorrectionArray->AddAt(new TGeoHMatrix(rotMatrix),lid); |
598 | } |
599 | } |
600 | return kTRUE; |
601 | } |
602 | |
603 | |