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