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