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