]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDpadPlane.cxx
AliTRDpadPlane in digitization scheme implemented
[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   // Store tilting angle as tangens (opposite direction!)
240   //
241   fTiltingAngle = TMath::Tan(TMath::Pi()/180.0 * -fTiltingAngle);
242
243   //
244   // The positions of the borders of the pads
245   //
246   // Row direction
247   //
248   if (fPadRow) delete [] fPadRow;
249   fPadRow = new Double_t[fNrows];
250   Double_t row = fGeo->GetChamberLength(p,0)
251                + fGeo->GetChamberLength(p,1)
252                + fGeo->GetChamberLength(p,2) / 2.
253                - fGeo->RpadW()
254                - fLengthRim;
255   for (Int_t ic = 0; ic < c; ic++) {
256     row -= fGeo->GetChamberLength(p,ic);
257   }
258   for (Int_t ir = 0; ir < fNrows; ir++) {
259     fPadRow[ir] = row;
260     row -= fRowSpacing;
261     if (ir == 0) {
262       row -= fLengthOPad;
263     }
264     else {
265       row -= fLengthIPad;
266     }
267   }
268   //
269   // Column direction
270   //
271   if (fPadCol) delete [] fPadCol;
272   fPadCol = new Double_t[fNcols];
273   Double_t col = fGeo->GetChamberWidth(p) / 2. 
274                + fGeo->CroWid()
275                - fWidthRim;
276   for (Int_t ic = 0; ic < fNcols; ic++) {
277     fPadCol[ic] = col;
278     col -= fColSpacing;
279     if (ic == 0) {
280       col -= fWidthOPad;
281     }
282     else {
283       col -= fWidthIPad;
284     }
285   }
286
287 }
288
289 //_____________________________________________________________________________
290 AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p):TObject(p)
291 {
292   //
293   // AliTRDpadPlane copy constructor
294   //
295
296   ((AliTRDpadPlane &) p).Copy(*this);
297
298 }
299
300 //_____________________________________________________________________________
301 AliTRDpadPlane::~AliTRDpadPlane()
302 {
303   //
304   // AliTRDpadPlane destructor
305   //
306
307   if (fGeo) {
308     delete fGeo;
309     fGeo    = 0;
310   }
311
312   if (fPadRow) {
313     delete [] fPadRow;
314     fPadRow = 0;
315   }
316
317   if (fPadCol) {
318     delete [] fPadCol;
319     fPadCol = 0;
320   }
321
322 }
323
324 //_____________________________________________________________________________
325 AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
326 {
327   //
328   // Assignment operator
329   //
330
331   if (this != &p) ((AliTRDpadPlane &) p).Copy(*this);
332   return *this;
333
334 }
335
336 //_____________________________________________________________________________
337 void AliTRDpadPlane::Copy(TObject &p) const
338 {
339   //
340   // Copy function
341   //
342
343   Int_t iBin = 0;
344
345   ((AliTRDpadPlane &) p).fGeo          = 0;
346
347   ((AliTRDpadPlane &) p).fPla          = fPla;
348   ((AliTRDpadPlane &) p).fCha          = fCha;
349
350   ((AliTRDpadPlane &) p).fLength       = fLength;
351   ((AliTRDpadPlane &) p).fWidth        = fWidth;
352   ((AliTRDpadPlane &) p).fLengthRim    = fLengthRim;
353   ((AliTRDpadPlane &) p).fWidthRim     = fWidthRim;
354   ((AliTRDpadPlane &) p).fLengthOPad   = fLengthOPad;
355   ((AliTRDpadPlane &) p).fWidthOPad    = fWidthOPad;
356   ((AliTRDpadPlane &) p).fLengthIPad   = fLengthIPad;
357   ((AliTRDpadPlane &) p).fWidthIPad    = fWidthIPad;
358
359   ((AliTRDpadPlane &) p).fRowSpacing   = fRowSpacing;
360   ((AliTRDpadPlane &) p).fColSpacing   = fColSpacing;
361
362   ((AliTRDpadPlane &) p).fNrows        = fNrows;
363   ((AliTRDpadPlane &) p).fNcols        = fNcols;
364
365   ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle;
366
367   if (((AliTRDpadPlane &) p).fPadRow) delete [] ((AliTRDpadPlane &) p).fPadRow;
368   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
369   for (iBin = 0; iBin < fNrows; iBin++) {
370     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
371   }                                                                             
372
373   if (((AliTRDpadPlane &) p).fPadCol) delete [] ((AliTRDpadPlane &) p).fPadCol;
374   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
375   for (iBin = 0; iBin < fNrows; iBin++) {
376     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
377   }                                                                             
378
379   TObject::Copy(p);
380
381 }
382
383 //_____________________________________________________________________________
384 Int_t AliTRDpadPlane::GetPadRowNumber(const Double_t z) const
385 {
386   //
387   // Finds the pad row number for a given global z-position
388   //
389
390   Int_t row    = 0;
391   Int_t nabove = 0;
392   Int_t nbelow = 0;
393   Int_t middle = 0;
394
395   if ((z > GetRow0()) || (z < GetRowEnd())) {
396
397     row = -1;
398
399   }
400   else {
401
402     nabove = fNrows+1;
403     nbelow = 0;
404     while (nabove - nbelow > 1) {
405       middle = (nabove + nbelow) / 2;
406       if (z == fPadRow[middle-1]) row    = middle;
407       if (z  > fPadRow[middle-1]) nabove = middle;
408       else                        nbelow = middle;
409     }
410     row = nbelow - 1;
411
412   }
413
414   return row;
415
416 }
417
418 //_____________________________________________________________________________
419 Int_t AliTRDpadPlane::GetPadColNumber(const Double_t rphi
420                                     , const Double_t rowOffset) const
421 {
422   //
423   // Finds the pad column number for a given global rphi-position
424   //
425
426   Int_t    col       = 0;
427   Int_t    nabove    = 0;
428   Int_t    nbelow    = 0;
429   Int_t    middle    = 0;
430   Double_t rphiShift = 0;
431
432   if ((rphi > GetCol0()) || (rphi < GetColEnd())) {
433
434     col = -1;
435
436   }
437   else {
438
439     //
440     // Take the tilting angle into account by shifting the hit position
441     // into the opposite direction
442     //
443
444     rphiShift = rphi + fTiltingAngle * rowOffset;
445
446     nabove = fNcols+1;
447     nbelow = 0;
448     while (nabove - nbelow > 1) {
449       middle = (nabove + nbelow) / 2;
450       if (rphi == fPadCol[middle-1]) col    = middle;
451       if (rphi  > fPadCol[middle-1]) nabove = middle;
452       else                           nbelow = middle;
453     }
454     col = nbelow - 1;
455
456     //printf("rphi=%f, rphiShift=%f, col=%d, colH=%f\n"
457     //   ,rphi,rphiShift,col,fPadCol[col]);
458
459   }
460
461   return col;
462
463 }