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