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