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