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