fAlarms is not deleted by AliPHOSQAVirtualChekable
[u/mrichter/AliRoot.git] / TRD / AliTRDgeometry.cxx
CommitLineData
f7336fa3 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/*
17$Log$
cbba4394 18Revision 1.16 2002/03/28 14:59:07 cblume
19Coding conventions
20
0a29d0f1 21Revision 1.15 2002/02/11 14:21:16 cblume
22Update of the geometry. Get rid of MANY
23
0a770ac9 24Revision 1.14 2001/11/06 17:19:41 cblume
25Add detailed geometry and simple simulator
26
16bf9884 27Revision 1.13 2001/08/02 08:30:45 cblume
28Fix positions of cooling material
29
52052b58 30Revision 1.12 2001/05/21 16:45:47 hristov
31Last minute changes (C.Blume)
32
db30bf0f 33Revision 1.11 2001/05/11 07:56:12 hristov
34Consistent declarations needed on Alpha
35
ff821236 36Revision 1.10 2001/05/07 08:08:05 cblume
37Update of TRD code
38
a2b90f83 39Revision 1.9 2001/03/27 12:48:33 cblume
40Correct for volume overlaps
41
b42a9f88 42Revision 1.8 2001/03/13 09:30:35 cblume
43Update of digitization. Moved digit branch definition to AliTRD
44
6244debe 45Revision 1.7 2001/02/14 18:22:26 cblume
46Change in the geometry of the padplane
47
71d9fa7b 48Revision 1.6 2000/11/01 14:53:20 cblume
49Merge with TRD-develop
50
793ff80c 51Revision 1.1.4.7 2000/10/16 01:16:53 cblume
52Changed timebin 0 to be the one closest to the readout
53
54Revision 1.1.4.6 2000/10/15 23:35:57 cblume
55Include geometry constants as static member
56
57Revision 1.1.4.5 2000/10/06 16:49:46 cblume
58Made Getters const
59
60Revision 1.1.4.4 2000/10/04 16:34:58 cblume
61Replace include files by forward declarations
62
63Revision 1.1.4.3 2000/09/22 14:43:40 cblume
64Allow the pad/timebin-dimensions to be changed after initialization
65
66Revision 1.1.4.2 2000/09/18 13:37:01 cblume
67Minor coding corrections
68
69Revision 1.5 2000/10/02 21:28:19 fca
70Removal of useless dependecies via forward declarations
71
72Revision 1.4 2000/06/08 18:32:58 cblume
73Make code compliant to coding conventions
74
75Revision 1.3 2000/06/07 16:25:37 cblume
76Try to remove compiler warnings on Sun and HP
77
78Revision 1.2 2000/05/08 16:17:27 cblume
79Merge TRD-develop
80
81Revision 1.1.4.1 2000/05/08 14:45:55 cblume
82Bug fix in RotateBack(). Geometry update
83
94de3818 84Revision 1.4 2000/06/08 18:32:58 cblume
85Make code compliant to coding conventions
86
8230f242 87Revision 1.3 2000/06/07 16:25:37 cblume
88Try to remove compiler warnings on Sun and HP
89
9d0b222b 90Revision 1.2 2000/05/08 16:17:27 cblume
91Merge TRD-develop
92
6f1e466d 93Revision 1.1.4.1 2000/05/08 14:45:55 cblume
94Bug fix in RotateBack(). Geometry update
95
96Revision 1.1 2000/02/28 19:00:44 cblume
97Add new TRD classes
98
f7336fa3 99*/
100
101///////////////////////////////////////////////////////////////////////////////
102// //
103// TRD geometry class //
104// //
105///////////////////////////////////////////////////////////////////////////////
106
793ff80c 107#include "AliMC.h"
108
f7336fa3 109#include "AliTRDgeometry.h"
110#include "AliTRDrecPoint.h"
94de3818 111#include "AliMC.h"
f7336fa3 112
113ClassImp(AliTRDgeometry)
114
793ff80c 115//_____________________________________________________________________________
116
117 //
118 // The geometry constants
119 //
120 const Int_t AliTRDgeometry::fgkNsect = kNsect;
121 const Int_t AliTRDgeometry::fgkNplan = kNplan;
122 const Int_t AliTRDgeometry::fgkNcham = kNcham;
123 const Int_t AliTRDgeometry::fgkNdet = kNdet;
124
125 //
126 // Dimensions of the detector
127 //
0a770ac9 128
129 // Inner and outer radius of the mother volumes
793ff80c 130 const Float_t AliTRDgeometry::fgkRmin = 294.0;
131 const Float_t AliTRDgeometry::fgkRmax = 368.0;
132
0a770ac9 133 // Upper and lower length of the mother volumes
793ff80c 134 const Float_t AliTRDgeometry::fgkZmax1 = 378.35;
135 const Float_t AliTRDgeometry::fgkZmax2 = 302.0;
136
0a770ac9 137 // Parameter of the BTR mother volumes
793ff80c 138 const Float_t AliTRDgeometry::fgkSheight = 74.0;
139 const Float_t AliTRDgeometry::fgkSwidth1 = 99.613;
140 const Float_t AliTRDgeometry::fgkSwidth2 = 125.707;
141 const Float_t AliTRDgeometry::fgkSlenTR1 = 751.0;
142 const Float_t AliTRDgeometry::fgkSlenTR2 = 313.5;
143 const Float_t AliTRDgeometry::fgkSlenTR3 = 159.5;
144
0a770ac9 145 // Height of different chamber parts
146 // Radiator
147 const Float_t AliTRDgeometry::fgkCraH = 4.8;
148 // Drift region
149 const Float_t AliTRDgeometry::fgkCdrH = 3.0;
150 // Amplification region
151 const Float_t AliTRDgeometry::fgkCamH = 0.7;
152 // Readout
153 const Float_t AliTRDgeometry::fgkCroH = 2.0;
154 // Total height
155 const Float_t AliTRDgeometry::fgkCH = AliTRDgeometry::fgkCraH
156 + AliTRDgeometry::fgkCdrH
157 + AliTRDgeometry::fgkCamH
158 + AliTRDgeometry::fgkCroH;
159
160 // Vertical spacing of the chambers
161 const Float_t AliTRDgeometry::fgkVspace = 2.1;
162
163 // Horizontal spacing of the chambers
164 const Float_t AliTRDgeometry::fgkHspace = 2.0;
165
166 // Thicknesses of different parts of the chamber frame
167 // Lower aluminum frame
168 const Float_t AliTRDgeometry::fgkCalT = 0.3;
169 // Lower G10 frame sides
170 const Float_t AliTRDgeometry::fgkCclsT = 0.3;
171 // Lower G10 frame front
172 const Float_t AliTRDgeometry::fgkCclfT = 1.0;
173 // Upper G10 frame
174 const Float_t AliTRDgeometry::fgkCcuT = 0.9;
175 // Upper Al frame
176 const Float_t AliTRDgeometry::fgkCauT = 1.5;
177
178 // Additional width of the readout chamber frames
179 const Float_t AliTRDgeometry::fgkCroW = 0.9;
180
181 // Difference of outer chamber width and pad plane width
182 const Float_t AliTRDgeometry::fgkCpadW = 1.0;
183 const Float_t AliTRDgeometry::fgkRpadW = 1.5;
793ff80c 184
185 //
186 // Thickness of the the material layers
187 //
db30bf0f 188 const Float_t AliTRDgeometry::fgkRaThick = 0.3646;
793ff80c 189 const Float_t AliTRDgeometry::fgkMyThick = 0.005;
0a770ac9 190 const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH;
191 const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH;
192 const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick
193 + AliTRDgeometry::fgkAmThick;
793ff80c 194 const Float_t AliTRDgeometry::fgkCuThick = 0.001;
195 const Float_t AliTRDgeometry::fgkSuThick = 0.06;
196 const Float_t AliTRDgeometry::fgkFeThick = 0.0044;
197 const Float_t AliTRDgeometry::fgkCoThick = 0.02;
db30bf0f 198 const Float_t AliTRDgeometry::fgkWaThick = 0.02;
793ff80c 199
200 //
201 // Position of the material layers
202 //
0a770ac9 203 const Float_t AliTRDgeometry::fgkRaZpos = -1.50;
204 const Float_t AliTRDgeometry::fgkMyZpos = 0.895;
205 const Float_t AliTRDgeometry::fgkDrZpos = 2.4;
206 const Float_t AliTRDgeometry::fgkAmZpos = 0.0;
207 const Float_t AliTRDgeometry::fgkCuZpos = -0.9995;
793ff80c 208 const Float_t AliTRDgeometry::fgkSuZpos = 0.0000;
0a770ac9 209 const Float_t AliTRDgeometry::fgkFeZpos = 0.0322;
210 const Float_t AliTRDgeometry::fgkCoZpos = 0.97;
211 const Float_t AliTRDgeometry::fgkWaZpos = 0.99;
793ff80c 212
f7336fa3 213//_____________________________________________________________________________
214AliTRDgeometry::AliTRDgeometry():AliGeometry()
215{
216 //
217 // AliTRDgeometry default constructor
218 //
219
220 Init();
221
222}
223
224//_____________________________________________________________________________
225AliTRDgeometry::~AliTRDgeometry()
226{
8230f242 227 //
228 // AliTRDgeometry destructor
229 //
f7336fa3 230
231}
232
233//_____________________________________________________________________________
234void AliTRDgeometry::Init()
235{
236 //
237 // Initializes the geometry parameter
238 //
f7336fa3 239 // The maximum number of pads
240 // and the position of pad 0,0,0
241 //
242 // chambers seen from the top:
243 // +----------------------------+
244 // | |
793ff80c 245 // | | ^
246 // | | rphi|
247 // | | |
248 // |0 | |
249 // +----------------------------+ +------>
f7336fa3 250 // z
793ff80c 251 // chambers seen from the side: ^
252 // +----------------------------+ drift|
253 // |0 | |
254 // | | |
255 // +----------------------------+ +------>
f7336fa3 256 // z
257 //
a2b90f83 258 // IMPORTANT: time bin 0 is now the first one in the drift region
259 // closest to the readout !!!
793ff80c 260 //
f7336fa3 261
0a770ac9 262 Int_t icham;
263 Int_t iplan;
264 Int_t isect;
265
266 // The outer width of the chambers
267 fCwidth[0] = 95.6;
268 fCwidth[1] = 100.1;
269 fCwidth[2] = 104.5;
270 fCwidth[3] = 108.9;
271 fCwidth[4] = 113.4;
272 fCwidth[5] = 117.8;
273
274 // The outer lengths of the chambers
275 Float_t length[kNplan][kNcham] = { { 123.5, 123.5, 110.0, 123.5, 123.5 }
276 , { 131.0, 131.0, 110.0, 131.0, 131.0 }
277 , { 134.5, 138.5, 110.0, 138.5, 134.5 }
278 , { 142.0, 146.0, 110.0, 146.0, 142.0 }
279 , { 142.0, 153.0, 110.0, 153.0, 142.0 }
280 , { 134.0, 160.5, 110.0, 160.5, 134.0 } };
281
282 for (icham = 0; icham < kNcham; icham++) {
283 for (iplan = 0; iplan < kNplan; iplan++) {
284 fClength[iplan][icham] = length[iplan][icham];
285 fClengthPH[iplan][icham] = 0.0;
286 fClengthRH[iplan][icham] = 0.0;
287 }
288 }
289
290 // The pad size in column direction (rphi-direction)
291 SetColPadSize(0,0.65);
292 SetColPadSize(1,0.68);
293 SetColPadSize(2,0.71);
294 SetColPadSize(3,0.74);
295 SetColPadSize(4,0.77);
296 SetColPadSize(5,0.80);
297
298 // The pad row (z-direction)
299 SetNRowPad();
793ff80c 300
a2b90f83 301 // The number of time bins. Default is 100 ns timbin size
6244debe 302 SetNTimeBin(15);
793ff80c 303
a2b90f83 304 // Additional time bins before and after the drift region.
305 // Default is to only sample the drift region
306 SetExpandTimeBin(0,0);
307
793ff80c 308 // The rotation matrix elements
309 Float_t phi = 0;
310 for (isect = 0; isect < fgkNsect; isect++) {
311 phi = -2.0 * kPI / (Float_t) fgkNsect * ((Float_t) isect + 0.5);
312 fRotA11[isect] = TMath::Cos(phi);
313 fRotA12[isect] = TMath::Sin(phi);
314 fRotA21[isect] = TMath::Sin(phi);
315 fRotA22[isect] = TMath::Cos(phi);
316 phi = -1.0 * phi;
317 fRotB11[isect] = TMath::Cos(phi);
318 fRotB12[isect] = TMath::Sin(phi);
319 fRotB21[isect] = TMath::Sin(phi);
320 fRotB22[isect] = TMath::Cos(phi);
321 }
322
323}
324
325//_____________________________________________________________________________
0a770ac9 326void AliTRDgeometry::SetNRowPad(const Int_t p, const Int_t c, const Int_t npad)
793ff80c 327{
328 //
0a770ac9 329 // Redefines the number of pads in raw direction for
330 // a given plane and chamber number
793ff80c 331 //
332
0a770ac9 333 for (Int_t isect = 0; isect < fgkNsect; isect++) {
334
335 fRowMax[p][c][isect] = npad;
336
337 fRowPadSize[p][c][isect] = (fClength[p][c] - 2.*fgkRpadW)
338 / ((Float_t) npad);
339
340 }
341
342}
343
344//_____________________________________________________________________________
345void AliTRDgeometry::SetNRowPad()
346{
347 //
348 // Defines the number of pads in row direction
349 //
350
351 Int_t isect;
352 Int_t icham;
353 Int_t iplan;
354
355 Int_t rowMax[kNplan][kNcham] = { { 16, 16, 12, 16, 16 }
356 , { 16, 16, 12, 16, 16 }
357 , { 16, 16, 12, 16, 16 }
358 , { 16, 16, 12, 16, 16 }
359 , { 14, 16, 12, 16, 14 }
360 , { 13, 16, 12, 16, 13 } };
361
362 for (isect = 0; isect < kNsect; isect++) {
363 for (icham = 0; icham < kNcham; icham++) {
364 for (iplan = 0; iplan < kNplan; iplan++) {
365
366 fRowMax[iplan][icham][isect] = rowMax[iplan][icham];
367
368 fRowPadSize[iplan][icham][isect] = (fClength[iplan][icham] - 2.*fgkRpadW)
369 / ((Float_t) rowMax[iplan][icham]);
370
371 Float_t row0 = fgkRpadW - fClength[iplan][0]
372 - fClength[iplan][1]
373 - fClength[iplan][2]/2.;
374 for (Int_t ic = 0; ic < icham; ic++) {
375 row0 += fClength[iplan][ic];
376 }
377 fRow0[iplan][icham][isect] = row0;
378
379 }
380 }
f7336fa3 381 }
382
793ff80c 383}
384
0a770ac9 385//_____________________________________________________________________________
386void AliTRDgeometry::SetColPadSize(const Int_t p, const Float_t s)
387{
388 //
389 // Redefines the pad size in column direction
390 //
391
392 fColPadSize[p] = s;
393 fCol0[p] = - fCwidth[p]/2. + fgkCpadW;
394 fColMax[p] = ((Int_t) ((fCwidth[p] - 2. * fgkCpadW) / s));
395
396}
397
793ff80c 398//_____________________________________________________________________________
a2b90f83 399void AliTRDgeometry::SetNTimeBin(const Int_t nbin)
793ff80c 400{
401 //
a2b90f83 402 // Redefines the number of time bins in the drift region.
403 // The time bin width is defined by the length of the
404 // drift region divided by <nbin>.
793ff80c 405 //
406
71d9fa7b 407 fTimeMax = nbin;
408 fTimeBinSize = fgkDrThick / ((Float_t) fTimeMax);
793ff80c 409 for (Int_t iplan = 0; iplan < fgkNplan; iplan++) {
0a770ac9 410 fTime0[iplan] = fgkRmin + fgkCraH + fgkCdrH
411 + iplan * (fgkCH + fgkVspace);
793ff80c 412 }
f7336fa3 413
414}
415
416//_____________________________________________________________________________
cbba4394 417void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
f7336fa3 418{
419 //
0a770ac9 420 // Create TRD geometry
421 //
f7336fa3 422
423}
424
425//_____________________________________________________________________________
94de3818 426Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local, Float_t *global) const
f7336fa3 427{
428 //
429 // Converts local pad-coordinates (row,col,time) into
430 // global ALICE reference frame coordinates (x,y,z)
431 //
432
793ff80c 433 Int_t icham = GetChamber(idet); // Chamber info (0-4)
434 Int_t isect = GetSector(idet); // Sector info (0-17)
435 Int_t iplan = GetPlane(idet); // Plane info (0-5)
f7336fa3 436
6f1e466d 437 return Local2Global(iplan,icham,isect,local,global);
f7336fa3 438
439}
440
441//_____________________________________________________________________________
442Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
94de3818 443 , Float_t *local, Float_t *global) const
f7336fa3 444{
445 //
446 // Converts local pad-coordinates (row,col,time) into
447 // global ALICE reference frame coordinates (x,y,z)
448 //
449
793ff80c 450 Int_t idet = GetDetector(iplan,icham,isect); // Detector number
f7336fa3 451
16bf9884 452 Float_t padRow = local[0]+0.5; // Pad Row position
453 Float_t padCol = local[1]+0.5; // Pad Column position
454 Float_t timeSlice = local[2]+0.5; // Time "position"
f7336fa3 455
793ff80c 456 Float_t row0 = GetRow0(iplan,icham,isect);
457 Float_t col0 = GetCol0(iplan);
458 Float_t time0 = GetTime0(iplan);
f7336fa3 459
793ff80c 460 Float_t rot[3];
f7336fa3 461
462 // calculate (x,y,z) position in rotated chamber
a2b90f83 463 rot[0] = time0 - (timeSlice - fTimeBefore) * fTimeBinSize;
464 rot[1] = col0 + padCol * fColPadSize[iplan];
465 rot[2] = row0 + padRow * fRowPadSize[iplan][icham][isect];
f7336fa3 466
467 // Rotate back to original position
468 return RotateBack(idet,rot,global);
469
470}
471
472//_____________________________________________________________________________
793ff80c 473Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot) const
f7336fa3 474{
475 //
476 // Rotates all chambers in the position of sector 0 and transforms
477 // the coordinates in the ALICE restframe <pos> into the
478 // corresponding local frame <rot>.
479 //
480
793ff80c 481 Int_t sector = GetSector(d);
f7336fa3 482
793ff80c 483 rot[0] = pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
484 rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
f7336fa3 485 rot[2] = pos[2];
486
487 return kTRUE;
488
489}
490
491//_____________________________________________________________________________
94de3818 492Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
f7336fa3 493{
494 //
495 // Rotates a chambers from the position of sector 0 into its
496 // original position and transforms the corresponding local frame
497 // coordinates <rot> into the coordinates of the ALICE restframe <pos>.
498 //
499
793ff80c 500 Int_t sector = GetSector(d);
f7336fa3 501
793ff80c 502 pos[0] = rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
503 pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
6f1e466d 504 pos[2] = rot[2];
f7336fa3 505
506 return kTRUE;
507
508}
509
510//_____________________________________________________________________________
0a770ac9 511Int_t AliTRDgeometry::GetDetectorSec(const Int_t p, const Int_t c) const
512{
513 //
514 // Convert plane / chamber into detector number for one single sector
515 //
516
517 return (p + c * fgkNplan);
518
519}
520
521//_____________________________________________________________________________
ff821236 522Int_t AliTRDgeometry::GetDetector(const Int_t p, const Int_t c, const Int_t s) const
f7336fa3 523{
524 //
525 // Convert plane / chamber / sector into detector number
526 //
527
793ff80c 528 return (p + c * fgkNplan + s * fgkNplan * fgkNcham);
f7336fa3 529
530}
531
532//_____________________________________________________________________________
ff821236 533Int_t AliTRDgeometry::GetPlane(const Int_t d) const
f7336fa3 534{
535 //
536 // Reconstruct the plane number from the detector number
537 //
538
793ff80c 539 return ((Int_t) (d % fgkNplan));
f7336fa3 540
541}
542
543//_____________________________________________________________________________
ff821236 544Int_t AliTRDgeometry::GetChamber(const Int_t d) const
f7336fa3 545{
546 //
547 // Reconstruct the chamber number from the detector number
548 //
549
793ff80c 550 return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan);
f7336fa3 551
552}
553
554//_____________________________________________________________________________
ff821236 555Int_t AliTRDgeometry::GetSector(const Int_t d) const
f7336fa3 556{
557 //
558 // Reconstruct the sector number from the detector number
559 //
560
793ff80c 561 return ((Int_t) (d / (fgkNplan * fgkNcham)));
f7336fa3 562
563}
564
565//_____________________________________________________________________________
793ff80c 566void AliTRDgeometry::GetGlobal(const AliRecPoint *p, TVector3 &pos
567 , TMatrix &mat) const
f7336fa3 568{
569 //
570 // Returns the global coordinate and error matrix of a AliTRDrecPoint
571 //
572
573 GetGlobal(p,pos);
9d0b222b 574 mat.Zero();
f7336fa3 575
576}
577
578//_____________________________________________________________________________
94de3818 579void AliTRDgeometry::GetGlobal(const AliRecPoint *p, TVector3 &pos) const
f7336fa3 580{
581 //
582 // Returns the global coordinate and error matrix of a AliTRDrecPoint
583 //
584
585 Int_t detector = ((AliTRDrecPoint *) p)->GetDetector();
586
587 Float_t global[3];
588 Float_t local[3];
6f1e466d 589 local[0] = ((AliTRDrecPoint *) p)->GetLocalRow();
590 local[1] = ((AliTRDrecPoint *) p)->GetLocalCol();
591 local[2] = ((AliTRDrecPoint *) p)->GetLocalTime();
f7336fa3 592
593 if (Local2Global(detector,local,global)) {
594 pos.SetX(global[0]);
595 pos.SetY(global[1]);
596 pos.SetZ(global[2]);
597 }
598 else {
599 pos.SetX(0.0);
600 pos.SetY(0.0);
601 pos.SetZ(0.0);
602 }
603
604}