]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDpadPlane.cxx
Inserting TMath.h where required by the new version of ROOT
[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()
41 ,fGeo(0)
42 ,fPla(0)
43 ,fCha(0)
44 ,fLength(0)
45 ,fWidth(0)
46 ,fLengthRim(0)
47 ,fWidthRim(0)
48 ,fLengthOPad(0)
49 ,fWidthOPad(0)
50 ,fLengthIPad(0)
51 ,fWidthIPad(0)
52 ,fRowSpacing(0)
53 ,fColSpacing(0)
54 ,fNrows(0)
55 ,fNcols(0)
56 ,fTiltingAngle(0)
57 ,fTiltingTan(0)
58 ,fPadRow(0)
59 ,fPadCol(0)
e0d47c25 60{
61 //
62 // Default constructor
63 //
64
e0d47c25 65}
66
67//_____________________________________________________________________________
2745a409 68AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c)
69 :TObject()
70 ,fGeo(0)
71 ,fPla(0)
72 ,fCha(0)
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)
e0d47c25 89{
90 //
91 // Constructor that initializes a given pad plane type
92 //
93
bd0f8685 94 fGeo = new AliTRDgeometry();
e0d47c25 95
96 fPla = p;
97 fCha = c;
98
e0d47c25 99 fRowSpacing = 0.0;
100 fColSpacing = 0.0;
101
102 fLengthRim = 1.0;
103 fWidthRim = 0.5;
104
105 fNcols = 144;
106
107 //
108 // The pad plane parameter
109 //
110 switch (p) {
111 case 0:
112 if (c == 2) {
113 // L0C0 type
114 fNrows = 12;
115 fLength = 108.0;
287c5d50 116 fWidth = 92.2;
e0d47c25 117 fLengthOPad = 8.0;
118 fWidthOPad = 0.515;
119 fLengthIPad = 9.0;
120 fWidthIPad = 0.635;
121 fTiltingAngle = -2.0;
122 }
123 else {
124 // L0C1 type
125 fNrows = 16;
126 fLength = 122.0;
287c5d50 127 fWidth = 92.2;
e0d47c25 128 fLengthOPad = 7.5;
129 fWidthOPad = 0.515;
130 fLengthIPad = 7.5;
131 fWidthIPad = 0.635;
132 fTiltingAngle = -2.0;
133 }
134 break;
135 case 1:
136 if (c == 2) {
137 // L1C0 type
138 fNrows = 12;
139 fLength = 108.0;
140 fWidth = 96.6;
141 fLengthOPad = 8.0;
142 fWidthOPad = 0.585;
143 fLengthIPad = 9.0;
144 fWidthIPad = 0.665;
145 fTiltingAngle = 2.0;
146 }
147 else {
148 // L1C1 type
149 fNrows = 16;
150 fLength = 122.0;
151 fWidth = 96.6;
152 fLengthOPad = 7.5;
153 fWidthOPad = 0.585;
154 fLengthIPad = 7.5;
155 fWidthIPad = 0.665;
156 fTiltingAngle = 2.0;
157 }
158 break;
159 case 2:
160 if (c == 2) {
161 // L2C0 type
162 fNrows = 12;
163 fLength = 108.0;
164 fWidth = 101.1;
165 fLengthOPad = 8.0;
166 fWidthOPad = 0.705;
167 fLengthIPad = 9.0;
168 fWidthIPad = 0.695;
169 fTiltingAngle = -2.0;
170 }
171 else {
172 // L2C1 type
173 fNrows = 16;
174 fLength = 129.0;
175 fWidth = 101.1;
176 fLengthOPad = 7.5;
177 fWidthOPad = 0.705;
178 fLengthIPad = 8.0;
179 fWidthIPad = 0.695;
180 fTiltingAngle = -2.0;
181 }
182 break;
183 case 3:
184 if (c == 2) {
185 // L3C0 type
186 fNrows = 12;
187 fLength = 108.0;
188 fWidth = 105.5;
189 fLengthOPad = 8.0;
190 fWidthOPad = 0.775;
191 fLengthIPad = 9.0;
192 fWidthIPad = 0.725;
193 fTiltingAngle = 2.0;
194 }
195 else {
196 // L3C1 type
197 fNrows = 16;
198 fLength = 136.0;
199 fWidth = 105.5;
200 fLengthOPad = 7.5;
201 fWidthOPad = 0.775;
202 fLengthIPad = 8.5;
203 fWidthIPad = 0.725;
204 fTiltingAngle = 2.0;
205 }
206 break;
207 case 4:
208 if (c == 2) {
209 // L4C0 type
210 fNrows = 12;
211 fLength = 108.0;
212 fWidth = 109.9;
213 fLengthOPad = 8.0;
214 fWidthOPad = 0.845;
215 fLengthIPad = 9.0;
216 fWidthIPad = 0.755;
217 fTiltingAngle = -2.0;
218 }
219 else {
220 // L4C1 type
221 fNrows = 16;
222 fLength = 143.0;
223 fWidth = 109.9;
224 fLengthOPad = 7.5;
225 fWidthOPad = 0.845;
226 fLengthIPad = 9.0;
227 fWidthIPad = 0.755;
228 fTiltingAngle = -2.0;
229 }
230 break;
231 case 5:
232 if (c == 2) {
233 // L5C0 type
234 fNrows = 12;
235 fLength = 108.0;
236 fWidth = 114.4;
237 fLengthOPad = 8.0;
238 fWidthOPad = 0.965;
239 fLengthIPad = 9.0;
240 fWidthIPad = 0.785;
241 fTiltingAngle = 2.0;
242 }
243 else {
244 // L5C1 type
245 fNrows = 16;
246 fLength = 145.0;
247 fWidth = 114.4;
248 fLengthOPad = 8.5;
249 fWidthOPad = 0.965;
250 fLengthIPad = 9.0;
251 fWidthIPad = 0.785;
252 fTiltingAngle = 2.0;
253 }
254 break;
255 };
256
a5cadd36 257 //
2f4fac20 258 // Store tilting angle as tangens
a5cadd36 259 //
2f4fac20 260 fTiltingTan = TMath::Tan(TMath::Pi()/180.0 * fTiltingAngle);
a5cadd36 261
e0d47c25 262 //
263 // The positions of the borders of the pads
264 //
265 // Row direction
266 //
e0d47c25 267 fPadRow = new Double_t[fNrows];
268 Double_t row = fGeo->GetChamberLength(p,0)
269 + fGeo->GetChamberLength(p,1)
f881dc35 270 + fGeo->GetChamberLength(p,2) / 2.0
a5cadd36 271 - fGeo->RpadW()
e0d47c25 272 - fLengthRim;
273 for (Int_t ic = 0; ic < c; ic++) {
274 row -= fGeo->GetChamberLength(p,ic);
275 }
276 for (Int_t ir = 0; ir < fNrows; ir++) {
277 fPadRow[ir] = row;
278 row -= fRowSpacing;
a5cadd36 279 if (ir == 0) {
e0d47c25 280 row -= fLengthOPad;
281 }
282 else {
283 row -= fLengthIPad;
284 }
285 }
286 //
287 // Column direction
288 //
e0d47c25 289 fPadCol = new Double_t[fNcols];
f881dc35 290 Double_t col = fGeo->GetChamberWidth(p) / 2.0
287c5d50 291 + fGeo->CroWid()
e0d47c25 292 - fWidthRim;
293 for (Int_t ic = 0; ic < fNcols; ic++) {
294 fPadCol[ic] = col;
295 col -= fColSpacing;
a5cadd36 296 if (ic == 0) {
e0d47c25 297 col -= fWidthOPad;
298 }
299 else {
300 col -= fWidthIPad;
301 }
302 }
303
304}
305
306//_____________________________________________________________________________
2745a409 307AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p)
308 :TObject(p)
309 ,fGeo(0)
310 ,fPla(p.fPla)
311 ,fCha(p.fCha)
312 ,fLength(p.fLength)
313 ,fWidth(p.fWidth)
314 ,fLengthRim(p.fLengthRim)
315 ,fWidthRim(p.fLengthRim)
316 ,fLengthOPad(p.fLengthOPad)
317 ,fWidthOPad(p.fWidthOPad)
318 ,fLengthIPad(p.fLengthIPad)
319 ,fWidthIPad(p.fWidthIPad)
320 ,fRowSpacing(p.fRowSpacing)
321 ,fColSpacing(p.fColSpacing)
322 ,fNrows(p.fNrows)
323 ,fNcols(p.fNcols)
324 ,fTiltingAngle(p.fTiltingAngle)
325 ,fTiltingTan(p.fTiltingTan)
326 ,fPadRow(0)
327 ,fPadCol(0)
e0d47c25 328{
329 //
330 // AliTRDpadPlane copy constructor
331 //
332
2745a409 333 Int_t iBin = 0;
334
f881dc35 335 if (((AliTRDpadPlane &) p).fPadRow) {
336 delete [] ((AliTRDpadPlane &) p).fPadRow;
337 }
2745a409 338 ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
339 for (iBin = 0; iBin < fNrows; iBin++) {
340 ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
341 }
342
f881dc35 343 if (((AliTRDpadPlane &) p).fPadCol) {
344 delete [] ((AliTRDpadPlane &) p).fPadCol;
345 }
2745a409 346 ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
347 for (iBin = 0; iBin < fNrows; iBin++) {
348 ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
349 }
e0d47c25 350
351}
352
353//_____________________________________________________________________________
354AliTRDpadPlane::~AliTRDpadPlane()
355{
356 //
357 // AliTRDpadPlane destructor
358 //
359
360 if (fGeo) {
361 delete fGeo;
362 fGeo = 0;
363 }
364
365 if (fPadRow) {
366 delete [] fPadRow;
367 fPadRow = 0;
368 }
369
370 if (fPadCol) {
371 delete [] fPadCol;
372 fPadCol = 0;
373 }
374
375}
376
3c537e64 377//_____________________________________________________________________________
378AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
379{
380 //
381 // Assignment operator
382 //
383
f881dc35 384 if (this != &p) {
385 ((AliTRDpadPlane &) p).Copy(*this);
386 }
387
3c537e64 388 return *this;
389
390}
391
e0d47c25 392//_____________________________________________________________________________
393void AliTRDpadPlane::Copy(TObject &p) const
394{
395 //
396 // Copy function
397 //
398
399 Int_t iBin = 0;
400
401 ((AliTRDpadPlane &) p).fGeo = 0;
402
403 ((AliTRDpadPlane &) p).fPla = fPla;
404 ((AliTRDpadPlane &) p).fCha = fCha;
405
406 ((AliTRDpadPlane &) p).fLength = fLength;
407 ((AliTRDpadPlane &) p).fWidth = fWidth;
408 ((AliTRDpadPlane &) p).fLengthRim = fLengthRim;
409 ((AliTRDpadPlane &) p).fWidthRim = fWidthRim;
410 ((AliTRDpadPlane &) p).fLengthOPad = fLengthOPad;
411 ((AliTRDpadPlane &) p).fWidthOPad = fWidthOPad;
412 ((AliTRDpadPlane &) p).fLengthIPad = fLengthIPad;
413 ((AliTRDpadPlane &) p).fWidthIPad = fWidthIPad;
414
415 ((AliTRDpadPlane &) p).fRowSpacing = fRowSpacing;
416 ((AliTRDpadPlane &) p).fColSpacing = fColSpacing;
417
418 ((AliTRDpadPlane &) p).fNrows = fNrows;
419 ((AliTRDpadPlane &) p).fNcols = fNcols;
420
421 ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle;
4ffb371b 422 ((AliTRDpadPlane &) p).fTiltingTan = fTiltingTan;
e0d47c25 423
f881dc35 424 if (((AliTRDpadPlane &) p).fPadRow) {
425 delete [] ((AliTRDpadPlane &) p).fPadRow;
426 }
e0d47c25 427 ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
428 for (iBin = 0; iBin < fNrows; iBin++) {
429 ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
430 }
431
f881dc35 432 if (((AliTRDpadPlane &) p).fPadCol) {
433 delete [] ((AliTRDpadPlane &) p).fPadCol;
434 }
e0d47c25 435 ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
436 for (iBin = 0; iBin < fNrows; iBin++) {
437 ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
438 }
439
440 TObject::Copy(p);
441
442}
443
444//_____________________________________________________________________________
98ce8151 445Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
e0d47c25 446{
447 //
448 // Finds the pad row number for a given global z-position
449 //
450
451 Int_t row = 0;
452 Int_t nabove = 0;
453 Int_t nbelow = 0;
454 Int_t middle = 0;
455
f881dc35 456 if ((z > GetRow0() ) ||
457 (z < GetRowEnd())) {
a5cadd36 458
e0d47c25 459 row = -1;
a5cadd36 460
e0d47c25 461 }
462 else {
a5cadd36 463
f881dc35 464 nabove = fNrows + 1;
e0d47c25 465 nbelow = 0;
466 while (nabove - nbelow > 1) {
467 middle = (nabove + nbelow) / 2;
f881dc35 468 if (z == fPadRow[middle-1]) {
469 row = middle;
470 }
471 if (z > fPadRow[middle-1]) {
472 nabove = middle;
473 }
474 else {
475 nbelow = middle;
476 }
e0d47c25 477 }
478 row = nbelow - 1;
a5cadd36 479
e0d47c25 480 }
481
482 return row;
483
484}
485
486//_____________________________________________________________________________
98ce8151 487Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi
f881dc35 488 , Double_t /*rowOffset*/) const
e0d47c25 489{
490 //
491 // Finds the pad column number for a given global rphi-position
492 //
493
f881dc35 494 Int_t col = 0;
495 Int_t nabove = 0;
496 Int_t nbelow = 0;
497 Int_t middle = 0;
2f4fac20 498
f881dc35 499 if ((rphi > GetCol0() ) ||
500 (rphi < GetColEnd())) {
e0d47c25 501
e0d47c25 502 col = -1;
a5cadd36 503
e0d47c25 504 }
505 else {
a5cadd36 506
f881dc35 507 nabove = fNcols + 1;
e0d47c25 508 nbelow = 0;
509 while (nabove - nbelow > 1) {
510 middle = (nabove + nbelow) / 2;
f881dc35 511 if (rphi == fPadCol[middle-1]) {
512 col = middle;
513 }
514 if (rphi > fPadCol[middle-1]) {
515 nabove = middle;
516 }
517 else {
518 nbelow = middle;
519 }
e0d47c25 520 }
521 col = nbelow - 1;
e0d47c25 522
e0d47c25 523 }
e0d47c25 524
a5cadd36 525 return col;
e0d47c25 526
527}