]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCv3.cxx
removed obsolete AliTPCDigitsDisplay.C
[u/mrichter/AliRoot.git] / TPC / AliTPCv3.cxx
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 Revision 1.11.8.2  2000/04/10 08:36:12  kowal2
19
20 Updated readout chambers
21 Some modifications to StepManager by M. Kowalski
22
23 Revision 1.11.8.1  2000/04/10 07:56:53  kowal2
24 Not used anymore - removed
25
26 Revision 1.11  1999/11/04 17:28:07  fca
27 Correct barrel part of HV Degrader
28
29 Revision 1.10  1999/10/14 16:52:08  fca
30 Only use PDG codes and not GEANT ones
31
32 Revision 1.9  1999/10/08 06:27:23  fca
33 Corrected bug in the HV degrader geometry, thanks to G.Tabary
34
35 Revision 1.8  1999/10/04 13:39:55  fca
36 Correct array index problem
37
38 Revision 1.7  1999/09/29 09:24:34  fca
39 Introduction of the Copyright and cvs Log
40
41 */
42
43 ///////////////////////////////////////////////////////////////////////////////
44 //                                                                           //
45 //  Time Projection Chamber version 3 -- detailed TPC and slow simulation    //
46 //                                                                           //
47 //Begin_Html
48 /*
49 <img src="picts/AliTPCv3Class.gif">
50 */
51 //End_Html
52 //                                                                           //
53 //                                                                           //
54 ///////////////////////////////////////////////////////////////////////////////
55
56 #include <stdlib.h>
57 #include <TMath.h>
58 #include "AliTPCv3.h"
59 #include "AliRun.h"
60 #include "AliConst.h"
61 #include "AliTPCDigitsArray.h"
62 #include"AliTPCParam.h"
63 #include "AliPDG.h"
64
65 ClassImp(AliTPCv3)
66  
67 //_____________________________________________________________________________
68 AliTPCv3::AliTPCv3(const char *name, const char *title) :
69   AliTPC(name, title) 
70 {
71   //
72   // Standard constructor for Time Projection Chamber version 3
73   //
74
75   SetBufferSize(128000);
76 }
77  
78 //_____________________________________________________________________________
79 void AliTPCv3::CreateGeometry()
80 {
81   //
82   // Creation of the TPC coarse geometry (version 3)
83   // Origin Marek Kowalski Cracow
84   //
85   //Begin_Html
86   /*
87     <img src="picts/AliTPCv0.gif">
88   */
89   //End_Html
90   //Begin_Html
91   /*
92     <img src="picts/AliTPCv0Tree.gif">
93   */
94   //End_Html
95
96   Int_t *idtmed = fIdtmed->GetArray();
97
98   Float_t dm[21];
99   Int_t idrotm[120];
100
101   Int_t nRotMat = 0;
102
103
104   // ---------------------------------------------------- 
105   //          FIELD CAGE WITH ENDCAPS - G10
106   //          THIS IS ALSO A TPC MOTHER VOLUME 
107   // ---------------------------------------------------- 
108
109   dm[0] = 76.;
110   dm[1] = 278.;
111   dm[2] = 275.;
112
113   gMC->Gsvolu("TPC ", "TUBE", idtmed[8], dm, 3); 
114
115   //-----------------------------------------------------
116   //  Endcap cover c-fibre 0.86% X0
117   //-----------------------------------------------------
118
119   dm[0] = 78.;
120   dm[1] = 258.;
121   dm[2] = 0.95;
122
123   gMC->Gsvolu("TPEC","TUBE",idtmed[10],dm,3);
124
125   //-----------------------------------------------------
126   // Drift gas , leave 2 cm at the outer radius
127   // and inner raddius
128   //-----------------------------------------------------
129
130   dm[0] = 78.;
131   dm[1] = 258.;
132   dm[2] = 250.;
133
134   gMC->Gsvolu("TGAS", "TUBE", idtmed[4], dm, 3);
135
136
137   //------------------------------------------------------
138   //  membrane holder - carbon fiber
139   //------------------------------------------------------
140
141
142   gMC->Gsvolu("TPMH","TUBE",idtmed[6],dm,0);
143
144   dm[0] = 252.;
145   dm[1] = 258.;
146   dm[2] = 0.2;
147
148   gMC->Gsposp("TPMH",1,"TGAS",0.,0.,0.,0,"ONLY",dm,3);
149  
150   dm[0] = 78.;
151   dm[1] = 82.;
152   dm[2] = 0.1;
153
154   gMC->Gsposp("TPMH",2,"TGAS",0.,0.,0.,0,"ONLY",dm,3);
155
156   //----------------------------------------------------------
157   //  HV membrane - 25 microns of mylar
158   //----------------------------------------------------------
159
160   dm[0] = 82.;
161   dm[1] = 252.;
162   dm[2] = 0.00125;
163
164   gMC->Gsvolu("TPHV","TUBE",idtmed[5],dm,3);
165
166   gMC->Gspos("TPHV",1,"TGAS",0.,0.,0.,0,"ONLY");
167
168   gMC->Gspos("TGAS",1,"TPC ",0.,0.,0.,0,"ONLY");
169
170   //----------------------------------------------------------
171   // "side" gas volume, the same as the drift gas
172   // the readout chambers are placed there.  
173   //----------------------------------------------------------
174
175   dm[0] = 78.;
176   dm[1] = 258.;
177   dm[2] = 0.5*(275. - 250.);
178    
179   gMC->Gsvolu("TPSG", "TUBE", idtmed[2], dm, 3);
180
181   Float_t z_side = dm[2]; // 1/2 of the side gas thickness
182
183   //-----------------------------------------------------------
184   //   Readout chambers , 25% of X0, I use Al as the material
185   //-----------------------------------------------------------
186
187   Float_t InnerOpenAngle = fTPCParam->GetInnerAngle();
188   Float_t OuterOpenAngle = fTPCParam->GetOuterAngle();
189
190   Float_t InnerAngleShift = fTPCParam->GetInnerAngleShift();
191   Float_t OuterAngleShift = fTPCParam->GetOuterAngleShift();
192
193
194   Int_t nInnerSector = fTPCParam->GetNInnerSector()/2;
195   Int_t nOuterSector = fTPCParam->GetNOuterSector()/2;
196
197
198   Float_t InSecLowEdge = fTPCParam->GetInnerRadiusLow();
199   Float_t InSecUpEdge =  fTPCParam->GetInnerRadiusUp();
200
201   Float_t OuSecLowEdge = fTPCParam->GetOuterRadiusLow();
202   Float_t OuSecUpEdge = fTPCParam->GetOuterRadiusUp();
203
204   Float_t SecThick = 2.225; // Al
205
206   Float_t LowEdge = fTPCParam->GetInnerFrameSpace();
207
208   //  S (Inner) sectors
209
210   dm[0] = InSecLowEdge*TMath::Tan(0.5*InnerOpenAngle)-LowEdge;
211   dm[1] = InSecUpEdge*TMath::Tan(0.5*InnerOpenAngle)-LowEdge;
212   dm[2] = SecThick;
213   dm[3] = 0.5*(InSecUpEdge-InSecLowEdge);
214
215   Float_t xCenterS = InSecLowEdge+dm[3];
216
217   gMC->Gsvolu("TRCS", "TRD1", idtmed[0], dm, 4); 
218
219   //  L (Outer) sectors
220
221   Float_t UpEdge = fTPCParam->GetOuterFrameSpace();
222
223   dm[0] = OuSecLowEdge*TMath::Tan(0.5*OuterOpenAngle)-UpEdge;
224   dm[1] = OuSecUpEdge*TMath::Tan(0.5*OuterOpenAngle)-UpEdge;
225   dm[2] = SecThick;
226   dm[3] = 0.5*(OuSecUpEdge-OuSecLowEdge);
227
228   Float_t xCenterL = OuSecLowEdge+dm[3];  
229
230   gMC->Gsvolu("TRCL", "TRD1", idtmed[0], dm, 4);
231
232   Float_t z1 = -z_side + SecThick*0.5;
233
234   //------------------------------------------------------------------
235   // Positioning of the S-sector readout chambers
236   //------------------------------------------------------------------
237
238   Int_t ns;
239   Float_t theta1,theta2,theta3;
240   Float_t phi1,phi2,phi3;
241   Float_t alpha;
242   Float_t x,y;
243
244   for(ns=0;ns<nInnerSector;ns++){
245     
246     phi1 = ns * InnerOpenAngle + 270.*kDegrad + InnerAngleShift;
247     phi1 *= kRaddeg; // in degrees
248
249     phi1 = (Float_t)TMath::Nint(phi1);
250
251     if (phi1 > 360.) phi1 -= 360.;
252       
253     theta1 = 90.;
254     phi2   = 90.;
255     theta2 = 180.;
256     phi3   = ns * InnerOpenAngle + InnerAngleShift;
257     phi3 *= kRaddeg; // in degrees
258
259     phi3 = (Float_t)TMath::Nint(phi3);
260       
261     if(phi3 > 360.) phi3 -= 360.;
262
263     theta3 = 90.;
264
265     alpha = phi3*kDegrad;
266
267     x = xCenterS * TMath::Cos(alpha);
268     y = xCenterS * TMath::Sin(alpha); 
269  
270     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);  
271      
272     gMC->Gspos("TRCS", ns+1, "TPSG", x, y, z1, idrotm[nRotMat], "ONLY");
273
274     nRotMat++;     
275
276   }
277     
278   //-------------------------------------------------------------------
279   //  Positioning of the L-sectors readout chambers
280   //-------------------------------------------------------------------
281     
282   for(ns=0;ns<nOuterSector;ns++){
283     phi1 = ns * OuterOpenAngle + 270.*kDegrad + OuterAngleShift;
284     phi1 *= kRaddeg; // in degrees
285
286     phi1 = (Float_t)TMath::Nint(phi1);
287     
288
289     if (phi1 > 360.) phi1 -= 360.;
290       
291     theta1 = 90.;
292     phi2   = 90.;
293     theta2 = 180.;
294     phi3   = ns * OuterOpenAngle+OuterAngleShift;
295     phi3 *= kRaddeg; // in degrees
296
297     phi3 = (Float_t)TMath::Nint(phi3);
298
299       
300     if(phi3 > 360.) phi3 -= 360.;
301
302     theta3 = 90.;
303
304     alpha = phi3*kDegrad;
305
306     x = xCenterL * TMath::Cos(alpha);
307     y = xCenterL * TMath::Sin(alpha); 
308  
309     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);  
310      
311
312     gMC->Gspos("TRCL", ns+1, "TPSG", x, y, z1, idrotm[nRotMat], "ONLY"); 
313
314     nRotMat++;   
315
316   }
317
318   Float_t z0 = z_side - 0.95;
319
320   gMC->Gspos("TPEC",1,"TPSG",0.,0.,z0,0,"ONLY");
321
322   // ========================================================== 
323   //                  wheels 
324   // ========================================================== 
325
326   //
327   //  auxilary structures
328   //
329
330
331   gMC->Gsvolu("TPWI","TUBE",idtmed[24],dm,0); // "air" 
332
333   // ---------------------------------------------------------- 
334   //       Large wheel -> positioned in the TPC 
335   // ---------------------------------------------------------- 
336   
337
338   z0 = 263.5; // TPC length - 1/2 spoke wheel width
339
340   dm[0] = 258.;
341   dm[1] = 278.;
342   dm[2] = 11.5;
343   
344   gMC->Gsvolu("TPWL", "TUBE", idtmed[0], dm, 3); 
345
346   dm[0] = dm[0]+2.;
347   dm[1] = 278.;
348   dm[2] = dm[2]-2.;
349
350   gMC->Gsposp("TPWI",1,"TPWL",0.,0.,0.,0,"ONLY",dm,3);
351
352   gMC->Gspos("TPWL", 1, "TPC ", 0, 0, z0, 0, "ONLY");
353   gMC->Gspos("TPWL", 2, "TPC ", 0, 0, -z0, 0, "ONLY");
354
355   //
356   //  Outer vessel + CO2 HV degrader
357   //
358
359   dm[0] = 260.;
360   dm[1] = 278.;
361   dm[2] = 252.;
362
363   gMC->Gsvolu("TPCO","TUBE",idtmed[12],dm,3);
364
365   dm[0] = 275.;
366   dm[1] = 278.;
367   
368   gMC->Gsvolu("TPOV","TUBE",idtmed[10],dm,3);
369
370   gMC->Gspos("TPOV",1,"TPCO",0.,0.,0.,0,"ONLY");
371
372
373   // G10 plugs
374
375   dm[0] = 258.;
376   dm[1] = 260.;
377   dm[2] = 1.;
378
379   gMC->Gsvolu("TPG1","TUBE",idtmed[8],dm,3);
380   gMC->Gspos("TPG1",1,"TPCO",0.,0.,251.,0,"ONLY");
381   gMC->Gspos("TPG1",2,"TPCO",0.,0.,-251.,0,"ONLY");  
382
383   gMC->Gspos("TPCO",1,"TPC ",0.,0.,0.,0,"ONLY");
384
385
386   //----------------------------------------------------------
387   //  Small wheel -> positioned in "side gas
388   //----------------------------------------------------------
389
390   dm[0] = 78.;
391   dm[1] = 82.;
392   dm[2] = 11.5;
393
394   gMC->Gsvolu("TPWS", "TUBE", idtmed[0], dm, 3);
395
396   dm[0] = 78.;
397   dm[1] = dm[1]-2;
398   dm[2] = dm[2]-2.;
399
400   gMC->Gsvolu("TPW1", "TUBE", idtmed[2], dm, 3);
401   
402   gMC->Gspos("TPW1", 1, "TPWS", 0., 0., 0., 0, "ONLY");
403
404   z0 = 1.; // spoke wheel is shifted w.r.t. center of the "side gas"
405
406   gMC->Gspos("TPWS", 1, "TPSG", 0, 0, z0, 0, "ONLY");
407
408
409   // to avoid overlaps
410
411   dm[0] = 76.;
412   dm[1] = 78.;
413   dm[2] = 11.5;
414
415   gMC->Gsvolu("TPS1","TUBE",idtmed[0],dm,3);
416
417   dm[2] = 9.5;
418
419   gMC->Gsvolu("TPS2","TUBE",idtmed[24],dm,3);
420
421   gMC->Gspos("TPS2",1,"TPS1",0.,0.,0.,0,"ONLY");
422
423   z0= 263.5;
424   
425   gMC->Gspos("TPS1",1,"TPC ",0.,0.,z0,0,"ONLY");
426   gMC->Gspos("TPS1",2,"TPC ",0.,0.,-z0,0,"ONLY");
427
428   // G10 plug
429
430   dm[0] = 76.;
431   dm[1] = 78.;
432   dm[2] = 1.;
433
434   gMC->Gsvolu("TPG2","TUBE",idtmed[8],dm,3);
435
436   z0 = 251.;
437
438   gMC->Gspos("TPG2",1,"TPC ",0.,0.,z0,0,"ONLY");
439   gMC->Gspos("TPG2",2,"TPC ",0.,0.,-z0,0,"ONLY");
440
441
442   //---------------------------------------------------------
443   //  central wheel  6 (radial direction) x 4 (along z) cm2
444   //---------------------------------------------------------
445
446   dm[0] = 140.;
447   dm[1] = 146.;
448   dm[2] = 2.;
449
450   gMC->Gsvolu("TPWC","TUBE",idtmed[0],dm,3);
451
452   dm[0] = dm[0] + 2.;
453   dm[1] = dm[1] - 2.;
454   dm[2] = dm[2] - 1.;
455
456   gMC->Gsposp("TPWI",2,"TPWC",0.,0.,0.,0,"ONLY",dm,3);
457
458   z0 = z_side - 1.9 - 2.;
459
460   gMC->Gspos("TPWC",1,"TPSG",0.,0.,z0,0,"ONLY");
461
462   //
463
464   gMC->Gsvolu("TPSE","BOX ",idtmed[24],dm,0); // "empty" part of the spoke 
465
466  
467   //---------------------------------------------------------
468   //  inner spokes (nSectorInner)
469   //---------------------------------------------------------
470
471   dm[0] = 0.5*(139.9-82.1);
472   dm[1] = 3.;
473   dm[2] = 2.;
474
475   Float_t x1 = dm[0]+82.;
476
477   gMC->Gsvolu("TPSI","BOX",idtmed[0],dm,3);
478
479   dm[1] = dm[1]-1.;
480   dm[2] = dm[2]-1.;
481
482   gMC->Gsposp("TPSE",1,"TPSI",0.,0.,0.,0,"ONLY",dm,3);
483
484   for(ns=0;ns<nInnerSector;ns++){
485
486     phi1 = 0.5*InnerOpenAngle + ns*InnerOpenAngle + InnerAngleShift;
487     theta1=90.;
488     phi1 *=kRaddeg;
489
490     phi1 = (Float_t)TMath::Nint(phi1);
491
492     phi2 = phi1+90.;
493     if(phi2>360.) phi2 -= 360.;
494     theta2=90.;
495     phi3=0.;
496     theta3=0.;
497
498     alpha = phi1 * kDegrad;
499     x     = x1 * TMath::Cos(alpha);
500     y     = x1 * TMath::Sin(alpha);    
501
502    AliMatrix(idrotm[nRotMat],theta1,phi1,theta2,phi2,theta3,phi3);
503
504    gMC->Gspos("TPSI",ns+1,"TPSG",x,y,z0,idrotm[nRotMat],"ONLY");  
505
506    nRotMat++;
507
508   }
509
510   //-------------------------------------------------------------
511   // outer spokes (nSectorOuter)
512   //-------------------------------------------------------------
513
514   dm[0] = 0.5*(257.9-146.1);
515   dm[1] = 3.;
516   dm[2] = 2.;
517
518   x1 = dm[0] + 146.;
519
520   gMC->Gsvolu("TPSO","BOX ",idtmed[0],dm,3);
521
522   dm[1] = dm[1] - 1.;
523   dm[2] = dm[2] - 1.;
524
525   gMC->Gsposp("TPSE",2,"TPSO",0.,0.,0.,0,"ONLY",dm,3);
526
527   for(ns=0;ns<nOuterSector;ns++){
528
529     phi1 = 0.5*OuterOpenAngle + ns*OuterOpenAngle + OuterAngleShift;
530     theta1=90.;
531     phi1 *=kRaddeg;
532
533     phi1 = (Float_t)TMath::Nint(phi1);
534
535     phi2 = phi1+90.;
536     if(phi2>360.) phi2 -= 360.;
537     theta2=90.;
538     phi3=0.;
539     theta3=0.;
540
541     alpha = phi1 * kDegrad;
542     x     = x1 * TMath::Cos(alpha);
543     y     = x1 * TMath::Sin(alpha);    
544
545    AliMatrix(idrotm[nRotMat],theta1,phi1,theta2,phi2,theta3,phi3);
546
547    gMC->Gspos("TPSO",ns+1,"TPSG",x,y,z0,idrotm[nRotMat],"ONLY");  
548
549    nRotMat++;
550
551   }  
552   
553
554   
555   // -------------------------------------------------------- 
556   //         put the readout chambers into the TPC 
557   // -------------------------------------------------------- 
558
559   theta1 = 90.;
560   phi1   = 0.;
561   theta2 = 90.;
562   phi2   = 270.;
563   theta3 = 180.;
564   phi3   = 0.;
565   
566   AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
567   
568   z0 = z_side + 250.;
569   
570   gMC->Gspos("TPSG", 1, "TPC ", 0, 0, z0, 0, "ONLY");
571   gMC->Gspos("TPSG", 2, "TPC ", 0, 0, -z0, idrotm[nRotMat], "ONLY");
572   
573   gMC->Gspos("TPC ", 1, "ALIC", 0, 0, 0, 0, "ONLY");
574
575   //----------------------------------------------------
576   //  Inner vessel and HV degrader
577   //----------------------------------------------------
578
579   dm[0] = 0.;
580   dm[1] = 360.;
581   dm[2] = 4.;
582   
583   dm[3] = -250.;
584   dm[4] = 74.4;
585   dm[5] = 76.;
586
587   dm[6] = -64.5;
588   dm[7] = 50.;
589   dm[8] = 76.;
590
591   dm[9] = 64.5;
592   dm[10] = 50.;
593   dm[11] = 76.;
594
595   dm[12] = 250.;
596   dm[13] = 74.4;
597   dm[14] = 76.;
598
599   gMC->Gsvolu("TPVD", "PCON", idtmed[12], dm, 15); // CO2
600
601   // cone parts
602
603   dm[0] = 0.;
604   dm[1] = 360.;
605   dm[2] = 2.;
606
607   dm[3] = 64.5;
608   dm[4] = 50.;
609   dm[5] = 51.6;
610  
611   dm[6] = 250.;
612   dm[7] = 74.4;
613   dm[8] = 76.;
614
615
616   gMC->Gsvolu("TIVC","PCON",idtmed[11],dm,9); // C-fibre
617
618   gMC->Gspos("TIVC",1,"TPVD",0.,0.,0.,0,"ONLY");
619   gMC->Gspos("TIVC",2,"TPVD",0.,0.,0.,idrotm[nRotMat],"ONLY");
620
621   // barrel part
622
623   dm[0] = 50.;
624   dm[1] = 50.5;
625   dm[2] = 64.5;
626
627   gMC->Gsvolu("TIVB","TUBE",idtmed[9],dm,3);
628
629   gMC->Gspos("TIVB",1,"TPVD",0.,0.,0.,0,"ONLY");
630
631   gMC->Gspos("TPVD",1,"ALIC",0.,0.,0.,0,"ONLY");
632
633   
634
635   
636
637   // --------------------------------------------------- 
638   //               volumes ordering 
639   // --------------------------------------------------- 
640   gMC->Gsord("TPSG", 6);
641  
642 } // end of function
643
644  
645  
646 //_____________________________________________________________________________
647 void AliTPCv3::DrawDetector()
648 {
649   //
650   // Draw a shaded view of the Time Projection Chamber version 1
651   //
652
653
654   // Set everything unseen
655   gMC->Gsatt("*", "seen", -1);
656   // 
657   // Set ALIC mother transparent
658   gMC->Gsatt("ALIC","SEEN",0);
659   //
660   // Set the volumes visible
661   gMC->Gsatt("TPC","SEEN",0);
662   gMC->Gsatt("TGAS","SEEN",0);
663   gMC->Gsatt("TPSG","SEEN",0);
664   gMC->Gsatt("TPHV","SEEN",1);
665   gMC->Gsatt("TPMH","SEEN",1);
666   gMC->Gsatt("TPEC","SEEN",0);
667   gMC->Gsatt("TRCS","SEEN",1);
668   gMC->Gsatt("TRCL","SEEN",1);
669   gMC->Gsatt("TPWL","SEEN",1);
670   gMC->Gsatt("TPWI","SEEN",1);
671   gMC->Gsatt("TPWS","SEEN",1);
672   gMC->Gsatt("TPW1","SEEN",1);
673   gMC->Gsatt("TPS1","SEEN",1);
674   gMC->Gsatt("TPS2","SEEN",1);
675   gMC->Gsatt("TPG1","SEEN",1);
676   gMC->Gsatt("TPG2","SEEN",1);
677   gMC->Gsatt("TPWC","SEEN",1);
678   gMC->Gsatt("TPSI","SEEN",1); 
679   gMC->Gsatt("TPSO","SEEN",1);
680   gMC->Gsatt("TPCO","SEEN",1);
681   gMC->Gsatt("TPOV","SEEN",1);
682   gMC->Gsatt("TPVD","SEEN",1);
683   //
684   gMC->Gdopt("hide", "on");
685   gMC->Gdopt("shad", "on");
686   gMC->Gsatt("*", "fill", 7);
687   gMC->SetClipBox(".");
688   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
689   gMC->DefaultRange();
690   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .025, .025);
691   gMC->Gdhead(1111, "Time Projection Chamber");
692   gMC->Gdman(18, 4, "MAN");
693   gMC->Gdopt("hide","off");
694 }
695
696 //_____________________________________________________________________________
697 void AliTPCv3::CreateMaterials()
698 {
699   //
700   // Define materials for version 2 of the Time Projection Chamber
701   //
702
703
704   //
705   // Increase maximum number of steps
706   gMC->SetMaxNStep(30000);
707   //
708   AliTPC::CreateMaterials();
709 }
710
711 //_____________________________________________________________________________
712 void AliTPCv3::Init()
713 {
714   //
715   // Initialises version 3 of the TPC after that it has been built
716   //
717   Int_t *idtmed = fIdtmed->GetArray()-399;
718
719   AliTPC::Init();
720
721   fIdSens1=gMC->VolId("TGAS"); // drift gas as a sensitive volume
722
723   gMC->SetMaxNStep(30000); // max. number of steps increased
724
725   gMC->Gstpar(idtmed[403],"LOSS",5);
726
727   printf("*** TPC version 3 initialized ***\n");
728   printf("Maximum number of steps = %d\n",gMC->GetMaxNStep());
729
730   //
731   
732 }
733
734 //_____________________________________________________________________________
735 void AliTPCv3::StepManager()
736 {
737   //
738   // Called for every step in the Time Projection Chamber
739   //
740
741   //
742   // parameters used for the energy loss calculations
743   //
744   const Float_t prim = 14.35; // number of primary collisions per 1 cm
745   const Float_t poti = 20.77e-9; // first ionization potential for Ne/CO2
746   const Float_t w_ion = 35.97e-9; // energy for the ion-electron pair creation 
747  
748  
749   const Float_t big = 1.e10;
750
751   Int_t id,copy;
752   TLorentzVector pos;
753   Float_t hits[4];
754   Int_t vol[2];  
755   TClonesArray &lhits = *fHits;
756   
757   vol[1]=0;
758   vol[0]=0;
759
760   //
761
762   gMC->SetMaxStep(big);
763   
764   if(!gMC->IsTrackAlive()) return; // particle has disappeared
765   
766   Float_t charge = gMC->TrackCharge();
767   
768   if(TMath::Abs(charge)<=0.) return; // take only charged particles
769   
770   
771   id=gMC->CurrentVolID(copy);
772   
773   // Check the sensitive volume
774   
775   if (id != fIdSens1) return;
776   
777   //
778   //  charged particle is in the sensitive volume
779   //
780   
781   if(gMC->TrackStep() > 0) {
782
783     
784     Int_t nel = (Int_t)(((gMC->Edep())-poti)/w_ion) + 1;
785     nel=TMath::Min(nel,300); // 300 electrons corresponds to 10 keV
786     
787     gMC->TrackPosition(pos);
788     hits[0]=pos[0];
789     hits[1]=pos[1];
790     hits[2]=pos[2];
791
792     //
793     // check the selected side of the TPC
794     //
795  
796     if(fSide && fSide*hits[2]<=0.) return;
797
798     hits[3]=(Float_t)nel;
799     
800     // Add this hit
801    
802     new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
803     
804   } 
805   
806   // Stemax calculation for the next step
807   
808   Float_t pp;
809   TLorentzVector mom;
810   gMC->TrackMomentum(mom);
811   Float_t ptot=mom.Rho();
812   Float_t beta_gamma = ptot/gMC->TrackMass();
813   
814   Int_t pid=gMC->TrackPid();
815   if((pid==kElectron || pid==kPositron) && ptot > 0.002)
816     { 
817       pp = prim*1.58; // electrons above 20 MeV/c are on the plateau!
818     }
819   else
820     {
821       pp=prim*BetheBloch(beta_gamma);    
822       if(TMath::Abs(charge) > 1.) pp *= (charge*charge);
823     }
824   
825   Float_t random[1];
826   gMC->Rndm(random,1); // good, old GRNDM from Geant3
827   
828   Double_t rnd = (Double_t)random[0];
829   
830   gMC->SetMaxStep(-TMath::Log(rnd)/pp);
831   
832 }
833
834 //_____________________________________________________________________________
835 Float_t AliTPCv3::BetheBloch(Float_t bg)
836 {
837   //
838   // Bethe-Bloch energy loss formula
839   //
840   const Double_t p1=0.76176e-1;
841   const Double_t p2=10.632;
842   const Double_t p3=0.13279e-4;
843   const Double_t p4=1.8631;
844   const Double_t p5=1.9479;
845
846   Double_t dbg = (Double_t) bg;
847
848   Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
849
850   Double_t aa = TMath::Power(beta,p4);
851   Double_t bb = TMath::Power(1./dbg,p5);
852
853   bb=TMath::Log(p3+bb);
854   
855   return ((Float_t)((p2-aa-bb)*p1/aa));
856 }