Corrected a problem in rotation matrix number assignment
[u/mrichter/AliRoot.git] / TPC / AliTPCv0.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  Time Projection Chamber version 0 -- "coarse" TPC                        //
4 //                                                                           //
5 //Begin_Html
6 /*
7 <img src="picts/AliTPCv0Class.gif">
8 */
9 //End_Html
10 //                                                                           //
11 //                                                                           //
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #include <TMath.h>
15 #include <TGeometry.h>
16 #include <TNode.h>
17 #include <TTUBE.h>
18 #include "AliTPCv0.h"
19 #include "AliRun.h"
20 #include <iostream.h>
21 #include <fstream.h>
22
23 #include "AliMC.h"
24 #include "AliConst.h"
25
26 #include "AliTPCParam.h"
27 #include "AliTPCD.h"
28
29 ClassImp(AliTPCv0)
30  
31 //_____________________________________________________________________________
32 AliTPCv0::AliTPCv0(const char *name, const char *title) 
33          :AliTPC(name, title)
34 {
35   //
36   // Standard creator for TPC version 0
37   //
38 }
39
40 //_____________________________________________________________________________
41 void AliTPCv0::CreateGeometry()
42 {
43   //
44   // Creation of the TPC coarse geometry (version 0)
45   // Origin Marek Kowalski Crakow
46   //
47   //Begin_Html
48   /*
49     <img src="picts/AliTPCv0.gif">
50   */
51   //End_Html
52   //Begin_Html
53   /*
54     <img src="picts/AliTPCv0Tree.gif">
55   */
56   //End_Html
57
58   AliTPCParam * fTPCParam = &(fDigParam->GetParam());
59
60   Int_t *idtmed = fIdtmed->GetArray();
61
62   Float_t dm[21];
63   Int_t idrotm[120];
64
65   Int_t nRotMat = 0;
66
67
68   // ---------------------------------------------------- 
69   //          FIELD CAGE WITH ENDCAPS - G10
70   //          THIS IS ALSO A TPC MOTHER VOLUME 
71   // ---------------------------------------------------- 
72
73   dm[0] = 76.;
74   dm[1] = 278.;
75   dm[2] = 275.;
76
77   gMC->Gsvolu("TPC ", "TUBE", idtmed[8], dm, 3); 
78
79   //-----------------------------------------------------
80   //  Endcap cover c-fibre 0.86% X0
81   //-----------------------------------------------------
82
83   dm[0] = 78.;
84   dm[1] = 258.;
85   dm[2] = 0.95;
86
87   gMC->Gsvolu("TPEC","TUBE",idtmed[10],dm,3);
88
89   //-----------------------------------------------------
90   // Drift gas , leave 2 cm at the outer radius
91   // and inner raddius
92   //-----------------------------------------------------
93
94   dm[0] = 78.;
95   dm[1] = 258.;
96   dm[2] = 250.;
97
98   gMC->Gsvolu("TGAS", "TUBE", idtmed[3], dm, 3);
99
100
101   //------------------------------------------------------
102   //  membrane holder - carbon fiber
103   //------------------------------------------------------
104
105
106   gMC->Gsvolu("TPMH","TUBE",idtmed[6],dm,0);
107
108   dm[0] = 252.;
109   dm[1] = 258.;
110   dm[2] = 0.2;
111
112   gMC->Gsposp("TPMH",1,"TGAS",0.,0.,0.,0,"ONLY",dm,3);
113  
114   dm[0] = 78.;
115   dm[2] = 82.;
116   dm[2] = 0.1;
117
118   gMC->Gsposp("TPMH",2,"TGAS",0.,0.,0.,0,"ONLY",dm,3);
119
120   //----------------------------------------------------------
121   //  HV membrane - 25 microns of mylar
122   //----------------------------------------------------------
123
124   dm[0] = 82.;
125   dm[1] = 252.;
126   dm[2] = 0.00125;
127
128   gMC->Gsvolu("TPHV","TUBE",idtmed[5],dm,3);
129
130   gMC->Gspos("TPHV",1,"TGAS",0.,0.,0.,0,"ONLY");
131
132   gMC->Gspos("TGAS",1,"TPC ",0.,0.,0.,0,"ONLY");
133
134   //----------------------------------------------------------
135   // "side" gas volume, the same as the drift gas
136   // the readout chambers are placed there.  
137   //----------------------------------------------------------
138
139   dm[0] = 78.;
140   dm[1] = 258.;
141   dm[2] = 0.5*(275. - 250.);
142    
143   gMC->Gsvolu("TPSG", "TUBE", idtmed[2], dm, 3);
144
145   Float_t z_side = dm[2]; // 1/2 of the side gas thickness
146
147   //-----------------------------------------------------------
148   //   Readout chambers , 25% of X0, I use Al as the material
149   //-----------------------------------------------------------
150
151   Float_t InnerOpenAngle = fTPCParam->GetInnerAngle();
152   Float_t OuterOpenAngle = fTPCParam->GetOuterAngle();
153
154   Float_t InnerAngleShift = fTPCParam->GetInnerAngleShift();
155   Float_t OuterAngleShift = fTPCParam->GetOuterAngleShift();
156
157
158   Int_t nInnerSector = fTPCParam->GetNInnerSector()/2;
159   Int_t nOuterSector = fTPCParam->GetNOuterSector()/2;
160
161
162   Float_t InSecLowEdge = fTPCParam->GetInSecLowEdge();
163   Float_t InSecUpEdge =  fTPCParam->GetInSecUpEdge();
164
165   Float_t OuSecLowEdge = fTPCParam->GetOuSecLowEdge();
166   Float_t OuSecUpEdge = fTPCParam->GetOuSecUpEdge();
167
168   Float_t SecThick = 2.225; // Al
169
170   Float_t edge = fTPCParam->GetEdge();
171
172   //  S (Inner) sectors
173
174   dm[0] = InSecLowEdge*TMath::Tan(0.5*InnerOpenAngle)-edge;
175   dm[1] = InSecUpEdge*TMath::Tan(0.5*InnerOpenAngle)-edge;
176   dm[2] = SecThick;
177   dm[3] = 0.5*(InSecUpEdge-InSecLowEdge);
178
179   Float_t xCenterS = InSecLowEdge+dm[3];
180
181   gMC->Gsvolu("TRCS", "TRD1", idtmed[0], dm, 4); 
182
183   //  L (Outer) sectors
184
185   dm[0] = OuSecLowEdge*TMath::Tan(0.5*OuterOpenAngle)-edge;
186   dm[1] = OuSecUpEdge*TMath::Tan(0.5*OuterOpenAngle)-edge;
187   dm[2] = SecThick;
188   dm[3] = 0.5*(OuSecUpEdge-OuSecLowEdge);
189
190   Float_t xCenterL = OuSecLowEdge+dm[3];  
191
192   gMC->Gsvolu("TRCL", "TRD1", idtmed[0], dm, 4);
193
194   Float_t z1 = -z_side + SecThick*0.5;
195
196   //------------------------------------------------------------------
197   // Positioning of the S-sector readout chambers
198   //------------------------------------------------------------------
199
200   Int_t ns;
201   Float_t theta1,theta2,theta3;
202   Float_t phi1,phi2,phi3;
203   Float_t alpha;
204   Float_t x,y;
205
206   for(ns=0;ns<nInnerSector;ns++){
207     
208     phi1 = ns * InnerOpenAngle + 270.*kDegrad + InnerAngleShift;
209     phi1 *= kRaddeg; // in degrees
210
211     phi1 = (Float_t)TMath::Nint(phi1);
212
213     if (phi1 > 360.) phi1 -= 360.;
214       
215     theta1 = 90.;
216     phi2   = 90.;
217     theta2 = 180.;
218     phi3   = ns * InnerOpenAngle + InnerAngleShift;
219     phi3 *= kRaddeg; // in degrees
220
221     phi3 = (Float_t)TMath::Nint(phi3);
222       
223     if(phi3 > 360.) phi3 -= 360.;
224
225     theta3 = 90.;
226
227     alpha = phi3*kDegrad;
228
229     x = xCenterS * TMath::Cos(alpha);
230     y = xCenterS * TMath::Sin(alpha); 
231  
232     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);  
233      
234     gMC->Gspos("TRCS", ns+1, "TPSG", x, y, z1, idrotm[nRotMat], "ONLY");
235
236     nRotMat++;     
237
238   }
239     
240   //-------------------------------------------------------------------
241   //  Positioning of the L-sectors readout chambers
242   //-------------------------------------------------------------------
243     
244   for(ns=0;ns<nOuterSector;ns++){
245     phi1 = ns * OuterOpenAngle + 270.*kDegrad + OuterAngleShift;
246     phi1 *= kRaddeg; // in degrees
247
248     phi1 = (Float_t)TMath::Nint(phi1);
249     
250
251     if (phi1 > 360.) phi1 -= 360.;
252       
253     theta1 = 90.;
254     phi2   = 90.;
255     theta2 = 180.;
256     phi3   = ns * OuterOpenAngle+OuterAngleShift;
257     phi3 *= kRaddeg; // in degrees
258
259     phi3 = (Float_t)TMath::Nint(phi3);
260
261       
262     if(phi3 > 360.) phi3 -= 360.;
263
264     theta3 = 90.;
265
266     alpha = phi3*kDegrad;
267
268     x = xCenterL * TMath::Cos(alpha);
269     y = xCenterL * TMath::Sin(alpha); 
270  
271     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);  
272      
273
274     gMC->Gspos("TRCL", ns+1, "TPSG", x, y, z1, idrotm[nRotMat], "ONLY"); 
275
276     nRotMat++;   
277
278   }
279
280   Float_t z0 = z_side - 0.95;
281
282   gMC->Gspos("TPEC",1,"TPSG",0.,0.,z0,0,"ONLY");
283
284   // ========================================================== 
285   //                  wheels 
286   // ========================================================== 
287
288   //
289   //  auxilary structures
290   //
291
292
293   gMC->Gsvolu("TPWI","TUBE",idtmed[24],dm,0); // "air" 
294
295   // ---------------------------------------------------------- 
296   //       Large wheel -> positioned in the TPC 
297   // ---------------------------------------------------------- 
298   
299
300   z0 = 263.5; // TPC length - 1/2 spoke wheel width
301
302   dm[0] = 258.;
303   dm[1] = 278.;
304   dm[2] = 11.5;
305   
306   gMC->Gsvolu("TPWL", "TUBE", idtmed[0], dm, 3); 
307
308   dm[0] = dm[0]+2.;
309   dm[1] = 278.;
310   dm[2] = dm[2]-2.;
311
312   gMC->Gsposp("TPWI",1,"TPWL",0.,0.,0.,0,"ONLY",dm,3);
313
314   gMC->Gspos("TPWL", 1, "TPC ", 0, 0, z0, 0, "ONLY");
315   gMC->Gspos("TPWL", 2, "TPC ", 0, 0, -z0, 0, "ONLY");
316
317   //
318   //  Outer vessel + CO2 HV degrader
319   //
320
321   dm[0] = 260.;
322   dm[1] = 278.;
323   dm[2] = 252.;
324
325   gMC->Gsvolu("TPCO","TUBE",idtmed[12],dm,3);
326
327   dm[0] = 275.;
328   dm[1] = 278.;
329   
330   gMC->Gsvolu("TPOV","TUBE",idtmed[10],dm,3);
331
332   gMC->Gspos("TPOV",1,"TPCO",0.,0.,0.,0,"ONLY");
333
334
335   // G10 plugs
336
337   dm[0] = 258.;
338   dm[1] = 260.;
339   dm[2] = 1.;
340
341   gMC->Gsvolu("TPG1","TUBE",idtmed[8],dm,3);
342   gMC->Gspos("TPG1",1,"TPCO",0.,0.,251.,0,"ONLY");
343   gMC->Gspos("TPG1",2,"TPCO",0.,0.,-251.,0,"ONLY");  
344
345   gMC->Gspos("TPCO",1,"TPC ",0.,0.,0.,0,"ONLY");
346
347
348   //----------------------------------------------------------
349   //  Small wheel -> positioned in "side gas
350   //----------------------------------------------------------
351
352   dm[0] = 78.;
353   dm[1] = 82.;
354   dm[2] = 11.5;
355
356   gMC->Gsvolu("TPWS", "TUBE", idtmed[0], dm, 3);
357
358   dm[0] = 78.;
359   dm[1] = dm[1]-2;
360   dm[2] = dm[2]-2.;
361
362   gMC->Gsvolu("TPW1", "TUBE", idtmed[2], dm, 3);
363   
364   gMC->Gspos("TPW1", 1, "TPWS", 0., 0., 0., 0, "ONLY");
365
366   z0 = 1.; // spoke wheel is shifted w.r.t. center of the "side gas"
367
368   gMC->Gspos("TPWS", 1, "TPSG", 0, 0, z0, 0, "ONLY");
369
370
371   // to avoid overlaps
372
373   dm[0] = 76.;
374   dm[1] = 78.;
375   dm[2] = 11.5;
376
377   gMC->Gsvolu("TPS1","TUBE",idtmed[0],dm,3);
378
379   dm[2] = 9.5;
380
381   gMC->Gsvolu("TPS2","TUBE",idtmed[24],dm,3);
382
383   gMC->Gspos("TPS2",1,"TPS1",0.,0.,0.,0,"ONLY");
384
385   z0= 263.5;
386   
387   gMC->Gspos("TPS1",1,"TPC ",0.,0.,z0,0,"ONLY");
388   gMC->Gspos("TPS1",2,"TPC ",0.,0.,-z0,0,"ONLY");
389
390   // G10 plug
391
392   dm[0] = 76.;
393   dm[2] = 78.;
394   dm[3] = 1.;
395
396   gMC->Gsvolu("TPG2","TUBE",idtmed[8],dm,3);
397
398   z0 = 251.;
399
400   gMC->Gspos("TPG2",1,"TPC ",0.,0.,z0,0,"ONLY");
401   gMC->Gspos("TPG2",2,"TPC ",0.,0.,-z0,0,"ONLY");
402
403
404   //---------------------------------------------------------
405   //  central wheel  6 (radial direction) x 4 (along z) cm2
406   //---------------------------------------------------------
407
408   dm[0] = 140.;
409   dm[1] = 146.;
410   dm[2] = 2.;
411
412   gMC->Gsvolu("TPWC","TUBE",idtmed[0],dm,3);
413
414   dm[0] = dm[0] + 2.;
415   dm[1] = dm[1] - 2.;
416   dm[2] = dm[2] - 1.;
417
418   gMC->Gsposp("TPWI",2,"TPWC",0.,0.,0.,0,"ONLY",dm,3);
419
420   z0 = z_side - 1.9 - 2.;
421
422   gMC->Gspos("TPWC",1,"TPSG",0.,0.,z0,0,"ONLY");
423
424   //
425
426   gMC->Gsvolu("TPSE","BOX ",idtmed[24],dm,0); // "empty" part of the spoke 
427
428  
429   //---------------------------------------------------------
430   //  inner spokes (nSectorInner)
431   //---------------------------------------------------------
432
433   dm[0] = 0.5*(139.9-82.1);
434   dm[1] = 3.;
435   dm[2] = 2.;
436
437   Float_t x1 = dm[0]+82.;
438
439   gMC->Gsvolu("TPSI","BOX",idtmed[0],dm,3);
440
441   dm[1] = dm[1]-1.;
442   dm[2] = dm[2]-1.;
443
444   gMC->Gsposp("TPSE",1,"TPSI",0.,0.,0.,0,"ONLY",dm,3);
445
446   for(ns=0;ns<nInnerSector;ns++){
447
448     phi1 = 0.5*InnerOpenAngle + ns*InnerOpenAngle + InnerAngleShift;
449     theta1=90.;
450     phi1 *=kRaddeg;
451
452     phi1 = (Float_t)TMath::Nint(phi1);
453
454     phi2 = phi1+90.;
455     if(phi2>360.) phi2 -= 360.;
456     theta2=90.;
457     phi3=0.;
458     theta3=0.;
459
460     alpha = phi1 * kDegrad;
461     x     = x1 * TMath::Cos(alpha);
462     y     = x1 * TMath::Sin(alpha);    
463
464    AliMatrix(idrotm[nRotMat],theta1,phi1,theta2,phi2,theta3,phi3);
465
466    gMC->Gspos("TPSI",ns+1,"TPSG",x,y,z0,idrotm[nRotMat],"ONLY");  
467
468    nRotMat++;
469
470   }
471
472   //-------------------------------------------------------------
473   // outer spokes (nSectorOuter)
474   //-------------------------------------------------------------
475
476   dm[0] = 0.5*(257.9-146.1);
477   dm[1] = 3.;
478   dm[2] = 2.;
479
480   x1 = dm[0] + 146.;
481
482   gMC->Gsvolu("TPSO","BOX ",idtmed[0],dm,3);
483
484   dm[1] = dm[1] - 1.;
485   dm[2] = dm[2] - 1.;
486
487   gMC->Gsposp("TPSE",2,"TPSO",0.,0.,0.,0,"ONLY",dm,3);
488
489   for(ns=0;ns<nOuterSector;ns++){
490
491     phi1 = 0.5*OuterOpenAngle + ns*OuterOpenAngle + OuterAngleShift;
492     theta1=90.;
493     phi1 *=kRaddeg;
494
495     phi1 = (Float_t)TMath::Nint(phi1);
496
497     phi2 = phi1+90.;
498     if(phi2>360.) phi2 -= 360.;
499     theta2=90.;
500     phi3=0.;
501     theta3=0.;
502
503     alpha = phi1 * kDegrad;
504     x     = x1 * TMath::Cos(alpha);
505     y     = x1 * TMath::Sin(alpha);    
506
507    AliMatrix(idrotm[nRotMat],theta1,phi1,theta2,phi2,theta3,phi3);
508
509    gMC->Gspos("TPSO",ns+1,"TPSG",x,y,z0,idrotm[nRotMat],"ONLY");  
510
511    nRotMat++;
512
513   }  
514   
515
516   
517   // -------------------------------------------------------- 
518   //         put the readout chambers into the TPC 
519   // -------------------------------------------------------- 
520
521   theta1 = 90.;
522   phi1   = 0.;
523   theta2 = 90.;
524   phi2   = 270.;
525   theta3 = 180.;
526   phi3   = 0.;
527   
528   AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
529   
530   z0 = z_side + 250.;
531   
532   gMC->Gspos("TPSG", 1, "TPC ", 0, 0, z0, 0, "ONLY");
533   gMC->Gspos("TPSG", 2, "TPC ", 0, 0, -z0, idrotm[nRotMat], "ONLY");
534   
535   gMC->Gspos("TPC ", 1, "ALIC", 0, 0, 0, 0, "ONLY");
536
537   //----------------------------------------------------
538   //  Inner vessel and HV degrader
539   //----------------------------------------------------
540
541   dm[0] = 0.;
542   dm[1] = 360.;
543   dm[2] = 4.;
544   
545   dm[3] = -250.;
546   dm[4] = 74.4;
547   dm[5] = 76.;
548
549   dm[6] = -64.5;
550   dm[7] = 50.;
551   dm[8] = 76.;
552
553   dm[9] = -64.5;
554   dm[10] = 50.;
555   dm[11] = 76.;
556
557   dm[12] = 250.;
558   dm[13] = 74.4;
559   dm[14] = 76.;
560
561   gMC->Gsvolu("TPVD", "PCON", idtmed[12], dm, 15); // CO2
562
563   // cone parts
564
565   dm[0] = 0.;
566   dm[1] = 360.;
567   dm[2] = 2.;
568
569   dm[3] = 64.5;
570   dm[4] = 50.;
571   dm[5] = 51.6;
572  
573   dm[6] = 250.;
574   dm[7] = 74.4;
575   dm[8] = 76.;
576
577
578   gMC->Gsvolu("TIVC","PCON",idtmed[11],dm,9); // C-fibre
579
580   gMC->Gspos("TIVC",1,"TPVD",0.,0.,0.,0,"ONLY");
581   gMC->Gspos("TIVC",2,"TPVD",0.,0.,0.,idrotm[nRotMat],"ONLY");
582
583   // barrel part
584
585   dm[0] = 50.;
586   dm[1] = 50.5;
587   dm[2] = 32.25;
588
589   gMC->Gsvolu("TIVB","TUBE",idtmed[9],dm,3);
590
591   gMC->Gspos("TIVB",1,"TPVD",0.,0.,0.,0,"ONLY");
592
593   gMC->Gspos("TPVD",1,"ALIC",0.,0.,0.,0,"ONLY");
594
595   
596
597   
598
599   // --------------------------------------------------- 
600   //               volumes ordering 
601   // --------------------------------------------------- 
602   gMC->Gsord("TPSG", 6);
603  
604 } // end of function
605
606
607 //_____________________________________________________________________________
608 void AliTPCv0::CreateMaterials()
609 {
610   //
611   // Define materials for the TPC
612   //
613   AliTPC::CreateMaterials();
614 }
615
616 //_____________________________________________________________________________
617 void AliTPCv0::DrawDetector()
618 {
619   //
620   // Draw a shaded view of the Time Projection Chamber version 0
621   //
622
623   // Set everything unseen
624   gMC->Gsatt("*", "seen", -1);
625   // 
626   // Set ALIC mother transparent
627   gMC->Gsatt("ALIC","SEEN",0);
628   //
629   // Set the volumes visible
630   gMC->Gsatt("TPC","SEEN",0);
631   gMC->Gsatt("TGAS","SEEN",0);
632   gMC->Gsatt("TPSG","SEEN",0);
633   gMC->Gsatt("TPHV","SEEN",1);
634   gMC->Gsatt("TPMH","SEEN",1);
635   gMC->Gsatt("TPEC","SEEN",0);
636   gMC->Gsatt("TRCS","SEEN",1);
637   gMC->Gsatt("TRCL","SEEN",1);
638   gMC->Gsatt("TPWL","SEEN",1);
639   gMC->Gsatt("TPWI","SEEN",1);
640   gMC->Gsatt("TPWS","SEEN",1);
641   gMC->Gsatt("TPW1","SEEN",1);
642   gMC->Gsatt("TPS1","SEEN",1);
643   gMC->Gsatt("TPS2","SEEN",1);
644   gMC->Gsatt("TPG1","SEEN",1);
645   gMC->Gsatt("TPG2","SEEN",1);
646   gMC->Gsatt("TPWC","SEEN",1);
647   gMC->Gsatt("TPSI","SEEN",1); 
648   gMC->Gsatt("TPSO","SEEN",1);
649   gMC->Gsatt("TPCO","SEEN",1);
650   gMC->Gsatt("TPOV","SEEN",1);
651   gMC->Gsatt("TPVD","SEEN",1);
652   //
653   gMC->Gdopt("hide", "on");
654   gMC->Gdopt("shad", "on");
655   gMC->Gsatt("*", "fill", 7);
656   gMC->SetClipBox(".");
657   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
658   gMC->DefaultRange();
659   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .025, .025);
660   gMC->Gdhead(1111, "Time Projection Chamber");
661   gMC->Gdman(18, 4, "MAN");
662   gMC->Gdopt("hide","off");
663 }
664
665 //_____________________________________________________________________________
666 void AliTPCv0::Init()
667 {
668   //
669   // Initialise Time Projection Chamber version 0
670   //
671   printf("TPC version 0 initialized\n");
672 }
673
674 //_____________________________________________________________________________
675 void AliTPCv0::StepManager()
676 {
677   //
678   // Procedure called at each step in the TPC
679   //
680 }