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