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