]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDpadPlane.cxx
Add new FEE parameter class by Ken
[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 Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
231 {
232   //
233   // Finds the pad row number for a given z-position in local supermodule system
234   //
235
236   Int_t row    = 0;
237   Int_t nabove = 0;
238   Int_t nbelow = 0;
239   Int_t middle = 0;
240
241   if ((z > GetRow0()  ) || 
242       (z < GetRowEnd())) {
243
244     row = -1;
245
246   }
247   else {
248
249     nabove = fNrows + 1;
250     nbelow = 0;
251     while (nabove - nbelow > 1) {
252       middle = (nabove + nbelow) / 2;
253       if (z == (fPadRow[middle-1] + fPadRowSMOffset)) {
254         row    = middle;
255       }
256       if (z  > (fPadRow[middle-1] + fPadRowSMOffset)) {
257         nabove = middle;
258       }
259       else {
260         nbelow = middle;
261       }
262     }
263     row = nbelow - 1;
264
265   }
266
267   return row;
268
269 }
270
271 //_____________________________________________________________________________
272 Int_t AliTRDpadPlane::GetPadRowNumberROC(Double_t z) const
273 {
274   //
275   // Finds the pad row number for a given z-position in local ROC system
276   //
277
278   Int_t row    = 0;
279   Int_t nabove = 0;
280   Int_t nbelow = 0;
281   Int_t middle = 0;
282
283   if ((z > GetRow0ROC()  ) || 
284       (z < GetRowEndROC())) {
285
286     row = -1;
287
288   }
289   else {
290
291     nabove = fNrows + 1;
292     nbelow = 0;
293     while (nabove - nbelow > 1) {
294       middle = (nabove + nbelow) / 2;
295       if (z == fPadRow[middle-1]) {
296         row    = middle;
297       }
298       if (z  > fPadRow[middle-1]) {
299         nabove = middle;
300       }
301       else {
302         nbelow = middle;
303       }
304     }
305     row = nbelow - 1;
306
307   }
308
309   return row;
310
311 }
312
313 //_____________________________________________________________________________
314 Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const
315 {
316   //
317   // Finds the pad column number for a given global rphi-position
318   //
319
320   Int_t col    = 0;
321   Int_t nabove = 0;
322   Int_t nbelow = 0;
323   Int_t middle = 0;
324
325   if ((rphi > GetCol0()  ) || 
326       (rphi < GetColEnd())) {
327
328     col = -1;
329
330   }
331   else {
332
333     nabove = fNcols + 1;
334     nbelow = 0;
335     while (nabove - nbelow > 1) {
336       middle = (nabove + nbelow) / 2;
337       if (rphi == fPadCol[middle-1]) {
338         col    = middle;
339       }
340       if (rphi  > fPadCol[middle-1]) {
341         nabove = middle;
342       }
343       else {
344         nbelow = middle;
345       }
346     }
347     col = nbelow - 1;
348
349   }
350
351   return col;
352
353 }