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