]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDgeometry.cxx
- Return from Gstpar if material is not used.
[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
afc51ac2 16/* $Id$ */
f7336fa3 17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// TRD geometry class //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
793ff80c 24
bdbb05bb 25#include <TError.h>
26
27#include "AliRunLoader.h"
f7336fa3 28#include "AliTRDgeometry.h"
5443e65e 29#include "AliTRDparameter.h"
f7336fa3 30
31ClassImp(AliTRDgeometry)
32
793ff80c 33//_____________________________________________________________________________
34
35 //
36 // The geometry constants
37 //
38 const Int_t AliTRDgeometry::fgkNsect = kNsect;
39 const Int_t AliTRDgeometry::fgkNplan = kNplan;
40 const Int_t AliTRDgeometry::fgkNcham = kNcham;
41 const Int_t AliTRDgeometry::fgkNdet = kNdet;
42
43 //
44 // Dimensions of the detector
45 //
0a770ac9 46
47 // Inner and outer radius of the mother volumes
793ff80c 48 const Float_t AliTRDgeometry::fgkRmin = 294.0;
49 const Float_t AliTRDgeometry::fgkRmax = 368.0;
50
0a770ac9 51 // Upper and lower length of the mother volumes
793ff80c 52 const Float_t AliTRDgeometry::fgkZmax1 = 378.35;
53 const Float_t AliTRDgeometry::fgkZmax2 = 302.0;
54
0a770ac9 55 // Parameter of the BTR mother volumes
793ff80c 56 const Float_t AliTRDgeometry::fgkSheight = 74.0;
57 const Float_t AliTRDgeometry::fgkSwidth1 = 99.613;
58 const Float_t AliTRDgeometry::fgkSwidth2 = 125.707;
59 const Float_t AliTRDgeometry::fgkSlenTR1 = 751.0;
60 const Float_t AliTRDgeometry::fgkSlenTR2 = 313.5;
61 const Float_t AliTRDgeometry::fgkSlenTR3 = 159.5;
62
73ae7b59 63 // The super module side plates
64 const Float_t AliTRDgeometry::fgkSMpltT = 0.2;
65 const Float_t AliTRDgeometry::fgkSMgapT = 0.5;
66
0a770ac9 67 // Height of different chamber parts
68 // Radiator
69 const Float_t AliTRDgeometry::fgkCraH = 4.8;
70 // Drift region
71 const Float_t AliTRDgeometry::fgkCdrH = 3.0;
72 // Amplification region
73 const Float_t AliTRDgeometry::fgkCamH = 0.7;
74 // Readout
73ae7b59 75 const Float_t AliTRDgeometry::fgkCroH = 2.316;
0a770ac9 76 // Total height
77 const Float_t AliTRDgeometry::fgkCH = AliTRDgeometry::fgkCraH
78 + AliTRDgeometry::fgkCdrH
79 + AliTRDgeometry::fgkCamH
80 + AliTRDgeometry::fgkCroH;
81
82 // Vertical spacing of the chambers
73ae7b59 83 const Float_t AliTRDgeometry::fgkVspace = 1.784;
0a770ac9 84
85 // Horizontal spacing of the chambers
86 const Float_t AliTRDgeometry::fgkHspace = 2.0;
87
88 // Thicknesses of different parts of the chamber frame
89 // Lower aluminum frame
90 const Float_t AliTRDgeometry::fgkCalT = 0.3;
91 // Lower G10 frame sides
92 const Float_t AliTRDgeometry::fgkCclsT = 0.3;
93 // Lower G10 frame front
94 const Float_t AliTRDgeometry::fgkCclfT = 1.0;
95 // Upper G10 frame
96 const Float_t AliTRDgeometry::fgkCcuT = 0.9;
97 // Upper Al frame
98 const Float_t AliTRDgeometry::fgkCauT = 1.5;
99
100 // Additional width of the readout chamber frames
101 const Float_t AliTRDgeometry::fgkCroW = 0.9;
102
103 // Difference of outer chamber width and pad plane width
73ae7b59 104 //const Float_t AliTRDgeometry::fgkCpadW = 1.0;
105 const Float_t AliTRDgeometry::fgkCpadW = 0.0;
de6df1b1 106 const Float_t AliTRDgeometry::fgkRpadW = 1.0;
793ff80c 107
108 //
109 // Thickness of the the material layers
110 //
db30bf0f 111 const Float_t AliTRDgeometry::fgkRaThick = 0.3646;
793ff80c 112 const Float_t AliTRDgeometry::fgkMyThick = 0.005;
0a770ac9 113 const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH;
114 const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH;
115 const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick
116 + AliTRDgeometry::fgkAmThick;
793ff80c 117 const Float_t AliTRDgeometry::fgkCuThick = 0.001;
118 const Float_t AliTRDgeometry::fgkSuThick = 0.06;
119 const Float_t AliTRDgeometry::fgkFeThick = 0.0044;
120 const Float_t AliTRDgeometry::fgkCoThick = 0.02;
db30bf0f 121 const Float_t AliTRDgeometry::fgkWaThick = 0.02;
793ff80c 122
123 //
124 // Position of the material layers
125 //
0a770ac9 126 const Float_t AliTRDgeometry::fgkRaZpos = -1.50;
127 const Float_t AliTRDgeometry::fgkMyZpos = 0.895;
128 const Float_t AliTRDgeometry::fgkDrZpos = 2.4;
129 const Float_t AliTRDgeometry::fgkAmZpos = 0.0;
130 const Float_t AliTRDgeometry::fgkCuZpos = -0.9995;
793ff80c 131 const Float_t AliTRDgeometry::fgkSuZpos = 0.0000;
0a770ac9 132 const Float_t AliTRDgeometry::fgkFeZpos = 0.0322;
133 const Float_t AliTRDgeometry::fgkCoZpos = 0.97;
134 const Float_t AliTRDgeometry::fgkWaZpos = 0.99;
793ff80c 135
f7336fa3 136//_____________________________________________________________________________
137AliTRDgeometry::AliTRDgeometry():AliGeometry()
138{
139 //
140 // AliTRDgeometry default constructor
141 //
142
143 Init();
144
145}
146
147//_____________________________________________________________________________
148AliTRDgeometry::~AliTRDgeometry()
149{
8230f242 150 //
151 // AliTRDgeometry destructor
152 //
f7336fa3 153
154}
155
156//_____________________________________________________________________________
157void AliTRDgeometry::Init()
158{
159 //
160 // Initializes the geometry parameter
161 //
f7336fa3 162 // The maximum number of pads
163 // and the position of pad 0,0,0
164 //
165 // chambers seen from the top:
166 // +----------------------------+
167 // | |
793ff80c 168 // | | ^
169 // | | rphi|
170 // | | |
171 // |0 | |
172 // +----------------------------+ +------>
f7336fa3 173 // z
793ff80c 174 // chambers seen from the side: ^
175 // +----------------------------+ drift|
176 // |0 | |
177 // | | |
178 // +----------------------------+ +------>
f7336fa3 179 // z
180 //
a2b90f83 181 // IMPORTANT: time bin 0 is now the first one in the drift region
182 // closest to the readout !!!
793ff80c 183 //
f7336fa3 184
0a770ac9 185 Int_t icham;
186 Int_t iplan;
187 Int_t isect;
188
189 // The outer width of the chambers
73ae7b59 190 fCwidth[0] = 94.8;
191 fCwidth[1] = 99.3;
192 fCwidth[2] = 103.7;
193 fCwidth[3] = 108.1;
194 fCwidth[4] = 112.6;
195 fCwidth[5] = 117.0;
0a770ac9 196
197 // The outer lengths of the chambers
73ae7b59 198 // Includes the spacings between the chambers!
8737e16f 199 Float_t length[kNplan][kNcham] = { { 124.0, 124.0, 110.0, 124.0, 124.0 }
200 , { 131.0, 131.0, 110.0, 131.0, 131.0 }
201 , { 138.0, 138.0, 110.0, 138.0, 138.0 }
202 , { 145.0, 145.0, 110.0, 145.0, 145.0 }
203 , { 147.0, 147.0, 110.0, 147.0, 147.0 }
204 , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
0a770ac9 205
206 for (icham = 0; icham < kNcham; icham++) {
207 for (iplan = 0; iplan < kNplan; iplan++) {
208 fClength[iplan][icham] = length[iplan][icham];
209 fClengthPH[iplan][icham] = 0.0;
210 fClengthRH[iplan][icham] = 0.0;
211 }
212 }
213
793ff80c 214 // The rotation matrix elements
215 Float_t phi = 0;
216 for (isect = 0; isect < fgkNsect; isect++) {
5443e65e 217 phi = -2.0 * TMath::Pi() / (Float_t) fgkNsect * ((Float_t) isect + 0.5);
793ff80c 218 fRotA11[isect] = TMath::Cos(phi);
219 fRotA12[isect] = TMath::Sin(phi);
220 fRotA21[isect] = TMath::Sin(phi);
221 fRotA22[isect] = TMath::Cos(phi);
222 phi = -1.0 * phi;
223 fRotB11[isect] = TMath::Cos(phi);
224 fRotB12[isect] = TMath::Sin(phi);
225 fRotB21[isect] = TMath::Sin(phi);
226 fRotB22[isect] = TMath::Cos(phi);
227 }
228
229}
230
f7336fa3 231//_____________________________________________________________________________
73ae7b59 232void AliTRDgeometry::CreateGeometry(Int_t* )
f7336fa3 233{
234 //
0a770ac9 235 // Create TRD geometry
236 //
f7336fa3 237
238}
239
240//_____________________________________________________________________________
5443e65e 241Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local
242 , Float_t *global
243 , AliTRDparameter *par) const
f7336fa3 244{
245 //
246 // Converts local pad-coordinates (row,col,time) into
247 // global ALICE reference frame coordinates (x,y,z)
248 //
249
793ff80c 250 Int_t icham = GetChamber(idet); // Chamber info (0-4)
251 Int_t isect = GetSector(idet); // Sector info (0-17)
252 Int_t iplan = GetPlane(idet); // Plane info (0-5)
f7336fa3 253
5443e65e 254 return Local2Global(iplan,icham,isect,local,global,par);
f7336fa3 255
256}
257
258//_____________________________________________________________________________
259Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
5443e65e 260 , Float_t *local, Float_t *global
261 , AliTRDparameter *par) const
f7336fa3 262{
263 //
264 // Converts local pad-coordinates (row,col,time) into
265 // global ALICE reference frame coordinates (x,y,z)
266 //
267
5443e65e 268 if (!par) {
269 Error("Local2Global","No parameter defined\n");
270 return kFALSE;
271 }
272
793ff80c 273 Int_t idet = GetDetector(iplan,icham,isect); // Detector number
f7336fa3 274
16bf9884 275 Float_t padRow = local[0]+0.5; // Pad Row position
276 Float_t padCol = local[1]+0.5; // Pad Column position
277 Float_t timeSlice = local[2]+0.5; // Time "position"
f7336fa3 278
5443e65e 279 Float_t row0 = par->GetRow0(iplan,icham,isect);
280 Float_t col0 = par->GetCol0(iplan);
281 Float_t time0 = par->GetTime0(iplan);
f7336fa3 282
793ff80c 283 Float_t rot[3];
f7336fa3 284
285 // calculate (x,y,z) position in rotated chamber
5443e65e 286 rot[0] = time0 - (timeSlice - par->GetTimeBefore())
287 * par->GetTimeBinSize();
288 rot[1] = col0 + padCol
289 * par->GetColPadSize(iplan);
290 rot[2] = row0 + padRow
291 * par->GetRowPadSize(iplan,icham,isect);
f7336fa3 292
293 // Rotate back to original position
294 return RotateBack(idet,rot,global);
295
296}
297
3d7b6a24 298
299
300//_____________________________________________________________________________
301Bool_t AliTRDgeometry::Global2Local(Int_t mode, Float_t *local, Float_t *global, Int_t* index, AliTRDparameter *par) const
302{
303 //
304 // Converts local pad-coordinates (row,col,time) into
305 // global ALICE reference frame coordinates (x,y,z)
306 //
307 //index[0]=plane number
308 //index[1]=chamber number
309 //index[2]=sector number
310 //
311 // mode=0 - local coordinate in y, z, x - rotated global
312 // mode=2 - local coordinate in pad, and pad row, x - rotated global
313 //
314 if (!par) {
315 Error("Local2Global","No parameter defined\n");
316 return kFALSE;
317 }
318
319 //Int_t idet = GetDetector(iplan,icham,isect); // Detector number
320 Int_t idet = GetDetector(index[0],index[1],index[2]); // Detector number
321 Rotate(idet,global,local);
322 if (mode==0) return kTRUE;
323 //
324 // Float_t row0 = par->GetRow0(iplan,icham,isect);
325 //Float_t col0 = par->GetCol0(iplan);
326 //Float_t time0 = par->GetTime0(iplan);
327 //
328 // mode 1 to be implemented later
329 // calculate (x,y,z) position in time bin pad row pad
330 //
331 //rot[0] = time0 - (timeSlice - par->GetTimeBefore())
332 // * par->GetTimeBinSize();
333 //rot[1] = col0 + padCol
334 // * par->GetColPadSize(iplan);
335 //rot[2] = row0 + padRow
336 // * par->GetRowPadSize(iplan,icham,isect);
337
338 return kTRUE;
339
340}
341
342//___________________________________________________________________
343Bool_t AliTRDgeometry::Global2Detector(Float_t global[3], Int_t index[3], AliTRDparameter *par)
344{
345 //
346 //
347 //input = global position
348 //output =index
349 //index[0]=plane number
350 //index[1]=chamber number
351 //index[2]=sector number
352 Float_t fi;
353 //
354 fi = TMath::ATan2(global[1],global[0]);
355 if (fi<0) fi += 2*TMath::Pi();
356 index[2] = Int_t(TMath::Nint((fi - GetAlpha()/2.)/GetAlpha()));
357 //
358 //
359 Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]];
360 index[0] = 0;
361 Float_t max = locx-par->GetTime0(0);
362 for (Int_t iplane=1; iplane<fgkNplan;iplane++){
363 Float_t dist = TMath::Abs(locx-par->GetTime0(iplane));
364 if (dist < max){
365 index[0] = iplane;
366 max = dist;
367 }
368 }
369 Float_t theta = TMath::ATan2(global[2],locx);
370 index[1] = TMath::Nint(float(fgkNcham)*theta/(0.25*TMath::Pi()));
371 return kTRUE;
372
373}
374
375
f7336fa3 376//_____________________________________________________________________________
793ff80c 377Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot) const
f7336fa3 378{
379 //
380 // Rotates all chambers in the position of sector 0 and transforms
381 // the coordinates in the ALICE restframe <pos> into the
382 // corresponding local frame <rot>.
383 //
384
793ff80c 385 Int_t sector = GetSector(d);
f7336fa3 386
793ff80c 387 rot[0] = pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
388 rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
f7336fa3 389 rot[2] = pos[2];
390
391 return kTRUE;
392
393}
394
395//_____________________________________________________________________________
94de3818 396Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
f7336fa3 397{
398 //
399 // Rotates a chambers from the position of sector 0 into its
400 // original position and transforms the corresponding local frame
401 // coordinates <rot> into the coordinates of the ALICE restframe <pos>.
402 //
403
793ff80c 404 Int_t sector = GetSector(d);
f7336fa3 405
793ff80c 406 pos[0] = rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
407 pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
6f1e466d 408 pos[2] = rot[2];
f7336fa3 409
410 return kTRUE;
411
412}
413
414//_____________________________________________________________________________
afc51ac2 415Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c) const
0a770ac9 416{
417 //
418 // Convert plane / chamber into detector number for one single sector
419 //
420
421 return (p + c * fgkNplan);
422
423}
424
425//_____________________________________________________________________________
afc51ac2 426Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s) const
f7336fa3 427{
428 //
429 // Convert plane / chamber / sector into detector number
430 //
431
793ff80c 432 return (p + c * fgkNplan + s * fgkNplan * fgkNcham);
f7336fa3 433
434}
435
436//_____________________________________________________________________________
afc51ac2 437Int_t AliTRDgeometry::GetPlane(Int_t d) const
f7336fa3 438{
439 //
440 // Reconstruct the plane number from the detector number
441 //
442
793ff80c 443 return ((Int_t) (d % fgkNplan));
f7336fa3 444
445}
446
447//_____________________________________________________________________________
afc51ac2 448Int_t AliTRDgeometry::GetChamber(Int_t d) const
f7336fa3 449{
450 //
451 // Reconstruct the chamber number from the detector number
452 //
453
793ff80c 454 return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan);
f7336fa3 455
456}
457
458//_____________________________________________________________________________
afc51ac2 459Int_t AliTRDgeometry::GetSector(Int_t d) const
f7336fa3 460{
461 //
462 // Reconstruct the sector number from the detector number
463 //
464
793ff80c 465 return ((Int_t) (d / (fgkNplan * fgkNcham)));
f7336fa3 466
467}
468
8737e16f 469//_____________________________________________________________________________
470void AliTRDgeometry::SetOldGeometry()
471{
472 //
473 // Use the old chamber lengths
474 //
475
476 Int_t icham;
477 Int_t iplan;
478
479 Float_t length[kNplan][kNcham] = { { 123.5, 123.5, 110.0, 123.5, 123.5 }
480 , { 131.0, 131.0, 110.0, 131.0, 131.0 }
481 , { 134.5, 138.5, 110.0, 138.5, 134.5 }
482 , { 142.0, 146.0, 110.0, 146.0, 142.0 }
483 , { 142.0, 153.0, 110.0, 153.0, 142.0 }
484 , { 134.0, 160.5, 110.0, 160.5, 134.0 } };
485
486 for (icham = 0; icham < kNcham; icham++) {
487 for (iplan = 0; iplan < kNplan; iplan++) {
488 fClength[iplan][icham] = length[iplan][icham];
489 }
490 }
491
492}
bdbb05bb 493
494//_____________________________________________________________________________
495AliTRDgeometry* AliTRDgeometry::GetGeometry(AliRunLoader* runLoader)
496{
497 //
498 // load the geometry from the galice file
499 //
500
501 if (!runLoader) runLoader = AliRunLoader::GetRunLoader();
502 if (!runLoader) {
503 ::Error("AliTRDgeometry::GetGeometry", "No run loader");
504 return NULL;
505 }
506
507 TDirectory* saveDir = gDirectory;
508 runLoader->CdGAFile();
509
510 AliTRDgeometry* geom = (AliTRDgeometry*) gDirectory->Get("TRDgeometry");
511 if (!geom) ::Error("AliTRDgeometry::GetGeometry", "Geometry not found");
512
513 saveDir->cd();
514 return geom;
515}