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"
30 #include "AliTRDpadPlane.h"
35 ClassImp(AliTRDgeometry)
37 //_____________________________________________________________________________
40 // The geometry constants
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;
48 // Dimensions of the detector
51 // Inner and outer radius of the mother volumes
52 const Float_t AliTRDgeometry::fgkRmin = 294.0;
53 const Float_t AliTRDgeometry::fgkRmax = 368.0;
55 // Upper and lower length of the mother volumes
56 const Float_t AliTRDgeometry::fgkZmax1 = 378.35;
57 const Float_t AliTRDgeometry::fgkZmax2 = 302.0;
59 // Parameter of the BTR mother volumes
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;
67 // The super module side plates
68 const Float_t AliTRDgeometry::fgkSMpltT = 0.2;
69 const Float_t AliTRDgeometry::fgkSMgapT = 0.5;
71 // Height of different chamber parts
73 const Float_t AliTRDgeometry::fgkCraH = 4.8;
75 const Float_t AliTRDgeometry::fgkCdrH = 3.0;
76 // Amplification region
77 const Float_t AliTRDgeometry::fgkCamH = 0.7;
79 const Float_t AliTRDgeometry::fgkCroH = 2.316;
81 const Float_t AliTRDgeometry::fgkCH = AliTRDgeometry::fgkCraH
82 + AliTRDgeometry::fgkCdrH
83 + AliTRDgeometry::fgkCamH
84 + AliTRDgeometry::fgkCroH;
86 // Vertical spacing of the chambers
87 const Float_t AliTRDgeometry::fgkVspace = 1.784;
89 // Horizontal spacing of the chambers
90 const Float_t AliTRDgeometry::fgkHspace = 2.0;
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;
100 const Float_t AliTRDgeometry::fgkCcuT = 0.9;
102 const Float_t AliTRDgeometry::fgkCauT = 1.5;
104 // Additional width of the readout chamber frames
105 const Float_t AliTRDgeometry::fgkCroW = 0.9;
107 // Difference of outer chamber width and pad plane width
108 //const Float_t AliTRDgeometry::fgkCpadW = 1.0;
109 const Float_t AliTRDgeometry::fgkCpadW = 0.0;
110 const Float_t AliTRDgeometry::fgkRpadW = 1.0;
113 // Thickness of the the material layers
115 const Float_t AliTRDgeometry::fgkRaThick = 0.3646;
116 const Float_t AliTRDgeometry::fgkMyThick = 0.005;
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;
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;
125 const Float_t AliTRDgeometry::fgkWaThick = 0.02;
128 // Position of the material layers
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;
135 const Float_t AliTRDgeometry::fgkSuZpos = 0.0000;
136 const Float_t AliTRDgeometry::fgkFeZpos = 0.0322;
137 const Float_t AliTRDgeometry::fgkCoZpos = 0.97;
138 const Float_t AliTRDgeometry::fgkWaZpos = 0.99;
140 //_____________________________________________________________________________
141 AliTRDgeometry::AliTRDgeometry():AliGeometry()
144 // AliTRDgeometry default constructor
151 //_____________________________________________________________________________
152 AliTRDgeometry::~AliTRDgeometry()
155 // AliTRDgeometry destructor
160 //_____________________________________________________________________________
161 void AliTRDgeometry::Init()
164 // Initializes the geometry parameter
166 // The maximum number of pads
167 // and the position of pad 0,0,0
169 // chambers seen from the top:
170 // +----------------------------+
176 // +----------------------------+ +------>
178 // chambers seen from the side: ^
179 // +----------------------------+ drift|
182 // +----------------------------+ +------>
185 // IMPORTANT: time bin 0 is now the first one in the drift region
186 // closest to the readout !!!
193 // The outer width of the chambers
195 // Changed with the introduction of
196 // the new layer 0. The old layer 6
205 // fCwidth[5] = 117.0;
207 // The outer lengths of the chambers
208 // Includes the spacings between the chambers!
209 // Changed with the introduction of
210 // the new layer 0. The old layer 6
212 Float_t length[kNplan][kNcham] = { { 124.0, 124.0, 110.0, 124.0, 124.0 }
213 , { 124.0, 124.0, 110.0, 124.0, 124.0 }
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 }
217 , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
219 // , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
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;
229 // The rotation matrix elements
231 for (isect = 0; isect < fgkNsect; isect++) {
232 phi = -2.0 * TMath::Pi() / (Float_t) fgkNsect * ((Float_t) isect + 0.5);
233 fRotA11[isect] = TMath::Cos(phi);
234 fRotA12[isect] = TMath::Sin(phi);
235 fRotA21[isect] = TMath::Sin(phi);
236 fRotA22[isect] = TMath::Cos(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);
246 //_____________________________________________________________________________
247 void AliTRDgeometry::CreateGeometry(Int_t* )
250 // Create TRD geometry
255 //_____________________________________________________________________________
256 Bool_t AliTRDgeometry::Local2Global(Int_t idet, Double_t *local
258 , AliTRDparameter *par) const
261 // Converts local pad-coordinates (row,col,time) into
262 // global ALICE reference frame coordinates (x,y,z)
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)
269 return Local2Global(iplan,icham,isect,local,global,par);
273 //_____________________________________________________________________________
274 Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
275 , Double_t *local, Double_t *global
276 , AliTRDparameter *par) const
279 // Converts local pad-coordinates (row,col,time) into
280 // global ALICE reference frame coordinates (x,y,z)
284 Error("Local2Global","No parameter defined\n");
288 AliTRDpadPlane *padPlane = par->GetPadPlane(iplan,icham);
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;
294 Float_t time0 = par->GetTime0(iplan);
297 rot[0] = time0 - (timeSlice - par->GetTimeBefore())
298 * par->GetDriftVelocity()/par->GetSamplingFrequency();
299 rot[1] = padPlane->GetColPos(col) - 0.5 * padPlane->GetColSize(col);
300 rot[2] = padPlane->GetRowPos(row) - 0.5 * padPlane->GetRowSize(row);
302 // Rotate back to original position
303 Int_t idet = GetDetector(iplan,icham,isect);
304 return RotateBack(idet,rot,global);
308 //_____________________________________________________________________________
309 Bool_t AliTRDgeometry::Global2Local(Int_t mode, Double_t *local, Double_t *global
310 , Int_t* index, AliTRDparameter *par) const
313 // Converts local pad-coordinates (row,col,time) into
314 // global ALICE reference frame coordinates (x,y,z)
316 // index[0] = plane number
317 // index[1] = chamber number
318 // index[2] = sector number
320 // mode=0 - local coordinate in y, z, x - rotated global
321 // mode=2 - local coordinate in pad, and pad row, x - rotated global
325 Error("Local2Global","No parameter defined\n");
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;
334 // Float_t row0 = par->GetRow0(iplan,icham,isect);
335 //Float_t col0 = par->GetCol0(iplan);
336 //Float_t time0 = par->GetTime0(iplan);
338 // mode 1 to be implemented later
339 // calculate (x,y,z) position in time bin pad row pad
341 //rot[0] = time0 - (timeSlice - par->GetTimeBefore())
342 // * par->GetDriftVelocity()/par->GetSamplingFrequency();
343 //rot[1] = col0 + padCol
344 // * par->GetColPadSize(iplan);
345 //rot[2] = row0 + padRow
346 // * par->GetRowPadSize(iplan,icham,isect);
352 //_____________________________________________________________________________
353 Bool_t AliTRDgeometry::Global2Detector(Double_t global[3], Int_t index[3]
354 , AliTRDparameter *par)
357 // input = global position
359 // index[0] = plane number
360 // index[1] = chamber number
361 // index[2] = sector number
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()));
371 Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]];
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));
381 Float_t theta = TMath::ATan2(global[2],locx);
382 index[1] = TMath::Nint(float(fgkNcham)*theta/(0.25*TMath::Pi()));
388 //_____________________________________________________________________________
389 Bool_t AliTRDgeometry::Rotate(Int_t d, Double_t *pos, Double_t *rot) const
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>.
397 Int_t sector = GetSector(d);
399 rot[0] = pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
400 rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
407 //_____________________________________________________________________________
408 Bool_t AliTRDgeometry::RotateBack(Int_t d, Double_t *rot, Double_t *pos) const
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>.
416 Int_t sector = GetSector(d);
418 pos[0] = rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
419 pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
426 //_____________________________________________________________________________
427 Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c) const
430 // Convert plane / chamber into detector number for one single sector
433 return (p + c * fgkNplan);
437 //_____________________________________________________________________________
438 Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s) const
441 // Convert plane / chamber / sector into detector number
444 return (p + c * fgkNplan + s * fgkNplan * fgkNcham);
448 //_____________________________________________________________________________
449 Int_t AliTRDgeometry::GetPlane(Int_t d) const
452 // Reconstruct the plane number from the detector number
455 return ((Int_t) (d % fgkNplan));
459 //_____________________________________________________________________________
460 Int_t AliTRDgeometry::GetChamber(Int_t d) const
463 // Reconstruct the chamber number from the detector number
466 return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan);
470 //_____________________________________________________________________________
471 Int_t AliTRDgeometry::GetSector(Int_t d) const
474 // Reconstruct the sector number from the detector number
477 return ((Int_t) (d / (fgkNplan * fgkNcham)));
481 //_____________________________________________________________________________
482 AliTRDgeometry* AliTRDgeometry::GetGeometry(AliRunLoader* runLoader)
485 // load the geometry from the galice file
488 if (!runLoader) runLoader = AliRunLoader::GetRunLoader();
490 ::Error("AliTRDgeometry::GetGeometry", "No run loader");
494 TDirectory* saveDir = gDirectory;
495 runLoader->CdGAFile();
497 // Try from the galice.root file
498 AliTRDgeometry* geom = (AliTRDgeometry*) gDirectory->Get("TRDgeometry");
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();
506 if (!geom) ::Error("AliTRDgeometry::GetGeometry", "Geometry not found");