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