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