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