Make some calculations optional for HLT
[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()
053767a4 41 ,fLayer(0)
42 ,fStack(0)
2745a409 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)
58897a75 60 ,fAnodeWireOffset(0)
e0d47c25 61{
62 //
63 // Default constructor
64 //
65
e0d47c25 66}
67
68//_____________________________________________________________________________
053767a4 69AliTRDpadPlane::AliTRDpadPlane(Int_t layer, Int_t stack)
5dfd5caf 70 :TObject()
053767a4 71 ,fLayer(layer)
72 ,fStack(stack)
5dfd5caf 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)
58897a75 90 ,fAnodeWireOffset(0)
5dfd5caf 91{
92 //
93 // Constructor
94 //
95
96}
97
98//_____________________________________________________________________________
2745a409 99AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p)
100 :TObject(p)
053767a4 101 ,fLayer(p.fLayer)
102 ,fStack(p.fStack)
2745a409 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)
4329977a 119 ,fPadRowSMOffset(p.fPadRowSMOffset)
58897a75 120 ,fAnodeWireOffset(p.fAnodeWireOffset)
e0d47c25 121{
122 //
123 // AliTRDpadPlane copy constructor
124 //
125
2745a409 126 Int_t iBin = 0;
127
f881dc35 128 if (((AliTRDpadPlane &) p).fPadRow) {
129 delete [] ((AliTRDpadPlane &) p).fPadRow;
130 }
2745a409 131 ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
132 for (iBin = 0; iBin < fNrows; iBin++) {
133 ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
134 }
135
f881dc35 136 if (((AliTRDpadPlane &) p).fPadCol) {
137 delete [] ((AliTRDpadPlane &) p).fPadCol;
138 }
2745a409 139 ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
140 for (iBin = 0; iBin < fNrows; iBin++) {
141 ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
142 }
e0d47c25 143
144}
145
146//_____________________________________________________________________________
147AliTRDpadPlane::~AliTRDpadPlane()
148{
149 //
150 // AliTRDpadPlane destructor
151 //
152
e0d47c25 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//_____________________________________________________________________________
3c537e64 166AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
167{
168 //
169 // Assignment operator
170 //
171
f881dc35 172 if (this != &p) {
173 ((AliTRDpadPlane &) p).Copy(*this);
174 }
175
3c537e64 176 return *this;
177
178}
179
180//_____________________________________________________________________________
e0d47c25 181void AliTRDpadPlane::Copy(TObject &p) const
182{
183 //
184 // Copy function
185 //
186
187 Int_t iBin = 0;
188
58897a75 189 ((AliTRDpadPlane &) p).fLayer = fLayer;
190 ((AliTRDpadPlane &) p).fStack = fStack;
e0d47c25 191
58897a75 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;
e0d47c25 200
58897a75 201 ((AliTRDpadPlane &) p).fRowSpacing = fRowSpacing;
202 ((AliTRDpadPlane &) p).fColSpacing = fColSpacing;
e0d47c25 203
58897a75 204 ((AliTRDpadPlane &) p).fNrows = fNrows;
205 ((AliTRDpadPlane &) p).fNcols = fNcols;
e0d47c25 206
58897a75 207 ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle;
208 ((AliTRDpadPlane &) p).fTiltingTan = fTiltingTan;
e0d47c25 209
58897a75 210 ((AliTRDpadPlane &) p).fPadRowSMOffset = fPadRowSMOffset;
211 ((AliTRDpadPlane &) p).fAnodeWireOffset = fAnodeWireOffset;
e0d47c25 212
f881dc35 213 if (((AliTRDpadPlane &) p).fPadRow) {
214 delete [] ((AliTRDpadPlane &) p).fPadRow;
215 }
e0d47c25 216 ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
217 for (iBin = 0; iBin < fNrows; iBin++) {
218 ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
219 }
220
f881dc35 221 if (((AliTRDpadPlane &) p).fPadCol) {
222 delete [] ((AliTRDpadPlane &) p).fPadCol;
223 }
e0d47c25 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//_____________________________________________________________________________
f18d4f83 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//_____________________________________________________________________________
98ce8151 246Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
e0d47c25 247{
248 //
4329977a 249 // Finds the pad row number for a given z-position in local supermodule system
e0d47c25 250 //
251
252 Int_t row = 0;
253 Int_t nabove = 0;
254 Int_t nbelow = 0;
255 Int_t middle = 0;
256
f881dc35 257 if ((z > GetRow0() ) ||
258 (z < GetRowEnd())) {
a5cadd36 259
e0d47c25 260 row = -1;
a5cadd36 261
e0d47c25 262 }
263 else {
a5cadd36 264
f881dc35 265 nabove = fNrows + 1;
e0d47c25 266 nbelow = 0;
267 while (nabove - nbelow > 1) {
e2db9fdc 268 middle = (nabove + nbelow) / 2;
4329977a 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;
f881dc35 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 }
e0d47c25 320 }
321 row = nbelow - 1;
a5cadd36 322
e0d47c25 323 }
324
325 return row;
326
327}
328
329//_____________________________________________________________________________
4329977a 330Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const
e0d47c25 331{
332 //
023b669c 333 // Finds the pad column number for a given rphi-position
e0d47c25 334 //
335
4329977a 336 Int_t col = 0;
337 Int_t nabove = 0;
338 Int_t nbelow = 0;
339 Int_t middle = 0;
2f4fac20 340
023b669c 341 if ((rphi < GetCol0() ) ||
342 (rphi > GetColEnd())) {
e0d47c25 343
e0d47c25 344 col = -1;
a5cadd36 345
e0d47c25 346 }
347 else {
a5cadd36 348
023b669c 349 nabove = fNcols;
e0d47c25 350 nbelow = 0;
351 while (nabove - nbelow > 1) {
352 middle = (nabove + nbelow) / 2;
023b669c 353 if (rphi == fPadCol[middle]) {
f881dc35 354 col = middle;
355 }
023b669c 356 if (rphi > fPadCol[middle]) {
357 nbelow = middle;
f881dc35 358 }
359 else {
023b669c 360 nabove = middle;
f881dc35 361 }
e0d47c25 362 }
023b669c 363 col = nbelow;
e0d47c25 364
e0d47c25 365 }
e0d47c25 366
a5cadd36 367 return col;
e0d47c25 368
369}