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