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