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