]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDgeometry.cxx
Consistent cuts for propagation and refit inward. Reducing printout (M.Ivanov)
[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   // The super module side plates
61   const Float_t AliTRDgeometry::fgkSMpltT  = 0.2;
62   const Float_t AliTRDgeometry::fgkSMgapT  = 0.5;  
63
64   // Height of different chamber parts
65   // Radiator
66   const Float_t AliTRDgeometry::fgkCraH    =   4.8; 
67   // Drift region
68   const Float_t AliTRDgeometry::fgkCdrH    =   3.0;
69   // Amplification region
70   const Float_t AliTRDgeometry::fgkCamH    =   0.7;
71   // Readout
72   const Float_t AliTRDgeometry::fgkCroH    =   2.316;
73   // Total height
74   const Float_t AliTRDgeometry::fgkCH      = AliTRDgeometry::fgkCraH
75                                            + AliTRDgeometry::fgkCdrH
76                                            + AliTRDgeometry::fgkCamH
77                                            + AliTRDgeometry::fgkCroH;  
78
79   // Vertical spacing of the chambers
80   const Float_t AliTRDgeometry::fgkVspace  =   1.784;
81
82   // Horizontal spacing of the chambers
83   const Float_t AliTRDgeometry::fgkHspace  =   2.0;
84
85   // Thicknesses of different parts of the chamber frame
86   // Lower aluminum frame
87   const Float_t AliTRDgeometry::fgkCalT    =   0.3;
88   // Lower G10 frame sides
89   const Float_t AliTRDgeometry::fgkCclsT   =   0.3;
90   // Lower G10 frame front
91   const Float_t AliTRDgeometry::fgkCclfT   =   1.0;
92   // Upper G10 frame
93   const Float_t AliTRDgeometry::fgkCcuT    =   0.9;
94   // Upper Al frame
95   const Float_t AliTRDgeometry::fgkCauT    =   1.5;
96
97   // Additional width of the readout chamber frames
98   const Float_t AliTRDgeometry::fgkCroW    =   0.9;
99
100   // Difference of outer chamber width and pad plane width
101   //const Float_t AliTRDgeometry::fgkCpadW   =   1.0;
102   const Float_t AliTRDgeometry::fgkCpadW   =   0.0;
103   const Float_t AliTRDgeometry::fgkRpadW   =   1.0;
104
105   //
106   // Thickness of the the material layers
107   //
108   const Float_t AliTRDgeometry::fgkRaThick = 0.3646;  
109   const Float_t AliTRDgeometry::fgkMyThick = 0.005;
110   const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH;    
111   const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH;
112   const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick
113                                            + AliTRDgeometry::fgkAmThick;
114   const Float_t AliTRDgeometry::fgkCuThick = 0.001; 
115   const Float_t AliTRDgeometry::fgkSuThick = 0.06; 
116   const Float_t AliTRDgeometry::fgkFeThick = 0.0044; 
117   const Float_t AliTRDgeometry::fgkCoThick = 0.02;
118   const Float_t AliTRDgeometry::fgkWaThick = 0.02;
119
120   //
121   // Position of the material layers
122   //
123   const Float_t AliTRDgeometry::fgkRaZpos  = -1.50;
124   const Float_t AliTRDgeometry::fgkMyZpos  =  0.895;
125   const Float_t AliTRDgeometry::fgkDrZpos  =  2.4;
126   const Float_t AliTRDgeometry::fgkAmZpos  =  0.0;
127   const Float_t AliTRDgeometry::fgkCuZpos  = -0.9995;
128   const Float_t AliTRDgeometry::fgkSuZpos  =  0.0000;
129   const Float_t AliTRDgeometry::fgkFeZpos  =  0.0322;
130   const Float_t AliTRDgeometry::fgkCoZpos  =  0.97;
131   const Float_t AliTRDgeometry::fgkWaZpos  =  0.99;
132
133 //_____________________________________________________________________________
134 AliTRDgeometry::AliTRDgeometry():AliGeometry()
135 {
136   //
137   // AliTRDgeometry default constructor
138   //
139
140   Init();
141
142 }
143
144 //_____________________________________________________________________________
145 AliTRDgeometry::~AliTRDgeometry()
146 {
147   //
148   // AliTRDgeometry destructor
149   //
150
151 }
152
153 //_____________________________________________________________________________
154 void AliTRDgeometry::Init()
155 {
156   //
157   // Initializes the geometry parameter
158   //
159   // The maximum number of pads
160   // and the position of pad 0,0,0 
161   // 
162   // chambers seen from the top:
163   //     +----------------------------+
164   //     |                            |
165   //     |                            |      ^
166   //     |                            |  rphi|
167   //     |                            |      |
168   //     |0                           |      | 
169   //     +----------------------------+      +------>
170   //                                             z 
171   // chambers seen from the side:            ^
172   //     +----------------------------+ drift|
173   //     |0                           |      |
174   //     |                            |      |
175   //     +----------------------------+      +------>
176   //                                             z
177   //                                             
178   // IMPORTANT: time bin 0 is now the first one in the drift region 
179   // closest to the readout !!!
180   //
181
182   Int_t icham;
183   Int_t iplan;
184   Int_t isect;
185
186   // The outer width of the chambers
187   fCwidth[0] =  94.8;
188   fCwidth[1] =  99.3;
189   fCwidth[2] = 103.7;
190   fCwidth[3] = 108.1;
191   fCwidth[4] = 112.6;
192   fCwidth[5] = 117.0;
193
194   // The outer lengths of the chambers
195   // Includes the spacings between the chambers!
196   Float_t length[kNplan][kNcham]   = { { 124.0, 124.0, 110.0, 124.0, 124.0 }
197                                      , { 131.0, 131.0, 110.0, 131.0, 131.0 }
198                                      , { 138.0, 138.0, 110.0, 138.0, 138.0 }
199                                      , { 145.0, 145.0, 110.0, 145.0, 145.0 }
200                                      , { 147.0, 147.0, 110.0, 147.0, 147.0 }
201                                      , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
202
203   for (icham = 0; icham < kNcham; icham++) {
204     for (iplan = 0; iplan < kNplan; iplan++) {
205       fClength[iplan][icham]   = length[iplan][icham];
206       fClengthPH[iplan][icham] = 0.0;
207       fClengthRH[iplan][icham] = 0.0;
208     }
209   }
210
211   // The rotation matrix elements
212   Float_t phi = 0;
213   for (isect = 0; isect < fgkNsect; isect++) {
214     phi = -2.0 * TMath::Pi() /  (Float_t) fgkNsect * ((Float_t) isect + 0.5);
215     fRotA11[isect] = TMath::Cos(phi);
216     fRotA12[isect] = TMath::Sin(phi);
217     fRotA21[isect] = TMath::Sin(phi);
218     fRotA22[isect] = TMath::Cos(phi);
219     phi = -1.0 * phi;
220     fRotB11[isect] = TMath::Cos(phi);
221     fRotB12[isect] = TMath::Sin(phi);
222     fRotB21[isect] = TMath::Sin(phi);
223     fRotB22[isect] = TMath::Cos(phi);
224   }
225  
226 }
227
228 //_____________________________________________________________________________
229 void AliTRDgeometry::CreateGeometry(Int_t* )
230 {
231   //
232   // Create TRD geometry
233   //
234
235 }
236
237 //_____________________________________________________________________________
238 Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local
239                                    , Float_t *global
240                                    , AliTRDparameter *par) const
241 {
242   //
243   // Converts local pad-coordinates (row,col,time) into 
244   // global ALICE reference frame coordinates (x,y,z)
245   //
246
247   Int_t icham = GetChamber(idet);    // Chamber info (0-4)
248   Int_t isect = GetSector(idet);     // Sector info  (0-17)
249   Int_t iplan = GetPlane(idet);      // Plane info   (0-5)
250
251   return Local2Global(iplan,icham,isect,local,global,par);
252
253 }
254  
255 //_____________________________________________________________________________
256 Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
257                                   , Float_t *local, Float_t *global
258                                   , AliTRDparameter *par) const
259 {
260   //
261   // Converts local pad-coordinates (row,col,time) into 
262   // global ALICE reference frame coordinates (x,y,z)
263   //
264
265   if (!par) {
266     Error("Local2Global","No parameter defined\n");
267     return kFALSE;
268   }
269
270   Int_t    idet      = GetDetector(iplan,icham,isect); // Detector number
271
272   Float_t  padRow    = local[0]+0.5;                   // Pad Row position
273   Float_t  padCol    = local[1]+0.5;                   // Pad Column position
274   Float_t  timeSlice = local[2]+0.5;                   // Time "position"
275
276   Float_t  row0      = par->GetRow0(iplan,icham,isect);
277   Float_t  col0      = par->GetCol0(iplan);
278   Float_t  time0     = par->GetTime0(iplan);
279
280   Float_t  rot[3];
281
282   // calculate (x,y,z) position in rotated chamber
283   rot[0] = time0 - (timeSlice - par->GetTimeBefore()) 
284          * par->GetTimeBinSize();
285   rot[1] = col0  + padCol                    
286          * par->GetColPadSize(iplan);
287   rot[2] = row0  + padRow                    
288          * par->GetRowPadSize(iplan,icham,isect);
289
290   // Rotate back to original position
291   return RotateBack(idet,rot,global);
292
293 }
294
295
296
297 //_____________________________________________________________________________
298 Bool_t AliTRDgeometry::Global2Local(Int_t mode, Float_t *local, Float_t *global, Int_t* index,  AliTRDparameter *par) const
299 {
300   //
301   // Converts local pad-coordinates (row,col,time) into 
302   // global ALICE reference frame coordinates (x,y,z)
303   //
304   //index[0]=plane number
305   //index[1]=chamber number
306   //index[2]=sector number
307   //
308   // mode=0  - local coordinate in y, z,             x - rotated global   
309   // mode=2  - local coordinate in pad, and pad row, x - rotated global
310   //
311   if (!par) {
312     Error("Local2Global","No parameter defined\n");
313     return kFALSE;
314   }
315   
316   //Int_t    idet    = GetDetector(iplan,icham,isect); // Detector number
317   Int_t    idet      = GetDetector(index[0],index[1],index[2]); // Detector number
318   Rotate(idet,global,local);
319   if (mode==0) return kTRUE;
320   //
321   //  Float_t  row0      = par->GetRow0(iplan,icham,isect);
322   //Float_t  col0      = par->GetCol0(iplan);
323   //Float_t  time0     = par->GetTime0(iplan);
324   //
325   // mode 1 to be implemented later
326   // calculate (x,y,z) position in time bin pad row pad
327   //
328   //rot[0] = time0 - (timeSlice - par->GetTimeBefore()) 
329   //       * par->GetTimeBinSize();
330   //rot[1] = col0  + padCol                    
331   //       * par->GetColPadSize(iplan);
332   //rot[2] = row0  + padRow                    
333   //       * par->GetRowPadSize(iplan,icham,isect);
334
335   return kTRUE;
336
337 }
338
339 //___________________________________________________________________
340 Bool_t   AliTRDgeometry::Global2Detector(Float_t global[3], Int_t index[3], AliTRDparameter *par)
341 {
342   //  
343   //
344   //input = global position
345   //output =index
346   //index[0]=plane number
347   //index[1]=chamber number
348   //index[2]=sector number
349   Float_t fi;
350   //
351   fi = TMath::ATan2(global[1],global[0]);
352   if (fi<0) fi += 2*TMath::Pi();
353   index[2] = Int_t(TMath::Nint((fi - GetAlpha()/2.)/GetAlpha()));
354   //
355   //
356   Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]];  
357   index[0] = 0;
358   Float_t max = locx-par->GetTime0(0);
359   for (Int_t iplane=1; iplane<fgkNplan;iplane++){
360     Float_t dist = TMath::Abs(locx-par->GetTime0(iplane));
361     if (dist < max){
362       index[0] = iplane;
363       max = dist;
364     }
365   }
366   Float_t theta = TMath::ATan2(global[2],locx);
367   index[1] = TMath::Nint(float(fgkNcham)*theta/(0.25*TMath::Pi()));
368   return kTRUE;
369
370 }
371
372
373 //_____________________________________________________________________________
374 Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot) const
375 {
376   //
377   // Rotates all chambers in the position of sector 0 and transforms
378   // the coordinates in the ALICE restframe <pos> into the 
379   // corresponding local frame <rot>.
380   //
381
382   Int_t sector = GetSector(d);
383
384   rot[0] =  pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
385   rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
386   rot[2] =  pos[2];
387
388   return kTRUE;
389
390 }
391
392 //_____________________________________________________________________________
393 Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
394 {
395   //
396   // Rotates a chambers from the position of sector 0 into its
397   // original position and transforms the corresponding local frame 
398   // coordinates <rot> into the coordinates of the ALICE restframe <pos>.
399   //
400
401   Int_t sector = GetSector(d);
402
403   pos[0] =  rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
404   pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
405   pos[2] =  rot[2];
406
407   return kTRUE;
408
409 }
410
411 //_____________________________________________________________________________
412 Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c) const
413 {
414   //
415   // Convert plane / chamber into detector number for one single sector
416   //
417
418   return (p + c * fgkNplan);
419
420 }
421
422 //_____________________________________________________________________________
423 Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s) const
424 {
425   //
426   // Convert plane / chamber / sector into detector number
427   //
428
429   return (p + c * fgkNplan + s * fgkNplan * fgkNcham);
430
431 }
432
433 //_____________________________________________________________________________
434 Int_t AliTRDgeometry::GetPlane(Int_t d) const
435 {
436   //
437   // Reconstruct the plane number from the detector number
438   //
439
440   return ((Int_t) (d % fgkNplan));
441
442 }
443
444 //_____________________________________________________________________________
445 Int_t AliTRDgeometry::GetChamber(Int_t d) const
446 {
447   //
448   // Reconstruct the chamber number from the detector number
449   //
450
451   return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan);
452
453 }
454
455 //_____________________________________________________________________________
456 Int_t AliTRDgeometry::GetSector(Int_t d) const
457 {
458   //
459   // Reconstruct the sector number from the detector number
460   //
461
462   return ((Int_t) (d / (fgkNplan * fgkNcham)));
463
464 }
465
466 //_____________________________________________________________________________
467 void AliTRDgeometry::SetOldGeometry()
468 {
469   //
470   // Use the old chamber lengths
471   //
472
473   Int_t icham;
474   Int_t iplan;
475
476   Float_t length[kNplan][kNcham]   = { { 123.5, 123.5, 110.0, 123.5, 123.5 }
477                                      , { 131.0, 131.0, 110.0, 131.0, 131.0 }
478                                      , { 134.5, 138.5, 110.0, 138.5, 134.5 }
479                                      , { 142.0, 146.0, 110.0, 146.0, 142.0 }
480                                      , { 142.0, 153.0, 110.0, 153.0, 142.0 }
481                                      , { 134.0, 160.5, 110.0, 160.5, 134.0 } };
482
483   for (icham = 0; icham < kNcham; icham++) {
484     for (iplan = 0; iplan < kNplan; iplan++) {
485       fClength[iplan][icham]   = length[iplan][icham];
486     }
487   }
488
489 }