]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCv2.cxx
Introduce standard Author and Modified fields
[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.18  1999/10/14 16:52:08  fca
19 Only use PDG codes and not GEANT ones
20
21 Revision 1.17  1999/10/08 06:27:23  fca
22 Corrected bug in the HV degrader geometry, thanks to G.Tabary
23
24 Revision 1.16  1999/10/04 13:39:54  fca
25 Correct array index problem
26
27 Revision 1.15  1999/09/29 09:24:34  fca
28 Introduction of the Copyright and cvs Log
29
30 */
31
32 ///////////////////////////////////////////////////////////////////////////////
33 //                                                                           //
34 //  Time Projection Chamber version 2 -- detailed TPC and slow simulation    //
35 //                                                                           //
36 //Begin_Html
37 /*
38 <img src="picts/AliTPCv2Class.gif">
39 */
40 //End_Html
41 //                                                                           //
42 //                                                                           //
43 ///////////////////////////////////////////////////////////////////////////////
44 #include <stdlib.h>
45
46 #include <TMath.h>
47
48 #include "AliTPCv2.h"
49 #include "AliTPCD.h"
50 #include "AliRun.h"
51 #include "AliConst.h"
52 #include "AliPDG.h"
53
54 ClassImp(AliTPCv2)
55  
56 //_____________________________________________________________________________
57 AliTPCv2::AliTPCv2(const char *name, const char *title) :
58   AliTPC(name, title) 
59 {
60   //
61   // Standard constructor for Time Projection Chamber version 2
62   //
63   fIdSens1=0;
64   fIdSens2=0;
65   SetBufferSize(128000);
66 }
67  
68 //_____________________________________________________________________________
69 void AliTPCv2::CreateGeometry()
70 {
71   //
72   // Create the geometry of Time Projection Chamber version 2
73   //
74   //Begin_Html
75   /*
76     <img src="picts/AliTPCv2.gif">
77   */
78   //End_Html
79   //Begin_Html
80   /*
81     <img src="picts/AliTPCv2Tree.gif">
82   */
83   //End_Html
84
85   AliTPCParam * fTPCParam = &(fDigParam->GetParam());
86
87   Int_t *idtmed = fIdtmed->GetArray();
88
89   Float_t dm[21];
90   Int_t idrotm[120];
91
92   Int_t nRotMat = 0;
93
94   Int_t i,ifl1,ifl2;
95
96   Int_t nInnerSector = fTPCParam->GetNInnerSector()/2;
97   Int_t nOuterSector = fTPCParam->GetNOuterSector()/2;
98   
99   // --------------------------------------------------- 
100   //        sector specification check 
101   // --------------------------------------------------- 
102   if (fSecAL >= 0) {
103     ifl1 = 0;
104     
105     for (i = 0; i < 6; ++i) {
106       if (fSecLows[i] >= 0 && fSecLows[i] < 2*nInnerSector) {
107         ifl1 = 1;
108         printf("*** SECTOR %d selected\n",fSecLows[i]);
109       }
110     }
111
112   } else {
113     printf("*** ALL LOWER SECTORS SELECTED ***\n");
114     ifl1 = 1;
115   }
116
117   if (fSecAU >= 0) {
118     ifl2 = 0;
119     
120     for (i = 0; i < 12; ++i) {
121       if (fSecUps[i] > 2*nInnerSector-1 && 
122           fSecUps[i] < 2*(nInnerSector+nOuterSector)) {
123         ifl2 = 1;
124         printf("*** SECTOR %d selected\n",fSecUps[i]);
125       }
126     }
127     
128   } else {
129     printf("*** ALL UPPER SECTORS SELECTED ***\n");
130     ifl1 = 1;
131   }
132   
133   if (ifl1 == 0 && ifl2 == 0) {
134     printf("*** ERROR: AT LEAST ONE SECTOR MUST BE SPECIFIED ***\n");
135     printf("!!! PROGRAM STOPPED !!!\n");
136     exit(1);
137   }
138   
139   if ((fSecAL < 0 || fSecAU < 0) && fSens >= 0) {
140     printf("** ERROR: STRIPS CANNOT BE SPECIFIED FOR ALL SECTORS **\n");
141     printf("!!! PROGRAM STOPPED !!!\n");
142     exit(1);
143   }
144   
145   // ---------------------------------------------------- 
146   //          FIELD CAGE WITH ENDCAPS - G10
147   //          THIS IS ALSO A TPC MOTHER VOLUME 
148   // ---------------------------------------------------- 
149
150   dm[0] = 76.;
151   dm[1] = 278.;
152   dm[2] = 275.;
153
154   gMC->Gsvolu("TPC ", "TUBE", idtmed[8], dm, 3); 
155
156   //-----------------------------------------------------
157   //  Endcap cover c-fibre 0.86% X0
158   //-----------------------------------------------------
159
160   dm[0] = 78.;
161   dm[1] = 258.;
162   dm[2] = 0.95;
163
164   gMC->Gsvolu("TPEC","TUBE",idtmed[10],dm,3);
165
166   //-----------------------------------------------------
167   // Drift gas , leave 2 cm at the outer radius
168   // and inner raddius
169   //-----------------------------------------------------
170
171   dm[0] = 78.;
172   dm[1] = 258.;
173   dm[2] = 250.;
174
175   gMC->Gsvolu("TGAS", "TUBE", idtmed[3], dm, 3);
176
177   //------------------------------------------------------
178   //  membrane holder - carbon fiber
179   //------------------------------------------------------
180
181
182   gMC->Gsvolu("TPMH","TUBE",idtmed[6],dm,0);
183
184   dm[0] = 252.;
185   dm[1] = 258.;
186   dm[2] = 0.2;
187
188   gMC->Gsposp("TPMH",1,"TGAS",0.,0.,0.,0,"ONLY",dm,3);
189  
190   dm[0] = 78.;
191   dm[1] = 82.;
192   dm[2] = 0.1;
193
194   gMC->Gsposp("TPMH",2,"TGAS",0.,0.,0.,0,"ONLY",dm,3);
195
196   //----------------------------------------------------------
197   //  HV membrane - 25 microns of mylar
198   //----------------------------------------------------------
199
200   dm[0] = 82.;
201   dm[1] = 252.;
202   dm[2] = 0.00125;
203
204   gMC->Gsvolu("TPHV","TUBE",idtmed[5],dm,3);
205
206   gMC->Gspos("TPHV",1,"TGAS",0.,0.,0.,0,"ONLY");
207
208   gMC->Gspos("TGAS",1,"TPC ",0.,0.,0.,0,"ONLY");
209
210   //----------------------------------------------------------
211   // "side" gas volume, the same as the drift gas
212   // the readout chambers are placed there.  
213   //----------------------------------------------------------
214
215   dm[0] = 78.;
216   dm[1] = 258.;
217   dm[2] = 0.5*(275. - 250.);
218    
219   gMC->Gsvolu("TPSG", "TUBE", idtmed[2], dm, 3);
220
221   Float_t z_side = dm[2]; // 1/2 of the side gas thickness
222
223   //-----------------------------------------------------------
224   //   Readout chambers , 25% of X0, I use Al as the material
225   //-----------------------------------------------------------
226
227   Float_t InnerOpenAngle = fTPCParam->GetInnerAngle();
228   Float_t OuterOpenAngle = fTPCParam->GetOuterAngle();
229
230   Float_t InnerAngleShift = fTPCParam->GetInnerAngleShift();
231   Float_t OuterAngleShift = fTPCParam->GetOuterAngleShift();
232
233   Float_t InSecLowEdge = fTPCParam->GetInSecLowEdge();
234   Float_t InSecUpEdge =  fTPCParam->GetInSecUpEdge();
235
236   Float_t OuSecLowEdge = fTPCParam->GetOuSecLowEdge();
237   Float_t OuSecUpEdge = fTPCParam->GetOuSecUpEdge();
238
239
240   Float_t SecThick = 2.225; // Al
241
242   Float_t edge = fTPCParam->GetEdge();
243
244   //  S (Inner) sectors
245
246   dm[0] = InSecLowEdge*TMath::Tan(0.5*InnerOpenAngle)-edge;
247   dm[1] = InSecUpEdge*TMath::Tan(0.5*InnerOpenAngle)-edge;
248   dm[2] = 0.5*SecThick;
249   dm[3] = 0.5*(InSecUpEdge-InSecLowEdge);
250
251   Float_t xCenterS = InSecLowEdge+dm[3];
252
253   gMC->Gsvolu("TRCS", "TRD1", idtmed[0], dm, 4); 
254
255   //  L (Outer) sectors
256
257   dm[0] = OuSecLowEdge*TMath::Tan(0.5*OuterOpenAngle)-edge;
258   dm[1] = OuSecUpEdge*TMath::Tan(0.5*OuterOpenAngle)-edge;
259   dm[2] = 0.5*SecThick;
260   dm[3] = 0.5*(OuSecUpEdge-OuSecLowEdge);
261
262   Float_t xCenterL = OuSecLowEdge+dm[3];  
263
264   gMC->Gsvolu("TRCL", "TRD1", idtmed[0], dm, 4);
265
266   Float_t z1 = -z_side + SecThick*0.5;
267
268   //------------------------------------------------------------------
269   // S sectors - "gas sectors" (TRD1)
270   //------------------------------------------------------------------
271
272   dm[0] = InSecLowEdge*TMath::Tan(0.5*InnerOpenAngle)-0.01;
273   dm[1] = InSecUpEdge*TMath::Tan(0.5*InnerOpenAngle)-0.01;
274   dm[2] = 0.5*(250. - 0.001);
275   dm[3] = 0.5*(InSecUpEdge-InSecLowEdge);  
276
277   gMC->Gsvolu("TSGA", "TRD1", idtmed[4], dm, 4); // sensitive
278
279   // ------------------------------------------------------------- 
280   //  Only for the debugging purpose and resolution calculation 
281   //  Sensitive strips at the pad-row center 
282   // ------------------------------------------------------------- 
283
284   Int_t ns;
285
286   if(fSens>=0){
287
288     Float_t r1,r2,zz;
289
290     Float_t StripThick = 0.01; // 100 microns
291     Float_t dead = fTPCParam->GetDeadZone();
292
293     gMC->Gsvolu("TSST", "TRD1", idtmed[4], dm, 0);
294
295     dm[2] = 0.5*(250. - 0.002);
296     dm[3] = 0.5 * StripThick;
297
298
299     for (ns = 0; ns < fTPCParam->GetNRowLow(); ns++) {
300
301       r1 = fTPCParam->GetPadRowRadiiLow(ns);
302       r2 = r1 + StripThick;     
303       dm[0] = r1 * TMath::Tan(0.5*InnerOpenAngle) - dead;
304       dm[1] = r2 * TMath::Tan(0.5*InnerOpenAngle) - dead;
305
306       zz = -InSecLowEdge -0.5*(InSecUpEdge-InSecLowEdge);
307       zz += r1;
308       zz += dm[3];
309
310       gMC->Gsposp("TSST", ns+1, "TSGA", 0., 0., zz, 0, "ONLY", dm, 4);
311
312     
313     }   
314
315     gMC->Gsord("TSGA", 3); 
316   
317   } // if strips selected
318
319   
320   //-----------------------------------------------------------------
321   //  L sectors - "gas sectors" (PGON to avoid overlaps)
322   //-----------------------------------------------------------------
323
324   dm[0] = 360.*kDegrad - 0.5*OuterOpenAngle;
325   dm[0] *= kRaddeg;
326   dm[0] = (Float_t)TMath::Nint(dm[0]);
327
328   dm[1] = OuterOpenAngle*kRaddeg;
329   dm[1] = (Float_t)TMath::Nint(dm[1]);
330
331   dm[2] = 1.;
332   dm[3] = 4.;
333
334   dm[4] = 0.002;
335   dm[5] = OuSecLowEdge;
336   dm[6] = 252.*TMath::Cos(0.5*OuterOpenAngle)-0.002;
337
338   dm[7] = dm[4]+0.2;
339   dm[8] = dm[5];
340   dm[9] = dm[6];
341
342   dm[10] = dm[7];
343   dm[11] = OuSecLowEdge;
344   dm[12] = OuSecUpEdge;
345
346   dm[13] = 250.;
347   dm[14] = dm[11];
348   dm[15] = dm[12];
349
350   gMC->Gsvolu("TLGA","PGON",idtmed[4],dm,16);  
351
352   if (fSens >= 0) {
353     
354     Float_t rmax = dm[6];
355     Float_t r1,r2;
356     Float_t dead = fTPCParam->GetDeadZone();
357
358     Float_t StripThick = 0.01; // 100 microns
359
360     gMC->Gsvolu("TLST", "PGON", idtmed[4], dm, 0);
361
362     dm[0] = 360.*kDegrad - 0.5*OuterOpenAngle;
363     dm[0] *= kRaddeg;
364     dm[0] = (Float_t)TMath::Nint(dm[0]);
365
366     dm[1] = OuterOpenAngle*kRaddeg;
367     dm[1] = (Float_t)TMath::Nint(dm[1]);
368
369     dm[2] = 1.;
370     dm[3] = 2.;
371
372     dm[7] = 250.;
373
374     Float_t xx = dead/TMath::Tan(0.5*OuterOpenAngle);
375
376     for(ns=0;ns<fTPCParam->GetNRowUp();ns++){
377
378       r1 = fTPCParam->GetPadRowRadiiUp(ns)-xx;
379       r2 = r1 + StripThick;
380
381       dm[5] = r1;
382       dm[6] = r2;
383
384       dm[8] = r1;
385       dm[9] = r2;
386
387       if(r2+xx < rmax){
388         dm[4] = 0.002;
389       }
390       else{
391         dm[4] = 0.202;
392       }
393
394       gMC->Gsposp("TLST",ns+1,"TLGA",xx,0.,0.,0,"ONLY",dm,10);
395
396     }    
397
398         gMC->Gsord("TLGA", 4);
399
400   } // if strips selected
401
402   //------------------------------------------------------------------
403   // Positioning of the S-sector readout chambers
404   //------------------------------------------------------------------
405
406   Float_t zs = 0.5*(250.+0.002);
407
408   Float_t theta1,theta2,theta3;
409   Float_t phi1,phi2,phi3;
410   Float_t alpha;
411   Float_t x,y;
412
413   for(ns=0;ns<nInnerSector;ns++){
414     
415     phi1 = ns * InnerOpenAngle + 270.*kDegrad + InnerAngleShift;
416     phi1 *= kRaddeg; // in degrees
417
418     phi1 = (Float_t)TMath::Nint(phi1);
419
420     if (phi1 > 360.) phi1 -= 360.;
421       
422     theta1 = 90.;
423     phi2   = 90.;
424     theta2 = 180.;
425     phi3   = ns * InnerOpenAngle + InnerAngleShift;
426     phi3 *= kRaddeg; // in degrees
427
428     phi3 = (Float_t)TMath::Nint(phi3);
429       
430     if(phi3 > 360.) phi3 -= 360.;
431
432     theta3 = 90.;
433
434     alpha = phi3*kDegrad;
435
436     x = xCenterS * TMath::Cos(alpha);
437     y = xCenterS * TMath::Sin(alpha); 
438  
439     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);  
440      
441     gMC->Gspos("TRCS", ns+1, "TPSG", x, y, z1, idrotm[nRotMat], "ONLY");
442
443     if(fSecAL < 0){
444
445       //---------------------------------------------------------------
446       //  position all sectors
447       //---------------------------------------------------------------
448
449       gMC->Gspos("TSGA",ns+1,"TGAS",x,y,zs,idrotm[nRotMat], "ONLY");
450       gMC->Gspos("TSGA",ns+1+nInnerSector,"TGAS",x,y,-zs,idrotm[nRotMat], "ONLY");
451     }
452
453     else{
454
455       //---------------------------------------------------------------
456       //  position selected sectors
457       //---------------------------------------------------------------
458
459       for(Int_t sel=0;sel<6;sel++){
460
461         if(fSecLows[sel] == ns){
462         gMC->Gspos("TSGA", ns+1, "TGAS", x, y, zs, idrotm[nRotMat], "ONLY");
463         }
464         else if(fSecLows[sel] == ns+nInnerSector){
465         gMC->
466           Gspos("TSGA",ns+1+nInnerSector,"TGAS", x, y,-zs,idrotm[nRotMat],"ONLY");
467         }
468       }
469     }
470
471     nRotMat++;     
472
473   }
474     
475   //-------------------------------------------------------------------
476   //  Positioning of the L-sectors readout chambers
477   //-------------------------------------------------------------------
478     
479   for(ns=0;ns<nOuterSector;ns++){
480     phi1 = ns * OuterOpenAngle + 270.*kDegrad + OuterAngleShift;
481     phi1 *= kRaddeg; // in degrees
482
483     phi1 = (Float_t)TMath::Nint(phi1);
484     
485
486     if (phi1 > 360.) phi1 -= 360.;
487       
488     theta1 = 90.;
489     phi2   = 90.;
490     theta2 = 180.;
491     phi3   = ns * OuterOpenAngle+OuterAngleShift;
492     phi3 *= kRaddeg; // in degrees
493
494     phi3 = (Float_t)TMath::Nint(phi3);
495
496       
497     if(phi3 > 360.) phi3 -= 360.;
498
499     theta3 = 90.;
500
501     alpha = phi3*kDegrad;
502
503     x = xCenterL * TMath::Cos(alpha);
504     y = xCenterL * TMath::Sin(alpha); 
505  
506     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);  
507      
508
509     gMC->Gspos("TRCL", ns+1, "TPSG", x, y, z1, idrotm[nRotMat], "ONLY"); 
510
511     nRotMat++;   
512
513   }
514
515   //-------------------------------------------------------------------
516   // Positioning of the L-sectors (gas sectors)
517   //-------------------------------------------------------------------
518
519   for(ns=0;ns<nOuterSector;ns++){
520
521      phi1 = ns*OuterOpenAngle + OuterAngleShift;
522      phi1 *= kRaddeg;
523     
524      phi1 = (Float_t)TMath::Nint(phi1);
525      if(phi1>360.) phi1 -= 360.;
526
527      theta1 = 90.;
528
529      phi2 = 90. + phi1;
530      if(phi2>360.) phi2 -= 360.;
531
532      theta2 = 90.; 
533
534      phi3 = 0.;
535      theta3 = 0.;
536
537      if(fSecAU < 0) {
538
539        //--------------------------------------------------------------
540        //  position all sectors
541        //--------------------------------------------------------------
542
543        AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3); 
544
545        gMC->Gspos("TLGA",ns+1,"TGAS" ,0.,0.,0.,idrotm[nRotMat],"ONLY");
546
547        nRotMat++;
548    
549        // reflection !!
550
551        phi3 = 0.;
552        theta3 = 180.;
553      
554        AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
555   
556        gMC->Gspos("TLGA",ns+1+nOuterSector,"TGAS" ,0.,0.,0.,idrotm[nRotMat],"ONLY");
557           
558        nRotMat++;
559      }
560
561      else{
562
563        //---------------------------------------------------------------
564        //  position selected sectors
565        //---------------------------------------------------------------
566
567        for(Int_t sel=0;sel<12;sel++){
568
569          if(fSecUps[sel] == ns+2*nInnerSector){
570            
571           AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3); 
572           gMC->Gspos("TLGA",ns+1,"TGAS" ,0.,0.,0.,idrotm[nRotMat],"ONLY");
573           nRotMat++; 
574
575          }
576          else if(fSecUps[sel] == ns+2*nInnerSector+nOuterSector){
577
578            // reflection
579
580            phi3 = 0.;
581            theta3 = 180.;
582
583            AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
584            gMC->
585            Gspos("TLGA",ns+1+nOuterSector,"TGAS" ,0.,0.,0.,idrotm[nRotMat],"ONLY");
586            nRotMat++; 
587
588          }
589
590        }
591
592      }
593
594   }
595   
596   Float_t z0 = z_side - 0.95;
597
598   gMC->Gspos("TPEC",1,"TPSG",0.,0.,z0,0,"ONLY");
599
600   // ========================================================== 
601   //                  wheels 
602   // ========================================================== 
603
604   //
605   //  auxilary structures
606   //
607
608
609   gMC->Gsvolu("TPWI","TUBE",idtmed[24],dm,0); // "air" 
610
611   // ---------------------------------------------------------- 
612   //       Large wheel -> positioned in the TPC 
613   // ---------------------------------------------------------- 
614   
615
616   z0 = 263.5; // TPC length - 1/2 spoke wheel width
617
618   dm[0] = 258.;
619   dm[1] = 278.;
620   dm[2] = 11.5;
621   
622   gMC->Gsvolu("TPWL", "TUBE", idtmed[0], dm, 3); 
623
624   dm[0] = dm[0]+2.;
625   dm[1] = 278.;
626   dm[2] = dm[2]-2.;
627
628   gMC->Gsposp("TPWI",1,"TPWL",0.,0.,0.,0,"ONLY",dm,3);
629
630   gMC->Gspos("TPWL", 1, "TPC ", 0, 0, z0, 0, "ONLY");
631   gMC->Gspos("TPWL", 2, "TPC ", 0, 0, -z0, 0, "ONLY");
632
633   //
634   //  Outer vessel + CO2 HV degrader
635   //
636
637   dm[0] = 260.;
638   dm[1] = 278.;
639   dm[2] = 252.;
640
641   gMC->Gsvolu("TPCO","TUBE",idtmed[12],dm,3);
642
643   dm[0] = 275.;
644   dm[1] = 278.;
645   
646   gMC->Gsvolu("TPOV","TUBE",idtmed[10],dm,3);
647
648   gMC->Gspos("TPOV",1,"TPCO",0.,0.,0.,0,"ONLY");
649
650
651   // G10 plugs
652
653   dm[0] = 258.;
654   dm[1] = 260.;
655   dm[2] = 1.;
656
657   gMC->Gsvolu("TPG1","TUBE",idtmed[8],dm,3);
658   gMC->Gspos("TPG1",1,"TPCO",0.,0.,251.,0,"ONLY");
659   gMC->Gspos("TPG1",2,"TPCO",0.,0.,-251.,0,"ONLY");  
660
661   gMC->Gspos("TPCO",1,"TPC ",0.,0.,0.,0,"ONLY");
662
663
664   //----------------------------------------------------------
665   //  Small wheel -> positioned in "side gas
666   //----------------------------------------------------------
667
668   dm[0] = 78.;
669   dm[1] = 82.;
670   dm[2] = 11.5;
671
672   gMC->Gsvolu("TPWS", "TUBE", idtmed[0], dm, 3);
673
674   dm[0] = 78.;
675   dm[1] = dm[1]-2;
676   dm[2] = dm[2]-2.;
677
678   gMC->Gsvolu("TPW1", "TUBE", idtmed[2], dm, 3);
679   
680   gMC->Gspos("TPW1", 1, "TPWS", 0., 0., 0., 0, "ONLY");
681
682   z0 = 1.; // spoke wheel is shifted w.r.t. center of the "side gas"
683
684   gMC->Gspos("TPWS", 1, "TPSG", 0, 0, z0, 0, "ONLY");
685
686
687   // to avoid overlaps
688
689   dm[0] = 76.;
690   dm[1] = 78.;
691   dm[2] = 11.5;
692
693   gMC->Gsvolu("TPS1","TUBE",idtmed[0],dm,3);
694
695   dm[2] = 9.5;
696
697   gMC->Gsvolu("TPS2","TUBE",idtmed[24],dm,3);
698
699   gMC->Gspos("TPS2",1,"TPS1",0.,0.,0.,0,"ONLY");
700
701   z0= 263.5;
702   
703   gMC->Gspos("TPS1",1,"TPC ",0.,0.,z0,0,"ONLY");
704   gMC->Gspos("TPS1",2,"TPC ",0.,0.,-z0,0,"ONLY");
705
706   // G10 plug
707
708   dm[0] = 76.;
709   dm[1] = 78.;
710   dm[2] = 1.;
711
712   gMC->Gsvolu("TPG2","TUBE",idtmed[8],dm,3);
713
714   z0 = 251.;
715
716   gMC->Gspos("TPG2",1,"TPC ",0.,0.,z0,0,"ONLY");
717   gMC->Gspos("TPG2",2,"TPC ",0.,0.,-z0,0,"ONLY");
718
719
720   //---------------------------------------------------------
721   //  central wheel  6 (radial direction) x 4 (along z) cm2
722   //---------------------------------------------------------
723
724   dm[0] = 140.;
725   dm[1] = 146.;
726   dm[2] = 2.;
727
728   gMC->Gsvolu("TPWC","TUBE",idtmed[0],dm,3);
729
730   dm[0] = dm[0] + 2.;
731   dm[1] = dm[1] - 2.;
732   dm[2] = dm[2] - 1.;
733
734   gMC->Gsposp("TPWI",2,"TPWC",0.,0.,0.,0,"ONLY",dm,3);
735
736   z0 = z_side - 1.9 - 2.;
737
738   gMC->Gspos("TPWC",1,"TPSG",0.,0.,z0,0,"ONLY");
739
740   //
741
742   gMC->Gsvolu("TPSE","BOX ",idtmed[24],dm,0); // "empty" part of the spoke 
743
744  
745   //---------------------------------------------------------
746   //  inner spokes (nSectorInner)
747   //---------------------------------------------------------
748
749   dm[0] = 0.5*(139.9-82.1);
750   dm[1] = 3.;
751   dm[2] = 2.;
752
753   Float_t x1 = dm[0]+82.;
754
755   gMC->Gsvolu("TPSI","BOX",idtmed[0],dm,3);
756
757   dm[1] = dm[1]-1.;
758   dm[2] = dm[2]-1.;
759
760   gMC->Gsposp("TPSE",1,"TPSI",0.,0.,0.,0,"ONLY",dm,3);
761
762   for(ns=0;ns<nInnerSector;ns++){
763
764     phi1 = 0.5*InnerOpenAngle + ns*InnerOpenAngle + InnerAngleShift;
765     theta1=90.;
766     phi1 *=kRaddeg;
767
768     phi1 = (Float_t)TMath::Nint(phi1);
769     if(phi1>360.) phi1 -= 360.;    
770
771     phi2 = phi1+90.;
772     if(phi2>360.) phi2 -= 360.;
773     theta2=90.;
774     phi3=0.;
775     theta3=0.;
776
777     alpha = phi1 * kDegrad;
778     x     = x1 * TMath::Cos(alpha);
779     y     = x1 * TMath::Sin(alpha);    
780
781    AliMatrix(idrotm[nRotMat],theta1,phi1,theta2,phi2,theta3,phi3);
782
783    gMC->Gspos("TPSI",ns+1,"TPSG",x,y,z0,idrotm[nRotMat],"ONLY");  
784
785    nRotMat++;
786
787   }
788
789   //-------------------------------------------------------------
790   // outer spokes (nSectorOuter)
791   //-------------------------------------------------------------
792
793   dm[0] = 0.5*(257.9-146.1);
794   dm[1] = 3.;
795   dm[2] = 2.;
796
797   x1 = dm[0] + 146.;
798
799   gMC->Gsvolu("TPSO","BOX ",idtmed[0],dm,3);
800
801   dm[1] = dm[1] - 1.;
802   dm[2] = dm[2] - 1.;
803
804   gMC->Gsposp("TPSE",2,"TPSO",0.,0.,0.,0,"ONLY",dm,3);
805
806   for(ns=0;ns<nOuterSector;ns++){
807
808     phi1 = 0.5*OuterOpenAngle + ns*OuterOpenAngle + OuterAngleShift;
809     theta1=90.;
810     phi1 *=kRaddeg;
811
812     phi1 = (Float_t)TMath::Nint(phi1);
813     if(phi1>360.) phi1 -= 360.;
814
815     phi2 = phi1+90.;
816     if(phi2>360.) phi2 -= 360.;
817     theta2=90.;
818     phi3=0.;
819     theta3=0.;
820
821     alpha = phi1 * kDegrad;
822     x     = x1 * TMath::Cos(alpha);
823     y     = x1 * TMath::Sin(alpha);    
824
825    AliMatrix(idrotm[nRotMat],theta1,phi1,theta2,phi2,theta3,phi3);
826
827    gMC->Gspos("TPSO",ns+1,"TPSG",x,y,z0,idrotm[nRotMat],"ONLY");  
828
829    nRotMat++;
830
831   }  
832   
833
834   
835   // -------------------------------------------------------- 
836   //         put the readout chambers into the TPC 
837   // -------------------------------------------------------- 
838
839   theta1 = 90.;
840   phi1   = 0.;
841   theta2 = 90.;
842   phi2   = 270.;
843   theta3 = 180.;
844   phi3   = 0.;
845   
846   AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
847   
848   z0 = z_side + 250.;
849   
850   gMC->Gspos("TPSG", 1, "TPC ", 0, 0, z0, 0, "ONLY");
851   gMC->Gspos("TPSG", 2, "TPC ", 0, 0, -z0, idrotm[nRotMat], "ONLY");
852   
853   gMC->Gspos("TPC ", 1, "ALIC", 0, 0, 0, 0, "ONLY");
854
855   //----------------------------------------------------
856   //  Inner vessel and HV degrader
857   //----------------------------------------------------
858
859   dm[0] = 0.;
860   dm[1] = 360.;
861   dm[2] = 4.;
862   
863   dm[3] = -250.;
864   dm[4] = 74.4;
865   dm[5] = 76.;
866
867   dm[6] = -64.5;
868   dm[7] = 50.;
869   dm[8] = 76.;
870
871   dm[9] = 64.5;
872   dm[10] = 50.;
873   dm[11] = 76.;
874
875   dm[12] = 250.;
876   dm[13] = 74.4;
877   dm[14] = 76.;
878
879   gMC->Gsvolu("TPVD", "PCON", idtmed[12], dm, 15); // CO2
880
881   // cone parts
882
883   dm[0] = 0.;
884   dm[1] = 360.;
885   dm[2] = 2.;
886
887   dm[3] = 64.5;
888   dm[4] = 50.;
889   dm[5] = 51.6;
890  
891   dm[6] = 250.;
892   dm[7] = 74.4;
893   dm[8] = 76.;
894
895
896   gMC->Gsvolu("TIVC","PCON",idtmed[11],dm,9); // C-fibre
897
898   gMC->Gspos("TIVC",1,"TPVD",0.,0.,0.,0,"ONLY");
899   gMC->Gspos("TIVC",2,"TPVD",0.,0.,0.,idrotm[nRotMat],"ONLY");
900
901   // barrel part
902
903   dm[0] = 50.;
904   dm[1] = 50.5;
905   dm[2] = 64.5;
906
907   gMC->Gsvolu("TIVB","TUBE",idtmed[9],dm,3);
908
909   gMC->Gspos("TIVB",1,"TPVD",0.,0.,0.,0,"ONLY");
910
911   gMC->Gspos("TPVD",1,"ALIC",0.,0.,0.,0,"ONLY");
912
913
914   // --------------------------------------------------- 
915   //               volumes ordering 
916   // ---------------------------------------------------
917
918   gMC->Gsord("TGAS", 6);
919   gMC->Gsord("TPSG", 6); 
920
921   
922
923 } // end of function
924  
925 //_____________________________________________________________________________
926 void AliTPCv2::DrawDetector()
927 {
928   //
929   // Draw a shaded view of the Time Projection Chamber version 1
930   //
931
932   // Set everything unseen
933   gMC->Gsatt("*", "seen", -1);
934   // 
935   // Set ALIC mother transparent
936   gMC->Gsatt("ALIC","SEEN",0);
937   //
938   // Set the volumes visible
939   gMC->Gsatt("TPC","SEEN",0);
940   gMC->Gsatt("TGAS","SEEN",0);
941   gMC->Gsatt("TPSG","SEEN",0);
942   gMC->Gsatt("TPHV","SEEN",1);
943   gMC->Gsatt("TPMH","SEEN",1);
944   gMC->Gsatt("TPEC","SEEN",0);
945   gMC->Gsatt("TRCS","SEEN",1);
946   gMC->Gsatt("TRCL","SEEN",1);
947   gMC->Gsatt("TPWL","SEEN",1);
948   gMC->Gsatt("TPWI","SEEN",1);
949   gMC->Gsatt("TPWS","SEEN",1);
950   gMC->Gsatt("TPW1","SEEN",1);
951   gMC->Gsatt("TPS1","SEEN",1);
952   gMC->Gsatt("TPS2","SEEN",1);
953   gMC->Gsatt("TPG1","SEEN",1);
954   gMC->Gsatt("TPG2","SEEN",1);
955   gMC->Gsatt("TPWC","SEEN",1);
956   gMC->Gsatt("TPSI","SEEN",1); 
957   gMC->Gsatt("TPSO","SEEN",1);
958   gMC->Gsatt("TPCO","SEEN",1);
959   gMC->Gsatt("TPOV","SEEN",1);
960   gMC->Gsatt("TPVD","SEEN",1);
961   //
962   gMC->Gdopt("hide", "on");
963   gMC->Gdopt("shad", "on");
964   gMC->Gsatt("*", "fill", 7);
965   gMC->SetClipBox(".");
966   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
967   gMC->DefaultRange();
968   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .025, .025);
969   gMC->Gdhead(1111, "Time Projection Chamber");
970   gMC->Gdman(18, 4, "MAN");
971   gMC->Gdopt("hide","off");
972 }
973
974 //_____________________________________________________________________________
975 void AliTPCv2::CreateMaterials()
976 {
977   //
978   // Define materials for version 2 of the Time Projection Chamber
979   //
980
981   //
982   // Increase maximum number of steps
983   gMC->SetMaxNStep(30000);
984   //
985   AliTPC::CreateMaterials();
986 }
987
988 //_____________________________________________________________________________
989 void AliTPCv2::Init()
990 {
991   //
992   // Initialises version 2 of the TPC after that it has been built
993   //
994   Int_t *idtmed = fIdtmed->GetArray()-399;
995   AliTPC::Init();
996   fIdSens1=gMC->VolId("TLGA"); // L-sector
997   fIdSens2=gMC->VolId("TSGA"); // S-sector 
998   fIdSens3=gMC->VolId("TSST"); // strip - S-sector (not always used)
999   fIdSens4=gMC->VolId("TLST"); // strip - S-sector (not always used)
1000
1001   gMC->SetMaxNStep(30000); // max. number of steps increased
1002
1003   gMC->Gstpar(idtmed[403],"LOSS",5);
1004
1005   printf("*** TPC version 2 initialized ***\n");
1006   printf("Maximum number of steps = %d\n",gMC->GetMaxNStep());
1007
1008   //
1009   
1010 }
1011
1012 //_____________________________________________________________________________
1013 void AliTPCv2::StepManager()
1014 {
1015   //
1016   // Called for every step in the Time Projection Chamber
1017   //
1018
1019   //
1020   // parameters used for the energy loss calculations
1021   //
1022   const Float_t prim = 14.35; // number of primary collisions per 1 cm
1023   const Float_t poti = 20.77e-9; // first ionization potential for Ne/CO2
1024   const Float_t w_ion = 35.97e-9; // energy for the ion-electron pair creation 
1025
1026   //  const Float_t prim = 17.65;
1027   //  const Float_t poti = 19.02e-9;
1028   // const Float_t w_ion = 33.06e-9;
1029  
1030  
1031   const Float_t big = 1.e10;
1032
1033   Int_t id,copy;
1034   Float_t hits[4];
1035   Int_t vol[2];  
1036   TClonesArray &lhits = *fHits;
1037   TLorentzVector pos;
1038
1039   AliTPCParam *fTPCParam = &(fDigParam->GetParam());
1040   
1041   vol[1]=0;
1042
1043   //
1044
1045   gMC->SetMaxStep(big);
1046   
1047   if(!gMC->IsTrackAlive()) return; // particle has disappeared
1048   
1049   Float_t charge = gMC->TrackCharge();
1050   
1051   if(TMath::Abs(charge)<=0.) return; // take only charged particles
1052   
1053   
1054   id=gMC->CurrentVolID(copy);
1055   
1056   // Check the sensitive volume
1057   
1058   if(id == fIdSens1) 
1059     {
1060       vol[0] = copy + fTPCParam->GetNInnerSector()-1; // L-sector number
1061     }
1062   else if(id == fIdSens2) 
1063     {
1064       vol[0] = copy-1; // S-sector number 
1065     }
1066   else if(id == fIdSens3 && gMC->IsTrackEntering())
1067     {
1068       vol[1] = copy-1;  // row number  
1069       id = gMC->CurrentVolOffID(1,copy);
1070       vol[0] = copy-1; // sector number (S-sector)
1071       
1072       gMC->TrackPosition(pos);
1073       hits[0]=pos[0];
1074       hits[1]=pos[1];
1075       hits[2]=pos[2];
1076       hits[3]=0.; // this hit has no energy loss
1077       new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
1078     }
1079   else if(id == fIdSens4 && gMC->IsTrackEntering())
1080     {
1081       vol[1] = copy-1; // row number 
1082       id = gMC->CurrentVolOffID(1,copy);
1083       vol[0] = copy+fTPCParam->GetNInnerSector()-1; // sector number (L-sector)
1084       
1085       gMC->TrackPosition(pos);
1086       hits[0]=pos[0];
1087       hits[1]=pos[1];
1088       hits[2]=pos[2];
1089       hits[3]=0.; // this hit has no energy loss
1090       new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
1091     }
1092   else return;
1093   
1094   //
1095   //  charged particle is in the sensitive volume
1096   //
1097   
1098   if(gMC->TrackStep() > 0) {
1099     
1100     Int_t nel = (Int_t)(((gMC->Edep())-poti)/w_ion) + 1;
1101     nel=TMath::Min(nel,300); // 300 electrons corresponds to 10 keV
1102     
1103     gMC->TrackPosition(pos);
1104     hits[0]=pos[0];
1105     hits[1]=pos[1];
1106     hits[2]=pos[2];
1107     hits[3]=(Float_t)nel;
1108     
1109     // Add this hit
1110     
1111     new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
1112     
1113   } 
1114   
1115   // Stemax calculation for the next step
1116   
1117   Float_t pp;
1118   TLorentzVector mom;
1119   gMC->TrackMomentum(mom);
1120   Float_t ptot=mom.Rho();
1121   Float_t beta_gamma = ptot/gMC->TrackMass();
1122   
1123   Int_t pid=gMC->TrackPid();
1124   if((pid==kElectron || pid==kPositron || pid==kGamma) && ptot > 0.002)
1125     { 
1126       pp = prim*1.58; // electrons above 20 MeV/c are on the plateau!
1127     }
1128   else
1129     {
1130       pp=prim*BetheBloch(beta_gamma);    
1131       if(TMath::Abs(charge) > 1.) pp *= (charge*charge);
1132     }
1133   
1134   Float_t random[1];
1135   gMC->Rndm(random,1); // good, old GRNDM from Geant3
1136   
1137   Double_t rnd = (Double_t)random[0];
1138   
1139   gMC->SetMaxStep(-TMath::Log(rnd)/pp);
1140   
1141 }
1142
1143 //_____________________________________________________________________________
1144 Float_t AliTPCv2::BetheBloch(Float_t bg)
1145 {
1146   //
1147   // Bethe-Bloch energy loss formula
1148   //
1149   const Double_t p1=0.76176e-1;
1150   const Double_t p2=10.632;
1151   const Double_t p3=0.13279e-4;
1152   const Double_t p4=1.8631;
1153   const Double_t p5=1.9479;
1154
1155   Double_t dbg = (Double_t) bg;
1156
1157   Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
1158
1159   Double_t aa = TMath::Power(beta,p4);
1160   Double_t bb = TMath::Power(1./dbg,p5);
1161
1162   bb=TMath::Log(p3+bb);
1163   
1164   return ((Float_t)((p2-aa-bb)*p1/aa));
1165 }