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