]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/Attic/AliTPCv1.cxx
Fix for coverity (AdC)
[u/mrichter/AliRoot.git] / TPC / Attic / 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 <TInterpreter.h>
35 #include <TMath.h>
36 #include <TVirtualMC.h>
37 #include <TString.h>
38 #include <TSystem.h>
39
40 #include "AliConst.h"
41 #include "AliRun.h"
42 #include "AliTPCDigitsArray.h"
43 #include "AliTPCParam.h"
44 #include "AliTPCParamSR.h"
45 #include "AliTPCv1.h"
46 #include "TLorentzVector.h"
47 #include "TGeoCone.h"
48 #include "AliMC.h"
49 #include "TGeoManager.h"
50 #include "TGeoVolume.h"
51 #include "TGeoPcon.h"
52 #include "TGeoTube.h"
53 #include "TGeoPgon.h"
54 #include "TGeoTrd1.h"
55 #include "TGeoCompositeShape.h"
56 #include "TGeoPara.h"
57 #include "TGeoPhysicalNode.h"
58 #include "TGeoHalfSpace.h"
59 #include "TTreeStream.h"
60 #include "TGeoArb8.h"
61
62 using std::ifstream;
63 using std::ios_base;
64 ClassImp(AliTPCv1)
65
66 //_____________________________________________________________________________
67
68   AliTPCv1::AliTPCv1():AliTPC(),fIdSens(0)
69 {
70
71   fHitType = 1;
72
73 }
74  
75 //_____________________________________________________________________________
76 AliTPCv1::AliTPCv1(const char *name, const char *title) 
77   :AliTPC(name, title),fIdSens(0)
78  {
79   //
80   // Standard constructor for Time Projection Chamber
81   //
82
83
84   if (fTPCParam)
85      fTPCParam->Write(fTPCParam->GetTitle());
86
87   fHitType=1;
88 }
89
90 //_____________________________________________________________________________
91 void AliTPCv1::CreateGeometry()
92 {
93   //-------------------------------------------------------------
94   // Creates geometry for Time Projection Chamber version 1
95   // Detailed geometry -- Fast simulation - space points
96   // at the pad-rows centers
97   // Origin M.Kowalski, INP Cracow, Marek.Kowalski@ifj.edu.pl
98   //-----------------------------------------------------------
99
100   //Begin_Html
101   /*
102     <img src="picts/AliTPC.gif">
103   */
104   //End_Html
105   //Begin_Html
106   /*
107     <img src="picts/AliTPCv1Tree.gif">
108   */
109   //End_Html
110   //----------------------------------------------------------
111   // This geometry is written using TGeo class
112   // Firstly the shapes are defined, and only then the volumes
113   // What is recognized by the MC are volumes
114   //----------------------------------------------------------
115   //
116   //  tpc - this will be the mother volume
117   //
118
119   //
120   // here I define a volume TPC
121   // retrive the medium name with "TPC_" as a leading string
122   //
123   TGeoPcon *tpc = new TGeoPcon(0.,360.,30); //30 sections
124   //
125   tpc->DefineSection(0,-289.6,77.,278.);
126   tpc->DefineSection(1,-262.1,77.,278.);
127   //
128   tpc->DefineSection(2,-262.1,83.1,278.);
129   tpc->DefineSection(3,-260.,83.1,278.);
130   //
131   tpc->DefineSection(4,-260.,70.,278.);    
132   tpc->DefineSection(5,-259.6,70.,278.);
133   //
134   tpc->DefineSection(6,-259.6,68.1,278.);
135   tpc->DefineSection(7,-253.6,68.1,278.);
136   //
137   tpc->DefineSection(8,-253.6,67.88,278.);//hs
138   tpc->DefineSection(9,-74.0,60.68,278.);// hs
139   //
140   tpc->DefineSection(10,-74.0,60.1,278.);
141   tpc->DefineSection(11,-73.3,60.1,278.);
142   //
143   tpc->DefineSection(12,-73.3,56.9,278.); 
144   tpc->DefineSection(13,-68.5,56.9,278.);
145   //
146   tpc->DefineSection(14,-68.5,60.,278.);
147   tpc->DefineSection(15,-64.7,60.,278.);
148   //
149   tpc->DefineSection(16,-64.7,56.9,278.); 
150   tpc->DefineSection(17,73.3,56.9,278.);
151   //
152   tpc->DefineSection(18,73.3,60.1,278.);
153   tpc->DefineSection(19,74.0,60.1,278.);
154   //
155   tpc->DefineSection(20,74.0,60.68,278.);// hs
156   tpc->DefineSection(21,253.6,65.38,278.);// hs
157   //
158   tpc->DefineSection(22,253.6,65.6,278.);
159   tpc->DefineSection(23,259.6,65.6,278.);
160   //
161   tpc->DefineSection(24,259.6,70.0,278.);
162   tpc->DefineSection(25,260.,70.0,278.);
163   //
164   tpc->DefineSection(26,260.,83.1,278.);
165   tpc->DefineSection(27,262.1,83.1,278.);
166   //
167   tpc->DefineSection(28,262.1,77.,278);
168   tpc->DefineSection(29,289.6,77.,278.);
169
170
171   //
172   TGeoMedium *m1 = gGeoManager->GetMedium("TPC_Air");
173   TGeoVolume *v1 = new TGeoVolume("TPC_M",tpc,m1);
174   //
175   // drift volume - sensitive volume, extended beyond the
176   // endcaps, because of the alignment
177   //
178   TGeoPcon *dvol = new TGeoPcon(0.,360.,6);
179   dvol->DefineSection(0,-260.,74.5,264.4);
180   dvol->DefineSection(1,-253.6,74.5,264.4);
181   //
182   dvol->DefineSection(2,-253.6,76.6774,258.);
183   dvol->DefineSection(3,253.6,76.6774,258.); 
184   //
185   dvol->DefineSection(4,253.6,74.5,264.4);
186   dvol->DefineSection(5,260.,74.5,264.4);
187   //
188   TGeoMedium *m5 = gGeoManager->GetMedium("TPC_Ne-CO2-1");
189   TGeoVolume *v9 = new TGeoVolume("TPC_Drift",dvol,m5);
190   //
191   //
192   v1->AddNode(v9,1);
193   //
194   // outer insulator
195   //
196   TGeoPcon *tpco = new TGeoPcon(0.,360.,6); //insulator
197   //
198   tpco->DefineSection(0,-256.6,264.8,278.);
199   tpco->DefineSection(1,-253.6,264.8,278.);
200   //
201   tpco->DefineSection(2,-253.6,258.,278.);
202   tpco->DefineSection(3,250.6,258.,278.);
203   //
204   tpco->DefineSection(4,250.6,258.,275.5);
205   tpco->DefineSection(5,253.6,258.,275.5);
206   //
207   TGeoMedium *m2 = gGeoManager->GetMedium("TPC_CO2");
208   TGeoVolume *v2 = new TGeoVolume("TPC_OI",tpco,m2);
209   //
210   // outer containment vessel
211   //
212   TGeoPcon *tocv = new TGeoPcon(0.,360.,6);  // containment vessel
213   //
214   tocv->DefineSection(0,-256.6,264.8,278.);
215   tocv->DefineSection(1,-253.6,264.8,278.);
216   //
217   tocv->DefineSection(2,-253.6,274.8124,278.);
218   tocv->DefineSection(3,247.6,274.8124,278.);  
219   //
220   tocv->DefineSection(4,247.6,270.4,278.);
221   tocv->DefineSection(5,250.6,270.4,278.);
222   //
223   TGeoMedium *m3 = gGeoManager->GetMedium("TPC_Al");
224   TGeoVolume *v3 = new TGeoVolume("TPC_OCV",tocv,m3); 
225   //
226   TGeoTube *to1 = new TGeoTube(274.8174,277.995,252.1); //epoxy
227   TGeoTube *to2 = new TGeoTube(274.8274,277.985,252.1); //tedlar
228   TGeoTube *to3 = new TGeoTube(274.8312,277.9812,252.1);//prepreg2
229   TGeoTube *to4 = new TGeoTube(274.9062,277.9062,252.1);//nomex
230   //
231   TGeoMedium *sm1 = gGeoManager->GetMedium("TPC_Epoxy");
232   TGeoMedium *sm2 = gGeoManager->GetMedium("TPC_Tedlar");
233   TGeoMedium *sm3 = gGeoManager->GetMedium("TPC_Prepreg2");
234   TGeoMedium *sm4 = gGeoManager->GetMedium("TPC_Nomex");
235   //
236   TGeoVolume *tov1 = new TGeoVolume("TPC_OCV1",to1,sm1);
237   TGeoVolume *tov2 = new TGeoVolume("TPC_OCV2",to2,sm2);
238   TGeoVolume *tov3 = new TGeoVolume("TPC_OCV3",to3,sm3);
239   TGeoVolume *tov4 = new TGeoVolume("TPC_OCV4",to4,sm4);
240   TGeoMedium *mhs = gGeoManager->GetMedium("TPC_Steel");
241   TGeoMedium *m12 =  gGeoManager->GetMedium("TPC_Water");
242   //-------------------------------------------------------
243   //  Tpc Outer Field Cage
244   //  daughters - composite (sandwich)
245   //-------------------------------------------------------
246
247   TGeoPcon *tofc = new TGeoPcon(0.,360.,6);
248   //
249   tofc->DefineSection(0,-253.6,258.,269.6);
250   tofc->DefineSection(1,-250.6,258.,269.6);
251   //
252   tofc->DefineSection(2,-250.6,258.,260.0676); 
253   tofc->DefineSection(3,250.6,258.,260.0676);
254   //
255   tofc->DefineSection(4,250.6,258.,275.5);
256   tofc->DefineSection(5,253.6,258.,275.5);
257   //
258   TGeoVolume *v4 = new TGeoVolume("TPC_TOFC",tofc,m3); 
259   //sandwich
260   TGeoTube *tf1 = new TGeoTube(258.0,260.0676,252.1); //tedlar
261   TGeoTube *tf2 = new TGeoTube(258.0038,260.0638,252.1); //prepreg3
262   TGeoTube *tf3 = new TGeoTube(258.0338,260.0338,252.1);//nomex
263   //
264   TGeoMedium *sm5 = gGeoManager->GetMedium("TPC_Prepreg3");
265   //
266   TGeoVolume *tf1v = new TGeoVolume("TPC_OFC1",tf1,sm2);
267   TGeoVolume *tf2v = new TGeoVolume("TPC_OFC2",tf2,sm5);
268   TGeoVolume *tf3v = new TGeoVolume("TPC_OFC3",tf3,sm4);
269   //
270   // outer part - positioning
271   //
272   tov1->AddNode(tov2,1); tov2->AddNode(tov3,1); tov3->AddNode(tov4,1);
273   //
274   tf1v->AddNode(tf2v,1); tf2v->AddNode(tf3v,1);
275   //
276   v3->AddNode(tov1,1,new TGeoTranslation(0.,0.,-1.5)); v4->AddNode(tf1v,1);
277   //
278   v2->AddNode(v3,1); v2->AddNode(v4,1); 
279   //
280   v1->AddNode(v2,1);
281   //--------------------------------------------------------------------
282   // Tpc Inner INsulator (CO2) 
283   // the cones, the central drum and the inner f.c. sandwich with a piece
284   // of the flane will be placed in the TPC
285   //--------------------------------------------------------------------
286   TGeoPcon *tpci = new TGeoPcon(0.,360.,4);
287   //
288   tpci->DefineSection(0,-253.6,68.4,76.6774);
289   tpci->DefineSection(1,-74.0,61.2,76.6774);
290   //
291   tpci->DefineSection(2,74.0,61.2,76.6774);  
292   //
293   tpci->DefineSection(3,253.6,65.9,76.6774);
294   //
295   TGeoVolume *v5 = new TGeoVolume("TPC_INI",tpci,m2);
296   //
297   // now the inner field cage - only part of flanges (2 copies)
298   //
299   TGeoTube *tif1 = new TGeoTube(69.9,76.6774,1.5); 
300   TGeoVolume *v6 = new TGeoVolume("TPC_IFC1",tif1,m3);
301   //
302  //---------------------------------------------------------
303   // Tpc Inner Containment vessel - Muon side
304   //---------------------------------------------------------
305   TGeoPcon *tcms = new TGeoPcon(0.,360.,10);
306   //
307   tcms->DefineSection(0,-259.1,68.1,74.2);
308   tcms->DefineSection(1,-253.6,68.1,74.2);
309   //
310   tcms->DefineSection(2,-253.6,68.1,68.4);
311   tcms->DefineSection(3,-74.0,60.9,61.2);
312   //
313   tcms->DefineSection(4,-74.0,60.1,61.2);
314   tcms->DefineSection(5,-73.3,60.1,61.2);
315   //
316   tcms->DefineSection(6,-73.3,56.9,61.2);
317   tcms->DefineSection(7,-73.0,56.9,61.2);
318   //
319   tcms->DefineSection(8,-73.0,56.9,58.8);
320   tcms->DefineSection(9,-71.3,56.9,58.8);
321   //
322   TGeoVolume *v7 = new TGeoVolume("TPC_ICVM",tcms,m3);
323   //------------------------------------------------
324   //  Heat screen muon side
325   //------------------------------------------------
326  
327   TGeoCone *thsm = new TGeoCone(89.8,67.88,68.1,60.68,60.9);
328   TGeoCone *thsmw = new TGeoCone(89.8,67.94,68.04,60.74,60.84);
329   TGeoVolume *hvsm = new TGeoVolume("TPC_HSM",thsm,mhs); //steel
330   TGeoVolume *hvsmw = new TGeoVolume("TPC_HSMW",thsmw,m12); //water 
331   // assembly heat screen muon
332   hvsm->AddNode(hvsmw,1);
333   //-----------------------------------------------
334   // inner containment vessel - shaft side
335   //-----------------------------------------------
336   TGeoPcon *tcss = new TGeoPcon(0.,360.,10);
337   //
338   tcss->DefineSection(0,71.3,56.9,58.8);
339   tcss->DefineSection(1,73.0,56.9,58.8);
340   //
341   tcss->DefineSection(2,73.0,56.9,61.2);
342   tcss->DefineSection(3,73.3,56.9,61.2);
343   //  
344   tcss->DefineSection(4,73.3,60.1,61.2);
345   tcss->DefineSection(5,74.0,60.1,61.2);
346   //
347   tcss->DefineSection(6,74.0,60.9,61.2);
348   tcss->DefineSection(7,253.6,65.6,65.9);
349   //
350   tcss->DefineSection(8,253.6,65.6,74.2);
351   tcss->DefineSection(9,258.1,65.6,74.2);
352   //
353   TGeoVolume *v8 = new TGeoVolume("TPC_ICVS",tcss,m3);
354   //-------------------------------------------------
355   //  Heat screen shaft side
356   //--------------------------------------------------
357   TGeoCone *thss = new TGeoCone(89.8,60.68,60.9,65.38,65.6);       
358   TGeoCone *thssw = new TGeoCone(89.8,60.74,60.84,65.44,65.54);     
359   TGeoVolume *hvss = new TGeoVolume("TPC_HSS",thss,mhs); //steel
360   TGeoVolume *hvssw = new TGeoVolume("TPC_HSSW",thssw,m12); //water 
361   //assembly heat screen shaft
362   hvss->AddNode(hvssw,1);
363   //-----------------------------------------------
364   //  Inner field cage
365   //  define 4 parts and make an assembly
366   //-----------------------------------------------
367   // part1 - Al - 2 copies
368   TGeoTube *t1 = new TGeoTube(76.6774,78.845,0.75);
369   TGeoVolume *tv1 = new TGeoVolume("TPC_IFC2",t1,m3);
370   // sandwich - outermost parts - 2 copies
371   TGeoTube *t2 = new TGeoTube(76.6774,78.845,74.175); // tedlar 38 microns
372   TGeoTube *t3 = new TGeoTube(76.6812,78.8412,74.175); // prepreg2 500 microns
373   TGeoTube *t4 = new TGeoTube(76.7312,78.7912,74.175); // prepreg3 300 microns
374   TGeoTube *t5 = new TGeoTube(76.7612,78.7612,74.175); // nomex 2 cm
375   //
376   TGeoVolume *tv2 = new TGeoVolume("TPC_IFC3",t2,sm2);
377   TGeoVolume *tv3 = new TGeoVolume("TPC_IFC4",t3,sm3);
378   TGeoVolume *tv4 = new TGeoVolume("TPC_IFC5",t4,sm5);
379   TGeoVolume *tv5 = new TGeoVolume("TPC_IFC6",t5,sm4);
380   //
381   // middle parts - 2 copies
382   TGeoTube *t6 = new TGeoTube(76.6774,78.795,5.); // tedlar 38 microns
383   TGeoTube *t7 = new TGeoTube(76.6812,78.7912,5.); // prepreg2 250 microns
384   TGeoTube *t8 = new TGeoTube(76.7062,78.7662,5.); // prepreg3 300 microns
385   TGeoTube *t9 = new TGeoTube(76.7362,78.7362,5.); // nomex 2 cm
386   //
387   TGeoVolume *tv6 = new TGeoVolume("TPC_IFC7",t6,sm2);
388   TGeoVolume *tv7 = new TGeoVolume("TPC_IFC8",t7,sm3);
389   TGeoVolume *tv8 = new TGeoVolume("TPC_IFC9",t8,sm5);
390   TGeoVolume *tv9 = new TGeoVolume("TPC_IFC10",t9,sm4);
391   // central part - 1 copy
392   TGeoTube *t10 = new TGeoTube(76.6774,78.745,93.75); // tedlar 38 microns 
393   TGeoTube *t11 = new TGeoTube(76.6812,78.7412,93.75); // prepreg3 300 microns
394   TGeoTube *t12 = new TGeoTube(76.7112,78.7112,93.75); // nomex 2 cm
395   //
396   TGeoVolume *tv10 = new TGeoVolume("TPC_IFC11",t10,sm2);
397   TGeoVolume *tv11 = new TGeoVolume("TPC_IFC12",t11,sm5);
398   TGeoVolume *tv12 = new TGeoVolume("TPC_IFC13",t12,sm4);
399   //
400   // inner part - positioning
401   //
402   // creating a sandwich
403   tv2->AddNode(tv3,1); tv3->AddNode(tv4,1); tv4->AddNode(tv5,1);
404   //
405   tv6->AddNode(tv7,1); tv7->AddNode(tv8,1); tv8->AddNode(tv9,1);
406   //
407   tv10->AddNode(tv11,1); tv11->AddNode(tv12,1);
408   //
409   TGeoVolumeAssembly *tv100 = new TGeoVolumeAssembly("TPC_IFC");
410   //
411   tv100->AddNode(tv10,1);
412   tv100->AddNode(tv6,1,new TGeoTranslation(0.,0.,-98.75));
413   tv100->AddNode(tv6,2,new TGeoTranslation(0.,0.,98.75));
414   tv100->AddNode(tv2,1,new TGeoTranslation(0.,0.,-177.925));
415   tv100->AddNode(tv2,2,new TGeoTranslation(0.,0.,177.925));
416   tv100->AddNode(tv1,1,new TGeoTranslation(0.,0.,-252.85));
417   tv100->AddNode(tv1,2,new TGeoTranslation(0.,0.,252.85));
418   //
419   v5->AddNode(v6,1, new TGeoTranslation(0.,0.,-252.1));
420   v5->AddNode(v6,2, new TGeoTranslation(0.,0.,252.1));
421   v1->AddNode(v5,1); v1->AddNode(v7,1); v1->AddNode(v8,1); 
422   v1->AddNode(hvsm,1,new TGeoTranslation(0.,0.,-163.8)); 
423   v1->AddNode(hvss,1,new TGeoTranslation(0.,0.,163.8)); 
424   v9->AddNode(tv100,1);
425   //
426   // central drum 
427   //
428   // flange + sandwich
429   //
430   TGeoPcon *cfl = new TGeoPcon(0.,360.,6);
431   cfl->DefineSection(0,-71.1,59.7,61.2);
432   cfl->DefineSection(1,-68.6,59.7,61.2);
433   //
434   cfl->DefineSection(2,-68.6,60.6324,61.2);
435   cfl->DefineSection(3,68.6,60.6324,61.2); 
436   //
437   cfl->DefineSection(4,68.6,59.7,61.2);
438   cfl->DefineSection(5,71.1,59.7,61.2);  
439   //
440   TGeoVolume *cflv = new TGeoVolume("TPC_CDR",cfl,m3);
441   // sandwich
442   TGeoTube *cd1 = new TGeoTube(60.6424,61.19,71.1);
443   TGeoTube *cd2 = new TGeoTube(60.6462,61.1862,71.1);
444   TGeoTube *cd3 = new TGeoTube(60.6662,61.1662,71.1);  
445   //
446   TGeoMedium *sm6 = gGeoManager->GetMedium("TPC_Prepreg1");
447   TGeoVolume *cd1v = new TGeoVolume("TPC_CDR1",cd1,sm2); //tedlar
448   TGeoVolume *cd2v = new TGeoVolume("TPC_CDR2",cd2,sm6);// prepreg1
449   TGeoVolume *cd3v = new TGeoVolume("TPC_CDR3",cd3,sm4); //nomex
450   //
451   // seals for central drum 2 copies
452   //
453   TGeoTube *cs = new TGeoTube(56.9,61.2,0.1);
454   TGeoMedium *sm7 = gGeoManager->GetMedium("TPC_Mylar");
455   TGeoVolume *csv = new TGeoVolume("TPC_CDRS",cs,sm7);
456   v1->AddNode(csv,1,new TGeoTranslation(0.,0.,-71.2));
457   v1->AddNode(csv,2,new TGeoTranslation(0.,0.,71.2));
458   //
459   // seal collars 
460   TGeoPcon *se = new TGeoPcon(0.,360.,6);
461   se->DefineSection(0,-72.8,59.7,61.2);
462   se->DefineSection(1,-72.3,59.7,61.2);
463   //
464   se->DefineSection(2,-72.3,58.85,61.2);
465   se->DefineSection(3,-71.6,58.85,61.2); 
466   //
467   se->DefineSection(4,-71.6,59.7,61.2);
468   se->DefineSection(5,-71.3,59.7,61.2);  
469   //
470   TGeoVolume *sev = new TGeoVolume("TPC_CDCE",se,m3);
471   //
472   TGeoTube *si = new TGeoTube(56.9,58.8,1.); 
473   TGeoVolume *siv = new TGeoVolume("TPC_CDCI",si,m3);
474   //
475   // define reflection matrix 
476   //
477   TGeoRotation *ref = new TGeoRotation("ref",90.,0.,90.,90.,180.,0.);
478   //
479   cd1v->AddNode(cd2v,1); cd2v->AddNode(cd3v,1); cflv->AddNode(cd1v,1);
480   //
481   v1->AddNode(siv,1,new TGeoTranslation(0.,0.,-69.9));
482   v1->AddNode(siv,2,new TGeoTranslation(0.,0.,69.9));
483   v1->AddNode(sev,1); v1->AddNode(sev,2,ref); v1->AddNode(cflv,1);
484   //
485   // central membrane - 2 rings and a mylar membrane - assembly
486   //
487   TGeoTube *ih = new TGeoTube(81.05,84.05,0.3);
488   TGeoTube *oh = new TGeoTube(250.,256.,.5);
489   TGeoTube *mem = new TGeoTube(84.05,250,0.01);
490   TGeoVolume *ihv = new TGeoVolume("TPC_IHVH",ih,m3);
491   TGeoVolume *ohv = new TGeoVolume("TPC_OHVH",oh,m3);
492   TGeoVolume *memv = new TGeoVolume("TPC_HV",mem,sm7);
493   //
494   TGeoVolumeAssembly *cm = new TGeoVolumeAssembly("TPC_HVMEM");
495   cm->AddNode(ihv,1);
496   cm->AddNode(ohv,1);
497   cm->AddNode(memv,1);
498   v9->AddNode(cm,1);
499   //
500   // end caps - they are make as an assembly of single segments
501   // containing both readout chambers
502   //
503   Double_t openingAngle = 10.*TMath::DegToRad();
504   Double_t thick=1.5; // rib
505   Double_t shift = thick/TMath::Sin(openingAngle);
506   //
507   Double_t lowEdge = 86.3; // hole in the wheel
508   Double_t upEdge = 240.4; // hole in the wheel
509   //
510   new TGeoTubeSeg("sec",74.5,264.4,3.,0.,20.);
511   //
512   TGeoPgon *hole = new TGeoPgon("hole",0.,20.,1,4);
513   //
514   hole->DefineSection(0,-3.5,lowEdge-shift,upEdge-shift);
515   hole->DefineSection(1,-1.5,lowEdge-shift,upEdge-shift);
516   //
517   hole->DefineSection(2,-1.5,lowEdge-shift,upEdge+3.-shift);
518   hole->DefineSection(3,3.5,lowEdge-shift,upEdge+3.-shift);
519   //
520   Double_t ys = shift*TMath::Sin(openingAngle); 
521   Double_t xs = shift*TMath::Cos(openingAngle);
522   TGeoTranslation *tr = new TGeoTranslation("tr",xs,ys,0.);  
523   tr->RegisterYourself();
524   TGeoCompositeShape *chamber = new TGeoCompositeShape("sec-hole:tr");
525   TGeoVolume *sv = new TGeoVolume("TPC_WSEG",chamber,m3);
526   TGeoPgon *bar = new TGeoPgon("bar",0.,20.,1,2);
527   bar->DefineSection(0,-3.,131.5-shift,136.5-shift);
528   bar->DefineSection(1,1.5,131.5-shift,136.5-shift);
529   TGeoVolume *barv = new TGeoVolume("TPC_WBAR",bar,m3);
530   TGeoVolumeAssembly *ch = new TGeoVolumeAssembly("TPC_WCH");//empty segment
531   //
532   ch->AddNode(sv,1); ch->AddNode(barv,1,tr);
533   //
534   // readout chambers
535   //
536   // IROC first
537   //
538    TGeoTrd1 *ibody = new TGeoTrd1(13.8742,21.3328,4.29,21.15);
539    TGeoVolume *ibdv = new TGeoVolume("TPC_IROCB",ibody,m3);
540   // empty space
541    TGeoTrd1 *emp = new TGeoTrd1(12.3742,19.8328,3.99,19.65);
542    TGeoVolume *empv = new TGeoVolume("TPC_IROCE",emp,m1);
543    ibdv->AddNode(empv,1,new TGeoTranslation(0.,-0.3,0.));
544    //bars
545    Double_t tga = (19.8328-12.3742)/39.3;
546    Double_t xmin,xmax;
547    xmin = 9.55*tga+12.3742;
548    xmax = 9.95*tga+12.3742;
549    TGeoTrd1 *ib1 = new TGeoTrd1(xmin,xmax,3.29,0.2);
550    TGeoVolume *ib1v = new TGeoVolume("TPC_IRB1",ib1,m3);
551    empv->AddNode(ib1v,1,new TGeoTranslation("tt1",0.,0.7,-9.9));
552    xmin=19.4*tga+12.3742;
553    xmax=19.9*tga+12.3742;
554    TGeoTrd1 *ib2 = new TGeoTrd1(xmin,xmax,3.29,0.25);
555    TGeoVolume *ib2v = new TGeoVolume("TPC_TRB2",ib2,m3);
556    empv->AddNode(ib2v,1,new TGeoTranslation(0.,0.7,0.));
557    xmin=29.35*tga+12.3742;
558    xmax=29.75*tga+12.3742;
559    TGeoTrd1 *ib3 = new TGeoTrd1(xmin,xmax,3.29,0.2); 
560    TGeoVolume *ib3v = new TGeoVolume("TPC_IRB3",ib3,m3);    
561    empv->AddNode(ib3v,1,new TGeoTranslation(0.,0.7,9.9));
562    //
563    // holes for connectors
564    //
565    TGeoBBox *conn = new TGeoBBox(0.4,0.3,4.675); // identical for iroc and oroc
566    TGeoVolume *connv = new TGeoVolume("TPC_RCCON",conn,m1);
567    TString fileName(gSystem->Getenv("ALICE_ROOT"));
568    fileName += "/TPC/conn_iroc.dat";
569    ifstream in;
570    in.open(fileName.Data(), ios_base::in); // asci file
571    for(Int_t i =0;i<86;i++){
572       Double_t y = 3.99;
573       Double_t x,z,ang;
574       in>>x>>z>>ang;
575       z-=26.5;
576       TGeoRotation *rrr = new TGeoRotation();
577       rrr->RotateY(ang);
578       TGeoCombiTrans *trans = new TGeoCombiTrans("trans",x,y,z,rrr);
579       ibdv->AddNode(connv,i+1,trans);
580    }
581    in.close();
582    // "cap"
583    new TGeoTrd1("icap",14.5974,23.3521,1.19,24.825);
584    // "hole"
585    new TGeoTrd1("ihole",13.8742,21.3328,1.2,21.15);
586    TGeoTranslation *tr1 = new TGeoTranslation("tr1",0.,0.,1.725);  
587    tr1->RegisterYourself();
588    TGeoCompositeShape *ic = new TGeoCompositeShape("icap-ihole:tr1");
589    TGeoVolume *icv = new TGeoVolume("TPC_IRCAP",ic,m3);
590    //
591    // pad plane and wire fixations
592    //
593    TGeoTrd1 *pp = new TGeoTrd1(14.5974,23.3521,0.3,24.825); //pad+iso
594    TGeoMedium *m4 = gGeoManager->GetMedium("TPC_G10");
595    TGeoVolume *ppv = new TGeoVolume("TPC_IRPP",pp,m4);
596    TGeoPara *f1 = new TGeoPara(.6,.5,24.825,0.,-10.,0.);
597    TGeoVolume *f1v = new TGeoVolume("TPC_IRF1",f1,m4);
598    TGeoPara *f2 = new TGeoPara(.6,.5,24.825,0.,10.,0.);
599    TGeoVolume *f2v = new TGeoVolume("TPC_IRF2",f2,m4);
600    //
601    TGeoVolumeAssembly *iroc = new TGeoVolumeAssembly("TPC_IROC");
602    //
603    iroc->AddNode(ibdv,1);
604    iroc->AddNode(icv,1,new TGeoTranslation(0.,3.1,-1.725));
605    iroc->AddNode(ppv,1,new TGeoTranslation(0.,4.59,-1.725));
606    tga =(23.3521-14.5974)/49.65; 
607    Double_t xx = 24.825*tga+14.5974-0.6;
608    iroc->AddNode(f1v,1,new TGeoTranslation(-xx,5.39,-1.725));
609    iroc->AddNode(f2v,1,new TGeoTranslation(xx,5.39,-1.725));
610    //
611    // OROC
612    //
613    TGeoTrd1 *obody = new TGeoTrd1(22.2938,40.5084,4.19,51.65);
614    TGeoVolume *obdv = new TGeoVolume("TPC_OROCB",obody,m3);
615    TGeoTrd1 *oemp = new TGeoTrd1(20.2938,38.5084,3.89,49.65);
616    TGeoVolume *oempv = new TGeoVolume("TPC_OROCE",oemp,m1);
617    obdv->AddNode(oempv,1,new TGeoTranslation(0.,-0.3,0.));
618    //horizontal bars
619    tga=(38.5084-20.2938)/99.3;
620    xmin=tga*10.2+20.2938;
621    xmax=tga*10.6+20.2938;
622    TGeoTrd1 *ob1 = new TGeoTrd1(xmin,xmax,2.915,0.2);
623    TGeoVolume *ob1v = new TGeoVolume("TPC_ORB1",ob1,m3);
624    //
625    xmin=22.55*tga+20.2938;
626    xmax=24.15*tga+20.2938;
627    TGeoTrd1 *ob2 = new TGeoTrd1(xmin,xmax,2.915,0.8);
628    TGeoVolume *ob2v = new TGeoVolume("TPC_ORB2",ob2,m3);
629    //
630    xmin=36.1*tga+20.2938;
631    xmax=36.5*tga+20.2938;
632    TGeoTrd1 *ob3 = new TGeoTrd1(xmin,xmax,2.915,0.2);
633    TGeoVolume *ob3v = new TGeoVolume("TPC_ORB3",ob3,m3);
634    //
635    xmin=49.0*tga+20.2938;
636    xmax=50.6*tga+20.2938;   
637    TGeoTrd1 *ob4 = new TGeoTrd1(xmin,xmax,2.915,0.8);
638    TGeoVolume *ob4v = new TGeoVolume("TPC_ORB4",ob4,m3);
639    //
640    xmin=63.6*tga+20.2938;
641    xmax=64.0*tga+20.2938;
642    TGeoTrd1 *ob5 = new TGeoTrd1(xmin,xmax,2.915,0.2);
643    TGeoVolume *ob5v = new TGeoVolume("TPC_ORB5",ob5,m3);
644    //
645    xmin=75.5*tga+20.2938;
646    xmax=77.15*tga+20.2938;
647    TGeoTrd1 *ob6 = new TGeoTrd1(xmin,xmax,2.915,0.8);
648    TGeoVolume *ob6v = new TGeoVolume("TPC_ORB6",ob6,m3);
649    //
650    xmin=88.7*tga+20.2938;
651    xmax=89.1*tga+20.2938;
652    TGeoTrd1 *ob7 = new TGeoTrd1(xmin,xmax,2.915,0.2);
653    TGeoVolume *ob7v = new TGeoVolume("TPC_ORB7",ob7,m3);
654    //
655    oempv->AddNode(ob1v,1,new TGeoTranslation(0.,0.975,-39.25));
656    oempv->AddNode(ob2v,1,new TGeoTranslation(0.,0.975,-26.3));
657    oempv->AddNode(ob3v,1,new TGeoTranslation(0.,0.975,-13.35));
658    oempv->AddNode(ob4v,1,new TGeoTranslation(0.,0.975,0.15));
659    oempv->AddNode(ob5v,1,new TGeoTranslation(0.,0.975,14.15));
660    oempv->AddNode(ob6v,1,new TGeoTranslation(0.,0.975,26.7));
661    oempv->AddNode(ob7v,1,new TGeoTranslation(0.,0.975,39.25));
662    // vertical bars
663    TGeoBBox *ob8 = new TGeoBBox(0.8,2.915,5.1); 
664    TGeoBBox *ob9 = new TGeoBBox(0.8,2.915,5.975);
665    TGeoBBox *ob10 = new TGeoBBox(0.8,2.915,5.775);
666    TGeoBBox *ob11 = new TGeoBBox(0.8,2.915,6.25);
667    TGeoBBox *ob12 = new TGeoBBox(0.8,2.915,6.5);
668    //
669    TGeoVolume *ob8v = new TGeoVolume("TPC_ORB8",ob8,m3);
670    TGeoVolume *ob9v = new TGeoVolume("TPC_ORB9",ob9,m3);
671    TGeoVolume *ob10v = new TGeoVolume("TPC_ORB10",ob10,m3);
672    TGeoVolume *ob11v = new TGeoVolume("TPC_ORB11",ob11,m3);
673    TGeoVolume *ob12v = new TGeoVolume("TPC_ORB12",ob12,m3);
674    //
675    oempv->AddNode(ob8v,1,new TGeoTranslation(0.,0.975,-44.55));
676    oempv->AddNode(ob8v,2,new TGeoTranslation(0.,0.975,44.55));
677    oempv->AddNode(ob9v,1,new TGeoTranslation(0.,0.975,-33.075));
678    oempv->AddNode(ob9v,2,new TGeoTranslation(0.,0.975,-19.525));
679    oempv->AddNode(ob10v,1,new TGeoTranslation(0.,0.975,20.125));
680    oempv->AddNode(ob10v,2,new TGeoTranslation(0.,0.975,33.275));
681    oempv->AddNode(ob11v,1,new TGeoTranslation(0.,0.975,-6.9));
682    oempv->AddNode(ob12v,1,new TGeoTranslation(0.,0.975,7.45));
683    //
684    // holes for connectors
685    //
686    fileName = gSystem->Getenv("ALICE_ROOT");
687    fileName += "/TPC/conn_oroc.dat";
688    in.open(fileName.Data(), ios_base::in); // asci file
689    for(Int_t i =0;i<78;i++){
690       Double_t y =3.89;
691       Double_t x,z,ang;
692       Double_t x1,z1,x2,z2;
693       in>>x>>z>>ang;        
694       Double_t xr = 4.7*TMath::Sin(ang*TMath::DegToRad());
695       Double_t zr = 4.7*TMath::Cos(ang*TMath::DegToRad());
696       //
697       x1=xr+x; x2=-xr+x; z1=zr+z; z2 = -zr+z;      
698       //
699       TGeoRotation *rr = new TGeoRotation();
700       rr->RotateY(ang); 
701       z1-=54.95;
702       z2-=54.95;
703       TGeoCombiTrans *trans1 = new TGeoCombiTrans("trans1",x1,y,z1,rr);
704       TGeoCombiTrans *trans2 = new TGeoCombiTrans("trans2",x2,y,z2,rr);
705       obdv->AddNode(connv,i+1,trans1);
706       obdv->AddNode(connv,i+79,trans2);
707    }
708    in.close();
709    // cap
710    new TGeoTrd1("ocap",23.3874,43.5239,1.09,57.1);
711    new TGeoTrd1("ohole",22.2938,40.5084,1.09,51.65);
712    TGeoTranslation *tr5 = new TGeoTranslation("tr5",0.,0.,-2.15);
713    tr5->RegisterYourself();
714    TGeoCompositeShape *oc = new TGeoCompositeShape("ocap-ohole:tr5");
715    TGeoVolume *ocv = new TGeoVolume("TPC_ORCAP",oc,m3);
716    //
717    // pad plane and wire fixations
718    //
719    TGeoTrd1 *opp = new TGeoTrd1(23.3874,43.5239,0.3,57.1);
720    TGeoVolume *oppv = new TGeoVolume("TPC_ORPP",opp,m4);
721    //
722    tga=(43.5239-23.3874)/114.2;
723    TGeoPara *f3 = new TGeoPara(.7,.6,57.1,0.,-10.,0.);
724    TGeoPara *f4 = new TGeoPara(.7,.6,57.1,0.,10.,0.);  
725    xx = 57.1*tga+23.3874-0.7;
726    TGeoVolume *f3v = new TGeoVolume("TPC_ORF1",f3,m4);
727    TGeoVolume *f4v = new TGeoVolume("TPC_ORF2",f4,m4);
728    //
729    TGeoVolumeAssembly *oroc = new TGeoVolumeAssembly("TPC_OROC");
730    //
731    oroc->AddNode(obdv,1);
732    oroc->AddNode(ocv,1,new TGeoTranslation(0.,3.1,2.15));
733    oroc->AddNode(oppv,1,new TGeoTranslation(0.,4.49,2.15));
734    oroc->AddNode(f3v,1,new TGeoTranslation(-xx,5.39,2.15));
735    oroc->AddNode(f4v,1,new TGeoTranslation(xx,5.39,2.15));
736    // 
737    // now iroc and oroc are placed into a sector...
738    //
739    TGeoVolumeAssembly *secta = new TGeoVolumeAssembly("TPC_SECT"); // a-side
740    TGeoVolumeAssembly *sectc = new TGeoVolumeAssembly("TPC_SECT"); // c-side
741    TGeoRotation rot1("rot1",90.,90.,0.);
742    TGeoRotation rot2("rot2");
743    rot2.RotateY(10.);
744    TGeoRotation *rot = new TGeoRotation("rot");
745    *rot=rot1*rot2;
746    //
747    Double_t x0,y0;
748    x0=110.2*TMath::Cos(openingAngle);
749    y0=110.2*TMath::Sin(openingAngle);
750    TGeoCombiTrans *combi1a = new TGeoCombiTrans("combi1",x0,y0,1.09+0.195,rot); //a-side 
751    TGeoCombiTrans *combi1c = new TGeoCombiTrans("combi1",x0,y0,1.09+0.222,rot); //c-side
752    x0=188.45*TMath::Cos(openingAngle);
753    y0=188.45*TMath::Sin(openingAngle);
754    TGeoCombiTrans *combi2a = new TGeoCombiTrans("combi2",x0,y0,0.99+0.195,rot); //a-side
755    TGeoCombiTrans *combi2c = new TGeoCombiTrans("combi2",x0,y0,0.99+0.222,rot); //c-side
756    //
757    // A-side
758    //
759    secta->AddNode(ch,1);
760    secta->AddNode(iroc,1,combi1a);
761    secta->AddNode(oroc,1,combi2a);
762    //
763    // C-side
764    //
765    sectc->AddNode(ch,1);
766    sectc->AddNode(iroc,1,combi1c);
767    sectc->AddNode(oroc,1,combi2c);
768    //
769    // now I try to make  wheels...
770    //
771    TGeoVolumeAssembly *wheela = new TGeoVolumeAssembly("TPC_ENDCAP");
772    TGeoVolumeAssembly *wheelc = new TGeoVolumeAssembly("TPC_ENDCAP");
773    //
774    for(Int_t i =0;i<18;i++){
775      Double_t phi = (20.*i);
776      TGeoRotation *r = new TGeoRotation();
777      r->RotateZ(phi);
778      wheela->AddNode(secta,i+1,r);
779      wheelc->AddNode(sectc,i+1,r); 
780     
781    }
782    // wheels in the drift volume!
783    TGeoCombiTrans *combi3 = new TGeoCombiTrans("combi3",0.,0.,256.6,ref);
784    v9->AddNode(wheela,1,combi3);
785    v9->AddNode(wheelc,2,new TGeoTranslation(0.,0.,-256.6));
786    
787    //_____________________________________________________________
788    // service support wheel
789    //_____________________________________________________________
790   TGeoPgon *sw = new TGeoPgon(0.,20.,1,2);
791   sw->DefineSection(0,-4.,80.5,251.75);
792   sw->DefineSection(1,4.,80.5,251.75); 
793   TGeoVolume *swv = new TGeoVolume("TPC_SWSEG",sw,m3); //Al
794   //
795   thick=1.;
796   shift = thick/TMath::Sin(openingAngle);
797   TGeoPgon *sh = new TGeoPgon(0.,20.,1,2);
798   sh->DefineSection(0,-4.,81.5-shift,250.75-shift);
799   sh->DefineSection(1,4.,81.5-shift,250.75-shift);
800   TGeoVolume *shv = new TGeoVolume("TPC_SWS1",sh,m1); //Air
801   //
802   TGeoMedium *m9 =  gGeoManager->GetMedium("TPC_Si"); 
803   TGeoPgon *el = new TGeoPgon(0.,20.,1,2);
804   el->DefineSection(0,-1.872,81.5-shift,250.75-shift);
805   el->DefineSection(1,1.872,81.5-shift,250.75-shift);
806   TGeoVolume *elv = new TGeoVolume("TPC_ELEC",el,m9); //Si 
807   //
808   shv->AddNode(elv,1);
809   //
810   //
811   ys = shift*TMath::Sin(openingAngle);
812   xs = shift*TMath::Cos(openingAngle);
813   swv->AddNode(shv,1,new TGeoTranslation(xs,ys,0.));
814   // cover
815   TGeoPgon *co = new TGeoPgon(0.,20.,1,2);
816   co->DefineSection(0,-0.5,77.,255.25);
817   co->DefineSection(1,0.5,77.,255.25);
818   TGeoVolume *cov = new TGeoVolume("TPC_SWC1",co,m3);//Al
819   // hole in a cover
820   TGeoPgon *coh = new TGeoPgon(0.,20.,1,2);
821   shift=4./TMath::Sin(openingAngle);
822   coh->DefineSection(0,-0.5,85.-shift,247.25-shift);
823   coh->DefineSection(1,0.5,85.-shift,247.25-shift);  
824   //
825   TGeoVolume *cohv = new TGeoVolume("TPC_SWC2",coh,m1);
826   //
827   ys = shift*TMath::Sin(openingAngle);
828   xs = shift*TMath::Cos(openingAngle);  
829   cov->AddNode(cohv,1,new TGeoTranslation(xs,ys,0.));
830   //
831   // Sector as an Assembly
832   //
833   TGeoVolumeAssembly *swhs = new TGeoVolumeAssembly("TPC_SSWSEC");
834   swhs->AddNode(swv,1);
835   swhs->AddNode(cov,1,new TGeoTranslation(0.,0.,-4.5));
836   swhs->AddNode(cov,2,new TGeoTranslation(0.,0.,4.5));
837   //
838   // SSW as an Assembly of sectors
839   //
840  TGeoVolumeAssembly *swheel = new TGeoVolumeAssembly("TPC_SSWHEEL");
841    for(Int_t i =0;i<18;i++){
842      Double_t phi = (20.*i);
843      TGeoRotation *r = new TGeoRotation();
844      r->RotateZ(phi);
845      swheel->AddNode(swhs,i+1,r);   
846    }
847    v1->AddNode(swheel,1,new TGeoTranslation(0.,0.,-284.6));
848    v1->AddNode(swheel,2,new TGeoTranslation(0.,0.,284.6));
849
850    // sensitive strips 
851    TGeoMedium *m8 = gGeoManager->GetMedium("TPC_Ne-CO2-2");
852    Int_t totrows;
853    totrows = fTPCParam->GetNRowLow() + fTPCParam->GetNRowUp();
854    Double_t *upar;
855    upar=NULL;
856    gGeoManager->Volume("TPC_Strip","PGON",m8->GetId(),upar);
857    upar=new Double_t [10];
858    upar[0]=0.;
859    upar[1]=360.;
860    upar[2]=18.;
861    upar[3]=2.;
862    //
863    upar[4]=-124.8;
864    upar[7]=124.8;
865
866    Double_t rlow=fTPCParam->GetPadRowRadiiLow(0);
867
868    upar[5]=rlow;
869    upar[6]=rlow+.01;
870    upar[8]=upar[5];
871    upar[9]=upar[6];
872    //
873    gGeoManager->Node("TPC_Strip",1,"TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10);
874    gGeoManager->Node("TPC_Strip",totrows+1,
875                      "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10);
876    //
877    // now, strips 
878    //
879      //lower sectors
880      for(Int_t i=2;i<fTPCParam->GetNRowLow()+1;i++){
881        rlow=fTPCParam->GetPadRowRadiiLow(i-1);
882        upar[5]=rlow;
883        upar[6]=rlow+.01;
884        upar[8]=upar[5];
885        upar[9]=upar[6];
886        gGeoManager->Node("TPC_Strip",i,
887                          "TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10);
888        gGeoManager->Node("TPC_Strip",totrows+i,
889                          "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10);       
890      }
891      //upper sectors
892      for(Int_t i=1;i<fTPCParam->GetNRowUp()+1;i++){
893        rlow=fTPCParam->GetPadRowRadiiUp(i-1); 
894        upar[5]=rlow;
895        upar[6]=rlow+.01;
896        upar[8]=upar[5];
897        upar[9]=upar[6];
898        gGeoManager->Node("TPC_Strip",i+fTPCParam->GetNRowLow(),
899                          "TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10); 
900        gGeoManager->Node("TPC_Strip",totrows+i+fTPCParam->GetNRowLow(),
901                          "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10); 
902      }
903    
904   //----------------------------------------------------------
905   // TPc Support Rods - MAKROLON
906   //----------------------------------------------------------
907   TGeoMedium *m6=gGeoManager->GetMedium("TPC_Makrolon");
908   TGeoMedium *m7=gGeoManager->GetMedium("TPC_Cu");
909   TGeoMedium *m10 =  gGeoManager->GetMedium("TPC_Alumina");
910   TGeoMedium *m11 =  gGeoManager->GetMedium("TPC_Peek");
911   TGeoMedium *m13 = gGeoManager->GetMedium("TPC_Brass");
912   // 
913   // tpc rod is an assembly of 10 long parts and 2 short parts
914   // connected with alu rings and plagged on both sides.
915   //
916   //
917 // tpc rod long
918 //
919   TGeoPcon *rod = new TGeoPcon("rod",0.,360.,6);
920  rod->DefineSection(0,-10.43,1.92,2.08);
921  rod->DefineSection(1,-9.75,1.92,2.08);
922
923  rod->DefineSection(2,-9.75,1.8,2.2);
924  rod->DefineSection(3,9.75,1.8,2.2);
925
926  rod->DefineSection(4,9.75,1.92,2.08);
927  rod->DefineSection(5,10.43,1.92,2.08);
928  //
929  TGeoVolume *mrodl = new TGeoVolume("TPC_mrodl",rod,m6);
930  //
931  // tpc rod short 
932  //
933  TGeoPcon *rod1 = new TGeoPcon("rod1",0.,360.,6);
934  rod1->DefineSection(0,-8.93,1.92,2.08);
935  rod1->DefineSection(1,-8.25,1.92,2.08);
936
937  rod1->DefineSection(2,-8.25,1.8,2.2);
938  rod1->DefineSection(3,8.25,1.8,2.2);
939
940  rod1->DefineSection(4,8.25,1.92,2.08);
941  rod1->DefineSection(5,8.93,1.92,2.08);
942  //
943  TGeoVolume *mrods = new TGeoVolume("TPC_mrods",rod1,m6);
944  //
945  // below is for the resistor rod
946  //
947  // hole for the brass connectors
948  //
949
950  new TGeoTube("hhole",0.,0.3,0.3);
951  //
952  //transformations for holes - initialy they
953  // are placed at x=0 and negative y
954  //
955   TGeoRotation *rhole = new TGeoRotation();
956   rhole->RotateX(90.);
957   TGeoCombiTrans *transf[13];
958   Char_t name[30];
959   for(Int_t i=0;i<13;i++){
960     //sprintf(name,"transf%d",i);
961     snprintf(name,30,"transf%d",i);
962     transf[i]= new TGeoCombiTrans(name,0.,-2.,-9.+i*1.5,rhole);
963     transf[i]->RegisterYourself();
964   }
965   // union expression for holes
966   TString operl("hhole:transf0");
967   for (Int_t i=1;i<13;i++){
968     //sprintf(name,"+hhole:transf%d",i);
969     snprintf(name,30,"+hhole:transf%d",i);
970     operl.Append(name);   
971   }
972   //
973  TString opers("hhole:transf1");
974   for (Int_t i=2;i<12;i++){
975     //sprintf(name,"+hhole:transf%d",i);
976     snprintf(name,30,"+hhole:transf%d",i); 
977     opers.Append(name);   
978   }
979   //union of holes
980   new TGeoCompositeShape("hlv",operl.Data());
981   new TGeoCompositeShape("hsv",opers.Data());
982   //
983   TGeoCompositeShape *rodl = new TGeoCompositeShape("rodl","rod-hlv");
984   TGeoCompositeShape *rods = new TGeoCompositeShape("rods","rod1-hsv");
985  //rods - volumes - makrolon rods with holes
986   TGeoVolume *rodlv = new TGeoVolume("TPC_rodl",rodl,m6);
987   TGeoVolume *rodsv = new TGeoVolume("TPC_rods",rods,m6);
988   //brass connectors
989  //connectors
990   TGeoTube *bcon = new TGeoTube(0.,0.3,0.3);//connectors
991   TGeoVolume *bconv = new TGeoVolume("TPC_bcon",bcon,m13);
992  //
993  // hooks holding strips
994  //
995  new TGeoBBox("hk1",0.625,0.015,0.75);
996  new TGeoBBox("hk2",0.625,0.015,0.15);
997  TGeoTranslation *tr21 = new TGeoTranslation("tr21",0.,-0.03,-0.6);
998  TGeoTranslation *tr12 = new TGeoTranslation("tr12",0.,-0.03,0.6);
999  tr21->RegisterYourself();
1000  tr12->RegisterYourself();
1001  
1002  TGeoCompositeShape *hook = new TGeoCompositeShape("hook","hk1+hk2:tr21+hk2:tr12");
1003  TGeoVolume *hookv = new TGeoVolume("TPC_hook",hook,m13);
1004  //
1005  // assembly of the short rod with connectors and hooks
1006  //
1007  //
1008  // short rod
1009  //
1010   TGeoVolumeAssembly *spart = new TGeoVolumeAssembly("TPC_spart");
1011   //
1012   spart->AddNode( rodsv,1);
1013   for(Int_t i=1;i<12;i++){
1014   spart->AddNode(bconv,i,transf[i]);
1015   }
1016   for(Int_t i =0;i<11;i++){
1017     spart->AddNode(hookv,i+1,new TGeoTranslation(0.,-2.315,-7.5+i*1.5));
1018   } 
1019  //
1020  // long rod
1021  //
1022   TGeoVolumeAssembly *lpart = new TGeoVolumeAssembly("TPC_lpart");
1023   //
1024   lpart->AddNode( rodlv,1);
1025   for(Int_t i=0;i<13;i++){
1026   lpart->AddNode(bconv,i+12,transf[i]);
1027   }
1028   for(Int_t i =0;i<13;i++){
1029     lpart->AddNode(hookv,i+12,new TGeoTranslation(0.,-2.315,-9.+i*1.5));
1030   }   
1031   //
1032   // alu ring
1033   //
1034   new TGeoTube("ring1",2.1075,2.235,0.53);
1035   new TGeoTube("ring2",1.7925,1.89,0.43);
1036   new TGeoTube("ring3",1.89,2.1075,0.05);
1037   TGeoCompositeShape *ring = new TGeoCompositeShape("ring","ring1+ring2+ring3");
1038   TGeoVolume *ringv = new TGeoVolume("TPC_ring",ring,m3);
1039   //
1040   // rod assembly
1041   //
1042   TGeoVolumeAssembly *tpcrrod = new TGeoVolumeAssembly("TPC_rrod");//rrod
1043   TGeoVolumeAssembly *tpcmrod = new TGeoVolumeAssembly("TPC_mrod");//makrolon rod  
1044   //long pieces
1045   for(Int_t i=0;i<11;i++){
1046     tpcrrod->AddNode(ringv,i+1,new TGeoTranslation(0.,0.,-105.+i*21));
1047     tpcmrod->AddNode(ringv,i+12,new TGeoTranslation(0.,0.,-105.+i*21));
1048   }
1049   for(Int_t i=0;i<10;i++){
1050     tpcrrod->AddNode(lpart,i+1,new TGeoTranslation(0.,0.,-94.5+i*21));//resistor rod
1051     tpcmrod->AddNode(mrodl,i+1,new TGeoTranslation(0.,0.,-94.5+i*21));//makrolon rod        
1052   }
1053   //
1054   // right plug - identical for all rods
1055   //
1056   TGeoPcon *tpcrp = new TGeoPcon(0.,360.,6);
1057   //
1058   tpcrp->DefineSection(0,123.05,1.89,2.1075);
1059   tpcrp->DefineSection(1,123.59,1.89,2.1075);
1060   //
1061   tpcrp->DefineSection(2,123.59,1.8,2.2);
1062   tpcrp->DefineSection(3,127.,1.8,2.2);
1063   //
1064   tpcrp->DefineSection(4,127.,0.,2.2);
1065   tpcrp->DefineSection(5,127.5,0.,2.2);
1066   //
1067   TGeoVolume *tpcrpv = new TGeoVolume("TPC_RP",tpcrp,m6);
1068   //
1069   // adding short pieces and right plug
1070   //
1071   tpcrrod->AddNode(spart,1,new TGeoTranslation(0.,0.,-114.));
1072   tpcrrod->AddNode(spart,2,new TGeoTranslation(0.,0.,114.)); 
1073   tpcrrod->AddNode(ringv,23,new TGeoTranslation(0.,0.,-123.));
1074   tpcrrod->AddNode(ringv,24,new TGeoTranslation(0.,0.,123.));
1075   tpcrrod->AddNode(tpcrpv,1);
1076   //
1077   tpcmrod->AddNode(mrods,1,new TGeoTranslation(0.,0.,-114.));
1078   tpcmrod->AddNode(mrods,2,new TGeoTranslation(0.,0.,114.)); 
1079   tpcmrod->AddNode(ringv,25,new TGeoTranslation(0.,0.,-123.));
1080   tpcmrod->AddNode(ringv,26,new TGeoTranslation(0.,0.,123.));
1081   tpcmrod->AddNode(tpcrpv,2);
1082   //
1083   // from the ringv position to the CM is 3.0 cm!
1084   //----------------------------------------
1085   //
1086   //
1087   //HV rods - makrolon + 0.58cm (diameter) Cu ->check the length
1088   TGeoTube *hvr = new TGeoTube(0.,1.465,123.);
1089   TGeoTube *hvc = new TGeoTube(0.,0.29,123.);
1090   //
1091   TGeoVolume *hvrv = new TGeoVolume("TPC_HV_Rod",hvr,m6);
1092   TGeoVolume *hvcv = new TGeoVolume("TPC_HV_Cable",hvc,m7);
1093   hvrv->AddNode(hvcv,1);
1094   //
1095   //resistor rod
1096   //
1097   TGeoTube *cr = new TGeoTube(0.,0.45,123.);   
1098   TGeoTube *cw = new TGeoTube(0.,0.15,123.);  
1099   TGeoVolume *crv = new TGeoVolume("TPC_CR",cr,m10);
1100   TGeoVolume *cwv = new TGeoVolume("TPC_W",cw,m12);   
1101   //
1102   // ceramic rod with water
1103   //
1104   crv->AddNode(cwv,1);
1105   //
1106   //peek rod
1107   //
1108   TGeoTube *pr =new TGeoTube(0.2,0.35,123.);  
1109   TGeoVolume *prv = new TGeoVolume("TPC_PR",pr,m11); 
1110   //
1111   // copper plates with connectors
1112   //
1113   new TGeoTube("tub",0.,1.7,0.025);
1114   //
1115   // half space - points on the plane and a normal vector
1116   //
1117   Double_t n[3],p[3];
1118   Double_t slope = TMath::Tan(22.*TMath::DegToRad());
1119   Double_t intp = 1.245;
1120   //
1121   Double_t b = slope*slope+1.;
1122   p[0]=intp*slope/b;
1123   p[1]=-intp/b;
1124   p[2]=0.;
1125   //
1126   n[0]=-p[0];
1127   n[1]=-p[1];
1128   n[2]=0.;
1129   Double_t norm;
1130   norm=TMath::Sqrt(n[0]*n[0]+n[1]*n[1]);
1131   n[0] /= norm;
1132   n[1] /=norm;
1133   //
1134   new TGeoHalfSpace("sp1",p,n);
1135   //
1136   slope = -slope; 
1137   //
1138   p[0]=intp*slope/b;
1139   p[1]=-intp/b;
1140   //
1141   n[0]=-p[0];
1142   n[1]=-p[1];
1143   norm=TMath::Sqrt(n[0]*n[0]+n[1]*n[1]);
1144   n[0] /= norm;
1145   n[1] /=norm;
1146   //
1147   new TGeoHalfSpace("sp2",p,n);
1148   // holes for rods
1149  //holes
1150  new TGeoTube("h1",0.,0.5,0.025);
1151  new TGeoTube("h2",0.,0.35,0.025);
1152  //translations:
1153  TGeoTranslation *ttr11 = new TGeoTranslation("ttr11",-0.866,0.5,0.);
1154  TGeoTranslation *ttr22 = new TGeoTranslation("ttr22",0.866,0.5,0.);
1155  ttr11->RegisterYourself();
1156  ttr22->RegisterYourself();
1157  // elastic connector
1158  new TGeoBBox("elcon",0.72,0.005,0.3);
1159  TGeoRotation *crr1 = new TGeoRotation();
1160  crr1->RotateZ(-22.);
1161 TGeoCombiTrans *ctr1 = new TGeoCombiTrans("ctr1",-0.36011, -1.09951,-0.325,crr1);
1162 ctr1->RegisterYourself();
1163  TGeoCompositeShape *cs1 = new TGeoCompositeShape("cs1",
1164 "(((((tub-h1:ttr11)-h1:ttr22)-sp1)-sp2)-h2)+elcon:ctr1");
1165  //
1166  TGeoVolume *csvv = new TGeoVolume("TPC_RR_CU",cs1,m7);
1167  //
1168  // resistor rod assembly 2 ceramic rods, peak rod, Cu plates
1169  // and resistors
1170  //
1171  TGeoVolumeAssembly *rrod = new TGeoVolumeAssembly("TPC_RRIN");
1172  // rods
1173  rrod->AddNode(crv,1,ttr11);
1174  rrod->AddNode(crv,2,ttr22); 
1175  rrod->AddNode(prv,1);
1176  //Cu plates
1177  for(Int_t i=0;i<165;i++){
1178    rrod->AddNode(csvv,i+1,new TGeoTranslation(0.,0.,-122.675+i*1.5));
1179  }
1180  //resistors
1181  TGeoTube *res = new TGeoTube(0.,0.15,0.5);
1182  TGeoVolume *resv = new TGeoVolume("TPC_RES",res,m10);
1183  TGeoVolumeAssembly *ress = new TGeoVolumeAssembly("TPC_RES_CH");
1184  ress->AddNode(resv,1,new TGeoTranslation(0.2,0.,0.));
1185  ress->AddNode(resv,2,new TGeoTranslation(-0.2,0.,0.));
1186  //
1187  TGeoRotation *crr2 = new TGeoRotation();
1188  crr2->RotateY(30.);
1189  TGeoRotation *crr3 = new TGeoRotation();
1190  crr3->RotateY(-30.); 
1191  //
1192  for(Int_t i=0;i<164;i+=2){
1193    rrod->AddNode(ress,i+1, new TGeoCombiTrans(0.,1.2,-121.925+i*1.5,crr2));
1194    rrod->AddNode(ress,i+2, new TGeoCombiTrans(0.,1.2,-121.925+(i+1)*1.5,crr3));
1195  }
1196
1197  tpcrrod->AddNode(rrod,1,new TGeoCombiTrans(0.,0.,0.5,crr1));
1198  //
1199  // rod left head with holders - inner
1200  //
1201  // first element - support for inner holder  TPC_IHS
1202  Double_t shift1[3] = {0.0,-0.175,0.0};
1203
1204 new TGeoBBox("tpcihs1", 4.7, 0.66, 2.35);               
1205 new TGeoBBox("tpcihs2", 4.7, 0.485, 1.0, shift1);
1206 new TGeoBBox("tpcihs3", 1.5, 0.485, 2.35, shift1);
1207 new TGeoTube("tpcihs4", 0.0, 2.38, 0.1);
1208 //
1209 Double_t pointstrap[16];    
1210 pointstrap[0]= 0.0;
1211 pointstrap[1]= 0.0;
1212 pointstrap[2]= 0.0;
1213 pointstrap[3]= 1.08;
1214 pointstrap[4]= 2.3;
1215 pointstrap[5]= 1.08;
1216 pointstrap[6]= 3.38;
1217 pointstrap[7]= 0.0;
1218 pointstrap[8]= 0.0;
1219 pointstrap[9]= 0.0;
1220 pointstrap[10]= 0.0;
1221 pointstrap[11]= 1.08;
1222 pointstrap[12]= 2.3;
1223 pointstrap[13]= 1.08;
1224 pointstrap[14]= 3.38;
1225 pointstrap[15]= 0.0;
1226 //
1227 TGeoArb8 *tpcihs5 = new TGeoArb8("tpcihs5", 0.6, pointstrap);
1228 //
1229 //  half space - cutting "legs"
1230 // 
1231  p[0]=0.0;
1232  p[1]=0.105;
1233  p[2]=0.0;
1234  //       
1235 n[0] = 0.0;
1236 n[1] = 1.0;
1237 n[2] = 0.0;
1238
1239 new TGeoHalfSpace("cutil1", p, n);
1240
1241 //
1242 // transformations
1243 //
1244 TGeoTranslation *trans2 = new TGeoTranslation("trans2", 0.0, 2.84, 2.25);
1245 trans2->RegisterYourself();
1246 TGeoTranslation*trans3= new TGeoTranslation("trans3", 0.0, 2.84, -2.25);
1247 trans3->RegisterYourself();
1248 //support - composite volume
1249 //
1250 TGeoCompositeShape *tpcihs6 = new TGeoCompositeShape("tpcihs6", "tpcihs1-(tpcihs2+tpcihs3)-(tpcihs4:trans2)-(tpcihs4:trans3)-cutil1");
1251 //
1252 // volumes - all makrolon
1253 //  
1254  TGeoVolume *tpcihss = new TGeoVolume("TPC_IHSS", tpcihs6, m6); //support
1255  TGeoVolume *tpcihst = new TGeoVolume("TPC_IHSTR",tpcihs5 , m6); //trapesoid
1256  //now assembly
1257 TGeoRotation *rot111 = new TGeoRotation(); 
1258 rot111->RotateY(180.0);
1259 //
1260 TGeoVolumeAssembly *tpcihs = new TGeoVolumeAssembly("TPC_IHS");    // assembly of the support
1261 tpcihs->AddNode(tpcihss, 1);
1262 tpcihs->AddNode(tpcihst, 1, new TGeoTranslation(-4.7, 0.66, 0.0));
1263 tpcihs->AddNode(tpcihst, 2, new TGeoCombiTrans(4.7, 0.66, 0.0, rot111));
1264 //
1265 // two rod holders (TPC_IRH) assembled with the support
1266 //
1267 new TGeoBBox("tpcirh1", 4.7, 1.33, 0.5);
1268  shift1[0]=-3.65;
1269  shift1[1]=0.53;
1270  shift1[2]=0.;
1271 new TGeoBBox("tpcirh2", 1.05, 0.8, 0.5, shift1);
1272  shift1[0]=3.65;
1273  shift1[1]=0.53;
1274  shift1[2]=0.;
1275 new TGeoBBox("tpcirh3", 1.05, 0.8, 0.5, shift1);
1276  shift1[0]=0.0;
1277  shift1[1]=1.08;
1278  shift1[2]=0.;
1279 new TGeoBBox("tpcirh4", 1.9, 0.25, 0.5, shift1);
1280 new TGeoTube("tpcirh5", 0, 1.9, 5);
1281 //
1282 TGeoTranslation *trans4 = new TGeoTranslation("trans4", 0, 0.83, 0.0); 
1283 trans4->RegisterYourself();
1284 //
1285 TGeoCompositeShape *tpcirh6 = new TGeoCompositeShape("tpcirh6", "tpcirh1-tpcirh2-tpcirh3-(tpcirh5:trans4)-tpcirh4");
1286 //
1287 // now volume
1288 //
1289 TGeoVolume *tpcirh = new TGeoVolume("TPC_IRH", tpcirh6, m6);   
1290 //
1291 // and all together...
1292 //
1293 TGeoVolume *tpciclamp = new TGeoVolumeAssembly("TPC_ICLP");
1294 tpciclamp->AddNode(tpcihs, 1);
1295 tpciclamp->AddNode(tpcirh, 1, new TGeoTranslation(0, 1.99, 1.1));
1296 tpciclamp->AddNode(tpcirh, 2, new TGeoTranslation(0, 1.99, -1.1));
1297 //
1298 // and now left inner "head"
1299 //
1300 TGeoPcon *inplug = new TGeoPcon("inplug", 0.0, 360.0, 14); 
1301
1302 inplug->DefineSection(0, 0.3, 0.0, 2.2);
1303 inplug->DefineSection(1, 0.6, 0.0, 2.2);
1304
1305 inplug->DefineSection(2, 0.6, 0.0, 1.75);
1306 inplug->DefineSection(3, 0.7, 0.0, 1.75);
1307
1308 inplug->DefineSection(4, 0.7, 1.55, 1.75);
1309 inplug->DefineSection(5, 1.6, 1.55, 1.75);
1310
1311 inplug->DefineSection(6, 1.6, 1.55, 2.2);
1312 inplug->DefineSection(7, 1.875, 1.55, 2.2);
1313
1314 inplug->DefineSection(8, 1.875, 1.55, 2.2);
1315 inplug->DefineSection(9, 2.47, 1.75, 2.2);
1316
1317 inplug->DefineSection(10, 2.47, 1.75, 2.08);
1318 inplug->DefineSection(11, 2.57, 1.8, 2.08);
1319
1320 inplug->DefineSection(12, 2.57, 1.92, 2.08);
1321 inplug->DefineSection(13, 2.95, 1.92, 2.08);
1322 //
1323  shift1[0]=0.0;
1324  shift1[1]=-2.09;
1325  shift1[2]=1.075;
1326  //
1327 new TGeoBBox("pcuti", 1.5, 0.11, 1.075, shift1);
1328 //
1329 TGeoCompositeShape *inplleft = new TGeoCompositeShape("inplleft", "inplug-pcuti");
1330 TGeoVolume *tpcinlplug = new TGeoVolume("TPC_INPLL", inplleft, m6);   
1331 //
1332 //  holder + plugs
1333 //
1334  TGeoVolume *tpcihpl = new TGeoVolumeAssembly("TPC_IHPL"); //holder+2 plugs (reflected)
1335  tpcihpl->AddNode(tpcinlplug, 1);
1336  tpcihpl->AddNode(tpcinlplug, 2,ref);
1337  tpcihpl->AddNode(tpciclamp,1,new TGeoTranslation(0.0, -2.765, 0.0)); 
1338  //
1339  // outer holders and clamps
1340  //
1341
1342  // outer membrane holder (between rods)  
1343 pointstrap[0]= 0.0;
1344 pointstrap[1]= 0.0;
1345 pointstrap[2]= 0.0;
1346 pointstrap[3]= 2.8;
1347 pointstrap[4]= 3.1;
1348 pointstrap[5]= 2.8-3.1*TMath::Tan(15.*TMath::DegToRad());
1349 pointstrap[6]= 3.1;
1350 pointstrap[7]= 0.0;
1351 pointstrap[8]= 0.0;
1352 pointstrap[9]= 0.0;
1353 pointstrap[10]= 0.0;
1354 pointstrap[11]= 2.8;
1355 pointstrap[12]= 3.1;
1356 pointstrap[13]= 2.8-3.1*TMath::Tan(15.*TMath::DegToRad());
1357 pointstrap[14]= 3.1;
1358 pointstrap[15]= 0.0;
1359 //
1360 TGeoArb8 *tpcomh1 = new TGeoArb8("tpcomh1", 1.05, pointstrap);   
1361 TGeoBBox *tpcomh2 = new TGeoBBox("tpcomh2", 0.8, 1.4, 6);
1362 //
1363 TGeoVolume *tpcomh1v = new TGeoVolume("TPC_OMH1", tpcomh1, m7);    
1364 TGeoVolume *tpcomh2v = new TGeoVolume("TPC_OMH2", tpcomh2, m7);
1365 //
1366 TGeoVolume *tpcomh3v = new TGeoVolumeAssembly("TPC_OMH3");    // assembly1
1367 tpcomh3v->AddNode(tpcomh1v, 1, new TGeoTranslation(0.8, -1.4, 4.95));
1368  tpcomh3v->AddNode(tpcomh1v, 2, new TGeoTranslation(0.8, -1.4, -4.95));
1369 tpcomh3v->AddNode(tpcomh2v, 1);
1370 //
1371 shift1[0] = 0.9;
1372 shift1[1] = -1.85;
1373 shift1[2] = 0.0;
1374 //
1375 new TGeoBBox("tpcomh3", 1.65, 1.15, 3.4);
1376 TGeoBBox *tpcomh4 = new TGeoBBox("tpcomh4", 0.75, 0.7, 3.4, shift1);
1377 //
1378 // halfspace 1
1379 //
1380 p[0] = 0.0;
1381 p[1] = -1.05;   
1382 p[2] = -3.4;
1383 //
1384 n[0] = 0.0;
1385 n[1] = -1.0*TMath::Tan(30.*TMath::DegToRad());
1386 n[2] = 1.0;
1387 //
1388 new TGeoHalfSpace("cutomh1", p, n); 
1389 //
1390 // halfspace 2
1391 //
1392 p[0] = 0.0;
1393 p[1] = -1.05;   
1394 p[2] = 3.4;
1395 //
1396 n[0] = 0.0;
1397 n[1] = -1.0*TMath::Tan(30.*TMath::DegToRad());
1398 n[2] = -1.0;
1399 //
1400 new TGeoHalfSpace("cutomh2", p, n);
1401 //
1402 // halfspace 3
1403 //
1404 p[0] = -1.65;
1405 p[1] = 0.0;     
1406 p[2] = -0.9;
1407 //
1408 n[0] = 1.0*TMath::Tan(75.*TMath::DegToRad());
1409 n[1] = 0.0;
1410 n[2] = 1.0;
1411 //
1412 new TGeoHalfSpace("cutomh3", p, n);   
1413 //
1414 // halfspace 4
1415 //
1416 p[0] = -1.65;
1417 p[1] = 0.0;      
1418 p[2] = 0.9;
1419 //
1420 n[0] = 1.0*TMath::Tan(75*TMath::DegToRad());
1421 n[1] = 0.0;
1422 n[2] = -1.0;
1423 //
1424 new TGeoHalfSpace("cutomh4", p, n); 
1425 //
1426 // halsfspace 5
1427 //
1428 p[0] = 1.65;
1429 p[1] = -1.05;      
1430 p[2] = 0.0;  
1431 //
1432 n[0] = -1.0;
1433 n[1] = -1.0*TMath::Tan(20.*TMath::DegToRad());
1434 n[2] = 0.0;
1435 //
1436 new TGeoHalfSpace("cutomh5", p, n); 
1437 //  
1438 TGeoCompositeShape *tpcomh5 = new TGeoCompositeShape("tpcomh5", "tpcomh3-cutomh1-cutomh2-cutomh3-cutomh4-cutomh5"); 
1439 //
1440  TGeoVolume *tpcomh5v = new TGeoVolume("TPC_OMH5",tpcomh5,m6);
1441  TGeoVolume *tpcomh4v = new TGeoVolume("TPC_OMH6",tpcomh4,m6);
1442  //
1443  TGeoVolumeAssembly *tpcomh7v = new TGeoVolumeAssembly("TPC_OMH7");
1444  tpcomh7v->AddNode(tpcomh5v,1);
1445  tpcomh7v->AddNode(tpcomh4v,1);
1446  //
1447  // full membrane holder - tpcomh3v + tpcomh7v
1448  //
1449  TGeoVolumeAssembly *tpcomh = new TGeoVolumeAssembly("TPC_OMH");
1450  tpcomh->AddNode(tpcomh3v,1,new TGeoTranslation(1.5,0.,0.));
1451  tpcomh->AddNode(tpcomh3v,2,new TGeoCombiTrans(-1.5,0.,0.,rot111));
1452  tpcomh->AddNode(tpcomh7v,1,new TGeoTranslation(0.65+1.5, 2.55, 0.0));
1453  tpcomh->AddNode(tpcomh7v,2,new TGeoCombiTrans(-0.65-1.5, 2.55, 0.0,rot111)); 
1454  //
1455  //  outer rod holder support
1456  //
1457 new TGeoBBox("tpcohs1", 3.8, 0.675, 2.35); 
1458 //
1459 shift1[0] = 0.0;
1460 shift1[1] = 0.175;
1461 shift1[2] = 0.0;
1462 //
1463 new TGeoBBox("tpcohs2", 1.5, 0.5, 2.35, shift1);
1464 new TGeoBBox("tpcohs3", 3.8, 0.5, 0.85, shift1);
1465 //
1466 shift1[0] = 0.0;
1467 shift1[1] = -1.175;
1468 shift1[2] = 0.0;
1469 //
1470 TGeoBBox *tpcohs4 = new TGeoBBox("tpsohs4", 3.1, 0.5, 0.7, shift1);
1471 //
1472 TGeoVolume *tpcohs4v = new TGeoVolume("TPC_OHS4", tpcohs4, m6);
1473 //
1474 p[0] = 0.0;
1475 p[1] = -0.186;   
1476 p[2] = 0.0;
1477 //
1478 n[0] = 0.0;
1479 n[1] = -1.0;
1480 n[2] = 0.0;
1481 //
1482 new TGeoHalfSpace("cutohs1", p, n);
1483 //
1484 TGeoCompositeShape *tpcohs5 = new TGeoCompositeShape("tpcohs5", "tpcohs1-tpcohs2-tpcohs3-cutohs1"); 
1485 TGeoVolume *tpcohs5v = new TGeoVolume("TPC_OHS5", tpcohs5, m6); 
1486 //
1487 TGeoVolumeAssembly *tpcohs = new TGeoVolumeAssembly("TPC_OHS");    
1488 tpcohs->AddNode(tpcohs5v, 1);
1489 tpcohs->AddNode(tpcohs4v, 1); 
1490 //
1491 // outer rod holder itself
1492 //
1493 shift1[0] = 0.0;
1494 shift1[1] = 1.325;
1495 shift1[2] = 0.0;
1496  new TGeoBBox("tpcorh1", 3.1, 1.825, 0.55); //from this box we cut pieces...
1497  //
1498 shift1[0] = -3.1;       
1499 shift1[1] = -0.5;       
1500 shift1[2] = 0.0;
1501 //
1502 new TGeoBBox("tpcorh2", 0.5, 2.75, 1.1, shift1);
1503 //
1504 shift1[0] = 3.1;        
1505 shift1[1] = -0.5;       
1506 shift1[2] = 0.0;
1507 //
1508 new TGeoBBox("tpcorh3", 0.5, 2.75, 1.1, shift1);
1509 //
1510 shift1[0] = 0.0;
1511 shift1[1] = -0.5;       
1512 shift1[2] = -0.95;
1513 //
1514 new TGeoBBox("tpcorh4", 3.9, 2.75, 0.5, shift1);
1515 //
1516 shift1[0] = 0.0;
1517 shift1[1] = -0.5;
1518 shift1[2] = 0.0;
1519 //
1520 new TGeoBBox("tpcorh5", 1.95, 0.5, 1.1, shift1);
1521 //
1522 shift1[0] = 0.0;
1523 shift1[1] = -0.5;
1524 shift1[2] = 0.55;
1525 //
1526 new TGeoBBox("tpcorh6", 2.4, 0.5, 0.6, shift1);
1527 //
1528 new TGeoTube("tpcorh7", 0, 1.95, 0.85);
1529 new TGeoTube("tpcorh8", 0, 2.4, 0.6);
1530 //
1531 TGeoTranslation *trans33 = new TGeoTranslation("trans33", 0.0, 0.0, 0.55); 
1532 trans33->RegisterYourself();
1533 //
1534 TGeoCompositeShape *tpcorh9 = new TGeoCompositeShape("tpcorh9", "tpcorh1-tpcorh2-tpcorh3-tpcorh4-tpcorh5-tpcorh6-(tpcorh8:trans33)-tpcorh7");
1535 //
1536  TGeoVolume *tpcorh9v = new TGeoVolume("TPC_ORH",tpcorh9,m6); //outer rod holder 
1537  //
1538  // now 2 holders together
1539  //
1540  TGeoVolumeAssembly *tpcorh = new TGeoVolumeAssembly("TPC_ORH2");
1541  //
1542  tpcorh->AddNode(tpcorh9v,1,new TGeoTranslation(0.0, 0.0, 1.25));
1543  tpcorh->AddNode(tpcorh9v,2,new TGeoCombiTrans(0.0, 0.0, -1.25,rot111));
1544 //
1545 // outer rod plug left
1546 //
1547 TGeoPcon *outplug = new TGeoPcon("outplug", 0.0, 360.0, 14); 
1548
1549 outplug->DefineSection(0, 0.5, 0.0, 2.2);
1550 outplug->DefineSection(1, 0.7, 0.0, 2.2);
1551
1552 outplug->DefineSection(2, 0.7, 1.55, 2.2);
1553 outplug->DefineSection(3, 0.8, 1.55, 2.2);
1554
1555 outplug->DefineSection(4, 0.8, 1.55, 1.75);
1556 outplug->DefineSection(5, 1.2, 1.55, 1.75);
1557
1558 outplug->DefineSection(6, 1.2, 1.55, 2.2);
1559 outplug->DefineSection(7, 1.875, 1.55, 2.2);
1560
1561 outplug->DefineSection(8, 1.875, 1.55, 2.2);
1562 outplug->DefineSection(9, 2.47, 1.75, 2.2);
1563
1564 outplug->DefineSection(10, 2.47, 1.75, 2.08);
1565 outplug->DefineSection(11, 2.57, 1.8, 2.08);
1566
1567 outplug->DefineSection(12, 2.57, 1.92, 2.08);
1568 outplug->DefineSection(13, 2.95, 1.92, 2.08);
1569 //
1570 shift1[0] = 0.0;
1571 shift1[1] = 2.09;
1572 shift1[2] = 1.01;
1573
1574 new TGeoBBox("cutout", 2.5, 0.11, 1.01, shift1);
1575 //
1576
1577 TGeoCompositeShape *outplleft = new TGeoCompositeShape("outplleft", "outplug-cutout");    
1578 TGeoVolume *outplleftv = new TGeoVolume("TPC_OPLL", outplleft, m6); 
1579 //
1580 //  support + holder + plug
1581 //
1582
1583  
1584  TGeoVolumeAssembly *tpcohpl = new TGeoVolumeAssembly("TPC_OHPL"); 
1585  //
1586  tpcohpl->AddNode(outplleftv,1); //plug
1587  tpcohpl->AddNode(outplleftv,2,ref); //plug reflected
1588  tpcohpl->AddNode(tpcorh,1); //rod holder
1589  tpcohpl->AddNode(tpcohs,1,new TGeoTranslation(0.0, 3.925, 0)); // support
1590  //
1591
1592  //
1593  // main membrane holder
1594  //           
1595 pointstrap[0]= 0.0;
1596 pointstrap[1]= 0.0;
1597 pointstrap[2]= 0.0;
1598 pointstrap[3]= 2.8;
1599 pointstrap[4]= 3.1;
1600 pointstrap[5]= 1.96;
1601 pointstrap[6]= 3.1;
1602 pointstrap[7]= 0.0;
1603 pointstrap[8]= 0.0;
1604 pointstrap[9]= 0.0;
1605 pointstrap[10]= 0.0;
1606 pointstrap[11]= 2.8;
1607 pointstrap[12]= 3.1;
1608 pointstrap[13]= 1.96;
1609 pointstrap[14]= 3.1;
1610 pointstrap[15]= 0.0; 
1611 //
1612 TGeoArb8 *tpcmmh1 = new TGeoArb8("tpcmmh1", 1.75, pointstrap);
1613 TGeoBBox *tpcmmh2 = new TGeoBBox("tpcmmh2", 0.8, 1.4, 12.5); 
1614 //
1615 TGeoVolume *tpcmmh1v = new TGeoVolume("TPC_MMH1", tpcmmh1, m6);   
1616 TGeoVolume *tpcmmh2v = new TGeoVolume("TPC_MMH2", tpcmmh2, m6);
1617 //
1618  TGeoVolumeAssembly *tpcmmhs = new TGeoVolumeAssembly("TPC_MMHS");
1619  tpcmmhs->AddNode(tpcmmh1v,1,new TGeoTranslation(0.8, -1.4, 10.75));
1620  tpcmmhs->AddNode(tpcmmh1v,2,new TGeoTranslation(0.8, -1.4, -10.75));
1621  tpcmmhs->AddNode(tpcmmh2v,1);
1622  //
1623  // main membrahe holder clamp
1624  //
1625 shift1[0] = -0.75;
1626 shift1[1] = -1.15;
1627 shift1[2] = 0.0;
1628 //
1629 new TGeoBBox("tpcmmhc1", 1.65, 1.85, 8.9); 
1630 new TGeoBBox("tpcmmhc2", 0.9, 0.7, 8.9, shift1);
1631 //
1632 // half spaces  - cuts
1633 //
1634 p[0] = -1.65;
1635 p[1] = 0.0;   
1636 p[2] = -0.9;
1637 //
1638 n[0] = 8.0;
1639 n[1] = 0.0;
1640 n[2] = 8.0*TMath::Tan(13.*TMath::DegToRad());
1641 //
1642 new TGeoHalfSpace("cutmmh1", p, n);
1643 //
1644 p[0] = -1.65;
1645 p[1] = 0.0;   
1646 p[2] = 0.9;
1647 //
1648 n[0] = 8.0;
1649 n[1] = 0.0;
1650 n[2] = -8.0*TMath::Tan(13.*TMath::DegToRad());
1651 //
1652 new TGeoHalfSpace("cutmmh2", p, n);
1653 //
1654 p[0] = 0.0;
1655 p[1] = 1.85;   
1656 p[2] = -2.8;
1657 //
1658 n[0] = 0.0;
1659 n[1] = -6.1;
1660 n[2] = 6.1*TMath::Tan(20.*TMath::DegToRad());
1661 //
1662 new TGeoHalfSpace("cutmmh3", p, n);
1663 //
1664 p[0] = 0.0;
1665 p[1] = 1.85;      
1666 p[2] = 2.8;
1667 //
1668 n[0] = 0.0;
1669 n[1] = -6.1;
1670 n[2] = -6.1*TMath::Tan(20*TMath::DegToRad());
1671 //
1672 new TGeoHalfSpace("cutmmh4", p, n);
1673 //
1674 p[0] = 0.75;
1675 p[1] = 0.0; 
1676 p[2] = -8.9;
1677 //
1678 n[0] = 2.4*TMath::Tan(30*TMath::DegToRad());
1679 n[1] = 0.0;
1680 n[2] = 2.4;
1681 //
1682  new TGeoHalfSpace("cutmmh5", p, n);
1683 //
1684 p[0] = 0.75;
1685 p[1] = 0.0;
1686 p[2] = 8.9;
1687 //
1688 n[0] = 2.4*TMath::Tan(30*TMath::DegToRad());
1689 n[1] = 0.0;
1690 n[2] = -2.4;
1691 //
1692 new TGeoHalfSpace("cutmmh6", p, n);
1693
1694 TGeoCompositeShape *tpcmmhc = new TGeoCompositeShape("TPC_MMHC", "tpcmmhc1-tpcmmhc2-cutmmh1-cutmmh2-cutmmh3-cutmmh4-cutmmh5-cutmmh6"); 
1695
1696  TGeoVolume *tpcmmhcv = new TGeoVolume("TPC_MMHC",tpcmmhc,m6);
1697  //
1698 TGeoVolume *tpcmmh = new TGeoVolumeAssembly("TPC_MMH");
1699 //
1700  tpcmmh->AddNode(tpcmmhcv,1,new TGeoTranslation(0.65+1.5, 1.85, 0.0));
1701  tpcmmh->AddNode(tpcmmhcv,2,new TGeoCombiTrans(-0.65-1.5, 1.85, 0.0,rot111));
1702  tpcmmh->AddNode(tpcmmhs,1,new TGeoTranslation(1.5, 0.0, 0.0));
1703  tpcmmh->AddNode(tpcmmhs,2,new TGeoCombiTrans(-1.5, 0.0, 0.0,rot111));
1704  //
1705  
1706  //
1707
1708 //--------------------------------------------
1709  //
1710  // guard ring resistor chain
1711  //
1712
1713  TGeoTube *gres1 = new TGeoTube(0.,0.375,125.);// inside ifc
1714  //
1715  TGeoVolume *vgres1 = new TGeoVolume("TPC_GRES1",gres1,m10);
1716
1717  //
1718  Double_t xrc,yrc;
1719  //
1720  xrc=79.3*TMath::Cos(350.*TMath::DegToRad());
1721  yrc=79.3*TMath::Sin(350.*TMath::DegToRad());
1722  //
1723  v9->AddNode(vgres1,1,new TGeoTranslation(xrc,yrc,126.9));
1724  v9->AddNode(vgres1,2,new TGeoTranslation(xrc,yrc,-126.9));
1725  //
1726  xrc=79.3*TMath::Cos(190.*TMath::DegToRad());
1727  yrc=79.3*TMath::Sin(190.*TMath::DegToRad()); 
1728  //
1729  v9->AddNode(vgres1,3,new TGeoTranslation(xrc,yrc,126.9));
1730  v9->AddNode(vgres1,4,new TGeoTranslation(xrc,yrc,-126.9));
1731  //------------------------------------------------------------------
1732  TGeoRotation refl("refl",90.,0.,90.,90.,180.,0.);
1733  TGeoRotation rotrod("rotrod");
1734  //
1735  TGeoRotation *rotpos[2]; 
1736  //
1737  TGeoRotation *rotrod1[2]; 
1738
1739   
1740  //v9 - drift gas
1741
1742     TGeoRotation rot102("rot102");
1743     rot102.RotateY(-90.);
1744
1745   for(Int_t i=0;i<18;i++){
1746     Double_t angle,x,y;
1747     Double_t z,r; 
1748     angle=TMath::DegToRad()*20.*(Double_t)i;
1749     //inner rods
1750     r=81.5;
1751     x=r * TMath::Cos(angle);
1752     y=r * TMath::Sin(angle);
1753     z = 126.;
1754     TGeoRotation *rot12 = new TGeoRotation();
1755     rot12->RotateZ(-90.0+i*20.);
1756     v9->AddNode(tpcihpl,i+1,new TGeoCombiTrans(x, y, 0., rot12));
1757     //
1758     if(i==11){//resistor rod inner
1759        rotrod.RotateZ(-90.+angle);
1760        rotrod1[0]= new TGeoRotation();
1761        rotpos[0]= new TGeoRotation();
1762        //
1763        rotrod1[0]->RotateZ(-90.+angle);
1764        *rotpos[0] = refl*rotrod; //rotation+reflection
1765         v9->AddNode(tpcrrod,1,new TGeoCombiTrans(x,y, z, rotrod1[0])); //A
1766         v9->AddNode(tpcrrod,2,new TGeoCombiTrans(x,y,-z, rotpos[0])); //C      
1767     } 
1768     else { 
1769       v9->AddNode(tpcmrod,i+1,new TGeoTranslation(x,y,z));//shaft
1770       v9->AddNode(tpcmrod,i+19,new TGeoCombiTrans(x,y,-z,ref));//muon
1771     }
1772     // outer rods
1773     r=254.25;
1774     x=r * TMath::Cos(angle);
1775     y=r * TMath::Sin(angle);
1776     z=126.;
1777     //
1778     // outer rod holder + outer left plug
1779     //
1780     TGeoRotation *rot33 = new TGeoRotation();
1781     rot33->RotateZ(-90+i*20.);
1782     //
1783     v9->AddNode(tpcohpl,i+1,new TGeoCombiTrans(x, y, 0., rot33));
1784     //
1785     Double_t xxx = 256.297*TMath::Cos((i*20.+10.)*TMath::DegToRad());
1786     Double_t yyy = 256.297*TMath::Sin((i*20.+10.)*TMath::DegToRad());
1787     //
1788     TGeoRotation rot101("rot101");
1789     rot101.RotateZ(90.+i*20.+10.);
1790     TGeoRotation *rot103 = new TGeoRotation("rot103");
1791     *rot103 = rot101*rot102;
1792     //
1793     TGeoCombiTrans *trh100 = new TGeoCombiTrans(xxx,yyy,0.,rot103);
1794     //
1795     if(i==2) {
1796       //main membrane holder
1797       v9->AddNode(tpcmmh,1,trh100);
1798     }
1799     else{
1800       // "normal" membrane holder
1801       v9->AddNode(tpcomh,i+1,trh100);      
1802     }
1803
1804     //
1805     if(i==3){//resistor rod outer
1806       rotrod.RotateZ(90.+angle);
1807       rotrod1[1]= new TGeoRotation();
1808       rotpos[1]= new TGeoRotation();
1809       rotrod1[1]->RotateZ(90.+angle);
1810       *rotpos[1] = refl*rotrod;//rotation+reflection
1811       v9->AddNode(tpcrrod,3,new TGeoCombiTrans(x,y, z, rotrod1[1])); //A 
1812       v9->AddNode(tpcrrod,4,new TGeoCombiTrans(x,y, -z, rotpos[1])); //C
1813     }
1814     else {
1815       v9->AddNode(tpcmrod,i+37,new TGeoTranslation(x,y,z));//shaft
1816       v9->AddNode(tpcmrod,i+55,new TGeoCombiTrans(x,y,-z,ref));//muon      
1817     }
1818     if(i==15){
1819       v9->AddNode(hvrv,1,new TGeoTranslation(x,y,z+0.7)); //hv->A-side only      
1820
1821
1822     }
1823   } //end of rods positioning
1824
1825
1826   TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
1827   alice->AddNode(v1,1);
1828
1829 } // end of function
1830
1831
1832 //_____________________________________________________________________________
1833 void AliTPCv1::CreateMaterials()
1834 {
1835   //
1836   // Define materials for Time Projection Chamber
1837   //
1838   AliTPC::CreateMaterials();
1839 }
1840
1841 //_____________________________________________________________________________
1842 void AliTPCv1::Init()
1843 {
1844   //
1845   // Initialises TPC detector after it has been created
1846   //
1847
1848   fIdSens=gMC->VolId("TPC_Strip"); // sensitive strip
1849
1850   printf("%s: *** TPC version 1 initialized***\n",ClassName());
1851
1852   // printf("TPC version 1 initialized\n");
1853 }
1854
1855 //_____________________________________________________________________________
1856 void AliTPCv1::StepManager()
1857 {
1858   //
1859   // Called at every step in the Time Projection Chamber
1860   //
1861   Int_t         copy, id, i;
1862   Float_t       hits[5];
1863   Int_t         vol[2];
1864   TLorentzVector p;
1865  //
1866
1867   id = gMC->CurrentVolID(copy);
1868   if(id!=fIdSens) return;
1869   if(gMC->TrackCharge() && gMC->IsTrackEntering()) {
1870
1871     // 
1872     // Only charged tracks entering the sensitive volume
1873     //
1874
1875       gMC->TrackPosition(p);
1876   Double_t r = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]);
1877   //
1878   
1879   //
1880   Double_t angle = TMath::ACos(p[0]/r);  
1881   angle = (p[1]<0.) ? TMath::TwoPi()-angle : angle;
1882   //
1883   // angular segment, it is not a real sector number...
1884   //
1885   Int_t sector=TMath::Nint((angle-fTPCParam->GetInnerAngleShift())/
1886                fTPCParam->GetInnerAngle());
1887   // rotate to segment "0"
1888   Float_t cos,sin;
1889   fTPCParam->AdjustCosSin(sector,cos,sin);
1890   Float_t x1 = p[0]*cos + p[1]*sin;
1891   Float_t y1 = TMath::Abs(-p[0]*sin + p[1]*cos);
1892   // calculate real sector number...
1893   if (x1>fTPCParam->GetOuterRadiusLow()){
1894     sector = TMath::Nint((angle-fTPCParam->GetOuterAngleShift())/
1895              fTPCParam->GetOuterAngle())+fTPCParam->GetNInnerSector();
1896     if (p[2]<0)         sector+=(fTPCParam->GetNOuterSector()>>1);
1897   }
1898     else   
1899       if (p[2]<0) sector+=(fTPCParam->GetNInnerSector()>>1); 
1900   //
1901   // here I have a sector number
1902   //
1903   vol[0]=sector;
1904   //
1905   Int_t totrows = fTPCParam->GetNRowLow()+fTPCParam->GetNRowUp();
1906   vol[1] = (copy<=totrows) ? copy-1 : copy-1-totrows;
1907   // row numbers are autonomous for lower and upper sectors
1908   if(vol[0] > fTPCParam->GetNInnerSector()) {
1909      vol[1] -= fTPCParam->GetNRowLow();
1910   }
1911   Double_t range = (sector<36) ? fTPCParam->GetYInner(vol[1]) :
1912                    fTPCParam->GetYOuter(vol[1]);
1913   if(y1>range) return;
1914      if(vol[1] == 0){
1915   
1916         // because Jouri wants to have this
1917
1918         gMC->TrackMomentum(p);
1919         hits[0]=p[0];
1920         hits[1]=p[1];
1921         hits[2]=p[2];
1922         hits[3]=0.; // this hit has no energy loss
1923         // Get also the track time for pileup simulation
1924         hits[4]=gMC->TrackTime();
1925
1926         AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits); // M.I.
1927      }
1928    gMC->TrackPosition(p);
1929       for(i=0;i<3;++i) hits[i]=p[i];
1930       hits[3]=1; //I'd like to have something positive here (I.Belikov)
1931       // Get also the track time for pileup simulation
1932       hits[4]=gMC->TrackTime();
1933
1934       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits); // M.I.    
1935
1936   }// track entering sensitive strip
1937    
1938 }
1939 //_____________________________________________________________________________
1940
1941
1942