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