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