]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDgeometry.cxx
Bug Correction
[u/mrichter/AliRoot.git] / TRD / AliTRDgeometry.cxx
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
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  TRD geometry class                                                       //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24
25 #include "AliTRDgeometry.h"
26 #include "AliTRDparameter.h"
27
28 ClassImp(AliTRDgeometry)
29
30 //_____________________________________________________________________________
31
32   //
33   // The geometry constants
34   //
35   const Int_t   AliTRDgeometry::fgkNsect   = kNsect;
36   const Int_t   AliTRDgeometry::fgkNplan   = kNplan;
37   const Int_t   AliTRDgeometry::fgkNcham   = kNcham;
38   const Int_t   AliTRDgeometry::fgkNdet    = kNdet;
39
40   //
41   // Dimensions of the detector
42   //
43
44   // Inner and outer radius of the mother volumes 
45   const Float_t AliTRDgeometry::fgkRmin    = 294.0;
46   const Float_t AliTRDgeometry::fgkRmax    = 368.0;
47
48   // Upper and lower length of the mother volumes 
49   const Float_t AliTRDgeometry::fgkZmax1   = 378.35; 
50   const Float_t AliTRDgeometry::fgkZmax2   = 302.0; 
51
52   // Parameter of the BTR mother volumes 
53   const Float_t AliTRDgeometry::fgkSheight =  74.0; 
54   const Float_t AliTRDgeometry::fgkSwidth1 =  99.613;
55   const Float_t AliTRDgeometry::fgkSwidth2 = 125.707;
56   const Float_t AliTRDgeometry::fgkSlenTR1 = 751.0;
57   const Float_t AliTRDgeometry::fgkSlenTR2 = 313.5; 
58   const Float_t AliTRDgeometry::fgkSlenTR3 = 159.5;  
59
60   // Height of different chamber parts
61   // Radiator
62   const Float_t AliTRDgeometry::fgkCraH    =   4.8; 
63   // Drift region
64   const Float_t AliTRDgeometry::fgkCdrH    =   3.0;
65   // Amplification region
66   const Float_t AliTRDgeometry::fgkCamH    =   0.7;
67   // Readout
68   const Float_t AliTRDgeometry::fgkCroH    =   2.0;
69   // Total height
70   const Float_t AliTRDgeometry::fgkCH      = AliTRDgeometry::fgkCraH
71                                            + AliTRDgeometry::fgkCdrH
72                                            + AliTRDgeometry::fgkCamH
73                                            + AliTRDgeometry::fgkCroH;  
74
75   // Vertical spacing of the chambers
76   const Float_t AliTRDgeometry::fgkVspace  =   2.1;
77
78   // Horizontal spacing of the chambers
79   const Float_t AliTRDgeometry::fgkHspace  =   2.0;
80
81   // Thicknesses of different parts of the chamber frame
82   // Lower aluminum frame
83   const Float_t AliTRDgeometry::fgkCalT    =   0.3;
84   // Lower G10 frame sides
85   const Float_t AliTRDgeometry::fgkCclsT   =   0.3;
86   // Lower G10 frame front
87   const Float_t AliTRDgeometry::fgkCclfT   =   1.0;
88   // Upper G10 frame
89   const Float_t AliTRDgeometry::fgkCcuT    =   0.9;
90   // Upper Al frame
91   const Float_t AliTRDgeometry::fgkCauT    =   1.5;
92
93   // Additional width of the readout chamber frames
94   const Float_t AliTRDgeometry::fgkCroW    =   0.9;
95
96   // Difference of outer chamber width and pad plane width
97   const Float_t AliTRDgeometry::fgkCpadW   =   1.0;
98   const Float_t AliTRDgeometry::fgkRpadW   =   1.0;
99
100   //
101   // Thickness of the the material layers
102   //
103   const Float_t AliTRDgeometry::fgkRaThick = 0.3646;  
104   const Float_t AliTRDgeometry::fgkMyThick = 0.005;
105   const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH;    
106   const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH;
107   const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick
108                                            + AliTRDgeometry::fgkAmThick;
109   const Float_t AliTRDgeometry::fgkCuThick = 0.001; 
110   const Float_t AliTRDgeometry::fgkSuThick = 0.06; 
111   const Float_t AliTRDgeometry::fgkFeThick = 0.0044; 
112   const Float_t AliTRDgeometry::fgkCoThick = 0.02;
113   const Float_t AliTRDgeometry::fgkWaThick = 0.02;
114
115   //
116   // Position of the material layers
117   //
118   const Float_t AliTRDgeometry::fgkRaZpos  = -1.50;
119   const Float_t AliTRDgeometry::fgkMyZpos  =  0.895;
120   const Float_t AliTRDgeometry::fgkDrZpos  =  2.4;
121   const Float_t AliTRDgeometry::fgkAmZpos  =  0.0;
122   const Float_t AliTRDgeometry::fgkCuZpos  = -0.9995;
123   const Float_t AliTRDgeometry::fgkSuZpos  =  0.0000;
124   const Float_t AliTRDgeometry::fgkFeZpos  =  0.0322;
125   const Float_t AliTRDgeometry::fgkCoZpos  =  0.97;
126   const Float_t AliTRDgeometry::fgkWaZpos  =  0.99;
127
128 //_____________________________________________________________________________
129 AliTRDgeometry::AliTRDgeometry():AliGeometry()
130 {
131   //
132   // AliTRDgeometry default constructor
133   //
134
135   Init();
136
137 }
138
139 //_____________________________________________________________________________
140 AliTRDgeometry::~AliTRDgeometry()
141 {
142   //
143   // AliTRDgeometry destructor
144   //
145
146 }
147
148 //_____________________________________________________________________________
149 void AliTRDgeometry::Init()
150 {
151   //
152   // Initializes the geometry parameter
153   //
154   // The maximum number of pads
155   // and the position of pad 0,0,0 
156   // 
157   // chambers seen from the top:
158   //     +----------------------------+
159   //     |                            |
160   //     |                            |      ^
161   //     |                            |  rphi|
162   //     |                            |      |
163   //     |0                           |      | 
164   //     +----------------------------+      +------>
165   //                                             z 
166   // chambers seen from the side:            ^
167   //     +----------------------------+ drift|
168   //     |0                           |      |
169   //     |                            |      |
170   //     +----------------------------+      +------>
171   //                                             z
172   //                                             
173   // IMPORTANT: time bin 0 is now the first one in the drift region 
174   // closest to the readout !!!
175   //
176
177   Int_t icham;
178   Int_t iplan;
179   Int_t isect;
180
181   // The outer width of the chambers
182   fCwidth[0] =  95.6;
183   fCwidth[1] = 100.1;
184   fCwidth[2] = 104.5;
185   fCwidth[3] = 108.9;
186   fCwidth[4] = 113.4;
187   fCwidth[5] = 117.8;
188
189   // The outer lengths of the chambers
190   Float_t length[kNplan][kNcham]   = { { 124.0, 124.0, 110.0, 124.0, 124.0 }
191                                      , { 131.0, 131.0, 110.0, 131.0, 131.0 }
192                                      , { 138.0, 138.0, 110.0, 138.0, 138.0 }
193                                      , { 145.0, 145.0, 110.0, 145.0, 145.0 }
194                                      , { 147.0, 147.0, 110.0, 147.0, 147.0 }
195                                      , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
196
197   for (icham = 0; icham < kNcham; icham++) {
198     for (iplan = 0; iplan < kNplan; iplan++) {
199       fClength[iplan][icham]   = length[iplan][icham];
200       fClengthPH[iplan][icham] = 0.0;
201       fClengthRH[iplan][icham] = 0.0;
202     }
203   }
204
205   // The rotation matrix elements
206   Float_t phi = 0;
207   for (isect = 0; isect < fgkNsect; isect++) {
208     phi = -2.0 * TMath::Pi() /  (Float_t) fgkNsect * ((Float_t) isect + 0.5);
209     fRotA11[isect] = TMath::Cos(phi);
210     fRotA12[isect] = TMath::Sin(phi);
211     fRotA21[isect] = TMath::Sin(phi);
212     fRotA22[isect] = TMath::Cos(phi);
213     phi = -1.0 * phi;
214     fRotB11[isect] = TMath::Cos(phi);
215     fRotB12[isect] = TMath::Sin(phi);
216     fRotB21[isect] = TMath::Sin(phi);
217     fRotB22[isect] = TMath::Cos(phi);
218   }
219  
220 }
221
222 //_____________________________________________________________________________
223 void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
224 {
225   //
226   // Create TRD geometry
227   //
228
229 }
230
231 //_____________________________________________________________________________
232 Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local
233                                    , Float_t *global
234                                    , AliTRDparameter *par) const
235 {
236   //
237   // Converts local pad-coordinates (row,col,time) into 
238   // global ALICE reference frame coordinates (x,y,z)
239   //
240
241   Int_t icham = GetChamber(idet);    // Chamber info (0-4)
242   Int_t isect = GetSector(idet);     // Sector info  (0-17)
243   Int_t iplan = GetPlane(idet);      // Plane info   (0-5)
244
245   return Local2Global(iplan,icham,isect,local,global,par);
246
247 }
248  
249 //_____________________________________________________________________________
250 Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
251                                   , Float_t *local, Float_t *global
252                                   , AliTRDparameter *par) const
253 {
254   //
255   // Converts local pad-coordinates (row,col,time) into 
256   // global ALICE reference frame coordinates (x,y,z)
257   //
258
259   if (!par) {
260     Error("Local2Global","No parameter defined\n");
261     return kFALSE;
262   }
263
264   Int_t    idet      = GetDetector(iplan,icham,isect); // Detector number
265
266   Float_t  padRow    = local[0]+0.5;                   // Pad Row position
267   Float_t  padCol    = local[1]+0.5;                   // Pad Column position
268   Float_t  timeSlice = local[2]+0.5;                   // Time "position"
269
270   Float_t  row0      = par->GetRow0(iplan,icham,isect);
271   Float_t  col0      = par->GetCol0(iplan);
272   Float_t  time0     = par->GetTime0(iplan);
273
274   Float_t  rot[3];
275
276   // calculate (x,y,z) position in rotated chamber
277   rot[0] = time0 - (timeSlice - par->GetTimeBefore()) 
278          * par->GetTimeBinSize();
279   rot[1] = col0  + padCol                    
280          * par->GetColPadSize(iplan);
281   rot[2] = row0  + padRow                    
282          * par->GetRowPadSize(iplan,icham,isect);
283
284   // Rotate back to original position
285   return RotateBack(idet,rot,global);
286
287 }
288
289 //_____________________________________________________________________________
290 Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot) const
291 {
292   //
293   // Rotates all chambers in the position of sector 0 and transforms
294   // the coordinates in the ALICE restframe <pos> into the 
295   // corresponding local frame <rot>.
296   //
297
298   Int_t sector = GetSector(d);
299
300   rot[0] =  pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
301   rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
302   rot[2] =  pos[2];
303
304   return kTRUE;
305
306 }
307
308 //_____________________________________________________________________________
309 Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
310 {
311   //
312   // Rotates a chambers from the position of sector 0 into its
313   // original position and transforms the corresponding local frame 
314   // coordinates <rot> into the coordinates of the ALICE restframe <pos>.
315   //
316
317   Int_t sector = GetSector(d);
318
319   pos[0] =  rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
320   pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
321   pos[2] =  rot[2];
322
323   return kTRUE;
324
325 }
326
327 //_____________________________________________________________________________
328 Int_t AliTRDgeometry::GetDetectorSec(const Int_t p, const Int_t c) const
329 {
330   //
331   // Convert plane / chamber into detector number for one single sector
332   //
333
334   return (p + c * fgkNplan);
335
336 }
337
338 //_____________________________________________________________________________
339 Int_t AliTRDgeometry::GetDetector(const Int_t p, const Int_t c, const Int_t s) const
340 {
341   //
342   // Convert plane / chamber / sector into detector number
343   //
344
345   return (p + c * fgkNplan + s * fgkNplan * fgkNcham);
346
347 }
348
349 //_____________________________________________________________________________
350 Int_t AliTRDgeometry::GetPlane(const Int_t d) const
351 {
352   //
353   // Reconstruct the plane number from the detector number
354   //
355
356   return ((Int_t) (d % fgkNplan));
357
358 }
359
360 //_____________________________________________________________________________
361 Int_t AliTRDgeometry::GetChamber(const Int_t d) const
362 {
363   //
364   // Reconstruct the chamber number from the detector number
365   //
366
367   return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan);
368
369 }
370
371 //_____________________________________________________________________________
372 Int_t AliTRDgeometry::GetSector(const Int_t d) const
373 {
374   //
375   // Reconstruct the sector number from the detector number
376   //
377
378   return ((Int_t) (d / (fgkNplan * fgkNcham)));
379
380 }
381
382 //_____________________________________________________________________________
383 void AliTRDgeometry::SetOldGeometry()
384 {
385   //
386   // Use the old chamber lengths
387   //
388
389   Int_t icham;
390   Int_t iplan;
391
392   Float_t length[kNplan][kNcham]   = { { 123.5, 123.5, 110.0, 123.5, 123.5 }
393                                      , { 131.0, 131.0, 110.0, 131.0, 131.0 }
394                                      , { 134.5, 138.5, 110.0, 138.5, 134.5 }
395                                      , { 142.0, 146.0, 110.0, 146.0, 142.0 }
396                                      , { 142.0, 153.0, 110.0, 153.0, 142.0 }
397                                      , { 134.0, 160.5, 110.0, 160.5, 134.0 } };
398
399   for (icham = 0; icham < kNcham; icham++) {
400     for (iplan = 0; iplan < kNplan; iplan++) {
401       fClength[iplan][icham]   = length[iplan][icham];
402     }
403   }
404
405 }