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