]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDpadPlane.cxx
2851dd3a817fc6d28c53f6261aa1b517fc55fcf9
[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 <TMath.h>
32
33 #include "AliTRDpadPlane.h"
34 #include "AliTRDgeometry.h"
35
36 ClassImp(AliTRDpadPlane)
37
38 //_____________________________________________________________________________
39 AliTRDpadPlane::AliTRDpadPlane()
40   :TObject()
41   ,fPla(0)
42   ,fCha(0)
43   ,fLength(0)
44   ,fWidth(0)
45   ,fLengthRim(0)
46   ,fWidthRim(0)
47   ,fLengthOPad(0)
48   ,fWidthOPad(0)
49   ,fLengthIPad(0)
50   ,fWidthIPad(0)
51   ,fRowSpacing(0)
52   ,fColSpacing(0)
53   ,fNrows(0)
54   ,fNcols(0)
55   ,fTiltingAngle(0)
56   ,fTiltingTan(0)
57   ,fPadRow(0)
58   ,fPadCol(0)
59   ,fPadRowSMOffset(0)
60 {
61   //
62   // Default constructor
63   //
64
65 }
66
67 //_____________________________________________________________________________
68 AliTRDpadPlane::AliTRDpadPlane(Int_t plane, Int_t chamber)
69   :TObject()
70   ,fPla(plane)
71   ,fCha(chamber)
72   ,fLength(0)
73   ,fWidth(0)
74   ,fLengthRim(0)
75   ,fWidthRim(0)
76   ,fLengthOPad(0)
77   ,fWidthOPad(0)
78   ,fLengthIPad(0)
79   ,fWidthIPad(0)
80   ,fRowSpacing(0)
81   ,fColSpacing(0)
82   ,fNrows(0)
83   ,fNcols(0)
84   ,fTiltingAngle(0)
85   ,fTiltingTan(0)
86   ,fPadRow(0)
87   ,fPadCol(0)
88   ,fPadRowSMOffset(0)
89 {
90   //
91   // Constructor
92   //
93
94 }
95
96 //_____________________________________________________________________________
97 AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p)
98   :TObject(p)
99   ,fPla(p.fPla)
100   ,fCha(p.fCha)
101   ,fLength(p.fLength)
102   ,fWidth(p.fWidth)
103   ,fLengthRim(p.fLengthRim)
104   ,fWidthRim(p.fLengthRim)
105   ,fLengthOPad(p.fLengthOPad)
106   ,fWidthOPad(p.fWidthOPad)
107   ,fLengthIPad(p.fLengthIPad)
108   ,fWidthIPad(p.fWidthIPad)
109   ,fRowSpacing(p.fRowSpacing)
110   ,fColSpacing(p.fColSpacing)
111   ,fNrows(p.fNrows)
112   ,fNcols(p.fNcols)
113   ,fTiltingAngle(p.fTiltingAngle)
114   ,fTiltingTan(p.fTiltingTan)
115   ,fPadRow(0)
116   ,fPadCol(0)
117   ,fPadRowSMOffset(p.fPadRowSMOffset)
118 {
119   //
120   // AliTRDpadPlane copy constructor
121   //
122
123   Int_t iBin = 0;
124
125   if (((AliTRDpadPlane &) p).fPadRow) {
126     delete [] ((AliTRDpadPlane &) p).fPadRow;
127   }
128   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
129   for (iBin = 0; iBin < fNrows; iBin++) {
130     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
131   }                                                                             
132
133   if (((AliTRDpadPlane &) p).fPadCol) {
134     delete [] ((AliTRDpadPlane &) p).fPadCol;
135   }
136   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
137   for (iBin = 0; iBin < fNrows; iBin++) {
138     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
139   }                                                                             
140
141 }
142
143 //_____________________________________________________________________________
144 AliTRDpadPlane::~AliTRDpadPlane()
145 {
146   //
147   // AliTRDpadPlane destructor
148   //
149
150   if (fPadRow) {
151     delete [] fPadRow;
152     fPadRow = 0;
153   }
154
155   if (fPadCol) {
156     delete [] fPadCol;
157     fPadCol = 0;
158   }
159
160 }
161
162 //_____________________________________________________________________________
163 AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
164 {
165   //
166   // Assignment operator
167   //
168
169   if (this != &p) {
170     ((AliTRDpadPlane &) p).Copy(*this);
171   }
172
173   return *this;
174
175 }
176
177 //_____________________________________________________________________________
178 void AliTRDpadPlane::Copy(TObject &p) const
179 {
180   //
181   // Copy function
182   //
183
184   Int_t iBin = 0;
185
186   ((AliTRDpadPlane &) p).fPla            = fPla;
187   ((AliTRDpadPlane &) p).fCha            = fCha;
188
189   ((AliTRDpadPlane &) p).fLength         = fLength;
190   ((AliTRDpadPlane &) p).fWidth          = fWidth;
191   ((AliTRDpadPlane &) p).fLengthRim      = fLengthRim;
192   ((AliTRDpadPlane &) p).fWidthRim       = fWidthRim;
193   ((AliTRDpadPlane &) p).fLengthOPad     = fLengthOPad;
194   ((AliTRDpadPlane &) p).fWidthOPad      = fWidthOPad;
195   ((AliTRDpadPlane &) p).fLengthIPad     = fLengthIPad;
196   ((AliTRDpadPlane &) p).fWidthIPad      = fWidthIPad;
197
198   ((AliTRDpadPlane &) p).fRowSpacing     = fRowSpacing;
199   ((AliTRDpadPlane &) p).fColSpacing     = fColSpacing;
200
201   ((AliTRDpadPlane &) p).fNrows          = fNrows;
202   ((AliTRDpadPlane &) p).fNcols          = fNcols;
203
204   ((AliTRDpadPlane &) p).fTiltingAngle   = fTiltingAngle;
205   ((AliTRDpadPlane &) p).fTiltingTan     = fTiltingTan;
206
207   ((AliTRDpadPlane &) p).fPadRowSMOffset = fPadRowSMOffset;
208
209   if (((AliTRDpadPlane &) p).fPadRow) {
210     delete [] ((AliTRDpadPlane &) p).fPadRow;
211   }
212   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
213   for (iBin = 0; iBin < fNrows; iBin++) {
214     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
215   }                                                                             
216
217   if (((AliTRDpadPlane &) p).fPadCol) {
218     delete [] ((AliTRDpadPlane &) p).fPadCol;
219   }
220   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
221   for (iBin = 0; iBin < fNrows; iBin++) {
222     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
223   }                                                                             
224
225   TObject::Copy(p);
226
227 }
228
229 //_____________________________________________________________________________
230 void AliTRDpadPlane::SetTiltingAngle(Double_t t)
231 {
232   //
233   // Set the tilting angle of the pads
234   //
235  
236   fTiltingAngle = t; 
237   fTiltingTan   = TMath::Tan(TMath::Pi()/180.0 * fTiltingAngle); 
238
239 }
240
241 //_____________________________________________________________________________
242 Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
243 {
244   //
245   // Finds the pad row number for a given z-position in local supermodule system
246   //
247
248   Int_t row    = 0;
249   Int_t nabove = 0;
250   Int_t nbelow = 0;
251   Int_t middle = 0;
252
253   if ((z > GetRow0()  ) || 
254       (z < GetRowEnd())) {
255
256     row = -1;
257
258   }
259   else {
260
261     nabove = fNrows + 1;
262     nbelow = 0;
263     while (nabove - nbelow > 1) {
264       middle = (nabove + nbelow) / 2;
265       if (z == (fPadRow[middle-1] + fPadRowSMOffset)) {
266         row    = middle;
267       }
268       if (z  > (fPadRow[middle-1] + fPadRowSMOffset)) {
269         nabove = middle;
270       }
271       else {
272         nbelow = middle;
273       }
274     }
275     row = nbelow - 1;
276
277   }
278
279   return row;
280
281 }
282
283 //_____________________________________________________________________________
284 Int_t AliTRDpadPlane::GetPadRowNumberROC(Double_t z) const
285 {
286   //
287   // Finds the pad row number for a given z-position in local ROC system
288   //
289
290   Int_t row    = 0;
291   Int_t nabove = 0;
292   Int_t nbelow = 0;
293   Int_t middle = 0;
294
295   if ((z > GetRow0ROC()  ) || 
296       (z < GetRowEndROC())) {
297
298     row = -1;
299
300   }
301   else {
302
303     nabove = fNrows + 1;
304     nbelow = 0;
305     while (nabove - nbelow > 1) {
306       middle = (nabove + nbelow) / 2;
307       if (z == fPadRow[middle-1]) {
308         row    = middle;
309       }
310       if (z  > fPadRow[middle-1]) {
311         nabove = middle;
312       }
313       else {
314         nbelow = middle;
315       }
316     }
317     row = nbelow - 1;
318
319   }
320
321   return row;
322
323 }
324
325 //_____________________________________________________________________________
326 Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const
327 {
328   //
329   // Finds the pad column number for a given global rphi-position
330   //
331
332   Int_t col    = 0;
333   Int_t nabove = 0;
334   Int_t nbelow = 0;
335   Int_t middle = 0;
336
337   if ((rphi > GetCol0()  ) || 
338       (rphi < GetColEnd())) {
339
340     col = -1;
341
342   }
343   else {
344
345     nabove = fNcols + 1;
346     nbelow = 0;
347     while (nabove - nbelow > 1) {
348       middle = (nabove + nbelow) / 2;
349       if (rphi == fPadCol[middle-1]) {
350         col    = middle;
351       }
352       if (rphi  > fPadCol[middle-1]) {
353         nabove = middle;
354       }
355       else {
356         nbelow = middle;
357       }
358     }
359     col = nbelow - 1;
360
361   }
362
363   return col;
364
365 }