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