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