]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDpadPlane.cxx
Add missing assignment function
[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.025;
81   //fColSpacing = 0.025;
82
83   fRowSpacing = 0.0;
84   fColSpacing = 0.0;
85
86   fLengthRim  = 1.0;
87   fWidthRim   = 0.5;
88
89   fNcols      = 144;
90
91   //
92   // The pad plane parameter
93   //
94   switch (p) {
95   case 0:
96     if (c == 2) {
97       // L0C0 type
98       fNrows        =  12;
99       fLength       = 108.0;
100       fWidth        =  94.4;
101       fLengthOPad   =   8.0;
102       fWidthOPad    =   0.515;
103       fLengthIPad   =   9.0;
104       fWidthIPad    =   0.635;
105       fTiltingAngle =  -2.0;
106     }
107     else {
108       // L0C1 type
109       fNrows        =  16;
110       fLength       = 122.0;
111       fWidth        =  94.4;
112       fLengthOPad   =   7.5;
113       fWidthOPad    =   0.515;
114       fLengthIPad   =   7.5;
115       fWidthIPad    =   0.635;
116       fTiltingAngle =  -2.0;
117     }
118     break;
119   case 1:
120     if (c == 2) {
121       // L1C0 type
122       fNrows        =  12;
123       fLength       = 108.0;
124       fWidth        =  96.6;
125       fLengthOPad   =   8.0;
126       fWidthOPad    =   0.585;
127       fLengthIPad   =   9.0;
128       fWidthIPad    =   0.665;
129       fTiltingAngle =   2.0;
130     }
131     else {
132       // L1C1 type
133       fNrows        =  16;
134       fLength       = 122.0;
135       fWidth        =  96.6;
136       fLengthOPad   =   7.5;
137       fWidthOPad    =   0.585;
138       fLengthIPad   =   7.5;
139       fWidthIPad    =   0.665;
140       fTiltingAngle =   2.0;
141     }
142     break;
143   case 2:
144     if (c == 2) {
145       // L2C0 type
146       fNrows        =  12;
147       fLength       = 108.0;
148       fWidth        = 101.1;
149       fLengthOPad   =   8.0;
150       fWidthOPad    =   0.705;
151       fLengthIPad   =   9.0;
152       fWidthIPad    =   0.695;
153       fTiltingAngle =  -2.0;
154     }
155     else {
156       // L2C1 type
157       fNrows        =  16;
158       fLength       = 129.0;
159       fWidth        = 101.1;
160       fLengthOPad   =   7.5;
161       fWidthOPad    =   0.705;
162       fLengthIPad   =   8.0;
163       fWidthIPad    =   0.695;
164       fTiltingAngle =  -2.0;
165     }
166     break;
167   case 3:
168     if (c == 2) {
169       // L3C0 type
170       fNrows        =  12;
171       fLength       = 108.0;
172       fWidth        = 105.5;
173       fLengthOPad   =   8.0;
174       fWidthOPad    =   0.775;
175       fLengthIPad   =   9.0;
176       fWidthIPad    =   0.725;
177       fTiltingAngle =   2.0;
178     }
179     else {
180       // L3C1 type
181       fNrows        =  16;
182       fLength       = 136.0;
183       fWidth        = 105.5;
184       fLengthOPad   =   7.5;
185       fWidthOPad    =   0.775;
186       fLengthIPad   =   8.5;
187       fWidthIPad    =   0.725;
188       fTiltingAngle =   2.0;
189     }
190     break;
191   case 4:
192     if (c == 2) {
193       // L4C0 type
194       fNrows        =  12;
195       fLength       = 108.0;
196       fWidth        = 109.9;
197       fLengthOPad   =   8.0;
198       fWidthOPad    =   0.845;
199       fLengthIPad   =   9.0;
200       fWidthIPad    =   0.755;
201       fTiltingAngle =  -2.0;
202     }
203     else {
204       // L4C1 type
205       fNrows        =  16;
206       fLength       = 143.0;
207       fWidth        = 109.9;
208       fLengthOPad   =   7.5;
209       fWidthOPad    =   0.845;
210       fLengthIPad   =   9.0;
211       fWidthIPad    =   0.755;
212       fTiltingAngle =  -2.0;
213     }
214     break;
215   case 5:
216     if (c == 2) {
217       // L5C0 type
218       fNrows        =  12;
219       fLength       = 108.0;
220       fWidth        = 114.4;
221       fLengthOPad   =   8.0;
222       fWidthOPad    =   0.965;
223       fLengthIPad   =   9.0;
224       fWidthIPad    =   0.785;
225       fTiltingAngle =   2.0;
226     }
227     else {
228       // L5C1 type
229       fNrows        =  16;
230       fLength       = 145.0;
231       fWidth        = 114.4;
232       fLengthOPad   =   8.5;
233       fWidthOPad    =   0.965;
234       fLengthIPad   =   9.0;
235       fWidthIPad    =   0.785;
236       fTiltingAngle =   2.0;
237     }
238     break;
239   };
240
241   //
242   // The positions of the borders of the pads
243   //
244   // Row direction
245   //
246   if (fPadRow) delete [] fPadRow;
247   fPadRow = new Double_t[fNrows];
248   Double_t row = fGeo->GetChamberLength(p,0)
249                + fGeo->GetChamberLength(p,1)
250                + fGeo->GetChamberLength(p,2) / 2.
251                - fLengthRim;
252   for (Int_t ic = 0; ic < c; ic++) {
253     row -= fGeo->GetChamberLength(p,ic);
254   }
255   for (Int_t ir = 0; ir < fNrows; ir++) {
256     fPadRow[ir] = row;
257     row -= fRowSpacing;
258     if (ir == 1) {
259       row -= fLengthOPad;
260     }
261     else {
262       row -= fLengthIPad;
263     }
264   }
265   //
266   // Column direction
267   //
268   if (fPadCol) delete [] fPadCol;
269   fPadCol = new Double_t[fNcols];
270   Double_t col = fGeo->GetChamberWidth(p) / 2. 
271                - fWidthRim;
272   for (Int_t ic = 0; ic < fNcols; ic++) {
273     fPadCol[ic] = col;
274     col -= fColSpacing;
275     if (ic == 1) {
276       col -= fWidthOPad;
277     }
278     else {
279       col -= fWidthIPad;
280     }
281   }
282
283 }
284
285 //_____________________________________________________________________________
286 AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p):TObject(p)
287 {
288   //
289   // AliTRDpadPlane copy constructor
290   //
291
292   ((AliTRDpadPlane &) p).Copy(*this);
293
294 }
295
296 //_____________________________________________________________________________
297 AliTRDpadPlane::~AliTRDpadPlane()
298 {
299   //
300   // AliTRDpadPlane destructor
301   //
302
303   if (fGeo) {
304     delete fGeo;
305     fGeo    = 0;
306   }
307
308   if (fPadRow) {
309     delete [] fPadRow;
310     fPadRow = 0;
311   }
312
313   if (fPadCol) {
314     delete [] fPadCol;
315     fPadCol = 0;
316   }
317
318 }
319
320 //_____________________________________________________________________________
321 AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
322 {
323   //
324   // Assignment operator
325   //
326
327   if (this != &p) ((AliTRDpadPlane &) p).Copy(*this);
328   return *this;
329
330 }
331
332 //_____________________________________________________________________________
333 void AliTRDpadPlane::Copy(TObject &p) const
334 {
335   //
336   // Copy function
337   //
338
339   Int_t iBin = 0;
340
341   ((AliTRDpadPlane &) p).fGeo          = 0;
342
343   ((AliTRDpadPlane &) p).fPla          = fPla;
344   ((AliTRDpadPlane &) p).fCha          = fCha;
345
346   ((AliTRDpadPlane &) p).fLength       = fLength;
347   ((AliTRDpadPlane &) p).fWidth        = fWidth;
348   ((AliTRDpadPlane &) p).fLengthRim    = fLengthRim;
349   ((AliTRDpadPlane &) p).fWidthRim     = fWidthRim;
350   ((AliTRDpadPlane &) p).fLengthOPad   = fLengthOPad;
351   ((AliTRDpadPlane &) p).fWidthOPad    = fWidthOPad;
352   ((AliTRDpadPlane &) p).fLengthIPad   = fLengthIPad;
353   ((AliTRDpadPlane &) p).fWidthIPad    = fWidthIPad;
354
355   ((AliTRDpadPlane &) p).fRowSpacing   = fRowSpacing;
356   ((AliTRDpadPlane &) p).fColSpacing   = fColSpacing;
357
358   ((AliTRDpadPlane &) p).fNrows        = fNrows;
359   ((AliTRDpadPlane &) p).fNcols        = fNcols;
360
361   ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle;
362
363   if (((AliTRDpadPlane &) p).fPadRow) delete [] ((AliTRDpadPlane &) p).fPadRow;
364   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
365   for (iBin = 0; iBin < fNrows; iBin++) {
366     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
367   }                                                                             
368
369   if (((AliTRDpadPlane &) p).fPadCol) delete [] ((AliTRDpadPlane &) p).fPadCol;
370   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
371   for (iBin = 0; iBin < fNrows; iBin++) {
372     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
373   }                                                                             
374
375   TObject::Copy(p);
376
377 }
378
379 //_____________________________________________________________________________
380 Int_t AliTRDpadPlane::GetPadRowNumber(const Double_t z)
381 {
382   //
383   // Finds the pad row number for a given global z-position
384   //
385
386   Int_t row    = 0;
387   Int_t nabove = 0;
388   Int_t nbelow = 0;
389   Int_t middle = 0;
390
391   if ((z > fPadRow[0]) ||
392       (z < fPadRow[0] - fLength + 2.0*fLengthRim)) {
393     row = -1;
394   }
395   else {
396     nabove = fNrows+1;
397     nbelow = 0;
398     while (nabove - nbelow > 1) {
399       middle = (nabove + nbelow) / 2;
400       if (z == fPadRow[middle-1]) row    = middle;
401       if (z  > fPadRow[middle-1]) nabove = middle;
402       else                        nbelow = middle;
403     }
404     row = nbelow - 1;
405   }
406
407   return row;
408
409 }
410
411 //_____________________________________________________________________________
412 Int_t AliTRDpadPlane::GetPadColNumber(const Double_t rphi)
413 {
414   //
415   // Finds the pad column number for a given global rphi-position
416   //
417
418   Int_t col    = 0;
419   Int_t nabove = 0;
420   Int_t nbelow = 0;
421   Int_t middle = 0;
422
423   if ((rphi > fPadCol[0]) ||
424       (rphi < fPadCol[0] - fWidth + 2.0*fWidthRim)) {
425     col = -1;
426   }
427   else {
428     nabove = fNcols+1;
429     nbelow = 0;
430     while (nabove - nbelow > 1) {
431       middle = (nabove + nbelow) / 2;
432       if (rphi == fPadCol[middle-1]) col    = middle;
433       if (rphi  > fPadCol[middle-1]) nabove = middle;
434       else                           nbelow = middle;
435     }
436     col = nbelow - 1;
437   }
438
439   return col;
440
441 }
442
443 //_____________________________________________________________________________
444 Double_t AliTRDpadPlane::GetPadRowOffset(const Int_t row, const Double_t z)
445 {
446   //
447   // Calculates the distance to the pad border in row direction
448   //
449
450   if ((row < 0) || (row >= fNrows)) {
451     return -1.0;
452   }
453   else {
454     return fPadRow[row] - z;
455   }
456
457 }
458
459 //_____________________________________________________________________________
460 Double_t AliTRDpadPlane::GetPadColOffset(const Int_t col, const Double_t rphi)
461 {
462   //
463   // Calculates the distance to the pad border in column direction
464   //
465
466   if ((col < 0) || (col >= fNcols)) {
467     return -1.0;
468   }
469   else {
470     return fPadCol[col] - rphi;
471   }
472
473 }