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