Add new TRD classes
[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
16/*
17$Log$
18*/
19
20///////////////////////////////////////////////////////////////////////////////
21// //
22// TRD geometry class //
23// //
24///////////////////////////////////////////////////////////////////////////////
25
26#include "AliTRDgeometry.h"
27#include "AliTRDrecPoint.h"
28
29ClassImp(AliTRDgeometry)
30
31//_____________________________________________________________________________
32AliTRDgeometry::AliTRDgeometry():AliGeometry()
33{
34 //
35 // AliTRDgeometry default constructor
36 //
37
38 Init();
39
40}
41
42//_____________________________________________________________________________
43AliTRDgeometry::~AliTRDgeometry()
44{
45
46}
47
48//_____________________________________________________________________________
49void AliTRDgeometry::Init()
50{
51 //
52 // Initializes the geometry parameter
53 //
54
55 Int_t iplan;
56
57 // The width of the chambers
58 fCwidth[0] = 99.6;
59 fCwidth[1] = 104.1;
60 fCwidth[2] = 108.5;
61 fCwidth[3] = 112.9;
62 fCwidth[4] = 117.4;
63 fCwidth[5] = 121.8;
64
65 // The default pad dimensions
66 fRowPadSize = 4.5;
67 fColPadSize = 1.0;
68 fTimeBinSize = 0.1;
69
70 // The maximum number of pads
71 // and the position of pad 0,0,0
72 //
73 // chambers seen from the top:
74 // +----------------------------+
75 // | |
76 // | | ^
77 // | | rphi|
78 // | | |
79 // |0 | |
80 // +----------------------------+ +------>
81 // z
82 // chambers seen from the side: ^
83 // +----------------------------+ time|
84 // | | |
85 // |0 | |
86 // +----------------------------+ +------>
87 // z
88 //
89
90 // The pad column (rphi-direction)
91 for (iplan = 0; iplan < kNplan; iplan++) {
92 fColMax[iplan] = 1 + TMath::Nint((fCwidth[iplan] - 2. * kCcthick)
93 / fColPadSize - 0.5);
94 fCol0[iplan] = -fCwidth[iplan]/2. + kCcthick;
95 }
96
97 // The time bucket
98 fTimeMax = 1 + TMath::Nint(kDrThick / fTimeBinSize - 0.5);
99 for (iplan = 0; iplan < kNplan; iplan++) {
100 fTime0[iplan] = kRmin + kCcframe/2. + kDrZpos - 0.5 * kDrThick
101 + iplan * (kCheight + kCspace);
102 }
103
104}
105
106//_____________________________________________________________________________
107void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
108{
109 //
110 // Create the TRD geometry
111 //
112 // Author: Christoph Blume (C.Blume@gsi.de) 20/07/99
113 //
114 // The volumes:
115 // TRD1-3 (Air) --- The TRD mother volumes for one sector.
116 // To be placed into the spaceframe.
117 //
118 // UAFI(/M/O) (Al) --- The aluminum frame of the inner(/middle/outer) chambers (readout)
119 // UCFI(/M/O) (C) --- The carbon frame of the inner(/middle/outer) chambers
120 // (driftchamber + radiator)
121 // UAII(/M/O) (Air) --- The inner part of the readout of the inner(/middle/outer) chambers
122 // UFII(/M/O) (Air) --- The inner part of the chamner and radiator of the
123 // inner(/middle/outer) chambers
124 //
125 // The material layers in one chamber:
126 // UL01 (G10) --- The gas seal of the radiator
127 // UL02 (CO2) --- The gas in the radiator
128 // UL03 (PE) --- The foil stack
129 // UL04 (Mylar) --- Entrance window to the driftvolume and HV-cathode
130 // UL05 (Xe) --- The driftvolume
131 // UL06 (Xe) --- The amplification region
132 //
133 // UL07 (Cu) --- The pad plane
134 // UL08 (G10) --- The Nomex honeycomb support structure
135 // UL09 (Cu) --- FEE and signal lines
136 // UL10 (PE) --- The cooling devices
137 // UL11 (Water) --- The cooling water
138
139 const Int_t npar_cha = 3;
140
141 Float_t par_dum[3];
142 Float_t par_cha[npar_cha];
143
144 Float_t xpos, ypos, zpos;
145
146 // The aluminum frames - readout + electronics (Al)
147 // The inner chambers
148 gMC->Gsvolu("UAFI","BOX ",idtmed[1301-1],par_dum,0);
149 // The middle chambers
150 gMC->Gsvolu("UAFM","BOX ",idtmed[1301-1],par_dum,0);
151 // The outer chambers
152 gMC->Gsvolu("UAFO","BOX ",idtmed[1301-1],par_dum,0);
153
154 // The inner part of the aluminum frames (Air)
155 // The inner chambers
156 gMC->Gsvolu("UAII","BOX ",idtmed[1302-1],par_dum,0);
157 // The middle chambers
158 gMC->Gsvolu("UAIM","BOX ",idtmed[1302-1],par_dum,0);
159 // The outer chambers
160 gMC->Gsvolu("UAIO","BOX ",idtmed[1302-1],par_dum,0);
161
162 // The carbon frames - radiator + driftchamber (C)
163 // The inner chambers
164 gMC->Gsvolu("UCFI","BOX ",idtmed[1307-1],par_dum,0);
165 // The middle chambers
166 gMC->Gsvolu("UCFM","BOX ",idtmed[1307-1],par_dum,0);
167 // The outer chambers
168 gMC->Gsvolu("UCFO","BOX ",idtmed[1307-1],par_dum,0);
169
170 // The inner part of the carbon frames (Air)
171 // The inner chambers
172 gMC->Gsvolu("UCII","BOX ",idtmed[1302-1],par_dum,0);
173 // The middle chambers
174 gMC->Gsvolu("UCIM","BOX ",idtmed[1302-1],par_dum,0);
175 // The outer chambers
176 gMC->Gsvolu("UCIO","BOX ",idtmed[1302-1],par_dum,0);
177
178 // The material layers inside the chambers
179 par_cha[0] = -1.;
180 par_cha[1] = -1.;
181 // G10 layer (radiator seal)
182 par_cha[2] = kSeThick/2;
183 gMC->Gsvolu("UL01","BOX ",idtmed[1313-1],par_cha,npar_cha);
184 // CO2 layer (radiator)
185 par_cha[2] = kRaThick/2;
186 gMC->Gsvolu("UL02","BOX ",idtmed[1312-1],par_cha,npar_cha);
187 // PE layer (radiator)
188 par_cha[2] = kPeThick/2;
189 gMC->Gsvolu("UL03","BOX ",idtmed[1303-1],par_cha,npar_cha);
190 // Mylar layer (entrance window + HV cathode)
191 par_cha[2] = kMyThick/2;
192 gMC->Gsvolu("UL04","BOX ",idtmed[1308-1],par_cha,npar_cha);
193 // Xe/Isobutane layer (drift volume, sensitive)
194 par_cha[2] = kDrThick/2.;
195 gMC->Gsvolu("UL05","BOX ",idtmed[1309-1],par_cha,npar_cha);
196 // Xe/Isobutane layer (amplification volume, not sensitive)
197 par_cha[2] = kAmThick/2.;
198 gMC->Gsvolu("UL06","BOX ",idtmed[1309-1],par_cha,npar_cha);
199
200 // Cu layer (pad plane)
201 par_cha[2] = kCuThick/2;
202 gMC->Gsvolu("UL07","BOX ",idtmed[1305-1],par_cha,npar_cha);
203 // G10 layer (support structure)
204 par_cha[2] = kSuThick/2;
205 gMC->Gsvolu("UL08","BOX ",idtmed[1313-1],par_cha,npar_cha);
206 // Cu layer (FEE + signal lines)
207 par_cha[2] = kFeThick/2;
208 gMC->Gsvolu("UL09","BOX ",idtmed[1305-1],par_cha,npar_cha);
209 // PE layer (cooling devices)
210 par_cha[2] = kCoThick/2;
211 gMC->Gsvolu("UL10","BOX ",idtmed[1303-1],par_cha,npar_cha);
212 // Water layer (cooling)
213 par_cha[2] = kWaThick/2;
214 gMC->Gsvolu("UL11","BOX ",idtmed[1314-1],par_cha,npar_cha);
215
216 // Position the layers in the chambers
217 xpos = 0;
218 ypos = 0;
219
220 // G10 layer (radiator seal)
221 zpos = kSeZpos;
222 gMC->Gspos("UL01",1,"UCII",xpos,ypos,zpos,0,"ONLY");
223 gMC->Gspos("UL01",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
224 gMC->Gspos("UL01",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
225 // CO2 layer (radiator)
226 zpos = kRaZpos;
227 gMC->Gspos("UL02",1,"UCII",xpos,ypos,zpos,0,"ONLY");
228 gMC->Gspos("UL02",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
229 gMC->Gspos("UL02",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
230 // PE layer (radiator)
231 zpos = 0;
232 gMC->Gspos("UL03",1,"UL02",xpos,ypos,zpos,0,"ONLY");
233 // Mylar layer (entrance window + HV cathode)
234 zpos = kMyZpos;
235 gMC->Gspos("UL04",1,"UCII",xpos,ypos,zpos,0,"ONLY");
236 gMC->Gspos("UL04",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
237 gMC->Gspos("UL04",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
238 // Xe/Isobutane layer (drift volume)
239 zpos = kDrZpos;
240 gMC->Gspos("UL05",1,"UCII",xpos,ypos,zpos,0,"ONLY");
241 gMC->Gspos("UL05",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
242 gMC->Gspos("UL05",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
243 // Xe/Isobutane layer (amplification volume)
244 zpos = kAmZpos;
245 gMC->Gspos("UL06",1,"UCII",xpos,ypos,zpos,0,"ONLY");
246 gMC->Gspos("UL06",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
247 gMC->Gspos("UL06",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
248
249 // Cu layer (pad plane)
250 zpos = kCuZpos;
251 gMC->Gspos("UL07",1,"UAII",xpos,ypos,zpos,0,"ONLY");
252 gMC->Gspos("UL07",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
253 gMC->Gspos("UL07",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
254 // G10 layer (support structure)
255 zpos = kSuZpos;
256 gMC->Gspos("UL08",1,"UAII",xpos,ypos,zpos,0,"ONLY");
257 gMC->Gspos("UL08",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
258 gMC->Gspos("UL08",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
259 // Cu layer (FEE + signal lines)
260 zpos = kFeZpos;
261 gMC->Gspos("UL09",1,"UAII",xpos,ypos,zpos,0,"ONLY");
262 gMC->Gspos("UL09",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
263 gMC->Gspos("UL09",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
264 // PE layer (cooling devices)
265 zpos = kCoZpos;
266 gMC->Gspos("UL10",1,"UAII",xpos,ypos,zpos,0,"ONLY");
267 gMC->Gspos("UL10",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
268 gMC->Gspos("UL10",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
269 // Water layer (cooling)
270 zpos = kWaZpos;
271 gMC->Gspos("UL11",1,"UAII",xpos,ypos,zpos,0,"ONLY");
272 gMC->Gspos("UL11",1,"UAIM",xpos,ypos,zpos,0,"ONLY");
273 gMC->Gspos("UL11",1,"UAIO",xpos,ypos,zpos,0,"ONLY");
274
275}
276
277//_____________________________________________________________________________
278Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local, Float_t *global)
279{
280 //
281 // Converts local pad-coordinates (row,col,time) into
282 // global ALICE reference frame coordinates (x,y,z)
283 //
284
285 Int_t icham = GetChamber(idet); // Chamber info (0-4)
286 Int_t isect = GetSector(idet); // Sector info (0-17)
287 Int_t iplan = GetPlane(idet); // Plane info (0-5)
288
289 Float_t padRow = local[0]; // Pad Row position
290 Float_t padCol = local[1]; // Pad Column position
291 Float_t timeSlice = local[2]; // Time "position"
292
293 Float_t row0 = GetRow0(iplan,icham,isect);
294 Float_t col0 = GetCol0(iplan);
295 Float_t time0 = GetTime0(iplan);
296
297 Float_t rot[3];
298
299 // calculate (x,y) position in rotated chamber
300 rot[1] = col0 + padCol * fColPadSize;
301 rot[0] = time0 + timeSlice * fTimeBinSize;
302 // calculate z-position:
303 rot[2] = row0 + padRow * fRowPadSize;
304
305 // Rotate back to original position
306 return RotateBack(idet,rot,global);
307
308}
309
310//_____________________________________________________________________________
311Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
312 , Float_t *local, Float_t *global)
313{
314 //
315 // Converts local pad-coordinates (row,col,time) into
316 // global ALICE reference frame coordinates (x,y,z)
317 //
318
319 Int_t idet = GetDetector(iplan,icham,isect); // Detector number
320
321 Float_t padRow = local[0]; // Pad Row position
322 Float_t padCol = local[1]; // Pad Column position
323 Float_t timeSlice = local[2]; // Time "position"
324
325 Float_t row0 = GetRow0(iplan,icham,isect);
326 Float_t col0 = GetCol0(iplan);
327 Float_t time0 = GetTime0(iplan);
328
329 Float_t rot[3];
330
331 // calculate (x,y,z) position in rotated chamber
332 rot[1] = col0 + padCol * fColPadSize;
333 rot[0] = time0 + timeSlice * fTimeBinSize;
334 rot[2] = row0 + padRow * fRowPadSize;
335
336 // Rotate back to original position
337 return RotateBack(idet,rot,global);
338
339}
340
341//_____________________________________________________________________________
342Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot)
343{
344 //
345 // Rotates all chambers in the position of sector 0 and transforms
346 // the coordinates in the ALICE restframe <pos> into the
347 // corresponding local frame <rot>.
348 //
349
350 Int_t sector = GetSector(d);
351
352 Float_t phi = -2.0 * kPI / (Float_t) kNsect * ((Float_t) sector + 0.5);
353
354 rot[0] = pos[0] * TMath::Cos(phi) + pos[1] * TMath::Sin(phi);
355 rot[1] = -pos[0] * TMath::Sin(phi) + pos[1] * TMath::Cos(phi);
356 rot[2] = pos[2];
357
358 return kTRUE;
359
360}
361
362//_____________________________________________________________________________
363Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos)
364{
365 //
366 // Rotates a chambers from the position of sector 0 into its
367 // original position and transforms the corresponding local frame
368 // coordinates <rot> into the coordinates of the ALICE restframe <pos>.
369 //
370
371 Int_t sector = GetSector(d);
372
373 Float_t phi = 2.0 * kPI / (Float_t) kNsect * ((Float_t) sector + 0.5);
374
375 rot[0] = pos[0] * TMath::Cos(phi) + pos[1] * TMath::Sin(phi);
376 rot[1] = -pos[0] * TMath::Sin(phi) + pos[1] * TMath::Cos(phi);
377 rot[2] = pos[2];
378
379 return kTRUE;
380
381}
382
383//_____________________________________________________________________________
384Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s)
385{
386 //
387 // Convert plane / chamber / sector into detector number
388 //
389
390 return (p + c * kNplan + s * kNplan * kNcham);
391
392}
393
394//_____________________________________________________________________________
395Int_t AliTRDgeometry::GetPlane(Int_t d)
396{
397 //
398 // Reconstruct the plane number from the detector number
399 //
400
401 return ((Int_t) (d % kNplan));
402
403}
404
405//_____________________________________________________________________________
406Int_t AliTRDgeometry::GetChamber(Int_t d)
407{
408 //
409 // Reconstruct the chamber number from the detector number
410 //
411
412 return ((Int_t) (d % (kNplan * kNcham)) / kNplan);
413
414}
415
416//_____________________________________________________________________________
417Int_t AliTRDgeometry::GetSector(Int_t d)
418{
419 //
420 // Reconstruct the sector number from the detector number
421 //
422
423 return ((Int_t) (d / (kNplan * kNcham)));
424
425}
426
427//_____________________________________________________________________________
428void AliTRDgeometry::GetGlobal(const AliRecPoint *p, TVector3 &pos, TMatrix &mat)
429{
430 //
431 // Returns the global coordinate and error matrix of a AliTRDrecPoint
432 //
433
434 GetGlobal(p,pos);
435
436}
437
438//_____________________________________________________________________________
439void AliTRDgeometry::GetGlobal(const AliRecPoint *p, TVector3 &pos)
440{
441 //
442 // Returns the global coordinate and error matrix of a AliTRDrecPoint
443 //
444
445 Int_t detector = ((AliTRDrecPoint *) p)->GetDetector();
446
447 Float_t global[3];
448 Float_t local[3];
449 local[0] = pos.X();
450 local[1] = pos.Y();
451 local[2] = pos.Z();
452
453 if (Local2Global(detector,local,global)) {
454 pos.SetX(global[0]);
455 pos.SetY(global[1]);
456 pos.SetZ(global[2]);
457 }
458 else {
459 pos.SetX(0.0);
460 pos.SetY(0.0);
461 pos.SetZ(0.0);
462 }
463
464}