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