Geometry rewritten in the TGeo modeler.
[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 /* $Id$ */
17
18 //
19 ///////////////////////////////////////////////////////////////////////////////
20 //                                                                           //
21 //  Time Projection Chamber version 1 -- detailed TPC and fast simulation    //
22 //                                                                           // 
23 //Begin_Html
24 /*
25 <img src="picts/AliTPCv1Class.gif">
26 */
27 //End_Html
28 //                                                                           //
29 //                                                                           //
30 ///////////////////////////////////////////////////////////////////////////////
31
32 #include <Riostream.h>
33 #include <stdlib.h>
34 #include <TBRIK.h>
35 #include <TGeometry.h>
36 #include <TInterpreter.h>
37 #include <TMath.h>
38 #include <TNode.h>
39 #include <TTUBE.h>
40 #include <TVirtualMC.h>
41
42 #include "AliConst.h"
43 #include "AliRun.h"
44 #include "AliTPCDigitsArray.h"
45 #include "AliTPCParam.h"
46 #include "AliTPCParamSR.h"
47 #include "AliTPCv1.h"
48 #include "TLorentzVector.h"
49 #include "AliMC.h"
50 #include "TGeoManager.h"
51 #include "TGeoVolume.h"
52 #include "TGeoPcon.h"
53 #include "TGeoTube.h"
54 #include "TGeoPgon.h"
55 #include "TGeoTrd1.h"
56 #include "TGeoCompositeShape.h"
57 #include "TGeoPara.h"
58 ClassImp(AliTPCv1)
59
60 //_____________________________________________________________________________
61
62   AliTPCv1::AliTPCv1(){
63
64   fHitType = 1;
65
66 }
67  
68 //_____________________________________________________________________________
69 AliTPCv1::AliTPCv1(const char *name, const char *title) 
70   :AliTPC(name, title) {
71   //
72   // Standard constructor for Time Projection Chamber
73   //
74   fIdSens=0;
75
76
77   if (fTPCParam)
78      fTPCParam->Write(fTPCParam->GetTitle());
79
80   fHitType=1;
81 }
82
83 //_____________________________________________________________________________
84 void AliTPCv1::CreateGeometry()
85 {
86   //-------------------------------------------------------------
87   // Creates geometry for Time Projection Chamber version 1
88   // Detailed geometry -- Fast simulation - space points
89   // at the pad-rows centers
90   // Origin M.Kowalski, INP Cracow, Marek.Kowalski@ifj.edu.pl
91   //-----------------------------------------------------------
92
93   //Begin_Html
94   /*
95     <img src="picts/AliTPC.gif">
96   */
97   //End_Html
98   //Begin_Html
99   /*
100     <img src="picts/AliTPCv1Tree.gif">
101   */
102   //End_Html
103   //----------------------------------------------------------
104   // This geometry is written using TGeo class
105   // Firstly the shapes are defined, and only then the volumes
106   // What is recognized by the MC are volumes
107   //----------------------------------------------------------
108   //
109   //  tpc - this will be the mother volume
110   //
111
112   //
113   // here I define a volume TPC
114   // retrive the medium name with "TPC_" as a leading string
115   //
116   TGeoPcon *tpc = new TGeoPcon(0.,360.,18); //18 sections
117   tpc->DefineSection(0,-290.,77.,278.);
118   tpc->DefineSection(1,-259.6,77.,278.);
119   //
120   tpc->DefineSection(2,-259.6,68.1,278.);
121   tpc->DefineSection(3,-253.6,68.1,278.);
122   //
123   tpc->DefineSection(4,-253.6,68.,278.);
124   tpc->DefineSection(5,-74.0,60.8,278.);
125   //
126   tpc->DefineSection(6,-74.0,60.1,278.);
127   tpc->DefineSection(7,-73.3,60.1,278.);
128   //
129   tpc->DefineSection(8,-73.3,56.9,278.); 
130   tpc->DefineSection(9,73.3,56.9,278.);
131   //
132   tpc->DefineSection(10,73.3,60.1,278.);
133   tpc->DefineSection(11,74.0,60.1,278.);
134   //
135   tpc->DefineSection(12,74.0,60.8,278.);
136   tpc->DefineSection(13,253.6,65.5,278.);
137   //
138   tpc->DefineSection(14,253.6,65.6,278.);
139   tpc->DefineSection(15,259.6,65.6,278.);
140   //
141   tpc->DefineSection(16,259.6,77.0,278.);
142   tpc->DefineSection(17,290.,77.,278.);
143   //
144   TGeoMedium *m1 = gGeoManager->GetMedium("TPC_Air");
145   TGeoVolume *v1 = new TGeoVolume("TPC_M",tpc,m1);
146   //
147   // drift volume - sensitive volume, extended beyond the
148   // endcaps, because of the alignment
149   //
150   TGeoPcon *dvol = new TGeoPcon(0.,360.,6);
151   dvol->DefineSection(0,-260.,74.5,264.4);
152   dvol->DefineSection(1,-253.6,74.5,264.4);
153   //
154   dvol->DefineSection(2,-253.6,76.6774,258.);
155   dvol->DefineSection(3,253.6,76.6774,258.); 
156   //
157   dvol->DefineSection(4,253.6,74.5,264.4);
158   dvol->DefineSection(5,260.,74.5,264.4);
159   //
160   TGeoMedium *m5 = gGeoManager->GetMedium("TPC_Ne-CO2-N-1");
161   TGeoVolume *v9 = new TGeoVolume("TPC_Drift",dvol,m5);
162   //
163   //
164   v1->AddNode(v9,1);
165   //
166   // outer insulator
167   //
168   TGeoPcon *tpco = new TGeoPcon(0.,360.,6); //insulator
169   //
170   tpco->DefineSection(0,-256.6,264.8,278.);
171   tpco->DefineSection(1,-253.6,264.8,278.);
172   //
173   tpco->DefineSection(2,-253.6,258.,278.);
174   tpco->DefineSection(3,250.6,258.,278.);
175   //
176   tpco->DefineSection(4,250.6,258.,275.5);
177   tpco->DefineSection(5,253.6,258.,275.5);
178   //
179   TGeoMedium *m2 = gGeoManager->GetMedium("TPC_CO2");
180   TGeoVolume *v2 = new TGeoVolume("TPC_OI",tpco,m2);
181   //
182   // outer containment vessel
183   //
184   TGeoPcon *tocv = new TGeoPcon(0.,360.,6);  // containment vessel
185   //
186   tocv->DefineSection(0,-256.6,264.8,278.);
187   tocv->DefineSection(1,-253.6,264.8,278.);
188   //
189   tocv->DefineSection(2,-253.6,274.8124,278.);
190   tocv->DefineSection(3,247.6,274.8124,278.);  
191   //
192   tocv->DefineSection(4,247.6,270.4,278.);
193   tocv->DefineSection(5,250.6,270.4,278.);
194   //
195   TGeoMedium *m3 = gGeoManager->GetMedium("TPC_Al");
196   TGeoVolume *v3 = new TGeoVolume("TPC_OCV",tocv,m3); 
197   //
198   TGeoTube *to1 = new TGeoTube(274.8174,277.995,252.1); //epoxy
199   TGeoTube *to2 = new TGeoTube(274.8274,277.985,252.1); //tedlar
200   TGeoTube *to3 = new TGeoTube(274.8312,277.9812,252.1);//prepreg2
201   TGeoTube *to4 = new TGeoTube(274.9062,277.9062,252.1);//nomex
202   //
203   TGeoMedium *sm1 = gGeoManager->GetMedium("TPC_Epoxy");
204   TGeoMedium *sm2 = gGeoManager->GetMedium("TPC_Tedlar");
205   TGeoMedium *sm3 = gGeoManager->GetMedium("TPC_Prepreg2");
206   TGeoMedium *sm4 = gGeoManager->GetMedium("TPC_Nomex");
207   //
208   TGeoVolume *tov1 = new TGeoVolume("TPC_OCV1",to1,sm1);
209   TGeoVolume *tov2 = new TGeoVolume("TPC_OCV2",to2,sm2);
210   TGeoVolume *tov3 = new TGeoVolume("TPC_OCV3",to3,sm3);
211   TGeoVolume *tov4 = new TGeoVolume("TPC_OCV4",to4,sm4);
212
213   //-------------------------------------------------------
214   //  Tpc Outer Field Cage
215   //  daughters - composite (sandwich)
216   //-------------------------------------------------------
217
218   TGeoPcon *tofc = new TGeoPcon(0.,360.,6);
219   //
220   tofc->DefineSection(0,-253.6,258.,269.6);
221   tofc->DefineSection(1,-250.6,258.,269.6);
222   //
223   tofc->DefineSection(2,-250.6,258.,260.0676); 
224   tofc->DefineSection(3,250.6,258.,260.0676);
225   //
226   tofc->DefineSection(4,250.6,258.,275.5);
227   tofc->DefineSection(5,253.6,258.,275.5);
228   //
229   TGeoVolume *v4 = new TGeoVolume("TPC_TOFC",tofc,m3); 
230   //sandwich
231   TGeoTube *tf1 = new TGeoTube(258.0,260.0676,252.1); //tedlar
232   TGeoTube *tf2 = new TGeoTube(258.0038,260.0638,252.1); //prepreg3
233   TGeoTube *tf3 = new TGeoTube(258.0338,260.0338,252.1);//nomex
234   //
235   TGeoMedium *sm5 = gGeoManager->GetMedium("TPC_Prepreg3");
236   //
237   TGeoVolume *tf1v = new TGeoVolume("TPC_OFC1",tf1,sm2);
238   TGeoVolume *tf2v = new TGeoVolume("TPC_OFC2",tf2,sm5);
239   TGeoVolume *tf3v = new TGeoVolume("TPC_OFC3",tf3,sm4);
240   //
241   // outer part - positioning
242   //
243   tov1->AddNode(tov2,1); tov2->AddNode(tov3,1); tov3->AddNode(tov4,1);
244   //
245   tf1v->AddNode(tf2v,1); tf2v->AddNode(tf3v,1);
246   //
247   v3->AddNode(tov1,1); v4->AddNode(tf1v,1);
248   //
249   v2->AddNode(v3,1); v2->AddNode(v4,1); 
250   //
251   v1->AddNode(v2,1);
252   //--------------------------------------------------------------------
253   // Tpc Inner INsulator (CO2) 
254   // the cones, the central drum and the inner f.c. sandwich with a piece
255   // of the flane will be placed in the TPC
256   //--------------------------------------------------------------------
257   TGeoPcon *tpci = new TGeoPcon(0.,360.,4);
258   //
259   tpci->DefineSection(0,-253.6,68.4,76.6774);
260   tpci->DefineSection(1,-74.0,61.2,76.6774);
261   //
262   tpci->DefineSection(2,74.0,61.2,76.6774);  
263   //
264   tpci->DefineSection(3,253.6,65.9,76.6774);
265   //
266   TGeoVolume *v5 = new TGeoVolume("TPC_INI",tpci,m2);
267   //
268   // now the inner field cage - only part of flanges (2 copies)
269   //
270   TGeoTube *tif1 = new TGeoTube(69.9,76.6774,1.5); 
271   TGeoVolume *v6 = new TGeoVolume("TPC_IFC1",tif1,m3);
272   //
273  //---------------------------------------------------------
274   // Tpc Inner Containment vessel - Muon side
275   //---------------------------------------------------------
276   TGeoPcon *tcms = new TGeoPcon(0.,360.,10);
277   //
278   tcms->DefineSection(0,-259.1,68.1,74.2);
279   tcms->DefineSection(1,-253.6,68.1,74.2);
280   //
281   tcms->DefineSection(2,-253.6,68.1,68.4);
282   tcms->DefineSection(3,-74.0,60.9,61.2);
283   //
284   tcms->DefineSection(4,-74.0,60.1,61.2);
285   tcms->DefineSection(5,-73.3,60.1,61.2);
286   //
287   tcms->DefineSection(6,-73.3,56.9,61.2);
288   tcms->DefineSection(7,-73.0,56.9,61.2);
289   //
290   tcms->DefineSection(8,-73.0,56.9,58.8);
291   tcms->DefineSection(9,-71.3,56.9,58.8);
292   //
293   TGeoVolume *v7 = new TGeoVolume("TPC_ICVM",tcms,m3);
294   //-----------------------------------------------
295   // inner containment vessel - shaft side
296   //-----------------------------------------------
297   TGeoPcon *tcss = new TGeoPcon(0.,360.,10);
298   //
299   tcss->DefineSection(0,71.3,56.9,58.8);
300   tcss->DefineSection(1,73.0,56.9,58.8);
301   //
302   tcss->DefineSection(2,73.0,56.9,61.2);
303   tcss->DefineSection(3,73.3,56.9,61.2);
304   //  
305   tcss->DefineSection(4,73.3,60.1,61.2);
306   tcss->DefineSection(5,74.0,60.1,61.2);
307   //
308   tcss->DefineSection(6,74.0,60.9,61.2);
309   tcss->DefineSection(7,253.6,65.6,65.9);
310   //
311   tcss->DefineSection(8,253.6,65.6,74.2);
312   tcss->DefineSection(9,258.1,65.6,74.2);
313   //
314   TGeoVolume *v8 = new TGeoVolume("TPC_ICVS",tcss,m3);
315   //-----------------------------------------------
316   //  Inner field cage
317   //  define 4 parts and make an assembly
318   //-----------------------------------------------
319   // part1 - Al - 2 copies
320   TGeoTube *t1 = new TGeoTube(76.6774,78.845,0.75);
321   TGeoVolume *tv1 = new TGeoVolume("TPC_IFC2",t1,m3);
322   // sandwich - outermost parts - 2 copies
323   TGeoTube *t2 = new TGeoTube(76.6774,78.845,74.175); // tedlar 38 microns
324   TGeoTube *t3 = new TGeoTube(76.6812,78.8412,74.175); // prepreg2 500 microns
325   TGeoTube *t4 = new TGeoTube(76.7312,78.7912,74.175); // prepreg3 300 microns
326   TGeoTube *t5 = new TGeoTube(76.7612,78.7612,74.175); // nomex 2 cm
327   //
328   TGeoVolume *tv2 = new TGeoVolume("TPC_IFC3",t2,sm2);
329   TGeoVolume *tv3 = new TGeoVolume("TPC_IFC4",t3,sm3);
330   TGeoVolume *tv4 = new TGeoVolume("TPC_IFC5",t4,sm5);
331   TGeoVolume *tv5 = new TGeoVolume("TPC_IFC6",t5,sm4);
332   //
333   // middle parts - 2 copies
334   TGeoTube *t6 = new TGeoTube(76.6774,78.795,5.); // tedlar 38 microns
335   TGeoTube *t7 = new TGeoTube(76.6812,78.7912,5.); // prepreg2 250 microns
336   TGeoTube *t8 = new TGeoTube(76.7062,78.7662,5.); // prepreg3 300 microns
337   TGeoTube *t9 = new TGeoTube(76.7362,78.7362,5.); // nomex 2 cm
338   //
339   TGeoVolume *tv6 = new TGeoVolume("TPC_IFC7",t6,sm2);
340   TGeoVolume *tv7 = new TGeoVolume("TPC_IFC8",t7,sm3);
341   TGeoVolume *tv8 = new TGeoVolume("TPC_IFC9",t8,sm5);
342   TGeoVolume *tv9 = new TGeoVolume("TPC_IFC10",t9,sm4);
343   // central part - 1 copy
344   TGeoTube *t10 = new TGeoTube(76.6774,78.745,93.75); // tedlar 38 microns 
345   TGeoTube *t11 = new TGeoTube(76.6812,78.7412,93.75); // prepreg3 300 microns
346   TGeoTube *t12 = new TGeoTube(76.7112,78.7112,93.75); // nomex 2 cm
347   //
348   TGeoVolume *tv10 = new TGeoVolume("TPC_IFC11",t10,sm2);
349   TGeoVolume *tv11 = new TGeoVolume("TPC_IFC12",t11,sm5);
350   TGeoVolume *tv12 = new TGeoVolume("TPC_IFC13",t12,sm4);
351   //
352   // inner part - positioning
353   //
354   // creating a sandwich
355   tv2->AddNode(tv3,1); tv3->AddNode(tv4,1); tv4->AddNode(tv5,1);
356   //
357   tv6->AddNode(tv7,1); tv7->AddNode(tv8,1); tv8->AddNode(tv9,1);
358   //
359   tv10->AddNode(tv11,1); tv11->AddNode(tv12,1);
360   //
361   TGeoVolumeAssembly *tv100 = new TGeoVolumeAssembly("TPC_IFC");
362   //
363   tv100->AddNode(tv10,1);
364   tv100->AddNode(tv6,1,new TGeoTranslation(0.,0.,-98.75));
365   tv100->AddNode(tv6,2,new TGeoTranslation(0.,0.,98.75));
366   tv100->AddNode(tv2,1,new TGeoTranslation(0.,0.,-177.925));
367   tv100->AddNode(tv2,2,new TGeoTranslation(0.,0.,177.925));
368   tv100->AddNode(tv1,1,new TGeoTranslation(0.,0.,-252.85));
369   tv100->AddNode(tv1,2,new TGeoTranslation(0.,0.,252.85));
370   //
371   v5->AddNode(v6,1, new TGeoTranslation(0.,0.,-252.1));
372   v5->AddNode(v6,2, new TGeoTranslation(0.,0.,252.1));
373   v1->AddNode(v5,1); v1->AddNode(v7,1); v1->AddNode(v8,1); 
374   v9->AddNode(tv100,1);
375   //
376   // central drum 
377   //
378   // flange + sandwich
379   //
380   TGeoPcon *cfl = new TGeoPcon(0.,360.,6);
381   cfl->DefineSection(0,-71.1,59.7,61.2);
382   cfl->DefineSection(1,-68.6,59.7,61.2);
383   //
384   cfl->DefineSection(2,-68.6,60.6324,61.2);
385   cfl->DefineSection(3,68.6,60.6324,61.2); 
386   //
387   cfl->DefineSection(4,68.6,59.7,61.2);
388   cfl->DefineSection(5,71.1,59.7,61.2);  
389   //
390   TGeoVolume *cflv = new TGeoVolume("TPC_CDR",cfl,m3);
391   // sandwich
392   TGeoTube *cd1 = new TGeoTube(60.6424,61.19,71.1);
393   TGeoTube *cd2 = new TGeoTube(60.6462,61.1862,71.1);
394   TGeoTube *cd3 = new TGeoTube(60.6662,61.1662,71.1);  
395   //
396   TGeoMedium *sm6 = gGeoManager->GetMedium("TPC_Prepreg1");
397   TGeoVolume *cd1v = new TGeoVolume("TPC_CDR1",cd1,sm2); //tedlar
398   TGeoVolume *cd2v = new TGeoVolume("TPC_CDR2",cd2,sm6);// prepreg1
399   TGeoVolume *cd3v = new TGeoVolume("TPC_CDR3",cd3,sm4); //nomex
400   //
401   // seals for central drum 2 copies
402   //
403   TGeoTube *cs = new TGeoTube(56.9,61.2,0.1);
404   TGeoMedium *sm7 = gGeoManager->GetMedium("TPC_Mylar");
405   TGeoVolume *csv = new TGeoVolume("TPC_CDRS",cs,sm7);
406   v1->AddNode(csv,1,new TGeoTranslation(0.,0.,-71.));
407   v1->AddNode(csv,2,new TGeoTranslation(0.,0.,71.));
408   //
409   // seal collars 
410   TGeoPcon *se = new TGeoPcon(0.,360.,6);
411   se->DefineSection(0,-72.8,59.7,61.2);
412   se->DefineSection(1,-72.3,59.7,61.2);
413   //
414   se->DefineSection(2,-72.3,58.85,61.2);
415   se->DefineSection(3,-71.6,58.85,61.2); 
416   //
417   se->DefineSection(4,-71.6,59.7,61.2);
418   se->DefineSection(5,-71.3,59.7,61.2);  
419   //
420   TGeoVolume *sev = new TGeoVolume("TPC_CDCE",se,m3);
421   //
422   TGeoTube *si = new TGeoTube(56.9,58.8,1.); 
423   TGeoVolume *siv = new TGeoVolume("TPC_CDCI",si,m3);
424   //
425   // define reflection matrix 
426   //
427   TGeoRotation *ref = new TGeoRotation("ref",90.,0.,90.,270.,180.,0.);
428   //
429   cd1v->AddNode(cd2v,1); cd2v->AddNode(cd3v,1); cflv->AddNode(cd1v,1);
430   //
431   v1->AddNode(siv,1,new TGeoTranslation(0.,0.,-72.1));
432   v1->AddNode(siv,2,new TGeoTranslation(0.,0.,72.1));
433   v1->AddNode(sev,1); v1->AddNode(sev,2,ref); v1->AddNode(cflv,1);
434   //
435   // central membrane - 2 rings and a mylar membrane - assembly
436   //
437   TGeoTube *ih = new TGeoTube(81.05,84.05,0.3);
438   TGeoTube *oh = new TGeoTube(250.,256.,.5);
439   TGeoTube *mem = new TGeoTube(84.05,250,0.01);
440   TGeoVolume *ihv = new TGeoVolume("TPC_IHVH",ih,m3);
441   TGeoVolume *ohv = new TGeoVolume("TPC_OHVH",oh,m3);
442   TGeoVolume *memv = new TGeoVolume("TPC_HV",mem,sm7);
443   //
444   TGeoVolumeAssembly *cm = new TGeoVolumeAssembly("TPC_HVMEM");
445   cm->AddNode(ihv,1);
446   cm->AddNode(ohv,1);
447   cm->AddNode(memv,1);
448   v9->AddNode(cm,1);
449   //
450   // end caps - they are make as an assembly of single segments
451   // containing both readout chambers
452   //
453   Double_t OpeningAngle = 10.*TMath::DegToRad();
454   Double_t thick=1.5; // rib
455   Double_t shift = thick/TMath::Sin(OpeningAngle);
456   //
457   Double_t LowEdge = 86.3; // hole in the wheel
458   Double_t UpEdge = 240.4; // hole in the wheel
459   //
460   new TGeoTubeSeg("sec",74.5,264.4,3.,0.,20.);
461   //
462   TGeoPgon *hole = new TGeoPgon("hole",0.,20.,1,4);
463   //
464   hole->DefineSection(0,-3.5,LowEdge-shift,UpEdge-shift);
465   hole->DefineSection(1,-1.5,LowEdge-shift,UpEdge-shift);
466   //
467   hole->DefineSection(2,-1.5,LowEdge-shift,UpEdge+3.-shift);
468   hole->DefineSection(3,3.5,LowEdge-shift,UpEdge+3.-shift);
469   //
470   Double_t ys = shift*TMath::Sin(OpeningAngle); 
471   Double_t xs = shift*TMath::Cos(OpeningAngle);
472   TGeoTranslation *tr = new TGeoTranslation("tr",xs,ys,0.);  
473   tr->RegisterYourself();
474   TGeoCompositeShape *chamber = new TGeoCompositeShape("sec-hole:tr");
475   TGeoVolume *sv = new TGeoVolume("TPC_WSEG",chamber,m3);
476   TGeoPgon *bar = new TGeoPgon("bar",0.,20.,1,2);
477   bar->DefineSection(0,-3.,131.5-shift,136.5-shift);
478   bar->DefineSection(1,1.5,131.5-shift,136.5-shift);
479   TGeoVolume *barv = new TGeoVolume("TPC_WBAR",bar,m3);
480   TGeoVolumeAssembly *ch = new TGeoVolumeAssembly("TPC_WCH");//empty segment
481   //
482   ch->AddNode(sv,1); ch->AddNode(barv,1,tr);
483   //
484   // readout chambers
485   //
486   // IROC first
487   //
488    TGeoTrd1 *ibody = new TGeoTrd1(13.8742,21.3328,4.29,21.15);
489    TGeoVolume *ibdv = new TGeoVolume("TPC_IROCB",ibody,m3);
490   // empty space
491    TGeoTrd1 *emp = new TGeoTrd1(12.3742,19.8328,3.99,19.65);
492    TGeoVolume *empv = new TGeoVolume("TPC_IROCE",emp,m1);
493    ibdv->AddNode(empv,1,new TGeoTranslation(0.,-0.3,0.));
494    //bars
495    Double_t tga = (19.8328-12.3742)/39.3;
496    Double_t xmin,xmax;
497    xmin = 9.55*tga+12.3742;
498    xmax = 9.95*tga+12.3742;
499    TGeoTrd1 *ib1 = new TGeoTrd1(xmin,xmax,3.29,0.2);
500    TGeoVolume *ib1v = new TGeoVolume("TPC_IRB1",ib1,m3);
501    empv->AddNode(ib1v,1,new TGeoTranslation("tt1",0.,0.7,-9.9));
502    xmin=19.4*tga+12.3742;
503    xmax=19.9*tga+12.3742;
504    TGeoTrd1 *ib2 = new TGeoTrd1(xmin,xmax,3.29,0.25);
505    TGeoVolume *ib2v = new TGeoVolume("TPC_TRB2",ib2,m3);
506    empv->AddNode(ib2v,1,new TGeoTranslation(0.,0.7,0.));
507    xmin=29.35*tga+12.3742;
508    xmax=29.75*tga+12.3742;
509    TGeoTrd1 *ib3 = new TGeoTrd1(xmin,xmax,3.29,0.2); 
510    TGeoVolume *ib3v = new TGeoVolume("TPC_IRB3",ib3,m3);    
511    empv->AddNode(ib3v,1,new TGeoTranslation(0.,0.7,9.9));
512    //
513    // holes for connectors
514    //
515    TGeoBBox *conn = new TGeoBBox(0.4,0.3,4.675); // identical for iroc and oroc
516    TGeoVolume *connv = new TGeoVolume("TPC_RCCON",conn,m1);
517    ifstream in;
518    in.open("conn_iroc.dat", ios_base::in); // asci file
519    for(Int_t i =0;i<86;i++){
520       Double_t y = 3.9;
521       Double_t x,z,ang;
522       in>>x>>z>>ang;
523       TGeoRotation *rrr = new TGeoRotation();
524       rrr->RotateY(ang);
525       TGeoCombiTrans *trans = new TGeoCombiTrans("trans",x,y,z,rrr);
526       ibdv->AddNode(connv,i+1,trans);
527    }
528    in.close();
529    // "cap"
530    new TGeoTrd1("icap",14.5974,23.3521,1.19,24.825);
531    // "hole"
532    new TGeoTrd1("ihole",13.8742,21.3328,1.2,21.15);
533    TGeoTranslation *tr1 = new TGeoTranslation("tr1",0.,0.,1.725);  
534    tr1->RegisterYourself();
535    TGeoCompositeShape *ic = new TGeoCompositeShape("icap-ihole:tr1");
536    TGeoVolume *icv = new TGeoVolume("TPC_IRCAP",ic,m3);
537    //
538    // pad plane and wire fixations
539    //
540    TGeoTrd1 *pp = new TGeoTrd1(14.5974,23.3521,0.3,24.825); //pad+iso
541    TGeoMedium *m4 = gGeoManager->GetMedium("TPC_G10");
542    TGeoVolume *ppv = new TGeoVolume("TPC_IRPP",pp,m4);
543    TGeoPara *f1 = new TGeoPara(.6,.5,24.825,0.,-10.,0.);
544    TGeoVolume *f1v = new TGeoVolume("TPC_IRF1",f1,m4);
545    TGeoPara *f2 = new TGeoPara(.6,.5,24.825,0.,10.,0.);
546    TGeoVolume *f2v = new TGeoVolume("TPC_IRF2",f2,m4);
547    //
548    TGeoVolumeAssembly *iroc = new TGeoVolumeAssembly("TPC_IROC");
549    //
550    iroc->AddNode(ibdv,1);
551    iroc->AddNode(icv,1,new TGeoTranslation(0.,3.1,-1.725));
552    iroc->AddNode(ppv,1,new TGeoTranslation(0.,4.59,-1.725));
553    tga =(23.3521-14.5974)/49.65; 
554    Double_t xx = 24.825*tga+14.5974-0.6;
555    iroc->AddNode(f1v,1,new TGeoTranslation(-xx,5.39,-1.725));
556    iroc->AddNode(f2v,1,new TGeoTranslation(xx,5.39,-1.725));
557    //
558    // OROC
559    //
560    TGeoTrd1 *obody = new TGeoTrd1(22.2938,40.5084,4.19,51.65);
561    TGeoVolume *obdv = new TGeoVolume("TPC_OROCB",obody,m3);
562    TGeoTrd1 *oemp = new TGeoTrd1(20.2938,38.5084,3.89,49.65);
563    TGeoVolume *oempv = new TGeoVolume("TPC_OROCE",oemp,m1);
564    obdv->AddNode(oempv,1,new TGeoTranslation(0.,-0.3,0.));
565    //horizontal bars
566    tga=(38.5084-20.2938)/99.3;
567    xmin=tga*10.2+20.2938;
568    xmax=tga*10.6+20.2938;
569    TGeoTrd1 *ob1 = new TGeoTrd1(xmin,xmax,2.915,0.2);
570    TGeoVolume *ob1v = new TGeoVolume("TPC_ORB1",ob1,m3);
571    //
572    xmin=22.55*tga+20.2938;
573    xmax=24.15*tga+20.2938;
574    TGeoTrd1 *ob2 = new TGeoTrd1(xmin,xmax,2.915,0.8);
575    TGeoVolume *ob2v = new TGeoVolume("TPC_ORB2",ob2,m3);
576    //
577    xmin=36.1*tga+20.2938;
578    xmax=36.5*tga+20.2938;
579    TGeoTrd1 *ob3 = new TGeoTrd1(xmin,xmax,2.915,0.2);
580    TGeoVolume *ob3v = new TGeoVolume("TPC_ORB3",ob3,m3);
581    //
582    xmin=49.0*tga+20.2938;
583    xmax=50.6*tga+20.2938;   
584    TGeoTrd1 *ob4 = new TGeoTrd1(xmin,xmax,2.915,0.8);
585    TGeoVolume *ob4v = new TGeoVolume("TPC_ORB4",ob4,m3);
586    //
587    xmin=63.6*tga+20.2938;
588    xmax=64.0*tga+20.2938;
589    TGeoTrd1 *ob5 = new TGeoTrd1(xmin,xmax,2.915,0.2);
590    TGeoVolume *ob5v = new TGeoVolume("TPC_ORB5",ob5,m3);
591    //
592    xmin=75.5*tga+20.2938;
593    xmax=77.15*tga+20.2938;
594    TGeoTrd1 *ob6 = new TGeoTrd1(xmin,xmax,2.915,0.8);
595    TGeoVolume *ob6v = new TGeoVolume("TPC_ORB6",ob6,m3);
596    //
597    xmin=88.7*tga+20.2938;
598    xmax=89.1*tga+20.2938;
599    TGeoTrd1 *ob7 = new TGeoTrd1(xmin,xmax,2.915,0.2);
600    TGeoVolume *ob7v = new TGeoVolume("TPC_ORB7",ob7,m3);
601    //
602    oempv->AddNode(ob1v,1,new TGeoTranslation(0.,0.975,-39.25));
603    oempv->AddNode(ob2v,1,new TGeoTranslation(0.,0.975,-26.3));
604    oempv->AddNode(ob3v,1,new TGeoTranslation(0.,0.975,-13.35));
605    oempv->AddNode(ob4v,1,new TGeoTranslation(0.,0.975,0.15));
606    oempv->AddNode(ob5v,1,new TGeoTranslation(0.,0.975,14.15));
607    oempv->AddNode(ob6v,1,new TGeoTranslation(0.,0.975,26.7));
608    oempv->AddNode(ob7v,1,new TGeoTranslation(0.,0.975,39.25));
609    // vertical bars
610    TGeoBBox *ob8 = new TGeoBBox(0.8,2.915,5.1); 
611    TGeoBBox *ob9 = new TGeoBBox(0.8,2.915,5.975);
612    TGeoBBox *ob10 = new TGeoBBox(0.8,2.915,5.775);
613    TGeoBBox *ob11 = new TGeoBBox(0.8,2.915,6.25);
614    TGeoBBox *ob12 = new TGeoBBox(0.8,2.915,6.5);
615    //
616    TGeoVolume *ob8v = new TGeoVolume("TPC_ORB8",ob8,m3);
617    TGeoVolume *ob9v = new TGeoVolume("TPC_ORB9",ob9,m3);
618    TGeoVolume *ob10v = new TGeoVolume("TPC_ORB10",ob10,m3);
619    TGeoVolume *ob11v = new TGeoVolume("TPC_ORB11",ob11,m3);
620    TGeoVolume *ob12v = new TGeoVolume("TPC_ORB12",ob12,m3);
621    //
622    oempv->AddNode(ob8v,1,new TGeoTranslation(0.,0.975,-44.55));
623    oempv->AddNode(ob8v,2,new TGeoTranslation(0.,0.975,44.55));
624    oempv->AddNode(ob9v,1,new TGeoTranslation(0.,0.975,-33.075));
625    oempv->AddNode(ob9v,2,new TGeoTranslation(0.,0.975,-19.525));
626    oempv->AddNode(ob10v,1,new TGeoTranslation(0.,0.975,20.125));
627    oempv->AddNode(ob10v,2,new TGeoTranslation(0.,0.975,33.275));
628    oempv->AddNode(ob11v,1,new TGeoTranslation(0.,0.975,-6.9));
629    oempv->AddNode(ob12v,1,new TGeoTranslation(0.,0.975,7.45));
630    //
631    // holes for connectors
632    //
633    in.open("conn_oroc.dat", ios_base::in); // asci file
634    for(Int_t i =0;i<78;i++){
635       Double_t y =3.89;
636       Double_t x,z,ang;
637       Double_t x1,z1,x2,z2;
638       in>>x>>z>>ang;        
639       Double_t xr = 4.7*TMath::Sin(ang*TMath::DegToRad());
640       Double_t zr = 4.7*TMath::Cos(ang*TMath::DegToRad());
641       //
642       x1=xr+x; x2=-xr+x; z1=zr+z; z2 = -zr+z;      
643       //
644       TGeoRotation *rr = new TGeoRotation();
645       rr->RotateY(ang); 
646       z1-=54.95;
647       z2-=54.95;
648       TGeoCombiTrans *trans1 = new TGeoCombiTrans("trans1",x1,y,z1,rr);
649       TGeoCombiTrans *trans2 = new TGeoCombiTrans("trans2",x2,y,z2,rr);
650       obdv->AddNode(connv,i+1,trans1);
651       obdv->AddNode(connv,i+79,trans2);
652    }
653    in.close();
654    // cap
655    new TGeoTrd1("ocap",23.3874,43.5239,1.09,57.1);
656    new TGeoTrd1("ohole",22.2938,40.5084,1.09,51.65);
657    TGeoTranslation *tr5 = new TGeoTranslation("tr5",0.,0.,-2.15);
658    tr5->RegisterYourself();
659    TGeoCompositeShape *oc = new TGeoCompositeShape("ocap-ohole:tr5");
660    TGeoVolume *ocv = new TGeoVolume("TPC_ORCAP",oc,m3);
661    //
662    // pad plane and wire fixations
663    //
664    TGeoTrd1 *opp = new TGeoTrd1(23.3874,43.5239,0.3,57.1);
665    TGeoVolume *oppv = new TGeoVolume("TPC_ORPP",opp,m4);
666    //
667    tga=(43.5239-23.3874)/114.2;
668    TGeoPara *f3 = new TGeoPara(.7,.6,57.1,0.,-10.,0.);
669    TGeoPara *f4 = new TGeoPara(.7,.6,57.1,0.,10.,0.);  
670    xx = 57.1*tga+23.3874-0.7;
671    TGeoVolume *f3v = new TGeoVolume("TPC_ORF1",f3,m4);
672    TGeoVolume *f4v = new TGeoVolume("TPC_ORF2",f4,m4);
673    //
674    TGeoVolumeAssembly *oroc = new TGeoVolumeAssembly("TPC_OROC");
675    //
676    oroc->AddNode(obdv,1);
677    oroc->AddNode(ocv,1,new TGeoTranslation(0.,3.1,2.15));
678    oroc->AddNode(oppv,1,new TGeoTranslation(0.,4.49,2.15));
679    oroc->AddNode(f3v,1,new TGeoTranslation(-xx,5.39,2.15));
680    oroc->AddNode(f4v,1,new TGeoTranslation(xx,5.39,2.15));
681    // 
682    // now iroc and oroc are placed into a sector...
683    //
684    TGeoVolumeAssembly *sect = new TGeoVolumeAssembly("TPC_SECT");
685    TGeoRotation rot1("rot1",90.,90.,0.);
686    TGeoRotation rot2("rot2");
687    rot2.RotateY(10.);
688    TGeoRotation *rot = new TGeoRotation("rot");
689    *rot=rot1*rot2;
690    //
691    Double_t x0,y0;
692    x0=110.2*TMath::Cos(OpeningAngle);
693    y0=110.2*TMath::Sin(OpeningAngle);
694    TGeoCombiTrans *combi1 = new TGeoCombiTrans("combi1",x0,y0,1.09,rot);
695    x0=188.45*TMath::Cos(OpeningAngle);
696    y0=188.45*TMath::Sin(OpeningAngle);
697    TGeoCombiTrans *combi2 = new TGeoCombiTrans("combi2",x0,y0,0.99,rot);
698    //
699    sect->AddNode(ch,1);
700    sect->AddNode(iroc,1,combi1);
701    sect->AddNode(oroc,1,combi2);
702    //
703    // segment is ready...
704    // now I try to make a wheel...
705    //
706    TGeoVolumeAssembly *wheel = new TGeoVolumeAssembly("TPC_ENDCAP");
707    //
708    for(Int_t i =0;i<18;i++){
709      Double_t phi = (20.*i);
710      TGeoRotation *r = new TGeoRotation();
711      r->RotateZ(phi);
712      wheel->AddNode(sect,i+1,r);
713     
714    }
715    // wheels in the drift volume!
716    v9->AddNode(wheel,1,new TGeoTranslation(0.,0.,-256.6));
717    TGeoCombiTrans *combi3 = new TGeoCombiTrans("combi3",0.,0.,256.6,ref);
718    v9->AddNode(wheel,2,combi3);
719    
720    //_____________________________________________________________
721    // service support wheel
722    //_____________________________________________________________
723   TGeoPgon *sw = new TGeoPgon(0.,20.,1,2);
724   sw->DefineSection(0,-4.,80.5,251.75);
725   sw->DefineSection(1,4.,80.5,251.75); 
726   TGeoVolume *swv = new TGeoVolume("TPC_SWSEG",sw,m3); //Al
727   //
728   thick=1.;
729   shift = thick/TMath::Sin(OpeningAngle);
730   TGeoPgon *sh = new TGeoPgon(0.,20.,1,2);
731   sh->DefineSection(0,-4.,81.5-shift,250.75-shift);
732   sh->DefineSection(1,4.,81.5-shift,250.75-shift);
733   TGeoVolume *shv = new TGeoVolume("TPC_SWS1",sh,m1); //Air
734   //
735   ys = shift*TMath::Sin(OpeningAngle);
736   xs = shift*TMath::Cos(OpeningAngle);
737   swv->AddNode(shv,1,new TGeoTranslation(xs,ys,0.));
738   // cover
739   TGeoPgon *co = new TGeoPgon(0.,20.,1,2);
740   co->DefineSection(0,-0.5,77.,255.25);
741   co->DefineSection(1,0.5,77.,255.25);
742   TGeoVolume *cov = new TGeoVolume("TPC_SWC1",co,m3);//Al
743   // hole in a cover
744   TGeoPgon *coh = new TGeoPgon(0.,20.,1,2);
745   shift=4./TMath::Sin(OpeningAngle);
746   coh->DefineSection(0,-0.5,85.-shift,247.25-shift);
747   coh->DefineSection(1,0.5,85.-shift,247.25-shift);  
748   //
749   TGeoVolume *cohv = new TGeoVolume("TPC_SWC2",coh,m1);
750   //
751   ys = shift*TMath::Sin(OpeningAngle);
752   xs = shift*TMath::Cos(OpeningAngle);  
753   cov->AddNode(cohv,1,new TGeoTranslation(xs,ys,0.));
754   //
755   // Sector as an Assembly
756   //
757   TGeoVolumeAssembly *swhs = new TGeoVolumeAssembly("TPC_SSWSEC");
758   swhs->AddNode(swv,1);
759   swhs->AddNode(cov,1,new TGeoTranslation(0.,0.,-4.5));
760   swhs->AddNode(cov,2,new TGeoTranslation(0.,0.,4.5));
761   //
762   // SSW as an Assembly of sectors
763   //
764  TGeoVolumeAssembly *swheel = new TGeoVolumeAssembly("TPC_SSWHEEL");
765    for(Int_t i =0;i<18;i++){
766      Double_t phi = (20.*i);
767      TGeoRotation *r = new TGeoRotation();
768      r->RotateZ(phi);
769      swheel->AddNode(swhs,i+1,r);   
770    }
771    v1->AddNode(swheel,1,new TGeoTranslation(0.,0.,-284.6));
772    v1->AddNode(swheel,2,new TGeoTranslation(0.,0.,284.6));
773
774    // sensitive strips 
775    TGeoMedium *m8 = gGeoManager->GetMedium("TPC_Ne-CO2-N-2");
776    Int_t totrows;
777    totrows = fTPCParam->GetNRowLow() + fTPCParam->GetNRowUp();
778    Double_t *upar;
779    upar=NULL;
780    gGeoManager->Volume("TPC_Strip","PGON",m8->GetId(),upar);
781    upar=new Double_t [10];
782    upar[0]=0.;
783    upar[1]=360.;
784    upar[2]=18.;
785    upar[3]=2.;
786    //
787    upar[4]=-124.8;
788    upar[7]=124.8;
789
790    Double_t rlow=fTPCParam->GetPadRowRadiiLow(0);
791
792    upar[5]=rlow;
793    upar[6]=rlow+.01;
794    upar[8]=upar[5];
795    upar[9]=upar[6];
796    //
797    gGeoManager->Node("TPC_Strip",1,"TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10);
798    gGeoManager->Node("TPC_Strip",totrows+1,
799                      "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10);
800    //
801    // now, strips 
802    //
803      //lower sectors
804      for(Int_t i=2;i<fTPCParam->GetNRowLow()+1;i++){
805        rlow=fTPCParam->GetPadRowRadiiLow(i-1);
806        upar[5]=rlow;
807        upar[6]=rlow+.01;
808        upar[8]=upar[5];
809        upar[9]=upar[6];
810        gGeoManager->Node("TPC_Strip",i,
811                          "TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10);
812        gGeoManager->Node("TPC_Strip",totrows+i,
813                          "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10);       
814      }
815      //upper sectors
816      for(Int_t i=1;i<fTPCParam->GetNRowUp()+1;i++){
817        rlow=fTPCParam->GetPadRowRadiiUp(i-1); 
818        upar[5]=rlow;
819        upar[6]=rlow+.01;
820        upar[8]=upar[5];
821        upar[9]=upar[6];
822        gGeoManager->Node("TPC_Strip",i+fTPCParam->GetNRowLow(),
823                          "TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10); 
824        gGeoManager->Node("TPC_Strip",totrows+i+fTPCParam->GetNRowLow(),
825                          "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10); 
826      }
827    
828   //----------------------------------------------------------
829   // TPc Support Rods - MAKROLON
830   //----------------------------------------------------------
831   TGeoMedium *m6=gGeoManager->GetMedium("TPC_Makrolon");
832   TGeoMedium *m7=gGeoManager->GetMedium("TPC_Cu");
833   // upper and lower rods differ in length!
834   delete [] upar;
835   upar=NULL;
836   gGeoManager->Volume("TPC_Rod","TUBE",m6->GetId(),upar);
837   upar=new Double_t [3];
838   upar[0]=1.8;
839   upar[1]=2.2;
840   
841   //
842   //HV rods - makrolon + 0.58cm (diameter) Cu
843   TGeoTube *hvr = new TGeoTube(0.,4.4,126.64);
844   TGeoTube *hvc = new TGeoTube(0.,0.29,126.64);
845   //
846   TGeoVolume *hvrv = new TGeoVolume("TPC_HV_Rod",hvr,m6);
847   TGeoVolume *hvcv = new TGeoVolume("TPC_HV_Cable",hvc,m7);
848   hvrv->AddNode(hvcv,1);
849   
850   for(Int_t i=0;i<17;i++){
851     Double_t angle,x,y;
852     Double_t z,r; 
853     angle=TMath::DegToRad()*20.*(Double_t)i;
854     r=81.5;
855     x=r * TMath::Cos(angle);
856     y=r * TMath::Sin(angle);
857     upar[2]=126.64; //lower
858     z= 126.96;
859     if(i==15){
860       v9->AddNode(hvrv,1,new TGeoTranslation(x,y,z));
861       v9->AddNode(hvrv,2,new TGeoTranslation(x,y,-z));
862     }
863     else{
864      gGeoManager->Node("TPC_Rod",i+1,"TPC_Drift",x,y,z,0,kTRUE,upar,3);//shaft
865      gGeoManager->Node("TPC_Rod",i+18,"TPC_Drift",x,y,-z,0,kTRUE,upar,3);//muon
866     }
867     r=254.25;
868     x=r * TMath::Cos(angle);
869     y=r * TMath::Sin(angle);
870     upar[2]=126.54; //upper
871     z=127.06;
872     gGeoManager->Node("TPC_Rod",i+36,"TPC_Drift",x,y,z,0,kTRUE,upar,3);
873     gGeoManager->Node("TPC_Rod",i+54,"TPC_Drift",x,y,-z,0,kTRUE,upar,3);
874   }
875
876   gMC->Gspos("TPC_M",1,"ALIC",0.,0.,0.,0,"ONLY");
877
878 } // end of function
879
880 //_____________________________________________________________________________
881 void AliTPCv1::DrawDetector()
882 {
883   //
884   // Draw a shaded view of the Time Projection Chamber version 1
885   //
886
887   // Set everything unseen
888   gMC->Gsatt("*", "seen", -1);
889   // 
890   // Set ALIC mother transparent
891   gMC->Gsatt("ALIC","SEEN",0);
892   //
893   // Set the volumes visible
894   gMC->Gsatt("TPC ","SEEN",0);
895   gMC->Gsatt("TOIN","SEEN",1);
896   gMC->Gsatt("TOIN","COLO",7);
897   gMC->Gsatt("TOCV","SEEN",1);
898   gMC->Gsatt("TOCV","COLO",4);
899   gMC->Gsatt("TSA1","SEEN",0);
900   gMC->Gsatt("TSA2","SEEN",0);
901   gMC->Gsatt("TSA3","SEEN",0);
902   gMC->Gsatt("TSA4","SEEN",0);  
903   gMC->Gsatt("TSA5","SEEN",0);
904   gMC->Gsatt("TOFC","SEEN",1);
905   gMC->Gsatt("TOFC","COLO",4);
906   gMC->Gsatt("TSA6","SEEN",0);
907   gMC->Gsatt("TSA7","SEEN",0);
908   gMC->Gsatt("TSA8","SEEN",0);    
909   gMC->Gsatt("TIIN","SEEN",1);
910   gMC->Gsatt("TIIN","COLO",7);
911   gMC->Gsatt("TII1","SEEN",0);
912   gMC->Gsatt("TIFC","SEEN",1);
913   gMC->Gsatt("TIFC","COLO",4);
914   gMC->Gsatt("TSA9","SEEN",0); 
915   gMC->Gsatt("TS10","SEEN",0);
916   gMC->Gsatt("TS11","SEEN",0);
917   gMC->Gsatt("TS12","SEEN",0);
918   gMC->Gsatt("TS13","SEEN",0);
919   gMC->Gsatt("TS14","SEEN",0);
920   gMC->Gsatt("TICC","SEEN",0);
921   gMC->Gsatt("TICM","SEEN",0);
922   gMC->Gsatt("TS15","SEEN",0);
923   gMC->Gsatt("TS16","SEEN",0);
924   gMC->Gsatt("TS17","SEEN",0);
925   gMC->Gsatt("TS18","SEEN",0);  
926   gMC->Gsatt("TS19","SEEN",0); 
927   gMC->Gsatt("TPJ1","SEEN",0);
928   gMC->Gsatt("TPJ2","SEEN",0);
929   gMC->Gsatt("TICS","SEEN",0);
930   gMC->Gsatt("TDGN","SEEN",0); 
931   gMC->Gsatt("TIRC","SEEN",0);
932   gMC->Gsatt("TIC1","SEEN",1);
933   gMC->Gsatt("TIPP","SEEN",0);
934   gMC->Gsatt("TIC3","SEEN",0);
935   gMC->Gsatt("TRCE","SEEN",0);
936   gMC->Gsatt("TPSC","SEEN",0);
937   gMC->Gsatt("TPCC","SEEN",0); 
938   gMC->Gsatt("TORC","SEEN",0);
939   gMC->Gsatt("TOPP","SEEN",0);
940   gMC->Gsatt("TOC3","SEEN",0);
941   gMC->Gsatt("TOC1","SEEN",1);
942   gMC->Gsatt("TSSW","SEEN",1);
943   gMC->Gsatt("TSWC","SEEN",1);
944   gMC->Gsatt("TSSW","COLO",3);
945   gMC->Gsatt("TSWC","COLO",3);
946   gMC->Gsatt("TSCE","COLO",6);
947   gMC->Gsatt("TSCE","SEEN",1);
948   gMC->Gsatt("TWES","SEEN",0);
949   gMC->Gsatt("TSWB","SEEN",0);
950   gMC->Gsatt("TPEL","SEEN",0);
951   gMC->Gsatt("TPMW","SEEN",1);
952   gMC->Gsatt("TESR","SEEN",1);
953   gMC->Gsatt("TPMW","COLO",12);
954   gMC->Gsatt("TIC1","COLO",5);
955   gMC->Gsatt("TOC1","COLO",5);
956   gMC->Gsatt("TESB","SEEN",0);
957   gMC->Gsatt("THVM","SEEN",1);
958   gMC->Gsatt("THVM","COLO",11);
959   gMC->Gsatt("THVH","SEEN",0);
960   gMC->Gsatt("TPSR","SEEN",0); 
961   gMC->Gsatt("THVL","SEEN",0);
962   gMC->Gsatt("THVC","SEEN",0);  
963   gMC->Gsatt("THVE","SEEN",0);
964   gMC->Gsatt("THVR","SEEN",0);
965   gMC->Gsatt("TPSS","SEEN",0);
966   gMC->Gsatt("TPUS","SEEN",0);
967   gMC->Gsatt("TPLS","SEEN",0);
968
969   //
970   gMC->Gdopt("hide", "on");
971   gMC->Gdopt("shad", "on");
972   gMC->Gsatt("*", "fill", 7);
973   gMC->SetClipBox(".");
974   gMC->SetClipBox("TPMW",-300,300,-300,300,254.,270.);
975   gMC->SetClipBox("TESR",-300,300,-300,300,254.,270.);
976   gMC->SetClipBox("TSSW",-300,300,-300,300,283.,284.);
977   gMC->SetClipBox("TSWC",-300,300,-300,300,283.,284.);
978   gMC->SetClipBox("*", 0, 300, -300, 300, -290, 290);
979   gMC->DefaultRange();
980   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .025, .025);
981   gMC->Gdhead(1111, "Time Projection Chamber");
982   gMC->Gdman(18, 4, "MAN");
983   gMC->Gdopt("hide","off");
984 }
985
986 //_____________________________________________________________________________
987 void AliTPCv1::CreateMaterials()
988 {
989   //
990   // Define materials for Time Projection Chamber
991   //
992   AliTPC::CreateMaterials();
993 }
994
995 //_____________________________________________________________________________
996 void AliTPCv1::Init()
997 {
998   //
999   // Initialises TPC detector after it has been created
1000   //
1001
1002   fIdSens=gMC->VolId("TPC_Strip"); // sensitive strip
1003
1004   printf("%s: *** TPC version 1 initialized***\n",ClassName());
1005
1006   // printf("TPC version 1 initialized\n");
1007 }
1008
1009 //_____________________________________________________________________________
1010 void AliTPCv1::StepManager()
1011 {
1012   //
1013   // Called at every step in the Time Projection Chamber
1014   //
1015   Int_t         copy, id, i;
1016   Float_t       hits[5];
1017   Int_t         vol[2];
1018   TLorentzVector p;
1019  //
1020
1021   id = gMC->CurrentVolID(copy);
1022   if(id!=fIdSens) return;
1023   if(gMC->TrackCharge() && gMC->IsTrackEntering()) {
1024
1025     // 
1026     // Only charged tracks entering the sensitive volume
1027     //
1028
1029       gMC->TrackPosition(p);
1030   Double_t r = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]);
1031   //
1032   
1033   //
1034   Double_t angle = TMath::ACos(p[0]/r);  
1035   angle = (p[1]<0.) ? TMath::TwoPi()-angle : angle;
1036   //
1037   // angular segment, it is not a real sector number...
1038   //
1039   Int_t sector=TMath::Nint((angle-fTPCParam->GetInnerAngleShift())/
1040                fTPCParam->GetInnerAngle());
1041   // rotate to segment "0"
1042   Float_t cos,sin;
1043   fTPCParam->AdjustCosSin(sector,cos,sin);
1044   Float_t x1 = p[0]*cos + p[1]*sin;
1045   Float_t y1 = TMath::Abs(-p[0]*sin + p[1]*cos);
1046   // calculate real sector number...
1047   if (x1>fTPCParam->GetOuterRadiusLow()){
1048     sector = TMath::Nint((angle-fTPCParam->GetOuterAngleShift())/
1049              fTPCParam->GetOuterAngle())+fTPCParam->GetNInnerSector();
1050     if (p[2]<0)         sector+=(fTPCParam->GetNOuterSector()>>1);
1051   }
1052     else   
1053       if (p[2]<0) sector+=(fTPCParam->GetNInnerSector()>>1); 
1054   //
1055   // here I have a sector number
1056   //
1057   vol[0]=sector;
1058   //
1059   Int_t totrows = fTPCParam->GetNRowLow()+fTPCParam->GetNRowUp();
1060   vol[1] = (copy<=totrows) ? copy-1 : copy-1-totrows;
1061   // row numbers are autonomous for lower and upper sectors
1062   if(vol[0] > fTPCParam->GetNInnerSector()) {
1063      vol[1] -= fTPCParam->GetNRowLow();
1064   }
1065   Double_t range = (sector<36) ? fTPCParam->GetYInner(vol[1]) :
1066                    fTPCParam->GetYOuter(vol[1]);
1067   if(y1>range) return;
1068      if(vol[1] == 0){
1069   
1070         // because Jouri wants to have this
1071
1072         gMC->TrackMomentum(p);
1073         hits[0]=p[0];
1074         hits[1]=p[1];
1075         hits[2]=p[2];
1076         hits[3]=0.; // this hit has no energy loss
1077         // Get also the track time for pileup simulation
1078         hits[4]=gMC->TrackTime();
1079
1080         AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits); // M.I.
1081      }
1082    gMC->TrackPosition(p);
1083       for(i=0;i<3;++i) hits[i]=p[i];
1084       hits[3]=1; //I'd like to have something positive here (I.Belikov)
1085       // Get also the track time for pileup simulation
1086       hits[4]=gMC->TrackTime();
1087
1088       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits); // M.I.    
1089
1090   }// track entering sensitive strip
1091    
1092 }
1093 //_____________________________________________________________________________
1094
1095
1096