]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDpadPlane.cxx
Fix of geometry and pad plane parameter
[u/mrichter/AliRoot.git] / TRD / AliTRDpadPlane.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 //  Describes a pad plane of a TRD ROC                                       //
21 //                                                                           //
22 //  Contains the information on pad postions, pad dimensions,                //
23 //  tilting angle, etc.                                                      //
24 //  It also provides methods to identify the current pad number from         //
25 //  global coordinates.                                                      //
26 //                                                                           //
27 ///////////////////////////////////////////////////////////////////////////////
28
29 #include "AliTRDpadPlane.h"
30 #include "AliTRDgeometryFull.h"
31
32 ClassImp(AliTRDpadPlane)
33
34 //_____________________________________________________________________________
35 AliTRDpadPlane::AliTRDpadPlane():TObject()
36 {
37   //
38   // Default constructor
39   //
40
41   fGeo          = 0;
42
43   fPla          = 0;
44   fCha          = 0;
45
46   fLength       = 0.0;
47   fWidth        = 0.0;
48   fLengthRim    = 0.0;
49   fWidthRim     = 0.0;
50   fLengthOPad   = 0.0;
51   fWidthOPad    = 0.0;
52   fLengthIPad   = 0.0;
53   fWidthIPad    = 0.0;
54
55   fRowSpacing   = 0.0;
56   fColSpacing   = 0.0;
57
58   fNrows        = 0;
59   fNcols        = 0;
60
61   fPadRow       = 0;
62   fPadCol       = 0;
63
64   fTiltingAngle = 0.0;
65
66 }
67
68 //_____________________________________________________________________________
69 AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c):TObject()
70 {
71   //
72   // Constructor that initializes a given pad plane type
73   //
74
75   fGeo = new AliTRDgeometryFull();
76
77   fPla = p;
78   fCha = c;
79
80   fRowSpacing = 0.0;
81   fColSpacing = 0.0;
82
83   fLengthRim  = 1.0;
84   fWidthRim   = 0.5;
85
86   fNcols      = 144;
87
88   //
89   // The pad plane parameter
90   //
91   switch (p) {
92   case 0:
93     if (c == 2) {
94       // L0C0 type
95       fNrows        =  12;
96       fLength       = 108.0;
97       fWidth        =  92.2;
98       fLengthOPad   =   8.0;
99       fWidthOPad    =   0.515;
100       fLengthIPad   =   9.0;
101       fWidthIPad    =   0.635;
102       fTiltingAngle =  -2.0;
103     }
104     else {
105       // L0C1 type
106       fNrows        =  16;
107       fLength       = 122.0;
108       fWidth        =  92.2;
109       fLengthOPad   =   7.5;
110       fWidthOPad    =   0.515;
111       fLengthIPad   =   7.5;
112       fWidthIPad    =   0.635;
113       fTiltingAngle =  -2.0;
114     }
115     break;
116   case 1:
117     if (c == 2) {
118       // L1C0 type
119       fNrows        =  12;
120       fLength       = 108.0;
121       fWidth        =  96.6;
122       fLengthOPad   =   8.0;
123       fWidthOPad    =   0.585;
124       fLengthIPad   =   9.0;
125       fWidthIPad    =   0.665;
126       fTiltingAngle =   2.0;
127     }
128     else {
129       // L1C1 type
130       fNrows        =  16;
131       fLength       = 122.0;
132       fWidth        =  96.6;
133       fLengthOPad   =   7.5;
134       fWidthOPad    =   0.585;
135       fLengthIPad   =   7.5;
136       fWidthIPad    =   0.665;
137       fTiltingAngle =   2.0;
138     }
139     break;
140   case 2:
141     if (c == 2) {
142       // L2C0 type
143       fNrows        =  12;
144       fLength       = 108.0;
145       fWidth        = 101.1;
146       fLengthOPad   =   8.0;
147       fWidthOPad    =   0.705;
148       fLengthIPad   =   9.0;
149       fWidthIPad    =   0.695;
150       fTiltingAngle =  -2.0;
151     }
152     else {
153       // L2C1 type
154       fNrows        =  16;
155       fLength       = 129.0;
156       fWidth        = 101.1;
157       fLengthOPad   =   7.5;
158       fWidthOPad    =   0.705;
159       fLengthIPad   =   8.0;
160       fWidthIPad    =   0.695;
161       fTiltingAngle =  -2.0;
162     }
163     break;
164   case 3:
165     if (c == 2) {
166       // L3C0 type
167       fNrows        =  12;
168       fLength       = 108.0;
169       fWidth        = 105.5;
170       fLengthOPad   =   8.0;
171       fWidthOPad    =   0.775;
172       fLengthIPad   =   9.0;
173       fWidthIPad    =   0.725;
174       fTiltingAngle =   2.0;
175     }
176     else {
177       // L3C1 type
178       fNrows        =  16;
179       fLength       = 136.0;
180       fWidth        = 105.5;
181       fLengthOPad   =   7.5;
182       fWidthOPad    =   0.775;
183       fLengthIPad   =   8.5;
184       fWidthIPad    =   0.725;
185       fTiltingAngle =   2.0;
186     }
187     break;
188   case 4:
189     if (c == 2) {
190       // L4C0 type
191       fNrows        =  12;
192       fLength       = 108.0;
193       fWidth        = 109.9;
194       fLengthOPad   =   8.0;
195       fWidthOPad    =   0.845;
196       fLengthIPad   =   9.0;
197       fWidthIPad    =   0.755;
198       fTiltingAngle =  -2.0;
199     }
200     else {
201       // L4C1 type
202       fNrows        =  16;
203       fLength       = 143.0;
204       fWidth        = 109.9;
205       fLengthOPad   =   7.5;
206       fWidthOPad    =   0.845;
207       fLengthIPad   =   9.0;
208       fWidthIPad    =   0.755;
209       fTiltingAngle =  -2.0;
210     }
211     break;
212   case 5:
213     if (c == 2) {
214       // L5C0 type
215       fNrows        =  12;
216       fLength       = 108.0;
217       fWidth        = 114.4;
218       fLengthOPad   =   8.0;
219       fWidthOPad    =   0.965;
220       fLengthIPad   =   9.0;
221       fWidthIPad    =   0.785;
222       fTiltingAngle =   2.0;
223     }
224     else {
225       // L5C1 type
226       fNrows        =  16;
227       fLength       = 145.0;
228       fWidth        = 114.4;
229       fLengthOPad   =   8.5;
230       fWidthOPad    =   0.965;
231       fLengthIPad   =   9.0;
232       fWidthIPad    =   0.785;
233       fTiltingAngle =   2.0;
234     }
235     break;
236   };
237
238   //
239   // The positions of the borders of the pads
240   //
241   // Row direction
242   //
243   if (fPadRow) delete [] fPadRow;
244   fPadRow = new Double_t[fNrows];
245   Double_t row = fGeo->GetChamberLength(p,0)
246                + fGeo->GetChamberLength(p,1)
247                + fGeo->GetChamberLength(p,2) / 2.
248                - fLengthRim;
249   for (Int_t ic = 0; ic < c; ic++) {
250     row -= fGeo->GetChamberLength(p,ic);
251   }
252   for (Int_t ir = 0; ir < fNrows; ir++) {
253     fPadRow[ir] = row;
254     row -= fRowSpacing;
255     if (ir == 1) {
256       row -= fLengthOPad;
257     }
258     else {
259       row -= fLengthIPad;
260     }
261   }
262   //
263   // Column direction
264   //
265   if (fPadCol) delete [] fPadCol;
266   fPadCol = new Double_t[fNcols];
267   Double_t col = fGeo->GetChamberWidth(p) / 2. 
268                + fGeo->CroWid()
269                - fWidthRim;
270   for (Int_t ic = 0; ic < fNcols; ic++) {
271     fPadCol[ic] = col;
272     col -= fColSpacing;
273     if (ic == 1) {
274       col -= fWidthOPad;
275     }
276     else {
277       col -= fWidthIPad;
278     }
279   }
280
281 }
282
283 //_____________________________________________________________________________
284 AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p):TObject(p)
285 {
286   //
287   // AliTRDpadPlane copy constructor
288   //
289
290   ((AliTRDpadPlane &) p).Copy(*this);
291
292 }
293
294 //_____________________________________________________________________________
295 AliTRDpadPlane::~AliTRDpadPlane()
296 {
297   //
298   // AliTRDpadPlane destructor
299   //
300
301   if (fGeo) {
302     delete fGeo;
303     fGeo    = 0;
304   }
305
306   if (fPadRow) {
307     delete [] fPadRow;
308     fPadRow = 0;
309   }
310
311   if (fPadCol) {
312     delete [] fPadCol;
313     fPadCol = 0;
314   }
315
316 }
317
318 //_____________________________________________________________________________
319 AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
320 {
321   //
322   // Assignment operator
323   //
324
325   if (this != &p) ((AliTRDpadPlane &) p).Copy(*this);
326   return *this;
327
328 }
329
330 //_____________________________________________________________________________
331 void AliTRDpadPlane::Copy(TObject &p) const
332 {
333   //
334   // Copy function
335   //
336
337   Int_t iBin = 0;
338
339   ((AliTRDpadPlane &) p).fGeo          = 0;
340
341   ((AliTRDpadPlane &) p).fPla          = fPla;
342   ((AliTRDpadPlane &) p).fCha          = fCha;
343
344   ((AliTRDpadPlane &) p).fLength       = fLength;
345   ((AliTRDpadPlane &) p).fWidth        = fWidth;
346   ((AliTRDpadPlane &) p).fLengthRim    = fLengthRim;
347   ((AliTRDpadPlane &) p).fWidthRim     = fWidthRim;
348   ((AliTRDpadPlane &) p).fLengthOPad   = fLengthOPad;
349   ((AliTRDpadPlane &) p).fWidthOPad    = fWidthOPad;
350   ((AliTRDpadPlane &) p).fLengthIPad   = fLengthIPad;
351   ((AliTRDpadPlane &) p).fWidthIPad    = fWidthIPad;
352
353   ((AliTRDpadPlane &) p).fRowSpacing   = fRowSpacing;
354   ((AliTRDpadPlane &) p).fColSpacing   = fColSpacing;
355
356   ((AliTRDpadPlane &) p).fNrows        = fNrows;
357   ((AliTRDpadPlane &) p).fNcols        = fNcols;
358
359   ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle;
360
361   if (((AliTRDpadPlane &) p).fPadRow) delete [] ((AliTRDpadPlane &) p).fPadRow;
362   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
363   for (iBin = 0; iBin < fNrows; iBin++) {
364     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
365   }                                                                             
366
367   if (((AliTRDpadPlane &) p).fPadCol) delete [] ((AliTRDpadPlane &) p).fPadCol;
368   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
369   for (iBin = 0; iBin < fNrows; iBin++) {
370     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
371   }                                                                             
372
373   TObject::Copy(p);
374
375 }
376
377 //_____________________________________________________________________________
378 Int_t AliTRDpadPlane::GetPadRowNumber(const Double_t z)
379 {
380   //
381   // Finds the pad row number for a given global z-position
382   //
383
384   Int_t row    = 0;
385   Int_t nabove = 0;
386   Int_t nbelow = 0;
387   Int_t middle = 0;
388
389   if ((z > fPadRow[0]) ||
390       (z < fPadRow[0] - fLength + 2.0*fLengthRim)) {
391     row = -1;
392   }
393   else {
394     nabove = fNrows+1;
395     nbelow = 0;
396     while (nabove - nbelow > 1) {
397       middle = (nabove + nbelow) / 2;
398       if (z == fPadRow[middle-1]) row    = middle;
399       if (z  > fPadRow[middle-1]) nabove = middle;
400       else                        nbelow = middle;
401     }
402     row = nbelow - 1;
403   }
404
405   return row;
406
407 }
408
409 //_____________________________________________________________________________
410 Int_t AliTRDpadPlane::GetPadColNumber(const Double_t rphi)
411 {
412   //
413   // Finds the pad column number for a given global rphi-position
414   //
415
416   Int_t col    = 0;
417   Int_t nabove = 0;
418   Int_t nbelow = 0;
419   Int_t middle = 0;
420
421   if ((rphi > fPadCol[0]) ||
422       (rphi < fPadCol[0] - fWidth + 2.0*fWidthRim)) {
423     col = -1;
424   }
425   else {
426     nabove = fNcols+1;
427     nbelow = 0;
428     while (nabove - nbelow > 1) {
429       middle = (nabove + nbelow) / 2;
430       if (rphi == fPadCol[middle-1]) col    = middle;
431       if (rphi  > fPadCol[middle-1]) nabove = middle;
432       else                           nbelow = middle;
433     }
434     col = nbelow - 1;
435   }
436
437   return col;
438
439 }
440
441 //_____________________________________________________________________________
442 Double_t AliTRDpadPlane::GetPadRowOffset(const Int_t row, const Double_t z)
443 {
444   //
445   // Calculates the distance to the pad border in row direction
446   //
447
448   if ((row < 0) || (row >= fNrows)) {
449     return -1.0;
450   }
451   else {
452     return fPadRow[row] - z;
453   }
454
455 }
456
457 //_____________________________________________________________________________
458 Double_t AliTRDpadPlane::GetPadColOffset(const Int_t col, const Double_t rphi)
459 {
460   //
461   // Calculates the distance to the pad border in column direction
462   //
463
464   if ((col < 0) || (col >= fNcols)) {
465     return -1.0;
466   }
467   else {
468     return fPadCol[col] - rphi;
469   }
470
471 }