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