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