]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCv3.cxx
Corrected bug in the inner containment vessel (cones)
[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.24  2001/04/24 11:22:01  kowal2
19 Protection against too small betagamma
20
21 Revision 1.23  2001/04/24 11:17:33  kowal2
22 New TPC geometry.
23
24 Revision 1.22  2001/03/13 13:07:34  kowal2
25 Corrected bug in the TPC mother volume geometry.
26 Thanks to A. Morsch
27
28 Revision 1.21  2000/11/30 11:48:50  kowal2
29 TLorentzVector.h adde to satisfy the latest changes by Federico
30
31 Revision 1.20  2000/11/14 10:48:57  kowal2
32 Correct material used for TSA4. Thanks to J. Barbosa.
33
34 Revision 1.19  2000/11/06 17:24:10  kowal2
35 Corrected bug in the outer containment vessel and
36 the outer field cage geometry.
37 Thanks to J. Barbosa.
38
39 Revision 1.18  2000/11/02 16:55:24  kowal2
40 Corrected bug in the inner containment vessel geometry.
41 Thanks to J. Belikov
42
43 Revision 1.17  2000/11/02 07:24:11  kowal2
44 Correction in the TPC geometry.
45 Changes due to the new hit structure.
46
47 Revision 1.16  2000/10/02 21:28:18  fca
48 Removal of useless dependecies via forward declarations
49
50 Revision 1.15  2000/07/10 20:57:39  hristov
51 Update of TPC code and macros by M.Kowalski
52
53 Revision 1.14  2000/06/30 12:07:50  kowal2
54 Updated from the TPC-PreRelease branch
55
56 Revision 1.13.2.4  2000/06/26 07:39:42  kowal2
57 Changes to obey the coding rules
58
59 Revision 1.13.2.3  2000/06/25 08:38:41  kowal2
60 Splitted from AliTPCtracking
61
62 Revision 1.13.2.2  2000/06/16 12:58:13  kowal2
63 Changed parameter settings
64
65 Revision 1.13.2.1  2000/06/09 07:15:07  kowal2
66
67 Defaults loaded automatically (hard-wired)
68 Optional parameters can be set via macro called in the constructor
69
70 Revision 1.13  2000/05/15 10:00:30  kowal2
71 Corrected bug in the TPC geometry, thanks to Ivana Hrivnacova
72
73 Revision 1.12  2000/04/17 09:37:33  kowal2
74 removed obsolete AliTPCDigitsDisplay.C
75
76 Revision 1.11.8.2  2000/04/10 08:36:12  kowal2
77
78 Updated readout chambers
79 Some modifications to StepManager by M. Kowalski
80
81 Revision 1.11.8.1  2000/04/10 07:56:53  kowal2
82 Not used anymore - removed
83
84 Revision 1.11  1999/11/04 17:28:07  fca
85 Correct barrel part of HV Degrader
86
87 Revision 1.10  1999/10/14 16:52:08  fca
88 Only use PDG codes and not GEANT ones
89
90 Revision 1.9  1999/10/08 06:27:23  fca
91 Corrected bug in the HV degrader geometry, thanks to G.Tabary
92
93 Revision 1.8  1999/10/04 13:39:55  fca
94 Correct array index problem
95
96 Revision 1.7  1999/09/29 09:24:34  fca
97 Introduction of the Copyright and cvs Log
98
99 */
100
101 //
102 ///////////////////////////////////////////////////////////////////////////////
103 //                                                                           //
104 //  Time Projection Chamber version 3 -- detailed TPC and slow simulation    //
105 //                                                                     
106 //Begin_Html
107 /*
108 <img src="picts/AliTPCv3Class.gif">
109 */
110 //End_Html
111 //                                                                           //
112 //                                                                           //
113 ///////////////////////////////////////////////////////////////////////////////
114
115 #include <stdlib.h>
116 #include <TMath.h>
117 #include "AliTPCv3.h"
118 #include "AliRun.h"
119 #include "AliMC.h"
120 #include "AliConst.h"
121 #include "AliTPCDigitsArray.h"
122 #include"AliTPCParam.h"
123 #include"AliTPCParamSR.h"
124 #include "AliPDG.h"
125 #include <TInterpreter.h>
126 #include "TLorentzVector.h"
127 #include "AliTPCTrackHits.h"
128
129 ClassImp(AliTPCv3)
130 //_____________________________________________________________________________
131
132   AliTPCv3::AliTPCv3(){
133
134   fHitType = 1;
135
136
137
138 //_____________________________________________________________________________
139 AliTPCv3::AliTPCv3(const char *name, const char *title) :
140   AliTPC(name, title) 
141 {
142   //
143   // Standard constructor for Time Projection Chamber version 3
144   //
145
146   SetBufferSize(128000);
147   fIdSens=0;
148
149   SetGasMixt(2,20,10,-1,0.9,0.1,0.);
150
151   if (fTPCParam)
152      fTPCParam->Write(fTPCParam->GetTitle());
153
154   fHitType =1;
155 }
156  
157 //_____________________________________________________________________________
158 void AliTPCv3::CreateGeometry()
159 {
160   //
161   // Creation of the TPC coarse geometry (version 3)
162   // The whole drift volume is sensitive
163   // Origin Marek Kowalski Cracow
164   //
165   //Begin_Html
166   /*
167     <img src="picts/AliTPCgif">
168   */
169   //End_Html
170   //Begin_Html
171   /*
172     <img src="picts/AliTPCv3Tree.gif">
173   */
174   //End_Html
175   Float_t dm[50];
176
177   Int_t *idtmed = fIdtmed->GetArray(); // TPC media
178
179   Int_t idrotm[120]; // rotation matrices
180
181   Int_t nRotMat = 0; // actual number of rotation matrices
182
183
184   //
185   //  Mother volume (Air) - all volumes will be positioned in it
186   //
187   
188   dm[0]=0.;
189   dm[1]=360.;
190   dm[2]=8.;
191
192   //
193
194   dm[3]=-283.7;
195   dm[4]=65.6;
196   dm[5]=278.;
197
198   //
199
200   dm[6]=-253.6;
201   dm[7]=65.6;
202   dm[8]=278.;
203
204   //
205
206   dm[9]=-73.3;
207   dm[10]=60.9;
208   dm[11]=278.;  
209
210   //
211
212   dm[12]=-73.3;
213   dm[13]=56.9;
214   dm[14]=278.;
215
216   //
217
218   dm[15]=73.3;
219   dm[16]=56.9;
220   dm[17]=278.;
221
222   //
223
224   dm[18]=73.3;
225   dm[19]=60.9;
226   dm[20]=278.;
227
228   //
229
230   dm[21]=253.6;
231   dm[22]=65.6;
232   dm[23]=278.;
233
234   //
235
236   dm[24]=283.7;
237   dm[25]=65.6;
238   dm[26]=278.;
239   
240   gMC->Gsvolu("TPC ","PCON",idtmed[0],dm,27);
241
242   // outer part
243
244   //-------------------------------------------------------------------
245   //   Tpc Outer INsulator (CO2) - contains cont. vessel and field cage
246   //-------------------------------------------------------------------
247
248   dm[0]= 0.;
249   dm[1]= 360.;
250   dm[2]= 6.;
251
252   //
253
254   dm[3]=-253.6;
255   dm[4]=258.;
256   dm[5]=275.5;
257
258   //
259
260   dm[6]=-250.6;
261   dm[7]=258.;
262   dm[8]=275.5; 
263
264   //
265
266   dm[9]=-250.6;
267   dm[10]=258.;
268   dm[11]=278.;
269
270   //
271
272   dm[12]=253.6;
273   dm[13]=258.;
274   dm[14]=278.; 
275
276   //
277
278   dm[15]=253.6;
279   dm[16]=264.8;
280   dm[17]=278.;  
281
282   //
283
284   dm[18]=256.6;
285   dm[19]=264.8;
286   dm[20]=278.;
287
288   gMC->Gsvolu("TOIN","PCON",idtmed[3],dm,21);
289
290   //----------------------------------------------------------------
291   // Tpc Outer Contaiment Vessel  
292   //  mother volume - Al, daughters - composite (sandwich)
293   //----------------------------------------------------------------
294
295   dm[0]=0.;
296   dm[1]=360.;
297   dm[2]=6.;
298
299   //
300
301   dm[3]=-250.6;
302   dm[4]=270.4;
303   dm[5]=278.;
304
305   //
306
307   dm[6]=-247.6;
308   dm[7]=270.4;
309   dm[8]=278.; 
310
311   //
312
313   dm[9]=-247.6;
314   dm[10]=274.81;
315   dm[11]=278.;
316
317   //
318
319   dm[12]=253.6;
320   dm[13]=274.81;
321   dm[14]=278.;
322
323   //
324
325   dm[15]=253.6;
326   dm[16]=264.8;
327   dm[17]=278.;
328
329   //
330
331   dm[18]=256.6;
332   dm[19]=264.8;
333   dm[20]=278.;
334
335   gMC->Gsvolu("TOCV","PCON",idtmed[4],dm,21);
336
337   // Daughter volumes - sandwich
338
339   // Tpc SAndwich 1 - Al
340
341   dm[0]=274.81;
342   dm[1]=278.;
343   dm[2]=252.1;
344
345   gMC->Gsvolu("TSA1","TUBE",idtmed[4],dm,3);
346
347   // Tpc SAndwich 2 - epoxy glue (I use Lexan)
348
349   dm[0] += 5.e-3;
350   dm[1] -= 5.e-3;
351
352   gMC->Gsvolu("TSA2","TUBE",idtmed[14],dm,3);
353
354   // Tpc SAndwich 3 - Tedlar
355
356   dm[0] += 0.01;
357   dm[1] -= 0.01;
358   
359   gMC->Gsvolu("TSA3","TUBE",idtmed[9],dm,3);
360
361
362   // Tpc SAndwich 4 - fiber glass (G10)
363
364   dm[0] += 5.e-3;
365   dm[1] -= 5.e-3;
366
367   gMC->Gsvolu("TSA4","TUBE",idtmed[12],dm,3);  
368
369   // Tpc SAndwich 5 - NOMEX honeycomb
370
371   dm[0] += 0.075;
372   dm[1] -= 0.075;   
373   
374   gMC->Gsvolu("TSA5","TUBE",idtmed[6],dm,3);
375
376   // 5->4->3->2->1->TCOV
377
378
379   gMC->Gspos("TSA5",1,"TSA4",0.,0.,0.,0,"ONLY");
380   gMC->Gspos("TSA4",1,"TSA3",0.,0.,0.,0,"ONLY");
381   gMC->Gspos("TSA3",1,"TSA2",0.,0.,0.,0,"ONLY");
382   gMC->Gspos("TSA2",1,"TSA1",0.,0.,0.,0,"ONLY");  
383
384   gMC->Gspos("TSA1",1,"TOCV",0.,0.,3.,0,"ONLY");
385
386   // TCOV-> TOIN
387
388   gMC->Gspos("TOCV",1,"TOIN",0.,0.,0.,0,"ONLY");
389
390   //-------------------------------------------------------
391   //  Tpc Outer Field Cage
392   //  mother volume - Al, daughters - composite (sandwich)
393   //-------------------------------------------------------
394
395   dm[0]=0.;
396   dm[1]=360.;
397   dm[2]=6.;
398
399   //
400
401   dm[3]=-253.6;
402   dm[4]=258.;
403   dm[5]=275.5;
404
405   //
406
407   dm[6]=-250.6;
408   dm[7]=258.;
409   dm[8]=275.5;
410
411   //
412
413   dm[9]=-250.6;
414   dm[10]=258.;
415   dm[11]=260.05;
416
417   //
418
419   dm[12]=250.6;
420   dm[13]=258.;
421   dm[14]=260.05;
422
423   //
424
425   dm[15]=250.6;
426   dm[16]=258.;
427   dm[17]=275.5;
428
429   //
430
431   dm[18]=253.6;
432   dm[19]=258.;
433   dm[20]=275.5;
434
435   gMC->Gsvolu("TOFC","PCON",idtmed[4],dm,21);
436
437   // Daughter volumes 
438
439   // Tpc SAndwich 6 - Tedlar
440
441   dm[0]= 258.;
442   dm[1]= 260.05;
443   dm[2]= 252.1;
444
445   gMC->Gsvolu("TSA6","TUBE",idtmed[9],dm,3);
446
447   // Tpc SAndwich 7 - fiber glass
448
449   dm[0] += 5.e-3;
450   dm[1] -= 5.e-3;
451
452   gMC->Gsvolu("TSA7","TUBE",idtmed[12],dm,3);
453
454
455   // Tpc SAndwich 8 - NOMEX
456
457   dm[0] += 0.02;
458   dm[1] -= 0.02;
459
460   gMC->Gsvolu("TSA8","TUBE",idtmed[6],dm,3);    
461
462   // 8->7->6->TOFC
463
464   gMC->Gspos("TSA8",1,"TSA7",0.,0.,0.,0,"ONLY");
465   gMC->Gspos("TSA7",1,"TSA6",0.,0.,0.,0,"ONLY"); 
466   gMC->Gspos("TSA6",1,"TOFC",0.,0.,0.,0,"ONLY");
467
468   // TOFC->TOIN
469
470   gMC->Gspos("TOFC",1,"TOIN",0.,0.,0.,0,"ONLY");
471
472   // TOIN->TPC
473
474   gMC->Gspos("TOIN",1,"TPC ",0.,0.,0.,0,"ONLY");
475
476   // inner part
477
478   //--------------------------------------------------------------------
479   // Tpc Inner INsulator (CO2) - inner f.c. will be placed there
480   // Inner containment vessel will be placed directly in the TPC
481   //-------------------------------------------------------------------- 
482
483   dm[0]=0.;
484   dm[1]=360.;
485   dm[2]=4.;
486
487   // 
488
489   dm[3]=-253.6;
490   dm[4]=65.9;
491   dm[5]=79.2;
492
493   //
494
495   dm[6]=-73.3;
496   dm[7]=61.2;
497   dm[8]=79.2;  
498
499   //
500
501   dm[9]=73.3;
502   dm[10]=61.2;
503   dm[11]=79.2;
504
505   //
506
507   dm[12]=253.6;
508   dm[13]=65.9;
509   dm[14]=79.2;
510
511   gMC->Gsvolu("TIIN","PCON",idtmed[3],dm,15);
512
513   // the middle part of the F.C. is thinner - carve out the strip - Ne-CO2
514
515   dm[0]=79.16;
516   dm[1]=79.2;
517   dm[2]=88.;
518
519   gMC->Gsvolu("TII1","TUBE",idtmed[1],dm,3);
520
521   gMC->Gspos("TII1",1,"TIIN",0.,0.,0.,0,"ONLY");
522
523   //-----------------------------------------------------
524   // Tpc Inner Field Cage
525   // mother volume - Al, daughters - composite (sandwich)
526   //------------------------------------------------------
527
528   dm[0]=0.;
529   dm[1]=360.;
530   dm[2]=10.;
531
532   //
533
534   dm[3]=-253.6;
535   dm[4]=70.3;
536   dm[5]=79.2;
537
538   //
539
540   dm[6]=-250.6;
541   dm[7]=70.3;
542   dm[8]=79.2;
543
544   //
545
546   dm[9]=-250.6;
547   dm[10]=77.05;
548   dm[11]=79.2;
549
550   //
551
552   dm[12]=-88.;
553   dm[13]=77.05;
554   dm[14]=79.2;
555
556   //
557
558   dm[15]=-88.;
559   dm[16]=77.09;
560   dm[17]=79.16;
561
562   //
563
564   dm[18]=88.;
565   dm[19]=77.09;
566   dm[20]=79.16;
567
568   //
569
570   dm[21]=88.;
571   dm[22]=77.05;
572   dm[23]=79.2;
573
574   //
575
576   dm[24]=250.6;
577   dm[25]=77.05;
578   dm[26]=79.2;
579
580   //
581
582   dm[27]=250.6;
583   dm[28]=70.3;
584   dm[29]=79.2;
585
586   //
587
588   dm[30]=253.6;
589   dm[31]=70.3;
590   dm[32]=79.2;
591
592   gMC->Gsvolu("TIFC","PCON",idtmed[4],dm,33);
593
594   // daughter volumes - central part
595
596   // Tpc Sandwich 9 -Tedlar
597
598   dm[0]=77.09;
599   dm[1]=79.16;
600   dm[2]=88.;
601
602   gMC->Gsvolu("TSA9","TUBE",idtmed[9],dm,3); 
603
604   // Tpc Sandwich 10 - fiber glass (G10) 
605
606   dm[0] += 5.e-3;
607   dm[1] -= 5.e-3;
608
609   gMC->Gsvolu("TS10","TUBE",idtmed[12],dm,3);
610
611   // Tpc Sandwich 11 - NOMEX
612
613   dm[0] += 0.03;
614   dm[1] -= 0.03; 
615
616   gMC->Gsvolu("TS11","TUBE",idtmed[6],dm,3);
617
618   // 11->10->9->TIFC
619
620   gMC->Gspos("TS11",1,"TS10",0.,0.,0.,0,"ONLY");
621   gMC->Gspos("TS10",1,"TSA9",0.,0.,0.,0,"ONLY");
622
623   gMC->Gspos("TSA9",1,"TIFC",0.,0.,0.,0,"ONLY");
624
625   // daughter volumes - outer parts (reinforced)
626
627   // Tpc Sandwich 12 -Tedlar
628
629   dm[0]=77.05;
630   dm[1]=79.2;
631   dm[2]=82.05;
632
633   gMC->Gsvolu("TS12","TUBE",idtmed[9],dm,3);
634
635   // Tpc Sandwich 13 - fiber glass (G10) 
636
637   dm[0] += 5.e-3;
638   dm[1] -= 5.e-3;
639
640   gMC->Gsvolu("TS13","TUBE",idtmed[12],dm,3);
641
642   // Tpc Sandwich 14 - NOMEX
643
644   dm[0] += 0.07;
645   dm[1] -= 0.07;  
646
647   gMC->Gsvolu("TS14","TUBE",idtmed[6],dm,3);
648
649   // 14->13->12->TIFC
650
651   gMC->Gspos("TS14",1,"TS13",0.,0.,0.,0,"ONLY");
652   gMC->Gspos("TS13",1,"TS12",0.,0.,0.,0,"ONLY"); 
653
654   gMC->Gspos("TS12",1,"TIFC",0.,0.,170.05,0,"ONLY");
655   gMC->Gspos("TS12",2,"TIFC",0.,0.,-170.05,0,"ONLY"); 
656
657   // place this inside the inner insulator
658
659   gMC->Gspos("TIFC",1,"TIIN",0.,0.,0.,0,"ONLY");
660
661   // and now in the TPC...
662
663   gMC->Gspos("TIIN",1,"TPC ",0.,0.,0.,0,"ONLY");
664
665   //---------------------------------------------------------
666   // Tpc Inner Containment vessel - Cones
667   //---------------------------------------------------------
668
669   dm[0]=0.;
670   dm[1]=360.;
671   dm[2]=8.;
672
673   //
674
675   dm[3]=71.8;
676   dm[4]=56.9;
677   dm[5]=59.4;
678
679   //
680
681   dm[6]=73.;
682   dm[7]=56.9;
683   dm[8]=59.4;
684
685   //
686
687   dm[9]=73.;
688   dm[10]=56.9;
689   dm[11]=61.2;
690
691   //
692
693   dm[12]=73.3;
694   dm[13]=56.9;
695   dm[14]=61.2;
696
697   //
698    
699   dm[15]=73.3;
700   dm[16]=60.9;
701   dm[17]=61.2;
702
703   // 
704
705   dm[18]=253.6;
706   dm[19]=65.6;
707   dm[20]=65.9; 
708
709   //
710
711   dm[21]=253.6;
712   dm[22]=65.6;
713   dm[23]=74.6;
714
715   //
716
717   dm[24]=256.6;
718   dm[25]=65.6;
719   dm[26]=74.6;
720
721   gMC->Gsvolu("TICC","PCON",idtmed[4],dm,27);
722
723   Float_t phi1,phi2,phi3,theta1,theta2,theta3; // rotation angles
724
725   // reflection matrix
726   
727   theta1 = 90.;
728   phi1   = 0.;
729   theta2 = 90.;
730   phi2   = 270.;
731   theta3 = 180.;
732   phi3   = 0.;
733
734   AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
735
736   gMC->Gspos("TICC",1,"TPC ",0.,0.,0.,0,"ONLY");
737   gMC->Gspos("TICC",2,"TPC ",0.,0.,0.,idrotm[nRotMat],"ONLY");
738
739
740   //---------------------------------------------------------
741   // Tpc Inner Containment vessel - Middle part -Al
742   //---------------------------------------------------------
743
744   dm[0]=0.;
745   dm[1]=360.;
746   dm[2]=6.;
747
748   //
749
750   dm[3]=-71.6;
751   dm[4]=60.2;
752   dm[5]=61.2;
753
754   //
755
756   dm[6]=-69.1;
757   dm[7]=60.2;
758   dm[8]=61.2;
759
760   //
761
762   dm[9]=-69.1;
763   dm[10]=60.64;
764   dm[11]=61.2;  
765
766   //
767
768   dm[12]=69.1;
769   dm[13]=60.64;
770   dm[14]=61.2;
771
772   //
773
774   dm[15]=69.1;
775   dm[16]=60.2;
776   dm[17]=61.2;
777
778   //
779
780   dm[18]=71.6;
781   dm[19]=60.2;
782   dm[20]=61.2;
783
784   gMC->Gsvolu("TICM","PCON",idtmed[4],dm,21);
785
786   // Tpc Sandwich 15 - Al
787
788   dm[0]=60.64;
789   dm[1]=61.2;
790   dm[2]=70.1;
791
792   gMC->Gsvolu("TS15","TUBE",idtmed[4],dm,3);
793
794   // Tpc Sandwich 16 -  epoxy glue
795
796   dm[0] += 5.e-3;
797   dm[1] -= 5.e-3;
798
799   gMC->Gsvolu("TS16","TUBE",idtmed[14],dm,3);
800
801   // Tpc Sandwich 17 - Tedlar
802
803   dm[0] += 0.01;
804   dm[1] -= 0.01;
805
806   gMC->Gsvolu("TS17","TUBE",idtmed[9],dm,3);
807
808   // Tpc Sandwich 18 - fiber glass
809
810   dm[0] += 5.e-3;
811   dm[1] -= 5.e-3;
812
813   gMC->Gsvolu("TS18","TUBE",idtmed[12],dm,3);  
814
815   // Tpc Sandwich 19 - Nomex
816
817   dm[0] += 0.01;
818   dm[1] -= 0.01;
819
820   gMC->Gsvolu("TS19","TUBE",idtmed[12],dm,3); 
821
822   // 19->18->17->16->15-> TICM
823
824   gMC->Gspos("TS19",1,"TS18",0.,0.,0.,0,"ONLY"); 
825   gMC->Gspos("TS18",1,"TS17",0.,0.,0.,0,"ONLY");
826   gMC->Gspos("TS17",1,"TS16",0.,0.,0.,0,"ONLY");
827   gMC->Gspos("TS16",1,"TS15",0.,0.,0.,0,"ONLY");
828
829   gMC->Gspos("TS15",1,"TICM ",0.,0.,0.,0,"ONLY");
830  
831
832   // TPc inner cont. vessel Joints
833
834   dm[0]=60.2;
835   dm[1]=61.2;
836   dm[2]=0.5;
837
838   gMC->Gsvolu("TPJ1","TUBE",idtmed[4],dm,3);
839
840   gMC->Gspos("TPJ1",1,"TPC ",0.,0.,72.3,0,"ONLY");
841   gMC->Gspos("TPJ1",2,"TPC ",0.,0.,-72.3,0,"ONLY");
842
843   //
844
845   dm[0]=0.;
846   dm[1]=360.;
847   dm[2]=4.;
848
849   //
850
851   dm[3]=70.8;
852   dm[4]=58.4;
853   dm[5]=60.1;
854
855   //
856
857   dm[6]=71.2;
858   dm[7]=58.4;
859   dm[8]=60.1;
860
861   //
862
863   dm[9]=71.2;
864   dm[10]=58.4;
865   dm[11]=59.4;
866
867   //
868
869   dm[12]=71.6;
870   dm[13]=58.4;
871   dm[14]=59.4;
872
873   gMC->Gsvolu("TPJ2","PCON",idtmed[4],dm,15);
874
875   gMC->Gspos("TPJ2",1,"TPC ",0.,0.,0.,0,"ONLY");
876   gMC->Gspos("TPJ2",2,"TPC ",0.,0.,0.,idrotm[nRotMat],"ONLY");
877
878
879
880   // Tpc Inner Containment vessel Seal (Viton, I use Lexan for a time being)
881
882   dm[0]=58.4;
883   dm[1]=61.2;
884   dm[2]=0.1;
885
886   gMC->Gsvolu("TICS","TUBE",idtmed[14],dm,3);
887
888   gMC->Gspos("TICS",1,"TPC ",0.,0.,71.7,0,"ONLY");
889   gMC->Gspos("TICS",2,"TPC ",0.,0.,-71.7,0,"ONLY"); 
890
891   // TICM -> TPC
892
893   gMC->Gspos("TICM",1,"TPC ",0.,0.,0.,0,"ONLY");
894
895   //
896
897   nRotMat++; // prepare for the next rotation matrix 
898
899   //---------------------------------------------------------
900   //  Tpc Dift Gas volume Nonsensitive (Ne-CO2 90/10)
901   //  and its daughters (HV membrane, rods, readout chambers)
902   //---------------------------------------------------------
903
904   dm[0]= 79.2;
905   dm[1]= 258.0;
906   dm[2]= 253.6;
907
908   gMC->Gsvolu("TDGS","TUBE",idtmed[2],dm,3); 
909
910   // sector opening angles
911
912   Float_t innerOpenAngle = fTPCParam->GetInnerAngle();
913
914   // sector angle shift
915
916   Float_t innerAngleShift = fTPCParam->GetInnerAngleShift();
917
918   // number of sectors
919
920   Int_t nInnerSector = fTPCParam->GetNInnerSector()/2;
921   Int_t nOuterSector = fTPCParam->GetNOuterSector()/2;
922
923   // All above parameters are identical for inner and outer
924   // sectors. The distinction is kept for the historical reasons
925   // and eventually will disappear.
926
927   Float_t tanAlpha = TMath::Tan(0.5*innerOpenAngle);
928   Float_t cosAlpha = TMath::Sqrt(1.+tanAlpha*tanAlpha);
929   Float_t space;
930
931   //-------------------------------------------------------------------------
932   //   Tpc Inner Readout Chambers 
933   //-------------------------------------------------------------------------
934
935   dm[0]= 14.483;
936   dm[1]= 23.3345; 
937   dm[2]= 1.6; // thickness
938   dm[3]= 25.1;
939
940   gMC->Gsvolu("TIRC","TRD1",idtmed[4],dm,4);
941
942   // this volume will be positioned in the empty space
943   // of the end-cap to avoid overlaps
944
945   dm[0]= 13.7305;
946   dm[1]= 21.1895;
947   dm[2]= 2.25;
948   dm[3]= 21.15;
949
950   gMC->Gsvolu("TIC1","TRD1",idtmed[4],dm,4);
951
952
953   //------------------------------------------------
954   // Tpc Inner readout chamber Pad Plane
955   //------------------------------------------------
956
957   dm[0]= 14.483;
958   dm[1]= 23.3345;
959   dm[2]= 0.5;
960   dm[3]= 25.1;
961
962   gMC->Gsvolu("TIPP","TRD1",idtmed[12],dm,4);
963
964   // 
965
966   dm[0] -= 1.218511934;
967   dm[1] -= 1.218511934;
968   dm[2] = 0.35;
969
970   gMC->Gsvolu("TIC3","TRD1",idtmed[1],dm,4);
971
972   gMC->Gspos("TIC3",1,"TIPP",0.,0.15,0.,0,"ONLY");
973
974   gMC->Gspos("TIPP",1,"TIRC",0.,1.1,0.,0,"ONLY");
975
976
977   //----------------------------------------------
978   // Tpc Readout Chambers Empty spaces - for both
979   // inner and outer sectors
980   //----------------------------------------------
981
982   gMC->Gsvolu("TRCE","TRD1",idtmed[0],dm,0);
983
984   // Inner sector - 4 spaces
985
986
987   dm[3] = 4.7625;
988   dm[0] = 12.472;
989
990   Float_t rr = 90.52;
991   Float_t zz;
992
993   zz= -12.7875;
994   
995   space = rr*tanAlpha-dm[0];
996
997   for(Int_t nsLow=0;nsLow<4;nsLow++){
998
999     rr += 9.525;
1000     dm[1]= rr*tanAlpha - space;  
1001
1002     dm[2]=0.8;
1003
1004     gMC->Gsposp("TRCE",nsLow+1,"TIRC",0.,-0.8,zz,0,"ONLY",dm,4);
1005
1006     //
1007
1008     dm[2] = 1.2;
1009
1010     gMC->Gsposp("TRCE",nsLow+5,"TIC1",0.,1.05,zz-2.1,0,"ONLY",dm,4);
1011
1012     rr += 0.4;
1013     dm[0] = rr*tanAlpha - space;
1014     zz += (0.4+9.525); 
1015
1016   }
1017
1018   dm[0]= 12.472;
1019   // dm[1] - this is the dm[1] from the previous TRCE
1020   dm[2]= 1.05;
1021   dm[3]= 19.65;
1022
1023   gMC->Gsposp("TRCE",9,"TIC1",0.,-1.2,0.,0,"ONLY",dm,4);   
1024
1025   //
1026   // TPc Space for Connectors
1027   //
1028
1029   dm[0]= .3;
1030   dm[1]= .3;
1031   dm[2]= 4.5;
1032
1033   gMC->Gsvolu("TPSC","BOX ",idtmed[0],dm,3);
1034
1035   // TPC Connectors
1036
1037   dm[0]= .25;
1038   dm[1]= .15;
1039   dm[2]= 3.75;
1040
1041   gMC->Gsvolu("TPCC","BOX ",idtmed[13],dm,3); 
1042
1043   gMC->Gspos("TPCC",1,"TPSC",0.,0.15,0.,0,"ONLY");
1044
1045   zz = -12.7875;
1046
1047
1048   Float_t alpha;
1049   Float_t astep;
1050
1051   // inner part of the inner sector - 2 x 20 holes
1052   
1053   astep = 20.00096874/19.;
1054
1055   alpha = 10.00048437-astep;
1056
1057   Float_t x1,x2;
1058
1059     x1 = 13.31175725;
1060     x1 -= 0.996357832; 
1061
1062     x2 = 15.06180253;
1063     x2 -= 1.163028812;
1064
1065   Int_t ncon;
1066
1067   for(ncon=0;ncon<20;ncon++){
1068
1069     phi1 = 0.;
1070     theta1 = 90.+alpha;
1071     phi2=90.;
1072     theta2 = 90.;
1073     phi3 = (alpha>0) ? 0. : 180.;
1074     theta3 = TMath::Abs(alpha);
1075
1076     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
1077
1078  
1079
1080     gMC->Gspos("TPSC",ncon+1,"TIRC",x1,0.3,-12.7875,idrotm[nRotMat],"ONLY");
1081     gMC->Gspos("TPSC",ncon+21,"TIRC",x2,0.3,-2.8625,idrotm[nRotMat],"ONLY");
1082
1083
1084     x1 -= 1.296357833;
1085     x2 -= 1.463028812;
1086
1087     alpha -= astep;   
1088     nRotMat++; 
1089
1090   }
1091
1092   // outer part of the inner sector - 2 x 25 holes
1093
1094    astep = 20.00096874/24.; 
1095    alpha = 10.00048437-astep;
1096
1097    x1 = 16.81184781;
1098    x1 -= 1.016295986;
1099
1100    x2 = 18.5618931;
1101    x2 -= 1.150914854;
1102
1103   for(ncon=0;ncon<25;ncon++){
1104
1105     phi1 = 0.;
1106     theta1 = 90.+alpha;
1107     phi2=90.;
1108     theta2 = 90.;
1109     phi3 = (alpha>0) ? 0. : 180.;
1110     theta3 = TMath::Abs(alpha);
1111
1112     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
1113
1114  
1115
1116     gMC->Gspos("TPSC",ncon+41,"TIRC",x1,0.3,7.0625,idrotm[nRotMat],"ONLY");
1117     gMC->Gspos("TPSC",ncon+66,"TIRC",x2,0.3,16.9875,idrotm[nRotMat],"ONLY");
1118
1119
1120     x1 -= 1.316295986;
1121     x2 -= 1.450914854;
1122
1123     alpha -= astep;   
1124     nRotMat++; 
1125
1126   }  
1127
1128   //--------------------------------------------------------------------------
1129   //  TPC Outer Readout Chambers
1130   //  this is NOT a final design
1131   //--------------------------------------------------------------------------
1132
1133   dm[0]= 23.3875;
1134   dm[1]= 43.524;
1135   dm[2]= 1.5; //thickness
1136   dm[3]= 57.1;
1137
1138   gMC->Gsvolu("TORC","TRD1",idtmed[4],dm,4);
1139
1140   //------------------------------------------------
1141   // Tpc Outer readout chamber Pad Plane
1142   //------------------------------------------------
1143
1144   dm[2]= 0.5;
1145
1146   gMC->Gsvolu("TOPP","TRD1",idtmed[12],dm,4);
1147
1148   dm[0] -= 1.218511934;
1149   dm[1] -= 1.218511934;
1150   dm[2] = 0.35;
1151
1152   gMC->Gsvolu("TOC3","TRD1",idtmed[1],dm,4);
1153
1154   gMC->Gspos("TOC3",1,"TOPP",0.,0.15,0.,0,"ONLY");
1155
1156   gMC->Gspos("TOPP",1,"TORC",0.,1.0,0.,0,"ONLY");
1157
1158   // empty space
1159
1160   dm[0]= 21.035;
1161   dm[1]= 38.7205;
1162   dm[2]= 0.7; 
1163   dm[3]= 50.15;
1164
1165   gMC->Gsposp("TRCE",10,"TORC",0.,-0.8,-2.15,0,"ONLY",dm,4);  
1166
1167   dm[0]= 22.2935;
1168   dm[1]= 40.5085;
1169   dm[2]= 2.25;
1170   dm[3]= 51.65;
1171
1172   gMC->Gsvolu("TOC1","TRD1",idtmed[4],dm,4);
1173
1174   dm[0]= 21.35;
1175   dm[1]= 38.7205;
1176   dm[2]= 2.25;
1177   dm[3]= 50.15;
1178
1179   gMC->Gsposp("TRCE",11,"TOC1",0.,0.,0.,0,"ONLY",dm,4);
1180
1181   //-----------------------------------------------
1182   // Tpc Services Support Wheel
1183   //-----------------------------------------------
1184
1185   dm[0]=0.;
1186   dm[1]=360.;
1187   dm[2]=18.;
1188   dm[3]=2.;
1189
1190   dm[4]= -5.;
1191   dm[5]= 77.017;
1192   dm[6]= 255.267;
1193
1194   dm[7]= 5.;
1195   dm[8]= dm[5];
1196   dm[9]= dm[6];
1197
1198   gMC->Gsvolu("TSSW","PGON",idtmed[4],dm,10);
1199
1200   // Tpc Services Wheel Cover
1201
1202   dm[4]= -0.5;
1203   dm[7]= 0.5;
1204
1205   gMC->Gsvolu("TSWC","PGON",idtmed[4],dm,10);
1206
1207   // Tpc Service wheel Cover Empty space
1208    
1209   dm[0]= 10.99;
1210   dm[1]= 39.599;
1211   dm[2]= .5;
1212   dm[3]= 81.125;
1213
1214   gMC->Gsvolu("TSCE","TRD1",idtmed[0],dm,4);
1215
1216   // Tpc services Wheel Empty Spaces
1217
1218   dm[0]= 13.18017507;
1219   dm[1]= 44.61045938;
1220   dm[2]= 4.;
1221   dm[3]= 89.125;
1222
1223   gMC->Gsvolu("TWES","TRD1",idtmed[0],dm,4);
1224
1225   // Tpc Services Wheel Bars
1226
1227   gMC->Gsvolu("TSWB","TRD1",idtmed[4],dm,0);
1228
1229   // bars-> TWES
1230
1231   dm[2]= 4.;
1232   dm[3]= .4;
1233
1234   dm[0]= 13.8149522;
1235   dm[1]= 13.95601379;
1236   
1237   gMC->Gsposp("TSWB",1,"TWES",0.,0.,-85.125,0,"ONLY",dm,4);
1238
1239   dm[0]= 43.83462067; 
1240   dm[1]= 43.97568225;
1241
1242   gMC->Gsposp("TSWB",2,"TWES",0.,0.,85.125,0,"ONLY",dm,4);
1243
1244   // TPc ELectronics - right now 30% X0 Si
1245
1246   dm[0]= 14.03813696;
1247   dm[1]= 43.3524075;
1248   dm[2]= 1.404;
1249   dm[3]= 83.125;
1250
1251   gMC->Gsvolu("TPEL","TRD1",idtmed[11],dm,4);
1252   gMC->Gspos("TPEL",1,"TWES",0.,0.,0.,0,"ONLY");
1253
1254   //--------------------------------------------------------------------------
1255   //  End caps
1256   //--------------------------------------------------------------------------
1257
1258   // TPc Main Wheel - Al
1259
1260   dm[0]= 74.9;
1261   dm[1]= 264.4;
1262   dm[2]= 3.0;
1263
1264   gMC->Gsvolu("TPMW","TUBE",idtmed[4],dm,3);
1265
1266   //--------------------------------------------------------------------------
1267   //  Tpc Empty Space for the Readout chambers
1268   //--------------------------------------------------------------------------  
1269
1270   Float_t rLow= 86.2;
1271   Float_t rUp= 243.5;
1272   Float_t dR = 0.5*(rUp-rLow);
1273
1274   space= 1.5/cosAlpha; // wheel ribs are 3.0 cm wide
1275
1276   dm[0]= rLow*tanAlpha-space;
1277   dm[1]= rUp*tanAlpha-space;
1278   dm[2] = 3.0;
1279   dm[3]= dR;
1280
1281   gMC->Gsvolu("TESR","TRD1",idtmed[0],dm,4);
1282
1283   // TIC1->TESR
1284
1285   gMC->Gspos("TIC1",1,"TESR",0.,0.75,-dR+23.97,0,"ONLY");
1286
1287   // TOC1->TESR
1288
1289   gMC->Gspos("TOC1",1,"TESR",0.,0.75,dR-55.02,0,"ONLY");
1290
1291   // Tpc Empty Space Bars - Al (daughters of TESR)
1292
1293   Float_t zBar;
1294
1295   gMC->Gsvolu("TESB","TRD1",idtmed[4],dm,0);
1296
1297   // lower bar
1298
1299   dm[0]= rLow*tanAlpha-space;
1300   dm[1]= 88.7*tanAlpha-space;
1301   dm[2]= 2.25;
1302   dm[3]= 1.275;
1303
1304   zBar = -dR+dm[3];
1305
1306   gMC->Gsposp("TESB",1,"TESR",0.,0.75,zBar,0,"ONLY",dm,4);
1307
1308   // middle bar
1309
1310   dm[0]= 131.65*tanAlpha-space;
1311   dm[1]= 136.5*tanAlpha-space;
1312   dm[3]= 2.425;
1313
1314   zBar = -dR +131.65+dm[3]-rLow;
1315
1316   gMC->Gsposp("TESB",2,"TESR",0.,0.75,zBar,0,"ONLY",dm,4);  
1317
1318   // upper bar
1319
1320   dm[0]= 240.4*tanAlpha-space;
1321   dm[1]= rUp*tanAlpha-space;
1322   dm[3]= 1.55;
1323
1324   zBar = dR-dm[3];
1325
1326   gMC->Gsposp("TESB",3,"TESR",0.,0.75,zBar,0,"ONLY",dm,4);
1327
1328   //  positioning of the empty spaces into the main wheel
1329
1330   Float_t rCenter,xc,yc;
1331   Float_t rInner,rOuter; // center of the inner and outer chamber
1332
1333   rCenter = rLow+dR;
1334
1335   rInner = 108.07;
1336   rOuter = 190.68;
1337
1338
1339   for(Int_t ns=0; ns<nInnerSector;ns++){
1340
1341     phi1 = ns * innerOpenAngle + innerAngleShift;
1342     phi1 *= kRaddeg; // in degrees
1343
1344     phi1 = (Float_t)TMath::Nint(phi1) + 270.;
1345
1346     if (phi1 > 360.) phi1 -= 360.;
1347
1348     theta1 = 90.;
1349     phi2   = 90.;
1350     theta2 = 180.;
1351     phi3   = ns * innerOpenAngle + innerAngleShift;
1352     phi3 *= kRaddeg; // in degrees
1353
1354     phi3 = (Float_t)TMath::Nint(phi3);
1355       
1356     if(phi3 > 360.) phi3 -= 360.;
1357
1358     theta3 = 90.;
1359
1360     // "holes"->End plate
1361
1362     xc = rCenter*TMath::Cos(phi3*kDegrad);
1363     yc = rCenter*TMath::Sin(phi3*kDegrad);
1364
1365     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
1366
1367     gMC->Gspos("TESR",ns+1,"TPMW",xc,yc,0.,idrotm[nRotMat],"ONLY");
1368
1369     // TSCE->TSWC (services wheel volumes)
1370
1371     xc = 166.142*TMath::Cos(phi3*kDegrad);
1372     yc = 166.142*TMath::Sin(phi3*kDegrad);
1373
1374     gMC->Gspos("TSCE",ns+1,"TSWC",xc,yc,0.,idrotm[nRotMat],"ONLY");
1375     gMC->Gspos("TWES",ns+1,"TSSW",xc,yc,0.,idrotm[nRotMat],"ONLY");
1376
1377
1378     // readout chambers->TDGS (drift gas)
1379
1380     xc = rInner*TMath::Cos(phi3*kDegrad);
1381     yc = rInner*TMath::Sin(phi3*kDegrad);
1382
1383     gMC->Gspos("TIRC",ns+1,"TDGS",xc,yc,252.,idrotm[nRotMat],"ONLY");
1384      
1385     xc = rOuter*TMath::Cos(phi3*kDegrad);
1386     yc = rOuter*TMath::Sin(phi3*kDegrad);
1387
1388     gMC->Gspos("TORC",ns+1,"TDGS",xc,yc,252.1,idrotm[nRotMat],"ONLY");
1389
1390     nRotMat++;
1391
1392     theta2 = 0.; // reflection
1393
1394     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
1395
1396     xc = rInner*TMath::Cos(phi3*kDegrad);
1397     yc = rInner*TMath::Sin(phi3*kDegrad);
1398
1399     gMC->Gspos("TIRC",ns+nInnerSector+1,"TDGS",xc,yc,-252.,idrotm[nRotMat],"ONLY");
1400
1401     xc = rOuter*TMath::Cos(phi3*kDegrad);
1402     yc = rOuter*TMath::Sin(phi3*kDegrad);
1403
1404     gMC->Gspos("TORC",ns+nOuterSector+1,"TDGS",xc,yc,-252.1,idrotm[nRotMat],"ONLY");
1405
1406     nRotMat++;
1407
1408   } 
1409   // TPMW->TPC
1410
1411   gMC->Gspos("TPMW",1,"TPC ",0.,0.,256.6,0,"ONLY");
1412   gMC->Gspos("TPMW",2,"TPC ",0.,0.,-256.6,idrotm[0],"ONLY");
1413
1414   //---------------------------------------------------------
1415   //  Tpc High Voltage Membrane - 100 microns of mylar
1416   //---------------------------------------------------------
1417
1418   dm[0]=82.8;
1419   dm[1]=252.;
1420   dm[2]=0.005;
1421
1422   gMC->Gsvolu("THVM","TUBE",idtmed[8],dm,3);
1423
1424   gMC->Gspos("THVM",1,"TDGS",0.,0.,0.,0,"ONLY");
1425
1426   // Tpc High Voltage membrane Holders
1427
1428   gMC->Gsvolu("THVH","TUBE",idtmed[4],dm,0);
1429
1430   
1431
1432   // inner
1433
1434   dm[0]=79.3;
1435   dm[1]=82.8;
1436   dm[2]=0.2;
1437
1438   gMC->Gsposp("THVH",1,"TDGS",0.,0.,0.,0,"ONLY",dm,3);
1439   
1440   // outer
1441
1442   dm[0]= 252.;
1443   dm[1]= 257.9;
1444   dm[2]= 0.4;
1445
1446   gMC->Gsposp("THVH",2,"TDGS",0.,0.,0.,0,"ONLY",dm,3);
1447
1448   //----------------------------------------------------------
1449   // TPc Support Rods - MAKROLON
1450   //----------------------------------------------------------
1451
1452   dm[0]= 0.9;
1453   dm[1]= 1.2;
1454
1455   gMC->Gsvolu("TPSR","TUBE",idtmed[7],dm,0); // inner and outer rods differ
1456
1457
1458   for(Int_t nrod=0;nrod<18;nrod++){
1459     Float_t angle=innerOpenAngle*(Float_t)nrod;
1460
1461     xc=81.5*TMath::Cos(angle);
1462     yc=81.5*TMath::Sin(angle); 
1463
1464     dm[2]=126.7;
1465
1466     gMC->Gsposp("TPSR",nrod+1,"TDGS",xc,yc,126.9,0,"ONLY",dm,3); 
1467     gMC->Gsposp("TPSR",nrod+19,"TDGS",xc,yc,-126.9,0,"ONLY",dm,3);
1468
1469     dm[2]=126.6;
1470
1471     xc=254.25*TMath::Cos(angle);
1472     yc=254.25*TMath::Sin(angle);   
1473       
1474     // rod number 54 contans the HV cable
1475
1476     if(nrod<17) {
1477       gMC->Gsposp("TPSR",nrod+37,"TDGS",xc,yc,127.,0,"ONLY",dm,3);
1478       gMC->Gsposp("TPSR",nrod+54,"TDGS",xc,yc,-127.,0,"ONLY",dm,3);
1479     }
1480     
1481   }
1482
1483   //----------------------------------------------------------
1484   // Tpc High Voltage Rod - MAKROLON + Copper cable
1485   //----------------------------------------------------------
1486
1487   // rod with cable (Left)
1488
1489   dm[0]=0.;
1490   dm[1]=2.25;
1491   dm[2]=126.6;
1492
1493   gMC->Gsvolu("THVL","TUBE",idtmed[7],dm,3);
1494
1495   // HV cable
1496  
1497   dm[0]=0.;
1498   dm[1]=0.3;
1499   dm[2]=126.6;
1500
1501   gMC->Gsvolu("THVC","TUBE",idtmed[10],dm,3);  
1502
1503   // empty space
1504
1505   dm[0]=0.3;
1506   dm[1]=1.;
1507   dm[2]=126.6;
1508
1509   gMC->Gsvolu("THVE","TUBE",idtmed[1],dm,3);
1510
1511   gMC->Gspos("THVC",1,"THVL",0.,0.,0.,0,"ONLY");
1512   gMC->Gspos("THVE",1,"THVL",0.,0.,0.,0,"ONLY");
1513
1514   // rod without cable
1515
1516   dm[0]=1.8;
1517   dm[1]=2.25;
1518   dm[2]=126.6;
1519
1520   gMC->Gsvolu("THVR","TUBE",idtmed[7],dm,3);
1521
1522   gMC->Gspos("THVL",1,"TDGS",xc,yc,-127.,0,"ONLY");  
1523   gMC->Gspos("THVR",1,"TDGS",xc,yc,127.,0,"ONLY");
1524
1525   gMC->Gspos("TDGS",1,"TPC ",0.,0.,0.,0,"ONLY"); 
1526  
1527   // services wheel cover -> wheel
1528
1529
1530   gMC->Gspos("TSWC",1,"TSSW",0.,0.,4.5,0,"ONLY");
1531   gMC->Gspos("TSWC",2,"TSSW",0.,0.,-4.5,0,"ONLY");
1532
1533
1534   // put the wheel into the TPC
1535
1536   gMC->Gspos("TSSW",1,"TPC ",0.,0.,278.7,0,"ONLY");
1537   gMC->Gspos("TSSW",2,"TPC ",0.,0.,-278.7,0,"ONLY");
1538
1539   //
1540
1541   gMC->Gsord("TPMW",6);
1542   gMC->Gsord("TSSW",6);
1543   gMC->Gsord("TSWC",6);
1544
1545   // put the TPC into ALIC (main mother volume)
1546
1547   gMC->Gspos("TPC ",1,"ALIC",0.,0.,0.,0,"ONLY");
1548
1549  
1550 } // end of function
1551  
1552 //_____________________________________________________________________________
1553 void AliTPCv3::DrawDetector()
1554 {
1555   //
1556   // Draw a shaded view of the Time Projection Chamber version 3
1557   //
1558
1559
1560   // Set everything unseen
1561   gMC->Gsatt("*", "seen", -1);
1562   // 
1563   // Set ALIC mother transparent
1564   gMC->Gsatt("ALIC","SEEN",0);
1565   //
1566   // Set the volumes visible
1567   //
1568
1569   gMC->Gsatt("TPC ","SEEN",0);
1570   gMC->Gsatt("TOIN","SEEN",1);
1571   gMC->Gsatt("TOIN","COLO",7);
1572   gMC->Gsatt("TOCV","SEEN",1);
1573   gMC->Gsatt("TOCV","COLO",4);
1574   gMC->Gsatt("TSA1","SEEN",0);
1575   gMC->Gsatt("TSA2","SEEN",0);
1576   gMC->Gsatt("TSA3","SEEN",0);
1577   gMC->Gsatt("TSA4","SEEN",0);  
1578   gMC->Gsatt("TSA5","SEEN",0);
1579   gMC->Gsatt("TOFC","SEEN",1);
1580   gMC->Gsatt("TOFC","COLO",4);
1581   gMC->Gsatt("TSA6","SEEN",0);
1582   gMC->Gsatt("TSA7","SEEN",0);
1583   gMC->Gsatt("TSA8","SEEN",0);    
1584   gMC->Gsatt("TIIN","SEEN",1);
1585   gMC->Gsatt("TIIN","COLO",7);
1586   gMC->Gsatt("TII1","SEEN",0);
1587   gMC->Gsatt("TIFC","SEEN",1);
1588   gMC->Gsatt("TIFC","COLO",4);
1589   gMC->Gsatt("TSA9","SEEN",0); 
1590   gMC->Gsatt("TS10","SEEN",0);
1591   gMC->Gsatt("TS11","SEEN",0);
1592   gMC->Gsatt("TS12","SEEN",0);
1593   gMC->Gsatt("TS13","SEEN",0);
1594   gMC->Gsatt("TS14","SEEN",0);
1595   gMC->Gsatt("TICC","SEEN",0);
1596   gMC->Gsatt("TICM","SEEN",0);
1597   gMC->Gsatt("TS15","SEEN",0);
1598   gMC->Gsatt("TS16","SEEN",0);
1599   gMC->Gsatt("TS17","SEEN",0);
1600   gMC->Gsatt("TS18","SEEN",0);  
1601   gMC->Gsatt("TS19","SEEN",0); 
1602   gMC->Gsatt("TPJ1","SEEN",0);
1603   gMC->Gsatt("TPJ2","SEEN",0);
1604   gMC->Gsatt("TICS","SEEN",0);
1605   gMC->Gsatt("TDGS","SEEN",0); 
1606   gMC->Gsatt("TIRC","SEEN",0);
1607   gMC->Gsatt("TIC1","SEEN",1);
1608   gMC->Gsatt("TIPP","SEEN",0);
1609   gMC->Gsatt("TIC3","SEEN",0);
1610   gMC->Gsatt("TRCE","SEEN",0);
1611   gMC->Gsatt("TPSC","SEEN",0);
1612   gMC->Gsatt("TPCC","SEEN",0); 
1613   gMC->Gsatt("TORC","SEEN",0);
1614   gMC->Gsatt("TOPP","SEEN",0);
1615   gMC->Gsatt("TOC3","SEEN",0);
1616   gMC->Gsatt("TOC1","SEEN",1);
1617   gMC->Gsatt("TSSW","SEEN",1);
1618   gMC->Gsatt("TSWC","SEEN",1);
1619   gMC->Gsatt("TSSW","COLO",3);
1620   gMC->Gsatt("TSWC","COLO",3);
1621   gMC->Gsatt("TSCE","COLO",6);
1622   gMC->Gsatt("TSCE","SEEN",1);
1623   gMC->Gsatt("TWES","SEEN",0);
1624   gMC->Gsatt("TSWB","SEEN",0);
1625   gMC->Gsatt("TPEL","SEEN",0);
1626   gMC->Gsatt("TPMW","SEEN",1);
1627   gMC->Gsatt("TESR","SEEN",1);
1628   gMC->Gsatt("TPMW","COLO",12);
1629   gMC->Gsatt("TIC1","COLO",5);
1630   gMC->Gsatt("TOC1","COLO",5);
1631   gMC->Gsatt("TESB","SEEN",0);
1632   gMC->Gsatt("THVM","SEEN",1);
1633   gMC->Gsatt("THVM","COLO",11);
1634   gMC->Gsatt("THVH","SEEN",0);
1635   gMC->Gsatt("TPSR","SEEN",0); 
1636   gMC->Gsatt("THVL","SEEN",0);
1637   gMC->Gsatt("THVC","SEEN",0);  
1638   gMC->Gsatt("THVE","SEEN",0);
1639   gMC->Gsatt("THVR","SEEN",0);
1640
1641   //
1642   gMC->Gdopt("hide", "on");
1643   gMC->Gdopt("shad", "on");
1644   gMC->Gsatt("*", "fill", 7);
1645   gMC->SetClipBox(".");
1646   gMC->SetClipBox("TPMW",-300,300,-300,300,254.,270.);
1647   gMC->SetClipBox("TESR",-300,300,-300,300,254.,270.);
1648   gMC->SetClipBox("TSSW",-300,300,-300,300,283.,284.);
1649   gMC->SetClipBox("TSWC",-300,300,-300,300,283.,284.);
1650   gMC->SetClipBox("*", 0, 300, -300, 300, -290, 290);
1651   gMC->DefaultRange();
1652   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .025, .025);
1653   gMC->Gdhead(1111, "Time Projection Chamber");
1654   gMC->Gdman(18, 4, "MAN");
1655   gMC->Gdopt("hide","off");
1656 }
1657
1658 //_____________________________________________________________________________
1659 void AliTPCv3::CreateMaterials()
1660 {
1661   //
1662   // Define materials for version 2 of the Time Projection Chamber
1663   //
1664
1665
1666   //
1667   AliTPC::CreateMaterials();
1668 }
1669
1670 //_____________________________________________________________________________
1671 void AliTPCv3::Init()
1672 {
1673   //
1674   // Initialises version 3 of the TPC after that it has been built
1675   //
1676   Int_t *idtmed = fIdtmed->GetArray();
1677
1678   AliTPC::Init();
1679
1680   fIdSens=gMC->VolId("TDGS"); // drift gas as a sensitive volume
1681
1682   gMC->SetMaxNStep(30000); // max. number of steps increased
1683
1684   gMC->Gstpar(idtmed[2],"LOSS",5);
1685
1686   printf("*** TPC version 3 initialized ***\n");
1687   printf("Maximum number of steps = %d\n",gMC->GetMaxNStep());
1688
1689   //
1690   
1691 }
1692
1693 //_____________________________________________________________________________
1694 void AliTPCv3::StepManager()
1695 {
1696   //
1697   // Called for every step in the Time Projection Chamber
1698   //
1699
1700   //
1701   // parameters used for the energy loss calculations
1702   //
1703   const Float_t kprim = 14.35; // number of primary collisions per 1 cm
1704   const Float_t kpoti = 20.77e-9; // first ionization potential for Ne/CO2
1705   const Float_t kwIon = 35.97e-9; // energy for the ion-electron pair creation 
1706  
1707  
1708   const Float_t kbig = 1.e10;
1709
1710   Int_t id,copy;
1711   TLorentzVector pos;
1712   Float_t hits[4];
1713   Int_t vol[2];  
1714   
1715   vol[1]=0;
1716   vol[0]=0;
1717
1718   //
1719
1720   gMC->SetMaxStep(kbig);
1721   
1722   if(!gMC->IsTrackAlive()) return; // particle has disappeared
1723   
1724   Float_t charge = gMC->TrackCharge();
1725   
1726   if(TMath::Abs(charge)<=0.) return; // take only charged particles
1727   
1728   
1729   id=gMC->CurrentVolID(copy);
1730   
1731   // Check the sensitive volume
1732   
1733   if (id != fIdSens) return;
1734   
1735   //
1736   //  charged particle is in the sensitive volume
1737   //
1738   
1739   if(gMC->TrackStep() > 0) {
1740
1741     
1742     Int_t nel = (Int_t)(((gMC->Edep())-kpoti)/kwIon) + 1;
1743     nel=TMath::Min(nel,300); // 300 electrons corresponds to 10 keV
1744     
1745     gMC->TrackPosition(pos);
1746     hits[0]=pos[0];
1747     hits[1]=pos[1];
1748     hits[2]=pos[2];
1749
1750     //
1751     // check the selected side of the TPC
1752     //
1753  
1754     if(fSide && fSide*hits[2]<=0.) return;
1755
1756     hits[3]=(Float_t)nel;
1757     
1758     // Add this hit
1759    
1760     AddHit(gAlice->CurrentTrack(), vol,hits);  //MI change
1761     
1762   } 
1763   
1764   // Stemax calculation for the next step
1765   
1766   Float_t pp;
1767   TLorentzVector mom;
1768   gMC->TrackMomentum(mom);
1769   Float_t ptot=mom.Rho();
1770   Float_t betaGamma = ptot/gMC->TrackMass();
1771   
1772   Int_t pid=gMC->TrackPid();
1773   if((pid==kElectron || pid==kPositron) && ptot > 0.002)
1774     { 
1775       pp = kprim*1.58; // electrons above 20 MeV/c are on the plateau!
1776     }
1777   else
1778     {
1779       betaGamma = TMath::Max(betaGamma,(Float_t)7.e-3); 
1780       pp=kprim*BetheBloch(betaGamma);    
1781       if(TMath::Abs(charge) > 1.) pp *= (charge*charge);
1782     }
1783   
1784   Float_t random[1];
1785   gMC->Rndm(random,1); // good, old GRNDM from Geant3
1786   
1787   Double_t rnd = (Double_t)random[0];
1788   
1789   gMC->SetMaxStep(-TMath::Log(rnd)/pp);
1790   
1791 }
1792
1793 //_____________________________________________________________________________
1794 Float_t AliTPCv3::BetheBloch(Float_t bg)
1795 {
1796   //
1797   // Bethe-Bloch energy loss formula
1798   //
1799   const Double_t kp1=0.76176e-1;
1800   const Double_t kp2=10.632;
1801   const Double_t kp3=0.13279e-4;
1802   const Double_t kp4=1.8631;
1803   const Double_t kp5=1.9479;
1804
1805   Double_t dbg = (Double_t) bg;
1806
1807   Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
1808
1809   Double_t aa = TMath::Power(beta,kp4);
1810   Double_t bb = TMath::Power(1./dbg,kp5);
1811
1812   bb=TMath::Log(kp3+bb);
1813   
1814   return ((Float_t)((kp2-aa-bb)*kp1/aa));
1815 }