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