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