]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDpadPlane.cxx
8d9c7e78900beca9c25124f9d9f74bb3dfa27afa
[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.
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. 
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) delete [] ((AliTRDpadPlane &) p).fPadRow;
332   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
333   for (iBin = 0; iBin < fNrows; iBin++) {
334     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
335   }                                                                             
336
337   if (((AliTRDpadPlane &) p).fPadCol) delete [] ((AliTRDpadPlane &) p).fPadCol;
338   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
339   for (iBin = 0; iBin < fNrows; iBin++) {
340     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
341   }                                                                             
342
343 }
344
345 //_____________________________________________________________________________
346 AliTRDpadPlane::~AliTRDpadPlane()
347 {
348   //
349   // AliTRDpadPlane destructor
350   //
351
352   if (fGeo) {
353     delete fGeo;
354     fGeo    = 0;
355   }
356
357   if (fPadRow) {
358     delete [] fPadRow;
359     fPadRow = 0;
360   }
361
362   if (fPadCol) {
363     delete [] fPadCol;
364     fPadCol = 0;
365   }
366
367 }
368
369 //_____________________________________________________________________________
370 AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
371 {
372   //
373   // Assignment operator
374   //
375
376   if (this != &p) ((AliTRDpadPlane &) p).Copy(*this);
377   return *this;
378
379 }
380
381 //_____________________________________________________________________________
382 void AliTRDpadPlane::Copy(TObject &p) const
383 {
384   //
385   // Copy function
386   //
387
388   Int_t iBin = 0;
389
390   ((AliTRDpadPlane &) p).fGeo          = 0;
391
392   ((AliTRDpadPlane &) p).fPla          = fPla;
393   ((AliTRDpadPlane &) p).fCha          = fCha;
394
395   ((AliTRDpadPlane &) p).fLength       = fLength;
396   ((AliTRDpadPlane &) p).fWidth        = fWidth;
397   ((AliTRDpadPlane &) p).fLengthRim    = fLengthRim;
398   ((AliTRDpadPlane &) p).fWidthRim     = fWidthRim;
399   ((AliTRDpadPlane &) p).fLengthOPad   = fLengthOPad;
400   ((AliTRDpadPlane &) p).fWidthOPad    = fWidthOPad;
401   ((AliTRDpadPlane &) p).fLengthIPad   = fLengthIPad;
402   ((AliTRDpadPlane &) p).fWidthIPad    = fWidthIPad;
403
404   ((AliTRDpadPlane &) p).fRowSpacing   = fRowSpacing;
405   ((AliTRDpadPlane &) p).fColSpacing   = fColSpacing;
406
407   ((AliTRDpadPlane &) p).fNrows        = fNrows;
408   ((AliTRDpadPlane &) p).fNcols        = fNcols;
409
410   ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle;
411   ((AliTRDpadPlane &) p).fTiltingTan   = fTiltingTan;
412
413   if (((AliTRDpadPlane &) p).fPadRow) delete [] ((AliTRDpadPlane &) p).fPadRow;
414   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
415   for (iBin = 0; iBin < fNrows; iBin++) {
416     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
417   }                                                                             
418
419   if (((AliTRDpadPlane &) p).fPadCol) delete [] ((AliTRDpadPlane &) p).fPadCol;
420   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
421   for (iBin = 0; iBin < fNrows; iBin++) {
422     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
423   }                                                                             
424
425   TObject::Copy(p);
426
427 }
428
429 //_____________________________________________________________________________
430 Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
431 {
432   //
433   // Finds the pad row number for a given global z-position
434   //
435
436   Int_t row    = 0;
437   Int_t nabove = 0;
438   Int_t nbelow = 0;
439   Int_t middle = 0;
440
441   if ((z > GetRow0()) || (z < GetRowEnd())) {
442
443     row = -1;
444
445   }
446   else {
447
448     nabove = fNrows+1;
449     nbelow = 0;
450     while (nabove - nbelow > 1) {
451       middle = (nabove + nbelow) / 2;
452       if (z == fPadRow[middle-1]) row    = middle;
453       if (z  > fPadRow[middle-1]) nabove = middle;
454       else                        nbelow = middle;
455     }
456     row = nbelow - 1;
457
458   }
459
460   return row;
461
462 }
463
464 //_____________________________________________________________________________
465 Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi
466                                      , Double_t /*rowOffset*/) const
467 {
468   //
469   // Finds the pad column number for a given global rphi-position
470   //
471
472   Int_t    col       = 0;
473   Int_t    nabove    = 0;
474   Int_t    nbelow    = 0;
475   Int_t    middle    = 0;
476   Double_t rphiShift = 0;
477
478   // MI change don't apply tilting angle here - better to do it directly on hit level
479   // Take the tilting angle into account by shifting the hit position
480   // into the opposite direction
481   // 
482
483   rphiShift = rphi ;
484
485   if ((rphiShift > GetCol0()) || (rphiShift < GetColEnd())) {
486
487     col = -1;
488
489   }
490   else {
491
492     nabove = fNcols+1;
493     nbelow = 0;
494     while (nabove - nbelow > 1) {
495       middle = (nabove + nbelow) / 2;
496       if (rphiShift == fPadCol[middle-1]) col    = middle;
497       if (rphiShift  > fPadCol[middle-1]) nabove = middle;
498       else                                nbelow = middle;
499     }
500     col = nbelow - 1;
501
502   }
503
504   return col;
505
506 }