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