]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCv1.cxx
Class AliGenDoubleScan included
[u/mrichter/AliRoot.git] / TPC / AliTPCv1.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.14  1999/10/08 06:27:23  fca
19 Corrected bug in the HV degrader geometry, thanks to G.Tabary
20
21 Revision 1.13  1999/10/04 13:39:54  fca
22 Correct array index problem
23
24 Revision 1.12  1999/09/29 09:24:34  fca
25 Introduction of the Copyright and cvs Log
26
27 */
28
29 ///////////////////////////////////////////////////////////////////////////////
30 //                                                                           //
31 //  Time Projection Chamber version 1 -- detailed TPC and fast simulation    //
32 //                                                                           //
33 //Begin_Html
34 /*
35 <img src="picts/AliTPCv1Class.gif">
36 */
37 //End_Html
38 //                                                                           //
39 //                                                                           //
40 ///////////////////////////////////////////////////////////////////////////////
41
42 #include <TMath.h>
43 #include <TGeometry.h>
44 #include <TNode.h>
45 #include <TBRIK.h>
46 #include <TTUBE.h>
47 #include "AliTPCv1.h"
48 #include "AliRun.h"
49 #include <iostream.h>
50 #include <fstream.h>
51
52 #include "AliMC.h"
53 #include "AliConst.h"
54
55 #include "AliTPCParam.h"
56 #include "AliTPCD.h"
57
58 ClassImp(AliTPCv1)
59  
60 //_____________________________________________________________________________
61 AliTPCv1::AliTPCv1(const char *name, const char *title) 
62   :AliTPC(name, title) {
63   //
64   // Standard constructor for Time Projection Chamber
65   //
66   fIdSens1=fIdSens2=0;
67 }
68
69 //_____________________________________________________________________________
70 void AliTPCv1::CreateGeometry()
71 {
72   //
73   // Creates geometry for Time Projection Chamber version 1
74   // Detailed geometry -- Fast simulation
75   // Origin M.Kowalski 
76   //
77   //Begin_Html
78   /*
79     <img src="picts/AliTPCv1.gif">
80   */
81   //End_Html
82   //Begin_Html
83   /*
84     <img src="picts/AliTPCv1Tree.gif">
85   */
86   //End_Html
87
88   AliTPCParam * fTPCParam = &(fDigParam->GetParam());
89
90   Int_t *idtmed = fIdtmed->GetArray();
91
92   Float_t dm[21];
93   Int_t idrotm[120];
94
95   Int_t nRotMat = 0;
96
97
98   // ---------------------------------------------------- 
99   //          FIELD CAGE WITH ENDCAPS - G10
100   //          THIS IS ALSO A TPC MOTHER VOLUME 
101   // ---------------------------------------------------- 
102
103   dm[0] = 76.;
104   dm[1] = 278.;
105   dm[2] = 275.;
106
107   gMC->Gsvolu("TPC ", "TUBE", idtmed[8], dm, 3); 
108
109   //-----------------------------------------------------
110   //  Endcap cover c-fibre 0.86% X0
111   //-----------------------------------------------------
112
113   dm[0] = 78.;
114   dm[1] = 258.;
115   dm[2] = 0.95;
116
117   gMC->Gsvolu("TPEC","TUBE",idtmed[10],dm,3);
118
119   //-----------------------------------------------------
120   // Drift gas , leave 2 cm at the outer radius
121   // and inner raddius
122   //-----------------------------------------------------
123
124   dm[0] = 78.;
125   dm[1] = 258.;
126   dm[2] = 250.;
127
128   gMC->Gsvolu("TGAS", "TUBE", idtmed[3], dm, 3);
129
130
131   //------------------------------------------------------
132   //  membrane holder - carbon fiber
133   //------------------------------------------------------
134
135
136   gMC->Gsvolu("TPMH","TUBE",idtmed[6],dm,0);
137
138   dm[0] = 252.;
139   dm[1] = 258.;
140   dm[2] = 0.2;
141
142   gMC->Gsposp("TPMH",1,"TGAS",0.,0.,0.,0,"ONLY",dm,3);
143  
144   dm[0] = 78.;
145   dm[1] = 82.;
146   dm[2] = 0.1;
147
148   gMC->Gsposp("TPMH",2,"TGAS",0.,0.,0.,0,"ONLY",dm,3);
149
150   //----------------------------------------------------------
151   //  HV membrane - 25 microns of mylar
152   //----------------------------------------------------------
153
154   dm[0] = 82.;
155   dm[1] = 252.;
156   dm[2] = 0.00125;
157
158   gMC->Gsvolu("TPHV","TUBE",idtmed[5],dm,3);
159
160   gMC->Gspos("TPHV",1,"TGAS",0.,0.,0.,0,"ONLY");
161
162   gMC->Gspos("TGAS",1,"TPC ",0.,0.,0.,0,"ONLY");
163
164   //----------------------------------------------------------
165   // "side" gas volume, the same as the drift gas
166   // the readout chambers are placed there.  
167   //----------------------------------------------------------
168
169   dm[0] = 78.;
170   dm[1] = 258.;
171   dm[2] = 0.5*(275. - 250.);
172    
173   gMC->Gsvolu("TPSG", "TUBE", idtmed[2], dm, 3);
174
175   Float_t z_side = dm[2]; // 1/2 of the side gas thickness
176
177   //-----------------------------------------------------------
178   //   Readout chambers , 25% of X0, I use Al as the material
179   //-----------------------------------------------------------
180
181   Float_t InnerOpenAngle = fTPCParam->GetInnerAngle();
182   Float_t OuterOpenAngle = fTPCParam->GetOuterAngle();
183
184   Float_t InnerAngleShift = fTPCParam->GetInnerAngleShift();
185   Float_t OuterAngleShift = fTPCParam->GetOuterAngleShift();
186
187
188   Int_t nInnerSector = fTPCParam->GetNInnerSector()/2;
189   Int_t nOuterSector = fTPCParam->GetNOuterSector()/2;
190
191
192   Float_t InSecLowEdge = fTPCParam->GetInSecLowEdge();
193   Float_t InSecUpEdge =  fTPCParam->GetInSecUpEdge();
194
195   Float_t OuSecLowEdge = fTPCParam->GetOuSecLowEdge();
196   Float_t OuSecUpEdge = fTPCParam->GetOuSecUpEdge();
197
198   Float_t SecThick = 2.225; // Al
199
200   Float_t edge = fTPCParam->GetEdge();
201
202   //  S (Inner) sectors
203
204   dm[0] = InSecLowEdge*TMath::Tan(0.5*InnerOpenAngle)-edge;
205   dm[1] = InSecUpEdge*TMath::Tan(0.5*InnerOpenAngle)-edge;
206   dm[2] = 0.5*SecThick;
207   dm[3] = 0.5*(InSecUpEdge-InSecLowEdge);
208
209   Float_t xCenterS = InSecLowEdge+dm[3];
210
211   gMC->Gsvolu("TRCS", "TRD1", idtmed[0], dm, 4); 
212
213   //  L (Outer) sectors
214
215   dm[0] = OuSecLowEdge*TMath::Tan(0.5*OuterOpenAngle)-edge;
216   dm[1] = OuSecUpEdge*TMath::Tan(0.5*OuterOpenAngle)-edge;
217   dm[2] = 0.5*SecThick;
218   dm[3] = 0.5*(OuSecUpEdge-OuSecLowEdge);
219
220   Float_t xCenterL = OuSecLowEdge+dm[3];  
221
222   gMC->Gsvolu("TRCL", "TRD1", idtmed[0], dm, 4);
223
224   Float_t z1 = -z_side + SecThick*0.5;
225
226   //------------------------------------------------------------------
227   // S sectors - "gas sectors" (TRD1)
228   //------------------------------------------------------------------
229
230   dm[0] = InSecLowEdge*TMath::Tan(0.5*InnerOpenAngle)-0.01;
231   dm[1] = InSecUpEdge*TMath::Tan(0.5*InnerOpenAngle)-0.01;
232   dm[2] = 0.5*(250. - 0.001);
233   dm[3] = 0.5*(InSecUpEdge-InSecLowEdge);  
234
235   gMC->Gsvolu("TSGA", "TRD1", idtmed[3], dm, 4); // nonsensitive
236
237   //------------------------------------------------------------------
238   // sensitive strips - "pad rows"
239   //------------------------------------------------------------------
240
241   Int_t ns;
242   Float_t r1,r2,zz;
243
244   Float_t StripThick = 0.01; // 100 microns
245   Float_t dead = fTPCParam->GetDeadZone();
246
247   gMC->Gsvolu("TSST", "TRD1", idtmed[4], dm, 0);
248
249   dm[2] = 0.5*(250. - 0.002);
250   dm[3] = 0.5 * StripThick;
251
252
253   // S-sector
254
255   for (ns = 0; ns < fTPCParam->GetNRowLow(); ns++) {
256
257     r1 = fTPCParam->GetPadRowRadiiLow(ns);
258     r2 = r1 + StripThick;     
259     dm[0] = r1 * TMath::Tan(0.5*InnerOpenAngle) - dead;
260     dm[1] = r2 * TMath::Tan(0.5*InnerOpenAngle) - dead;
261
262     zz = -InSecLowEdge -0.5*(InSecUpEdge-InSecLowEdge);
263     zz += r1;
264     zz += dm[3];
265
266     gMC->Gsposp("TSST", ns+1, "TSGA", 0., 0., zz, 0, "ONLY", dm, 4);
267     
268
269   }
270
271   //-----------------------------------------------------------------
272   //  L sectors - "gas sectors" (PGON to avoid overlaps)
273   //-----------------------------------------------------------------
274
275   dm[0] = 360.*kDegrad - 0.5*OuterOpenAngle;
276   dm[0] *= kRaddeg;
277   dm[0] = (Float_t)TMath::Nint(dm[0]);
278
279   dm[1] = OuterOpenAngle*kRaddeg;
280   dm[1] = (Float_t)TMath::Nint(dm[1]);
281
282   dm[2] = 1.;
283   dm[3] = 4.;
284
285   dm[4] = 0.002;
286   dm[5] = OuSecLowEdge;
287   dm[6] = 252.*TMath::Cos(0.5*OuterOpenAngle)-0.002;
288
289   dm[7] = dm[4]+0.2;
290   dm[8] = dm[5];
291   dm[9] = dm[6];
292
293   dm[10] = dm[7];
294   dm[11] = OuSecLowEdge;
295   dm[12] = OuSecUpEdge;
296
297   dm[13] = 250.;
298   dm[14] = dm[11];
299   dm[15] = dm[12];
300
301   gMC->Gsvolu("TLGA","PGON",idtmed[3],dm,16);
302
303   //------------------------------------------------------------------
304   // sensitive strips - "pad rows"
305   //------------------------------------------------------------------
306
307   Float_t rmax = dm[6];
308
309   // L-sectors
310
311   gMC->Gsvolu("TLST", "PGON", idtmed[4], dm, 0);
312
313   dm[0] = 360.*kDegrad - 0.5*OuterOpenAngle;
314   dm[0] *= kRaddeg;
315   dm[0] = (Float_t)TMath::Nint(dm[0]);
316
317   dm[1] = OuterOpenAngle*kRaddeg;
318   dm[1] = (Float_t)TMath::Nint(dm[1]);
319
320   dm[2] = 1.;
321   dm[3] = 2.;
322
323   dm[7] = 250.;
324
325   Float_t xx = dead/TMath::Tan(0.5*OuterOpenAngle);
326
327   for(ns=0;ns<fTPCParam->GetNRowUp();ns++){
328
329     r1 = fTPCParam->GetPadRowRadiiUp(ns)-xx;
330     r2 = r1 + StripThick;
331
332     dm[5] = r1;
333     dm[6] = r2;
334
335     dm[8] = r1;
336     dm[9] = r2;
337
338     if(r2+xx < rmax){
339       dm[4] = 0.002;
340     }
341     else{
342       dm[4] = 0.202;
343     }
344
345     gMC->Gsposp("TLST",ns+1,"TLGA",xx,0.,0.,0,"ONLY",dm,10);
346
347   }
348   
349   //------------------------------------------------------------------
350   // Positioning of the S-sector readout chambers
351   //------------------------------------------------------------------
352
353   Float_t zs = 0.5*(250.+0.002);
354
355   Float_t theta1,theta2,theta3;
356   Float_t phi1,phi2,phi3;
357   Float_t alpha;
358   Float_t x,y;
359
360   for(ns=0;ns<nInnerSector;ns++){
361     
362     phi1 = ns * InnerOpenAngle + 270.*kDegrad + InnerAngleShift;
363     phi1 *= kRaddeg; // in degrees
364
365     phi1 = (Float_t)TMath::Nint(phi1);
366
367     if (phi1 > 360.) phi1 -= 360.;
368
369       
370     theta1 = 90.;
371     phi2   = 90.;
372     theta2 = 180.;
373     phi3   = ns * InnerOpenAngle + InnerAngleShift;
374     phi3 *= kRaddeg; // in degrees
375
376     phi3 = (Float_t)TMath::Nint(phi3);
377       
378     if(phi3 > 360.) phi3 -= 360.;
379
380     theta3 = 90.;
381
382     alpha = phi3*kDegrad;
383
384     x = xCenterS * TMath::Cos(alpha);
385     y = xCenterS * TMath::Sin(alpha); 
386  
387     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);  
388      
389     gMC->Gspos("TRCS", ns+1, "TPSG", x, y, z1, idrotm[nRotMat], "ONLY");
390
391     gMC->Gspos("TSGA",ns+1,"TGAS",x,y,zs,idrotm[nRotMat], "ONLY");
392     gMC->Gspos("TSGA",ns+1+nInnerSector,"TGAS",x,y,-zs,idrotm[nRotMat], "ONLY");
393
394     nRotMat++;     
395
396   }
397     
398   //-------------------------------------------------------------------
399   //  Positioning of the L-sectors readout chambers
400   //-------------------------------------------------------------------
401     
402   for(ns=0;ns<nOuterSector;ns++){
403     phi1 = ns * OuterOpenAngle + 270.*kDegrad + OuterAngleShift;
404     phi1 *= kRaddeg; // in degrees
405
406     phi1 = (Float_t)TMath::Nint(phi1);
407     
408
409     if (phi1 > 360.) phi1 -= 360.;
410       
411     theta1 = 90.;
412     phi2   = 90.;
413     theta2 = 180.;
414     phi3   = ns * OuterOpenAngle+OuterAngleShift;
415     phi3 *= kRaddeg; // in degrees
416
417     phi3 = (Float_t)TMath::Nint(phi3);
418
419       
420     if(phi3 > 360.) phi3 -= 360.;
421
422     theta3 = 90.;
423
424     alpha = phi3*kDegrad;
425
426     x = xCenterL * TMath::Cos(alpha);
427     y = xCenterL * TMath::Sin(alpha); 
428  
429     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);  
430      
431
432     gMC->Gspos("TRCL", ns+1, "TPSG", x, y, z1, idrotm[nRotMat], "ONLY"); 
433
434     nRotMat++;   
435
436   }
437
438   //-------------------------------------------------------------------
439   // Positioning of the L-sectors (gas sectors)
440   //-------------------------------------------------------------------
441
442   for(ns=0;ns<nOuterSector;ns++){
443
444      phi1 = ns*OuterOpenAngle + OuterAngleShift;
445      phi1 *= kRaddeg;
446     
447      phi1 = (Float_t)TMath::Nint(phi1);
448      if(phi1>360.) phi1 -= 360.;
449
450      theta1 = 90.;
451
452      phi2 = 90. + phi1;
453      if(phi2>360.) phi2 -= 360.;
454
455      theta2 = 90.; 
456
457      phi3 = 0.;
458      theta3 = 0.;
459
460      alpha = phi1*kDegrad;
461
462
463      AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3); 
464
465
466      gMC->Gspos("TLGA",ns+1,"TGAS" ,0.,0.,0.,idrotm[nRotMat],"ONLY");
467
468      nRotMat++;
469    
470      // reflection !!
471
472      phi3 = 0.;
473      theta3 = 180.;
474      
475      AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
476   
477      gMC->Gspos("TLGA",ns+1+nOuterSector,"TGAS" ,0.,0.,0.,idrotm[nRotMat],"ONLY");
478           
479     nRotMat++;
480   }
481   
482   Float_t z0 = z_side - 0.95;
483
484   gMC->Gspos("TPEC",1,"TPSG",0.,0.,z0,0,"ONLY");
485
486   // ========================================================== 
487   //                  wheels 
488   // ========================================================== 
489
490   //
491   //  auxilary structures
492   //
493
494
495   gMC->Gsvolu("TPWI","TUBE",idtmed[24],dm,0); // "air" 
496
497   // ---------------------------------------------------------- 
498   //       Large wheel -> positioned in the TPC 
499   // ---------------------------------------------------------- 
500   
501
502   z0 = 263.5; // TPC length - 1/2 spoke wheel width
503
504   dm[0] = 258.;
505   dm[1] = 278.;
506   dm[2] = 11.5;
507   
508   gMC->Gsvolu("TPWL", "TUBE", idtmed[0], dm, 3); 
509
510   dm[0] = dm[0]+2.;
511   dm[1] = 278.;
512   dm[2] = dm[2]-2.;
513
514   gMC->Gsposp("TPWI",1,"TPWL",0.,0.,0.,0,"ONLY",dm,3);
515
516   gMC->Gspos("TPWL", 1, "TPC ", 0, 0, z0, 0, "ONLY");
517   gMC->Gspos("TPWL", 2, "TPC ", 0, 0, -z0, 0, "ONLY");
518
519   //
520   //  Outer vessel + CO2 HV degrader
521   //
522
523   dm[0] = 260.;
524   dm[1] = 278.;
525   dm[2] = 252.;
526
527   gMC->Gsvolu("TPCO","TUBE",idtmed[12],dm,3);
528
529   dm[0] = 275.;
530   dm[1] = 278.;
531   
532   gMC->Gsvolu("TPOV","TUBE",idtmed[10],dm,3);
533
534   gMC->Gspos("TPOV",1,"TPCO",0.,0.,0.,0,"ONLY");
535
536
537   // G10 plugs
538
539   dm[0] = 258.;
540   dm[1] = 260.;
541   dm[2] = 1.;
542
543   gMC->Gsvolu("TPG1","TUBE",idtmed[8],dm,3);
544   gMC->Gspos("TPG1",1,"TPCO",0.,0.,251.,0,"ONLY");
545   gMC->Gspos("TPG1",2,"TPCO",0.,0.,-251.,0,"ONLY");  
546
547   gMC->Gspos("TPCO",1,"TPC ",0.,0.,0.,0,"ONLY");
548
549
550   //----------------------------------------------------------
551   //  Small wheel -> positioned in "side gas
552   //----------------------------------------------------------
553
554   dm[0] = 78.;
555   dm[1] = 82.;
556   dm[2] = 11.5;
557
558   gMC->Gsvolu("TPWS", "TUBE", idtmed[0], dm, 3);
559
560   dm[0] = 78.;
561   dm[1] = dm[1]-2;
562   dm[2] = dm[2]-2.;
563
564   gMC->Gsvolu("TPW1", "TUBE", idtmed[2], dm, 3);
565   
566   gMC->Gspos("TPW1", 1, "TPWS", 0., 0., 0., 0, "ONLY");
567
568   z0 = 1.; // spoke wheel is shifted w.r.t. center of the "side gas"
569
570   gMC->Gspos("TPWS", 1, "TPSG", 0, 0, z0, 0, "ONLY");
571
572
573   // to avoid overlaps
574
575   dm[0] = 76.;
576   dm[1] = 78.;
577   dm[2] = 11.5;
578
579   gMC->Gsvolu("TPS1","TUBE",idtmed[0],dm,3);
580
581   dm[2] = 9.5;
582
583   gMC->Gsvolu("TPS2","TUBE",idtmed[24],dm,3);
584
585   gMC->Gspos("TPS2",1,"TPS1",0.,0.,0.,0,"ONLY");
586
587   z0= 263.5;
588   
589   gMC->Gspos("TPS1",1,"TPC ",0.,0.,z0,0,"ONLY");
590   gMC->Gspos("TPS1",2,"TPC ",0.,0.,-z0,0,"ONLY");
591
592   // G10 plug
593
594   dm[0] = 76.;
595   dm[1] = 78.;
596   dm[2] = 1.;
597
598   gMC->Gsvolu("TPG2","TUBE",idtmed[8],dm,3);
599
600   z0 = 251.;
601
602   gMC->Gspos("TPG2",1,"TPC ",0.,0.,z0,0,"ONLY");
603   gMC->Gspos("TPG2",2,"TPC ",0.,0.,-z0,0,"ONLY");
604
605
606   //---------------------------------------------------------
607   //  central wheel  6 (radial direction) x 4 (along z) cm2
608   //---------------------------------------------------------
609
610   dm[0] = 140.;
611   dm[1] = 146.;
612   dm[2] = 2.;
613
614   gMC->Gsvolu("TPWC","TUBE",idtmed[0],dm,3);
615
616   dm[0] = dm[0] + 2.;
617   dm[1] = dm[1] - 2.;
618   dm[2] = dm[2] - 1.;
619
620   gMC->Gsposp("TPWI",2,"TPWC",0.,0.,0.,0,"ONLY",dm,3);
621
622   z0 = z_side - 1.9 - 2.;
623
624   gMC->Gspos("TPWC",1,"TPSG",0.,0.,z0,0,"ONLY");
625
626   //
627
628   gMC->Gsvolu("TPSE","BOX ",idtmed[24],dm,0); // "empty" part of the spoke 
629
630  
631   //---------------------------------------------------------
632   //  inner spokes (nSectorInner)
633   //---------------------------------------------------------
634
635   dm[0] = 0.5*(139.9-82.1);
636   dm[1] = 3.;
637   dm[2] = 2.;
638
639   Float_t x1 = dm[0]+82.;
640
641   gMC->Gsvolu("TPSI","BOX",idtmed[0],dm,3);
642
643   dm[1] = dm[1]-1.;
644   dm[2] = dm[2]-1.;
645
646   gMC->Gsposp("TPSE",1,"TPSI",0.,0.,0.,0,"ONLY",dm,3);
647
648   for(ns=0;ns<nInnerSector;ns++){
649
650     phi1 = 0.5*InnerOpenAngle + ns*InnerOpenAngle + InnerAngleShift;
651     theta1=90.;
652     phi1 *=kRaddeg;
653
654     phi1 = (Float_t)TMath::Nint(phi1);
655     if(phi1>360.) phi1 -= 360.;    
656
657     phi2 = phi1+90.;
658     if(phi2>360.) phi2 -= 360.;
659     theta2=90.;
660     phi3=0.;
661     theta3=0.;
662
663     alpha = phi1 * kDegrad;
664     x     = x1 * TMath::Cos(alpha);
665     y     = x1 * TMath::Sin(alpha);    
666
667    AliMatrix(idrotm[nRotMat],theta1,phi1,theta2,phi2,theta3,phi3);
668
669    gMC->Gspos("TPSI",ns+1,"TPSG",x,y,z0,idrotm[nRotMat],"ONLY");  
670
671    nRotMat++;
672
673   }
674
675   //-------------------------------------------------------------
676   // outer spokes (nSectorOuter)
677   //-------------------------------------------------------------
678
679   dm[0] = 0.5*(257.9-146.1);
680   dm[1] = 3.;
681   dm[2] = 2.;
682
683   x1 = dm[0] + 146.;
684
685   gMC->Gsvolu("TPSO","BOX ",idtmed[0],dm,3);
686
687   dm[1] = dm[1] - 1.;
688   dm[2] = dm[2] - 1.;
689
690   gMC->Gsposp("TPSE",2,"TPSO",0.,0.,0.,0,"ONLY",dm,3);
691
692   for(ns=0;ns<nOuterSector;ns++){
693
694     phi1 = 0.5*OuterOpenAngle + ns*OuterOpenAngle + OuterAngleShift;
695     theta1=90.;
696     phi1 *=kRaddeg;
697
698     phi1 = (Float_t)TMath::Nint(phi1);
699     if(phi1>360.) phi1 -= 360.;
700
701     phi2 = phi1+90.;
702     if(phi2>360.) phi2 -= 360.;
703     theta2=90.;
704     phi3=0.;
705     theta3=0.;
706
707     alpha = phi1 * kDegrad;
708     x     = x1 * TMath::Cos(alpha);
709     y     = x1 * TMath::Sin(alpha);    
710
711    AliMatrix(idrotm[nRotMat],theta1,phi1,theta2,phi2,theta3,phi3);
712
713    gMC->Gspos("TPSO",ns+1,"TPSG",x,y,z0,idrotm[nRotMat],"ONLY");  
714
715    nRotMat++;
716
717   }  
718   
719
720   
721   // -------------------------------------------------------- 
722   //         put the readout chambers into the TPC 
723   // -------------------------------------------------------- 
724
725   theta1 = 90.;
726   phi1   = 0.;
727   theta2 = 90.;
728   phi2   = 270.;
729   theta3 = 180.;
730   phi3   = 0.;
731   
732   AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
733   
734   z0 = z_side + 250.;
735   
736   gMC->Gspos("TPSG", 1, "TPC ", 0, 0, z0, 0, "ONLY");
737   gMC->Gspos("TPSG", 2, "TPC ", 0, 0, -z0, idrotm[nRotMat], "ONLY");
738   
739   gMC->Gspos("TPC ", 1, "ALIC", 0, 0, 0, 0, "ONLY");
740
741   //----------------------------------------------------
742   //  Inner vessel and HV degrader
743   //----------------------------------------------------
744
745   dm[0] = 0.;
746   dm[1] = 360.;
747   dm[2] = 4.;
748   
749   dm[3] = -250.;
750   dm[4] = 74.4;
751   dm[5] = 76.;
752
753   dm[6] = -64.5;
754   dm[7] = 50.;
755   dm[8] = 76.;
756
757   dm[9] = 64.5;
758   dm[10] = 50.;
759   dm[11] = 76.;
760
761   dm[12] = 250.;
762   dm[13] = 74.4;
763   dm[14] = 76.;
764
765   gMC->Gsvolu("TPVD", "PCON", idtmed[12], dm, 15); // CO2
766
767   // cone parts
768
769   dm[0] = 0.;
770   dm[1] = 360.;
771   dm[2] = 2.;
772
773   dm[3] = 64.5;
774   dm[4] = 50.;
775   dm[5] = 51.6;
776  
777   dm[6] = 250.;
778   dm[7] = 74.4;
779   dm[8] = 76.;
780
781
782   gMC->Gsvolu("TIVC","PCON",idtmed[11],dm,9); // C-fibre
783
784   gMC->Gspos("TIVC",1,"TPVD",0.,0.,0.,0,"ONLY");
785   gMC->Gspos("TIVC",2,"TPVD",0.,0.,0.,idrotm[nRotMat],"ONLY");
786
787   // barrel part
788
789   dm[0] = 50.;
790   dm[1] = 50.5;
791   dm[2] = 64.5;
792
793   gMC->Gsvolu("TIVB","TUBE",idtmed[9],dm,3);
794
795   gMC->Gspos("TIVB",1,"TPVD",0.,0.,0.,0,"ONLY");
796
797   gMC->Gspos("TPVD",1,"ALIC",0.,0.,0.,0,"ONLY");
798
799   
800
801   
802
803   // --------------------------------------------------- 
804   //               volumes ordering 
805   // --------------------------------------------------- 
806   gMC->Gsord("TGAS", 6);
807   gMC->Gsord("TPSG", 6);
808   gMC->Gsord("TSGA", 3);
809   gMC->Gsord("TLGA", 4);
810
811 } // end of function
812
813
814 //_____________________________________________________________________________
815 void AliTPCv1::DrawDetector()
816 {
817   //
818   // Draw a shaded view of the Time Projection Chamber version 1
819   //
820
821   // Set everything unseen
822   gMC->Gsatt("*", "seen", -1);
823   // 
824   // Set ALIC mother transparent
825   gMC->Gsatt("ALIC","SEEN",0);
826   //
827   // Set the volumes visible
828   gMC->Gsatt("TPC","SEEN",0);
829   gMC->Gsatt("TGAS","SEEN",0);
830   gMC->Gsatt("TPSG","SEEN",0);
831   gMC->Gsatt("TPHV","SEEN",1);
832   gMC->Gsatt("TPMH","SEEN",1);
833   gMC->Gsatt("TPEC","SEEN",0);
834   gMC->Gsatt("TRCS","SEEN",1);
835   gMC->Gsatt("TRCL","SEEN",1);
836   gMC->Gsatt("TPWL","SEEN",1);
837   gMC->Gsatt("TPWI","SEEN",1);
838   gMC->Gsatt("TPWS","SEEN",1);
839   gMC->Gsatt("TPW1","SEEN",1);
840   gMC->Gsatt("TPS1","SEEN",1);
841   gMC->Gsatt("TPS2","SEEN",1);
842   gMC->Gsatt("TPG1","SEEN",1);
843   gMC->Gsatt("TPG2","SEEN",1);
844   gMC->Gsatt("TPWC","SEEN",1);
845   gMC->Gsatt("TPSI","SEEN",1); 
846   gMC->Gsatt("TPSO","SEEN",1);
847   gMC->Gsatt("TPCO","SEEN",1);
848   gMC->Gsatt("TPOV","SEEN",1);
849   gMC->Gsatt("TPVD","SEEN",1);
850   //
851   gMC->Gdopt("hide", "on");
852   gMC->Gdopt("shad", "on");
853   gMC->Gsatt("*", "fill", 7);
854   gMC->SetClipBox(".");
855   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
856   gMC->DefaultRange();
857   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .025, .025);
858   gMC->Gdhead(1111, "Time Projection Chamber");
859   gMC->Gdman(18, 4, "MAN");
860   gMC->Gdopt("hide","off");
861 }
862
863 //_____________________________________________________________________________
864 void AliTPCv1::CreateMaterials()
865 {
866   //
867   // Define materials for Time Projection Chamber
868   //
869   AliTPC::CreateMaterials();
870 }
871
872 //_____________________________________________________________________________
873 void AliTPCv1::Init()
874 {
875   //
876   // Initialises TPC detector after it has been created
877   //
878
879   fIdSens1=gMC->VolId("TLST"); // L-sector
880   fIdSens2=gMC->VolId("TSST"); // S-sector
881
882   printf("TPC version 1 initialized\n");
883 }
884
885 //_____________________________________________________________________________
886 void AliTPCv1::StepManager()
887 {
888   //
889   // Called at every step in the Time Projection Chamber
890   //
891   Int_t         copy, id, i;
892   Float_t       hits[4];
893   Int_t         vol[2];
894   TLorentzVector p;
895   TClonesArray &lhits = *fHits;
896
897   AliTPCParam *fTPCParam = &(fDigParam->GetParam());
898   
899   //
900
901   if(gMC->TrackCharge() && gMC->IsTrackEntering()) {
902     //
903     // Only entering charged tracks
904     //
905     if((id=gMC->CurrentVolID(copy))==fIdSens1) {
906
907       // L
908
909       vol[1]=copy-1; // row
910       id=gMC->CurrentVolOffID(1,copy);
911       vol[0]=copy+fTPCParam->GetNInnerSector()-1; // sector
912     } else if(id==fIdSens2) {
913
914       // S
915
916       vol[1]=copy-1; // row
917       id=gMC->CurrentVolOffID(1,copy); // sector
918       vol[0]=copy-1;
919     } else return;
920
921     gMC->TrackPosition(p);
922     for(i=0;i<3;++i) hits[i]=p[i];
923     hits[3]=0;
924     new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
925   }
926 }
927
928
929