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"
34 #include "AliTRDcalibDB.h"
35 #include "AliTRDCommonParam.h"
37 ClassImp(AliTRDgeometry)
39 //_____________________________________________________________________________
42 // The geometry constants
44 const Int_t AliTRDgeometry::fgkNsect = kNsect;
45 const Int_t AliTRDgeometry::fgkNplan = kNplan;
46 const Int_t AliTRDgeometry::fgkNcham = kNcham;
47 const Int_t AliTRDgeometry::fgkNdet = kNdet;
50 // Dimensions of the detector
53 // Inner and outer radius of the mother volumes
54 const Float_t AliTRDgeometry::fgkRmin = 294.0;
55 const Float_t AliTRDgeometry::fgkRmax = 368.0;
57 // Upper and lower length of the mother volumes
58 const Float_t AliTRDgeometry::fgkZmax1 = 378.35;
59 const Float_t AliTRDgeometry::fgkZmax2 = 302.0;
61 // Parameter of the BTR mother volumes
62 const Float_t AliTRDgeometry::fgkSheight = 74.0;
63 const Float_t AliTRDgeometry::fgkSwidth1 = 99.613;
64 const Float_t AliTRDgeometry::fgkSwidth2 = 125.707;
65 const Float_t AliTRDgeometry::fgkSlenTR1 = 751.0;
66 const Float_t AliTRDgeometry::fgkSlenTR2 = 313.5;
67 const Float_t AliTRDgeometry::fgkSlenTR3 = 159.5;
69 // The super module side plates
70 const Float_t AliTRDgeometry::fgkSMpltT = 0.2;
71 const Float_t AliTRDgeometry::fgkSMgapT = 0.5;
73 // Height of different chamber parts
75 const Float_t AliTRDgeometry::fgkCraH = 4.8;
77 const Float_t AliTRDgeometry::fgkCdrH = 3.0;
78 // Amplification region
79 const Float_t AliTRDgeometry::fgkCamH = 0.7;
81 const Float_t AliTRDgeometry::fgkCroH = 2.316;
83 const Float_t AliTRDgeometry::fgkCH = AliTRDgeometry::fgkCraH
84 + AliTRDgeometry::fgkCdrH
85 + AliTRDgeometry::fgkCamH
86 + AliTRDgeometry::fgkCroH;
88 // Vertical spacing of the chambers
89 const Float_t AliTRDgeometry::fgkVspace = 1.784;
91 // Horizontal spacing of the chambers
92 const Float_t AliTRDgeometry::fgkHspace = 2.0;
94 // Thicknesses of different parts of the chamber frame
95 // Lower aluminum frame
96 const Float_t AliTRDgeometry::fgkCalT = 0.3;
97 // Lower G10 frame sides
98 const Float_t AliTRDgeometry::fgkCclsT = 0.3;
99 // Lower G10 frame front
100 const Float_t AliTRDgeometry::fgkCclfT = 1.0;
102 const Float_t AliTRDgeometry::fgkCcuT = 0.9;
104 const Float_t AliTRDgeometry::fgkCauT = 1.5;
106 // Additional width of the readout chamber frames
107 const Float_t AliTRDgeometry::fgkCroW = 0.9;
109 // Difference of outer chamber width and pad plane width
110 //const Float_t AliTRDgeometry::fgkCpadW = 1.0;
111 const Float_t AliTRDgeometry::fgkCpadW = 0.0;
112 const Float_t AliTRDgeometry::fgkRpadW = 1.0;
115 // Thickness of the the material layers
117 const Float_t AliTRDgeometry::fgkRaThick = 0.3646;
118 const Float_t AliTRDgeometry::fgkMyThick = 0.005;
119 const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH;
120 const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH;
121 const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick
122 + AliTRDgeometry::fgkAmThick;
123 const Float_t AliTRDgeometry::fgkCuThick = 0.001;
124 const Float_t AliTRDgeometry::fgkSuThick = 0.06;
125 const Float_t AliTRDgeometry::fgkFeThick = 0.0044;
126 const Float_t AliTRDgeometry::fgkCoThick = 0.02;
127 const Float_t AliTRDgeometry::fgkWaThick = 0.02;
130 // Position of the material layers
132 const Float_t AliTRDgeometry::fgkRaZpos = -1.50;
133 const Float_t AliTRDgeometry::fgkMyZpos = 0.895;
134 const Float_t AliTRDgeometry::fgkDrZpos = 2.4;
135 const Float_t AliTRDgeometry::fgkAmZpos = 0.0;
136 const Float_t AliTRDgeometry::fgkCuZpos = -0.9995;
137 const Float_t AliTRDgeometry::fgkSuZpos = 0.0000;
138 const Float_t AliTRDgeometry::fgkFeZpos = 0.0322;
139 const Float_t AliTRDgeometry::fgkCoZpos = 0.97;
140 const Float_t AliTRDgeometry::fgkWaZpos = 0.99;
142 const Double_t AliTRDgeometry::fgkTime0Base = Rmin() + CraHght() + CdrHght() + CamHght()/2.;
143 const Float_t AliTRDgeometry::fgkTime0[6] = { fgkTime0Base + 0 * (Cheight() + Cspace()),
144 fgkTime0Base + 1 * (Cheight() + Cspace()),
145 fgkTime0Base + 2 * (Cheight() + Cspace()),
146 fgkTime0Base + 3 * (Cheight() + Cspace()),
147 fgkTime0Base + 4 * (Cheight() + Cspace()),
148 fgkTime0Base + 5 * (Cheight() + Cspace()) };
150 //_____________________________________________________________________________
151 AliTRDgeometry::AliTRDgeometry():AliGeometry()
154 // AliTRDgeometry default constructor
160 //_____________________________________________________________________________
161 AliTRDgeometry::~AliTRDgeometry()
164 // AliTRDgeometry destructor
168 //_____________________________________________________________________________
169 void AliTRDgeometry::Init()
172 // Initializes the geometry parameter
174 // The maximum number of pads
175 // and the position of pad 0,0,0
177 // chambers seen from the top:
178 // +----------------------------+
184 // +----------------------------+ +------>
186 // chambers seen from the side: ^
187 // +----------------------------+ drift|
190 // +----------------------------+ +------>
193 // IMPORTANT: time bin 0 is now the first one in the drift region
194 // closest to the readout !!!
201 // The outer width of the chambers
203 // Changed with the introduction of
204 // the new layer 0. The old layer 6
213 // fCwidth[5] = 117.0;
215 // The outer lengths of the chambers
216 // Includes the spacings between the chambers!
217 // Changed with the introduction of
218 // the new layer 0. The old layer 6
220 Float_t length[kNplan][kNcham] = { { 124.0, 124.0, 110.0, 124.0, 124.0 }
221 , { 124.0, 124.0, 110.0, 124.0, 124.0 }
222 , { 131.0, 131.0, 110.0, 131.0, 131.0 }
223 , { 138.0, 138.0, 110.0, 138.0, 138.0 }
224 , { 145.0, 145.0, 110.0, 145.0, 145.0 }
225 , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
227 // , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
229 for (icham = 0; icham < kNcham; icham++) {
230 for (iplan = 0; iplan < kNplan; iplan++) {
231 fClength[iplan][icham] = length[iplan][icham];
232 fClengthPH[iplan][icham] = 0.0;
233 fClengthRH[iplan][icham] = 0.0;
237 // The rotation matrix elements
239 for (isect = 0; isect < fgkNsect; isect++) {
240 phi = -2.0 * TMath::Pi() / (Float_t) fgkNsect * ((Float_t) isect + 0.5);
241 fRotA11[isect] = TMath::Cos(phi);
242 fRotA12[isect] = TMath::Sin(phi);
243 fRotA21[isect] = TMath::Sin(phi);
244 fRotA22[isect] = TMath::Cos(phi);
246 fRotB11[isect] = TMath::Cos(phi);
247 fRotB12[isect] = TMath::Sin(phi);
248 fRotB21[isect] = TMath::Sin(phi);
249 fRotB22[isect] = TMath::Cos(phi);
254 //_____________________________________________________________________________
255 void AliTRDgeometry::CreateGeometry(Int_t* )
258 // Create TRD geometry
263 //_____________________________________________________________________________
264 Bool_t AliTRDgeometry::Local2Global(Int_t idet, Double_t *local
266 , AliTRDparameter *par) const
269 // Converts local pad-coordinates (row,col,time) into
270 // global ALICE reference frame coordinates (x,y,z)
273 Int_t icham = GetChamber(idet); // Chamber info (0-4)
274 Int_t isect = GetSector(idet); // Sector info (0-17)
275 Int_t iplan = GetPlane(idet); // Plane info (0-5)
277 return Local2Global(iplan,icham,isect,local,global,par);
281 //_____________________________________________________________________________
282 Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
283 , Double_t *local, Double_t *global
284 , AliTRDparameter *par) const
287 // Converts local pad-coordinates (row,col,time) into
288 // global ALICE reference frame coordinates (x,y,z)
292 Error("Local2Global","No parameter defined\n");
296 AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
300 AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
304 AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham);
306 // calculate (x,y,z) position in rotated chamber
307 Int_t row = ((Int_t) local[0]);
308 Int_t col = ((Int_t) local[1]);
309 Float_t timeSlice = local[2] + 0.5;
310 Float_t time0 = GetTime0(iplan);
313 rot[0] = time0 - (timeSlice - par->GetTimeBefore())
314 * calibration->GetVdrift(iplan, icham, isect, col, row)/calibration->GetSamplingFrequency();
315 rot[1] = padPlane->GetColPos(col) - 0.5 * padPlane->GetColSize(col);
316 rot[2] = padPlane->GetRowPos(row) - 0.5 * padPlane->GetRowSize(row);
318 // Rotate back to original position
319 Int_t idet = GetDetector(iplan,icham,isect);
320 return RotateBack(idet,rot,global);
324 //_____________________________________________________________________________
325 Bool_t AliTRDgeometry::Global2Local(Int_t mode, Double_t *local, Double_t *global
326 , Int_t* index, AliTRDparameter *par) const
329 // Converts local pad-coordinates (row,col,time) into
330 // global ALICE reference frame coordinates (x,y,z)
332 // index[0] = plane number
333 // index[1] = chamber number
334 // index[2] = sector number
336 // mode=0 - local coordinate in y, z, x - rotated global
337 // mode=2 - local coordinate in pad, and pad row, x - rotated global
341 Error("Global2Local","No parameter defined\n");
345 //Int_t idet = GetDetector(iplan,icham,isect); // Detector number
346 Int_t idet = GetDetector(index[0],index[1],index[2]); // Detector number
347 Rotate(idet,global,local);
348 if (mode==0) return kTRUE;
350 // Float_t row0 = par->GetRow0(iplan,icham,isect);
351 //Float_t col0 = par->GetCol0(iplan);
352 //Float_t time0 = GetTime0(iplan);
354 // mode 1 to be implemented later
355 // calculate (x,y,z) position in time bin pad row pad
357 //rot[0] = time0 - (timeSlice - par->GetTimeBefore())
358 // * par->GetDriftVelocity()/par->GetSamplingFrequency();
359 //rot[1] = col0 + padCol
360 // * par->GetColPadSize(iplan);
361 //rot[2] = row0 + padRow
362 // * par->GetRowPadSize(iplan,icham,isect);
368 //_____________________________________________________________________________
369 Bool_t AliTRDgeometry::Global2Detector(Double_t global[3], Int_t index[3])
372 // input = global position
374 // index[0] = plane number
375 // index[1] = chamber number
376 // index[2] = sector number
381 fi = TMath::ATan2(global[1],global[0]);
382 if (fi<0) fi += 2*TMath::Pi();
383 index[2] = Int_t(TMath::Nint((fi - GetAlpha()/2.)/GetAlpha()));
386 Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]];
388 Float_t max = locx - GetTime0(0);
389 for (Int_t iplane=1; iplane<fgkNplan;iplane++){
390 Float_t dist = TMath::Abs(locx - GetTime0(iplane));
396 Float_t theta = TMath::ATan2(global[2],locx);
397 index[1] = TMath::Nint(float(fgkNcham)*theta/(0.25*TMath::Pi()));
403 //_____________________________________________________________________________
404 Bool_t AliTRDgeometry::Rotate(Int_t d, Double_t *pos, Double_t *rot) const
407 // Rotates all chambers in the position of sector 0 and transforms
408 // the coordinates in the ALICE restframe <pos> into the
409 // corresponding local frame <rot>.
412 Int_t sector = GetSector(d);
414 rot[0] = pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
415 rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
422 //_____________________________________________________________________________
423 Bool_t AliTRDgeometry::RotateBack(Int_t d, Double_t *rot, Double_t *pos) const
426 // Rotates a chambers from the position of sector 0 into its
427 // original position and transforms the corresponding local frame
428 // coordinates <rot> into the coordinates of the ALICE restframe <pos>.
431 Int_t sector = GetSector(d);
433 pos[0] = rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
434 pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
441 //_____________________________________________________________________________
442 Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c)
445 // Convert plane / chamber into detector number for one single sector
448 return (p + c * fgkNplan);
452 //_____________________________________________________________________________
453 Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s)
456 // Convert plane / chamber / sector into detector number
459 return (p + c * fgkNplan + s * fgkNplan * fgkNcham);
463 //_____________________________________________________________________________
464 Int_t AliTRDgeometry::GetPlane(Int_t d) const
467 // Reconstruct the plane number from the detector number
470 return ((Int_t) (d % fgkNplan));
474 //_____________________________________________________________________________
475 Int_t AliTRDgeometry::GetChamber(Int_t d) const
478 // Reconstruct the chamber number from the detector number
481 return ((Int_t) (d % (fgkNplan * fgkNcham)) / fgkNplan);
485 //_____________________________________________________________________________
486 Int_t AliTRDgeometry::GetSector(Int_t d) const
489 // Reconstruct the sector number from the detector number
492 return ((Int_t) (d / (fgkNplan * fgkNcham)));
496 //_____________________________________________________________________________
497 AliTRDgeometry* AliTRDgeometry::GetGeometry(AliRunLoader* runLoader)
500 // load the geometry from the galice file
503 if (!runLoader) runLoader = AliRunLoader::GetRunLoader();
505 ::Error("AliTRDgeometry::GetGeometry", "No run loader");
509 TDirectory* saveDir = gDirectory;
510 runLoader->CdGAFile();
512 // Try from the galice.root file
513 AliTRDgeometry* geom = (AliTRDgeometry*) gDirectory->Get("TRDgeometry");
516 // It is not in the file, try to get it from gAlice,
517 // which corresponds to the run loader
518 AliTRD * trd = (AliTRD*)runLoader->GetAliRun()->GetDetector("TRD");
519 geom = trd->GetGeometry();
521 if (!geom) ::Error("AliTRDgeometry::GetGeometry", "Geometry not found");