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