1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // TRD geometry class //
22 ///////////////////////////////////////////////////////////////////////////////
27 #include "AliRunLoader.h"
28 #include "AliTRDgeometry.h"
29 #include "AliTRDparameter.h"
31 ClassImp(AliTRDgeometry)
33 //_____________________________________________________________________________
36 // The geometry constants
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;
44 // Dimensions of the detector
47 // Inner and outer radius of the mother volumes
48 const Float_t AliTRDgeometry::fgkRmin = 294.0;
49 const Float_t AliTRDgeometry::fgkRmax = 368.0;
51 // Upper and lower length of the mother volumes
52 const Float_t AliTRDgeometry::fgkZmax1 = 378.35;
53 const Float_t AliTRDgeometry::fgkZmax2 = 302.0;
55 // Parameter of the BTR mother volumes
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;
63 // The super module side plates
64 const Float_t AliTRDgeometry::fgkSMpltT = 0.2;
65 const Float_t AliTRDgeometry::fgkSMgapT = 0.5;
67 // Height of different chamber parts
69 const Float_t AliTRDgeometry::fgkCraH = 4.8;
71 const Float_t AliTRDgeometry::fgkCdrH = 3.0;
72 // Amplification region
73 const Float_t AliTRDgeometry::fgkCamH = 0.7;
75 const Float_t AliTRDgeometry::fgkCroH = 2.316;
77 const Float_t AliTRDgeometry::fgkCH = AliTRDgeometry::fgkCraH
78 + AliTRDgeometry::fgkCdrH
79 + AliTRDgeometry::fgkCamH
80 + AliTRDgeometry::fgkCroH;
82 // Vertical spacing of the chambers
83 const Float_t AliTRDgeometry::fgkVspace = 1.784;
85 // Horizontal spacing of the chambers
86 const Float_t AliTRDgeometry::fgkHspace = 2.0;
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;
96 const Float_t AliTRDgeometry::fgkCcuT = 0.9;
98 const Float_t AliTRDgeometry::fgkCauT = 1.5;
100 // Additional width of the readout chamber frames
101 const Float_t AliTRDgeometry::fgkCroW = 0.9;
103 // Difference of outer chamber width and pad plane width
104 //const Float_t AliTRDgeometry::fgkCpadW = 1.0;
105 const Float_t AliTRDgeometry::fgkCpadW = 0.0;
106 const Float_t AliTRDgeometry::fgkRpadW = 1.0;
109 // Thickness of the the material layers
111 const Float_t AliTRDgeometry::fgkRaThick = 0.3646;
112 const Float_t AliTRDgeometry::fgkMyThick = 0.005;
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;
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;
121 const Float_t AliTRDgeometry::fgkWaThick = 0.02;
124 // Position of the material layers
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;
131 const Float_t AliTRDgeometry::fgkSuZpos = 0.0000;
132 const Float_t AliTRDgeometry::fgkFeZpos = 0.0322;
133 const Float_t AliTRDgeometry::fgkCoZpos = 0.97;
134 const Float_t AliTRDgeometry::fgkWaZpos = 0.99;
136 //_____________________________________________________________________________
137 AliTRDgeometry::AliTRDgeometry():AliGeometry()
140 // AliTRDgeometry default constructor
147 //_____________________________________________________________________________
148 AliTRDgeometry::~AliTRDgeometry()
151 // AliTRDgeometry destructor
156 //_____________________________________________________________________________
157 void AliTRDgeometry::Init()
160 // Initializes the geometry parameter
162 // The maximum number of pads
163 // and the position of pad 0,0,0
165 // chambers seen from the top:
166 // +----------------------------+
172 // +----------------------------+ +------>
174 // chambers seen from the side: ^
175 // +----------------------------+ drift|
178 // +----------------------------+ +------>
181 // IMPORTANT: time bin 0 is now the first one in the drift region
182 // closest to the readout !!!
189 // The outer width of the chambers
197 // The outer lengths of the chambers
198 // Includes the spacings between the chambers!
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 } };
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;
214 // The rotation matrix elements
216 for (isect = 0; isect < fgkNsect; isect++) {
217 phi = -2.0 * TMath::Pi() / (Float_t) fgkNsect * ((Float_t) isect + 0.5);
218 fRotA11[isect] = TMath::Cos(phi);
219 fRotA12[isect] = TMath::Sin(phi);
220 fRotA21[isect] = TMath::Sin(phi);
221 fRotA22[isect] = TMath::Cos(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);
231 //_____________________________________________________________________________
232 void AliTRDgeometry::CreateGeometry(Int_t* )
235 // Create TRD geometry
240 //_____________________________________________________________________________
241 Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local
243 , AliTRDparameter *par) const
246 // Converts local pad-coordinates (row,col,time) into
247 // global ALICE reference frame coordinates (x,y,z)
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)
254 return Local2Global(iplan,icham,isect,local,global,par);
258 //_____________________________________________________________________________
259 Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
260 , Float_t *local, Float_t *global
261 , AliTRDparameter *par) const
264 // Converts local pad-coordinates (row,col,time) into
265 // global ALICE reference frame coordinates (x,y,z)
269 Error("Local2Global","No parameter defined\n");
273 Int_t idet = GetDetector(iplan,icham,isect); // Detector number
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"
279 Float_t row0 = par->GetRow0(iplan,icham,isect);
280 Float_t col0 = par->GetCol0(iplan);
281 Float_t time0 = par->GetTime0(iplan);
285 // calculate (x,y,z) position in rotated chamber
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);
293 // Rotate back to original position
294 return RotateBack(idet,rot,global);
300 //_____________________________________________________________________________
301 Bool_t AliTRDgeometry::Global2Local(Int_t mode, Float_t *local, Float_t *global, Int_t* index, AliTRDparameter *par) const
304 // Converts local pad-coordinates (row,col,time) into
305 // global ALICE reference frame coordinates (x,y,z)
307 //index[0]=plane number
308 //index[1]=chamber number
309 //index[2]=sector number
311 // mode=0 - local coordinate in y, z, x - rotated global
312 // mode=2 - local coordinate in pad, and pad row, x - rotated global
315 Error("Local2Global","No parameter defined\n");
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;
324 // Float_t row0 = par->GetRow0(iplan,icham,isect);
325 //Float_t col0 = par->GetCol0(iplan);
326 //Float_t time0 = par->GetTime0(iplan);
328 // mode 1 to be implemented later
329 // calculate (x,y,z) position in time bin pad row pad
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);
342 //___________________________________________________________________
343 Bool_t AliTRDgeometry::Global2Detector(Float_t global[3], Int_t index[3], AliTRDparameter *par)
347 //input = global position
349 //index[0]=plane number
350 //index[1]=chamber number
351 //index[2]=sector number
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()));
359 Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]];
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));
369 Float_t theta = TMath::ATan2(global[2],locx);
370 index[1] = TMath::Nint(float(fgkNcham)*theta/(0.25*TMath::Pi()));
376 //_____________________________________________________________________________
377 Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot) const
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>.
385 Int_t sector = GetSector(d);
387 rot[0] = pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
388 rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
395 //_____________________________________________________________________________
396 Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
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>.
404 Int_t sector = GetSector(d);
406 pos[0] = rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
407 pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
414 //_____________________________________________________________________________
415 Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c) const
418 // Convert plane / chamber into detector number for one single sector
421 return (p + c * fgkNplan);
425 //_____________________________________________________________________________
426 Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s) const
429 // Convert plane / chamber / sector into detector number
432 return (p + c * fgkNplan + s * fgkNplan * fgkNcham);
436 //_____________________________________________________________________________
437 Int_t AliTRDgeometry::GetPlane(Int_t d) const
440 // Reconstruct the plane number from the detector number
443 return ((Int_t) (d % fgkNplan));
447 //_____________________________________________________________________________
448 Int_t AliTRDgeometry::GetChamber(Int_t d) const
451 // Reconstruct the chamber number from the detector number
454 return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan);
458 //_____________________________________________________________________________
459 Int_t AliTRDgeometry::GetSector(Int_t d) const
462 // Reconstruct the sector number from the detector number
465 return ((Int_t) (d / (fgkNplan * fgkNcham)));
469 //_____________________________________________________________________________
470 void AliTRDgeometry::SetOldGeometry()
473 // Use the old chamber lengths
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 } };
486 for (icham = 0; icham < kNcham; icham++) {
487 for (iplan = 0; iplan < kNplan; iplan++) {
488 fClength[iplan][icham] = length[iplan][icham];
494 //_____________________________________________________________________________
495 AliTRDgeometry* AliTRDgeometry::GetGeometry(AliRunLoader* runLoader)
498 // load the geometry from the galice file
501 if (!runLoader) runLoader = AliRunLoader::GetRunLoader();
503 ::Error("AliTRDgeometry::GetGeometry", "No run loader");
507 TDirectory* saveDir = gDirectory;
508 runLoader->CdGAFile();
510 AliTRDgeometry* geom = (AliTRDgeometry*) gDirectory->Get("TRDgeometry");
511 if (!geom) ::Error("AliTRDgeometry::GetGeometry", "Geometry not found");