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