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