Use gMC and not pMC everywhere
[u/mrichter/AliRoot.git] / TPC / AliTPCv2.cxx
CommitLineData
fe4da5cc 1///////////////////////////////////////////////////////////////////////////////
2// //
3// Time Projection Chamber version 2 -- detailed TPC and slow simulation //
4// //
5//Begin_Html
6/*
1439f98e 7<img src="picts/AliTPCv2Class.gif">
fe4da5cc 8*/
9//End_Html
10// //
11// //
12///////////////////////////////////////////////////////////////////////////////
13
14#include <TMath.h>
bcac8ae4 15
fe4da5cc 16#include "AliTPCv2.h"
bcac8ae4 17#include "AliTPCD.h"
fe4da5cc 18#include "AliRun.h"
fe4da5cc 19#include "AliConst.h"
8c555625 20
fe4da5cc 21ClassImp(AliTPCv2)
22
23//_____________________________________________________________________________
24AliTPCv2::AliTPCv2(const char *name, const char *title) :
25 AliTPC(name, title)
26{
27 //
28 // Standard constructor for Time Projection Chamber version 2
29 //
30 fIdSens1=0;
31 fIdSens2=0;
32 SetBufferSize(128000);
33}
34
35//_____________________________________________________________________________
36void AliTPCv2::CreateGeometry()
37{
38 //
39 // Create the geometry of Time Projection Chamber version 2
40 //
41 //Begin_Html
42 /*
1439f98e 43 <img src="picts/AliTPCv2.gif">
fe4da5cc 44 */
45 //End_Html
46 //Begin_Html
47 /*
1439f98e 48 <img src="picts/AliTPCv2Tree.gif">
fe4da5cc 49 */
50 //End_Html
51
ad51aeb0 52 Int_t *idtmed = fIdtmed->GetArray()-399;
fe4da5cc 53
8c555625 54 AliTPCParam * fTPCParam = &(fDigParam->GetParam());
55
56 Float_t tana;
fe4da5cc 57 Int_t isll;
58 Float_t rlsl, wlsl, rssl, rlsu, wssl, wlsu, rssu, wssu;
59 Int_t i;
60 Float_t alpha, x, y, z, sec_thick;
61
62 Float_t r1, r2, x1, z0, z1, x2, theta1, theta2, theta3, dm[21];
63 Int_t il, iu;
64 Float_t z_side, zz;
65 Int_t idrotm[100];
66
67 Float_t x0l, x0u;
68 Int_t idr;
69 Float_t thl, opl;
70 Int_t ils, iss;
8c555625 71 Float_t thu, opu;
fe4da5cc 72 Int_t ifl1 = 0, ifl2 = 0;
73 Float_t phi1, phi2, phi3;
74
75 // ---------------------------------------------------
76 // sector specification check
77 // ---------------------------------------------------
78 if (fSecAL >= 0) {
79 ifl1 = 0;
80
81 for (i = 0; i < 6; ++i) {
82 if (fSecLows[i] > 0 && fSecLows[i] <25) {
83 ifl1 = 1;
84 printf("*** SECTOR %d selected\n",fSecLows[i]);
85 }
86 }
87
88 } else {
89 printf("*** ALL LOWER SECTORS SELECTED ***\n");
8c555625 90 ifl1 = 1;
fe4da5cc 91 }
92
93 if (fSecAU >= 0) {
94 ifl2 = 0;
95
96 for (i = 0; i < 12; ++i) {
97 if (fSecUps[i] > 24 && fSecUps[i] < 73) {
98 ifl2 = 1;
99 printf("*** SECTOR %d selected\n",fSecUps[i]);
100 }
101 }
102
103 } else {
104 printf("*** ALL UPPER SECTORS SELECTED ***\n");
8c555625 105 ifl1 = 1;
fe4da5cc 106 }
107
108 if (ifl1 == 0 && ifl2 == 0) {
109 printf("*** ERROR: AT LEAST ONE SECTOR MUST BE SPECIFIED ***\n");
110 printf("!!! PROGRAM STOPPED !!!\n");
111 exit(1);
112 }
113
114 if ((fSecAL < 0 || fSecAU < 0) && fSens >= 0) {
115 printf("** ERROR: STRIPS CANNOT BE SPECIFIED FOR ALL SECTORS **\n");
116 printf("!!! PROGRAM STOPPED !!!\n");
117 exit(1);
118 }
119 // ----------------------------------------------------
120 // FIELD CAGE WITH ENDCAPS - CARBON FIBER
121 // THIS IS ALSO A TPC MOTHER VOLUME
122 // ----------------------------------------------------
123 dm[0] = 76.;
124 dm[1] = 278.;
125 dm[2] = 275.;
126
cfce8870 127 gMC->Gsvolu("TPC ", "TUBE", idtmed[407], dm, 3);
fe4da5cc 128 // -------------------------------------------------------
129 // drift gas Ne/CO2 (90/10 volume) - nonsensitive
130 // field cage thickness = 0.52% X0
131 // ----------------------------------------------------
132 dm[0] = 76.+0.09776;
133 dm[1] = 257.;
134 dm[2] = 250.;
135
cfce8870 136 gMC->Gsvolu("TGAS", "TUBE", idtmed[402], dm, 3);
fe4da5cc 137 // ------------------------------------------------------
138 // "side" gas volume (the same as drift gas),
139 // here the readout chambers are positioned
140 // ------------------------------------------------------
141 dm[2] = 0.5*(275.-250.);
142 z_side = dm[2];
143
cfce8870 144 gMC->Gsvolu("TPSG", "TUBE", idtmed[401], dm, 3);
fe4da5cc 145 // ------------------------------------------------------
146 // HV midplane - 20 microns of mylar
147 // -----------------------------------------------------
148 dm[2] = .001;
149
cfce8870 150 gMC->Gsvolu("TPHV", "TUBE", idtmed[405], dm, 3);
fe4da5cc 151
152 // ====================================================
153 // lower and upper readout chambers
154 // ====================================================
155 // sectros opening angles in degrees
156 // ---------------------------------------------------
157 opl = 30.;
158 opu = 15.;
159 thl = TMath::Tan(opl * .5 * kDegrad);
160 thu = TMath::Tan(opu * .5 * kDegrad);
161 // ---------------------------------------------------
162 // S and L-sectors radii
163 // ---------------------------------------------------
164 rssl = 88.;
165 rssu = 136.;
166 rlsl = 142.;
167 rlsu = 250.;
168 // --------------------------------------------------
169 // Sectors widths
170 // --------------------------------------------------
171 wssl = 46.5;
172 wssu = 72.2;
173 wlsl = 37.;
174 wlsu = 65.4;
175 // ---------------------------------------------------
176 // Sector thickness 25% of X0 (Al)
177 // ---------------------------------------------------
178 sec_thick = 2.225;
179 // ---------------------------------------------------
180 // S-sectors (lower sectors)
181 // ---------------------------------------------------
182 dm[0] = wssl * .5;
183 dm[1] = wssu * .5;
184 dm[2] = sec_thick * .5;
185 dm[3] = (rssu - rssl) * .5;
186
187 x0l = rssl + dm[3];
188
cfce8870 189 gMC->Gsvolu("TRCS", "TRD1", idtmed[399], dm, 4);
fe4da5cc 190 // -----------------------------------------------------
191 // S-sectors --> "gas sectors" - sensitive
192 // -----------------------------------------------------
193 dm[2] = (250.-0.001)/2.;
cfce8870 194 gMC->Gsvolu("TSGA", "TRD1", idtmed[403], dm, 4);
fe4da5cc 195 // -------------------------------------------------------------
196 // Only for the debugging purpose and resolution calculation
197 // Sensitive strips at the pad-row center
198 // -------------------------------------------------------------
199 if (fSens >= 0) {
cfce8870 200 gMC->Gsvolu("TSST", "TRD1", idtmed[403], dm, 0);
fe4da5cc 201 dm[3] = .005;
8c555625 202
203 z0 = rssl + (rssu - rssl) * .5;
fe4da5cc 204
8c555625 205 for (iss = 0; iss < fTPCParam->GetNRowLow(); ++iss) {
206 r1 = fTPCParam->GetPadRowRadiiLow(iss);
fe4da5cc 207 r2 = r1 + dm[3] * 2.;
9f84158c 208 dm[0] = r1 * thl - 2.63;
209 dm[1] = r2 * thl - 2.63;
8c555625 210
211 zz = -z0 + r1 +dm[3];
212
cfce8870 213 gMC->Gsposp("TSST", iss+1, "TSGA", 0, 0, zz, 0, "ONLY", dm, 4);
fe4da5cc 214 }
cfce8870 215 gMC->Gsord("TSGA", 3);
fe4da5cc 216 }
217 // ---------------------------------------------------
218 // L-sectors (upper sectors)
219 // ---------------------------------------------------
220 dm[0] = wlsl * .5;
221 dm[1] = wlsu * .5;
222 dm[2] = sec_thick * .5;
223 dm[3] = (rlsu - rlsl) * .5;
224
225 x0u = rlsl + dm[3];
226
cfce8870 227 gMC->Gsvolu("TRCL", "TRD1", idtmed[399], dm, 4);
fe4da5cc 228 // -----------------------------------------------------
229 // L-sectors - "gas sectors" - sensitive!
230 // -----------------------------------------------------
231 dm[2] = (250.-0.001)/2.;
cfce8870 232 gMC->Gsvolu("TLGA", "TRD1", idtmed[403], dm, 4);
fe4da5cc 233 // -------------------------------------------------------------
234 // Only for the debugging purpose and resolution calculation
235 // Sensitive strips at the pad-row center
236 // -------------------------------------------------------------
237 if (fSens >= 0) {
cfce8870 238 gMC->Gsvolu("TLST", "TRD1", idtmed[403], dm, 0);
fe4da5cc 239
240 dm[3] = .005;
8c555625 241
242 z0 = rlsl+ (rlsu - rlsl) * .5;
fe4da5cc 243
8c555625 244 for (ils = 0; ils <fTPCParam->GetNRowUp(); ++ils) {
245 r1 = fTPCParam->GetPadRowRadiiUp(ils);
fe4da5cc 246 r2 = r1 + dm[3] * 2.;
8c555625 247 dm[0] = r1 * thu - 2.63;
248 dm[1] = r2 * thu - 2.63;
249
250 zz = -z0 + r1 +dm[3];
251
cfce8870 252 gMC->Gsposp("TLST", ils+1, "TLGA", 0, 0, zz, 0, "ONLY", dm, 4);
fe4da5cc 253 }
cfce8870 254 gMC->Gsord("TLGA", 3);
fe4da5cc 255 }
256 // ******************************************************
257 // ------------------------------------------------
258 // positioning of lower sectors (1-12)*2
259 // rotation matrices 1-12
260
261 // the isec_al flag allows to select all (<0) or
262 // only a few (up to 6) sectors
263 // ------------------------------------------------
264 z = (250.+0.001)/2.;
265 z1 = -z_side + sec_thick * .5;
266
267 for (il = 1; il <= 12; ++il) {
268 phi1 = (il - 1) * opl + 270.;
269 if (phi1 > 360.) {
270 phi1 += -360.;
271 }
272 theta1 = 90.;
273 phi2 = 90.;
274 theta2 = 180.;
275 phi3 = (il - 1) * opl;
276 theta3 = 90.;
277
278 idr = il;
279 AliMatrix(idrotm[idr], theta1, phi1, theta2, phi2, theta3, phi3);
280
281 alpha = (il - 1) * opl * kDegrad;
282 x = x0l * TMath::Cos(alpha);
283 y = x0l * TMath::Sin(alpha);
284
285 if (fSecAL < 0) {
286 // -----------------------------------------------------------
287 // position ALL lower sectors
288 // -----------------------------------------------------------
cfce8870 289 gMC->Gspos("TSGA", il, "TGAS", x, y, z, idrotm[idr], "ONLY");
290 gMC->Gspos("TSGA",il+12 , "TGAS", x, y, -z, idrotm[idr], "ONLY");
fe4da5cc 291 } else {
292 // -----------------------------------------------------------
293 // position selected lower sectors
294 // -----------------------------------------------------------
295 for (isll = 1; isll <= 6; ++isll) {
296 if (fSecLows[isll - 1] == il) {
cfce8870 297 gMC->Gspos("TSGA", il, "TGAS", x, y, z, idrotm[idr], "ONLY");
fe4da5cc 298 } else if (fSecLows[isll - 1] == il + 12) {
cfce8870 299 gMC->Gspos("TSGA",il+12 , "TGAS", x, y, -z, idrotm[idr],"ONLY");
fe4da5cc 300 }
301 }
302 }
303
cfce8870 304 gMC->Gspos("TRCS", il, "TPSG", x, y, z1, idrotm[idr], "ONLY");
fe4da5cc 305
306 }
307 // ----------------------------------------------------
308 // positioning of upper sectors (1-24)*2
309 // rotation matrices 13-36
310 // the isec_au flag allows to select all (<0) or
311 // only a few (up to 12) sectors
312 // ----------------------------------------------------
313 for (iu = 1; iu <= 24; ++iu) {
314 phi1 = (iu - 1) * opu + 270.;
315 if (phi1 > 360.) {
316 phi1 += -360.;
317 }
318 theta1 = 90.;
319 phi2 = 90.;
320 theta2 = 180.;
321 phi3 = (iu - 1) * opu;
322 theta3 = 90.;
323
324 idr = iu + 12;
325 AliMatrix(idrotm[idr], theta1, phi1, theta2, phi2, theta3, phi3);
326
327 alpha = (iu - 1) * opu * kDegrad;
328 x = x0u * TMath::Cos(alpha);
329 y = x0u * TMath::Sin(alpha);
330
331 if (fSecAU < 0) {
332 // -------------------------------------------------------------
333 // position ALL upper sectors
334 // -------------------------------------------------------------
cfce8870 335 gMC->Gspos("TLGA", iu, "TGAS", x, y, z, idrotm[idr], "ONLY");
336 gMC->Gspos("TLGA",iu+24 , "TGAS", x, y, -z, idrotm[idr], "ONLY");
fe4da5cc 337 } else {
338 // -------------------------------------------------------------
339 // position selected upper sectors
340 // -------------------------------------------------------------
341 for (isll = 1; isll <= 12; ++isll) {
342 if (fSecUps[isll - 1] == iu + 24) {
cfce8870 343 gMC->Gspos("TLGA", iu, "TGAS", x, y, z, idrotm[idr], "ONLY");
fe4da5cc 344 } else if (fSecUps[isll - 1] == iu + 48) {
cfce8870 345 gMC->Gspos("TLGA",iu+24 , "TGAS", x, y, -z, idrotm[idr],"ONLY");
fe4da5cc 346 }
347 }
348 }
349
cfce8870 350 gMC->Gspos("TRCL", iu, "TPSG", x, y, z1, idrotm[idr], "ONLY");
fe4da5cc 351 }
352 // --------------------------------------------------------
353 // Spoke wheel structures
354 // --------------------------------------------------------
cfce8870 355 gMC->Gsvolu("TSWS", "TUBE", idtmed[399], dm, 0);
fe4da5cc 356
357 z0 = -z_side + 2.;
358
359 dm[0] = 82.;
360 dm[1] = 86.;
361 dm[2] = 1.;
362
cfce8870 363 gMC->Gsposp("TSWS", 1, "TPSG", 0, 0, z0, 0, "ONLY", dm, 3);
fe4da5cc 364
365 dm[0] = 253.;
366 dm[1] = 257.;
367
cfce8870 368 gMC->Gsposp("TSWS", 2, "TPSG", 0, 0, z0, 0, "ONLY", dm, 3);
fe4da5cc 369
370 dm[0] = 140.9;
371 dm[1] = 141.9;
372
cfce8870 373 gMC->Gsposp("TSWS", 3, "TPSG", 0, 0, z0, 0, "ONLY", dm, 3);
fe4da5cc 374
375 // -------------------------------------------------------
376 // this volumes are to avoid overlaping
377 // -------------------------------------------------------
378 z0 = 253.;
379
380 dm[0] = 76.;
381 dm[1] = 76.+0.09776;
382
cfce8870 383 gMC->Gsposp("TSWS", 4, "TPC ", 0, 0, z0, 0, "ONLY", dm, 3);
384 gMC->Gsposp("TSWS", 5, "TPC ", 0, 0, -z0, 0, "ONLY", dm, 3);
fe4da5cc 385
386 z0 += 21.;
387
cfce8870 388 gMC->Gsposp("TSWS", 6, "TPC ", 0, 0, z0, 0, "ONLY", dm, 3);
389 gMC->Gsposp("TSWS", 7, "TPC ", 0, 0, -z0, 0, "ONLY", dm, 3);
fe4da5cc 390
391 dm[0] = 257.;
392 dm[1] = 257.+0.09776;
393 dm[2] = 11.5;
394
395 z0 = 263.5;
396
cfce8870 397 gMC->Gsposp("TSWS", 8, "TPC ", 0, 0, z0, 0, "ONLY", dm, 3);
398 gMC->Gsposp("TSWS", 9, "TPC ", 0, 0, -z0, 0, "ONLY", dm, 3);
fe4da5cc 399 // ==========================================================
400 // wheels
401 // ==========================================================
402 // ----------------------------------------------------------
403 // Large wheel -> positioned in the TPC
404 // ----------------------------------------------------------
405 dm[0] = 257.+0.09776;
406 dm[1] = 278.;
407 dm[2] = 11.5;
cfce8870 408 gMC->Gsvolu("TPW1", "TUBE", idtmed[399], dm, 3);
fe4da5cc 409
410 dm[0] = 259.;
411 dm[1] = 278.;
412 dm[2] = 9.5;
413
cfce8870 414 gMC->Gsvolu("TPW2", "TUBE", idtmed[498], dm, 3);
fe4da5cc 415
cfce8870 416 gMC->Gspos("TPW2", 1, "TPW1", 0, 0, 0, 0, "ONLY");
fe4da5cc 417
cfce8870 418 gMC->Gspos("TPW1", 1, "TPC ", 0, 0, z0, 0, "ONLY");
419 gMC->Gspos("TPW1", 2, "TPC ", 0, 0, -z0, 0, "ONLY");
fe4da5cc 420 // -----------------------------------------------------------
421 // Small wheel -> positioned in the TPSG
422 // -----------------------------------------------------------
423 dm[0] = 76.+0.09776;
424 dm[1] = 82.;
425 dm[2] = 11.5;
426
cfce8870 427 gMC->Gsvolu("TPW3", "TUBE", idtmed[399], dm, 3);
fe4da5cc 428
429 dm[0] = 76.+0.09776;
430 dm[1] = 80.;
431 dm[2] = 9.5;
432
cfce8870 433 gMC->Gsvolu("TPW4", "TUBE", idtmed[401], dm, 3);
fe4da5cc 434
cfce8870 435 gMC->Gspos("TPW4", 1, "TPW3", 0, 0, 0, 0, "ONLY");
fe4da5cc 436
437 z0 = 1.;
438
cfce8870 439 gMC->Gspos("TPW3", 1, "TPSG", 0, 0, z0, 0, "ONLY");
fe4da5cc 440 // ---------------------------------------------------------
441 // spokes, inner and outer, also the inner ring
442 // ---------------------------------------------------------
443 dm[0] = 0.5*(135.9-82.1);
444 dm[1] = 3.;
445 dm[2] = 2.;
446
447 x1 = dm[0] + 82.;
448
cfce8870 449 gMC->Gsvolu("TSPI", "BOX ", idtmed[399], dm, 3);
fe4da5cc 450
451 dm[1] = 2.;
452 dm[2] = 1.;
453
cfce8870 454 gMC->Gsvolu("TSP1", "BOX ", idtmed[498], dm, 3);
fe4da5cc 455
cfce8870 456 gMC->Gspos("TSP1", 1, "TSPI", 0, 0, 0, 0, "ONLY");
fe4da5cc 457
458 dm[0] = 0.5*(256.9-142.1);
459 dm[1] = 3.;
460 dm[2] = 2.;
461
462 x2 = dm[0] + 142.;
463
cfce8870 464 gMC->Gsvolu("TSPO", "BOX ", idtmed[399], dm, 3);
fe4da5cc 465
466 dm[1] = 2.;
467 dm[2] = 1.;
468
cfce8870 469 gMC->Gsvolu("TSP2", "BOX ", idtmed[498], dm, 3);
fe4da5cc 470
cfce8870 471 gMC->Gspos("TSP2", 1, "TSPO", 0, 0, 0, 0, "ONLY");
fe4da5cc 472 // --------------------------------------------------------
473 dm[0] = 136.;
474 dm[1] = 142.;
475 dm[2] = 2.;
476
cfce8870 477 gMC->Gsvolu("TSWH", "TUBE", idtmed[399], dm, 3);
fe4da5cc 478
479 dm[0] = 137.;
480 dm[1] = 141.;
481 dm[2] = 1.;
482
cfce8870 483 gMC->Gsvolu("TSW1", "TUBE", idtmed[498], dm, 3);
fe4da5cc 484
cfce8870 485 gMC->Gspos("TSW1", 1, "TSWH", 0, 0, 0, 0, "ONLY");
fe4da5cc 486
487 z0 = z_side - .16168 - 2.;
488 // --------------------------------------------------------
cfce8870 489 gMC->Gspos("TSWH", 1, "TPSG", 0, 0, z0, 0, "ONLY");
fe4da5cc 490 // -------------------------------------------------------
491 // posiioning of the inner spokes
492 // -------------------------------------------------------
493 for (il = 1; il <= 6; ++il) {
494 phi1 = opl * .5 + (il - 1) * 2. * opl;
495 theta1 = 90.;
496 phi2 = opl * .5 + 90. + (il - 1) * 2. * opl;
497 if (phi2 > 360.) {
498 phi2 += -360.;
499 }
500 theta2 = 90.;
501 phi3 = 0.;
502 theta3 = 0.;
503
504 alpha = phi1 * kDegrad;
505 x = x1 * TMath::Cos(alpha);
506 y = x1 * TMath::Sin(alpha);
507
508 idr = il + 36;
509
510 AliMatrix(idrotm[idr], theta1, phi1, theta2, phi2, theta3, phi3);
cfce8870 511 gMC->Gspos("TSPI", il, "TPSG", x, y, z0, idrotm[idr], "ONLY");
fe4da5cc 512
513 }
514
515 for (iu = 1; iu <= 12; ++iu) {
516 phi1 = opu * .5 + (iu - 1) * 2. * opu;
517 theta1 = 90.;
518 phi2 = opu * .5 + 90. + (iu - 1) * 2. * opu;
519 if (phi2 > 360.) {
520 phi2 += -360.;
521 }
522 theta2 = 90.;
523 phi3 = 0.;
524 theta3 = 0.;
525
526 alpha = phi1 * kDegrad;
527 x = x2 * TMath::Cos(alpha);
528 y = x2 * TMath::Sin(alpha);
529
530 idr = iu + 42;
531
532 AliMatrix(idrotm[idr], theta1, phi1, theta2, phi2, theta3, phi3);
cfce8870 533 gMC->Gspos("TSPO", iu, "TPSG", x, y, z0, idrotm[idr], "ONLY");
fe4da5cc 534 }
535 // --------------------------------------------------------
536 // endcap cover (C, 0.86% X0)
537 // --------------------------------------------------------
538 dm[0] = 76.+0.09776;
539 dm[1] = 257.;
540 dm[2] = 0.16168*0.5;
541
cfce8870 542 gMC->Gsvolu("TCOV", "TUBE", idtmed[407], dm, 3);
fe4da5cc 543
544 z0 = z_side - dm[2];
545
cfce8870 546 gMC->Gspos("TCOV", 1, "TPSG", 0, 0, z0, 0, "ONLY");
fe4da5cc 547 // --------------------------------------------------------
548 // put the readout chambers into the TPC
549 // --------------------------------------------------------
550 theta1 = 90.;
551 phi1 = 0.;
552 theta2 = 90.;
553 phi2 = 270.;
554 theta3 = 180.;
555 phi3 = 0.;
556
557 AliMatrix(idrotm[55], theta1, phi1, theta2, phi2, theta3, phi3);
558
559 z0 = z_side + 250.;
560
cfce8870 561 gMC->Gspos("TPSG", 1, "TPC ", 0, 0, z0, 0, "ONLY");
562 gMC->Gspos("TPSG", 2, "TPC ", 0, 0, -z0, idrotm[55], "ONLY");
fe4da5cc 563 // ---------------------------------------------------------
564 // outer gas insulation (CO2)
565 // ---------------------------------------------------------
566 dm[0] = 257.+0.09776;
567 dm[1] = 278.-0.25004;
568 dm[2] = 275.-23.;
569
cfce8870 570 gMC->Gsvolu("TPOI", "TUBE", idtmed[406], dm, 3);
fe4da5cc 571
cfce8870 572 gMC->Gspos("TPHV", 1, "TGAS", 0, 0, 0, 0, "ONLY");
573 gMC->Gspos("TGAS", 1, "TPC ", 0, 0, 0, 0, "ONLY");
574 gMC->Gspos("TPOI", 1, "TPC ", 0, 0, 0, 0, "ONLY");
fe4da5cc 575
cfce8870 576 gMC->Gspos("TPC ", 1, "ALIC", 0, 0, 0, 0, "ONLY");
fe4da5cc 577 // ======================================================
578 // all volumes below are positioned in ALIC
579 // ======================================================
580 // ------------------------------------------------------
581 // the last parts of the smaller wheel (TSWS)
582 // ------------------------------------------------------
583 dm[0] = 74.;
584 dm[1] = 76.;
585 dm[2] = 1.;
586
587 z0 = 253.;
588
cfce8870 589 gMC->Gsposp("TSWS", 10, "TPC ", 0, 0, z0, 0, "ONLY", dm, 3);
590 gMC->Gsposp("TSWS", 11, "TPC ", 0, 0, -z0, 0, "ONLY", dm, 3);
fe4da5cc 591
592 dm[0] = 70.;
593
594 z0 += 21.;
595
cfce8870 596 gMC->Gsposp("TSWS", 12, "TPC ", 0, 0, z0, 0, "ONLY", dm, 3);
597 gMC->Gsposp("TSWS", 13, "TPC ", 0, 0, -z0, 0, "ONLY", dm, 3);
fe4da5cc 598 // ----------------------------------------------------
599 // Inner vessel (PCON)
600 // This volume is to be positioned directly in ALIC
601 // ----------------------------------------------------
602 dm[0] = 0.;
603 dm[1] = 360.;
604 dm[2] = 4.;
605
606 dm[3] = -250.;
607 dm[4] = 75.;
608 dm[5] = 76.;
609
610 dm[6] = -64.5;
611 dm[7] = 50.;
612 dm[8] = 76.;
613
614 dm[9] = 64.5;
615 dm[10] = 50.;
616 dm[11] = 76.;
617
618 dm[12] = 250.;
619 dm[13] = 75.;
620 dm[14] = 76.;
621
cfce8870 622 gMC->Gsvolu("TPIV", "PCON", idtmed[407], dm, 15);
fe4da5cc 623 // --------------------------------------------------------
624 // fill the inner vessel with CO2, (HV kDegrader)
625 // cone parts have different thickness
626 // than the central barrel, according to the TP
627 // --------------------------------------------------------
628 tana = 75./185.5;
629
630 dm[0] = 0.;
631 dm[1] = 360.;
632 dm[2] = 6.;
633
634 dm[3] = -(250.-0.2162);
635 dm[4] = (185.5-0.2126)*tana+0.2126;
636 dm[5] = 76-0.001;
637
638 dm[6] = -64.5;
639 dm[7] = 50.+0.2162;
640 dm[8] = 76-0.001;
641
642 dm[9] = -64.5;
643 dm[10] = 50+0.05076;
644 dm[11] = 76-0.001;
645
646 dm[12] = 64.5;
647 dm[13] = 50+0.05076;
648 dm[14] = 76-0.001;
649
650 dm[15] = 64.5;
651 dm[16] = 50.+0.2162;
652 dm[17] = 76-0.001;
653
654 dm[18] = (250.-0.2162);
655 dm[19] = (185.5-0.2126)*tana+0.2126;
656 dm[20] = 76-0.001;
657
cfce8870 658 gMC->Gsvolu("TPVD", "PCON", idtmed[406], dm, 21);
fe4da5cc 659
cfce8870 660 gMC->Gspos("TPVD", 1, "TPIV", 0, 0, 0, 0, "ONLY");
fe4da5cc 661
cfce8870 662 gMC->Gspos("TPIV", 1, "ALIC", 0, 0, 0, 0, "ONLY");
fe4da5cc 663 // ---------------------------------------------------
664 // volumes ordering
665 // ---------------------------------------------------
cfce8870 666 gMC->Gsord("TGAS", 6);
667 gMC->Gsord("TPSG", 6);
fe4da5cc 668}
669
670//_____________________________________________________________________________
8c555625 671void AliTPCv2::DrawDetector()
fe4da5cc 672{
673 //
674 // Draw a shaded view of the Time Projection Chamber version 1
675 //
676
fe4da5cc 677 // Set everything unseen
cfce8870 678 gMC->Gsatt("*", "seen", -1);
fe4da5cc 679 //
680 // Set ALIC mother transparent
cfce8870 681 gMC->Gsatt("ALIC","SEEN",0);
fe4da5cc 682 //
683 // Set the volumes visible
cfce8870 684 gMC->Gsatt("TPC","SEEN",0);
685 gMC->Gsatt("TGAS","SEEN",0);
686 gMC->Gsatt("TPSG","SEEN",0);
687 gMC->Gsatt("TPHV","SEEN",1);
688 gMC->Gsatt("TRCS","SEEN",1);
689 gMC->Gsatt("TRCL","SEEN",1);
690 gMC->Gsatt("TSWS","SEEN",1);
691 gMC->Gsatt("TPW1","SEEN",1);
692 gMC->Gsatt("TPW3","SEEN",1);
693 gMC->Gsatt("TSPI","SEEN",1);
694 gMC->Gsatt("TSPO","SEEN",1);
695 gMC->Gsatt("TSWH","SEEN",1);
696 gMC->Gsatt("TPOI","SEEN",1);
697 gMC->Gsatt("TPIV","SEEN",1);
698 gMC->Gsatt("TPVD","SEEN",1);
fe4da5cc 699 //
cfce8870 700 gMC->Gdopt("hide", "on");
701 gMC->Gdopt("shad", "on");
702 gMC->Gsatt("*", "fill", 7);
703 gMC->SetClipBox(".");
704 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
705 gMC->DefaultRange();
706 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .025, .025);
707 gMC->Gdhead(1111, "Time Projection Chamber");
708 gMC->Gdman(18, 4, "MAN");
709 gMC->Gdopt("hide","off");
fe4da5cc 710}
711
712//_____________________________________________________________________________
713void AliTPCv2::CreateMaterials()
714{
715 //
716 // Define materials for version 2 of the Time Projection Chamber
717 //
718
fe4da5cc 719 //
720 // Increase maximum number of steps
cfce8870 721 gMC->SetMaxNStep(30000);
fe4da5cc 722 //
723 AliTPC::CreateMaterials();
724}
725
726//_____________________________________________________________________________
727void AliTPCv2::Init()
728{
729 //
730 // Initialises version 2 of the TPC after that it has been built
731 //
ad51aeb0 732 Int_t *idtmed = fIdtmed->GetArray()-399;
fe4da5cc 733 AliTPC::Init();
cfce8870 734 fIdSens1=gMC->VolId("TLGA"); // L-sector
735 fIdSens2=gMC->VolId("TSGA"); // S-sector
736 fIdSens3=gMC->VolId("TSST"); // strip - S-sector (not always used)
737 fIdSens4=gMC->VolId("TLST"); // strip - S-sector (not always used)
fe4da5cc 738
cfce8870 739 gMC->SetMaxNStep(30000); // max. number of steps increased
fe4da5cc 740
cfce8870 741 gMC->Gstpar(idtmed[403],"LOSS",5);
fe4da5cc 742
743 printf("*** TPC version 2 initialized ***\n");
cfce8870 744 printf("Maximum number of steps = %d\n",gMC->GetMaxNStep());
fe4da5cc 745
746 //
747
748}
749
750//_____________________________________________________________________________
751void AliTPCv2::StepManager()
752{
753 //
754 // Called for every step in the Time Projection Chamber
755 //
756
757 //
758 // parameters used for the energy loss calculations
759 //
760 const Float_t prim = 14.35; // number of primary collisions per 1 cm
761 const Float_t poti = 20.77e-9; // first ionization potential for Ne/CO2
762 const Float_t w_ion = 35.97e-9; // energy for the ion-electron pair creation
763
764
765 const Float_t big = 1.e10;
766
767 Int_t id,copy;
768 Float_t hits[4];
769 Int_t vol[2];
770 TClonesArray &lhits = *fHits;
fe4da5cc 771
772 vol[1]=0;
773
774 //
775
cfce8870 776 gMC->SetMaxStep(big);
fe4da5cc 777
cfce8870 778 if(!gMC->TrackAlive()) return; // particle has disappeared
fe4da5cc 779
cfce8870 780 Float_t charge = gMC->TrackCharge();
fe4da5cc 781
782 if(TMath::Abs(charge)<=0.) return; // take only charged particles
783
784
cfce8870 785 id=gMC->CurrentVol(0, copy);
fe4da5cc 786
787 // Check the sensitive volume
788
789 if(id == fIdSens1)
790 {
791 vol[0] = copy + 24; // L-sector number
792 }
793 else if(id == fIdSens2)
794 {
795 vol[0] = copy; // S-sector number
796 }
cfce8870 797 else if(id == fIdSens3 && gMC->TrackEntering())
fe4da5cc 798 {
799 vol[1] = copy; // row number
cfce8870 800 id = gMC->CurrentVolOff(1,0,copy);
fe4da5cc 801 vol[0] = copy; // sector number (S-sector)
802
cfce8870 803 gMC->TrackPosition(hits);
fe4da5cc 804 hits[3]=0.; // this hit has no energy loss
805 new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
806 }
cfce8870 807 else if(id == fIdSens4 && gMC->TrackEntering())
fe4da5cc 808 {
809 vol[1] = copy; // row number
cfce8870 810 id = gMC->CurrentVolOff(1,0,copy);
fe4da5cc 811 vol[0] = copy+24; // sector number (L-sector)
812
cfce8870 813 gMC->TrackPosition(hits);
fe4da5cc 814 hits[3]=0.; // this hit has no energy loss
815 new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
816 }
817 else return;
818
819 //
820 // charged particle is in the sensitive volume
821 //
822
cfce8870 823 if(gMC->TrackStep() > 0) {
fe4da5cc 824
cfce8870 825 Int_t nel = (Int_t)(((gMC->Edep())-poti)/w_ion) + 1;
fe4da5cc 826 nel=TMath::Min(nel,300); // 300 electrons corresponds to 10 keV
827
cfce8870 828 gMC->TrackPosition(hits);
fe4da5cc 829 hits[3]=(Float_t)nel;
830
831 // Add this hit
832
833 new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
834
835 }
836
837 // Stemax calculation for the next step
838
839 Float_t pp;
840 Float_t vect[4];
cfce8870 841 gMC->TrackMomentum(vect);
fe4da5cc 842 Float_t ptot = vect[3];
cfce8870 843 Float_t beta_gamma = ptot/(gMC->TrackMass());
fe4da5cc 844
cfce8870 845 if(gMC->TrackPid() <= 3 && ptot > 0.002)
fe4da5cc 846 {
847 pp = prim*1.58; // electrons above 20 MeV/c are on the plateau!
848 }
849 else
850 {
851 pp=prim*BetheBloch(beta_gamma);
852 if(TMath::Abs(charge) > 1.) pp *= (charge*charge);
853 }
854
855 Float_t random[1];
cfce8870 856 gMC->Rndm(random,1); // good, old GRNDM from Geant3
fe4da5cc 857
858 Double_t rnd = (Double_t)random[0];
859
cfce8870 860 gMC->SetMaxStep(-TMath::Log(rnd)/pp);
fe4da5cc 861
862}
863
864//_____________________________________________________________________________
865Float_t AliTPCv2::BetheBloch(Float_t bg)
866{
867 //
868 // Bethe-Bloch energy loss formula
869 //
870 const Double_t p1=0.76176e-1;
871 const Double_t p2=10.632;
872 const Double_t p3=0.13279e-4;
873 const Double_t p4=1.8631;
874 const Double_t p5=1.9479;
875
876 Double_t dbg = (Double_t) bg;
877
878 Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
879
880 Double_t aa = TMath::Power(beta,p4);
881 Double_t bb = TMath::Power(1./dbg,p5);
882
883 bb=TMath::Log(p3+bb);
884
885 return ((Float_t)((p2-aa-bb)*p1/aa));
886}