]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDgeometry.cxx
8f53a2878f5dfb0f0fbb8f55500e04d3e16538e8
[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 /*
17 $Log$
18 Revision 1.20  2002/10/31 17:45:35  cblume
19 New chamber geometry
20
21 Revision 1.19  2002/10/14 14:57:43  hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
23
24 Revision 1.15.6.2  2002/07/24 10:09:30  alibrary
25 Updating VirtualMC
26
27 Revision 1.15.6.1  2002/06/10 15:28:58  hristov
28 Merged with v3-08-02
29
30 Revision 1.17  2002/04/05 13:20:12  cblume
31 Remove const for CreateGeometry
32
33 Revision 1.16  2002/03/28 14:59:07  cblume
34 Coding conventions
35
36 Revision 1.18  2002/06/12 09:54:35  cblume
37 Update of tracking code provided by Sergei
38
39 Revision 1.17  2002/04/05 13:20:12  cblume
40 Remove const for CreateGeometry
41
42 Revision 1.16  2002/03/28 14:59:07  cblume
43 Coding conventions
44
45 Revision 1.15  2002/02/11 14:21:16  cblume
46 Update of the geometry. Get rid of MANY
47
48 Revision 1.14  2001/11/06 17:19:41  cblume
49 Add detailed geometry and simple simulator
50
51 Revision 1.13  2001/08/02 08:30:45  cblume
52 Fix positions of cooling material
53
54 Revision 1.12  2001/05/21 16:45:47  hristov
55 Last minute changes (C.Blume)
56
57 Revision 1.11  2001/05/11 07:56:12  hristov
58 Consistent declarations needed on Alpha
59
60 Revision 1.10  2001/05/07 08:08:05  cblume
61 Update of TRD code
62
63 Revision 1.9  2001/03/27 12:48:33  cblume
64 Correct for volume overlaps
65
66 Revision 1.8  2001/03/13 09:30:35  cblume
67 Update of digitization. Moved digit branch definition to AliTRD
68
69 Revision 1.7  2001/02/14 18:22:26  cblume
70 Change in the geometry of the padplane
71
72 Revision 1.6  2000/11/01 14:53:20  cblume
73 Merge with TRD-develop
74
75 Revision 1.1.4.7  2000/10/16 01:16:53  cblume
76 Changed timebin 0 to be the one closest to the readout
77
78 Revision 1.1.4.6  2000/10/15 23:35:57  cblume
79 Include geometry constants as static member
80
81 Revision 1.1.4.5  2000/10/06 16:49:46  cblume
82 Made Getters const
83
84 Revision 1.1.4.4  2000/10/04 16:34:58  cblume
85 Replace include files by forward declarations
86
87 Revision 1.1.4.3  2000/09/22 14:43:40  cblume
88 Allow the pad/timebin-dimensions to be changed after initialization
89
90 Revision 1.1.4.2  2000/09/18 13:37:01  cblume
91 Minor coding corrections
92
93 Revision 1.5  2000/10/02 21:28:19  fca
94 Removal of useless dependecies via forward declarations
95
96 Revision 1.4  2000/06/08 18:32:58  cblume
97 Make code compliant to coding conventions
98
99 Revision 1.3  2000/06/07 16:25:37  cblume
100 Try to remove compiler warnings on Sun and HP
101
102 Revision 1.2  2000/05/08 16:17:27  cblume
103 Merge TRD-develop
104
105 Revision 1.1.4.1  2000/05/08 14:45:55  cblume
106 Bug fix in RotateBack(). Geometry update
107
108 Revision 1.4  2000/06/08 18:32:58  cblume
109 Make code compliant to coding conventions
110
111 Revision 1.3  2000/06/07 16:25:37  cblume
112 Try to remove compiler warnings on Sun and HP
113
114 Revision 1.2  2000/05/08 16:17:27  cblume
115 Merge TRD-develop
116
117 Revision 1.1.4.1  2000/05/08 14:45:55  cblume
118 Bug fix in RotateBack(). Geometry update
119
120 Revision 1.1  2000/02/28 19:00:44  cblume
121 Add new TRD classes
122
123 */
124
125 ///////////////////////////////////////////////////////////////////////////////
126 //                                                                           //
127 //  TRD geometry class                                                       //
128 //                                                                           //
129 ///////////////////////////////////////////////////////////////////////////////
130
131 #include "AliMC.h"
132
133 #include "AliTRDgeometry.h"
134 #include "AliTRDparameter.h"
135 #include "AliMC.h"
136
137 ClassImp(AliTRDgeometry)
138
139 //_____________________________________________________________________________
140
141   //
142   // The geometry constants
143   //
144   const Int_t   AliTRDgeometry::fgkNsect   = kNsect;
145   const Int_t   AliTRDgeometry::fgkNplan   = kNplan;
146   const Int_t   AliTRDgeometry::fgkNcham   = kNcham;
147   const Int_t   AliTRDgeometry::fgkNdet    = kNdet;
148
149   //
150   // Dimensions of the detector
151   //
152
153   // Inner and outer radius of the mother volumes 
154   const Float_t AliTRDgeometry::fgkRmin    = 294.0;
155   const Float_t AliTRDgeometry::fgkRmax    = 368.0;
156
157   // Upper and lower length of the mother volumes 
158   const Float_t AliTRDgeometry::fgkZmax1   = 378.35; 
159   const Float_t AliTRDgeometry::fgkZmax2   = 302.0; 
160
161   // Parameter of the BTR mother volumes 
162   const Float_t AliTRDgeometry::fgkSheight =  74.0; 
163   const Float_t AliTRDgeometry::fgkSwidth1 =  99.613;
164   const Float_t AliTRDgeometry::fgkSwidth2 = 125.707;
165   const Float_t AliTRDgeometry::fgkSlenTR1 = 751.0;
166   const Float_t AliTRDgeometry::fgkSlenTR2 = 313.5; 
167   const Float_t AliTRDgeometry::fgkSlenTR3 = 159.5;  
168
169   // Height of different chamber parts
170   // Radiator
171   const Float_t AliTRDgeometry::fgkCraH    =   4.8; 
172   // Drift region
173   const Float_t AliTRDgeometry::fgkCdrH    =   3.0;
174   // Amplification region
175   const Float_t AliTRDgeometry::fgkCamH    =   0.7;
176   // Readout
177   const Float_t AliTRDgeometry::fgkCroH    =   2.0;
178   // Total height
179   const Float_t AliTRDgeometry::fgkCH      = AliTRDgeometry::fgkCraH
180                                            + AliTRDgeometry::fgkCdrH
181                                            + AliTRDgeometry::fgkCamH
182                                            + AliTRDgeometry::fgkCroH;  
183
184   // Vertical spacing of the chambers
185   const Float_t AliTRDgeometry::fgkVspace  =   2.1;
186
187   // Horizontal spacing of the chambers
188   const Float_t AliTRDgeometry::fgkHspace  =   2.0;
189
190   // Thicknesses of different parts of the chamber frame
191   // Lower aluminum frame
192   const Float_t AliTRDgeometry::fgkCalT    =   0.3;
193   // Lower G10 frame sides
194   const Float_t AliTRDgeometry::fgkCclsT   =   0.3;
195   // Lower G10 frame front
196   const Float_t AliTRDgeometry::fgkCclfT   =   1.0;
197   // Upper G10 frame
198   const Float_t AliTRDgeometry::fgkCcuT    =   0.9;
199   // Upper Al frame
200   const Float_t AliTRDgeometry::fgkCauT    =   1.5;
201
202   // Additional width of the readout chamber frames
203   const Float_t AliTRDgeometry::fgkCroW    =   0.9;
204
205   // Difference of outer chamber width and pad plane width
206   const Float_t AliTRDgeometry::fgkCpadW   =   1.0;
207   const Float_t AliTRDgeometry::fgkRpadW   =   1.0;
208
209   //
210   // Thickness of the the material layers
211   //
212   const Float_t AliTRDgeometry::fgkRaThick = 0.3646;  
213   const Float_t AliTRDgeometry::fgkMyThick = 0.005;
214   const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH;    
215   const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH;
216   const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick
217                                            + AliTRDgeometry::fgkAmThick;
218   const Float_t AliTRDgeometry::fgkCuThick = 0.001; 
219   const Float_t AliTRDgeometry::fgkSuThick = 0.06; 
220   const Float_t AliTRDgeometry::fgkFeThick = 0.0044; 
221   const Float_t AliTRDgeometry::fgkCoThick = 0.02;
222   const Float_t AliTRDgeometry::fgkWaThick = 0.02;
223
224   //
225   // Position of the material layers
226   //
227   const Float_t AliTRDgeometry::fgkRaZpos  = -1.50;
228   const Float_t AliTRDgeometry::fgkMyZpos  =  0.895;
229   const Float_t AliTRDgeometry::fgkDrZpos  =  2.4;
230   const Float_t AliTRDgeometry::fgkAmZpos  =  0.0;
231   const Float_t AliTRDgeometry::fgkCuZpos  = -0.9995;
232   const Float_t AliTRDgeometry::fgkSuZpos  =  0.0000;
233   const Float_t AliTRDgeometry::fgkFeZpos  =  0.0322;
234   const Float_t AliTRDgeometry::fgkCoZpos  =  0.97;
235   const Float_t AliTRDgeometry::fgkWaZpos  =  0.99;
236
237 //_____________________________________________________________________________
238 AliTRDgeometry::AliTRDgeometry():AliGeometry()
239 {
240   //
241   // AliTRDgeometry default constructor
242   //
243
244   Init();
245
246 }
247
248 //_____________________________________________________________________________
249 AliTRDgeometry::~AliTRDgeometry()
250 {
251   //
252   // AliTRDgeometry destructor
253   //
254
255 }
256
257 //_____________________________________________________________________________
258 void AliTRDgeometry::Init()
259 {
260   //
261   // Initializes the geometry parameter
262   //
263   // The maximum number of pads
264   // and the position of pad 0,0,0 
265   // 
266   // chambers seen from the top:
267   //     +----------------------------+
268   //     |                            |
269   //     |                            |      ^
270   //     |                            |  rphi|
271   //     |                            |      |
272   //     |0                           |      | 
273   //     +----------------------------+      +------>
274   //                                             z 
275   // chambers seen from the side:            ^
276   //     +----------------------------+ drift|
277   //     |0                           |      |
278   //     |                            |      |
279   //     +----------------------------+      +------>
280   //                                             z
281   //                                             
282   // IMPORTANT: time bin 0 is now the first one in the drift region 
283   // closest to the readout !!!
284   //
285
286   Int_t icham;
287   Int_t iplan;
288   Int_t isect;
289
290   // The outer width of the chambers
291   fCwidth[0] =  95.6;
292   fCwidth[1] = 100.1;
293   fCwidth[2] = 104.5;
294   fCwidth[3] = 108.9;
295   fCwidth[4] = 113.4;
296   fCwidth[5] = 117.8;
297
298   // The outer lengths of the chambers
299   Float_t length[kNplan][kNcham]   = { { 124.0, 124.0, 110.0, 124.0, 124.0 }
300                                      , { 131.0, 131.0, 110.0, 131.0, 131.0 }
301                                      , { 138.0, 138.0, 110.0, 138.0, 138.0 }
302                                      , { 145.0, 145.0, 110.0, 145.0, 145.0 }
303                                      , { 147.0, 147.0, 110.0, 147.0, 147.0 }
304                                      , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
305
306   for (icham = 0; icham < kNcham; icham++) {
307     for (iplan = 0; iplan < kNplan; iplan++) {
308       fClength[iplan][icham]   = length[iplan][icham];
309       fClengthPH[iplan][icham] = 0.0;
310       fClengthRH[iplan][icham] = 0.0;
311     }
312   }
313
314   // The rotation matrix elements
315   Float_t phi = 0;
316   for (isect = 0; isect < fgkNsect; isect++) {
317     phi = -2.0 * TMath::Pi() /  (Float_t) fgkNsect * ((Float_t) isect + 0.5);
318     fRotA11[isect] = TMath::Cos(phi);
319     fRotA12[isect] = TMath::Sin(phi);
320     fRotA21[isect] = TMath::Sin(phi);
321     fRotA22[isect] = TMath::Cos(phi);
322     phi = -1.0 * phi;
323     fRotB11[isect] = TMath::Cos(phi);
324     fRotB12[isect] = TMath::Sin(phi);
325     fRotB21[isect] = TMath::Sin(phi);
326     fRotB22[isect] = TMath::Cos(phi);
327   }
328  
329 }
330
331 //_____________________________________________________________________________
332 void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
333 {
334   //
335   // Create TRD geometry
336   //
337
338 }
339
340 //_____________________________________________________________________________
341 Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local
342                                    , Float_t *global
343                                    , AliTRDparameter *par) const
344 {
345   //
346   // Converts local pad-coordinates (row,col,time) into 
347   // global ALICE reference frame coordinates (x,y,z)
348   //
349
350   Int_t icham = GetChamber(idet);    // Chamber info (0-4)
351   Int_t isect = GetSector(idet);     // Sector info  (0-17)
352   Int_t iplan = GetPlane(idet);      // Plane info   (0-5)
353
354   return Local2Global(iplan,icham,isect,local,global,par);
355
356 }
357  
358 //_____________________________________________________________________________
359 Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
360                                   , Float_t *local, Float_t *global
361                                   , AliTRDparameter *par) const
362 {
363   //
364   // Converts local pad-coordinates (row,col,time) into 
365   // global ALICE reference frame coordinates (x,y,z)
366   //
367
368   if (!par) {
369     Error("Local2Global","No parameter defined\n");
370     return kFALSE;
371   }
372
373   Int_t    idet      = GetDetector(iplan,icham,isect); // Detector number
374
375   Float_t  padRow    = local[0]+0.5;                   // Pad Row position
376   Float_t  padCol    = local[1]+0.5;                   // Pad Column position
377   Float_t  timeSlice = local[2]+0.5;                   // Time "position"
378
379   Float_t  row0      = par->GetRow0(iplan,icham,isect);
380   Float_t  col0      = par->GetCol0(iplan);
381   Float_t  time0     = par->GetTime0(iplan);
382
383   Float_t  rot[3];
384
385   // calculate (x,y,z) position in rotated chamber
386   rot[0] = time0 - (timeSlice - par->GetTimeBefore()) 
387          * par->GetTimeBinSize();
388   rot[1] = col0  + padCol                    
389          * par->GetColPadSize(iplan);
390   rot[2] = row0  + padRow                    
391          * par->GetRowPadSize(iplan,icham,isect);
392
393   // Rotate back to original position
394   return RotateBack(idet,rot,global);
395
396 }
397
398 //_____________________________________________________________________________
399 Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot) const
400 {
401   //
402   // Rotates all chambers in the position of sector 0 and transforms
403   // the coordinates in the ALICE restframe <pos> into the 
404   // corresponding local frame <rot>.
405   //
406
407   Int_t sector = GetSector(d);
408
409   rot[0] =  pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
410   rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
411   rot[2] =  pos[2];
412
413   return kTRUE;
414
415 }
416
417 //_____________________________________________________________________________
418 Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
419 {
420   //
421   // Rotates a chambers from the position of sector 0 into its
422   // original position and transforms the corresponding local frame 
423   // coordinates <rot> into the coordinates of the ALICE restframe <pos>.
424   //
425
426   Int_t sector = GetSector(d);
427
428   pos[0] =  rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
429   pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
430   pos[2] =  rot[2];
431
432   return kTRUE;
433
434 }
435
436 //_____________________________________________________________________________
437 Int_t AliTRDgeometry::GetDetectorSec(const Int_t p, const Int_t c) const
438 {
439   //
440   // Convert plane / chamber into detector number for one single sector
441   //
442
443   return (p + c * fgkNplan);
444
445 }
446
447 //_____________________________________________________________________________
448 Int_t AliTRDgeometry::GetDetector(const Int_t p, const Int_t c, const Int_t s) const
449 {
450   //
451   // Convert plane / chamber / sector into detector number
452   //
453
454   return (p + c * fgkNplan + s * fgkNplan * fgkNcham);
455
456 }
457
458 //_____________________________________________________________________________
459 Int_t AliTRDgeometry::GetPlane(const Int_t d) const
460 {
461   //
462   // Reconstruct the plane number from the detector number
463   //
464
465   return ((Int_t) (d % fgkNplan));
466
467 }
468
469 //_____________________________________________________________________________
470 Int_t AliTRDgeometry::GetChamber(const Int_t d) const
471 {
472   //
473   // Reconstruct the chamber number from the detector number
474   //
475
476   return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan);
477
478 }
479
480 //_____________________________________________________________________________
481 Int_t AliTRDgeometry::GetSector(const Int_t d) const
482 {
483   //
484   // Reconstruct the sector number from the detector number
485   //
486
487   return ((Int_t) (d / (fgkNplan * fgkNcham)));
488
489 }
490
491 //_____________________________________________________________________________
492 void AliTRDgeometry::SetOldGeometry()
493 {
494   //
495   // Use the old chamber lengths
496   //
497
498   Int_t icham;
499   Int_t iplan;
500
501   Float_t length[kNplan][kNcham]   = { { 123.5, 123.5, 110.0, 123.5, 123.5 }
502                                      , { 131.0, 131.0, 110.0, 131.0, 131.0 }
503                                      , { 134.5, 138.5, 110.0, 138.5, 134.5 }
504                                      , { 142.0, 146.0, 110.0, 146.0, 142.0 }
505                                      , { 142.0, 153.0, 110.0, 153.0, 142.0 }
506                                      , { 134.0, 160.5, 110.0, 160.5, 134.0 } };
507
508   for (icham = 0; icham < kNcham; icham++) {
509     for (iplan = 0; iplan < kNplan; iplan++) {
510       fClength[iplan][icham]   = length[iplan][icham];
511     }
512   }
513
514 }