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