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