]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySupport.cxx
new SPD cooling manifolds (M.Sitta)
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySupport.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 // This class Defines the Geometry for the ITS services and support cones
17 // outside of the ceneteral volume (except for the Ceneteral support 
18 // cylinders. Other classes define the rest of the ITS. Specificaly the ITS
19 // The SSD support cone,SSD Support centeral cylinder, SDD support cone,
20 // The SDD cupport centeral cylinder, the SPD Thermal Sheald, The supports
21 // and cable trays on both the RB26 (muon dump) and RB24 sides, and all of
22 // the cabling from the ladders/stave ends out past the TPC. 
23
24 /* $Id$ */
25 // General Root includes
26 #include <TMath.h>
27 // Root Geometry includes
28 //#include <AliLog.h>
29 #include <TGeoManager.h>
30 #include <TGeoVolume.h>
31 #include <TGeoPcon.h>
32 #include <TGeoCone.h>
33 #include <TGeoTube.h> // contaings TGeoTubeSeg
34 #include <TGeoArb8.h>
35 #include <TGeoXtru.h>
36 #include <TGeoCompositeShape.h>
37 #include <TGeoMatrix.h>
38 #include "AliITSv11GeometrySupport.h"
39
40 ClassImp(AliITSv11GeometrySupport)
41
42 #define SQ(A) (A)*(A)
43
44 //______________________________________________________________________
45 void AliITSv11GeometrySupport::SPDCone(TGeoVolume *moth,const TGeoManager *mgr)
46 {
47 //
48 // Creates the SPD thermal shield as a volume assembly
49 // and adds it to the mother volume
50 // (this is actually a merge of the previous SPDThermalSheald method
51 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06 and the
52 // CreateSPDThermalShield method of AliITSv11Hybrid)
53 //
54 // Input:
55 //         moth : the TGeoVolume owing the volume structure
56 //         mgr  : the GeoManager (default gGeoManager)
57 // Output:
58 //
59 // Created:         ???          ???
60 // Updated:      11 Dec 2007  Mario Sitta
61 // Updated:      20 Mar 2012  Mario Sitta  Reimplemented with simpler shapes
62 // Updated:      20 Jul 2012  Mario Sitta  Reimplemented with Composite Shape
63 //
64 // Technical data are taken from:  ALICE-Thermal Screen "Cone transition"
65 // (thermal-screen1_a3.ps), "Cylinder" (thermal-screen2_a3.ps), "Half
66 // assembly" (thermal-screen3_a3.ps), "Flange" (thermal-screen4_a3.ps)
67
68
69   // Dimensions of the Central shield
70   const Double_t kHalfLengthCentral  = 399.9*fgkmm;
71   const Double_t kThicknessCentral   = 0.4*fgkmm;
72   const Double_t kInnerRadiusCentral = 8.1475*fgkcm;
73   const Double_t kOuterRadiusCentral = 9.9255*fgkcm;
74   const Double_t kInnerACentral = 3.1674*fgkcm;
75   const Double_t kInnerBCentral = 2.023 *fgkcm;
76   const Double_t kOuterACentral = 2.4374*fgkcm;
77   const Double_t kOuterBCentral = 3.8162*fgkcm;
78   const Double_t kCoolManifHoleWid  = 24.0*fgkmm; // TO BE CHECKED!
79   const Double_t kCoolManifHoleLen  = 54.0*fgkmm; // TO BE CHECKED!
80   const Double_t kCoolManifHoleZPos = 33.8*fgkcm;
81   const Double_t kCoolSuppHoleWid  = 15.0*fgkmm; // TO BE CHECKED!
82   const Double_t kCoolSuppHoleLen  = 35.1*fgkmm; // TO BE CHECKED!
83   const Double_t kCoolSuppHoleZPos = 26.5*fgkcm;
84   // Dimensions of the EndCap shield
85   const Double_t kHalfLengthEndCap  = 25.*fgkmm;
86   const Double_t kThicknessEndCap   = 2.0*fgkmm;
87   const Double_t kInnerRadiusEndCap = 8.0775*fgkcm;
88   const Double_t kOuterRadiusEndCap = 9.9955*fgkcm;
89   const Double_t kInnerAEndCap = 3.1453*fgkcm;
90   const Double_t kInnerBEndCap = 2.0009*fgkcm;
91   const Double_t kOuterAEndCap = 2.4596*fgkcm;
92   const Double_t kOuterBEndCap = 3.8384*fgkcm;
93   // Dimensions of the Cone shield
94   const Double_t kHalfLengthCone  = 145.*fgkmm;
95   const Double_t kThicknessCone   = 0.3*fgkmm;
96   const Double_t kInnerRadialCone = 37.3*fgkcm;
97   const Double_t kOuterRadialCone = 39.0*fgkcm;
98   const Double_t kInnerACone = 14.2344*fgkcm;
99   const Double_t kInnerBCone =  9.0915*fgkcm;
100   const Double_t kOuterACone =  9.5058*fgkcm;
101   const Double_t kOuterBCone = 14.8831*fgkcm;
102   // Dimensions of the Flange's Ring and Wing
103   const Double_t kHalfLengthRing  = 7.5*fgkmm;
104   const Double_t kThicknessRing   = 0.3*fgkmm;
105   const Double_t kInnerRadiusRing = 37.3*fgkcm;
106   const Double_t kOuterRadiusRing = 42.0*fgkcm;
107   const Double_t kOuterRadiusWing = 49.25*fgkcm;
108   const Double_t kWideWing      = 6.0*fgkcm;
109   const Double_t kThetaWing     = 45.0;
110   // Common data
111   const Double_t kThetaDeg = 36.0;
112   const Double_t kTheta = kThetaDeg*TMath::DegToRad();
113   const Double_t kThicknessOmega = 0.3*fgkmm;
114
115   // Local variables
116   Double_t zpos;
117   Double_t xXtru[24], yXtru[24];
118   Double_t xshld[24], yshld[24]; // Coord. of external thermal shape
119   Double_t xair[24] , yair[24];  // Coord. of whole air shape
120   Double_t xair1[4] , yair1[4];  // Coord. of every single air volume
121   Double_t xomega[48], yomega[48];
122   //  Double_t *xyarb8;
123
124   // The entire shield is made up of two half central shields
125   // symmetric with respect to the XZ plane, four half end cap
126   // shields, again symmetric with respect to the XZ plane, and four
127   // half cones, symmetric with respect to the XZ plane too.
128
129   TGeoVolumeAssembly *vM = new TGeoVolumeAssembly("ITSspdThermalShield");
130
131   // The central half shield: a Composite Shape of carbon fiber.
132   // We need Composite Shapes because we have holes in which the SPD
133   // cooling manifolds and their supports will be placed.
134   // All Composite elements are XTru shapes
135
136   // First determine the external shape points
137   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
138                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
139                         kTheta,xshld,yshld);
140
141   // Now rescale to get the air volume dimensions
142     InsidePoint(xshld[23], yshld[23],
143                 xshld[ 0], yshld[ 0],
144                 xshld[ 1], yshld[ 1], kThicknessCentral,
145                 xair[0], yair[0]);
146   for (Int_t i=1; i<23; i++) {
147     InsidePoint(xshld[i-1], yshld[i-1],
148                 xshld[ i ], yshld[ i ],
149                 xshld[i+1], yshld[i+1], kThicknessCentral,
150                 xair[i], yair[i]);
151   }
152     InsidePoint(xshld[22], yshld[22],
153                 xshld[23], yshld[23],
154                 xshld[ 0], yshld[ 0], kThicknessCentral,
155                 xair[23], yair[23]);
156
157   // Then use them to determine the Omega shape points
158   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
159
160   // Finally create the single Xtru volumes
161   TGeoXtru *uppershape = new TGeoXtru(2);
162   uppershape->SetName("upTS");
163
164   for (Int_t j=0; j<6; j++) {
165     xXtru[j  ] = xair[11-j];
166     yXtru[j  ] = yair[11-j];
167     xXtru[j+6] = xshld[j+6];
168     yXtru[j+6] = yshld[j+6];
169   }
170   yXtru[5] = yXtru[6];  // Air is not at same Y as thermal shield
171   for (Int_t j=0; j<12; j++) {
172     xXtru[23-j] = -xXtru[j];
173     yXtru[23-j] =  yXtru[j];
174   }
175
176   uppershape->DefinePolygon(24,xXtru,yXtru);
177   uppershape->DefineSection(0,-kHalfLengthCentral);
178   uppershape->DefineSection(1, kHalfLengthCentral);
179
180   TGeoXtru *lowershape = new TGeoXtru(2);
181   lowershape->SetName("lwTS");
182
183   for (Int_t j=0; j<6; j++) {
184     xXtru[j  ] = xshld[j];
185     yXtru[j  ] = yshld[j];
186     xXtru[j+6] = xair[5-j];
187     yXtru[j+6] = yair[5-j];
188   }
189   yXtru[6] = yXtru[5];  // Air is not at same Y as thermal shield
190   for (Int_t j=0; j<12; j++) {
191     xXtru[23-j] = -xXtru[j];
192     yXtru[23-j] =  yXtru[j];
193   }
194
195   lowershape->DefinePolygon(24,xXtru,yXtru);
196   lowershape->DefineSection(0,-kHalfLengthCentral);
197   lowershape->DefineSection(1, kHalfLengthCentral);
198
199   yomega[10] = yshld[6];   // Add also base thickness
200   yomega[11] = yomega[10];
201   yomega[36] = yshld[17];
202   yomega[37] = yomega[36];
203
204   TGeoXtru *omegashape = new TGeoXtru(2);
205   omegashape->SetName("omTS");
206
207   omegashape->DefinePolygon(48,xomega,yomega);
208   omegashape->DefineSection(0,-kHalfLengthCentral);
209   omegashape->DefineSection(1, kHalfLengthCentral);
210
211   // And now the holes and their position matrices
212   Double_t radius = 0.5*(uppershape->GetY(11)+lowershape->GetY(0));
213
214   TGeoBBox *manifhole = new TGeoBBox(kCoolManifHoleWid/2,
215           0.55*(uppershape->GetY(11)-lowershape->GetY(0)),
216                                      kCoolManifHoleLen/2);
217   manifhole->SetName("mhTS");
218
219   zpos = kCoolManifHoleZPos + manifhole->GetDZ();
220
221   TGeoTranslation *m1p = new TGeoTranslation("m1p",0,radius, zpos);
222   TGeoTranslation *m1n = new TGeoTranslation("m1n",0,radius,-zpos);
223   m1p->RegisterYourself();
224   m1n->RegisterYourself();
225
226   TGeoCombiTrans *m2p = new TGeoCombiTrans("m2p",radius*SinD(kThetaDeg),
227                                                  radius*CosD(kThetaDeg),
228                                            zpos,
229                                         new TGeoRotation("",-kThetaDeg,0,0));
230   TGeoCombiTrans *m2n = new TGeoCombiTrans("m2n",radius*SinD(kThetaDeg),
231                                                  radius*CosD(kThetaDeg),
232                                           -zpos,
233                                         new TGeoRotation("",-kThetaDeg,0,0));
234   m2p->RegisterYourself();
235   m2n->RegisterYourself();
236
237   TGeoCombiTrans *m3p = new TGeoCombiTrans("m3p",radius*SinD(-kThetaDeg),
238                                                  radius*CosD(-kThetaDeg),
239                                            zpos,
240                                         new TGeoRotation("",kThetaDeg,0,0));
241   TGeoCombiTrans *m3n = new TGeoCombiTrans("m3n",radius*SinD(-kThetaDeg),
242                                                  radius*CosD(-kThetaDeg),
243                                           -zpos,
244                                         new TGeoRotation("",kThetaDeg,0,0));
245   m3p->RegisterYourself();
246   m3n->RegisterYourself();
247
248   TGeoCombiTrans *m4p = new TGeoCombiTrans("m4p",radius*SinD(2*kThetaDeg),
249                                                  radius*CosD(2*kThetaDeg),
250                                            zpos,
251                                         new TGeoRotation("",-2*kThetaDeg,0,0));
252   TGeoCombiTrans *m4n = new TGeoCombiTrans("m4n",radius*SinD(2*kThetaDeg),
253                                                  radius*CosD(2*kThetaDeg),
254                                           -zpos,
255                                         new TGeoRotation("",-2*kThetaDeg,0,0));
256   m4p->RegisterYourself();
257   m4n->RegisterYourself();
258
259   TGeoCombiTrans *m5p = new TGeoCombiTrans("m5p",radius*SinD(-2*kThetaDeg),
260                                                  radius*CosD(-2*kThetaDeg),
261                                            zpos,
262                                         new TGeoRotation("",2*kThetaDeg,0,0));
263   TGeoCombiTrans *m5n = new TGeoCombiTrans("m5n",radius*SinD(-2*kThetaDeg),
264                                                  radius*CosD(-2*kThetaDeg),
265                                           -zpos,
266                                         new TGeoRotation("",2*kThetaDeg,0,0));
267   m5p->RegisterYourself();
268   m5n->RegisterYourself();
269
270   TGeoBBox *supphole = new TGeoBBox(kCoolSuppHoleWid/2,
271          0.55*(uppershape->GetY(11)-lowershape->GetY(0)),
272                                     kCoolSuppHoleLen/2);
273   supphole->SetName("shTS");
274
275   zpos = kCoolSuppHoleZPos + supphole->GetDZ();
276
277   TGeoTranslation *s1p = new TGeoTranslation("s1p",0,radius, zpos);
278   TGeoTranslation *s1n = new TGeoTranslation("s1n",0,radius,-zpos);
279   s1p->RegisterYourself();
280   s1n->RegisterYourself();
281
282   TGeoCombiTrans *s2p = new TGeoCombiTrans("s2p",radius*SinD(kThetaDeg),
283                                                  radius*CosD(kThetaDeg),
284                                            zpos,
285                                         new TGeoRotation("",-kThetaDeg,0,0));
286   TGeoCombiTrans *s2n = new TGeoCombiTrans("s2n",radius*SinD(kThetaDeg),
287                                                  radius*CosD(kThetaDeg),
288                                           -zpos,
289                                         new TGeoRotation("",-kThetaDeg,0,0));
290   s2p->RegisterYourself();
291   s2n->RegisterYourself();
292
293   TGeoCombiTrans *s3p = new TGeoCombiTrans("s3p",radius*SinD(-kThetaDeg),
294                                                  radius*CosD(-kThetaDeg),
295                                            zpos,
296                                         new TGeoRotation("",kThetaDeg,0,0));
297   TGeoCombiTrans *s3n = new TGeoCombiTrans("s3n",radius*SinD(-kThetaDeg),
298                                                  radius*CosD(-kThetaDeg),
299                                           -zpos,
300                                         new TGeoRotation("",kThetaDeg,0,0));
301   s3p->RegisterYourself();
302   s3n->RegisterYourself();
303
304   TGeoCombiTrans *s4p = new TGeoCombiTrans("s4p",radius*SinD(2*kThetaDeg),
305                                                  radius*CosD(2*kThetaDeg),
306                                            zpos,
307                                         new TGeoRotation("",-2*kThetaDeg,0,0));
308   TGeoCombiTrans *s4n = new TGeoCombiTrans("s4n",radius*SinD(2*kThetaDeg),
309                                                  radius*CosD(2*kThetaDeg),
310                                           -zpos,
311                                         new TGeoRotation("",-2*kThetaDeg,0,0));
312   s4p->RegisterYourself();
313   s4n->RegisterYourself();
314
315   TGeoCombiTrans *s5p = new TGeoCombiTrans("s5p",radius*SinD(-2*kThetaDeg),
316                                                  radius*CosD(-2*kThetaDeg),
317                                            zpos,
318                                         new TGeoRotation("",2*kThetaDeg,0,0));
319   TGeoCombiTrans *s5n = new TGeoCombiTrans("s5n",radius*SinD(-2*kThetaDeg),
320                                                  radius*CosD(-2*kThetaDeg),
321                                           -zpos,
322                                         new TGeoRotation("",2*kThetaDeg,0,0));
323   s5p->RegisterYourself();
324   s5n->RegisterYourself();
325
326   // Finally the actual shape
327   TGeoCompositeShape *centralshape = new TGeoCompositeShape("centralTS",
328     "upTS+lwTS+omTS-mhTS:m1p-mhTS:m1n-mhTS:m2p-mhTS:m2n-mhTS:m3p-mhTS:m3n-mhTS:m4p-mhTS:m4n-mhTS:m5p-mhTS:m5n-shTS:s1p-shTS:s1n-shTS:s2p-shTS:s2n-shTS:s3p-shTS:s3n-shTS:s4p-shTS:s4n-shTS:s5p-shTS:s5n");
329 //    "upTS+lwTS+omTS-shTS:s1p-shTS:s2p-shTS:s3p-shTS:s4p");
330 //    "upTS+lwTS+omTS+mhTS:m1p+mhTS:m2p+mhTS:m3p+mhTS:m4p");
331
332   // The end cap half shield: a half tube of carbon fiber,
333   // filled with air volumes, which together make the whole shield
334   // (i.e. the tube and the Omega-shaped insert).
335   // They are all XTru shapes
336
337   TGeoXtru *endcapshape = new TGeoXtru(2);
338
339   CreateSPDThermalShape(kInnerAEndCap,kInnerBEndCap,kInnerRadiusEndCap,
340                         kOuterAEndCap,kOuterBEndCap,kOuterRadiusEndCap,
341                         kTheta,xshld,yshld);
342
343   endcapshape->DefinePolygon(24,xshld,yshld);
344   endcapshape->DefineSection(0,-kHalfLengthEndCap);
345   endcapshape->DefineSection(1, kHalfLengthEndCap);
346
347   // Now rescale to get the air volume dimensions
348     InsidePoint(xshld[23], yshld[23],
349                 xshld[ 0], yshld[ 0],
350                 xshld[ 1], yshld[ 1], kThicknessEndCap,
351                 xair[0], yair[0]);
352   for (Int_t i=1; i<23; i++) {
353     InsidePoint(xshld[i-1], yshld[i-1],
354                 xshld[ i ], yshld[ i ],
355                 xshld[i+1], yshld[i+1], kThicknessEndCap,
356                 xair[i], yair[i]);
357   }
358     InsidePoint(xshld[22], yshld[22],
359                 xshld[23], yshld[23],
360                 xshld[ 0], yshld[ 0], kThicknessEndCap,
361                 xair[23], yair[23]);
362
363   // Then use them to determine the Omega shape points
364   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
365
366   // Finally create the single air volumes
367   TGeoXtru *endcapair1shape = new TGeoXtru(2);
368
369   xair1[0] = xomega[1];
370   yair1[0] = yomega[1];
371   xair1[1] = xomega[0];
372   yair1[1] = yomega[0];
373   xair1[2] = -xair1[1];
374   yair1[2] =  yair1[1];
375   xair1[3] = -xair1[0];
376   yair1[3] =  yair1[0];
377
378   endcapair1shape->DefinePolygon(4,xair1,yair1);
379   endcapair1shape->DefineSection(0,-kHalfLengthEndCap);
380   endcapair1shape->DefineSection(1, kHalfLengthEndCap);
381
382   TGeoXtru *endcapair2shape = new TGeoXtru(2);
383
384   xair1[0] = xomega[21];
385   yair1[0] = yomega[21];
386   xair1[1] = xomega[20];
387   yair1[1] = yomega[20];
388   xair1[2] = xomega[23];
389   yair1[2] = yomega[23];
390   xair1[3] = xomega[22];
391   yair1[3] = yomega[22];
392
393   endcapair2shape->DefinePolygon(4,xair1,yair1);
394   endcapair2shape->DefineSection(0,-kHalfLengthEndCap);
395   endcapair2shape->DefineSection(1, kHalfLengthEndCap);
396
397   TGeoXtru *endcapair3shape = new TGeoXtru(2);
398
399   xair1[0] = xomega[2];
400   yair1[0] = yomega[2];
401   xair1[1] = xomega[3];
402   yair1[1] = yomega[3];
403   xair1[2] = xomega[4];
404   yair1[2] = yomega[4];
405   xair1[3] = xomega[5];
406   yair1[3] = yomega[5];
407
408   endcapair3shape->DefinePolygon(4,xair1,yair1);
409   endcapair3shape->DefineSection(0,-kHalfLengthEndCap);
410   endcapair3shape->DefineSection(1, kHalfLengthEndCap);
411
412   TGeoXtru *endcapair4shape = new TGeoXtru(2);
413
414   xair1[0] = xomega[16];
415   yair1[0] = yomega[16];
416   xair1[1] = xomega[17];
417   yair1[1] = yomega[17];
418   xair1[2] = xomega[18];
419   yair1[2] = yomega[18];
420   xair1[3] = xomega[19];
421   yair1[3] = yomega[19];
422
423   endcapair4shape->DefinePolygon(4,xair1,yair1);
424   endcapair4shape->DefineSection(0,-kHalfLengthEndCap);
425   endcapair4shape->DefineSection(1, kHalfLengthEndCap);
426
427   TGeoXtru *endcapair5shape = new TGeoXtru(2);
428
429   xair1[0] = xomega[6];
430   yair1[0] = yomega[6];
431   xair1[1] = xomega[7];
432   yair1[1] = yomega[7];
433   xair1[2] = xomega[8];
434   yair1[2] = yomega[8];
435   xair1[3] = xomega[9];
436   yair1[3] = yomega[9];
437
438   endcapair5shape->DefinePolygon(4,xair1,yair1);
439   endcapair5shape->DefineSection(0,-kHalfLengthEndCap);
440   endcapair5shape->DefineSection(1, kHalfLengthEndCap);
441
442   TGeoXtru *endcapair6shape = new TGeoXtru(2);
443
444   xair1[0] = xomega[12];
445   yair1[0] = yomega[12];
446   xair1[1] = xomega[13];
447   yair1[1] = yomega[13];
448   xair1[2] = xomega[14];
449   yair1[2] = yomega[14];
450   xair1[3] = xomega[15];
451   yair1[3] = yomega[15];
452
453   endcapair6shape->DefinePolygon(4,xair1,yair1);
454   endcapair6shape->DefineSection(0,-kHalfLengthEndCap);
455   endcapair6shape->DefineSection(1, kHalfLengthEndCap);
456
457   // The cone half shield is more complex since there is no basic
458   // TGeo shape to describe it correctly. So it is a Composite Shape
459   // of a series of TGeoArb8 shapes, in which TGeoArb8 shapes filled
460   // with air are placed, which all together make up the cone AND
461   // its internal insert. Part of the following code is adapted from
462   // old SPDThermalSheald method.
463
464   // sCn : Filled portions, sChn : Air holes
465   TGeoArb8 *sC1  = new TGeoArb8(kHalfLengthCone);
466   TGeoArb8 *sC2  = new TGeoArb8(kHalfLengthCone);
467   TGeoArb8 *sC3  = new TGeoArb8(kHalfLengthCone);
468   TGeoArb8 *sC4  = new TGeoArb8(kHalfLengthCone);
469   TGeoArb8 *sC5  = new TGeoArb8(kHalfLengthCone);
470   TGeoArb8 *sC6  = new TGeoArb8(kHalfLengthCone);
471   TGeoArb8 *sC7  = new TGeoArb8(kHalfLengthCone);
472   TGeoArb8 *sC8  = new TGeoArb8(kHalfLengthCone);
473   TGeoArb8 *sC9  = new TGeoArb8(kHalfLengthCone);
474   TGeoArb8 *sC10 = new TGeoArb8(kHalfLengthCone);
475   TGeoArb8 *sC11 = new TGeoArb8(kHalfLengthCone);
476
477   sC1->SetName("sC1");
478   sC2->SetName("sC2");
479   sC3->SetName("sC3");
480   sC4->SetName("sC4");
481   sC5->SetName("sC5");
482   sC6->SetName("sC6");
483   sC7->SetName("sC7");
484   sC8->SetName("sC8");
485   sC9->SetName("sC9");
486   sC10->SetName("sC10");
487   sC11->SetName("sC11");
488
489   TGeoArb8 *sCh1  = new TGeoArb8(kHalfLengthCone);
490   TGeoArb8 *sCh2  = new TGeoArb8(kHalfLengthCone);
491   TGeoArb8 *sCh3  = new TGeoArb8(kHalfLengthCone);
492   TGeoArb8 *sCh4  = new TGeoArb8(kHalfLengthCone);
493   TGeoArb8 *sCh5  = new TGeoArb8(kHalfLengthCone);
494   TGeoArb8 *sCh6  = new TGeoArb8(kHalfLengthCone);
495   TGeoArb8 *sCh7  = new TGeoArb8(kHalfLengthCone);
496   TGeoArb8 *sCh8  = new TGeoArb8(kHalfLengthCone);
497   TGeoArb8 *sCh9  = new TGeoArb8(kHalfLengthCone);
498   TGeoArb8 *sCh10 = new TGeoArb8(kHalfLengthCone);
499   TGeoArb8 *sCh11 = new TGeoArb8(kHalfLengthCone);
500
501   sCh1->SetName("sCh1");
502   sCh2->SetName("sCh2");
503   sCh3->SetName("sCh3");
504   sCh4->SetName("sCh4");
505   sCh5->SetName("sCh5");
506   sCh6->SetName("sCh6");
507   sCh7->SetName("sCh7");
508   sCh8->SetName("sCh8");
509   sCh9->SetName("sCh9");
510   sCh10->SetName("sCh10");
511   sCh11->SetName("sCh11");
512
513   // Smaller end: determine the coordinates of the points of carbon fiber
514   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
515                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
516                         kTheta,xshld,yshld);
517
518   sC1->SetVertex(0, xshld[12], yshld[12]);
519   sC1->SetVertex(1, xshld[11], yshld[11]);
520   sC1->SetVertex(2, xshld[ 0], yshld[ 0]);
521   sC1->SetVertex(3, xshld[23], yshld[23]);
522
523   sC2->SetVertex(0, xshld[11], yshld[11]);
524   sC2->SetVertex(1, xshld[10], yshld[10]);
525   sC2->SetVertex(2, xshld[ 1], yshld[ 1]);
526   sC2->SetVertex(3, xshld[ 0], yshld[ 0]);
527
528   sC3->SetVertex(0, xshld[10], yshld[10]);
529   sC3->SetVertex(1, xshld[ 9], yshld[ 9]);
530   sC3->SetVertex(2, xshld[ 2], yshld[ 2]);
531   sC3->SetVertex(3, xshld[ 1], yshld[ 1]);
532
533   sC4->SetVertex(0, xshld[ 9], yshld[ 9]);
534   sC4->SetVertex(1, xshld[ 8], yshld[ 8]);
535   sC4->SetVertex(2, xshld[ 3], yshld[ 3]);
536   sC4->SetVertex(3, xshld[ 2], yshld[ 2]);
537
538   sC5->SetVertex(0, xshld[ 8], yshld[ 8]);
539   sC5->SetVertex(1, xshld[ 7], yshld[ 7]);
540   sC5->SetVertex(2, xshld[ 4], yshld[ 4]);
541   sC5->SetVertex(3, xshld[ 3], yshld[ 3]);
542
543   sC6->SetVertex(0, xshld[ 7], yshld[ 7]);
544   sC6->SetVertex(1, xshld[ 6], yshld[ 6]);
545   sC6->SetVertex(2, xshld[ 5], yshld[ 5]);
546   sC6->SetVertex(3, xshld[ 4], yshld[ 4]);
547
548   sC7->SetVertex(0,-xshld[10], yshld[10]);
549   sC7->SetVertex(1,-xshld[11], yshld[11]);
550   sC7->SetVertex(2,-xshld[ 0], yshld[ 0]);
551   sC7->SetVertex(3,-xshld[ 1], yshld[ 1]);
552
553   sC8->SetVertex(0,-xshld[ 9], yshld[ 9]);
554   sC8->SetVertex(1,-xshld[10], yshld[10]);
555   sC8->SetVertex(2,-xshld[ 1], yshld[ 1]);
556   sC8->SetVertex(3,-xshld[ 2], yshld[ 2]);
557
558   sC9->SetVertex(0,-xshld[ 8], yshld[ 8]);
559   sC9->SetVertex(1,-xshld[ 9], yshld[ 9]);
560   sC9->SetVertex(2,-xshld[ 2], yshld[ 2]);
561   sC9->SetVertex(3,-xshld[ 3], yshld[ 3]);
562
563   sC10->SetVertex(0,-xshld[ 7], yshld[ 7]);
564   sC10->SetVertex(1,-xshld[ 8], yshld[ 8]);
565   sC10->SetVertex(2,-xshld[ 3], yshld[ 3]);
566   sC10->SetVertex(3,-xshld[ 4], yshld[ 4]);
567
568   sC11->SetVertex(0,-xshld[ 6], yshld[ 6]);
569   sC11->SetVertex(1,-xshld[ 7], yshld[ 7]);
570   sC11->SetVertex(2,-xshld[ 4], yshld[ 4]);
571   sC11->SetVertex(3,-xshld[ 5], yshld[ 5]);
572
573   // Then rescale to get the air volume dimensions
574     InsidePoint(xshld[23], yshld[23],
575                 xshld[ 0], yshld[ 0],
576                 xshld[ 1], yshld[ 1], kThicknessCone,
577                 xair[0], yair[0]);
578   for (Int_t i=1; i<23; i++) {
579     InsidePoint(xshld[i-1], yshld[i-1],
580                 xshld[ i ], yshld[ i ],
581                 xshld[i+1], yshld[i+1], kThicknessCone,
582                 xair[i], yair[i]);
583   }
584     InsidePoint(xshld[22], yshld[22],
585                 xshld[23], yshld[23],
586                 xshld[ 0], yshld[ 0], kThicknessCone,
587                 xair[23], yair[23]);
588
589   // Then use them to determine the Omega shape points
590   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
591
592   // Finally fill the small end coordinates of the air shapes
593   sCh1->SetVertex(0, xomega[ 0], yomega[ 0]);
594   sCh1->SetVertex(1, xomega[ 1], yomega[ 1]);
595   sCh1->SetVertex(2,-xomega[ 1], yomega[ 1]);
596   sCh1->SetVertex(3,-xomega[ 0], yomega[ 0]);
597
598   sCh2->SetVertex(0, xomega[20], yomega[20]);
599   sCh2->SetVertex(1, xomega[21], yomega[21]);
600   sCh2->SetVertex(2, xomega[22], yomega[22]);
601   sCh2->SetVertex(3, xomega[23], yomega[23]);
602
603   sCh3->SetVertex(0, xomega[ 2], yomega[ 2]);
604   sCh3->SetVertex(1, xomega[ 3], yomega[ 3]);
605   sCh3->SetVertex(2, xomega[ 4], yomega[ 4]);
606   sCh3->SetVertex(3, xomega[ 5], yomega[ 5]);
607
608   sCh4->SetVertex(0, xomega[16], yomega[16]);
609   sCh4->SetVertex(1, xomega[17], yomega[17]);
610   sCh4->SetVertex(2, xomega[18], yomega[18]);
611   sCh4->SetVertex(3, xomega[19], yomega[19]);
612
613   sCh5->SetVertex(0, xomega[ 6], yomega[ 6]);
614   sCh5->SetVertex(1, xomega[ 7], yomega[ 7]);
615   sCh5->SetVertex(2, xomega[ 8], yomega[ 8]);
616   sCh5->SetVertex(3, xomega[ 9], yomega[ 9]);
617
618   sCh6->SetVertex(0, xomega[12], yomega[12]);
619   sCh6->SetVertex(1, xomega[13], yomega[13]);
620   sCh6->SetVertex(2, xomega[14], yomega[14]);
621   sCh6->SetVertex(3, xomega[15], yomega[15]);
622
623   sCh7->SetVertex(0,-xomega[21], yomega[21]);
624   sCh7->SetVertex(1,-xomega[20], yomega[20]);
625   sCh7->SetVertex(2,-xomega[23], yomega[23]);
626   sCh7->SetVertex(3,-xomega[22], yomega[22]);
627
628   sCh8->SetVertex(0,-xomega[ 3], yomega[ 3]);
629   sCh8->SetVertex(1,-xomega[ 2], yomega[ 2]);
630   sCh8->SetVertex(2,-xomega[ 5], yomega[ 5]);
631   sCh8->SetVertex(3,-xomega[ 4], yomega[ 4]);
632
633   sCh9->SetVertex(0,-xomega[17], yomega[17]);
634   sCh9->SetVertex(1,-xomega[16], yomega[16]);
635   sCh9->SetVertex(2,-xomega[19], yomega[19]);
636   sCh9->SetVertex(3,-xomega[18], yomega[18]);
637
638   sCh10->SetVertex(0,-xomega[ 7], yomega[ 7]);
639   sCh10->SetVertex(1,-xomega[ 6], yomega[ 6]);
640   sCh10->SetVertex(2,-xomega[ 9], yomega[ 9]);
641   sCh10->SetVertex(3,-xomega[ 8], yomega[ 8]);
642
643   sCh11->SetVertex(0,-xomega[13], yomega[13]);
644   sCh11->SetVertex(1,-xomega[12], yomega[12]);
645   sCh11->SetVertex(2,-xomega[15], yomega[15]);
646   sCh11->SetVertex(3,-xomega[14], yomega[14]);
647
648   // Bigger end: determine the coordinates of the points of carbon fiber
649
650   // Drawings give only the radius, convert it to the apothegm
651   Double_t kInnerRadiusCone = TMath::Sqrt(kInnerRadialCone*kInnerRadialCone
652                                           - 0.25*kInnerACone*kInnerACone);
653   Double_t kOuterRadiusCone = TMath::Sqrt(kOuterRadialCone*kOuterRadialCone
654                                           - 0.25*kOuterACone*kOuterACone);
655
656   CreateSPDThermalShape(kInnerACone,kInnerBCone,kInnerRadiusCone,
657                         kOuterACone,kOuterBCone,kOuterRadiusCone,
658                         kTheta,xshld,yshld);
659
660   sC1->SetVertex(4, xshld[12], yshld[12]);
661   sC1->SetVertex(5, xshld[11], yshld[11]);
662   sC1->SetVertex(6, xshld[ 0], yshld[ 0]);
663   sC1->SetVertex(7, xshld[23], yshld[23]);
664
665   sC2->SetVertex(4, xshld[11], yshld[11]);
666   sC2->SetVertex(5, xshld[10], yshld[10]);
667   sC2->SetVertex(6, xshld[ 1], yshld[ 1]);
668   sC2->SetVertex(7, xshld[ 0], yshld[ 0]);
669
670   sC3->SetVertex(4, xshld[10], yshld[10]);
671   sC3->SetVertex(5, xshld[ 9], yshld[ 9]);
672   sC3->SetVertex(6, xshld[ 2], yshld[ 2]);
673   sC3->SetVertex(7, xshld[ 1], yshld[ 1]);
674
675   sC4->SetVertex(4, xshld[ 9], yshld[ 9]);
676   sC4->SetVertex(5, xshld[ 8], yshld[ 8]);
677   sC4->SetVertex(6, xshld[ 3], yshld[ 3]);
678   sC4->SetVertex(7, xshld[ 2], yshld[ 2]);
679
680   sC5->SetVertex(4, xshld[ 8], yshld[ 8]);
681   sC5->SetVertex(5, xshld[ 7], yshld[ 7]);
682   sC5->SetVertex(6, xshld[ 4], yshld[ 4]);
683   sC5->SetVertex(7, xshld[ 3], yshld[ 3]);
684
685   sC6->SetVertex(4, xshld[ 7], yshld[ 7]);
686   sC6->SetVertex(5, xshld[ 6], yshld[ 6]);
687   sC6->SetVertex(6, xshld[ 5], yshld[ 5]);
688   sC6->SetVertex(7, xshld[ 4], yshld[ 4]);
689
690   sC7->SetVertex(4,-xshld[10], yshld[10]);
691   sC7->SetVertex(5,-xshld[11], yshld[11]);
692   sC7->SetVertex(6,-xshld[ 0], yshld[ 0]);
693   sC7->SetVertex(7,-xshld[ 1], yshld[ 1]);
694
695   sC8->SetVertex(4,-xshld[ 9], yshld[ 9]);
696   sC8->SetVertex(5,-xshld[10], yshld[10]);
697   sC8->SetVertex(6,-xshld[ 1], yshld[ 1]);
698   sC8->SetVertex(7,-xshld[ 2], yshld[ 2]);
699
700   sC9->SetVertex(4,-xshld[ 8], yshld[ 8]);
701   sC9->SetVertex(5,-xshld[ 9], yshld[ 9]);
702   sC9->SetVertex(6,-xshld[ 2], yshld[ 2]);
703   sC9->SetVertex(7,-xshld[ 3], yshld[ 3]);
704
705   sC10->SetVertex(4,-xshld[ 7], yshld[ 7]);
706   sC10->SetVertex(5,-xshld[ 8], yshld[ 8]);
707   sC10->SetVertex(6,-xshld[ 3], yshld[ 3]);
708   sC10->SetVertex(7,-xshld[ 4], yshld[ 4]);
709
710   sC11->SetVertex(4,-xshld[ 6], yshld[ 6]);
711   sC11->SetVertex(5,-xshld[ 7], yshld[ 7]);
712   sC11->SetVertex(6,-xshld[ 4], yshld[ 4]);
713   sC11->SetVertex(7,-xshld[ 5], yshld[ 5]);
714
715   // Then rescale to get the air volume dimensions
716     InsidePoint(xshld[23], yshld[23],
717                 xshld[ 0], yshld[ 0],
718                 xshld[ 1], yshld[ 1], kThicknessCone,
719                 xair[0], yair[0]);
720   for (Int_t i=1; i<23; i++) {
721     InsidePoint(xshld[i-1], yshld[i-1],
722                 xshld[ i ], yshld[ i ],
723                 xshld[i+1], yshld[i+1], kThicknessCone,
724                 xair[i], yair[i]);
725   }
726     InsidePoint(xshld[22], yshld[22],
727                 xshld[23], yshld[23],
728                 xshld[ 0], yshld[ 0], kThicknessCone,
729                 xair[23], yair[23]);
730
731   // Then use them to determine the Omega shape points
732   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
733
734   // Finally fill the big end coordinates of the air shapes
735   sCh1->SetVertex(4, xomega[ 0], yomega[ 0]);
736   sCh1->SetVertex(5, xomega[ 1], yomega[ 1]);
737   sCh1->SetVertex(6,-xomega[ 1], yomega[ 1]);
738   sCh1->SetVertex(7,-xomega[ 0], yomega[ 0]);
739
740   sCh2->SetVertex(4, xomega[20], yomega[20]);
741   sCh2->SetVertex(5, xomega[21], yomega[21]);
742   sCh2->SetVertex(6, xomega[22], yomega[22]);
743   sCh2->SetVertex(7, xomega[23], yomega[23]);
744
745   sCh3->SetVertex(4, xomega[ 2], yomega[ 2]);
746   sCh3->SetVertex(5, xomega[ 3], yomega[ 3]);
747   sCh3->SetVertex(6, xomega[ 4], yomega[ 4]);
748   sCh3->SetVertex(7, xomega[ 5], yomega[ 5]);
749
750   sCh4->SetVertex(4, xomega[16], yomega[16]);
751   sCh4->SetVertex(5, xomega[17], yomega[17]);
752   sCh4->SetVertex(6, xomega[18], yomega[18]);
753   sCh4->SetVertex(7, xomega[19], yomega[19]);
754
755   sCh5->SetVertex(4, xomega[ 6], yomega[ 6]);
756   sCh5->SetVertex(5, xomega[ 7], yomega[ 7]);
757   sCh5->SetVertex(6, xomega[ 8], yomega[ 8]);
758   sCh5->SetVertex(7, xomega[ 9], yomega[ 9]);
759
760   sCh6->SetVertex(4, xomega[12], yomega[12]);
761   sCh6->SetVertex(5, xomega[13], yomega[13]);
762   sCh6->SetVertex(6, xomega[14], yomega[14]);
763   sCh6->SetVertex(7, xomega[15], yomega[15]);
764
765   sCh7->SetVertex(4,-xomega[21], yomega[21]);
766   sCh7->SetVertex(5,-xomega[20], yomega[20]);
767   sCh7->SetVertex(6,-xomega[23], yomega[23]);
768   sCh7->SetVertex(7,-xomega[22], yomega[22]);
769
770   sCh8->SetVertex(4,-xomega[ 3], yomega[ 3]);
771   sCh8->SetVertex(5,-xomega[ 2], yomega[ 2]);
772   sCh8->SetVertex(6,-xomega[ 5], yomega[ 5]);
773   sCh8->SetVertex(7,-xomega[ 4], yomega[ 4]);
774
775   sCh9->SetVertex(4,-xomega[17], yomega[17]);
776   sCh9->SetVertex(5,-xomega[16], yomega[16]);
777   sCh9->SetVertex(6,-xomega[19], yomega[19]);
778   sCh9->SetVertex(7,-xomega[18], yomega[18]);
779
780   sCh10->SetVertex(4,-xomega[ 7], yomega[ 7]);
781   sCh10->SetVertex(5,-xomega[ 6], yomega[ 6]);
782   sCh10->SetVertex(6,-xomega[ 9], yomega[ 9]);
783   sCh10->SetVertex(7,-xomega[ 8], yomega[ 8]);
784
785   sCh11->SetVertex(4,-xomega[13], yomega[13]);
786   sCh11->SetVertex(5,-xomega[12], yomega[12]);
787   sCh11->SetVertex(6,-xomega[15], yomega[15]);
788   sCh11->SetVertex(7,-xomega[14], yomega[14]);
789
790   // Now the actual carbon fiber cone: a CompositeShape
791   TGeoCompositeShape *sCone = new TGeoCompositeShape("sCone",
792                             "sC1+sC2+sC3+sC4+sC5+sC6+sC7+sC8+sC9+sC10+sC11");
793
794   // Finally the carbon fiber Ring with its Wings and their
795   // stesalite inserts. They are Tube and TubeSeg shapes
796
797   TGeoTube *ringshape = new TGeoTube(kInnerRadiusRing,kOuterRadiusRing,
798                                      kHalfLengthRing);
799
800   TGeoTube *ringinsertshape = new TGeoTube(kInnerRadiusRing+kThicknessRing,
801                                            kOuterRadiusRing-kThicknessRing,
802                                            kHalfLengthRing-kThicknessRing);
803
804   Double_t angleWideWing, angleWideWingThickness;
805   angleWideWing = (kWideWing/kOuterRadiusWing)*TMath::RadToDeg();
806   angleWideWingThickness = (kThicknessRing/kOuterRadiusWing)*TMath::RadToDeg();
807
808   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kOuterRadiusRing,kOuterRadiusWing,
809                                            kHalfLengthRing, 0, angleWideWing);
810
811   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kOuterRadiusRing,
812              kOuterRadiusWing-kThicknessRing, kHalfLengthRing-kThicknessRing,
813              angleWideWingThickness, angleWideWing-angleWideWingThickness);
814
815
816   // We have the shapes: now create the real volumes
817
818   TGeoMedium *medSPDcf  = mgr->GetMedium("ITS_SPD shield$");
819   TGeoMedium *medSPDair = mgr->GetMedium("ITS_SPD AIR$");
820   TGeoMedium *medSPDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
821
822   TGeoVolume *centralshield = new TGeoVolume("SPDcentralshield",
823                                              centralshape,medSPDcf);
824   centralshield->SetVisibility(kTRUE);
825   centralshield->SetLineColor(7);
826   centralshield->SetLineWidth(1);
827   centralshield->SetFillColor(centralshield->GetLineColor());
828   centralshield->SetFillStyle(4090); // 90% transparent
829
830   TGeoVolume *endcapshield = new TGeoVolume("SPDendcapshield",
831                                              endcapshape,medSPDcf);
832   endcapshield->SetVisibility(kTRUE);
833   endcapshield->SetLineColor(7);
834   endcapshield->SetLineWidth(1);
835
836   TGeoVolume *endcapair1 = new TGeoVolume("SPDendcapair1shield",
837                                           endcapair1shape,medSPDair);
838   endcapair1->SetVisibility(kTRUE);
839   endcapair1->SetLineColor(5); // Yellow
840   endcapair1->SetLineWidth(1);
841   endcapair1->SetFillColor(endcapair1->GetLineColor());
842   endcapair1->SetFillStyle(4090); // 90% transparent
843
844   TGeoVolume *endcapair2 = new TGeoVolume("SPDendcapair2shield",
845                                           endcapair2shape,medSPDair);
846   endcapair2->SetVisibility(kTRUE);
847   endcapair2->SetLineColor(5); // Yellow
848   endcapair2->SetLineWidth(1);
849   endcapair2->SetFillColor(endcapair2->GetLineColor());
850   endcapair2->SetFillStyle(4090); // 90% transparent
851
852   TGeoVolume *endcapair3 = new TGeoVolume("SPDendcapair3shield",
853                                           endcapair3shape,medSPDair);
854   endcapair3->SetVisibility(kTRUE);
855   endcapair3->SetLineColor(5); // Yellow
856   endcapair3->SetLineWidth(1);
857   endcapair3->SetFillColor(endcapair3->GetLineColor());
858   endcapair3->SetFillStyle(4090); // 90% transparent
859
860   TGeoVolume *endcapair4 = new TGeoVolume("SPDendcapair4shield",
861                                           endcapair4shape,medSPDair);
862   endcapair4->SetVisibility(kTRUE);
863   endcapair4->SetLineColor(5); // Yellow
864   endcapair4->SetLineWidth(1);
865   endcapair4->SetFillColor(endcapair4->GetLineColor());
866   endcapair4->SetFillStyle(4090); // 90% transparent
867
868   TGeoVolume *endcapair5 = new TGeoVolume("SPDendcapair5shield",
869                                           endcapair5shape,medSPDair);
870   endcapair5->SetVisibility(kTRUE);
871   endcapair5->SetLineColor(5); // Yellow
872   endcapair5->SetLineWidth(1);
873   endcapair5->SetFillColor(endcapair5->GetLineColor());
874   endcapair5->SetFillStyle(4090); // 90% transparent
875
876   TGeoVolume *endcapair6 = new TGeoVolume("SPDendcapair6shield",
877                                           endcapair6shape,medSPDair);
878   endcapair6->SetVisibility(kTRUE);
879   endcapair6->SetLineColor(5); // Yellow
880   endcapair6->SetLineWidth(1);
881   endcapair6->SetFillColor(endcapair6->GetLineColor());
882   endcapair6->SetFillStyle(4090); // 90% transparent
883
884   endcapshield->AddNode(endcapair1,1,0);
885   endcapshield->AddNode(endcapair2,1,0);
886   endcapshield->AddNode(endcapair2,2,new TGeoRotation("",90,180,-90));
887   endcapshield->AddNode(endcapair3,1,0);
888   endcapshield->AddNode(endcapair3,2,new TGeoRotation("",90,180,-90));
889   endcapshield->AddNode(endcapair4,1,0);
890   endcapshield->AddNode(endcapair4,2,new TGeoRotation("",90,180,-90));
891   endcapshield->AddNode(endcapair5,1,0);
892   endcapshield->AddNode(endcapair5,2,new TGeoRotation("",90,180,-90));
893   endcapshield->AddNode(endcapair6,1,0);
894   endcapshield->AddNode(endcapair6,2,new TGeoRotation("",90,180,-90));
895
896   TGeoVolume *vCone = new TGeoVolume("SPDconeshield",sCone,medSPDcf);
897   vCone->SetVisibility(kTRUE);
898   vCone->SetLineColor(7);
899   vCone->SetLineWidth(1);
900   vCone->SetFillColor(vCone->GetLineColor());
901   vCone->SetFillStyle(4090); // 90% transparent
902
903   TGeoVolume *vCh1 = new TGeoVolume("SPDconeshieldH1",sCh1,medSPDair);
904   vCh1->SetVisibility(kTRUE);
905   vCh1->SetLineColor(5); // Yellow
906   vCh1->SetLineWidth(1);
907   vCh1->SetFillColor(vCh1->GetLineColor());
908   vCh1->SetFillStyle(4090); // 90% transparent
909
910   TGeoVolume *vCh2 = new TGeoVolume("SPDconeshieldH2",sCh2,medSPDair);
911   vCh2->SetVisibility(kTRUE);
912   vCh2->SetLineColor(5); // Yellow
913   vCh2->SetLineWidth(1);
914   vCh2->SetFillColor(vCh2->GetLineColor());
915   vCh2->SetFillStyle(4090); // 90% transparent
916
917   TGeoVolume *vCh3 = new TGeoVolume("SPDconeshieldH3",sCh3,medSPDair);
918   vCh3->SetVisibility(kTRUE);
919   vCh3->SetLineColor(5); // Yellow
920   vCh3->SetLineWidth(1);
921   vCh3->SetFillColor(vCh3->GetLineColor());
922   vCh3->SetFillStyle(4090); // 90% transparent
923
924   TGeoVolume *vCh4 = new TGeoVolume("SPDconeshieldH4",sCh4,medSPDair);
925   vCh4->SetVisibility(kTRUE);
926   vCh4->SetLineColor(5); // Yellow
927   vCh4->SetLineWidth(1);
928   vCh4->SetFillColor(vCh4->GetLineColor());
929   vCh4->SetFillStyle(4090); // 90% transparent
930
931   TGeoVolume *vCh5 = new TGeoVolume("SPDconeshieldH5",sCh5,medSPDair);
932   vCh5->SetVisibility(kTRUE);
933   vCh5->SetLineColor(5); // Yellow
934   vCh5->SetLineWidth(1);
935   vCh5->SetFillColor(vCh5->GetLineColor());
936   vCh5->SetFillStyle(4090); // 90% transparent
937
938   TGeoVolume *vCh6 = new TGeoVolume("SPDconeshieldH6",sCh6,medSPDair);
939   vCh6->SetVisibility(kTRUE);
940   vCh6->SetLineColor(5); // Yellow
941   vCh6->SetLineWidth(1);
942   vCh6->SetFillColor(vCh6->GetLineColor());
943   vCh6->SetFillStyle(4090); // 90% transparent
944
945   TGeoVolume *vCh7 = new TGeoVolume("SPDconeshieldH7",sCh7,medSPDair);
946   vCh7->SetVisibility(kTRUE);
947   vCh7->SetLineColor(5); // Yellow
948   vCh7->SetLineWidth(1);
949   vCh7->SetFillColor(vCh7->GetLineColor());
950   vCh7->SetFillStyle(4090); // 90% transparent
951
952   TGeoVolume *vCh8 = new TGeoVolume("SPDconeshieldH8",sCh8,medSPDair);
953   vCh8->SetVisibility(kTRUE);
954   vCh8->SetLineColor(5); // Yellow
955   vCh8->SetLineWidth(1);
956   vCh8->SetFillColor(vCh8->GetLineColor());
957   vCh8->SetFillStyle(4090); // 90% transparent
958
959   TGeoVolume *vCh9 = new TGeoVolume("SPDconeshieldH9",sCh9,medSPDair);
960   vCh9->SetVisibility(kTRUE);
961   vCh9->SetLineColor(5); // Yellow
962   vCh9->SetLineWidth(1);
963   vCh9->SetFillColor(vCh9->GetLineColor());
964   vCh9->SetFillStyle(4090); // 90% transparent
965
966   TGeoVolume *vCh10 = new TGeoVolume("SPDconeshieldH10",sCh10,medSPDair);
967   vCh10->SetVisibility(kTRUE);
968   vCh10->SetLineColor(5); // Yellow
969   vCh10->SetLineWidth(1);
970   vCh10->SetFillColor(vCh10->GetLineColor());
971   vCh10->SetFillStyle(4090); // 90% transparent
972
973   TGeoVolume *vCh11 = new TGeoVolume("SPDconeshieldH11",sCh11,medSPDair);
974   vCh11->SetVisibility(kTRUE);
975   vCh11->SetLineColor(5); // Yellow
976   vCh11->SetLineWidth(1);
977   vCh11->SetFillColor(vCh11->GetLineColor());
978   vCh11->SetFillStyle(4090); // 90% transparent
979
980   vCone->AddNode(vCh1 ,1,0);
981   vCone->AddNode(vCh2 ,1,0);
982   vCone->AddNode(vCh3 ,1,0);
983   vCone->AddNode(vCh4 ,1,0);
984   vCone->AddNode(vCh5 ,1,0);
985   vCone->AddNode(vCh6 ,1,0);
986   vCone->AddNode(vCh7 ,1,0);
987   vCone->AddNode(vCh8 ,1,0);
988   vCone->AddNode(vCh9 ,1,0);
989   vCone->AddNode(vCh10,1,0);
990   vCone->AddNode(vCh11,1,0);
991
992   TGeoVolume *ring = new TGeoVolume("SPDshieldring",ringshape,medSPDcf);
993   ring->SetVisibility(kTRUE);
994   ring->SetLineColor(7);
995   ring->SetLineWidth(1);
996
997   TGeoVolume *ringinsert = new TGeoVolume("SPDshieldringinsert",
998                                           ringinsertshape,medSPDste);
999   ringinsert->SetVisibility(kTRUE);
1000   ringinsert->SetLineColor(3); // Green
1001 //  ringinsert->SetLineWidth(1);
1002   ringinsert->SetFillColor(ringinsert->GetLineColor());
1003   ringinsert->SetFillStyle(4010); // 10% transparent
1004
1005   ring->AddNode(ringinsert,1,0);
1006
1007   TGeoVolume *wing = new TGeoVolume("SPDshieldringwing",wingshape,medSPDcf);
1008   wing->SetVisibility(kTRUE);
1009   wing->SetLineColor(7);
1010   wing->SetLineWidth(1);
1011
1012   TGeoVolume *winginsert = new TGeoVolume("SPDshieldwinginsert",
1013                                           winginsertshape,medSPDste);
1014   winginsert->SetVisibility(kTRUE);
1015   winginsert->SetLineColor(3); // Green
1016 //  winginsert->SetLineWidth(1);
1017   winginsert->SetFillColor(winginsert->GetLineColor());
1018   winginsert->SetFillStyle(4010); // 10% transparent
1019
1020   wing->AddNode(winginsert,1,0);
1021
1022
1023   // Add all volumes in the assembly
1024   const Double_t kLittleZTrans = 0.1*fgkmm;
1025   vM->AddNode(centralshield,1,new TGeoTranslation(0,0,-kLittleZTrans));
1026   vM->AddNode(centralshield,2,new TGeoCombiTrans( 0,0,-kLittleZTrans,
1027                                   new TGeoRotation("",180,0,0)));
1028
1029   zpos = kHalfLengthCentral+kHalfLengthEndCap;
1030   vM->AddNode(endcapshield,1,
1031               new TGeoTranslation(0,0, zpos-kLittleZTrans));
1032   vM->AddNode(endcapshield,2,
1033               new TGeoTranslation(0,0,-zpos-kLittleZTrans));
1034   vM->AddNode(endcapshield,3,new TGeoCombiTrans(
1035               0, 0, zpos-kLittleZTrans, new TGeoRotation("",180,0,0) ) );
1036   vM->AddNode(endcapshield,4,new TGeoCombiTrans(
1037               0, 0,-zpos-kLittleZTrans, new TGeoRotation("",180,0,0) ) );
1038
1039   zpos = kHalfLengthCentral+2*kHalfLengthEndCap+kHalfLengthCone;
1040   vM->AddNode(vCone ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1041
1042   vM->AddNode(vCone ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1043                                 new TGeoRotation("", 0, 0, 180)   ));
1044
1045   vM->AddNode(vCone ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1046                                 new TGeoRotation("", 0, 180, 0)   ));
1047
1048   vM->AddNode(vCone ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1049                                 new TGeoRotation("", 0, 180, 180)   ));
1050
1051   zpos = kHalfLengthCentral+2*kHalfLengthEndCap+2*kHalfLengthCone
1052        + kHalfLengthRing;
1053   vM->AddNode(ring,1,new TGeoTranslation(0, 0, zpos-kLittleZTrans));
1054   vM->AddNode(ring,2,new TGeoTranslation(0, 0,-zpos-kLittleZTrans));
1055
1056   for (Int_t i=0; i<4; i++) {
1057     Double_t thetaW = kThetaWing*(2*i+1) - angleWideWing/2.;
1058     vM->AddNode(wing,2*i+1,new TGeoCombiTrans(0, 0, zpos-kLittleZTrans,
1059                                new TGeoRotation("",thetaW,0,0) ) );
1060     vM->AddNode(wing,2*i+2,new TGeoCombiTrans(0, 0,-zpos-kLittleZTrans,
1061                                new TGeoRotation("",thetaW,0,0) ) );
1062   }
1063
1064   // Some debugging if requested
1065   if(GetDebug(1)){
1066     vM->PrintNodes();
1067     vM->InspectShape();
1068   }
1069
1070   // Finally put the entire shield in the mother volume
1071   moth->AddNode(vM,1,0);
1072
1073   return;
1074 }
1075
1076 //______________________________________________________________________
1077 void AliITSv11GeometrySupport::CreateSPDThermalShape(
1078      Double_t ina, Double_t inb, Double_t inr,
1079      Double_t oua, Double_t oub, Double_t our,
1080      Double_t   t, Double_t *x , Double_t *y ) const
1081 {
1082 //
1083 // Creates the proper sequence of X and Y coordinates to determine
1084 // the base XTru polygon for the SPD thermal shapes
1085 //
1086 // Input:
1087 //        ina, inb : inner shape sides
1088 //        inr      : inner radius
1089 //        oua, oub : outer shape sides
1090 //        our      : outer radius
1091 //        t        : theta angle
1092 //
1093 // Output:
1094 //        x, y : coordinate vectors [24]
1095 //
1096 // Created:      14 Nov 2007  Mario Sitta
1097 // Updated:      11 Dec 2007  Mario Sitta
1098 //
1099   Double_t xlocal[6],ylocal[6];
1100
1101   //Create the first inner quadrant (X > 0)
1102   FillSPDXtruShape(ina,inb,inr,t,xlocal,ylocal);
1103   for (Int_t i=0; i<6; i++) {
1104     x[i] = xlocal[i];
1105     y[i] = ylocal[i];
1106   }
1107
1108   // Then reflex on the second quadrant (X < 0)
1109   for (Int_t i=0; i<6; i++) {
1110     x[23-i] = -x[i];
1111     y[23-i] =  y[i];
1112   }
1113
1114   // Now create the first outer quadrant (X > 0)
1115   FillSPDXtruShape(oua,oub,our,t,xlocal,ylocal);
1116   for (Int_t i=0; i<6; i++) {
1117     x[11-i] = xlocal[i];
1118     y[11-i] = ylocal[i];
1119   }
1120
1121   // Finally reflex on the second quadrant (X < 0)
1122   for (Int_t i=0; i<6; i++) {
1123     x[12+i] = -x[11-i];
1124     y[12+i] =  y[11-i];
1125   }
1126
1127   return;
1128 }
1129
1130 //______________________________________________________________________
1131 void AliITSv11GeometrySupport::CreateSPDOmegaShape(
1132                    const Double_t *xin, const Double_t *yin, Double_t  d,
1133                    Double_t   *x, Double_t *y)
1134 {
1135 //
1136 // Creates the proper sequence of X and Y coordinates to determine
1137 // the SPD Omega XTru polygon
1138 //
1139 // Input:
1140 //        xin, yin : coordinates of the air volume
1141 //        d        : Omega shape thickness
1142 //        t        : theta angle
1143 //
1144 // Output:
1145 //        x, y     : coordinate vectors [48]
1146 //
1147 // Created:      17 Nov 2007  Mario Sitta
1148 // Updated:      11 Dec 2007  Mario Sitta
1149 // Updated:      20 Feb 2009  Mario Sitta       New algorithm (the old one
1150 //                                              gives erroneous vertexes)
1151 //
1152
1153   // This vector contains the index of those points which coincide
1154   // with the corresponding points in the air shape
1155   Int_t indexAir2Omega[12] = {1, 2, 5, 6, 9, 10, 11, 15, 16, 19, 20, 23};
1156
1157   // First fill those vertexes corresponding to
1158   // the edges aligned to the air shape edges
1159   for (Int_t j=0; j<12; j++) {
1160     x[*(indexAir2Omega+j)] = xin[j];
1161     y[*(indexAir2Omega+j)] = yin[j];
1162   }
1163
1164   // Now get the coordinates of the first inner point
1165   PointFromParallelLines(x[23],y[23],x[1],y[1],d,x[0],y[0]);
1166
1167   // Knowing this, the second internal point can be determined
1168   InsidePoint(x[0],y[0],x[1],y[1],x[2],y[2],d,x[22],y[22]);
1169
1170   // The third point is now computable
1171   ReflectPoint(x[1],y[1],x[2],y[2],x[22],y[22],x[21],y[21]);
1172
1173   // Repeat this logic
1174   InsidePoint(x[21],y[21],x[20],y[20],x[19],y[19],-d,x[3],y[3]);
1175
1176   ReflectPoint(x[20],y[20],x[19],y[19],x[3],y[3],x[4],y[4]);
1177
1178   InsidePoint(x[4],y[4],x[5],y[5],x[6],y[6],d,x[18],y[18]);
1179
1180   ReflectPoint(x[5],y[5],x[6],y[6],x[18],y[18],x[17],y[17]);
1181
1182   InsidePoint(x[17],y[17],x[16],y[16],x[15],y[15],-d,x[7],y[7]);
1183
1184   ReflectPoint(x[16],y[16],x[15],y[15],x[7],y[7],x[8],y[8]);
1185
1186   InsidePoint(x[8],y[8],x[9],y[9],x[10],y[10],d,x[14],y[14]);
1187
1188   // These need to be fixed explicitly
1189   x[12] = x[11];
1190   y[12] = y[11] + d;
1191   x[13] = x[10] + d;
1192   y[13] = y[12];
1193
1194   // Finally reflect on the negative side
1195   for (Int_t i=0; i<24; i++) {
1196     x[24+i] = -x[23-i];
1197     y[24+i] =  y[23-i];
1198   }
1199
1200   // Wow ! We've finished
1201   return;
1202 }
1203
1204 //______________________________________________________________________
1205 void AliITSv11GeometrySupport::FillSPDXtruShape(Double_t a, Double_t b,
1206                                                 Double_t r, Double_t t,
1207                                                 Double_t *x, Double_t *y) const
1208 {
1209 //
1210 // Creates the partial sequence of X and Y coordinates to determine
1211 // the lateral part of the SPD thermal shield
1212 //
1213 // Input:
1214 //        a, b : shape sides
1215 //        r    : radius
1216 //        t    : theta angle
1217 //
1218 // Output:
1219 //        x, y : coordinate vectors [6]
1220 //
1221 // Created:      14 Nov 2007  Mario Sitta
1222 //
1223   x[0] = a/2;
1224   y[0] = r;
1225
1226   x[1] = x[0] + b * TMath::Cos(t/2);
1227   y[1] = y[0] - b * TMath::Sin(t/2);
1228
1229   x[2] = x[1] + a * TMath::Cos(t);
1230   y[2] = y[1] - a * TMath::Sin(t);
1231
1232   x[3] = x[2] + b * TMath::Cos(3*t/2);
1233   y[3] = y[2] - b * TMath::Sin(3*t/2);
1234
1235   x[4] = x[3] + a * TMath::Cos(2*t);
1236   y[4] = y[3] - a * TMath::Sin(2*t);
1237
1238   x[5] = x[4];
1239   y[5] = 0.;
1240
1241   return;
1242 }
1243
1244 //______________________________________________________________________
1245 void AliITSv11GeometrySupport::PointFromParallelLines(Double_t x1, Double_t y1,
1246                               Double_t x2, Double_t y2, Double_t d,
1247                               Double_t &x, Double_t &y) const
1248 {
1249 //
1250 // Determines the X and Y of the first internal point of the Omega shape
1251 // (i.e. the coordinates of a point given two parallel lines passing by
1252 // two points and placed at a known distance)
1253 //
1254 // Input:
1255 //        x1, y1 : first point
1256 //        x2, y2 : second point
1257 //        d      : distance between the two lines
1258 //
1259 // Output:
1260 //        x, y   : coordinate of the point
1261 //
1262 // Created:      22 Feb 2009  Mario Sitta
1263 //
1264 //Begin_Html
1265 /*
1266 <img src="ITS/doc/PointFromParallelLines.gif">
1267 */
1268 //End_Html
1269
1270   // The slope of the paralles lines at a distance d
1271   Double_t m; 
1272
1273   // The parameters of the solving equation
1274   // a x^2 - 2 b x + c = 0
1275   Double_t a = (x1 - x2)*(x1 - x2) - d*d;
1276   Double_t b = (x1 - x2)*(y1 - y2);
1277   Double_t c = (y1 - y2)*(y1 - y2) - d*d;
1278
1279   // (delta4 is Delta/4 because we use the reduced formula)
1280   Double_t delta4 = b*b - a*c;
1281
1282   // Compute the slope of the two parallel lines
1283   // (one of the two possible slopes, the one with the smaller
1284   // absolute value is needed)
1285   if (delta4 < 0) { // Should never happen with our data, but just to be sure
1286     x = -1;         // x is expected positive, so this flags an error
1287     return;
1288   } else
1289     m = (b + TMath::Sqrt(delta4))/a;  // b is negative with our data
1290
1291   // Finally compute the coordinates of the point
1292   x = x2 + (y1 - y2 - d)/m;
1293   y = y1 - d;
1294
1295   // Done
1296   return;
1297 }
1298
1299 //______________________________________________________________________
1300 void AliITSv11GeometrySupport::ReflectPoint(Double_t x1, Double_t y1,
1301                                             Double_t x2, Double_t y2,
1302                                             Double_t x3, Double_t y3,
1303                                             Double_t &x, Double_t &y) const
1304 {
1305 //
1306 // Given two points (x1,y1) and (x2,y2), determines the point (x,y)
1307 // lying on the line parallel to the line passing by these points,
1308 // at a distance d and passing by the point (x3,y3), which is symmetric to
1309 // the third point with respect to the axis of the segment delimited by
1310 // the two first points.
1311 //
1312 // Input:
1313 //        x1, y1 : first point
1314 //        x2, y2 : second point
1315 //        x3, y3 : third point
1316 //        d      : distance between the two lines
1317 //
1318 // Output:
1319 //        x, y   : coordinate of the reflected point
1320 //
1321 // Created:      22 Feb 2009  Mario Sitta
1322 //
1323 //Begin_Html
1324 /*
1325 <img src="ITS/doc/ReflectPoint.gif">
1326 */
1327 //End_Html
1328
1329   // The slope of the line passing by the first two points
1330   Double_t k = (y2 - y1)/(x2 - x1);
1331
1332   // The middle point of the segment 1-2
1333   Double_t xK = (x1 + x2)/2.;
1334   Double_t yK = (y1 + y2)/2.;
1335
1336   // The intercept between the axis of the segment 1-2 and the line
1337   // passing by 3 and parallel to the line passing by 1-2
1338   Double_t xH = (k*k*x3 + k*(yK - y3) + xK)/(k*k + 1);
1339   Double_t yH = k*(xH - x3) + y3;
1340
1341   // The point symmetric to 3 with respect to H
1342   x = 2*xH - x3;
1343   y = 2*yH - y3;
1344
1345   // Done
1346   return;
1347 }
1348
1349 //______________________________________________________________________
1350 void AliITSv11GeometrySupport::SDDCone(TGeoVolume *moth,const TGeoManager *mgr)
1351 {
1352 //
1353 // Creates the SDD support cone and cylinder geometry as a
1354 // volume assembly and adds it to the mother volume
1355 // (part of this code is taken or anyway inspired to SDDCone method
1356 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
1357 //
1358 // Input:
1359 //         moth : the TGeoVolume owing the volume structure
1360 //         mgr  : the GeoManager (default gGeoManager)
1361 // Output:
1362 //
1363 // Created:         ???       Bjorn S. Nilsen
1364 // Updated:      18 Feb 2008  Mario Sitta
1365 // Updated:      25 Jul 2008  Mario Sitta   SDDCarbonFiberCone simpler
1366 // Updated:      10 Jun 2010  Mario Sitta   Cables across cone holes added
1367 //
1368 // Technical data are taken from:  "Supporto Generale Settore SDD"
1369 // (technical drawings ALR-0816/1-B), "Supporto Globale Settore SDD"
1370 // (technical drawings ALR-0816/2A, ALR-0816/2B, ALR-0816/2C, ALR-0816/2D), 
1371 // private communication with B. Giraudo
1372
1373   // Dimensions of the Central cylinder and flanges
1374   const Double_t kCylinderHalfLength = (790.0/2)*fgkmm;
1375   const Double_t kCylinderInnerR     = (210.0/2)*fgkmm;
1376   const Double_t kCylinderOuterR     = (231.0/2)*fgkmm;
1377   const Double_t kFlangeHalfLength   = ( 15.0/2)*fgkmm;
1378   const Double_t kFlangeInnerR       = (210.5/2)*fgkmm;
1379   const Double_t kFlangeOuterR       = (230.5/2)*fgkmm;
1380   const Double_t kInsertoHalfLength  =
1381                                      kCylinderHalfLength - 2*kFlangeHalfLength;
1382 //  const Double_t kCFThickness        = kFlangeInnerR - kCylinderInnerR;
1383   const Double_t kBoltDiameter       =       6.0*fgkmm; // M6 screw
1384   const Double_t kBoltDepth          =       6.0*fgkmm; // In the flange
1385   const Double_t kBoltRadius         = (220.0/2)*fgkmm; // Radius in flange
1386   const Double_t kThetaBolt          =      30.0*fgkDegree;
1387   const Int_t    kNBolts             = (Int_t)(360.0/kThetaBolt);
1388   // Dimensions of the Cone
1389   const Double_t kConeROutMin        = (540.0/2)*fgkmm;
1390   const Double_t kConeROutMax        = (560.0/2)*fgkmm;
1391   const Double_t kConeRCurv          =      10.0*fgkmm; // Radius of curvature
1392   const Double_t kConeRinMin         = (210.0/2)*fgkmm;
1393 //  const Double_t kConeRinMax         = (216.0/2)*fgkmm;
1394   const Double_t kConeRinCylinder    = (231.0/2)*fgkmm;
1395   const Double_t kConeZCylinder      =     192.0*fgkmm;
1396   const Double_t kConeZOuterMilled   =      23.0*fgkmm;
1397   const Double_t kConeDZin           =      15.0*fgkmm; // ???
1398   const Double_t kConeThickness      =      10.0*fgkmm; // Rohacell + Carb.Fib.
1399   const Double_t kConeTheta          =      45.0*fgkDegree; // SDD cone angle
1400   const Double_t kSinConeTheta       =
1401                                      TMath::Sin(kConeTheta*TMath::DegToRad());
1402   const Double_t kCosConeTheta       =
1403                                      TMath::Cos(kConeTheta*TMath::DegToRad());
1404   const Double_t kTanConeTheta       =
1405                                      TMath::Tan(kConeTheta*TMath::DegToRad());
1406   // Dimensions of the Cone Inserts
1407   const Double_t kConeCFThickness    =       1.5*fgkmm;//Carbon fiber thickness
1408   // Dimensions of the Cone Holes
1409   const Double_t kHole1RMin          = (450.0/2)*fgkmm;
1410   const Double_t kHole1RMax          = (530.0/2)*fgkmm;
1411   const Double_t kHole2RMin          = (280.0/2)*fgkmm;
1412   const Double_t kHole2RMax          = (375.0/2)*fgkmm;
1413   const Double_t kHole1Phi           =      25.0*fgkDegree;
1414   const Double_t kHole2Phi           =      50.0*fgkDegree;
1415   const Double_t kHole3RMin          =     205.0*fgkmm;
1416   const Double_t kHole3DeltaR        =        15*fgkmm;
1417   const Double_t kHole3Width         =        30*fgkmm;
1418   const Int_t    kNHole3             =         6      ;
1419   const Double_t kHole4RMin          =     116.0*fgkmm;
1420   const Double_t kHole4DeltaR        =        15*fgkmm;
1421   const Double_t kHole4Width         =        30*fgkmm;
1422   //  const Int_t    kNHole4             =         3      ;
1423   // Fraction of materials in holes
1424   const Double_t kHolePlasticFrac    =       0.55846;
1425   const Double_t kHoleCuFrac         =       0.06319;
1426   const Double_t kHoleGlassFrac      =       0.02652;
1427
1428   // Local variables
1429   Double_t x, y, z, t, dza, rmin, rmax;
1430
1431
1432   // Recover the needed materials
1433   TGeoMedium *medSDDcf    = mgr->GetMedium("ITS_SDD C (M55J)$");
1434   TGeoMedium *medSDDair   = mgr->GetMedium("ITS_SDD AIR$");
1435   TGeoMedium *medSDDste   = mgr->GetMedium("ITS_G10FR4$"); // stesalite
1436   TGeoMedium *medSDDroh   = mgr->GetMedium("ITS_ROHACELL$");
1437   TGeoMedium *medSDDss    = mgr->GetMedium("ITS_INOX$");
1438   TGeoMedium *medSDDplast = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
1439   TGeoMedium *medSDDCu    = mgr->GetMedium("ITS_COPPER$");
1440   TGeoMedium *medSDDglass = mgr->GetMedium("ITS_SDD OPTICFIB$");
1441
1442   // First define the geometrical shapes
1443
1444   // Central cylinder with its internal foam and the lateral flanges:
1445   // a carbon fiber Tube which contains a rohacell Tube and two
1446   // stesalite Tube's
1447   TGeoTube *cylindershape = new TGeoTube(kCylinderInnerR,kCylinderOuterR,
1448                                          kCylinderHalfLength);
1449
1450   TGeoTube *insertoshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
1451                                         kInsertoHalfLength);
1452
1453   TGeoTube *flangeshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
1454                                        kFlangeHalfLength);
1455
1456   // The flange bolt: it is a Tube
1457   TGeoTube *boltshape = new TGeoTube(0.0, 0.5*kBoltDiameter, 0.5*kBoltDepth);
1458
1459   // Debug if requested
1460   if (GetDebug(1)) {
1461     cylindershape->InspectShape();
1462     insertoshape->InspectShape();
1463     flangeshape->InspectShape();
1464     boltshape->InspectShape();
1465   }
1466
1467
1468   // We have the shapes: now create the real volumes
1469
1470   TGeoVolume *cfcylinder = new TGeoVolume("SDDCarbonFiberCylinder",
1471                                           cylindershape,medSDDcf);
1472   cfcylinder->SetVisibility(kTRUE);
1473   cfcylinder->SetLineColor(4); // Blue
1474   cfcylinder->SetLineWidth(1);
1475   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
1476   cfcylinder->SetFillStyle(4000); // 0% transparent
1477
1478   TGeoVolume *foamcylinder = new TGeoVolume("SDDFoamCylinder",
1479                                             insertoshape,medSDDroh);
1480   foamcylinder->SetVisibility(kTRUE);
1481   foamcylinder->SetLineColor(3); // Green
1482   foamcylinder->SetLineWidth(1);
1483   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
1484   foamcylinder->SetFillStyle(4050); // 50% transparent
1485
1486   TGeoVolume *flangecylinder = new TGeoVolume("SDDFlangeCylinder",
1487                                               flangeshape,medSDDste);
1488   flangecylinder->SetVisibility(kTRUE);
1489   flangecylinder->SetLineColor(2); // Red
1490   flangecylinder->SetLineWidth(1);
1491   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
1492   flangecylinder->SetFillStyle(4050); // 50% transparent
1493
1494   TGeoVolume *bolt = new TGeoVolume("SDDFlangeBolt",boltshape,medSDDss);
1495   bolt->SetVisibility(kTRUE);
1496   bolt->SetLineColor(1);  // Black
1497   bolt->SetLineWidth(1);
1498   bolt->SetFillColor(bolt->GetLineColor());
1499   bolt->SetFillStyle(4050); // 50% transparent
1500
1501   // Mount up the cylinder
1502   for(Int_t i=0; i<kNBolts; i++){
1503     t = kThetaBolt*i;
1504     x = kBoltRadius*CosD(t);
1505     y = kBoltRadius*SinD(t);
1506     z = kFlangeHalfLength-kBoltDepth;
1507     flangecylinder->AddNode(bolt, i+1, new TGeoTranslation("",x,y,z));
1508   }
1509
1510   cfcylinder->AddNode(foamcylinder,1,0);
1511   cfcylinder->AddNode(flangecylinder,1,
1512               new TGeoTranslation(0, 0, kInsertoHalfLength+kFlangeHalfLength));
1513   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
1514               0, 0, -kInsertoHalfLength-kFlangeHalfLength,
1515               new TGeoRotation("",0,180,0)     ) );
1516
1517
1518   // SDD Support Cone with its internal inserts: a carbon fiber Pcon
1519   // with holes which contains a stesalite Pcon which on turn contains a
1520   // rohacell Pcon
1521
1522   dza = kConeThickness/kSinConeTheta-(kConeROutMax-kConeROutMin)/kTanConeTheta;
1523
1524   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 10);
1525
1526   coneshape->Z(0)     = 0.0;
1527   coneshape->Rmin(0)  = kConeROutMin;
1528   coneshape->Rmax(0)  = kConeROutMax;
1529
1530   coneshape->Z(1)     = kConeZOuterMilled - dza;
1531   coneshape->Rmin(1)  = coneshape->GetRmin(0);
1532   coneshape->Rmax(1)  = coneshape->GetRmax(0);
1533
1534   coneshape->Z(2)     = kConeZOuterMilled;
1535   coneshape->Rmax(2)  = coneshape->GetRmax(0);
1536
1537   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(1),
1538                     coneshape->GetRmin(1),kConeTheta,z,rmin);
1539   coneshape->Z(3)     = z;
1540   coneshape->Rmin(3)  = rmin;
1541
1542   coneshape->Rmin(2)  = RminFrom2Points(coneshape,3,1,coneshape->GetZ(2));
1543
1544   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(2),
1545                     coneshape->GetRmax(2),kConeTheta,z,rmax);
1546   coneshape->Z(4)     = z;
1547   coneshape->Rmax(4)  = rmax;
1548   coneshape->Rmin(4)  = RminFromZpCone(coneshape,3,kConeTheta,
1549                                        coneshape->GetZ(4),0.0);
1550
1551   coneshape->Rmax(3)  = RmaxFrom2Points(coneshape,4,2,coneshape->GetZ(3));
1552
1553   coneshape->Z(6)     = kConeZCylinder - kConeDZin;
1554
1555   RadiusOfCurvature(kConeRCurv,90.0,coneshape->GetZ(6),0.0,
1556                     90.0-kConeTheta,z,rmin);
1557   coneshape->Z(5)     = z;
1558   coneshape->Rmin(5)  = RminFromZpCone(coneshape,3,kConeTheta,z);
1559   coneshape->Rmax(5)  = RmaxFromZpCone(coneshape,4,kConeTheta,z);
1560
1561   RadiusOfCurvature(kConeRCurv,90.-kConeTheta,
1562                     0.0,coneshape->Rmin(5),90.0,z,rmin);
1563   coneshape->Rmin(6)  = rmin;
1564   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,4,kConeTheta,
1565                                        coneshape->GetZ(6));
1566
1567   coneshape->Z(7)     = coneshape->GetZ(6);
1568   coneshape->Rmin(7)  = kConeRinMin;
1569   coneshape->Rmax(7)  = coneshape->GetRmax(6);
1570
1571   coneshape->Rmin(8)  = kConeRinMin;
1572
1573   RadiusOfCurvature(kConeRCurv,90.0,kConeZCylinder,kConeRinCylinder,
1574                     90.0-kConeTheta,z,rmax);
1575   coneshape->Z(8)     = z;
1576   coneshape->Rmax(8)  = rmax;
1577
1578   coneshape->Z(9)     = kConeZCylinder;
1579   coneshape->Rmin(9)  = kConeRinMin;
1580   coneshape->Rmax(9)  = kConeRinCylinder;
1581
1582
1583   // SDD Cone Insert: another Pcon
1584   Double_t x0, y0, x1, y1, x2, y2;
1585   TGeoPcon *coneinsertshape = new TGeoPcon(0.0, 360.0, 9);
1586
1587   coneinsertshape->Z(0)    = coneshape->GetZ(0) + kConeCFThickness;
1588   coneinsertshape->Rmin(0) = coneshape->GetRmin(0) + kConeCFThickness;
1589   coneinsertshape->Rmax(0) = coneshape->GetRmax(0) - kConeCFThickness;
1590
1591   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1592   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1593   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1594   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1595   coneinsertshape->Z(1)    = z;
1596   coneinsertshape->Rmin(1) = rmin;
1597   coneinsertshape->Rmax(1) = coneinsertshape->GetRmax(0);
1598
1599   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmax(1);
1600   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmax(2);
1601   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmax(3);
1602   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1603   coneinsertshape->Z(2)    = z;
1604   coneinsertshape->Rmax(2) = rmax;
1605
1606   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1607   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1608   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1609   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1610   coneinsertshape->Z(3)    = z;
1611   coneinsertshape->Rmin(3) = rmin;
1612
1613   x0 = coneinsertshape->GetZ(1); y0 = coneinsertshape->GetRmin(1);
1614   x1 = coneinsertshape->GetZ(3); y1 = coneinsertshape->GetRmin(3);
1615   coneinsertshape->Rmin(2) = Yfrom2Points(x0, y0, x1, y1,
1616                                           coneinsertshape->Z(2));
1617
1618   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
1619   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
1620   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
1621   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1622   coneinsertshape->Z(4)    = z;
1623   coneinsertshape->Rmax(4) = rmax;
1624
1625   x0 = coneinsertshape->GetZ(2); y0 = coneinsertshape->GetRmax(2);
1626   x1 = coneinsertshape->GetZ(4); y1 = coneinsertshape->GetRmax(4);
1627   coneinsertshape->Rmax(3) = Yfrom2Points(x0, y0, x1, y1,
1628                                           coneinsertshape->Z(3));
1629
1630   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmin(4);
1631   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmin(5);
1632   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmin(6);
1633   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1634   coneinsertshape->Z(5)    = z;
1635   coneinsertshape->Rmin(5) = rmin;
1636   coneinsertshape->Rmax(5) = coneinsertshape->GetRmax(4) -
1637           kTanConeTheta*(coneinsertshape->GetZ(5) - coneinsertshape->GetZ(4));
1638
1639   x0 = coneinsertshape->GetZ(3); y0 = coneinsertshape->GetRmin(3);
1640   x1 = coneinsertshape->GetZ(5); y1 = coneinsertshape->GetRmin(5);
1641   coneinsertshape->Rmin(4) = Yfrom2Points(x0, y0, x1, y1,
1642                                           coneinsertshape->Z(4));
1643
1644   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmin(5);
1645   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmin(6);
1646   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmin(7);
1647   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1648   coneinsertshape->Z(6)    = z;
1649   coneinsertshape->Rmin(6) = rmin;
1650   coneinsertshape->Rmax(6) = coneinsertshape->GetRmax(4) -
1651           kTanConeTheta*(coneinsertshape->GetZ(6) - coneinsertshape->GetZ(4));
1652
1653   coneinsertshape->Z(7)    = coneinsertshape->GetZ(6);
1654   coneinsertshape->Rmin(7) = coneshape->GetRmin(7) + kConeCFThickness;
1655   coneinsertshape->Rmax(7) = coneinsertshape->GetRmax(6);
1656
1657   coneinsertshape->Z(8)    = coneshape->GetZ(9) - kConeCFThickness;
1658   coneinsertshape->Rmin(8) = coneinsertshape->GetRmin(7);
1659   coneinsertshape->Rmax(8) = coneinsertshape->GetRmax(4) -
1660           kTanConeTheta*(coneinsertshape->GetZ(8) - coneinsertshape->GetZ(4));
1661
1662   // SDD Cone Foam: another Pcon
1663   TGeoPcon *conefoamshape = new TGeoPcon(0.0, 360.0, 4);
1664
1665   RadiusOfCurvature(kConeRCurv+kConeCFThickness,0.0,coneinsertshape->GetZ(1),
1666                     coneinsertshape->GetRmin(1),kConeTheta,z,rmin);
1667
1668   conefoamshape->Z(0)    = z;
1669   conefoamshape->Rmin(0) = rmin;
1670   conefoamshape->Rmax(0) = conefoamshape->GetRmin(0);
1671
1672   conefoamshape->Z(1)    = conefoamshape->GetZ(0)+
1673                          (kConeThickness-2.0*kConeCFThickness)/kSinConeTheta;
1674   conefoamshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1675                                           conefoamshape->GetZ(1));
1676   conefoamshape->Rmax(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1677                                           conefoamshape->GetZ(1));
1678
1679   conefoamshape->Z(2)    = coneshape->GetZ(5)-kConeCFThickness;
1680   conefoamshape->Rmin(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1681                                           conefoamshape->GetZ(2));
1682   conefoamshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1683                                           conefoamshape->GetZ(2));
1684
1685   conefoamshape->Z(3)    = coneinsertshape->GetZ(5)+
1686                          (kConeThickness-2.0*kConeCFThickness)*kCosConeTheta;
1687   conefoamshape->Rmax(3) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1688                                           conefoamshape->GetZ(3));
1689   conefoamshape->Rmin(3) = conefoamshape->GetRmax(3);
1690
1691   // SDD Cone Holes: Pcon's
1692   // A single hole volume gives an overlap with coneinsert, so
1693   // three contiguous volumes are created: one to be put in the cone foam
1694   // and two in the cone carbon fiber envelope
1695   TGeoPcon *hole1shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1696
1697   hole1shape->Rmin(0) = kHole1RMax;
1698   hole1shape->Rmax(0) = hole1shape->GetRmin(0);
1699   hole1shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1700                                        hole1shape->GetRmin(0));
1701
1702   hole1shape->Rmax(1) = hole1shape->GetRmax(0);
1703   hole1shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1704                                        hole1shape->GetRmax(1));
1705   hole1shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1706                                        hole1shape->GetZ(1));
1707
1708   hole1shape->Rmin(2) = kHole1RMin;
1709   hole1shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1710                                        hole1shape->GetRmin(2));
1711   hole1shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1712                                        hole1shape->GetZ(2));
1713
1714   hole1shape->Rmin(3) = hole1shape->GetRmin(2);
1715   hole1shape->Rmax(3) = hole1shape->GetRmin(3);
1716   hole1shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1717                                        hole1shape->GetRmax(3));
1718
1719   TGeoPcon *hole11shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1720
1721   hole11shape->Rmin(0) = kHole1RMax;
1722   hole11shape->Rmax(0) = hole11shape->GetRmin(0);
1723   hole11shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1724                                         hole11shape->GetRmin(0));
1725
1726   hole11shape->Rmax(1) = hole11shape->GetRmax(0);
1727   hole11shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1728                                         hole11shape->GetRmax(1));
1729   hole11shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1730                                         hole11shape->GetZ(1));
1731
1732   hole11shape->Rmin(2) = kHole1RMin;
1733   hole11shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1734                                         hole11shape->GetRmin(2));
1735   hole11shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1736                                         hole11shape->GetZ(2));
1737
1738   hole11shape->Rmin(3) = hole11shape->GetRmin(2);
1739   hole11shape->Rmax(3) = hole11shape->GetRmin(3);
1740   hole11shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1741                                         hole11shape->GetRmax(3));
1742
1743   TGeoPcon *hole12shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1744
1745   hole12shape->Rmin(0) = kHole1RMax;
1746   hole12shape->Rmax(0) = hole12shape->GetRmin(0);
1747   hole12shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1748                                         hole12shape->GetRmin(0));
1749
1750   hole12shape->Rmax(1) = hole12shape->GetRmax(0);
1751   hole12shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1752                                         hole12shape->GetRmax(1));
1753   hole12shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1754                                         hole12shape->GetZ(1));
1755
1756   hole12shape->Rmin(2) = kHole1RMin;
1757   hole12shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1758                                         hole12shape->GetRmin(2));
1759   hole12shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1760                                         hole12shape->GetZ(2));
1761
1762   hole12shape->Rmin(3) = hole12shape->GetRmin(2);
1763   hole12shape->Rmax(3) = hole12shape->GetRmin(3);
1764   hole12shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1765                                         hole12shape->GetRmax(3));
1766
1767   //
1768   TGeoPcon *hole2shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1769
1770   hole2shape->Rmin(0) = kHole2RMax;
1771   hole2shape->Rmax(0) = hole2shape->GetRmin(0);
1772   hole2shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1773                                        hole2shape->GetRmin(0));
1774
1775   hole2shape->Rmax(1) = hole2shape->GetRmax(0);
1776   hole2shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1777                                        hole2shape->GetRmax(1));
1778   hole2shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1779                                        hole2shape->GetZ(1));
1780
1781   hole2shape->Rmin(2) = kHole2RMin;
1782   hole2shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1783                                        hole2shape->GetRmin(2));
1784   hole2shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1785                                        hole2shape->GetZ(2));
1786
1787   hole2shape->Rmin(3) = hole2shape->GetRmin(2);
1788   hole2shape->Rmax(3) = hole2shape->GetRmin(3);
1789   hole2shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1790                                        hole2shape->GetRmax(3));
1791
1792   TGeoPcon *hole21shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1793
1794   hole21shape->Rmin(0) = kHole2RMax;
1795   hole21shape->Rmax(0) = hole21shape->GetRmin(0);
1796   hole21shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1797                                         hole21shape->GetRmin(0));
1798
1799   hole21shape->Rmax(1) = hole21shape->GetRmax(0);
1800   hole21shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1801                                         hole21shape->GetRmax(1));
1802   hole21shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1803                                         hole21shape->GetZ(1));
1804
1805   hole21shape->Rmin(2) = kHole2RMin;
1806   hole21shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1807                                         hole21shape->GetRmin(2));
1808   hole21shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1809                                         hole21shape->GetZ(2));
1810
1811   hole21shape->Rmin(3) = hole21shape->GetRmin(2);
1812   hole21shape->Rmax(3) = hole21shape->GetRmin(3);
1813   hole21shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1814                                         hole21shape->GetRmax(3));
1815
1816   TGeoPcon *hole22shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1817
1818   hole22shape->Rmin(0) = kHole2RMax;
1819   hole22shape->Rmax(0) = hole22shape->GetRmin(0);
1820   hole22shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1821                                         hole22shape->GetRmin(0));
1822
1823   hole22shape->Rmax(1) = hole22shape->GetRmax(0);
1824   hole22shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1825                                         hole22shape->GetRmax(1));
1826   hole22shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1827                                         hole22shape->GetZ(1));
1828
1829   hole22shape->Rmin(2) = kHole2RMin;
1830   hole22shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1831                                         hole22shape->GetRmin(2));
1832   hole22shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1833                                         hole22shape->GetZ(2));
1834
1835   hole22shape->Rmin(3) = hole22shape->GetRmin(2);
1836   hole22shape->Rmax(3) = hole22shape->GetRmin(3);
1837   hole22shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1838                                         hole22shape->GetRmax(3));
1839
1840   //
1841   Double_t holePhi;
1842   holePhi = (kHole3Width/kHole3RMin)*TMath::RadToDeg();
1843
1844   TGeoPcon *hole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1845
1846   hole3shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1847   hole3shape->Rmax(0) = hole3shape->GetRmin(0);
1848   hole3shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1849                                        hole3shape->GetRmin(0));
1850
1851   hole3shape->Rmax(1) = hole3shape->GetRmax(0);
1852   hole3shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1853                                        hole3shape->GetRmax(1));
1854   hole3shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1855                                        hole3shape->GetZ(1));
1856
1857   hole3shape->Rmin(2) = kHole3RMin;
1858   hole3shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1859                                        hole3shape->GetRmin(2));
1860   hole3shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1861                                        hole3shape->GetZ(2));
1862
1863   hole3shape->Rmin(3) = hole3shape->GetRmin(2);
1864   hole3shape->Rmax(3) = hole3shape->GetRmin(3);
1865   hole3shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1866                                        hole3shape->GetRmax(3));
1867
1868   TGeoPcon *hole31shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1869
1870   hole31shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1871   hole31shape->Rmax(0) = hole31shape->GetRmin(0);
1872   hole31shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1873                                         hole31shape->GetRmin(0));
1874
1875   hole31shape->Rmax(1) = hole31shape->GetRmax(0);
1876   hole31shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1877                                         hole31shape->GetRmax(1));
1878   hole31shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1879                                         hole31shape->GetZ(1));
1880
1881   hole31shape->Rmin(2) = kHole3RMin;
1882   hole31shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1883                                         hole31shape->GetRmin(2));
1884   hole31shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1885                                         hole31shape->GetZ(2));
1886
1887   hole31shape->Rmin(3) = hole31shape->GetRmin(2);
1888   hole31shape->Rmax(3) = hole31shape->GetRmin(3);
1889   hole31shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1890                                         hole31shape->GetRmax(3));
1891
1892   TGeoPcon *hole32shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1893
1894   hole32shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1895   hole32shape->Rmax(0) = hole32shape->GetRmin(0);
1896   hole32shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1897                                         hole32shape->GetRmin(0));
1898
1899   hole32shape->Rmax(1) = hole32shape->GetRmax(0);
1900   hole32shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1901                                         hole32shape->GetRmax(1));
1902   hole32shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1903                                         hole32shape->GetZ(1));
1904
1905   hole32shape->Rmin(2) = kHole3RMin;
1906   hole32shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1907                                         hole32shape->GetRmin(2));
1908   hole32shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1909                                         hole32shape->GetZ(2));
1910
1911   hole32shape->Rmin(3) = hole32shape->GetRmin(2);
1912   hole32shape->Rmax(3) = hole32shape->GetRmin(3);
1913   hole32shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1914                                         hole32shape->GetRmax(3));
1915
1916   //
1917   holePhi = (kHole4Width/kHole4RMin)*TMath::RadToDeg();
1918
1919   TGeoPcon *hole4shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1920
1921   hole4shape->Rmin(0) = kHole4RMin + kHole4DeltaR;
1922   hole4shape->Rmax(0) = hole4shape->GetRmin(0);
1923   hole4shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1924                                        hole4shape->GetRmin(0));
1925
1926   hole4shape->Rmax(1) = hole4shape->GetRmax(0);
1927   hole4shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1928                                        hole4shape->GetRmax(1));
1929   hole4shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1930                                        hole4shape->GetZ(1));
1931
1932   hole4shape->Rmin(2) = kHole4RMin;
1933   hole4shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1934                                        hole4shape->GetRmin(2));
1935   hole4shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1936                                        hole4shape->GetZ(2));
1937
1938   hole4shape->Rmin(3) = hole4shape->GetRmin(2);
1939   hole4shape->Rmax(3) = hole4shape->GetRmin(3);
1940   hole4shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1941                                        hole4shape->GetRmax(3));
1942
1943   // Cables to be put inside the holes: Pcon's
1944   // (fractions are manually computed from AliITSv11GeometrySDD::SDDCables
1945   TGeoPcon *hole1plastshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1946
1947   hole1plastshape->Rmin(0) = hole1shape->GetRmin(0);
1948   hole1plastshape->Rmax(0) = hole1shape->GetRmax(0);
1949   hole1plastshape->Z(0)    = hole1shape->GetZ(0);
1950
1951   hole1plastshape->Rmin(1) = hole1shape->GetRmin(1);
1952   hole1plastshape->Rmax(1) = hole1shape->GetRmax(1);
1953   hole1plastshape->Z(1)    = hole1shape->GetZ(1);
1954
1955   dza = hole1plastshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHolePlasticFrac;
1956
1957   hole1plastshape->Rmin(2) = dza;
1958   hole1plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1959                                             hole1plastshape->GetRmin(2));
1960   hole1plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1961                                             hole1plastshape->GetZ(2));
1962
1963   hole1plastshape->Rmin(3) = hole1plastshape->GetRmin(2);
1964   hole1plastshape->Rmax(3) = hole1plastshape->GetRmin(3);
1965   hole1plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1966                                             hole1plastshape->GetRmax(3));
1967
1968   TGeoPcon *hole1Cushape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1969
1970   hole1Cushape->Rmin(0) = hole1plastshape->GetRmin(2);
1971   hole1Cushape->Rmax(0) = hole1Cushape->GetRmin(0);
1972   hole1Cushape->Z(0)    = hole1plastshape->GetZ(2);
1973
1974   dza = hole1Cushape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleCuFrac;
1975
1976   hole1Cushape->Rmin(1) = dza;
1977   hole1Cushape->Rmax(1) = hole1Cushape->GetRmax(0);
1978   hole1Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1979                                          hole1Cushape->GetRmin(1));
1980
1981   hole1Cushape->Rmax(2) = hole1Cushape->GetRmax(0);
1982   hole1Cushape->Rmin(2) = hole1Cushape->GetRmin(1);
1983   hole1Cushape->Z(2)    = hole1plastshape->GetZ(3);
1984
1985   hole1Cushape->Rmin(3) = hole1Cushape->GetRmin(1);
1986   hole1Cushape->Rmax(3) = hole1Cushape->GetRmin(3);
1987   hole1Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1988                                          hole1Cushape->GetRmax(3));
1989
1990   TGeoPcon *hole1glassshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1991
1992   hole1glassshape->Rmin(0) = hole1Cushape->GetRmin(1);
1993   hole1glassshape->Rmax(0) = hole1glassshape->GetRmin(0);
1994   hole1glassshape->Z(0)    = hole1Cushape->GetZ(1);
1995
1996   dza = hole1glassshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleGlassFrac;
1997
1998   hole1glassshape->Rmin(1) = dza;
1999   hole1glassshape->Rmax(1) = hole1glassshape->GetRmax(0);
2000   hole1glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2001                                             hole1glassshape->GetRmin(1));
2002
2003   hole1glassshape->Rmax(2) = hole1glassshape->GetRmax(0);
2004   hole1glassshape->Rmin(2) = hole1glassshape->GetRmin(1);
2005   hole1glassshape->Z(2)    = hole1Cushape->GetZ(3);
2006
2007   hole1glassshape->Rmin(3) = hole1glassshape->GetRmin(1);
2008   hole1glassshape->Rmax(3) = hole1glassshape->GetRmin(3);
2009   hole1glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2010                                             hole1glassshape->GetRmax(3));
2011   //
2012   TGeoPcon *hole2plastshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2013
2014   hole2plastshape->Rmin(0) = hole2shape->GetRmin(0);
2015   hole2plastshape->Rmax(0) = hole2shape->GetRmax(0);
2016   hole2plastshape->Z(0)    = hole2shape->GetZ(0);
2017
2018   hole2plastshape->Rmin(1) = hole2shape->GetRmin(1);
2019   hole2plastshape->Rmax(1) = hole2shape->GetRmax(1);
2020   hole2plastshape->Z(1)    = hole2shape->GetZ(1);
2021
2022   dza = hole2plastshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHolePlasticFrac;
2023
2024   hole2plastshape->Rmin(2) = dza;
2025   hole2plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2026                                             hole2plastshape->GetRmin(2));
2027   hole2plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
2028                                             hole2plastshape->GetZ(2));
2029
2030   hole2plastshape->Rmin(3) = hole2plastshape->GetRmin(2);
2031   hole2plastshape->Rmax(3) = hole2plastshape->GetRmin(3);
2032   hole2plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2033                                             hole2plastshape->GetRmax(3));
2034
2035   TGeoPcon *hole2Cushape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2036
2037   hole2Cushape->Rmin(0) = hole2plastshape->GetRmin(2);
2038   hole2Cushape->Rmax(0) = hole2Cushape->GetRmin(0);
2039   hole2Cushape->Z(0)    = hole2plastshape->GetZ(2);
2040
2041   dza = hole2Cushape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleCuFrac;
2042
2043   hole2Cushape->Rmin(1) = dza;
2044   hole2Cushape->Rmax(1) = hole2Cushape->GetRmax(0);
2045   hole2Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2046                                          hole2Cushape->GetRmin(1));
2047
2048   hole2Cushape->Rmax(2) = hole2Cushape->GetRmax(0);
2049   hole2Cushape->Rmin(2) = hole2Cushape->GetRmin(1);
2050   hole2Cushape->Z(2)    = hole2plastshape->GetZ(3);
2051
2052   hole2Cushape->Rmin(3) = hole2Cushape->GetRmin(1);
2053   hole2Cushape->Rmax(3) = hole2Cushape->GetRmin(3);
2054   hole2Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2055                                          hole2Cushape->GetRmax(3));
2056
2057   TGeoPcon *hole2glassshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2058
2059   hole2glassshape->Rmin(0) = hole2Cushape->GetRmin(1);
2060   hole2glassshape->Rmax(0) = hole2glassshape->GetRmin(0);
2061   hole2glassshape->Z(0)    = hole2Cushape->GetZ(1);
2062
2063   dza = hole2glassshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleGlassFrac;
2064
2065   hole2glassshape->Rmin(1) = dza;
2066   hole2glassshape->Rmax(1) = hole2glassshape->GetRmax(0);
2067   hole2glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2068                                             hole2glassshape->GetRmin(1));
2069
2070   hole2glassshape->Rmax(2) = hole2glassshape->GetRmax(0);
2071   hole2glassshape->Rmin(2) = hole2glassshape->GetRmin(1);
2072   hole2glassshape->Z(2)    = hole2Cushape->GetZ(3);
2073
2074   hole2glassshape->Rmin(3) = hole2glassshape->GetRmin(1);
2075   hole2glassshape->Rmax(3) = hole2glassshape->GetRmin(3);
2076   hole2glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2077                                             hole2glassshape->GetRmax(3));
2078
2079
2080   // Debug if requested
2081   if (GetDebug(1)) {
2082     coneshape->InspectShape();
2083     coneinsertshape->InspectShape();
2084     conefoamshape->InspectShape();
2085     hole1shape->InspectShape();
2086     hole2shape->InspectShape();
2087     hole3shape->InspectShape();
2088     hole4shape->InspectShape();
2089   }
2090
2091
2092   // We have the shapes: now create the real volumes
2093
2094   TGeoVolume *cfcone = new TGeoVolume("SDDCarbonFiberCone",
2095                                       coneshape,medSDDcf);
2096   cfcone->SetVisibility(kTRUE);
2097   cfcone->SetLineColor(4); // Blue
2098   cfcone->SetLineWidth(1);
2099   cfcone->SetFillColor(cfcone->GetLineColor());
2100   cfcone->SetFillStyle(4000); // 0% transparent
2101
2102   TGeoVolume *cfconeinsert = new TGeoVolume("SDDCarbonFiberConeInsert",
2103                                             coneinsertshape,medSDDste);
2104   cfconeinsert->SetVisibility(kTRUE);
2105   cfconeinsert->SetLineColor(2); // Red
2106   cfconeinsert->SetLineWidth(1);
2107   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2108   cfconeinsert->SetFillStyle(4050); // 50% transparent
2109
2110   TGeoVolume *cfconefoam = new TGeoVolume("SDDCarbonFiberConeFoam",
2111                                           conefoamshape,medSDDroh);
2112   cfconefoam->SetVisibility(kTRUE);
2113   cfconefoam->SetLineColor(7); // Light blue
2114   cfconefoam->SetLineWidth(1);
2115   cfconefoam->SetFillColor(cfconefoam->GetLineColor());
2116   cfconefoam->SetFillStyle(4050); // 50% transparent
2117
2118   TGeoVolume *hole1 = new TGeoVolume("SDDCableHole1",
2119                                      hole1shape,medSDDair);
2120   hole1->SetVisibility(kTRUE);
2121   hole1->SetLineColor(5); // Yellow
2122   hole1->SetLineWidth(1);
2123   hole1->SetFillColor(hole1->GetLineColor());
2124   hole1->SetFillStyle(4090); // 90% transparent
2125
2126   TGeoVolume *hole11 = new TGeoVolume("SDDCableHole11",
2127                                       hole11shape,medSDDair);
2128   hole11->SetVisibility(kTRUE);
2129   hole11->SetLineColor(5); // Yellow
2130   hole11->SetLineWidth(1);
2131   hole11->SetFillColor(hole11->GetLineColor());
2132   hole11->SetFillStyle(4090); // 90% transparent
2133
2134   TGeoVolume *hole12 = new TGeoVolume("SDDCableHole12",
2135                                       hole12shape,medSDDair);
2136   hole12->SetVisibility(kTRUE);
2137   hole12->SetLineColor(5); // Yellow
2138   hole12->SetLineWidth(1);
2139   hole12->SetFillColor(hole12->GetLineColor());
2140   hole12->SetFillStyle(4090); // 90% transparent
2141
2142   TGeoVolume *hole1plast = new TGeoVolume("SDDCableHole1Plast",
2143                                           hole1plastshape,medSDDplast);
2144   hole1plast->SetVisibility(kTRUE);
2145   hole1plast->SetLineColor(kBlue);
2146   hole1plast->SetLineWidth(1);
2147   hole1plast->SetFillColor(hole1plast->GetLineColor());
2148   hole1plast->SetFillStyle(4090); // 90% transparent
2149
2150   TGeoVolume *hole1Cu = new TGeoVolume("SDDCableHole1Cu",
2151                                        hole1Cushape,medSDDCu);
2152   hole1Cu->SetVisibility(kTRUE);
2153   hole1Cu->SetLineColor(kRed);
2154   hole1Cu->SetLineWidth(1);
2155   hole1Cu->SetFillColor(hole1Cu->GetLineColor());
2156   hole1Cu->SetFillStyle(4090); // 90% transparent
2157
2158   TGeoVolume *hole1glass = new TGeoVolume("SDDCableHole1glass",
2159                                           hole1glassshape,medSDDglass);
2160   hole1glass->SetVisibility(kTRUE);
2161   hole1glass->SetLineColor(kGreen);
2162   hole1glass->SetLineWidth(1);
2163   hole1glass->SetFillColor(hole1glass->GetLineColor());
2164   hole1glass->SetFillStyle(4090); // 90% transparent
2165
2166   TGeoVolume *hole2 = new TGeoVolume("SDDCableHole2",
2167                                      hole2shape,medSDDair);
2168   hole2->SetVisibility(kTRUE);
2169   hole2->SetLineColor(5); // Yellow
2170   hole2->SetLineWidth(1);
2171   hole2->SetFillColor(hole2->GetLineColor());
2172   hole2->SetFillStyle(4090); // 90% transparent
2173
2174   TGeoVolume *hole21 = new TGeoVolume("SDDCableHole21",
2175                                       hole21shape,medSDDair);
2176   hole21->SetVisibility(kTRUE);
2177   hole21->SetLineColor(5); // Yellow
2178   hole21->SetLineWidth(1);
2179   hole21->SetFillColor(hole21->GetLineColor());
2180   hole21->SetFillStyle(4090); // 90% transparent
2181
2182   TGeoVolume *hole22 = new TGeoVolume("SDDCableHole22",
2183                                       hole22shape,medSDDair);
2184   hole22->SetVisibility(kTRUE);
2185   hole22->SetLineColor(5); // Yellow
2186   hole22->SetLineWidth(1);
2187   hole22->SetFillColor(hole22->GetLineColor());
2188   hole22->SetFillStyle(4090); // 90% transparent
2189
2190   TGeoVolume *hole2plast = new TGeoVolume("SDDCableHole2Plast",
2191                                           hole2plastshape,medSDDplast);
2192   hole2plast->SetVisibility(kTRUE);
2193   hole2plast->SetLineColor(kBlue);
2194   hole2plast->SetLineWidth(1);
2195   hole2plast->SetFillColor(hole2plast->GetLineColor());
2196   hole2plast->SetFillStyle(4090); // 90% transparent
2197
2198   TGeoVolume *hole2Cu = new TGeoVolume("SDDCableHole2Cu",
2199                                        hole2Cushape,medSDDCu);
2200   hole2Cu->SetVisibility(kTRUE);
2201   hole2Cu->SetLineColor(kRed);
2202   hole2Cu->SetLineWidth(1);
2203   hole2Cu->SetFillColor(hole2Cu->GetLineColor());
2204   hole2Cu->SetFillStyle(4090); // 90% transparent
2205
2206   TGeoVolume *hole2glass = new TGeoVolume("SDDCableHole2glass",
2207                                           hole2glassshape,medSDDglass);
2208   hole2glass->SetVisibility(kTRUE);
2209   hole2glass->SetLineColor(kGreen);
2210   hole2glass->SetLineWidth(1);
2211   hole2glass->SetFillColor(hole2glass->GetLineColor());
2212   hole2glass->SetFillStyle(4090); // 90% transparent
2213
2214   TGeoVolume *hole3 = new TGeoVolume("SDDCableHole3",
2215                                      hole3shape,medSDDair);
2216   hole3->SetVisibility(kTRUE);
2217   hole3->SetLineColor(5); // Yellow
2218   hole3->SetLineWidth(1);
2219   hole3->SetFillColor(hole3->GetLineColor());
2220   hole3->SetFillStyle(4090); // 90% transparent
2221
2222   TGeoVolume *hole31 = new TGeoVolume("SDDCableHole31",
2223                                       hole31shape,medSDDair);
2224   hole31->SetVisibility(kTRUE);
2225   hole31->SetLineColor(5); // Yellow
2226   hole31->SetLineWidth(1);
2227   hole31->SetFillColor(hole31->GetLineColor());
2228   hole31->SetFillStyle(4090); // 90% transparent
2229
2230   TGeoVolume *hole32 = new TGeoVolume("SDDCableHole32",
2231                                       hole32shape,medSDDair);
2232   hole32->SetVisibility(kTRUE);
2233   hole32->SetLineColor(5); // Yellow
2234   hole32->SetLineWidth(1);
2235   hole32->SetFillColor(hole32->GetLineColor());
2236   hole32->SetFillStyle(4090); // 90% transparent
2237
2238   TGeoVolume *hole4 = new TGeoVolume("SDDCableHole4",
2239                                      hole4shape,medSDDair);
2240   hole4->SetVisibility(kTRUE);
2241   hole4->SetLineColor(5); // Yellow
2242   hole4->SetLineWidth(1);
2243   hole4->SetFillColor(hole4->GetLineColor());
2244   hole4->SetFillStyle(4090); // 90% transparent
2245
2246   // Mount up a cone
2247   cfconeinsert->AddNode(cfconefoam,1,0);
2248
2249   hole1->AddNode(hole1plast, 1, 0);
2250   hole1->AddNode(hole1Cu, 1, 0);
2251   hole1->AddNode(hole1glass, 1, 0);
2252
2253   hole2->AddNode(hole2plast, 1, 0);
2254   hole2->AddNode(hole2Cu, 1, 0);
2255   hole2->AddNode(hole2glass, 1, 0);
2256
2257   for (Int_t i=0; i<12; i++) {
2258     Double_t phiH = i*30.0;
2259     cfconefoam->AddNode(hole1 , i+1, new TGeoRotation("", 0, 0, phiH));
2260         cfcone->AddNode(hole11, i+1, new TGeoRotation("", 0, 0, phiH));
2261         cfcone->AddNode(hole12, i+1, new TGeoRotation("", 0, 0, phiH));
2262   }
2263
2264   for (Int_t i=0; i<6; i++) {
2265     Double_t phiH = i*60.0;
2266     cfconefoam->AddNode(hole2 , i+1, new TGeoRotation("", 0, 0, phiH));
2267         cfcone->AddNode(hole21, i+1, new TGeoRotation("", 0, 0, phiH));
2268         cfcone->AddNode(hole22, i+1, new TGeoRotation("", 0, 0, phiH));
2269   }
2270
2271   for (Int_t i=0; i<kNHole3; i++) {
2272     Double_t phiH0 = 360./(Double_t)kNHole3;
2273     Double_t phiH  = i*phiH0 + 0.5*phiH0;
2274     cfconefoam->AddNode(hole3 , i+1, new TGeoRotation("", phiH, 0, 0));
2275         cfcone->AddNode(hole31, i+1, new TGeoRotation("", phiH, 0, 0));
2276         cfcone->AddNode(hole32, i+1, new TGeoRotation("", phiH, 0, 0));
2277   }
2278
2279   cfcone->AddNode(cfconeinsert,1,0);
2280
2281 /*
2282   for (Int_t i=0; i<kNHole4; i++) {
2283     Double_t phiH0 = 360./(Double_t)kNHole4;
2284     Double_t phiH  = i*phiH0 + 0.25*phiH0;
2285     cfcone->AddNode(hole4, i+1, new TGeoRotation("", phiH, 0, 0));
2286   }
2287 */
2288   // Finally put everything in the mother volume
2289   moth->AddNode(cfcylinder,1,0);
2290
2291   z = coneshape->Z(9);
2292   moth->AddNode(cfcone,1,new TGeoTranslation(0, 0, -z - kCylinderHalfLength));
2293   moth->AddNode(cfcone,2,new TGeoCombiTrans (0, 0,  z + kCylinderHalfLength,
2294                          new TGeoRotation("", 0, 180, 0)                   ));
2295
2296
2297   return;
2298 }
2299
2300 //______________________________________________________________________
2301 void AliITSv11GeometrySupport::SSDCone(TGeoVolume *moth,const TGeoManager *mgr)
2302 {
2303 //
2304 // Creates the SSD support cone and cylinder geometry. as a
2305 // volume assembly and adds it to the mother volume
2306 // (part of this code is taken or anyway inspired to SSDCone method
2307 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
2308 //
2309 // Input:
2310 //         moth : the TGeoVolume owing the volume structure
2311 //         mgr  : the GeoManager (default gGeoManager)
2312 // Output:
2313 //
2314 // Created:         ???       Bjorn S. Nilsen
2315 // Updated:      08 Mar 2008  Mario Sitta
2316 //
2317 // Technical data are taken from:  "ITS Supporto Generale" (technical
2318 // drawings ALR3-0743/1, ALR3-0743/1A and ALR3-0743/1B), "Supporto Generale
2319 // Settore SSD" (technical drawings ALR3-0743/2A and ALR3-0743/2E), private
2320 // communication with B. Giraudo
2321 //
2322 // Updated:      11 Apr 2008  Mario Sitta
2323 // Measures from drawings give overlaps with SPD thermal shield wings,
2324 // so the terminal part of the SSD cone was reduced
2325 //
2326 // Updated:      30 Mar 2010  Mario Sitta
2327 // Following M. van Leeuwen's suggestion on material budget, the thickness
2328 // of the carbon fiber cylinder was increased from 0.6 to 0.625mm
2329
2330   // Dimensions of the Central cylinder and flanges
2331   const Double_t kCylinderHalfLength   = (1143.6/2) *fgkmm;
2332   const Double_t kCylinderOuterRadius  = ( 595.0/2) *fgkmm;
2333   const Double_t kCylinderThickness    =       0.625*fgkmm;
2334   const Double_t kFoamHalfLength       = (1020.0/2) *fgkmm;
2335   const Double_t kFoamThickness        =        5.0 *fgkmm;
2336   const Double_t kFlangeHalfLength     =
2337                                       (kCylinderHalfLength-kFoamHalfLength)/2.;
2338   const Double_t kFlangeInnerRadius    = ( 563.0/2) *fgkmm;
2339   // Dimensions of the Cone
2340   const Double_t kConeROuterMin        = ( 957.0/2) *fgkmm;
2341   const Double_t kConeROuterMax        = ( 997.0/2) *fgkmm;
2342   const Double_t kConeRInnerMin        = ( 564.0/2) *fgkmm;
2343   const Double_t kConeRCurv1           =       10.0 *fgkmm;
2344   const Double_t kConeRCurv2           =       25.0 *fgkmm;
2345   const Double_t kConeCent1RCurv2      = ( 578.0/2) *fgkmm;
2346   const Double_t kConeCent2RCurv2      = ( 592.0/2) *fgkmm;
2347 //  const Double_t kConeZOuterRing       =       47.0 *fgkmm;
2348 //  const Double_t kConeZOuterRingInside =       30.25*fgkmm;
2349 //  const Double_t kConeZInnerRing       =      161.5 *fgkmm;
2350 //  const Double_t kConeZLength          =      176.5 *fgkmm;
2351   const Double_t kConeZOuterRing       =       38.5 *fgkmm;
2352   const Double_t kConeZOuterRingInside =       22.2 *fgkmm;
2353   const Double_t kConeZInnerRing       =      153.0 *fgkmm;
2354   const Double_t kConeZLength          =      168.0 *fgkmm;
2355   const Double_t kConeZPosition        = kConeZLength + kCylinderHalfLength;
2356   const Double_t kConeThickness        =       13.0 *fgkmm; // Cone thickness
2357   const Double_t kConeTheta            =       39.1 *fgkDegree; // Cone angle
2358   const Double_t kSinConeTheta         =
2359                                       TMath::Sin(kConeTheta*TMath::DegToRad());
2360   const Double_t kCosConeTheta         =
2361                                       TMath::Cos(kConeTheta*TMath::DegToRad());
2362   // Dimensions of the Foam cores
2363   const Double_t kConeFoam1Length      =      112.3 *fgkmm;
2364   const Double_t kConeFoam2Length      =       58.4 *fgkmm;
2365   // Dimensions of the Cone Holes
2366   const Double_t kCoolingHoleWidth     =       40.0 *fgkmm;
2367   const Double_t kCoolingHoleHight     =       30.0 *fgkmm;
2368   const Double_t kCoolingHoleRmin      =      350.0 *fgkmm;
2369   const Double_t kCoolingHolePhi       =       45.0 *fgkDegree;
2370   const Double_t kMountingHoleWidth    =       20.0 *fgkmm;
2371   const Double_t kMountingHoleHight    =       20.0 *fgkmm;
2372   const Double_t kMountingHoleRmin     =      317.5 *fgkmm;
2373   const Double_t kMountingHolePhi      =       60.0 *fgkDegree;
2374   const Double_t kCableHoleRin         = ( 800.0/2) *fgkmm;
2375   const Double_t kCableHoleRout        = ( 920.0/2) *fgkmm;
2376   const Double_t kCableHoleWidth       =      200.0 *fgkmm;
2377 //  const Double_t kCableHoleAngle       =       42.0 *fgkDegree;
2378   // Dimensions of the Cone Wings
2379   const Double_t kWingRmax             =      527.5 *fgkmm;
2380   const Double_t kWingWidth            =       70.0 *fgkmm;
2381   const Double_t kWingHalfThick        = (  10.0/2) *fgkmm;
2382   const Double_t kThetaWing            =       45.0 *fgkDegree;
2383   // Dimensions of the SSD-SDD Mounting Brackets
2384   const Double_t kBracketRmin          = ( 541.0/2) *fgkmm;// See SDD ROutMin
2385   const Double_t kBracketRmax          = ( 585.0/2) *fgkmm;
2386   const Double_t kBracketHalfLength    = (   4.0/2) *fgkmm;
2387   const Double_t kBracketPhi           = (70.*fgkmm/kBracketRmax)*fgkRadian;
2388   // Common data
2389   const Double_t kCFThickness          =        0.75*fgkmm; //Carb. fib. thick.
2390
2391
2392   // Local variables
2393   Double_t rmin1, rmin2, rmax, z;
2394
2395   //
2396   //Begin_Html
2397   /*
2398     <img src="picts/ITS/file_name.gif">
2399     <P>
2400     <FONT FACE'"TIMES">
2401     ITS SSD central support and thermal shield cylinder.
2402     </FONT>
2403     </P>
2404   */
2405   //End_Html
2406   //
2407
2408   // Central cylinder with its internal foam and the lateral flanges:
2409   // a carbon fiber Pcon which contains a rohacell Tube and two
2410   // stesalite Cone's
2411   TGeoPcon *externalcylshape = new TGeoPcon(0,360,4);
2412
2413   rmax  = kCylinderOuterRadius;
2414   rmin1 = kFlangeInnerRadius - kCylinderThickness;
2415   rmin2 = rmax - 2*kCylinderThickness - kFoamThickness;
2416   externalcylshape->DefineSection(0,-kCylinderHalfLength,rmin1,rmax);
2417   externalcylshape->DefineSection(1,-kFoamHalfLength    ,rmin2,rmax);
2418   externalcylshape->DefineSection(2, kFoamHalfLength    ,rmin2,rmax);
2419   externalcylshape->DefineSection(3, kCylinderHalfLength,rmin1,rmax);
2420
2421   rmax  = kCylinderOuterRadius - kCylinderThickness;
2422   rmin1 = rmax - kFoamThickness;
2423   TGeoTube *foamshape = new TGeoTube(rmin1,rmax,kFoamHalfLength);
2424
2425   rmax  = kCylinderOuterRadius - kCylinderThickness;
2426   rmin1 = rmax - kFoamThickness;
2427   rmin2 = kFlangeInnerRadius;
2428   TGeoCone *flangeshape = new TGeoCone(kFlangeHalfLength,
2429                                        rmin1,rmax,rmin2,rmax);
2430
2431
2432   // We have the shapes: now create the real volumes
2433
2434   TGeoMedium *medSSDcf  = mgr->GetMedium("ITS_SSD C (M55J)$");
2435   TGeoMedium *medSSDair = mgr->GetMedium("ITS_SSD AIR$");
2436   TGeoMedium *medSSDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
2437   TGeoMedium *medSSDroh = mgr->GetMedium("ITS_ROHACELL$");
2438   TGeoMedium *medSSDal  = mgr->GetMedium("ITS_ALUMINUM$");
2439
2440   TGeoVolume *cfcylinder = new TGeoVolume("SSDexternalcylinder",
2441                                            externalcylshape,medSSDcf);
2442   cfcylinder->SetVisibility(kTRUE);
2443   cfcylinder->SetLineColor(4); // blue
2444   cfcylinder->SetLineWidth(1);
2445   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
2446   cfcylinder->SetFillStyle(4000); // 0% transparent
2447
2448   TGeoVolume *foamcylinder = new TGeoVolume("SSDfoamcylinder",
2449                                             foamshape,medSSDroh);
2450   foamcylinder->SetVisibility(kTRUE);
2451   foamcylinder->SetLineColor(3); // green
2452   foamcylinder->SetLineWidth(1);
2453   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
2454   foamcylinder->SetFillStyle(4050); // 50% transparent
2455
2456   TGeoVolume *flangecylinder = new TGeoVolume("SSDflangecylinder",
2457                                               flangeshape,medSSDste);
2458   flangecylinder->SetVisibility(kTRUE);
2459   flangecylinder->SetLineColor(2); // red
2460   flangecylinder->SetLineWidth(1);
2461   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
2462   flangecylinder->SetFillStyle(4050); // 50% transparent
2463
2464   // Mount up the cylinder
2465   cfcylinder->AddNode(foamcylinder,1,0);
2466   cfcylinder->AddNode(flangecylinder,1,
2467               new TGeoTranslation(0, 0, kFoamHalfLength+kFlangeHalfLength));
2468   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
2469               0, 0, -kFoamHalfLength-kFlangeHalfLength,
2470               new TGeoRotation("",0,180,0)     ) );
2471
2472
2473   // The whole Cone as an assembly
2474   TGeoVolumeAssembly *vC = new TGeoVolumeAssembly("ITSssdCone");
2475
2476
2477   // SSD Support Cone with its internal inserts: a carbon fiber Pcon
2478   // with holes which contains a stesalite Pcon which on turn contains a
2479   // rohacell Pcon
2480   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 12);
2481
2482   coneshape->Z(0)     = 0.0;
2483   coneshape->Rmin(0)  = kConeROuterMin;
2484   coneshape->Rmax(0)  = kConeROuterMax;
2485
2486   coneshape->Z(1)     = kConeZOuterRingInside - kConeRCurv1;
2487   coneshape->Rmin(1)  = coneshape->GetRmin(0);
2488   coneshape->Rmax(1)  = coneshape->GetRmax(0);
2489
2490   coneshape->Z(2)     = kConeZOuterRingInside;
2491   coneshape->Rmin(2)  = coneshape->GetRmin(1) - kConeRCurv1;
2492   coneshape->Rmax(2)  = coneshape->GetRmax(0);
2493
2494   coneshape->Z(3)     = coneshape->GetZ(2);
2495   coneshape->Rmax(3)  = coneshape->GetRmax(0);
2496
2497   coneshape->Z(4)     = kConeZOuterRing - kConeRCurv1;
2498   coneshape->Rmax(4)  = coneshape->GetRmax(0);
2499
2500   coneshape->Z(5)     = kConeZOuterRing;
2501   coneshape->Rmax(5)  = coneshape->GetRmax(4) - kConeRCurv1;
2502
2503   coneshape->Z(6)     = coneshape->GetZ(5);
2504
2505   RadiusOfCurvature(kConeRCurv2,90.0,kConeZInnerRing,kConeCent1RCurv2,
2506                     90.0-kConeTheta,z,rmin1);
2507   coneshape->Z(7)     = z;
2508   coneshape->Rmin(7)  = rmin1;
2509
2510   coneshape->Rmin(3)  = RminFromZpCone(coneshape,7,90.-kConeTheta,
2511                                        coneshape->GetZ(3));
2512
2513   coneshape->Rmin(4)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(4));
2514
2515   coneshape->Rmin(5)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(5));
2516
2517   coneshape->Rmin(6) = coneshape->GetRmin(5);
2518
2519   coneshape->Z(8)     = kConeZInnerRing;
2520   coneshape->Rmin(8)  = kConeCent1RCurv2;
2521
2522   coneshape->Z(9)     = coneshape->GetZ(8);
2523   coneshape->Rmin(9)  = kConeRInnerMin;
2524
2525   RadiusOfCurvature(kConeRCurv2,90.0,kConeZLength,kConeCent2RCurv2,
2526                     90.0-kConeTheta,z,rmax);
2527
2528   coneshape->Z(10)    = z;
2529   coneshape->Rmin(10) = coneshape->GetRmin(9);
2530   coneshape->Rmax(10) = rmax;
2531
2532   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,10,90.-kConeTheta,
2533                                        coneshape->GetZ(6));
2534
2535   coneshape->Rmax(7)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(7));
2536
2537   coneshape->Rmax(8)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(8));
2538
2539   coneshape->Rmax(9)  = coneshape->GetRmax(8);
2540
2541   coneshape->Z(11)    = kConeZLength;
2542   coneshape->Rmin(11) = coneshape->GetRmin(10);
2543   coneshape->Rmax(11) = kConeCent2RCurv2;
2544
2545   // SSD Cone Insert: another Pcon
2546   Double_t x0, y0, x1, y1, x2, y2;
2547   TGeoPcon *coneinsertshape = new TGeoPcon(0.0,360.0,12);
2548
2549   coneinsertshape->Z(0)     = coneshape->GetZ(0) + kCFThickness;
2550   coneinsertshape->Rmin(0)  = coneshape->GetRmin(0) + kCFThickness;
2551   coneinsertshape->Rmax(0)  = coneshape->GetRmax(0) - kCFThickness;
2552
2553   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
2554   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
2555   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
2556   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2557   coneinsertshape->Z(1)     = z;
2558   coneinsertshape->Rmin(1)  = rmin1;
2559   coneinsertshape->Rmax(1)  = coneinsertshape->GetRmax(0);
2560
2561   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmin(1);
2562   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmin(2);
2563   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmin(3);
2564   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2565   coneinsertshape->Z(2)     = z;
2566   coneinsertshape->Rmin(2)  = rmin1;
2567   coneinsertshape->Rmax(2)  = coneinsertshape->GetRmax(1);
2568
2569   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
2570   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
2571   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
2572   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2573   coneinsertshape->Z(3)     = z;
2574   coneinsertshape->Rmin(3)  = rmin1;
2575   coneinsertshape->Rmax(3)  = coneinsertshape->GetRmax(2);
2576
2577   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
2578   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
2579   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
2580   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2581   coneinsertshape->Z(4)     = z;
2582   coneinsertshape->Rmax(4)  = rmax;
2583
2584   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmax(4);
2585   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmax(5);
2586   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmax(6);
2587   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2588   coneinsertshape->Z(5)     = z;
2589   coneinsertshape->Rmax(5)  = rmax;
2590
2591   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmax(5);
2592   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmax(6);
2593   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmax(7);
2594   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2595   coneinsertshape->Z(6)     = z;
2596   coneinsertshape->Rmax(6)  = rmax;
2597
2598   x0 = coneshape->GetZ(6); y0 = coneshape->GetRmin(6);
2599   x1 = coneshape->GetZ(7); y1 = coneshape->GetRmin(7);
2600   x2 = coneshape->GetZ(8); y2 = coneshape->GetRmin(8);
2601   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2602   coneinsertshape->Z(7)     = z;
2603   coneinsertshape->Rmin(7)  = rmin1;
2604
2605   coneinsertshape->Rmin(4)  = RminFrom2Points(coneinsertshape,3,7,
2606                                               coneinsertshape->GetZ(4));
2607
2608   coneinsertshape->Rmin(5)  = RminFrom2Points(coneinsertshape,3,7,
2609                                               coneinsertshape->GetZ(5));
2610
2611   coneinsertshape->Rmin(6)  = coneinsertshape->GetRmin(5);
2612
2613   x0 = coneshape->GetZ(7); y0 = coneshape->GetRmin(7);
2614   x1 = coneshape->GetZ(8); y1 = coneshape->GetRmin(8);
2615   x2 = coneshape->GetZ(9); y2 = coneshape->GetRmin(9);
2616   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2617   coneinsertshape->Z(8)     = z;
2618   coneinsertshape->Rmin(8)  = rmin1;
2619
2620   x0 = coneshape->GetZ( 8); y0 = coneshape->GetRmin( 8);
2621   x1 = coneshape->GetZ( 9); y1 = coneshape->GetRmin( 9);
2622   x2 = coneshape->GetZ(10); y2 = coneshape->GetRmin(10);
2623   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2624   coneinsertshape->Z(9)     = z;
2625   coneinsertshape->Rmin(9)  = rmin1;
2626
2627   x0 = coneshape->GetZ( 9); y0 = coneshape->GetRmax( 9);
2628   x1 = coneshape->GetZ(10); y1 = coneshape->GetRmax(10);
2629   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmax(11);
2630   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2631   coneinsertshape->Z(10)    = z;
2632   coneinsertshape->Rmax(10) = rmax;
2633   coneinsertshape->Rmin(10) = coneinsertshape->GetRmin(9);
2634
2635   coneinsertshape->Rmax(7)  = RmaxFrom2Points(coneinsertshape,6,10,
2636                                               coneinsertshape->GetZ(7));
2637
2638   coneinsertshape->Rmax(8)  = RmaxFrom2Points(coneinsertshape,6,10,
2639                                               coneinsertshape->GetZ(8));
2640
2641   coneinsertshape->Rmax(9)  = coneinsertshape->GetRmax(8);
2642
2643   x0 = coneshape->GetZ(10); y0 = coneshape->GetRmax(10);
2644   x1 = coneshape->GetZ(11); y1 = coneshape->GetRmax(11);
2645   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmin(11);
2646   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2647   coneinsertshape->Z(11)    = z;
2648   coneinsertshape->Rmax(11) = rmax;
2649   coneinsertshape->Rmin(11) = coneinsertshape->GetRmin(10);
2650
2651   // SSD Cone Foams: two other Pcon's
2652   TGeoPcon *conefoam1shape = new TGeoPcon(0.0, 360.0, 4);
2653
2654   conefoam1shape->Z(0)    = coneinsertshape->GetZ(3);
2655   conefoam1shape->Rmin(0) = coneinsertshape->GetRmin(3);
2656   conefoam1shape->Rmax(0) = conefoam1shape->GetRmin(0);
2657
2658   conefoam1shape->Rmax(1) = conefoam1shape->GetRmax(0);
2659   conefoam1shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2660                                            conefoam1shape->GetRmax(1));
2661   conefoam1shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2662                                            conefoam1shape->GetZ(1));
2663
2664   Double_t t = kConeThickness - 2*kCFThickness;
2665   conefoam1shape->Rmin(2) = conefoam1shape->GetRmax(0) -
2666                            (kConeFoam1Length*kCosConeTheta - t*kSinConeTheta);
2667   conefoam1shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2668                                            conefoam1shape->GetRmin(2));
2669   conefoam1shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2670                                            conefoam1shape->GetZ(2));
2671
2672   conefoam1shape->Rmin(3) = conefoam1shape->GetRmin(2);
2673   conefoam1shape->Rmax(3) = conefoam1shape->GetRmin(3);
2674   conefoam1shape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2675                                            conefoam1shape->GetRmax(3));
2676
2677   TGeoPcon *conefoam2shape = new TGeoPcon(0.0, 360.0, 4);
2678
2679   conefoam2shape->Z(3)    = coneinsertshape->GetZ(10);
2680   conefoam2shape->Rmin(3) = coneinsertshape->GetRmax(10);
2681   conefoam2shape->Rmax(3) = conefoam2shape->GetRmin(3);
2682
2683   conefoam2shape->Rmin(2) = conefoam2shape->GetRmin(3);
2684   conefoam2shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2685                                            conefoam2shape->GetRmin(2));
2686   conefoam2shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2687                                            conefoam2shape->GetZ(2));
2688
2689   conefoam2shape->Rmin(0) = conefoam2shape->GetRmax(2) +
2690                            (kConeFoam2Length*kCosConeTheta - t*kSinConeTheta);
2691   conefoam2shape->Rmax(0) = conefoam2shape->GetRmin(0);
2692   conefoam2shape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2693                                            conefoam2shape->GetRmin(0));
2694
2695   conefoam2shape->Rmax(1) = conefoam2shape->GetRmax(0);
2696   conefoam2shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2697                                            conefoam2shape->GetRmax(1));
2698   conefoam2shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2699                                            conefoam2shape->GetZ(1));
2700
2701   // SSD Cone Holes: Pcon's
2702   // A single hole volume gives an overlap with coneinsert, so
2703   // three contiguous volumes are created: one to be put in coneinsert
2704   // and two in the cone carbon fiber envelope
2705   Double_t holePhi;
2706   holePhi = (kCoolingHoleWidth/kCoolingHoleRmin)*TMath::RadToDeg();
2707
2708   TGeoPcon *coolingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2709
2710   coolingholeshape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2711   coolingholeshape->Rmax(0) = coolingholeshape->GetRmin(0);
2712   coolingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2713                                              coolingholeshape->GetRmin(0));
2714
2715   coolingholeshape->Rmax(1) = coolingholeshape->GetRmax(0);
2716   coolingholeshape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2717                                              coolingholeshape->GetRmax(1));
2718   coolingholeshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2719                                              coolingholeshape->GetZ(1));
2720
2721   coolingholeshape->Rmin(2) = kCoolingHoleRmin;
2722   coolingholeshape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2723                                              coolingholeshape->GetRmin(2));
2724   coolingholeshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2725                                              coolingholeshape->GetZ(2));
2726
2727   coolingholeshape->Rmin(3) = coolingholeshape->GetRmin(2);
2728   coolingholeshape->Rmax(3) = coolingholeshape->GetRmin(3);
2729   coolingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2730                                              coolingholeshape->GetRmax(3));
2731
2732   TGeoPcon *coolinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2733
2734   coolinghole2shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2735   coolinghole2shape->Rmax(0) = coolinghole2shape->GetRmin(0);
2736   coolinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2737                                               coolinghole2shape->GetRmin(0));
2738
2739   coolinghole2shape->Rmax(1) = coolinghole2shape->GetRmax(0);
2740   coolinghole2shape->Z(1)    = coolingholeshape->GetZ(0);
2741   coolinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2742                                               coolinghole2shape->GetZ(1));
2743
2744   coolinghole2shape->Rmin(2) = kCoolingHoleRmin;
2745   coolinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2746                                               coolinghole2shape->GetRmin(2));
2747   coolinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2748                                               coolinghole2shape->GetZ(2));
2749
2750   coolinghole2shape->Rmin(3) = coolinghole2shape->GetRmin(2);
2751   coolinghole2shape->Rmax(3) = coolinghole2shape->GetRmin(3);
2752   coolinghole2shape->Z(3)    = coolingholeshape->GetZ(2);
2753
2754   TGeoPcon *coolinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2755
2756   coolinghole3shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2757   coolinghole3shape->Rmax(0) = coolinghole3shape->GetRmin(0);
2758   coolinghole3shape->Z(0)    = coolingholeshape->GetZ(1);
2759
2760   coolinghole3shape->Rmax(1) = coolinghole3shape->GetRmax(0);
2761   coolinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2762                                               coolinghole3shape->GetRmax(1));
2763   coolinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2764                                               coolinghole3shape->GetZ(1));
2765
2766   coolinghole3shape->Rmin(2) = kCoolingHoleRmin;
2767   coolinghole3shape->Z(2)    = coolingholeshape->GetZ(3);
2768   coolinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2769                                               coolinghole3shape->GetZ(2));
2770
2771   coolinghole3shape->Rmin(3) = coolinghole3shape->GetRmin(2);
2772   coolinghole3shape->Rmax(3) = coolinghole3shape->GetRmin(3);
2773   coolinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2774                                               coolinghole3shape->GetRmax(3));
2775
2776   //
2777   holePhi = (kMountingHoleWidth/kMountingHoleRmin)*TMath::RadToDeg();
2778
2779   TGeoPcon *mountingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2780
2781   mountingholeshape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2782   mountingholeshape->Rmax(0) = mountingholeshape->GetRmin(0);
2783   mountingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2784                                               mountingholeshape->GetRmin(0));
2785
2786   mountingholeshape->Rmin(1) = kMountingHoleRmin;
2787   mountingholeshape->Rmax(1) = mountingholeshape->GetRmax(0);
2788   mountingholeshape->Z(1)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2789                                               mountingholeshape->GetRmin(1));
2790
2791   mountingholeshape->Rmin(2) = mountingholeshape->GetRmin(1);
2792   mountingholeshape->Rmax(2) = mountingholeshape->GetRmax(1);
2793   mountingholeshape->Z(2)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2794                                               mountingholeshape->GetRmax(2));
2795
2796   mountingholeshape->Rmin(3) = mountingholeshape->GetRmin(2);
2797   mountingholeshape->Rmax(3) = mountingholeshape->GetRmin(3);
2798   mountingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2799                                               mountingholeshape->GetRmax(3));
2800
2801   TGeoPcon *mountinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2802
2803   mountinghole2shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2804   mountinghole2shape->Rmax(0) = mountingholeshape->GetRmin(0);
2805   mountinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2806                                                mountinghole2shape->GetRmin(0));
2807
2808   mountinghole2shape->Rmax(1) = mountinghole2shape->GetRmax(0);
2809   mountinghole2shape->Z(1)    = mountingholeshape->Z(0);
2810   mountinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2811                                                mountinghole2shape->GetZ(1));
2812
2813   mountinghole2shape->Rmin(2) = kMountingHoleRmin;
2814   mountinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2815                                                mountinghole2shape->GetRmin(2));
2816   mountinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2817                                                mountinghole2shape->GetZ(2));
2818
2819   mountinghole2shape->Rmin(3) = mountinghole2shape->Rmin(2);
2820   mountinghole2shape->Rmax(3) = mountinghole2shape->Rmin(3);
2821   mountinghole2shape->Z(3)    = mountingholeshape->Z(1);
2822
2823   TGeoPcon *mountinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2824
2825   mountinghole3shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2826   mountinghole3shape->Rmax(0) = mountingholeshape->GetRmin(0);
2827   mountinghole3shape->Z(0)    = mountingholeshape->GetZ(2);
2828
2829   mountinghole3shape->Rmax(1) = mountinghole3shape->GetRmax(0);
2830   mountinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2831                                                mountinghole3shape->GetRmax(1));
2832   mountinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2833                                                mountinghole3shape->GetZ(1));
2834
2835   mountinghole3shape->Rmin(2) = kMountingHoleRmin;
2836   mountinghole3shape->Z(2)    = mountingholeshape->Z(3);
2837   mountinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2838                                                mountinghole3shape->GetZ(2));
2839
2840   mountinghole3shape->Rmin(3) = mountinghole3shape->Rmin(2);
2841   mountinghole3shape->Rmax(3) = mountinghole3shape->Rmin(3);
2842   mountinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2843                                                mountinghole3shape->GetRmax(3));
2844
2845   // The Cable Hole is even more complicated, a Composite Shape
2846   // is unavoidable here (gosh!)
2847   TGeoPcon *coneshapecopy = new TGeoPcon("conecopy",0.0, 360.0, 12);
2848
2849   for (Int_t i=0; i<12; i++) {
2850     coneshapecopy->Rmin(i) = coneshape->GetRmin(i);
2851     coneshapecopy->Rmax(i) = coneshape->GetRmax(i);
2852     coneshapecopy->Z(i)    = coneshape->GetZ(i);
2853   }
2854
2855   holePhi = (kCableHoleWidth/kCableHoleRout)*TMath::RadToDeg();
2856   TGeoConeSeg *chCS = new TGeoConeSeg("chCS", 0.5*kConeZLength,
2857                                       kCableHoleRin, kCableHoleRout,
2858                                       kCableHoleRin, kCableHoleRout,
2859                                       -0.5*holePhi, 0.5*holePhi);
2860
2861   TGeoCompositeShape *cableholeshape = new TGeoCompositeShape(
2862                                            "SSDCableHoleShape",
2863                                            "conecopy*chCS");
2864
2865   if(GetDebug(1)){
2866     chCS->InspectShape();
2867     cableholeshape->InspectShape();
2868   }
2869
2870   // SSD Cone Wings: Tube and TubeSeg shapes
2871   Double_t angleWideWing, angleWideWingThickness;
2872   angleWideWing = (kWingWidth/kWingRmax)*TMath::RadToDeg();
2873   angleWideWingThickness = (kCFThickness/kWingRmax)*TMath::RadToDeg();
2874
2875   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kConeROuterMax, kWingRmax,
2876                                            kWingHalfThick,
2877                                            0, angleWideWing);
2878
2879   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kConeROuterMax,
2880                                  kWingRmax-kCFThickness,
2881                                  kWingHalfThick-kCFThickness,
2882                                  angleWideWingThickness,
2883                                  angleWideWing-angleWideWingThickness);
2884
2885   // SDD support plate, SSD side (Mounting Bracket): a TubeSeg
2886   TGeoTubeSeg *bracketshape = new TGeoTubeSeg(kBracketRmin, kBracketRmax,
2887                             kBracketHalfLength, -kBracketPhi/2, kBracketPhi/2);
2888
2889
2890   // We have the shapes: now create the real volumes
2891
2892   TGeoVolume *cfcone = new TGeoVolume("SSDCarbonFiberCone",
2893                                       coneshape,medSSDcf);
2894   cfcone->SetVisibility(kTRUE);
2895   cfcone->SetLineColor(4); // Blue
2896   cfcone->SetLineWidth(1);
2897   cfcone->SetFillColor(cfcone->GetLineColor());
2898   cfcone->SetFillStyle(4000); // 0% transparent
2899
2900   TGeoVolume *cfconeinsert = new TGeoVolume("SSDCarbonFiberConeInsert",
2901                                             coneinsertshape,medSSDste);
2902   cfconeinsert->SetVisibility(kTRUE);
2903   cfconeinsert->SetLineColor(2); // Red
2904   cfconeinsert->SetLineWidth(1);
2905   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2906   cfconeinsert->SetFillStyle(4050); // 50% transparent
2907
2908   TGeoVolume *cfconefoam1 = new TGeoVolume("SSDCarbonFiberConeFoam1",
2909                                             conefoam1shape,medSSDroh);
2910   cfconefoam1->SetVisibility(kTRUE);
2911   cfconefoam1->SetLineColor(3); // Green
2912   cfconefoam1->SetLineWidth(1);
2913   cfconefoam1->SetFillColor(cfconefoam1->GetLineColor());
2914   cfconefoam1->SetFillStyle(4050); // 50% transparent
2915
2916   TGeoVolume *cfconefoam2 = new TGeoVolume("SSDCarbonFiberConeFoam2",
2917                                             conefoam2shape,medSSDroh);
2918   cfconefoam2->SetVisibility(kTRUE);
2919   cfconefoam2->SetLineColor(3); // Green
2920   cfconefoam2->SetLineWidth(1);
2921   cfconefoam2->SetFillColor(cfconefoam2->GetLineColor());
2922   cfconefoam2->SetFillStyle(4050); // 50% transparent
2923
2924   TGeoVolume *coolinghole = new TGeoVolume("SSDCoolingHole",
2925                                            coolingholeshape,medSSDair);
2926   coolinghole->SetVisibility(kTRUE);
2927   coolinghole->SetLineColor(5); // Yellow
2928   coolinghole->SetLineWidth(1);
2929   coolinghole->SetFillColor(coolinghole->GetLineColor());
2930   coolinghole->SetFillStyle(4090); // 90% transparent
2931
2932   TGeoVolume *coolinghole2 = new TGeoVolume("SSDCoolingHole2",
2933                                             coolinghole2shape,medSSDair);
2934   coolinghole2->SetVisibility(kTRUE);
2935   coolinghole2->SetLineColor(5); // Yellow
2936   coolinghole2->SetLineWidth(1);
2937   coolinghole2->SetFillColor(coolinghole2->GetLineColor());
2938   coolinghole2->SetFillStyle(4090); // 90% transparent
2939
2940   TGeoVolume *coolinghole3 = new TGeoVolume("SSDCoolingHole3",
2941                                             coolinghole3shape,medSSDair);
2942   coolinghole3->SetVisibility(kTRUE);
2943   coolinghole3->SetLineColor(5); // Yellow
2944   coolinghole3->SetLineWidth(1);
2945   coolinghole3->SetFillColor(coolinghole3->GetLineColor());
2946   coolinghole3->SetFillStyle(4090); // 90% transparent
2947
2948   TGeoVolume *mountinghole = new TGeoVolume("SSDMountingHole",
2949                                             mountingholeshape,medSSDair);
2950   mountinghole->SetVisibility(kTRUE);
2951   mountinghole->SetLineColor(5); // Yellow
2952   mountinghole->SetLineWidth(1);
2953   mountinghole->SetFillColor(mountinghole->GetLineColor());
2954   mountinghole->SetFillStyle(4090); // 90% transparent
2955
2956   TGeoVolume *mountinghole2 = new TGeoVolume("SSDMountingHole2",
2957                                              mountinghole2shape,medSSDair);
2958   mountinghole2->SetVisibility(kTRUE);
2959   mountinghole2->SetLineColor(5); // Yellow
2960   mountinghole2->SetLineWidth(1);
2961   mountinghole2->SetFillColor(mountinghole2->GetLineColor());
2962   mountinghole2->SetFillStyle(4090); // 90% transparent
2963
2964   TGeoVolume *mountinghole3 = new TGeoVolume("SSDMountingHole3",
2965                                              mountinghole3shape,medSSDair);
2966   mountinghole3->SetVisibility(kTRUE);
2967   mountinghole3->SetLineColor(5); // Yellow
2968   mountinghole3->SetLineWidth(1);
2969   mountinghole3->SetFillColor(mountinghole3->GetLineColor());
2970   mountinghole3->SetFillStyle(4090); // 90% transparent
2971
2972   TGeoVolume *wing = new TGeoVolume("SSDWing",wingshape,medSSDcf);
2973   wing->SetVisibility(kTRUE);
2974   wing->SetLineColor(4); // Blue
2975   wing->SetLineWidth(1);
2976   wing->SetFillColor(wing->GetLineColor());
2977   wing->SetFillStyle(4000); // 0% transparent
2978
2979   TGeoVolume *cablehole = new TGeoVolume("SSDCableHole",
2980                                          cableholeshape,medSSDair);
2981   cablehole->SetVisibility(kTRUE);
2982   cablehole->SetLineColor(5); // Yellow
2983   cablehole->SetLineWidth(1);
2984   cablehole->SetFillColor(cablehole->GetLineColor());
2985   cablehole->SetFillStyle(4090); // 90% transparent
2986
2987   TGeoVolume *winginsert = new TGeoVolume("SSDWingInsert",
2988                                           winginsertshape,medSSDste);
2989   winginsert->SetVisibility(kTRUE);
2990   winginsert->SetLineColor(2); // Red
2991   winginsert->SetLineWidth(1);
2992   winginsert->SetFillColor(winginsert->GetLineColor());
2993   winginsert->SetFillStyle(4050); // 50% transparent
2994
2995   TGeoVolume *bracket = new TGeoVolume("SSDMountingBracket",
2996                                        bracketshape,medSSDal);
2997   bracket->SetVisibility(kTRUE);
2998   bracket->SetLineColor(6); // Purple
2999   bracket->SetLineWidth(1);
3000   bracket->SetFillColor(bracket->GetLineColor());
3001   bracket->SetFillStyle(4000); // 0% transparent
3002
3003   // Mount up a cone
3004   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
3005     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
3006     cfconefoam2->AddNode(mountinghole,i+1, new TGeoRotation("", phiH, 0, 0));
3007   }
3008
3009   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
3010     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
3011     cfconeinsert->AddNodeOverlap(coolinghole,i+1, new TGeoRotation("", phiH, 0, 0));
3012   }
3013
3014   cfconeinsert->AddNode(cfconefoam1,1,0);
3015   cfconeinsert->AddNode(cfconefoam2,1,0);
3016
3017   cfcone->AddNode(cfconeinsert,1,0);
3018
3019   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
3020     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
3021     cfcone->AddNode(coolinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
3022     cfcone->AddNode(coolinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
3023     cfcone->AddNodeOverlap(cablehole,i+1, new TGeoRotation("", phiH, 0, 0));
3024   }
3025
3026   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
3027     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
3028     cfcone->AddNode(mountinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
3029     cfcone->AddNode(mountinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
3030   }
3031
3032   wing->AddNode(winginsert,1,0);
3033
3034   // Add all volumes in the Cone assembly
3035   vC->AddNode(cfcone,1,new TGeoTranslation(0,0,-kConeZPosition));
3036
3037   for (Int_t i=0; i<4; i++) {
3038     Double_t thetaW = kThetaWing + 90.*i + angleWideWing/2.;
3039     vC->AddNode(wing, i+1, new TGeoCombiTrans(0, 0, -kConeZPosition+kWingHalfThick,
3040                            new TGeoRotation("",thetaW,180,0)));
3041   }
3042
3043   Double_t zBracket = kConeZPosition - coneshape->GetZ(9) +
3044                       2*bracketshape->GetDz();
3045   for (Int_t i=0; i<3; i++) {
3046     Double_t thetaB = 60 + 120.*i;
3047     vC->AddNode(bracket, i+1, new TGeoCombiTrans(0, 0, -zBracket,
3048                               new TGeoRotation("",thetaB,0,0)));
3049   }
3050
3051   // Finally put everything in the mother volume
3052   moth->AddNode(cfcylinder,1,0);
3053
3054   moth->AddNode(vC, 1, 0 );
3055   moth->AddNode(vC, 2, new TGeoRotation("",180, 180, 0) );
3056
3057   // Some debugging if requested
3058   if(GetDebug(1)){
3059     vC->PrintNodes();
3060     vC->InspectShape();
3061   }
3062
3063   return;
3064 }
3065
3066 //______________________________________________________________________
3067 void AliITSv11GeometrySupport::ServicesCableSupport(TGeoVolume *moth,
3068                                                     TGeoManager *mgr){
3069 //
3070 // Creates the cable trays which are outside the ITS support cones
3071 // but still inside the TPC
3072 // This is now a stearing routine, the actual work is done by three
3073 // specialized methods to avoid a really huge unique method
3074 //
3075 // Input:
3076 //         moth : the TGeoVolume owing the volume structure
3077 //         mgr  : the GeoManager (default gGeoManager)
3078 // Output:
3079 //
3080 // Created:      15 Nov 2009  Mario Sitta
3081 //
3082
3083   TraySupportsSideA(moth, mgr);
3084
3085   ServicesCableSupportSPD(moth, mgr);
3086   ServicesCableSupportSDD(moth, mgr);
3087   ServicesCableSupportSSD(moth, mgr);
3088
3089   return;
3090 }
3091
3092 //______________________________________________________________________
3093 void AliITSv11GeometrySupport::TraySupportsSideA(TGeoVolume *moth,
3094                                            const TGeoManager *mgr){
3095 //
3096 // Creates the structure supporting the ITS cable trays on Side A
3097 //
3098 // Input:
3099 //         moth : the TGeoVolume owing the volume structure
3100 //         mgr  : the GeoManager (default gGeoManager)
3101 // Output:
3102 //
3103 // Created:      14 Dec 2009  Mario Sitta
3104 // Updated:      26 Feb 2010  Mario Sitta
3105 //
3106 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
3107 // drawings and other (oral) information given by F.Tosello
3108 //
3109
3110   // Dimensions and positions of the A-Side Cable Tray Support Ring
3111   // (0872/G/A/01)
3112   const Double_t kSuppRingYTrans      =  110.00 *fgkmm;
3113   const Double_t kSuppRingZTrans      =(1011.00+435.00) *fgkmm;
3114   const Double_t kSuppForwYTrans      =  185.00 *fgkmm;
3115
3116   const Double_t kExtSuppRingSpace1   =   33.00 *fgkmm;
3117   const Double_t kExtSuppRingSpace2   =   45.00 *fgkmm;
3118   const Double_t kExtSuppRingSpcAbov  =   30.00 *fgkmm;
3119   const Double_t kExtSuppRingBase     =  491.50 *fgkmm;
3120   const Double_t kExtSuppRingInward   =   35.00 *fgkmm;
3121   const Double_t kExtSuppRingRmax     =  540.00 *fgkmm;
3122   const Double_t kExtSuppRingRint1    =  465.00 *fgkmm;
3123   const Double_t kExtSuppRingRint2    =  467.00 *fgkmm;
3124   const Double_t kExtSuppRingInnerHi  =  450.00 *fgkmm;
3125   const Double_t kExtSuppRingInWide   =  100.00 *fgkmm;
3126   const Double_t kExtSuppRingR7       =    7.00 *fgkmm;
3127   const Double_t kExtSuppRingR5       =    5.00 *fgkmm;
3128   const Double_t kExtSuppRingThick    =   20.00 *fgkmm;
3129
3130   const Double_t kExtSuppRingSpcAng   =   10.50 *TMath::DegToRad();
3131   const Double_t kExtSuppRingPartPhi  =   15.00 *TMath::DegToRad();
3132   const Double_t kExtSuppRingIntAng   =    7.00 *TMath::DegToRad();
3133   const Double_t kExtSuppRingBaseAng  =   75.00 *TMath::DegToRad();
3134   const Double_t kExtSuppRingR7Ang    =  100.00 *TMath::DegToRad(); // Guessed
3135
3136   const Int_t    kExtSuppRingNPtsArc  =   10; // N.points to approximate arc
3137
3138   const Double_t kIntSuppRingThick1   =   15.00 *fgkmm;
3139   const Double_t kIntSuppRingThick2   =   13.00 *fgkmm;
3140   const Double_t kIntSuppRingInward   =   24.00 *fgkmm;
3141   const Double_t kIntSuppRingThick    =   20.00 *fgkmm;
3142
3143   const Double_t kSuppCylHeight       =  340.00 *fgkmm;
3144   const Double_t kSuppCylRint         =  475.00 *fgkmm;
3145   const Double_t kSuppCylRext         =  478.00 *fgkmm;
3146   const Double_t kSuppCylDispl        =  137.70 *fgkmm;
3147
3148   const Double_t kSuppSpacerHeight    =   30.00 *fgkmm;
3149   const Double_t kSuppSpacerThick     =   10.00 *fgkmm;
3150
3151   const Double_t kSuppSpacerAngle     =   15.00;  // Degrees
3152
3153   const Double_t kSuppForwRingRint1   =  500.00 *fgkmm;
3154   const Double_t kSuppForwRingRint2   =  540.00 *fgkmm;
3155   const Double_t kSuppForwRingRext    =  560.00 *fgkmm;
3156   const Double_t kSuppForwRingThikAll =   50.00 *fgkmm;
3157   const Double_t kSuppForwRingThikInt =   20.00 *fgkmm;
3158
3159   // (0872/G/B/01)
3160   const Double_t kSuppForwConeRmin    =  558.00 *fgkmm;
3161   const Double_t kSuppForwConeRmax    =  681.00 *fgkmm;
3162   const Double_t kSuppForwConeLen1    =  318.00 *fgkmm;
3163   const Double_t kSuppForwConeLen2    =  662.00 *fgkmm;
3164   const Double_t kSuppForwConeThick   =    3.00 *fgkmm;
3165
3166   const Double_t kSuppBackRingPlacTop =   90.00 *fgkmm;
3167   const Double_t kSuppBackRingPlacSid =   50.00 *fgkmm;
3168   const Double_t kSuppBackRingHeight  =  760.00 *fgkmm;
3169   const Double_t kSuppBackRingRext    =  760.00 *fgkmm;
3170   const Double_t kSuppBackRingRint    =  685.00 *fgkmm;
3171 //  const Double_t kSuppBackRingRint2   =  675.00 *fgkmm;
3172   const Double_t kSuppBackRingR10     =   10.00 *fgkmm;
3173   const Double_t kSuppBackRingBase    =  739.00 *fgkmm;
3174   const Double_t kSuppBackRingThikAll =   50.00 *fgkmm;
3175   const Double_t kSuppBackRingThick1  =   20.00 *fgkmm;
3176   const Double_t kSuppBackRingThick2  =   20.00 *fgkmm;
3177
3178 //  const Double_t kSuppBackRingPlacAng =   10.00 *TMath::DegToRad();
3179   const Double_t kSuppBackRingPlacAng =   10.25 *TMath::DegToRad();//Fix ovlp.
3180   const Double_t kSuppBackRing2ndAng1 =   78.40 *TMath::DegToRad();
3181   const Double_t kSuppBackRing2ndAng2 =   45.00 *TMath::DegToRad();
3182
3183   const Int_t    kSuppBackRingNPtsArc =   10; // N.points to approximate arc
3184
3185   // (0872/G/C/01)
3186   const Double_t kRearSuppZTransGlob  =(1011.00+9315.00-6040.00) *fgkmm;
3187   const Double_t kBackRodZTrans       = 2420.00 *fgkmm;
3188
3189   const Double_t kBackRodLength       = 1160.00 *fgkmm;
3190   const Double_t kBackRodThickLen     =   20.00 *fgkmm;
3191   const Double_t kBackRodDiameter     =   20.00 *fgkmm;
3192
3193   const Double_t kSuppRearRingRint    =  360.00 *fgkmm;
3194   const Double_t kSuppRearRingRext1   =  410.00 *fgkmm;
3195   const Double_t kSuppRearRingRext2   =  414.00 *fgkmm;
3196   const Double_t kSuppRearRingHeight  =  397.00 *fgkmm;
3197   const Double_t kSuppRearRingTopWide =  111.87 *fgkmm;
3198   const Double_t kSuppRearRingBase    =  451.50 *fgkmm;
3199   const Double_t kSuppRearRingBaseHi  =   58.00 *fgkmm;
3200   const Double_t kSuppRearRingSideHi  =   52.00 *fgkmm;
3201   const Double_t kSuppRearRingInside  =   40.00 *fgkmm;
3202   const Double_t kSuppRearRingInsideHi=   12.00 *fgkmm;
3203   const Double_t kSuppRearRingThick   =   20.00 *fgkmm;
3204   const Double_t kSuppRearRingXRodHole=  441.50 *fgkmm;
3205   const Double_t kSuppRearRingYRodHole=   42.00 *fgkmm;
3206
3207   const Double_t kSuppRearRing1stAng  =   22.00 *TMath::DegToRad();
3208   const Double_t kSuppRearRingStepAng =   15.00 *TMath::DegToRad();
3209
3210   const Int_t    kSuppRearRingNPtsArc =   10; // N.points to approximate arc
3211
3212
3213   // Local variables
3214   Double_t xprof[2*(15+kExtSuppRingNPtsArc)],yprof[2*(15+kExtSuppRingNPtsArc)];
3215   Double_t slp1, slp2, phi, xm, ym;
3216   Double_t xloc, yloc, zloc, rmin, rmax, deltaR;
3217   Int_t npoints;
3218
3219
3220   // The whole support as an assembly
3221   TGeoVolumeAssembly *trayASuppStruct = new TGeoVolumeAssembly("ITSsuppSideAStructure");
3222   
3223
3224   // First create all needed shapes
3225
3226   // The External Ring (part of 0872/G/A/01): a really complex Xtru
3227   TGeoXtru *extSuppRing = new TGeoXtru(2);
3228
3229   // First the upper notch...
3230   xprof[ 0] = kExtSuppRingSpace1;
3231   yprof[ 0] = kExtSuppRingInnerHi + kExtSuppRingSpcAbov;
3232
3233   slp1 = TMath::Tan(TMath::Pi()/2 - kExtSuppRingSpcAng);
3234   IntersectCircle(slp1, xprof[0], yprof[0], kExtSuppRingRmax, 0., 0.,
3235                   xprof[5], yprof[5], xm, ym); // Ignore dummy xm,ym
3236
3237   xprof[ 4] = xprof[5];
3238   yprof[ 4] = yprof[5] - kExtSuppRingR5/TMath::Tan(kExtSuppRingSpcAng);
3239   xprof[ 3] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/6));
3240   yprof[ 3] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/6));
3241   xprof[ 2] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/3));
3242   yprof[ 2] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/3));
3243   xprof[ 1] = xprof[4] - kExtSuppRingR5;
3244   yprof[ 1] = yprof[4] - kExtSuppRingR5;
3245
3246   Int_t indx = 5+kExtSuppRingNPtsArc;
3247   // ...then the external arc, approximated with segments,...
3248   xprof[indx] = kExtSuppRingBase;
3249   yprof[indx] = TMath::Sqrt(kExtSuppRingRmax*kExtSuppRingRmax -
3250                             kExtSuppRingBase*kExtSuppRingBase);
3251   Double_t alphamin = TMath::ASin(kExtSuppRingSpace2/kExtSuppRingRmax);
3252   Double_t alphamax = TMath::Pi()/2 -
3253                     TMath::ASin(yprof[5+kExtSuppRingNPtsArc]/kExtSuppRingRmax);
3254
3255   for (Int_t jp = 1; jp < kExtSuppRingNPtsArc; jp++) {
3256     Double_t alpha = jp*(alphamax-alphamin)/kExtSuppRingNPtsArc;
3257     xprof[5+jp] = kExtSuppRingRmax*TMath::Sin(alpha);
3258     yprof[5+jp] = kExtSuppRingRmax*TMath::Cos(alpha);
3259   }
3260   // ...and finally the interior profile
3261   xprof[indx+1] = kExtSuppRingBase;
3262   yprof[indx+1] = kSuppRingYTrans;
3263   xprof[indx+2] = xprof[indx+1] - kExtSuppRingInward;
3264   yprof[indx+2] = yprof[indx+1];
3265
3266   phi  = TMath::Pi()/2 - 4*kExtSuppRingPartPhi - kExtSuppRingIntAng;
3267   slp1 = TMath::Tan(TMath::Pi() - kExtSuppRingBaseAng);
3268   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3269   xm   = kExtSuppRingRint2*TMath::Cos(phi);
3270   ym   = kExtSuppRingRint2*TMath::Sin(phi);
3271   IntersectLines(slp1, xprof[indx+2], yprof[indx+2], slp2, xm, ym,
3272                  xprof[indx+3], yprof[indx+3]);
3273
3274   slp1 = slp2;
3275   phi += kExtSuppRingPartPhi;
3276   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3277   xm   = kExtSuppRingRint1*TMath::Cos(phi);
3278   ym   = kExtSuppRingRint1*TMath::Sin(phi);
3279   IntersectLines(slp1, xprof[indx+3], yprof[indx+3], slp2, xm, ym,
3280                  xprof[indx+4], yprof[indx+4]);
3281   
3282   slp1 = slp2;
3283   phi += kExtSuppRingPartPhi;
3284   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3285   xm   = kExtSuppRingRint2*TMath::Cos(phi);
3286   ym   = kExtSuppRingRint2*TMath::Sin(phi);
3287   IntersectLines(slp1, xprof[indx+4], yprof[indx+4], slp2, xm, ym,
3288                  xprof[indx+5], yprof[indx+5]);
3289   
3290   slp1 = slp2;
3291   phi += kExtSuppRingPartPhi;
3292   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3293   xm   = kExtSuppRingRint1*TMath::Cos(phi);
3294   ym   = kExtSuppRingRint1*TMath::Sin(phi);
3295   IntersectLines(slp1, xprof[indx+5], yprof[indx+5], slp2, xm, ym,
3296                  xprof[indx+6], yprof[indx+6]);
3297   
3298   xprof[indx+9] = kExtSuppRingInWide;
3299   yprof[indx+9] = kExtSuppRingInnerHi;
3300   xprof[indx+8] = xprof[indx+9] +
3301                   (1 - TMath::Cos(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
3302   yprof[indx+8] = yprof[indx+9] +
3303                   (    TMath::Sin(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
3304   xprof[indx+7] = xprof[indx+9] +
3305                   (1 + TMath::Cos(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
3306   yprof[indx+7] = yprof[indx+9] +
3307                   (    TMath::Sin(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
3308   // Gosh, we did the right side! now reflex on the left side
3309   npoints = (sizeof(xprof)/sizeof(Double_t))/2;
3310   for (Int_t jp = 0; jp < npoints; jp++) {
3311     xprof[npoints+jp] = -xprof[npoints-1-jp];
3312     yprof[npoints+jp] =  yprof[npoints-1-jp];
3313   }
3314   // wow! now the actual Xtru
3315   extSuppRing->DefinePolygon(2*npoints, xprof, yprof);
3316   extSuppRing->DefineSection(0,0);
3317   extSuppRing->DefineSection(1,kExtSuppRingThick);
3318
3319   // The Internal Ring (part of 0872/G/A/01): another complex Xtru
3320   TGeoXtru *intSuppRing = new TGeoXtru(2);
3321
3322   // First the external profile...
3323   npoints = 0;
3324
3325   slp1 = 0;
3326   phi  = TMath::Pi()/2 - kExtSuppRingPartPhi - kExtSuppRingIntAng;
3327   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3328   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
3329   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
3330   IntersectLines(slp1,  0, kExtSuppRingInnerHi+kExtSuppRingSpcAbov,
3331                  slp2, xm, ym,
3332                  xprof[npoints], yprof[npoints]);
3333   npoints++;
3334
3335   slp1 = slp2;
3336   phi -= kExtSuppRingPartPhi;
3337   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3338   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
3339   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
3340   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3341                  slp2, xm, ym,
3342                  xprof[npoints], yprof[npoints]);
3343   npoints++;
3344
3345   slp1 = slp2;
3346   phi -= kExtSuppRingPartPhi;
3347   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3348   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
3349   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
3350   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3351                  slp2, xm, ym,
3352                  xprof[npoints], yprof[npoints]);
3353   npoints++;
3354
3355   slp1 = slp2;
3356   phi -= kExtSuppRingPartPhi;
3357   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3358   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
3359   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
3360   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3361                  slp2, xm, ym,
3362                  xprof[npoints], yprof[npoints]);
3363   npoints++;
3364
3365   xprof[npoints] = kExtSuppRingBase-kIntSuppRingInward;
3366   yprof[npoints] = Yfrom2Points(xprof[npoints-1], yprof[npoints-1], xm, ym,
3367                                 xprof[npoints]);
3368   npoints++;
3369
3370   xprof[npoints] = xprof[npoints-1];
3371   yprof[npoints] = kSuppRingYTrans;
3372   npoints++;
3373   // ...and then the interior profile, which is identical to extSuppRing one
3374   for (Int_t jp=0; jp < 8; jp++) {
3375     xprof[npoints] = extSuppRing->GetX(17+jp);
3376     yprof[npoints] = extSuppRing->GetY(17+jp);
3377     npoints++;
3378   }
3379   // We did the right side! now reflex on the left side
3380   for (Int_t jp = 0; jp < npoints; jp++) {
3381     xprof[npoints+jp] = -xprof[npoints-1-jp];
3382     yprof[npoints+jp] =  yprof[npoints-1-jp];
3383   }
3384   // And now the actual Xtru
3385   intSuppRing->DefinePolygon(2*npoints, xprof, yprof);
3386   intSuppRing->DefineSection(0,0);
3387   intSuppRing->DefineSection(1,kIntSuppRingThick);
3388
3389   // The intermediate cylinder (0872/G/A/03): a TubeSeg
3390   alphamin = TMath::ASin(kSuppCylDispl/kSuppCylRint)*TMath::RadToDeg();
3391   alphamax = 180 - alphamin;
3392   TGeoTubeSeg *interCylind = new TGeoTubeSeg(kSuppCylRint, kSuppCylRext,
3393                                      kSuppCylHeight/2, alphamin, alphamax);
3394
3395   // The spacer (0872/G/A/03): a simple Xtru
3396   TGeoXtru *suppSpacer = new TGeoXtru(2);
3397
3398   xprof[0] = kSuppSpacerHeight;
3399   yprof[0] = kSuppSpacerThick;
3400   xprof[1] = xprof[0];
3401   yprof[1] = 0;
3402   xprof[2] = 0;
3403   yprof[2] = 0;
3404   xprof[3] = kSuppSpacerThick*SinD(kSuppSpacerAngle);
3405   yprof[3] = yprof[0];
3406
3407   suppSpacer->DefinePolygon(4, xprof, yprof);
3408   suppSpacer->DefineSection(0,-kSuppCylHeight/2);
3409   suppSpacer->DefineSection(1, kSuppCylHeight/2);
3410
3411   // The forward ring (0872/G/B/02): a Pcon (slight oversimplification)
3412   Double_t rmean = (kSuppForwRingRint1+kSuppForwRingRext)/2;
3413   alphamin = TMath::ASin(kSuppForwYTrans/rmean)*TMath::RadToDeg();
3414   alphamax = 180 - alphamin;
3415
3416   TGeoPcon *forwardRing = new TGeoPcon(alphamin,alphamax-alphamin,4);
3417
3418   forwardRing->DefineSection(0,0,
3419                              kSuppForwRingRint1,kSuppForwRingRext);
3420   forwardRing->DefineSection(1,kSuppForwRingThikInt,
3421                              kSuppForwRingRint1,kSuppForwRingRext);
3422   forwardRing->DefineSection(2,kSuppForwRingThikInt,
3423                              kSuppForwRingRint2,kSuppForwRingRext);
3424   forwardRing->DefineSection(3,kSuppForwRingThikAll,
3425                              kSuppForwRingRint2,kSuppForwRingRext);
3426
3427   // The forward cone (0872/G/B/03): a TGeoPcon
3428   TGeoPcon *forwardCone = new TGeoPcon(alphamin,alphamax-alphamin,3);
3429
3430   forwardCone->DefineSection(0,0,
3431                              kSuppForwConeRmin-kSuppForwConeThick,
3432                              kSuppForwConeRmin);
3433   forwardCone->DefineSection(1,kSuppForwConeLen1,
3434                              kSuppForwConeRmin-kSuppForwConeThick,
3435                              kSuppForwConeRmin);
3436   forwardCone->DefineSection(2,kSuppForwConeLen1+kSuppForwConeLen2,
3437                              kSuppForwConeRmax-kSuppForwConeThick,
3438                              kSuppForwConeRmax);
3439
3440   // The first part of the Back Ring (part of 0872/G/B/01): a complex Xtru
3441   TGeoXtru *firstSuppBackRing = new TGeoXtru(2);
3442
3443   // First the external profile... (the arc is approximated with segments)
3444   npoints = 0;
3445
3446   xprof[npoints] = kSuppBackRingPlacTop;
3447   yprof[npoints] = kSuppBackRingHeight;
3448   npoints++;
3449
3450   alphamax = TMath::Pi()/2 - TMath::ASin(kSuppBackRingPlacTop/kSuppBackRingRext);
3451   alphamin = TMath::ASin((kSuppForwYTrans+kSuppBackRingPlacSid)/kSuppBackRingRext);
3452
3453   xprof[npoints] = xprof[npoints-1];
3454   yprof[npoints] = kSuppBackRingRext*TMath::Sin(alphamax);
3455   npoints++;
3456
3457   for (Int_t jp = 1; jp <= kSuppBackRingNPtsArc; jp++) {
3458     Double_t alpha = alphamax - jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
3459     xprof[npoints] = kSuppBackRingRext*TMath::Cos(alpha);
3460     yprof[npoints] = kSuppBackRingRext*TMath::Sin(alpha);
3461     npoints++;
3462   }
3463
3464   xprof[npoints] = kSuppBackRingBase -
3465                    kSuppBackRingPlacSid*TMath::Tan(kSuppBackRingPlacAng);
3466   yprof[npoints] = yprof[npoints-1];
3467   npoints++;
3468
3469   xprof[npoints] = kSuppBackRingBase;
3470   yprof[npoints] = kSuppForwYTrans;
3471   npoints++;
3472   // ...then the internal profile (the arc is approximated with segments)
3473   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint);
3474   alphamax = TMath::Pi()/2;
3475
3476   for (Int_t jp = 0; jp < kSuppBackRingNPtsArc; jp++) {
3477     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
3478     xprof[npoints] = kSuppBackRingRint*TMath::Cos(alpha);
3479     yprof[npoints] = kSuppBackRingRint*TMath::Sin(alpha);
3480     npoints++;
3481   }
3482
3483   xprof[npoints] = 0;
3484   yprof[npoints] = kSuppBackRingRint;
3485   npoints++;
3486   // We did the right side! now reflex on the left side (except last point)
3487   for (Int_t jp = 0; jp < npoints-1; jp++) {
3488     xprof[npoints+jp] = -xprof[npoints-jp-2];
3489     yprof[npoints+jp] =  yprof[npoints-jp-2];
3490   }
3491   // And now the actual Xtru
3492   firstSuppBackRing->DefinePolygon(2*npoints-1, xprof, yprof);
3493   firstSuppBackRing->DefineSection(0,0);
3494   firstSuppBackRing->DefineSection(1,kSuppBackRingThick1);
3495
3496   // The second part of the Back Ring (part of 0872/G/B/01): a Pcon
3497   // (slight oversimplification)
3498   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint)*TMath::RadToDeg();
3499   alphamax = 180 - alphamin;
3500
3501   TGeoPcon *secondSuppBackRing = new TGeoPcon(alphamin,alphamax-alphamin,6);
3502
3503   deltaR = kSuppBackRingThick2/TMath::Sin(kSuppBackRing2ndAng1);
3504   rmin = kSuppBackRingRint - kSuppBackRingThick1/TMath::Tan(kSuppBackRing2ndAng1);
3505   rmax = rmin + deltaR + kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
3506   secondSuppBackRing->DefineSection(0, 0, rmin, rmax);
3507
3508   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1/3));
3509   rmax -= kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1/3);
3510   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3511   secondSuppBackRing->DefineSection(1, zloc, rmin, rmax);
3512
3513   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1*2/3));
3514   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1*2/3);
3515   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3516   secondSuppBackRing->DefineSection(2, zloc, rmin, rmax);
3517
3518   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1));
3519   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
3520   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3521   secondSuppBackRing->DefineSection(3, zloc, rmin, rmax);
3522
3523   slp1 = TMath::Tan(kSuppBackRing2ndAng2);
3524   slp2 = TMath::Tan(TMath::Pi()/2 + kSuppBackRing2ndAng1);
3525   IntersectLines(-slp1,kSuppBackRingThikAll,deltaR/2,
3526                   slp2,kSuppBackRingThikAll,deltaR,
3527                   xm, ym);
3528
3529   zloc = xm - kSuppBackRingThick1;
3530   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3531   rmax = rmin + deltaR;
3532   secondSuppBackRing->DefineSection(4, zloc, rmin, rmax);
3533
3534   zloc = kSuppBackRingThikAll - kSuppBackRingThick1;
3535   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3536   rmax = rmin + deltaR/2;
3537   secondSuppBackRing->DefineSection(5, zloc, rmin, rmax);
3538
3539   // The supporting rod: a Tube
3540   TGeoTube *suppRod = new TGeoTube(0, kBackRodDiameter/2,
3541                                    (kBackRodLength - kBackRodThickLen)/2);
3542
3543   // The Back Ring (0872/G/C/01): another complex Xtru
3544   TGeoXtru *suppRearRing = new TGeoXtru(2);
3545
3546   // First the external profile...
3547   npoints = 0;
3548
3549   xprof[npoints] = kSuppRearRingTopWide;
3550   yprof[npoints] = kSuppRearRingHeight;
3551   npoints++;
3552
3553   phi = kSuppRearRing1stAng;
3554   slp1 = TMath::Tan(TMath::Pi() - phi);
3555   phi += kSuppRearRingStepAng;
3556   slp2 = TMath::Tan(TMath::Pi() - phi);
3557   xm = kSuppRearRingRext2*TMath::Sin(phi);
3558   ym = kSuppRearRingRext2*TMath::Cos(phi);
3559   IntersectLines(slp1, kSuppRearRingTopWide, kSuppRearRingHeight,
3560                  slp2, xm, ym,
3561                  xprof[npoints], yprof[npoints]);
3562   npoints++;
3563
3564   slp1 = slp2;
3565   phi += kSuppRearRingStepAng;
3566   slp2 = TMath::Tan(TMath::Pi() - phi);
3567   xm = kSuppRearRingRext1*TMath::Sin(phi);
3568   ym = kSuppRearRingRext1*TMath::Cos(phi);
3569   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3570                  slp2, xm, ym,
3571                  xprof[npoints], yprof[npoints]);
3572   npoints++;
3573
3574   slp1 = slp2;
3575   phi += kSuppRearRingStepAng;
3576   slp2 = TMath::Tan(TMath::Pi() - phi);
3577   xm = kSuppRearRingRext2*TMath::Sin(phi);
3578   ym = kSuppRearRingRext2*TMath::Cos(phi);
3579   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3580                  slp2, xm, ym,
3581                  xprof[npoints], yprof[npoints]);
3582   npoints++;
3583
3584   slp1 = slp2;
3585   slp2 = 0;
3586   xm = kSuppRearRingBase;
3587   ym = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3588   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3589                  slp2, xm, ym,
3590                  xprof[npoints], yprof[npoints]);
3591   npoints++;
3592
3593   xprof[npoints] = kSuppRearRingBase;
3594   yprof[npoints] = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3595   npoints++;
3596   xprof[npoints] = xprof[npoints - 1];
3597   yprof[npoints] = kSuppRearRingBaseHi;
3598   npoints++;
3599   xprof[npoints] = xprof[npoints - 1] - kSuppRearRingInside;
3600   yprof[npoints] = yprof[npoints - 1];
3601   npoints++;
3602   xprof[npoints] = xprof[npoints - 1];
3603   yprof[npoints] = yprof[npoints - 1] + kSuppRearRingInsideHi;
3604   npoints++;
3605   // ...then the internal arc, approximated with segments,...
3606   xprof[npoints] = kSuppRearRingRint;
3607   yprof[npoints] = yprof[npoints - 1];
3608
3609   alphamin = TMath::ASin(kSuppRearRingBaseHi/kSuppRearRingRint);
3610   alphamax = TMath::Pi()/2;
3611
3612   for (Int_t jp = 1; jp < kSuppRearRingNPtsArc; jp++) {
3613     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppRearRingNPtsArc;
3614     xprof[npoints+jp] = kSuppRearRingRint*TMath::Cos(alpha);
3615     yprof[npoints+jp] = kSuppRearRingRint*TMath::Sin(alpha);
3616   }
3617
3618   xprof[npoints+kSuppRearRingNPtsArc] = 0;
3619   yprof[npoints+kSuppRearRingNPtsArc] = kSuppRearRingRint;
3620   // We did the right side! now reflex on the left side
3621   Int_t nTotalPoints = npoints+kSuppRearRingNPtsArc;
3622   for (Int_t jp = 0; jp < nTotalPoints; jp++) {
3623     xprof[nTotalPoints+1+jp] = -xprof[nTotalPoints-1-jp];
3624     yprof[nTotalPoints+1+jp] =  yprof[nTotalPoints-1-jp];
3625   }
3626
3627   // And now the actual Xtru
3628   suppRearRing->DefinePolygon(2*nTotalPoints+1, xprof, yprof);
3629   suppRearRing->DefineSection(0,0);
3630   suppRearRing->DefineSection(1,kSuppRearRingThick);
3631
3632
3633   // We have all shapes: now create the real volumes
3634   TGeoMedium *medAl = mgr->GetMedium("ITS_ANTICORODAL$");
3635
3636   TGeoVolume *sideAExtSuppRing = new TGeoVolume("ITSsuppSideAExtSuppRing",
3637                                                  extSuppRing, medAl);
3638
3639   sideAExtSuppRing->SetVisibility(kTRUE);
3640   sideAExtSuppRing->SetLineColor(kMagenta+1);
3641   sideAExtSuppRing->SetLineWidth(1);
3642   sideAExtSuppRing->SetFillColor(sideAExtSuppRing->GetLineColor());
3643   sideAExtSuppRing->SetFillStyle(4000); // 0% transparent
3644
3645   TGeoVolume *sideAIntSuppRing = new TGeoVolume("ITSsuppSideAIntSuppRing",
3646                                                  intSuppRing, medAl);
3647
3648   sideAIntSuppRing->SetVisibility(kTRUE);
3649   sideAIntSuppRing->SetLineColor(kMagenta+1);
3650   sideAIntSuppRing->SetLineWidth(1);
3651   sideAIntSuppRing->SetFillColor(sideAIntSuppRing->GetLineColor());
3652   sideAIntSuppRing->SetFillStyle(4000); // 0% transparent
3653
3654   TGeoVolume *sideASuppCyl = new TGeoVolume("ITSsuppSideASuppCyl",
3655                                             interCylind, medAl);
3656
3657   sideASuppCyl->SetVisibility(kTRUE);
3658   sideASuppCyl->SetLineColor(kMagenta+1);
3659   sideASuppCyl->SetLineWidth(1);
3660   sideASuppCyl->SetFillColor(sideASuppCyl->GetLineColor());
3661   sideASuppCyl->SetFillStyle(4000); // 0% transparent
3662
3663   TGeoVolume *sideASuppSpacer = new TGeoVolume("ITSsuppSideASuppSpacer",
3664                                                suppSpacer, medAl);
3665
3666   sideASuppSpacer->SetVisibility(kTRUE);
3667   sideASuppSpacer->SetLineColor(kMagenta+1);
3668   sideASuppSpacer->SetLineWidth(1);
3669   sideASuppSpacer->SetFillColor(sideASuppSpacer->GetLineColor());
3670   sideASuppSpacer->SetFillStyle(4000); // 0% transparent
3671
3672   TGeoVolume *sideASuppForwRing = new TGeoVolume("ITSsuppSideASuppForwRing",
3673                                                  forwardRing, medAl);
3674
3675   sideASuppForwRing->SetVisibility(kTRUE);
3676   sideASuppForwRing->SetLineColor(kMagenta+1);
3677   sideASuppForwRing->SetLineWidth(1);
3678   sideASuppForwRing->SetFillColor(sideASuppForwRing->GetLineColor());
3679   sideASuppForwRing->SetFillStyle(4000); // 0% transparent
3680
3681   TGeoVolume *sideASuppForwCone = new TGeoVolume("ITSsuppSideASuppForwCone",
3682                                                  forwardCone, medAl);
3683
3684   sideASuppForwCone->SetVisibility(kTRUE);
3685   sideASuppForwCone->SetLineColor(kMagenta+1);
3686   sideASuppForwCone->SetLineWidth(1);
3687   sideASuppForwCone->SetFillColor(sideASuppForwCone->GetLineColor());
3688   sideASuppForwCone->SetFillStyle(4000); // 0% transparent
3689
3690   TGeoVolume *sideAFirstSuppBackRing = new TGeoVolume("ITSsuppSideAFirstSuppBackRing",
3691                                                      firstSuppBackRing, medAl);
3692
3693   sideAFirstSuppBackRing->SetVisibility(kTRUE);
3694   sideAFirstSuppBackRing->SetLineColor(kMagenta+1);
3695   sideAFirstSuppBackRing->SetLineWidth(1);
3696   sideAFirstSuppBackRing->SetFillColor(sideAFirstSuppBackRing->GetLineColor());
3697   sideAFirstSuppBackRing->SetFillStyle(4000); // 0% transparent
3698
3699   TGeoVolume *sideASecondSuppBackRing = new TGeoVolume("ITSsuppSideASecondSuppBackRing",
3700                                                        secondSuppBackRing, medAl);
3701
3702   sideASecondSuppBackRing->SetVisibility(kTRUE);
3703   sideASecondSuppBackRing->SetLineColor(kMagenta+1);
3704   sideASecondSuppBackRing->SetLineWidth(1);
3705   sideASecondSuppBackRing->SetFillColor(sideASecondSuppBackRing->GetLineColor());
3706   sideASecondSuppBackRing->SetFillStyle(4000); // 0% transparent
3707
3708   TGeoVolume *sideASuppRod = new TGeoVolume("ITSsuppSideASuppRod",
3709                                             suppRod, medAl);
3710
3711   sideASuppRod->SetVisibility(kTRUE);
3712   sideASuppRod->SetLineColor(kMagenta+1);
3713   sideASuppRod->SetLineWidth(1);
3714   sideASuppRod->SetFillColor(sideASuppRod->GetLineColor());
3715   sideASuppRod->SetFillStyle(4000); // 0% transparent
3716
3717   TGeoVolume *sideASuppRearRing = new TGeoVolume("ITSsuppSideASuppRearRing",
3718                                                  suppRearRing, medAl);
3719
3720   sideASuppRearRing->SetVisibility(kTRUE);
3721   sideASuppRearRing->SetLineColor(kMagenta+1);
3722   sideASuppRearRing->SetLineWidth(1);
3723   sideASuppRearRing->SetFillColor(sideASuppRearRing->GetLineColor());
3724   sideASuppRearRing->SetFillStyle(4000); // 0% transparent
3725
3726
3727   // Now build up the support structure
3728   zloc = kSuppRingZTrans;
3729   trayASuppStruct->AddNode(sideAExtSuppRing, 1,
3730                            new TGeoTranslation(0, 0, zloc) );
3731   trayASuppStruct->AddNode(sideAExtSuppRing, 2,
3732                            new TGeoCombiTrans( 0, 0, zloc,
3733                                                new TGeoRotation("",180,0,0)));
3734
3735   zloc += kExtSuppRingThick;
3736   trayASuppStruct->AddNode(sideAIntSuppRing, 1,
3737                            new TGeoTranslation(0, 0, zloc) );
3738   trayASuppStruct->AddNode(sideAIntSuppRing, 2,
3739                            new TGeoCombiTrans( 0, 0, zloc,
3740                                                new TGeoRotation("",180,0,0)));
3741
3742   xloc = kExtSuppRingBase - kIntSuppRingInward;
3743   yloc = kSuppRingYTrans;
3744   zloc += (kIntSuppRingThick + kSuppCylHeight/2);
3745   trayASuppStruct->AddNode(sideASuppCyl, 1,
3746                            new TGeoTranslation(0, 0, zloc) );
3747   trayASuppStruct->AddNode(sideASuppCyl, 2,
3748                            new TGeoCombiTrans( 0, 0, zloc,
3749                                                new TGeoRotation("",180,0,0)));
3750   trayASuppStruct->AddNode(sideASuppSpacer, 1,
3751                            new TGeoCombiTrans( xloc, yloc, zloc,
3752                            new TGeoRotation("",90+kSuppSpacerAngle,0,0)));
3753   trayASuppStruct->AddNode(sideASuppSpacer, 2,
3754                            new TGeoCombiTrans(-xloc, yloc, zloc,
3755                            new TGeoRotation("",0,180,kSuppSpacerAngle-90)));
3756   trayASuppStruct->AddNode(sideASuppSpacer, 3,
3757                            new TGeoCombiTrans( xloc,-yloc, zloc,
3758                            new TGeoRotation("",180,180,kSuppSpacerAngle-90)));
3759   trayASuppStruct->AddNode(sideASuppSpacer, 4,
3760                            new TGeoCombiTrans(-xloc,-yloc, zloc,
3761                            new TGeoRotation("",270+kSuppSpacerAngle,0,0)));
3762
3763
3764   zloc += kSuppCylHeight/2;
3765   trayASuppStruct->AddNode(sideAIntSuppRing, 3,
3766                            new TGeoTranslation(0, 0, zloc) );
3767   trayASuppStruct->AddNode(sideAIntSuppRing, 4,
3768                            new TGeoCombiTrans( 0, 0, zloc,
3769                                                new TGeoRotation("",180,0,0)));
3770
3771   zloc += kIntSuppRingThick;
3772   trayASuppStruct->AddNode(sideAExtSuppRing, 3,
3773                            new TGeoTranslation(0, 0, zloc) );
3774   trayASuppStruct->AddNode(sideAExtSuppRing, 4,
3775                            new TGeoCombiTrans( 0, 0, zloc,
3776                                                new TGeoRotation("",180,0,0)));
3777
3778   zloc += kExtSuppRingThick;
3779   trayASuppStruct->AddNode(sideASuppForwRing, 1,
3780                            new TGeoTranslation(0, 0, zloc) );
3781   trayASuppStruct->AddNode(sideASuppForwRing, 2,
3782                            new TGeoCombiTrans( 0, 0, zloc,
3783                                                new TGeoRotation("",180,0,0)));
3784
3785   zloc += kSuppForwRingThikAll;
3786   trayASuppStruct->AddNode(sideASuppForwCone, 1,
3787                            new TGeoTranslation(0, 0, zloc) );
3788   trayASuppStruct->AddNode(sideASuppForwCone, 2,
3789                            new TGeoCombiTrans( 0, 0, zloc,
3790                                                new TGeoRotation("",180,0,0)));
3791
3792   zloc += (kSuppForwConeLen1+kSuppForwConeLen2);
3793   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 1,
3794                            new TGeoTranslation(0, 0, zloc) );
3795   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 2,
3796                            new TGeoCombiTrans( 0, 0, zloc,
3797                                                new TGeoRotation("",180,0,0)));
3798
3799   zloc += kSuppBackRingThick1;
3800   trayASuppStruct->AddNode(sideASecondSuppBackRing, 1,
3801                            new TGeoTranslation(0, 0, zloc) );
3802   trayASuppStruct->AddNode(sideASecondSuppBackRing, 2,
3803                            new TGeoCombiTrans( 0, 0, zloc,
3804                                                new TGeoRotation("",180,0,0)));
3805
3806   xloc = kSuppRearRingXRodHole;
3807   yloc = kSuppRearRingBaseHi + kSuppRearRingYRodHole;
3808   zloc = kRearSuppZTransGlob - kBackRodZTrans + suppRod->GetDz();
3809   trayASuppStruct->AddNode(sideASuppRod, 1,
3810                            new TGeoTranslation( xloc, yloc, zloc) );
3811   trayASuppStruct->AddNode(sideASuppRod, 2,
3812                            new TGeoTranslation(-xloc, yloc, zloc) );
3813   trayASuppStruct->AddNode(sideASuppRod, 3,
3814                            new TGeoTranslation( xloc,-yloc, zloc) );
3815   trayASuppStruct->AddNode(sideASuppRod, 4,
3816                            new TGeoTranslation(-xloc,-yloc, zloc) );
3817
3818   zloc += suppRod->GetDz();
3819   trayASuppStruct->AddNode(sideASuppRearRing, 1,
3820                            new TGeoTranslation( 0, 0, zloc) );
3821   trayASuppStruct->AddNode(sideASuppRearRing, 2,
3822                            new TGeoCombiTrans( 0, 0, zloc,
3823                                                new TGeoRotation("",180,0,0)));
3824
3825
3826   // Finally put everything in the mother volume
3827   moth->AddNode(trayASuppStruct,1,0);
3828
3829   return;
3830 }
3831
3832 //______________________________________________________________________
3833 void AliITSv11GeometrySupport::ServicesCableSupportSPD(TGeoVolume *moth,
3834                                                        TGeoManager *mgr){
3835 //
3836 // Creates the all SPD cable trays which are outside the ITS support cones
3837 // but still inside the TPC
3838 // In order to avoid a huge monolithic routine, this method actually
3839 // calls inner methods to create and assemble the various (macro)pieces
3840 //
3841 // Input:
3842 //         moth : the TGeoVolume owing the volume structure
3843 //         mgr  : the GeoManager (default gGeoManager)
3844 // Output:
3845 //
3846 // Created:         ???       Bjorn S. Nilsen
3847 // Updated:      15 Nov 2009  Mario Sitta
3848 //
3849 // Technical data are taken from AutoCAD drawings and other (oral)
3850 // information given by F.Tosello
3851 //
3852
3853   SPDCableTraysSideA(moth, mgr);
3854   SPDCableTraysSideC(moth, mgr);
3855
3856 }
3857
3858 //______________________________________________________________________
3859 void AliITSv11GeometrySupport::ServicesCableSupportSDD(TGeoVolume *moth,
3860                                                        TGeoManager *mgr){
3861 //
3862 // Creates the all SDD cable trays which are outside the ITS support cones
3863 // but still inside the TPC
3864 // In order to avoid a huge monolithic routine, this method actually
3865 // calls inner methods to create and assemble the various (macro)pieces
3866 //
3867 // Input:
3868 //         moth : the TGeoVolume owing the volume structure
3869 //         mgr  : the GeoManager (default gGeoManager)
3870 // Output:
3871 //
3872 // Created:      14 Dec 2009  Mario Sitta
3873 //
3874
3875   SDDCableTraysSideA(moth, mgr);
3876   SDDCableTraysSideC(moth, mgr);
3877
3878   return;
3879 }
3880
3881 //______________________________________________________________________
3882 void AliITSv11GeometrySupport::ServicesCableSupportSSD(TGeoVolume *moth,
3883                                                        TGeoManager *mgr){
3884 //
3885 // Creates the SSD cable trays which are outside the ITS support cones
3886 // but still inside the TPC
3887 // In order to avoid a huge monolithic routine, this method actually
3888 // calls inner methods to create and assemble the various (macro)pieces
3889 //
3890 // Input:
3891 //         moth : the TGeoVolume owing the volume structure
3892 //         mgr  : the GeoManager (default gGeoManager)
3893 // Output:
3894 //
3895 // Created:      15 Nov 2009  Mario Sitta
3896 //
3897
3898   SSDCableTraysSideA(moth, mgr);
3899   SSDCableTraysSideC(moth, mgr);
3900
3901   return;
3902 }
3903
3904 //______________________________________________________________________
3905 void AliITSv11GeometrySupport::SPDCableTraysSideA(TGeoVolume *moth,
3906                                             const TGeoManager *mgr){
3907 //
3908 // Creates the SPD cable trays which are outside the ITS support cones
3909 // but still inside the TPC on Side A
3910 // (part of this code is taken or anyway inspired to ServicesCableSupport
3911 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
3912 //
3913 // Input:
3914 //         moth : the TGeoVolume owing the volume structure
3915 //         mgr  : the GeoManager (default gGeoManager)
3916 // Output:
3917 //
3918 // Created:      15 Feb 2010  Mario Sitta
3919 // Updated:      10 Jun 2010  Mario Sitta  Freon inside cooling pipes
3920 // Updated:      08 Sep 2010  Mario Sitta
3921 // Updated:      14 Sep 2010  Mario Sitta  Cables prolonged till cone
3922 //
3923 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
3924 // drawings and other (oral) information given by F.Tosello and D.Elia
3925 // (small differences with blueprints - e.g. -0.07mm in R1Trans and
3926 // R2Trans - fix small overlaps; they are then compensated in positioning
3927 // the Rear Tray to avoid its own overlaps with the rear supporting ring)
3928 // Optical fibers and voltage cables are approximated with mean materials
3929 // and square cross sections, but preserving the total material budget.
3930 //
3931
3932   // Overall position and rotation of the A-Side Cable Trays
3933   // (parts of 0872/G/D)
3934   const Double_t kTrayAR1Trans           =  396.93 *fgkmm;
3935   const Double_t kTrayAR2Trans           =  413.93 *fgkmm;
3936   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
3937   const Double_t kTrayAZRot              = (180-169.5);// Degrees
3938   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
3939   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
3940
3941   const Double_t kForwardTrayWide        =   94.00 *fgkmm;//!!!TO BE CHECKED!!!
3942   const Double_t kForwardTrayFirstHigh   =   83.00 *fgkmm;//!!!TO BE CHECKED!!!
3943   const Double_t kForwardTraySecondHigh  =   52.70 *fgkmm;//!!!TO BE CHECKED!!!
3944   const Double_t kForwardTrayTotalLen    =  853.00 *fgkmm;
3945   const Double_t kForwardTrayFirstLen    =  435.00 *fgkmm;
3946   const Double_t kForwardTrayWingWide    =   16.00 *fgkmm;//!!!TO BE CHECKED!!!
3947   const Double_t kForwardTrayInterSpace  =   18.00 *fgkmm;//!!!TO BE CHECKED!!!
3948   const Double_t kForwardTrayThick       =    2.00 *fgkmm;
3949
3950   const Int_t    kForwardSideNpoints     =    6;
3951
3952   const Double_t kExternalTrayLen        = 1200.00 *fgkmm;
3953   const Double_t kExternalTrayWide       = kForwardTrayWide;
3954   const Double_t kExternalTrayHigh       = kForwardTraySecondHigh;
3955   const Double_t kExternalTrayThick      = kForwardTrayThick;
3956
3957   const Double_t kCoolingTubeRmin        =    2.00 *fgkmm;
3958   const Double_t kCoolingTubeRmax        =    3.00 *fgkmm;
3959
3960   const Double_t kOpticalFibersSect      =    8.696*fgkmm;//!!!ESTIMATED!!!
3961   const Double_t kLowVoltageCableSectCu  =    7.675*fgkmm;// Computed
3962   const Double_t kLowVoltageCableHighPUR =    1.000*fgkmm;// Computed
3963   const Double_t kHiVoltageCableSectCu   =    1.535*fgkmm;// Computed
3964   const Double_t kHiVoltageCableHighPUR  =    0.500*fgkmm;// Computed
3965   const Double_t kCoaxCableSectCu        =    6.024*fgkmm;// Computed
3966   const Double_t kCoaxCableHighMeg       =    5.695*fgkmm;// Computed
3967
3968   const Double_t kTrayCCablesRot         =   75.000*fgkDegree;// Computed
3969   const Double_t kTrayCCablesZLenOut     =  227.000*fgkmm;// Computed
3970
3971
3972   // Local variables
3973   Double_t xprof[kForwardSideNpoints], yprof[kForwardSideNpoints];
3974   Double_t xloc, yloc, zloc, alpharot;
3975
3976
3977   // The two tray components as assemblies
3978   TGeoVolumeAssembly *cableTrayAForw =
3979     new TGeoVolumeAssembly("ITSsupportSPDTrayAForwRear");
3980   TGeoVolumeAssembly *cableTrayAExt =
3981     new TGeoVolumeAssembly("ITSsupportSPDTrayAExt");
3982   
3983
3984   // First create all needed shapes
3985
3986   // The lower face of the forward tray: a BBox
3987   TGeoBBox *forwTrayLowerFace = new TGeoBBox(kForwardTrayWide/2,
3988                                              kForwardTrayThick/2,
3989                                              kForwardTrayTotalLen/2);
3990
3991   // The side face of the forward tray: a Xtru
3992   TGeoXtru *forwTraySideFace = new TGeoXtru(2);
3993   forwTraySideFace->SetName("ITSsuppSPDForwTraySide");
3994
3995   xprof[0] = 0;
3996   yprof[0] = kForwardTrayThick;
3997   xprof[1] = kForwardTrayTotalLen;
3998   yprof[1] = yprof[0];
3999   xprof[2] = xprof[1];
4000   yprof[2] = kForwardTraySecondHigh - kForwardTrayThick;
4001   xprof[3] = kForwardTrayFirstLen;
4002   yprof[3] = yprof[2];
4003   xprof[4] = xprof[3];
4004   yprof[4] = kForwardTrayFirstHigh - kForwardTrayThick;
4005   xprof[5] = xprof[0];
4006   yprof[5] = yprof[4];
4007
4008   forwTraySideFace->DefinePolygon(6, xprof, yprof);
4009   forwTraySideFace->DefineSection(0, 0);
4010   forwTraySideFace->DefineSection(1, kForwardTrayThick);
4011
4012   // The covers of the forward tray: two BBox's
4013   TGeoBBox *forwTrayShortCover = new TGeoBBox(kForwardTrayWide/2,
4014                                               kForwardTrayThick/2,
4015                                               kForwardTrayFirstLen/2);
4016
4017   TGeoBBox *forwTrayLongCover = new TGeoBBox(kForwardTrayWide/2,
4018                                              kForwardTrayThick/2,
4019                              (kForwardTrayTotalLen - kForwardTrayFirstLen)/2);
4020
4021   // Each small wing of the forward tray: a BBox
4022   TGeoBBox *forwTrayWing = new TGeoBBox(kForwardTrayWingWide/2,
4023                              (kForwardTrayFirstHigh-kForwardTraySecondHigh)/2,
4024                                         kForwardTrayThick/2);
4025
4026   // The internal plane of the forward tray: a BBox
4027   TGeoBBox *forwTrayPlane = new TGeoBBox(kForwardTrayWide/2-kForwardTrayThick,
4028                                          kForwardTrayThick/2,
4029                                          kForwardTrayTotalLen/2);
4030
4031   // The internal wall of the forward tray: a BBox
4032   TGeoBBox *forwTrayWall = new TGeoBBox(kForwardTrayThick/2,
4033                                  (kForwardTrayInterSpace-kForwardTrayThick)/2,
4034                                         kForwardTrayTotalLen/2);
4035
4036   // Each horizontal face of the external tray: a BBox
4037   TGeoBBox *extTrayHorFace = new TGeoBBox(kExternalTrayWide/2-kExternalTrayThick,
4038                                           kExternalTrayThick/2,
4039                                           kExternalTrayLen/2);
4040
4041   // Each vertical face of the external tray: a BBox
4042   TGeoBBox *extTrayVerFace = new TGeoBBox(kExternalTrayThick/2,
4043                                           kExternalTrayHigh/2,
4044                                           kExternalTrayLen/2);
4045
4046   // The internal wall of the external tray: a BBox
4047   TGeoBBox *extTrayWall = new TGeoBBox(kExternalTrayThick/2,
4048                                  (kForwardTrayInterSpace-kExternalTrayThick)/2,
4049                                        kExternalTrayLen/2);
4050
4051   // The cooling tube inside the forward tray: a Tube
4052   Double_t zelong = (kForwardTraySecondHigh - 2*kForwardTrayThick
4053                 - 2*forwTrayWall->GetDY() - kCoolingTubeRmax)*SinD(kTrayAZRot);
4054   Double_t zlen = (zelong + kForwardTrayTotalLen)/2;
4055   TGeoTube *coolTubeForw = new TGeoTube(0, kCoolingTubeRmax, zlen);
4056
4057   // The freon inside the forward tray tubes: a Tube
4058   TGeoTube *freonTubeForw = new TGeoTube(0, kCoolingTubeRmin, zlen);
4059
4060   // The cooling tube inside the external tray: a Ctub
4061   TGeoCtub *coolTubeExt = new TGeoCtub(0, kCoolingTubeRmax,
4062                                        kExternalTrayLen/2, 0, 360,
4063                                        0, SinD(kTrayAZRot),-CosD(kTrayAZRot),
4064                                        0,                0,               1);
4065
4066   // The freon inside the forward tray tubes: a Tube
4067   TGeoCtub *freonTubeExt = new TGeoCtub(0, kCoolingTubeRmin,
4068                                         kExternalTrayLen/2, 0, 360,
4069                                         0, SinD(kTrayAZRot),-CosD(kTrayAZRot),
4070                                         0,                0,               1);
4071
4072   // The optical fibers inside the forward tray: a Xtru
4073   TGeoXtru *optFibsForw = new TGeoXtru(2);
4074
4075   xprof[0] = -kTrayCCablesZLenOut;
4076   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4077   xprof[1] = 0;
4078   yprof[1] = 0;
4079   xprof[2] = kForwardTrayTotalLen;
4080   yprof[2] = yprof[1];
4081   xprof[3] = xprof[2];
4082   yprof[3] = yprof[2] + kOpticalFibersSect;
4083   xprof[4] = xprof[1];
4084   yprof[4] = yprof[3];
4085   xprof[5] = xprof[0];
4086   yprof[5] = yprof[0] + kOpticalFibersSect;
4087
4088   optFibsForw->DefinePolygon(6, xprof, yprof);
4089   optFibsForw->DefineSection(0,-kOpticalFibersSect/2);
4090   optFibsForw->DefineSection(1, kOpticalFibersSect/2);
4091
4092   // The optical fibers inside the external tray: a Xtru
4093   TGeoXtru *optFibsExt = new TGeoXtru(2);
4094   optFibsExt->SetName("ITSsuppSPDExtTrayOptFibs");
4095
4096   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4097            + 2*forwTrayWall->GetDY();
4098   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4099   xprof[1] = kExternalTrayLen;
4100   yprof[1] = yprof[0];
4101   xprof[2] = xprof[1];
4102   yprof[2] = yprof[1] + kOpticalFibersSect;
4103   yprof[3] = yprof[2];
4104   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4105
4106   optFibsExt->DefinePolygon(4, xprof, yprof);
4107   optFibsExt->DefineSection(0, 0);
4108   optFibsExt->DefineSection(1, kOpticalFibersSect);
4109
4110   // The Low Voltage cables inside the forward tray: two Xtru
4111   TGeoXtru *lowCablesForwCu = new TGeoXtru(2);
4112
4113   xprof[0] = -kTrayCCablesZLenOut;
4114   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4115   xprof[1] = 0;
4116   yprof[1] = 0;
4117   xprof[2] = kForwardTrayTotalLen;
4118   yprof[2] = yprof[1];
4119   xprof[3] = xprof[2];
4120   yprof[3] = yprof[2] + kLowVoltageCableSectCu/2;
4121   xprof[4] = xprof[1];
4122   yprof[4] = yprof[3];
4123   xprof[5] = xprof[0];
4124   yprof[5] = yprof[0] + kLowVoltageCableSectCu/2;
4125
4126   lowCablesForwCu->DefinePolygon(6, xprof, yprof);
4127   lowCablesForwCu->DefineSection(0,-kLowVoltageCableSectCu);
4128   lowCablesForwCu->DefineSection(1, kLowVoltageCableSectCu);
4129
4130   TGeoXtru *lowCablesForwPUR = new TGeoXtru(2);
4131
4132   xprof[0] = lowCablesForwCu->GetX(5);
4133   yprof[0] = lowCablesForwCu->GetY(5);
4134   xprof[1] = lowCablesForwCu->GetX(4);
4135   yprof[1] = lowCablesForwCu->GetY(4);
4136   xprof[2] = lowCablesForwCu->GetX(3);
4137   yprof[2] = lowCablesForwCu->GetY(3);
4138   xprof[3] = xprof[2];
4139   yprof[3] = yprof[2] + kLowVoltageCableHighPUR/2;
4140   xprof[4] = xprof[1];
4141   yprof[4] = yprof[3];
4142   xprof[5] = xprof[0];
4143   yprof[5] = yprof[0] + kLowVoltageCableHighPUR/2;
4144
4145   lowCablesForwPUR->DefinePolygon(6, xprof, yprof);
4146   lowCablesForwPUR->DefineSection(0,-kLowVoltageCableSectCu);
4147   lowCablesForwPUR->DefineSection(1, kLowVoltageCableSectCu);
4148
4149   // The Low Voltage inside the external tray: two Xtru
4150   TGeoXtru *lowCablesExtCu = new TGeoXtru(2);
4151   lowCablesExtCu->SetName("ITSsuppSPDExtTrayLowVoltageCu");
4152
4153   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4154            + 2*forwTrayWall->GetDY();
4155   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4156   xprof[1] = kExternalTrayLen;
4157   yprof[1] = yprof[0];
4158   xprof[2] = xprof[1];
4159   yprof[2] = yprof[1] + kLowVoltageCableSectCu/2;
4160   yprof[3] = yprof[2];
4161   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4162
4163   lowCablesExtCu->DefinePolygon(4, xprof, yprof);
4164   lowCablesExtCu->DefineSection(0, 0);
4165   lowCablesExtCu->DefineSection(1, kLowVoltageCableSectCu*2);
4166
4167   TGeoXtru *lowCablesExtPUR = new TGeoXtru(2);
4168   lowCablesExtPUR->SetName("ITSsuppSPDExtTrayLowVoltagePUR");
4169
4170   xprof[0] = lowCablesExtCu->GetX(3);
4171   yprof[0] = lowCablesExtCu->GetY(3);
4172   xprof[1] = lowCablesExtCu->GetX(2);
4173   yprof[1] = lowCablesExtCu->GetY(2);
4174   xprof[2] = xprof[1];
4175   yprof[2] = yprof[1] + kLowVoltageCableHighPUR/2;
4176   yprof[3] = yprof[2];
4177   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4178
4179   lowCablesExtPUR->DefinePolygon(4, xprof, yprof);
4180   lowCablesExtPUR->DefineSection(0, 0);
4181   lowCablesExtPUR->DefineSection(1, kLowVoltageCableSectCu*2);
4182
4183   // The High Voltage cables inside the forward tray: two Xtru
4184   TGeoXtru *hiCablesForwCu = new TGeoXtru(2);
4185
4186   xprof[0] = -kTrayCCablesZLenOut;
4187   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4188   xprof[1] = 0;
4189   yprof[1] = 0;
4190   xprof[2] = kForwardTrayTotalLen;
4191   yprof[2] = yprof[1];
4192   xprof[3] = xprof[2];
4193   yprof[3] = yprof[2] + kHiVoltageCableSectCu/2;
4194   xprof[4] = xprof[1];
4195   yprof[4] = yprof[3];
4196   xprof[5] = xprof[0];
4197   yprof[5] = yprof[0] + kHiVoltageCableSectCu/2;
4198
4199   hiCablesForwCu->DefinePolygon(6, xprof, yprof);
4200   hiCablesForwCu->DefineSection(0,-kHiVoltageCableSectCu);
4201   hiCablesForwCu->DefineSection(1, kHiVoltageCableSectCu);
4202
4203   TGeoXtru *hiCablesForwPUR = new TGeoXtru(2);
4204
4205   xprof[0] = hiCablesForwCu->GetX(5);
4206   yprof[0] = hiCablesForwCu->GetY(5);
4207   xprof[1] = hiCablesForwCu->GetX(4);
4208   yprof[1] = hiCablesForwCu->GetY(4);
4209   xprof[2] = hiCablesForwCu->GetX(3);
4210   yprof[2] = hiCablesForwCu->GetY(3);
4211   xprof[3] = xprof[2];
4212   yprof[3] = yprof[2] + kHiVoltageCableHighPUR/2;
4213   xprof[4] = xprof[1];
4214   yprof[4] = yprof[3];
4215   xprof[5] = xprof[0];
4216   yprof[5] = yprof[0] + kHiVoltageCableHighPUR/2;
4217
4218   hiCablesForwPUR->DefinePolygon(6, xprof, yprof);
4219   hiCablesForwPUR->DefineSection(0,-kHiVoltageCableSectCu);
4220   hiCablesForwPUR->DefineSection(1, kHiVoltageCableSectCu);
4221
4222   // The High Voltage inside the external tray: two Xtru
4223   TGeoXtru *hiCablesExtCu = new TGeoXtru(2);
4224   hiCablesExtCu->SetName("ITSsuppSPDExtTrayHiVoltageCu");
4225
4226   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4227            + 2*forwTrayWall->GetDY();
4228   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4229   xprof[1] = kExternalTrayLen;
4230   yprof[1] = yprof[0];
4231   xprof[2] = xprof[1];
4232   yprof[2] = yprof[1] + kHiVoltageCableSectCu/2;
4233   yprof[3] = yprof[2];
4234   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4235
4236   hiCablesExtCu->DefinePolygon(4, xprof, yprof);
4237   hiCablesExtCu->DefineSection(0, 0);
4238   hiCablesExtCu->DefineSection(1, kHiVoltageCableSectCu*2);
4239
4240   TGeoXtru *hiCablesExtPUR = new TGeoXtru(2);
4241   hiCablesExtPUR->SetName("ITSsuppSPDExtTrayHiVoltagePUR");
4242
4243   xprof[0] = hiCablesExtCu->GetX(3);
4244   yprof[0] = hiCablesExtCu->GetY(3);
4245   xprof[1] = hiCablesExtCu->GetX(2);
4246   yprof[1] = hiCablesExtCu->GetY(2);
4247   xprof[2] = xprof[1];
4248   yprof[2] = yprof[1] + kHiVoltageCableHighPUR/2;
4249   yprof[3] = yprof[2];
4250   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4251
4252   hiCablesExtPUR->DefinePolygon(4, xprof, yprof);
4253   hiCablesExtPUR->DefineSection(0, 0);
4254   hiCablesExtPUR->DefineSection(1, kHiVoltageCableSectCu*2);
4255
4256   // The Coaxial cables inside the forward tray: two Xtru
4257   TGeoXtru *coaxCablesForwCu = new TGeoXtru(2);
4258   coaxCablesForwCu->SetName("ITSsuppSPDForwTrayCoaxCu");
4259
4260   xprof[0] = -kTrayCCablesZLenOut;
4261   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4262   xprof[1] = 0;
4263   yprof[1] = 0;
4264   xprof[2] = kForwardTrayTotalLen;
4265   yprof[2] = yprof[1];
4266   xprof[3] = xprof[2];
4267   yprof[3] = yprof[2] + kCoaxCableSectCu/2;
4268   xprof[4] = xprof[1];
4269   yprof[4] = yprof[3];
4270   xprof[5] = xprof[0];
4271   yprof[5] = yprof[0] + kCoaxCableSectCu/2;
4272
4273   coaxCablesForwCu->DefinePolygon(6, xprof, yprof);
4274   coaxCablesForwCu->DefineSection(0,-kCoaxCableSectCu);
4275   coaxCablesForwCu->DefineSection(1, kCoaxCableSectCu);
4276
4277   TGeoXtru *coaxCablesForwMeg = new TGeoXtru(2);
4278   coaxCablesForwMeg->SetName("ITSsuppSPDForwTrayCoaxMeg");
4279
4280   xprof[0] = coaxCablesForwCu->GetX(5);
4281   yprof[0] = coaxCablesForwCu->GetY(5);
4282   xprof[1] = coaxCablesForwCu->GetX(4);
4283   yprof[1] = coaxCablesForwCu->GetY(4);
4284   xprof[2] = coaxCablesForwCu->GetX(3);
4285   yprof[2] = coaxCablesForwCu->GetY(3);
4286   xprof[3] = xprof[2];
4287   yprof[3] = yprof[2] + kCoaxCableHighMeg/2;
4288   xprof[4] = xprof[1];
4289   yprof[4] = yprof[3];
4290   xprof[5] = xprof[0];
4291   yprof[5] = yprof[0] + kCoaxCableHighMeg/2;
4292
4293   coaxCablesForwMeg->DefinePolygon(6, xprof, yprof);
4294   coaxCablesForwMeg->DefineSection(0,-kCoaxCableSectCu);
4295   coaxCablesForwMeg->DefineSection(1, kCoaxCableSectCu);
4296
4297   // The Coaxial inside the external tray: two Xtru
4298   TGeoXtru *coaxCablesExtCu = new TGeoXtru(2);
4299   coaxCablesExtCu->SetName("ITSsuppSPDExtTrayCoaxCu");
4300
4301   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4302            + 2*forwTrayWall->GetDY();
4303   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4304   xprof[1] = kExternalTrayLen;
4305   yprof[1] = yprof[0];
4306   xprof[2] = xprof[1];
4307   yprof[2] = yprof[1] + kCoaxCableSectCu/2;
4308   yprof[3] = yprof[2];
4309   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4310
4311   coaxCablesExtCu->DefinePolygon(4, xprof, yprof);
4312   coaxCablesExtCu->DefineSection(0, 0);
4313   coaxCablesExtCu->DefineSection(1, kCoaxCableSectCu*2);
4314
4315   TGeoXtru *coaxCablesExtMeg = new TGeoXtru(2);
4316   coaxCablesExtMeg->SetName("ITSsuppSPDExtTrayCoaxMeg");
4317
4318   xprof[0] = coaxCablesExtCu->GetX(3);
4319   yprof[0] = coaxCablesExtCu->GetY(3);
4320   xprof[1] = coaxCablesExtCu->GetX(2);
4321   yprof[1] = coaxCablesExtCu->GetY(2);
4322   xprof[2] = xprof[1];
4323   yprof[2] = yprof[1] + kCoaxCableHighMeg/2;
4324   yprof[3] = yprof[2];
4325   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4326
4327   coaxCablesExtMeg->DefinePolygon(4, xprof, yprof);
4328   coaxCablesExtMeg->DefineSection(0, 0);
4329   coaxCablesExtMeg->DefineSection(1, kCoaxCableSectCu*2);
4330
4331
4332   // We have all shapes: now create the real volumes
4333   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
4334   TGeoMedium *medIn    = mgr->GetMedium("ITS_INOX$");
4335   TGeoMedium *medFreon = mgr->GetMedium("ITS_GASEOUS FREON$");
4336   TGeoMedium *medFibs  = mgr->GetMedium("ITS_SDD OPTICFIB$");//!TO BE CHECKED!
4337   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
4338   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
4339   TGeoMedium *medMeg   = mgr->GetMedium("ITS_MEGOLON$");
4340
4341   TGeoVolume *forwTrayABase = new TGeoVolume("ITSsuppSPDSideAForwTrayABase",
4342                                             forwTrayLowerFace, medAl);
4343
4344   forwTrayABase->SetVisibility(kTRUE);
4345   forwTrayABase->SetLineColor(6); // Purple
4346   forwTrayABase->SetLineWidth(1);
4347   forwTrayABase->SetFillColor(forwTrayABase->GetLineColor());
4348   forwTrayABase->SetFillStyle(4000); // 0% transparent
4349
4350   TGeoVolume *forwTrayASide = new TGeoVolume("ITSsuppSPDSideAForwTrayASide",
4351                                             forwTraySideFace, medAl);
4352
4353   forwTrayASide->SetVisibility(kTRUE);
4354   forwTrayASide->SetLineColor(6); // Purple
4355   forwTrayASide->SetLineWidth(1);
4356   forwTrayASide->SetFillColor(forwTrayASide->GetLineColor());
4357   forwTrayASide->SetFillStyle(4000); // 0% transparent
4358
4359   TGeoVolume *forwTrayACoverShort = new TGeoVolume("ITSsuppSPDSideAForwTrayASC",
4360                                                   forwTrayShortCover, medAl);
4361
4362   forwTrayACoverShort->SetVisibility(kTRUE);
4363   forwTrayACoverShort->SetLineColor(6); // Purple
4364   forwTrayACoverShort->SetLineWidth(1);
4365   forwTrayACoverShort->SetFillColor(forwTrayACoverShort->GetLineColor());
4366   forwTrayACoverShort->SetFillStyle(4000); // 0% transparent
4367
4368   TGeoVolume *forwTrayACoverLong = new TGeoVolume("ITSsuppSPDSideAForwTrayALC",
4369                                                  forwTrayLongCover, medAl);
4370
4371   forwTrayACoverLong->SetVisibility(kTRUE);
4372   forwTrayACoverLong->SetLineColor(6); // Purple
4373   forwTrayACoverLong->SetLineWidth(1);
4374   forwTrayACoverLong->SetFillColor(forwTrayACoverLong->GetLineColor());
4375   forwTrayACoverLong->SetFillStyle(4000); // 0% transparent
4376
4377   TGeoVolume *forwTrayAWing = new TGeoVolume("ITSsuppSPDSideAForwTrayAWing",
4378                                              forwTrayWing, medAl);
4379
4380   forwTrayAWing->SetVisibility(kTRUE);
4381   forwTrayAWing->SetLineColor(6); // Purple
4382   forwTrayAWing->SetLineWidth(1);
4383   forwTrayAWing->SetFillColor(forwTrayAWing->GetLineColor());
4384   forwTrayAWing->SetFillStyle(4000); // 0% transparent
4385
4386   TGeoVolume *forwTrayAPlane = new TGeoVolume("ITSsuppSPDSideAForwTrayAPlane",
4387                                               forwTrayPlane, medAl);
4388
4389   forwTrayAPlane->SetVisibility(kTRUE);
4390   forwTrayAPlane->SetLineColor(6); // Purple
4391   forwTrayAPlane->SetLineWidth(1);
4392   forwTrayAPlane->SetFillColor(forwTrayAPlane->GetLineColor());
4393   forwTrayAPlane->SetFillStyle(4000); // 0% transparent
4394
4395   TGeoVolume *forwTrayAWall = new TGeoVolume("ITSsuppSPDSideAForwTrayAWall",
4396                                              forwTrayWall, medAl);
4397
4398   forwTrayAWall->SetVisibility(kTRUE);
4399   forwTrayAWall->SetLineColor(6); // Purple
4400   forwTrayAWall->SetLineWidth(1);
4401   forwTrayAWall->SetFillColor(forwTrayAWall->GetLineColor());
4402   forwTrayAWall->SetFillStyle(4000); // 0% transparent
4403
4404   TGeoVolume *extTrayAHorFace = new TGeoVolume("ITSsuppSPDSideAExtTrayHorFace",
4405                                                extTrayHorFace, medAl);
4406
4407   extTrayAHorFace->SetVisibility(kTRUE);
4408   extTrayAHorFace->SetLineColor(6); // Purple
4409   extTrayAHorFace->SetLineWidth(1);
4410   extTrayAHorFace->SetFillColor(extTrayAHorFace->GetLineColor());
4411   extTrayAHorFace->SetFillStyle(4000); // 0% transparent
4412
4413   TGeoVolume *extTrayAVerFace = new TGeoVolume("ITSsuppSPDSideAExtTrayVerFace",
4414                                                extTrayVerFace, medAl);
4415
4416   extTrayAVerFace->SetVisibility(kTRUE);
4417   extTrayAVerFace->SetLineColor(6); // Purple
4418   extTrayAVerFace->SetLineWidth(1);
4419   extTrayAVerFace->SetFillColor(extTrayAVerFace->GetLineColor());
4420   extTrayAVerFace->SetFillStyle(4000); // 0% transparent
4421
4422   TGeoVolume *extTrayAWall = new TGeoVolume("ITSsuppSPDSideAExtTrayWall",
4423                                             extTrayWall, medAl);
4424
4425   extTrayAWall->SetVisibility(kTRUE);
4426   extTrayAWall->SetLineColor(6); // Purple
4427   extTrayAWall->SetLineWidth(1);
4428   extTrayAWall->SetFillColor(extTrayAWall->GetLineColor());
4429   extTrayAWall->SetFillStyle(4000); // 0% transparent
4430
4431   TGeoVolume *forwCoolTube = new TGeoVolume("ITSsuppSPDSideAForwTrayCoolTube",
4432                                             coolTubeForw, medIn);
4433
4434   forwCoolTube->SetVisibility(kTRUE);
4435   forwCoolTube->SetLineColor(kGray); // as in GeometrySPD
4436   forwCoolTube->SetLineWidth(1);
4437   forwCoolTube->SetFillColor(forwCoolTube->GetLineColor());
4438   forwCoolTube->SetFillStyle(4000); // 0% transparent
4439
4440   TGeoVolume *forwCoolFreon = new TGeoVolume("ITSsuppSPDSideAForwTrayFreon",
4441                                              freonTubeForw, medFreon);
4442
4443   forwCoolFreon->SetVisibility(kTRUE);
4444   forwCoolFreon->SetLineColor(kBlue); // Blue
4445   forwCoolFreon->SetLineWidth(1);
4446   forwCoolFreon->SetFillColor(forwCoolFreon->GetLineColor());
4447   forwCoolFreon->SetFillStyle(4000); // 0% transparent
4448
4449   TGeoVolume *extCoolTube = new TGeoVolume("ITSsuppSPDSideAExtTrayCoolTube",
4450                                            coolTubeExt, medIn);
4451
4452   extCoolTube->SetVisibility(kTRUE);
4453   extCoolTube->SetLineColor(kGray); // as in GeometrySPD
4454   extCoolTube->SetLineWidth(1);
4455   extCoolTube->SetFillColor(extCoolTube->GetLineColor());
4456   extCoolTube->SetFillStyle(4000); // 0% transparent
4457
4458   TGeoVolume *extCoolFreon = new TGeoVolume("ITSsuppSPDSideAExtTrayFreon",
4459                                             freonTubeExt, medFreon);
4460
4461   extCoolFreon->SetVisibility(kTRUE);
4462   extCoolFreon->SetLineColor(kBlue); // Blue
4463   extCoolFreon->SetLineWidth(1);
4464   extCoolFreon->SetFillColor(extCoolFreon->GetLineColor());
4465   extCoolFreon->SetFillStyle(4000); // 0% transparent
4466
4467   TGeoVolume *forwOptFibs = new TGeoVolume("ITSsuppSPDSideAForwTrayOptFibs",
4468                                            optFibsForw, medFibs);
4469
4470   forwOptFibs->SetVisibility(kTRUE);
4471   forwOptFibs->SetLineColor(kOrange); // Orange
4472   forwOptFibs->SetLineWidth(1);
4473   forwOptFibs->SetFillColor(forwOptFibs->GetLineColor());
4474   forwOptFibs->SetFillStyle(4000); // 0% transparent
4475
4476   TGeoVolume *extOptFibs = new TGeoVolume("ITSsuppSPDSideAExtTrayOptFibs",
4477                                           optFibsExt, medFibs);
4478
4479   extOptFibs->SetVisibility(kTRUE);
4480   extOptFibs->SetLineColor(kOrange); // Orange
4481   extOptFibs->SetLineWidth(1);
4482   extOptFibs->SetFillColor(extOptFibs->GetLineColor());
4483   extOptFibs->SetFillStyle(4000); // 0% transparent
4484
4485   TGeoVolume *forwLowCabsCu = new TGeoVolume("ITSsuppSPDSideAForwLowCabsCu",
4486                                              lowCablesForwCu, medCu);
4487
4488   forwLowCabsCu->SetVisibility(kTRUE);
4489   forwLowCabsCu->SetLineColor(kRed); // Red
4490   forwLowCabsCu->SetLineWidth(1);
4491   forwLowCabsCu->SetFillColor(forwLowCabsCu->GetLineColor());
4492   forwLowCabsCu->SetFillStyle(4000); // 0% transparent
4493
4494   TGeoVolume *forwLowCabsPUR = new TGeoVolume("ITSsuppSPDSideAForwLowCabsPUR",
4495                                               lowCablesForwPUR, medPUR);
4496
4497   forwLowCabsPUR->SetVisibility(kTRUE);
4498   forwLowCabsPUR->SetLineColor(kBlack); // Black
4499   forwLowCabsPUR->SetLineWidth(1);
4500   forwLowCabsPUR->SetFillColor(forwLowCabsPUR->GetLineColor());
4501   forwLowCabsPUR->SetFillStyle(4000); // 0% transparent
4502
4503   TGeoVolume *extLowCabsCu = new TGeoVolume("ITSsuppSPDSideAExtLowCabsCu",
4504                                             lowCablesExtCu, medCu);
4505
4506   extLowCabsCu->SetVisibility(kTRUE);
4507   extLowCabsCu->SetLineColor(kRed); // Red
4508   extLowCabsCu->SetLineWidth(1);
4509   extLowCabsCu->SetFillColor(extLowCabsCu->GetLineColor());
4510   extLowCabsCu->SetFillStyle(4000); // 0% transparent
4511
4512   TGeoVolume *extLowCabsPUR = new TGeoVolume("ITSsuppSPDSideAExtLowCabsPUR",
4513                                              lowCablesExtPUR, medPUR);
4514
4515   extLowCabsPUR->SetVisibility(kTRUE);
4516   extLowCabsPUR->SetLineColor(kBlack); // Black
4517   extLowCabsPUR->SetLineWidth(1);
4518   extLowCabsPUR->SetFillColor(extLowCabsPUR->GetLineColor());
4519   extLowCabsPUR->SetFillStyle(4000); // 0% transparent
4520
4521   TGeoVolume *forwHiCabsCu = new TGeoVolume("ITSsuppSPDSideAForwTrayHiCabsCu",
4522                                             hiCablesForwCu, medCu);
4523
4524   forwHiCabsCu->SetVisibility(kTRUE);
4525   forwHiCabsCu->SetLineColor(kRed); // Red
4526   forwHiCabsCu->SetLineWidth(1);
4527   forwHiCabsCu->SetFillColor(forwHiCabsCu->GetLineColor());
4528   forwHiCabsCu->SetFillStyle(4000); // 0% transparent
4529
4530   TGeoVolume *forwHiCabsPUR = new TGeoVolume("ITSsuppSPDSideAForwTrayHiCabsPUR",
4531                                              hiCablesForwPUR, medPUR);
4532
4533   forwHiCabsPUR->SetVisibility(kTRUE);
4534   forwHiCabsPUR->SetLineColor(kBlack); // Black
4535   forwHiCabsPUR->SetLineWidth(1);
4536   forwHiCabsPUR->SetFillColor(forwHiCabsPUR->GetLineColor());
4537   forwHiCabsPUR->SetFillStyle(4000); // 0% transparent
4538
4539   TGeoVolume *extHiCabsCu = new TGeoVolume("ITSsuppSPDSideAExtTrayHiCabsCu",
4540                                            hiCablesExtCu, medCu);
4541
4542   extHiCabsCu->SetVisibility(kTRUE);
4543   extHiCabsCu->SetLineColor(kRed); // Red
4544   extHiCabsCu->SetLineWidth(1);
4545   extHiCabsCu->SetFillColor(extHiCabsCu->GetLineColor());
4546   extHiCabsCu->SetFillStyle(4000); // 0% transparent
4547
4548   TGeoVolume *extHiCabsPUR = new TGeoVolume("ITSsuppSPDSideAExtTrayHiCabsPUR",
4549                                             hiCablesExtPUR, medPUR);
4550
4551   extHiCabsPUR->SetVisibility(kTRUE);
4552   extHiCabsPUR->SetLineColor(kBlack); // Black
4553   extHiCabsPUR->SetLineWidth(1);
4554   extHiCabsPUR->SetFillColor(extHiCabsPUR->GetLineColor());
4555   extHiCabsPUR->SetFillStyle(4000); // 0% transparent
4556
4557   TGeoVolume *forwCoaxCu = new TGeoVolume("ITSsuppSPDSideAForwTrayCoaxCu",
4558                                           coaxCablesForwCu, medCu);
4559
4560   forwCoaxCu->SetVisibility(kTRUE);
4561   forwCoaxCu->SetLineColor(kRed); // Red
4562   forwCoaxCu->SetLineWidth(1);
4563   forwCoaxCu->SetFillColor(forwCoaxCu->GetLineColor());
4564   forwCoaxCu->SetFillStyle(4000); // 0% transparent
4565
4566   TGeoVolume *forwCoaxMeg = new TGeoVolume("ITSsuppSPDSideAForwTrayCoaxMeg",
4567                                            coaxCablesForwMeg, medMeg);
4568
4569   forwCoaxMeg->SetVisibility(kTRUE);
4570   forwCoaxMeg->SetLineColor(kBlack); // Black
4571   forwCoaxMeg->SetLineWidth(1);
4572   forwCoaxMeg->SetFillColor(forwCoaxMeg->GetLineColor());
4573   forwCoaxMeg->SetFillStyle(4000); // 0% transparent
4574
4575   TGeoVolume *extCoaxCu = new TGeoVolume("ITSsuppSPDSideAExtTrayCoaxCu",
4576                                          coaxCablesExtCu, medCu);
4577
4578   extCoaxCu->SetVisibility(kTRUE);
4579   extCoaxCu->SetLineColor(kRed); // Red
4580   extCoaxCu->SetLineWidth(1);
4581   extCoaxCu->SetFillColor(extCoaxCu->GetLineColor());
4582   extCoaxCu->SetFillStyle(4000); // 0% transparent
4583
4584   TGeoVolume *extCoaxMeg = new TGeoVolume("ITSsuppSPDSideAExtTrayCoaxMeg",
4585                                           coaxCablesExtMeg, medMeg);
4586
4587   extCoaxMeg->SetVisibility(kTRUE);
4588   extCoaxMeg->SetLineColor(kBlack); // Black
4589   extCoaxMeg->SetLineWidth(1);
4590   extCoaxMeg->SetFillColor(extCoaxMeg->GetLineColor());
4591   extCoaxMeg->SetFillStyle(4000); // 0% transparent
4592
4593
4594   // Now build up the trays
4595   yloc = forwTrayLowerFace->GetDY();
4596   zloc = forwTrayLowerFace->GetDZ();
4597   cableTrayAForw->AddNode(forwTrayABase, 1,
4598                       new TGeoTranslation(0, yloc, zloc));
4599
4600   xloc = kForwardTrayWide/2;
4601   cableTrayAForw->AddNode(forwTrayASide, 1,
4602                       new TGeoCombiTrans( xloc, 0, 0,
4603                                          new TGeoRotation("",90,-90,-90)));
4604   cableTrayAForw->AddNode(forwTrayASide, 2,
4605                       new TGeoCombiTrans(-xloc+kForwardTrayThick, 0, 0,
4606                                          new TGeoRotation("",90,-90,-90)));
4607
4608   yloc = kForwardTrayFirstHigh - forwTrayShortCover->GetDY();
4609   zloc = forwTrayShortCover->GetDZ();
4610   cableTrayAForw->AddNode(forwTrayACoverShort, 1,
4611                       new TGeoTranslation(0, yloc, zloc));
4612
4613   yloc = kForwardTraySecondHigh - forwTrayLongCover->GetDY();
4614   zloc = kForwardTrayFirstLen + forwTrayLongCover->GetDZ();
4615   cableTrayAForw->AddNode(forwTrayACoverLong, 1,
4616                       new TGeoTranslation(0, yloc, zloc));
4617
4618   xloc = kForwardTrayWide/2 - kForwardTrayThick - forwTrayWing->GetDX();
4619   yloc = kForwardTrayFirstHigh - kForwardTrayThick - forwTrayWing->GetDY();
4620   zloc = kForwardTrayFirstLen - forwTrayWing->GetDZ();
4621   cableTrayAForw->AddNode(forwTrayAWing, 1,
4622                       new TGeoTranslation( xloc, yloc, zloc));
4623   cableTrayAForw->AddNode(forwTrayAWing, 2,
4624                       new TGeoTranslation(-xloc, yloc, zloc));
4625
4626   yloc = kForwardTrayThick + kForwardTrayInterSpace - forwTrayPlane->GetDY();
4627   zloc = forwTrayPlane->GetDZ();
4628   cableTrayAForw->AddNode(forwTrayAPlane, 1,
4629                       new TGeoTranslation(0, yloc, zloc));
4630
4631   yloc = kForwardTrayThick + forwTrayWall->GetDY();
4632   zloc = forwTrayWall->GetDZ();
4633   cableTrayAForw->AddNode(forwTrayAWall, 1,
4634                       new TGeoTranslation(0, yloc, zloc));
4635
4636   forwCoolTube->AddNode(forwCoolFreon, 1, 0);
4637
4638   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY()
4639        + coolTubeForw->GetRmax();
4640   zloc = coolTubeForw->GetDz();
4641   cableTrayAForw->AddNode(forwCoolTube, 1,
4642                       new TGeoTranslation(0, yloc, zloc));
4643
4644   xloc = optFibsForw->GetZ(1) + coolTubeForw->GetRmax();
4645   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4646   cableTrayAForw->AddNode(forwOptFibs, 1,
4647                       new TGeoCombiTrans( xloc, yloc, 0,
4648                                          new TGeoRotation("",-90.,90.,90.)));
4649
4650   xloc = lowCablesForwCu->GetZ(1) + coolTubeForw->GetRmax();
4651   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4652   cableTrayAForw->AddNode(forwLowCabsCu, 1,
4653                       new TGeoCombiTrans(-xloc, yloc, 0,
4654                                          new TGeoRotation("",-90.,90.,90.)));
4655   cableTrayAForw->AddNode(forwLowCabsPUR, 1,
4656                       new TGeoCombiTrans(-xloc, yloc, 0,
4657                                          new TGeoRotation("",-90.,90.,90.)));
4658
4659   xloc = 2*lowCablesForwCu->GetZ(1) +
4660          hiCablesForwCu->GetZ(1) + coolTubeForw->GetRmax();
4661   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4662   cableTrayAForw->AddNode(forwHiCabsCu, 1,
4663                       new TGeoCombiTrans(-xloc, yloc, 0,
4664                                          new TGeoRotation("",-90.,90.,90.)));
4665   cableTrayAForw->AddNode(forwHiCabsPUR, 1,
4666                       new TGeoCombiTrans(-xloc, yloc, 0,
4667                                          new TGeoRotation("",-90.,90.,90.)));
4668
4669   xloc = 2*optFibsForw->GetZ(1) + coaxCablesForwCu->GetZ(1) +
4670          coolTubeForw->GetRmax();
4671   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4672   cableTrayAForw->AddNode(forwCoaxCu, 1,
4673                       new TGeoCombiTrans( xloc, yloc, 0,
4674                                          new TGeoRotation("",-90.,90.,90.)));
4675   cableTrayAForw->AddNode(forwCoaxMeg, 1,
4676                       new TGeoCombiTrans( xloc, yloc, 0,
4677                                          new TGeoRotation("",-90.,90.,90.)));
4678
4679   // To simplify following placement in MARS, origin is on top
4680   yloc = -kExternalTrayHigh + kExternalTrayThick/2;
4681   zloc = kExternalTrayLen/2;
4682   cableTrayAExt->AddNode(extTrayAHorFace, 1,
4683                       new TGeoTranslation( 0, yloc, zloc));
4684
4685   xloc = kExternalTrayWide/2 - kExternalTrayThick/2;
4686   yloc = -kExternalTrayHigh/2;
4687   cableTrayAExt->AddNode(extTrayAVerFace, 1,
4688                       new TGeoTranslation( xloc, yloc, zloc));
4689   cableTrayAExt->AddNode(extTrayAVerFace, 2,
4690                       new TGeoTranslation(-xloc, yloc, zloc));
4691
4692   yloc = -kExternalTrayThick/2;
4693   cableTrayAExt->AddNode(extTrayAHorFace, 2,
4694                       new TGeoTranslation( 0, yloc, zloc));
4695
4696   yloc = -kExternalTrayHigh
4697        + kExternalTrayThick + kForwardTrayInterSpace - kExternalTrayThick/2;
4698   cableTrayAExt->AddNode(extTrayAHorFace, 3,
4699                       new TGeoTranslation( 0, yloc, zloc));
4700
4701   yloc = -kExternalTrayHigh + kExternalTrayThick + extTrayWall->GetDY();
4702   cableTrayAExt->AddNode(extTrayAWall, 1,
4703                       new TGeoTranslation( 0, yloc, zloc));
4704
4705   extCoolTube->AddNode(extCoolFreon, 1, 0);
4706
4707   yloc = -kExternalTrayHigh + 2*kExternalTrayThick + 2*extTrayWall->GetDY()
4708        + coolTubeExt->GetRmax();
4709   zloc = coolTubeExt->GetDz();
4710   cableTrayAExt->AddNode(extCoolTube, 1,
4711                       new TGeoTranslation(0, yloc, zloc));
4712
4713   xloc = optFibsExt->GetZ(1) + coolTubeExt->GetRmax();
4714   cableTrayAExt->AddNode(extOptFibs, 1,
4715                       new TGeoCombiTrans( xloc, 0, 0,
4716                                          new TGeoRotation("",90,-90,-90)));
4717
4718   xloc = coolTubeExt->GetRmax();
4719   cableTrayAExt->AddNode(extLowCabsCu, 1,
4720                       new TGeoCombiTrans(-xloc, 0, 0,
4721                                          new TGeoRotation("",90,-90,-90)));
4722   cableTrayAExt->AddNode(extLowCabsPUR, 1,
4723                       new TGeoCombiTrans(-xloc, 0, 0,
4724                                          new TGeoRotation("",90,-90,-90)));
4725
4726   xloc = lowCablesExtCu->GetZ(1) + coolTubeExt->GetRmax();
4727   cableTrayAExt->AddNode(extHiCabsCu, 1,
4728                       new TGeoCombiTrans(-xloc, 0, 0,
4729                                          new TGeoRotation("",90,-90,-90)));
4730   cableTrayAExt->AddNode(extHiCabsPUR, 1,
4731                       new TGeoCombiTrans(-xloc, 0, 0,
4732                                          new TGeoRotation("",90,-90,-90)));
4733
4734   xloc = coaxCablesExtCu->GetZ(1) + optFibsExt->GetZ(1) +
4735          coolTubeExt->GetRmax();
4736   cableTrayAExt->AddNode(extCoaxCu, 1,
4737                       new TGeoCombiTrans( xloc, 0, 0,
4738                                          new TGeoRotation("",90,-90,-90)));
4739   cableTrayAExt->AddNode(extCoaxMeg, 1,
4740                       new TGeoCombiTrans( xloc, 0, 0,
4741                                          new TGeoRotation("",90,-90,-90)));
4742
4743
4744   // Finally put everything in the mother volume
4745   Double_t rExtTray = kTrayAR2Trans + kExternalTrayHigh;
4746
4747   moth->AddNode(cableTrayAForw,1,
4748                 new TGeoTranslation( 0, kTrayAR1Trans, kTrayAZTrans));
4749   moth->AddNode(cableTrayAForw,2,
4750                 new TGeoCombiTrans(  0,-kTrayAR1Trans, kTrayAZTrans,
4751                                     new TGeoRotation("",180, 0, 0)));
4752
4753   yloc = kTrayAR1Trans + kExternalTrayHigh;
4754   zloc = kTrayAZTrans + kForwardTrayTotalLen;
4755   moth->AddNode(cableTrayAExt,1,
4756                 new TGeoCombiTrans( 0, yloc, zloc,
4757                                     new TGeoRotation("",  0,-kTrayAZRot, 0)));
4758   moth->AddNode(cableTrayAExt,2,
4759                 new TGeoCombiTrans( 0,-yloc, zloc,
4760                                     new TGeoRotation("",180,-kTrayAZRot, 0)));
4761
4762   alpharot = kTrayAFirstRotAng + kTrayASecondRotAng;
4763   xloc = kTrayAR2Trans*SinD(alpharot);
4764   yloc = kTrayAR2Trans*CosD(alpharot);
4765   moth->AddNode(cableTrayAForw,3,
4766                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4767                             new TGeoRotation("",-alpharot,0,0)   )   );
4768   xloc = rExtTray*SinD(alpharot);
4769   yloc = rExtTray*CosD(alpharot);
4770   moth->AddNode(cableTrayAExt,3,
4771                             new TGeoCombiTrans( xloc, yloc, zloc,
4772                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4773
4774   alpharot += 180;
4775   xloc = kTrayAR2Trans*SinD(alpharot);
4776   yloc = kTrayAR2Trans*CosD(alpharot);
4777   moth->AddNode(cableTrayAForw,4,
4778                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4779                             new TGeoRotation("",-alpharot,0,0)   )   );
4780   xloc = rExtTray*SinD(alpharot);
4781   yloc = rExtTray*CosD(alpharot);
4782   moth->AddNode(cableTrayAExt,4,
4783                             new TGeoCombiTrans( xloc, yloc, zloc,
4784                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4785
4786   alpharot = - kTrayAFirstRotAng - kTrayASecondRotAng;
4787   xloc = kTrayAR2Trans*SinD(alpharot);
4788   yloc = kTrayAR2Trans*CosD(alpharot);
4789   moth->AddNode(cableTrayAForw,5,
4790                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4791                             new TGeoRotation("",-alpharot,0,0)   )   );
4792   xloc = rExtTray*SinD(alpharot);
4793   yloc = rExtTray*CosD(alpharot);
4794   moth->AddNode(cableTrayAExt,5,
4795                             new TGeoCombiTrans( xloc, yloc, zloc,
4796                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4797
4798   alpharot += 180;
4799   xloc = kTrayAR2Trans*SinD(alpharot);
4800   yloc = kTrayAR2Trans*CosD(alpharot);
4801   moth->AddNode(cableTrayAForw,6,
4802                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4803                             new TGeoRotation("",-alpharot,0,0)   )   );
4804   xloc = rExtTray*SinD(alpharot);
4805   yloc = rExtTray*CosD(alpharot);
4806   moth->AddNode(cableTrayAExt,6,
4807                             new TGeoCombiTrans( xloc, yloc, zloc,
4808                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4809
4810   alpharot = kTrayAFirstRotAng + 3*kTrayASecondRotAng;
4811   xloc = kTrayAR2Trans*SinD(alpharot);
4812   yloc = kTrayAR2Trans*CosD(alpharot);
4813   moth->AddNode(cableTrayAForw,7,
4814                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4815                             new TGeoRotation("",-alpharot,0,0)   )   );
4816   xloc = rExtTray*SinD(alpharot);
4817   yloc = rExtTray*CosD(alpharot);
4818   moth->AddNode(cableTrayAExt,7,
4819                             new TGeoCombiTrans( xloc, yloc, zloc,
4820                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4821
4822   alpharot += 180;
4823   xloc = kTrayAR2Trans*SinD(alpharot);
4824   yloc = kTrayAR2Trans*CosD(alpharot);
4825   moth->AddNode(cableTrayAForw,8,
4826                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4827                             new TGeoRotation("",-alpharot,0,0)   )   );
4828   xloc = rExtTray*SinD(alpharot);
4829   yloc = rExtTray*CosD(alpharot);
4830   moth->AddNode(cableTrayAExt,8,
4831                             new TGeoCombiTrans( xloc, yloc, zloc,
4832                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4833
4834   alpharot = - kTrayAFirstRotAng - 3*kTrayASecondRotAng;
4835   xloc = kTrayAR2Trans*SinD(alpharot);
4836   yloc = kTrayAR2Trans*CosD(alpharot);
4837   moth->AddNode(cableTrayAForw,9,
4838                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4839                             new TGeoRotation("",-alpharot,0,0)   )   );
4840   xloc = rExtTray*SinD(alpharot);
4841   yloc = rExtTray*CosD(alpharot);
4842   moth->AddNode(cableTrayAExt,9,
4843                             new TGeoCombiTrans( xloc, yloc, zloc,
4844                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4845
4846   alpharot += 180;
4847   xloc = kTrayAR2Trans*SinD(alpharot);
4848   yloc = kTrayAR2Trans*CosD(alpharot);
4849   moth->AddNode(cableTrayAForw,10,
4850                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4851                             new TGeoRotation("",-alpharot,0,0)   )   );
4852   xloc = rExtTray*SinD(alpharot);
4853   yloc = rExtTray*CosD(alpharot);
4854   moth->AddNode(cableTrayAExt,10,
4855                             new TGeoCombiTrans( xloc, yloc, zloc,
4856                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4857
4858
4859   return;
4860 }
4861
4862 //______________________________________________________________________
4863 void AliITSv11GeometrySupport::SPDCableTraysSideC(TGeoVolume *moth,
4864                                             const TGeoManager *mgr){
4865 //
4866 // Creates the SPD cable trays which are outside the ITS support cones
4867 // but still inside the TPC on Side C
4868 // (part of this code is taken or anyway inspired to ServicesCableSupport
4869 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
4870 //
4871 // Input:
4872 //         moth : the TGeoVolume owing the volume structure
4873 //         mgr  : the GeoManager (default gGeoManager)
4874 // Output:
4875 //
4876 // Return:
4877 //
4878 // Created:         ???       Bjorn S. Nilsen
4879 // Updated:      22 Apr 2010  Mario Sitta
4880 // Updated:      10 Jun 2010  Mario Sitta  Freon inside cooling pipes
4881 // Updated:      08 Sep 2010  Mario Sitta
4882 // Updated:      14 Sep 2010  Mario Sitta  Cables prolonged till cone
4883 // Updated:      20 Dec 2011  Mario Sitta  Composite vol to avoid new overlap
4884 //
4885 // Technical data are taken from AutoCAD drawings and other (oral)
4886 // information given by D.Elia
4887 // Optical fibers and voltage cables are approximated with mean materials
4888 // and square cross sections, but preserving the total material budget.
4889 //
4890
4891   // Dimensions and positions of the C-Side Cable Tray elements
4892   const Int_t    kNumTraysSideC       =   10;
4893
4894   const Double_t kTrayCCablesOutRot   =   75.000 *fgkDegree;// Computed
4895   const Double_t kTrayCCablesZLenOut  =  245.000 *fgkmm;// Computed
4896
4897   const Double_t kTrayCHalfWide       =    6.350 *fgkcm;
4898   const Double_t kTrayCLength1        =  172.800 *fgkcm;
4899   const Double_t kTrayCLength2        =  189.300 *fgkcm;
4900   const Double_t kTrayCFirstLen       =  435.000 *fgkmm;
4901   const Double_t kTrayCFirstHigh      =   83.000 *fgkmm;//!!!TO BE CHECKED!!!
4902   const Double_t kTrayCSecondHigh     =   52.700 *fgkmm;//!!!TO BE CHECKED!!!
4903   const Double_t kTrayCThick          =    0.200 *fgkcm;
4904   const Double_t kTrayCInterSpace     =   18.000 *fgkmm;//!!!TO BE CHECKED!!!
4905   const Double_t kTrayCFoldAngle      =    5.000 *fgkDegree;
4906
4907   const Double_t kCoolingTubeRmin     =    2.000 *fgkmm;
4908   const Double_t kCoolingTubeRmax     =    3.000 *fgkmm;
4909   const Double_t kOpticalFibersSect   =    8.696 *fgkmm;//!!!ESTIMATED!!!
4910   const Double_t kLowVoltCableSectCu  =    7.675 *fgkmm;// Computed
4911   const Double_t kLowVoltCableHighPUR =    1.000 *fgkmm;// Computed
4912   const Double_t kHiVoltCableSectCu   =    1.535 *fgkmm;// Computed
4913   const Double_t kHiVoltCableHighPUR  =    0.500 *fgkmm;// Computed
4914   const Double_t kCoaxCableSectCu     =    6.024 *fgkmm;// Computed
4915   const Double_t kCoaxCableHighMeg    =    5.695 *fgkmm;// Computed
4916
4917   const Double_t kCablesYtrans        =    2.500 *fgkmm;// Avoid ovlps
4918
4919   // Overall position and rotation of the C-Side Cable Trays
4920   const Double_t kTraySideCRPos       =   45.300 *fgkcm;
4921   const Double_t kTraySideCZPos       = -102.400 *fgkcm;
4922   const Double_t kTraySideCAlphaRot[kNumTraysSideC/2]  =
4923     {    0.0,      41.0,     -41.0,      76.0,      -76.0};
4924   // From position of the other trays
4925
4926
4927   // Local variables
4928   Double_t xprof[8], yprof[8];
4929   Double_t xloc, yloc, zloc, delta, alpharot;
4930
4931
4932   // The single C-Side Cable tray as an assembly
4933   TGeoVolumeAssembly *cableTrayC = new TGeoVolumeAssembly("ITSsupportSPDTrayC");
4934
4935   // First create all needed shapes
4936
4937   // The Cable Tray lower face: a Xtru
4938   TGeoXtru *sideCHorFace = new TGeoXtru(2);
4939   sideCHorFace->SetName("ITSsuppSPDTraySideCHor");
4940
4941   xprof[0] = 0.;
4942   yprof[0] = 0.;
4943   xprof[1] = kTrayCLength1;
4944   yprof[1] = 0.;
4945   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4946   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4947   xprof[3] = xprof[2] - kTrayCThick*SinD(kTrayCFoldAngle);
4948   yprof[3] = yprof[2] + kTrayCThick*CosD(kTrayCFoldAngle);
4949   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4950               kTrayCThick , xprof[4], yprof[4]);
4951   xprof[5] = 0.;
4952   yprof[5] = kTrayCThick;
4953
4954   delta = kTrayCHalfWide - kTrayCThick;
4955
4956   sideCHorFace->DefinePolygon(6, xprof, yprof);
4957   sideCHorFace->DefineSection(0,-delta);
4958   sideCHorFace->DefineSection(1, delta);
4959
4960   // The Cable Tray middle face: a Xtru
4961   // (somehow duplicate of HorFace, but in this way avoid an overlap with Wall)
4962   TGeoXtru *sideCMidFace = new TGeoXtru(2);
4963
4964   xprof[0] = 0.;
4965   yprof[0] = kTrayCInterSpace + kTrayCThick;
4966   xprof[1] = kTrayCLength1;
4967   yprof[1] = yprof[0];
4968   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4969   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4970   xprof[3] = xprof[2] - kTrayCThick*SinD(kTrayCFoldAngle);
4971   yprof[3] = yprof[2] + kTrayCThick*CosD(kTrayCFoldAngle);
4972   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4973               kTrayCThick , xprof[4], yprof[4]);
4974   xprof[5] = 0.;
4975   yprof[5] = yprof[0] + kTrayCThick;
4976
4977   delta = kTrayCHalfWide - kTrayCThick;
4978
4979   sideCMidFace->DefinePolygon(6, xprof, yprof);
4980   sideCMidFace->DefineSection(0,-delta);
4981   sideCMidFace->DefineSection(1, delta);
4982
4983   // The Cable Tray lower face: a Xtru
4984   TGeoXtru *sideCSideFace = new TGeoXtru(2);
4985
4986   xprof[0] = 0.;
4987   yprof[0] = 0.;
4988   xprof[1] = kTrayCLength1;
4989   yprof[1] = 0.;
4990   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4991   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4992   xprof[3] = xprof[2] - kTrayCSecondHigh*SinD(kTrayCFoldAngle);
4993   yprof[3] = yprof[2] + kTrayCSecondHigh*CosD(kTrayCFoldAngle);
4994   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4995               kTrayCSecondHigh , xprof[4], yprof[4]);
4996   xprof[5] = kTrayCFirstLen;
4997   yprof[5] = kTrayCSecondHigh;
4998   xprof[6] = xprof[5];
4999   yprof[6] = kTrayCFirstHigh;
5000   xprof[7] = xprof[0];
5001   yprof[7] = yprof[6];
5002
5003   sideCSideFace->DefinePolygon(8, xprof, yprof);
5004   sideCSideFace->DefineSection(0, 0);
5005   sideCSideFace->DefineSection(1, kTrayCThick);
5006
5007   // The short cover: a BBox
5008   TGeoBBox *sideCShortCover = new TGeoBBox(kTrayCFirstLen/2,
5009                                            kTrayCThick/2,
5010                                            kTrayCHalfWide-kTrayCThick);
5011
5012   // The long cover: a Xtru
5013   TGeoXtru *sideCLongCover = new TGeoXtru(2);
5014
5015   xprof[5] = sideCSideFace->GetX(5);
5016   yprof[5] = sideCSideFace->GetY(5);
5017   xprof[4] = sideCSideFace->GetX(4);
5018   yprof[4] = sideCSideFace->GetY(4);
5019   xprof[3] = sideCSideFace->GetX(3);
5020   yprof[3] = sideCSideFace->GetY(3);
5021   xprof[2] = xprof[3] + kTrayCThick*SinD(kTrayCFoldAngle);
5022   yprof[2] = yprof[3] - kTrayCThick*CosD(kTrayCFoldAngle);
5023   InsidePoint(xprof[5], yprof[5], xprof[4], yprof[4], xprof[3], yprof[3],
5024              -kTrayCThick , xprof[1], yprof[1]);
5025   xprof[0] = xprof[5];
5026   yprof[0] = yprof[5] - kTrayCThick;
5027
5028   delta = kTrayCHalfWide - kTrayCThick;
5029
5030   sideCLongCover->DefinePolygon(6, xprof, yprof);
5031   sideCLongCover->DefineSection(0,-delta);
5032   sideCLongCover->DefineSection(1, delta);
5033
5034   // The internal wall: a Xtru
5035   TGeoXtru *intWall = new TGeoXtru(2);
5036   intWall->SetName("ITSsuppSPDTraySideCWall");
5037
5038   xprof[0] = sideCHorFace->GetX(5);
5039   yprof[0] = sideCHorFace->GetY(5);
5040   xprof[1] = sideCHorFace->GetX(4);
5041   yprof[1] = sideCHorFace->GetY(4);
5042   xprof[2] = sideCHorFace->GetX(3);
5043   yprof[2] = sideCHorFace->GetY(3);
5044   xprof[3] = sideCMidFace->GetX(2);
5045   yprof[3] = sideCMidFace->GetY(2);
5046   xprof[4] = sideCMidFace->GetX(1);
5047   yprof[4] = sideCMidFace->GetY(1);
5048   xprof[5] = sideCMidFace->GetX(0);
5049   yprof[5] = sideCMidFace->GetY(0);
5050
5051   intWall->DefinePolygon(6, xprof, yprof);
5052   intWall->DefineSection(0,-kTrayCThick/2);
5053   intWall->DefineSection(1, kTrayCThick/2);
5054
5055   // The horizontal part of the cooling tube inside the tray: a Tube
5056   delta = sideCMidFace->GetX(4) - sideCMidFace->GetX(5);
5057   TGeoTube *horTube = new TGeoTube(0, kCoolingTubeRmax, delta/2);
5058
5059   // The freon inside the horizontal part of the cooling tube: a Tube
5060   TGeoTube *horFreon = new TGeoTube(0, kCoolingTubeRmin, delta/2);
5061
5062   // The inclined part of the cooling tube inside the tray: a Ctub
5063   Double_t x3, y3, x4, y4;
5064   x3 = sideCMidFace->GetX(3);
5065   y3 = sideCMidFace->GetY(3);
5066   x4 = sideCMidFace->GetX(4);
5067   y4 = sideCMidFace->GetY(4);
5068   delta = TMath::Sqrt( (x4 - x3 + kCoolingTubeRmax*SinD(kTrayCFoldAngle))*
5069                        (x4 - x3 + kCoolingTubeRmax*SinD(kTrayCFoldAngle))    +
5070        (y4 + kCoolingTubeRmax - y3 - kCoolingTubeRmax*SinD(kTrayCFoldAngle))*
5071        (y4 + kCoolingTubeRmax - y3 - kCoolingTubeRmax*SinD(kTrayCFoldAngle)) );
5072
5073   TGeoCtub *incTube = new TGeoCtub(0, kCoolingTubeRmax, delta/2, 0, 360,
5074                                0, SinD(kTrayCFoldAngle),-CosD(kTrayCFoldAngle),
5075                                0,                     0,                    1);
5076
5077   // The freon inside the inclined part of the cooling tube: a Ctub
5078   TGeoCtub *incFreon = new TGeoCtub(0, kCoolingTubeRmin, delta/2, 0, 360,
5079                                0, SinD(kTrayCFoldAngle),-CosD(kTrayCFoldAngle),
5080                                0,                     0,                    1);
5081
5082   // The part of the cooling tube outside the tray: a Ctub
5083   TGeoCtub *outTube = new TGeoCtub(0, kCoolingTubeRmax,
5084                         0.5*kTrayCCablesZLenOut/SinD(kTrayCCablesOutRot),
5085                         0, 360,
5086                         0,                        0,                      -1,
5087                         0,-SinD(kTrayCCablesOutRot), CosD(kTrayCCablesOutRot));
5088
5089   // The freon inside the part of the cooling tube outside the tray: a Ctub
5090   TGeoCtub *outFreon = new TGeoCtub(0, kCoolingTubeRmin,
5091                         outTube->GetDz(),
5092                         0, 360,
5093                         0,                        0,                      -1,
5094                         0,-SinD(kTrayCCablesOutRot), CosD(kTrayCCablesOutRot));
5095
5096   // The optical fibers inside the tray: a Xtru
5097   TGeoXtru *optFibs = new TGeoXtru(2);
5098
5099   xprof[0] = -kTrayCCablesZLenOut;
5100   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5101   xprof[1] = sideCMidFace->GetX(5);
5102   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5103   xprof[2] = sideCMidFace->GetX(4);
5104   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5105   xprof[3] = sideCMidFace->GetX(3);
5106   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5107   xprof[4] = xprof[3] - kOpticalFibersSect*SinD(kTrayCFoldAngle);
5108   yprof[4] = yprof[3] + kOpticalFibersSect*CosD(kTrayCFoldAngle);
5109   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5110               kOpticalFibersSect , xprof[5], yprof[5]);
5111   xprof[6] = 0.;
5112   yprof[6] = yprof[1] + kOpticalFibersSect;
5113   xprof[7] = xprof[0];
5114   yprof[7] = yprof[0] + kOpticalFibersSect;
5115
5116   optFibs->DefinePolygon(8, xprof, yprof);
5117   optFibs->DefineSection(0, 0);
5118   optFibs->DefineSection(1, kOpticalFibersSect);
5119
5120   // The low voltage cables inside the tray: two Xtru
5121   TGeoXtru *lowCablesCu = new TGeoXtru(2);
5122
5123   xprof[0] = -kTrayCCablesZLenOut;
5124   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5125   xprof[1] = sideCMidFace->GetX(5);
5126   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5127   xprof[2] = sideCMidFace->GetX(4);
5128   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5129   xprof[3] = sideCMidFace->GetX(3);
5130   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5131   xprof[4] = xprof[3] - kLowVoltCableSectCu*SinD(kTrayCFoldAngle);
5132   yprof[4] = yprof[3] + kLowVoltCableSectCu*CosD(kTrayCFoldAngle);
5133   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5134               kLowVoltCableSectCu , xprof[5], yprof[5]);
5135   xprof[6] = 0.;
5136   yprof[6] = yprof[1] + kLowVoltCableSectCu;
5137   xprof[7] = xprof[0];
5138   yprof[7] = yprof[0] + kLowVoltCableSectCu;
5139
5140   lowCablesCu->DefinePolygon(8, xprof, yprof);
5141   lowCablesCu->DefineSection(0, 0);
5142   lowCablesCu->DefineSection(1, kLowVoltCableSectCu);
5143
5144   TGeoXtru *lowCablesPUR = new TGeoXtru(2);
5145
5146   xprof[0] = lowCablesCu->GetX(7);
5147   yprof[0] = lowCablesCu->GetY(7);
5148   xprof[1] = lowCablesCu->GetX(6);
5149   yprof[1] = lowCablesCu->GetY(6);
5150   xprof[2] = lowCablesCu->GetX(5);
5151   yprof[2] = lowCablesCu->GetY(5);
5152   xprof[3] = lowCablesCu->GetX(4);
5153   yprof[3] = lowCablesCu->GetY(4);
5154   xprof[4] = xprof[3] - kLowVoltCableHighPUR*SinD(kTrayCFoldAngle);
5155   yprof[4] = yprof[3] + kLowVoltCableHighPUR*CosD(kTrayCFoldAngle);
5156   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5157               kLowVoltCableHighPUR , xprof[5], yprof[5]);
5158   xprof[6] = 0.;
5159   yprof[6] = yprof[1] + kLowVoltCableHighPUR;
5160   xprof[7] = xprof[0];
5161   yprof[7] = yprof[0] + kLowVoltCableHighPUR;
5162
5163   lowCablesPUR->DefinePolygon(8, xprof, yprof);
5164   lowCablesPUR->DefineSection(0, 0);
5165   lowCablesPUR->DefineSection(1, kLowVoltCableSectCu);
5166
5167   // The high voltage cables inside the tray: two Xtru
5168   TGeoXtru *hiCablesCu = new TGeoXtru(2);
5169
5170   xprof[0] = -kTrayCCablesZLenOut;
5171   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5172   xprof[1] = sideCMidFace->GetX(5);
5173   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5174   xprof[2] = sideCMidFace->GetX(4);
5175   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5176   xprof[3] = sideCMidFace->GetX(3);
5177   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5178   xprof[4] = xprof[3] - kHiVoltCableSectCu*SinD(kTrayCFoldAngle);
5179   yprof[4] = yprof[3] + kHiVoltCableSectCu*CosD(kTrayCFoldAngle);
5180   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5181               kHiVoltCableSectCu , xprof[5], yprof[5]);
5182   xprof[6] = 0.;
5183   yprof[6] = yprof[1] + kHiVoltCableSectCu;
5184   xprof[7] = xprof[0];
5185   yprof[7] = yprof[0] + kHiVoltCableSectCu;
5186
5187   hiCablesCu->DefinePolygon(8, xprof, yprof);
5188   hiCablesCu->DefineSection(0, 0);
5189   hiCablesCu->DefineSection(1, kHiVoltCableSectCu);
5190
5191   TGeoXtru *hiCablesPUR = new TGeoXtru(2);
5192
5193   xprof[0] = hiCablesCu->GetX(7);
5194   yprof[0] = hiCablesCu->GetY(7);
5195   xprof[1] = hiCablesCu->GetX(6);
5196   yprof[1] = hiCablesCu->GetY(6);
5197   xprof[2] = hiCablesCu->GetX(5);
5198   yprof[2] = hiCablesCu->GetY(5);
5199   xprof[3] = hiCablesCu->GetX(4);
5200   yprof[3] = hiCablesCu->GetY(4);
5201   xprof[4] = xprof[3] - kHiVoltCableHighPUR*SinD(kTrayCFoldAngle);
5202   yprof[4] = yprof[3] + kHiVoltCableHighPUR*CosD(kTrayCFoldAngle);
5203   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5204               kHiVoltCableHighPUR , xprof[5], yprof[5]);
5205   xprof[6] = 0.;
5206   yprof[6] = yprof[1] + kHiVoltCableHighPUR;
5207   xprof[7] = xprof[0];
5208   yprof[7] = yprof[0] + kHiVoltCableHighPUR;
5209
5210   hiCablesPUR->DefinePolygon(8, xprof, yprof);
5211   hiCablesPUR->DefineSection(0, 0);
5212   hiCablesPUR->DefineSection(1, kHiVoltCableSectCu);
5213
5214   // The coaxial cables inside the tray: two Xtru
5215   TGeoXtru *coaxCablesCu = new TGeoXtru(2);
5216
5217   xprof[0] = -kTrayCCablesZLenOut;
5218   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5219   xprof[1] = sideCMidFace->GetX(5);
5220   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5221   xprof[2] = sideCMidFace->GetX(4);
5222   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5223   xprof[3] = sideCMidFace->GetX(3);
5224   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5225   xprof[4] = xprof[3] - kCoaxCableSectCu*SinD(kTrayCFoldAngle);
5226   yprof[4] = yprof[3] + kCoaxCableSectCu*CosD(kTrayCFoldAngle);
5227   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5228               kCoaxCableSectCu , xprof[5], yprof[5]);
5229   xprof[6] = 0.;
5230   yprof[6] = yprof[1] + kCoaxCableSectCu;
5231   xprof[7] = xprof[0];
5232   yprof[7] = yprof[0] + kCoaxCableSectCu;
5233
5234   coaxCablesCu->DefinePolygon(8, xprof, yprof);
5235   coaxCablesCu->DefineSection(0, 0);
5236   coaxCablesCu->DefineSection(1, kCoaxCableSectCu);
5237
5238   TGeoXtru *coaxCablesMeg = new TGeoXtru(2);
5239
5240   xprof[0] = coaxCablesCu->GetX(7);
5241   yprof[0] = coaxCablesCu->GetY(7);
5242   xprof[1] = coaxCablesCu->GetX(6);
5243   yprof[1] = coaxCablesCu->GetY(6);
5244   xprof[2] = coaxCablesCu->GetX(5);
5245   yprof[2] = coaxCablesCu->GetY(5);
5246   xprof[3] = coaxCablesCu->GetX(4);
5247   yprof[3] = coaxCablesCu->GetY(4);
5248   xprof[4] = xprof[3] - kCoaxCableHighMeg*SinD(kTrayCFoldAngle);
5249   yprof[4] = yprof[3] + kCoaxCableHighMeg*CosD(kTrayCFoldAngle);
5250   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5251               kCoaxCableHighMeg , xprof[5], yprof[5]);
5252   xprof[6] = 0.;
5253   yprof[6] = yprof[1] + kCoaxCableHighMeg;
5254   xprof[7] = xprof[0];
5255   yprof[7] = yprof[0] + kCoaxCableHighMeg;
5256
5257   coaxCablesMeg->DefinePolygon(8, xprof, yprof);
5258   coaxCablesMeg->DefineSection(0, 0);
5259   coaxCablesMeg->DefineSection(1, kCoaxCableSectCu);
5260
5261   // To avoid a newly discovered overlap,
5262   // transform the two overlapping volumes into a Composite Shape
5263   TGeoCompositeShape *trayIntern =
5264     new TGeoCompositeShape("ITSSPDInternalTrayC",
5265                            "ITSsuppSPDTraySideCHor+ITSsuppSPDTraySideCWall");
5266
5267   // We have all shapes: now create the real volumes
5268   TGeoMedium *medAl   = mgr->GetMedium("ITS_ALUMINUM$");
5269   TGeoMedium *medIn   = mgr->GetMedium("ITS_INOX$");
5270   TGeoMedium *medFr   = mgr->GetMedium("ITS_Freon$");
5271   TGeoMedium *medFibs = mgr->GetMedium("ITS_SDD OPTICFIB$");//!!TO BE CHECKED!!
5272   TGeoMedium *medCu   = mgr->GetMedium("ITS_COPPER$");
5273   TGeoMedium *medPUR  = mgr->GetMedium("ITS_POLYURETHANE$");
5274   TGeoMedium *medMeg  = mgr->GetMedium("ITS_MEGOLON$");
5275
5276   TGeoVolume *traySideCIntern  = new TGeoVolume("ITSsuppSPDTraySideCInternal",
5277                                                 trayIntern, medAl);
5278
5279   traySideCIntern->SetVisibility(kTRUE);
5280   traySideCIntern->SetLineColor(6); // Purple
5281   traySideCIntern->SetLineWidth(1);
5282   traySideCIntern->SetFillColor(traySideCIntern->GetLineColor());
5283   traySideCIntern->SetFillStyle(4000); // 0% transparent
5284
5285   TGeoVolume *traySideCMidFace  = new TGeoVolume("ITSsuppSPDTraySideCMid",
5286                                                  sideCMidFace, medAl);
5287
5288   traySideCMidFace->SetVisibility(kTRUE);
5289   traySideCMidFace->SetLineColor(6); // Purple
5290   traySideCMidFace->SetLineWidth(1);
5291   traySideCMidFace->SetFillColor(traySideCMidFace->GetLineColor());
5292   traySideCMidFace->SetFillStyle(4000); // 0% transparent
5293
5294   TGeoVolume *traySideCSideFace  = new TGeoVolume("ITSsuppSPDTraySideCSide",
5295                                                   sideCSideFace, medAl);
5296
5297   traySideCSideFace->SetVisibility(kTRUE);
5298   traySideCSideFace->SetLineColor(6); // Purple
5299   traySideCSideFace->SetLineWidth(1);
5300   traySideCSideFace->SetFillColor(traySideCSideFace->GetLineColor());
5301   traySideCSideFace->SetFillStyle(4000); // 0% transparent
5302
5303   TGeoVolume *traySideCShortCover  = new TGeoVolume("ITSsuppSPDTraySideCShCov",
5304                                                     sideCShortCover, medAl);
5305
5306   traySideCShortCover->SetVisibility(kTRUE);
5307   traySideCShortCover->SetLineColor(6); // Purple
5308   traySideCShortCover->SetLineWidth(1);
5309   traySideCShortCover->SetFillColor(traySideCShortCover->GetLineColor());
5310   traySideCShortCover->SetFillStyle(4000); // 0% transparent
5311
5312   TGeoVolume *traySideCLongCover  = new TGeoVolume("ITSsuppSPDTraySideCLnCov",
5313                                                    sideCLongCover, medAl);
5314
5315   traySideCLongCover->SetVisibility(kTRUE);
5316   traySideCLongCover->SetLineColor(6); // Purple
5317   traySideCLongCover->SetLineWidth(1);
5318   traySideCLongCover->SetFillColor(traySideCLongCover->GetLineColor());
5319   traySideCLongCover->SetFillStyle(4000); // 0% transparent
5320
5321   TGeoVolume *traySideCHorTube = new TGeoVolume("ITSsuppSPDTraySideCHorTube",
5322                                                 horTube, medIn);
5323
5324   traySideCHorTube->SetVisibility(kTRUE);
5325   traySideCHorTube->SetLineColor(kGray); // as in GeometrySPD
5326   traySideCHorTube->SetLineWidth(1);
5327   traySideCHorTube->SetFillColor(traySideCHorTube->GetLineColor());
5328   traySideCHorTube->SetFillStyle(4000); // 0% transparent
5329
5330   TGeoVolume *traySideCHorFreon = new TGeoVolume("ITSsuppSPDTraySideCHorFreon",
5331                                                  horFreon, medFr);
5332
5333   traySideCHorFreon->SetVisibility(kTRUE);
5334   traySideCHorFreon->SetLineColor(kBlue); // Blue
5335   traySideCHorFreon->SetLineWidth(1);
5336   traySideCHorFreon->SetFillColor(traySideCHorFreon->GetLineColor());
5337   traySideCHorFreon->SetFillStyle(4000); // 0% transparent
5338
5339   TGeoVolume *traySideCIncTube = new TGeoVolume("ITSsuppSPDTraySideCIncTube",
5340                                                 incTube, medIn);
5341
5342   traySideCIncTube->SetVisibility(kTRUE);
5343   traySideCIncTube->SetLineColor(kGray); // as in GeometrySPD
5344   traySideCIncTube->SetLineWidth(1);
5345   traySideCIncTube->SetFillColor(traySideCIncTube->GetLineColor());
5346   traySideCIncTube->SetFillStyle(4000); // 0% transparent
5347
5348   TGeoVolume *traySideCIncFreon = new TGeoVolume("ITSsuppSPDTraySideCIncFreon",
5349                                                  incFreon, medFr);
5350
5351   traySideCIncFreon->SetVisibility(kTRUE);
5352   traySideCIncFreon->SetLineColor(kBlue); // Blue
5353   traySideCIncFreon->SetLineWidth(1);
5354   traySideCIncFreon->SetFillColor(traySideCIncFreon->GetLineColor());
5355   traySideCIncFreon->SetFillStyle(4000); // 0% transparent
5356
5357   TGeoVolume *traySideCOutTube = new TGeoVolume("ITSsuppSPDTraySideCOutTube",
5358                                                 outTube, medIn);
5359
5360   traySideCOutTube->SetVisibility(kTRUE);
5361   traySideCOutTube->SetLineColor(kGray); // as in GeometrySPD
5362   traySideCOutTube->SetLineWidth(1);
5363   traySideCOutTube->SetFillColor(traySideCOutTube->GetLineColor());
5364   traySideCOutTube->SetFillStyle(4000); // 0% transparent
5365
5366   TGeoVolume *traySideCOutFreon = new TGeoVolume("ITSsuppSPDTraySideCOutFreon",
5367                                                  outFreon, medFr);
5368
5369   traySideCOutFreon->SetVisibility(kTRUE);
5370   traySideCOutFreon->SetLineColor(kBlue); // Blue
5371   traySideCOutFreon->SetLineWidth(1);
5372   traySideCOutFreon->SetFillColor(traySideCOutFreon->GetLineColor());
5373   traySideCOutFreon->SetFillStyle(4000); // 0% transparent
5374
5375   TGeoVolume *traySideCOptFibs = new TGeoVolume("ITSsuppSPDTraySideCOptFibs",
5376                                                 optFibs, medFibs);
5377
5378   traySideCOptFibs->SetVisibility(kTRUE);
5379   traySideCOptFibs->SetLineColor(kOrange); // Orange
5380   traySideCOptFibs->SetLineWidth(1);
5381   traySideCOptFibs->SetFillColor(traySideCOptFibs->GetLineColor());
5382   traySideCOptFibs->SetFillStyle(4000); // 0% transparent
5383
5384   TGeoVolume *traySideCLowCabsCu = new TGeoVolume("ITSsuppSPDTraySideCLVCu",
5385                                                   lowCablesCu, medCu);
5386
5387   traySideCLowCabsCu->SetVisibility(kTRUE);
5388   traySideCLowCabsCu->SetLineColor(kRed); // Red
5389   traySideCLowCabsCu->SetLineWidth(1);
5390   traySideCLowCabsCu->SetFillColor(traySideCLowCabsCu->GetLineColor());
5391   traySideCLowCabsCu->SetFillStyle(4000); // 0% transparent
5392
5393   TGeoVolume *traySideCLowCabsPUR = new TGeoVolume("ITSsuppSPDTraySideCLVPUR",
5394                                                    lowCablesPUR, medPUR);
5395
5396   traySideCLowCabsPUR->SetVisibility(kTRUE);
5397   traySideCLowCabsPUR->SetLineColor(kBlack); // Black
5398   traySideCLowCabsPUR->SetLineWidth(1);
5399   traySideCLowCabsPUR->SetFillColor(traySideCLowCabsPUR->GetLineColor());
5400   traySideCLowCabsPUR->SetFillStyle(4000); // 0% transparent
5401
5402   TGeoVolume *traySideCHiCabsCu = new TGeoVolume("ITSsuppSPDTraySideCHVCu",
5403                                                  hiCablesCu, medCu);
5404
5405   traySideCHiCabsCu->SetVisibility(kTRUE);
5406   traySideCHiCabsCu->SetLineColor(kRed); // Red
5407   traySideCHiCabsCu->SetLineWidth(1);
5408   traySideCHiCabsCu->SetFillColor(traySideCHiCabsCu->GetLineColor());
5409   traySideCHiCabsCu->SetFillStyle(4000); // 0% transparent
5410
5411   TGeoVolume *traySideCHiCabsPUR = new TGeoVolume("ITSsuppSPDTraySideCHVPUR",
5412                                                   hiCablesPUR, medPUR);
5413
5414   traySideCHiCabsPUR->SetVisibility(kTRUE);
5415   traySideCHiCabsPUR->SetLineColor(kBlack); // Black
5416   traySideCHiCabsPUR->SetLineWidth(1);
5417   traySideCHiCabsPUR->SetFillColor(traySideCHiCabsPUR->GetLineColor());
5418   traySideCHiCabsPUR->SetFillStyle(4000); // 0% transparent
5419
5420   TGeoVolume *traySideCCoaxCu = new TGeoVolume("ITSsuppSPDTraySideCCoaxCu",
5421                                                coaxCablesCu, medCu);
5422
5423   traySideCCoaxCu->SetVisibility(kTRUE);
5424   traySideCCoaxCu->SetLineColor(kRed); // Red
5425   traySideCCoaxCu->SetLineWidth(1);
5426   traySideCCoaxCu->SetFillColor(traySideCCoaxCu->GetLineColor());
5427   traySideCCoaxCu->SetFillStyle(4000); // 0% transparent
5428
5429   TGeoVolume *traySideCCoaxMeg = new TGeoVolume("ITSsuppSPDTraySideCCoaxMeg",
5430                                                 coaxCablesMeg, medMeg);
5431
5432   traySideCCoaxMeg->SetVisibility(kTRUE);
5433   traySideCCoaxMeg->SetLineColor(kBlack); // Black
5434   traySideCCoaxMeg->SetLineWidth(1);
5435   traySideCCoaxMeg->SetFillColor(traySideCCoaxMeg->GetLineColor());
5436   traySideCCoaxMeg->SetFillStyle(4000); // 0% transparent
5437
5438
5439   // Now build up the trays
5440   cableTrayC->AddNode(traySideCIntern,1,0);
5441
5442   cableTrayC->AddNode(traySideCMidFace,1,0);
5443
5444   zloc = kTrayCHalfWide - kTrayCThick;
5445   cableTrayC->AddNode(traySideCSideFace, 1,
5446                       new TGeoTranslation( 0, 0, zloc));
5447   zloc = -kTrayCHalfWide;
5448   cableTrayC->AddNode(traySideCSideFace, 2,
5449                       new TGeoTranslation( 0, 0, zloc));
5450
5451   xloc = sideCShortCover->GetDX();
5452   yloc = kTrayCFirstHigh - sideCShortCover->GetDY();
5453   cableTrayC->AddNode(traySideCShortCover, 1,
5454                       new TGeoTranslation( xloc, yloc, 0));
5455
5456   cableTrayC->AddNode(traySideCLongCover,1,0);
5457
5458   traySideCHorTube->AddNode(traySideCHorFreon, 1, 0);
5459   traySideCIncTube->AddNode(traySideCIncFreon, 1, 0);
5460   traySideCOutTube->AddNode(traySideCOutFreon, 1, 0);
5461
5462   xloc = horTube->GetDz();
5463   yloc = sideCMidFace->GetY(5) + horTube->GetRmax();
5464   cableTrayC->AddNode(traySideCHorTube, 1,
5465                       new TGeoCombiTrans( xloc, yloc, 0,
5466                       new TGeoRotation("",-90.,-90.,90.)));
5467
5468   xloc = sideCMidFace->GetX(4) + (incTube->GetDz())*CosD(kTrayCFoldAngle);
5469   yloc = sideCMidFace->GetY(4) +  incTube->GetRmax() +
5470             (incTube->GetDz())*SinD(kTrayCFoldAngle)+0.005;//Avoid small ovrlp
5471   cableTrayC->AddNode(traySideCIncTube, 1,
5472                       new TGeoCombiTrans( xloc, yloc, 0,
5473                       new TGeoRotation("",-90.+kTrayCFoldAngle,-90.,90.)));
5474
5475   xloc = -kTrayCCablesZLenOut/2 - outTube->GetRmax();
5476   yloc = xloc/TanD(kTrayCCablesOutRot) + sideCMidFace->GetY(4) -
5477          2*outTube->GetRmax();
5478   cableTrayC->AddNode(traySideCOutTube, 1,
5479                       new TGeoCombiTrans( xloc, yloc, 0,
5480                       new TGeoRotation("",-70.,-90.,90.)));
5481
5482   zloc = horTube->GetRmax();
5483   cableTrayC->AddNode(traySideCOptFibs, 1,
5484                       new TGeoTranslation( 0, 0, zloc));
5485
5486   zloc = kLowVoltCableSectCu + horTube->GetRmax();
5487   cableTrayC->AddNode(traySideCLowCabsCu, 1,
5488                       new TGeoTranslation( 0, 0,-zloc));
5489   cableTrayC->AddNode(traySideCLowCabsPUR, 1,
5490                       new TGeoTranslation( 0, 0,-zloc));
5491
5492   zloc = kHiVoltCableSectCu + kLowVoltCableSectCu + horTube->GetRmax();
5493   cableTrayC->AddNode(traySideCHiCabsCu, 1,
5494                       new TGeoTranslation( 0, 0,-zloc));
5495   cableTrayC->AddNode(traySideCHiCabsPUR, 1,
5496                       new TGeoTranslation( 0, 0,-zloc));
5497
5498   zloc = kOpticalFibersSect + kCoaxCableSectCu + horTube->GetRmax();
5499   cableTrayC->AddNode(traySideCCoaxCu, 1,
5500                       new TGeoTranslation( 0, 0, zloc));
5501   cableTrayC->AddNode(traySideCCoaxMeg, 1,
5502                       new TGeoTranslation( 0, 0, zloc));
5503
5504
5505   // Finally put everything in the mother volume
5506   for (Int_t jt = 0; jt < kNumTraysSideC/2; jt++) {
5507     alpharot = kTraySideCAlphaRot[jt];
5508
5509     xloc = kTraySideCRPos*SinD(alpharot);
5510     yloc = kTraySideCRPos*CosD(alpharot);
5511     moth->AddNode(cableTrayC,2*jt+1,
5512                 new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
5513                 new TGeoRotation("",-90.+alpharot,-90.,90.+kTrayCFoldAngle)));
5514     alpharot += 180;
5515     xloc = kTraySideCRPos*SinD(alpharot);
5516     yloc = kTraySideCRPos*CosD(alpharot);
5517     moth->AddNode(cableTrayC,2*jt+2,
5518                 new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
5519                 new TGeoRotation("",-90.+alpharot,-90.,90.+kTrayCFoldAngle)));
5520   }
5521
5522
5523   return;
5524 }
5525
5526 //______________________________________________________________________
5527 void AliITSv11GeometrySupport::SDDCableTraysSideA(TGeoVolume *moth,
5528                                              const TGeoManager *mgr){
5529 //
5530 // Creates the SDD cable trays which are outside the ITS support cones
5531 // but still inside the TPC on Side A
5532 // (part of this code is taken or anyway inspired to ServicesCableSupport
5533 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
5534 //
5535 // Input:
5536 //         moth : the TGeoVolume owing the volume structure
5537 //         mgr  : the GeoManager (default gGeoManager)
5538 // Output:
5539 //
5540 // Created:         ???       Bjorn S. Nilsen
5541 // Updated:       5 Jan 2010  Mario Sitta
5542 // Updated:      26 Feb 2010  Mario Sitta
5543 // Updated:      06 Sep 2010  Mario Sitta
5544 //
5545 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
5546 // drawings and other (oral) information given by F.Tosello
5547 //
5548
5549   // Overall position and rotation of the A-Side Cable Trays
5550   // (parts of 0872/G/D)
5551   const Double_t kTrayARTrans            =  408.35 *fgkmm;
5552   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
5553   const Double_t kTrayAZToSupportRing    =  435.00 *fgkmm;
5554   const Double_t kExternTrayYTrans       =   96.00 *fgkmm; // Computed
5555   const Double_t kExternTrayZTrans       =  823.00 *fgkmm;
5556   const Double_t kExternCoverYTrans      =    2.00 *fgkmm;
5557   const Double_t kTrayAZRot              = (180-169.5);// Degrees
5558   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
5559   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
5560
5561   const Double_t kForwardTrayThick       =    2.00 *fgkmm;
5562   const Double_t kForwardTrayTailHeight  =  100.00 *fgkmm; // Computed
5563   const Double_t kForwardTrayTotalHeight =  170.00 *fgkmm; // Computed
5564   const Double_t kForwardTrayUpperLength =  405.00 *fgkmm; // Computed
5565   const Double_t kForwardCoverLength     =  380.00 *fgkmm;
5566   const Double_t kForwardCoverWide       =  133.00 *fgkmm;
5567   const Double_t kForwardCoverHeight     =   10.00 *fgkmm;
5568   const Double_t kForwardCoverThick      =    1.00 *fgkmm;
5569
5570   const Double_t kExternTrayTotalLen     = 1200.00 *fgkmm;
5571   const Double_t kExternTrayTotalHeight  =   52.00 *fgkmm;
5572   const Double_t kExternCoverLen         = kExternTrayTotalLen;
5573   const Double_t kExternCoverThick       =    5.00 *fgkmm;
5574   const Double_t kExternCoverSideThick   =    3.00 *fgkmm;
5575
5576   const Int_t    kForwardTrayNpoints     =    8;
5577
5578   // Dimensions and positions of the Cable Tray elements
5579   const Double_t kSideACoolManifWide     =    8.23 *fgkcm;
5580   const Double_t kSideACoolManifHigh     =    8.06 *fgkcm;
5581   const Double_t kSideACoolManifLen      =    3.90 *fgkcm;
5582   const Double_t kSideACoolManifPOMFrac  =    0.0054;
5583   const Double_t kSideACoolManifSteelFrac=    0.8850;
5584   const Double_t kSideACoolManifWaterFrac=    0.0913;
5585   const Double_t kSideACoolManifAlFrac   =    0.0183;
5586
5587   const Double_t kSideACoolTubesWide     =    9.07 *fgkcm;
5588   const Double_t kSideACoolTubesHigh     =    1.88 *fgkcm;
5589   const Double_t kSideACoolTubesTrans    =    0.88 *fgkcm;
5590   const Double_t kSideACoolTubesPURFrac  =    0.5897;
5591   const Double_t kSideACoolTubesWaterFrac=    0.4101;
5592   const Double_t kSideACoolTubesAirFrac  =    0.0002;
5593
5594   const Double_t kSideAOptConnWide       =    0.90    *fgkcm;
5595   const Double_t kSideAOptConnLen        =    1.37    *fgkcm;
5596   const Double_t kSideAOptConnPBTFrac    =    0.5010;
5597   const Double_t kSideAOptConnSteelFrac  =    0.1784;
5598   const Double_t kSideAOptConnAlFrac     =    0.3206;
5599
5600   const Double_t kSideAOptFibsWide       =    0.71    *fgkcm;
5601   const Double_t kSideAOptFibsHigh       =    3.20    *fgkcm;
5602
5603   const Double_t kSideAInputCablesWide   =   12.50    *fgkcm;
5604   const Double_t kSideAInputCablesHigh   =    1.24    *fgkcm;
5605   const Double_t kSideAInputCablesLen    =   25.20    *fgkcm;
5606   const Double_t kSideAInputCablesYTrans =    1.15    *fgkcm;
5607   const Double_t kSideAInputCablesCu     =    0.7404;
5608   const Double_t kSideAInputCablesPlast  =    0.1269;
5609   const Double_t kSideAInputCablesAl     =    0.0057;
5610   const Double_t kSideAInputCablesKapton =    0.0172;
5611   const Double_t kSideAInputCablesPOLYAX =    0.1098;
5612
5613   const Double_t kSideAOutputCablesWide  =    8.30    *fgkcm;
5614   const Double_t kSideAOutputCablesHigh  =    1.56    *fgkcm;
5615   const Double_t kSideAOutputCablesCu    =    0.6783;
5616   const Double_t kSideAOutputCablesPlast =    0.1605;
5617   const Double_t kSideAOutputCablesAl    =    0.0078;
5618   const Double_t kSideAOutputCablesKapton=    0.0232;
5619   const Double_t kSideAOutputCablesPOLYAX=    0.1302;
5620
5621   const Double_t kSideAPCBBoardsWide     =   12.50    *fgkcm;
5622   const Double_t kSideAPCBBoardsHigh     =    6.32    *fgkcm;
5623   const Double_t kSideAPCBBoardsLen      =   24.00    *fgkcm;
5624   const Double_t kSideAPCBBoardsYTrans   =    0.75    *fgkcm;
5625   const Double_t kSideAPCBBoardsCu       =    0.3864;
5626   const Double_t kSideAPCBBoardsEpoxy    =    0.1486;
5627   const Double_t kSideAPCBBoardsPlast    =    0.0578;
5628   const Double_t kSideAPCBBoardsSteel    =    0.1521;
5629   const Double_t kSideAPCBBoardsPPS      =    0.2551;
5630
5631
5632   // Local variables
5633   Double_t xprof[kForwardTrayNpoints], yprof[kForwardTrayNpoints];
5634   Double_t xloc, yloc, zloc, alpharot, height;
5635
5636
5637   // The whole tray as an assembly
5638   TGeoVolumeAssembly *cableTrayA = new TGeoVolumeAssembly("ITSsupportSDDTrayA");
5639   
5640
5641   // First create all needed shapes
5642
5643   // The forward tray is very complex and deserves a dedicated method
5644   CreateSDDForwardTraySideA(cableTrayA,mgr);
5645
5646   // The forward cover: a Xtru
5647   TGeoXtru *forwardCover = new TGeoXtru(2);
5648   forwardCover->SetName("ITSsuppSDDForwCover");
5649
5650   xprof[0] = kForwardCoverWide/2;
5651   yprof[0] = kForwardCoverHeight;
5652   xprof[1] = xprof[0];
5653   yprof[1] = 0;
5654   xprof[2] = xprof[1] - kForwardCoverThick;
5655   yprof[2] = yprof[1];
5656   xprof[3] = xprof[2];
5657   yprof[3] = yprof[0] - kForwardCoverThick;
5658
5659   // We did the right side, now reflex on the left side
5660   for (Int_t jp = 0; jp < 4; jp++) {
5661     xprof[4+jp] = -xprof[3-jp];
5662     yprof[4+jp] =  yprof[3-jp];
5663   }
5664
5665   forwardCover->DefinePolygon(8, xprof, yprof);
5666   forwardCover->DefineSection(0, 0);
5667   forwardCover->DefineSection(1, kForwardCoverLength);
5668
5669   // The external tray (as 0872/G/D/03): a Xtru
5670   TGeoXtru *externalTray = CreateSDDSSDTraysSideA(kExternTrayTotalLen,
5671                                                   kExternTrayTotalHeight);
5672
5673   // The external covers: a Composite Shape
5674   TGeoCompositeShape *externCover = CreateTrayAExternalCover(kExternCoverLen);
5675
5676   // Now the volumes inside it
5677   // The cooling manifold: four boxes
5678   TGeoBBox *coolManifPOM = new TGeoBBox(kSideACoolManifWide/2,
5679                  kSideACoolManifPOMFrac*kSideACoolManifHigh/2,
5680                                         kSideACoolManifLen/2);
5681
5682   TGeoBBox *coolManifSteel = new TGeoBBox(kSideACoolManifWide/2,
5683                  kSideACoolManifSteelFrac*kSideACoolManifHigh/2,
5684                                           kSideACoolManifLen/2);
5685
5686   TGeoBBox *coolManifWater = new TGeoBBox(kSideACoolManifWide/2,
5687                  kSideACoolManifWaterFrac*kSideACoolManifHigh/2,
5688                                           kSideACoolManifLen/2);
5689
5690   TGeoBBox *coolManifAl = new TGeoBBox(kSideACoolManifWide/2,
5691                  kSideACoolManifAlFrac*kSideACoolManifHigh/2,
5692                                        kSideACoolManifLen/2);
5693
5694   // The cooling tubes: three Xtru's
5695   TGeoXtru *coolTubesPUR = new TGeoXtru(2);
5696
5697   height = kSideACoolTubesHigh*kSideACoolTubesPURFrac;
5698
5699   xprof[0] = kSideACoolManifLen;
5700   yprof[0] = kForwardTrayThick + kSideACoolTubesTrans;
5701   xprof[2] = kExternTrayZTrans + kForwardTrayTotalHeight*SinD(kTrayAZRot) +
5702              kExternTrayTotalLen*CosD(kTrayAZRot) - xprof[0]/2;
5703   yprof[2] = kForwardTrayTotalHeight*(1 - CosD(kTrayAZRot)) +
5704              kExternTrayYTrans - kExternTrayTotalHeight*CosD(kTrayAZRot) +
5705              kExternTrayTotalLen*SinD(kTrayAZRot) + yprof[0];
5706   IntersectLines(              0 , xprof[0], yprof[0],
5707                  TanD(kTrayAZRot), xprof[2], yprof[2],
5708                                    xprof[1], yprof[1]);
5709   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5710   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5711   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5712               height, xprof[4], yprof[4]);
5713   xprof[5] = xprof[0];
5714   yprof[5] = yprof[0] + height;
5715
5716   coolTubesPUR->DefinePolygon(6, xprof, yprof);
5717   coolTubesPUR->DefineSection(0,-kSideACoolTubesWide/2);
5718   coolTubesPUR->DefineSection(1, kSideACoolTubesWide/2);
5719
5720   TGeoXtru *coolTubesWater = new TGeoXtru(2);
5721
5722   height = kSideACoolTubesHigh*kSideACoolTubesWaterFrac;
5723
5724   xprof[0] = coolTubesPUR->GetX(5);
5725   yprof[0] = coolTubesPUR->GetY(5);
5726   xprof[1] = coolTubesPUR->GetX(4);
5727   yprof[1] = coolTubesPUR->GetY(4);
5728   xprof[2] = coolTubesPUR->GetX(3);
5729   yprof[2] = coolTubesPUR->GetY(3);
5730   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5731   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5732   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5733               height, xprof[4], yprof[4]);
5734   xprof[5] = xprof[0];
5735   yprof[5] = yprof[0] + height;
5736
5737   coolTubesWater->DefinePolygon(6, xprof, yprof);
5738   coolTubesWater->DefineSection(0,-kSideACoolTubesWide/2);
5739   coolTubesWater->DefineSection(1, kSideACoolTubesWide/2);
5740
5741   TGeoXtru *coolTubesAir = new TGeoXtru(2);
5742
5743   height = kSideACoolTubesHigh*kSideACoolTubesAirFrac;
5744
5745   xprof[0] = coolTubesWater->GetX(5);
5746   yprof[0] = coolTubesWater->GetY(5);
5747   xprof[1] = coolTubesWater->GetX(4);
5748   yprof[1] = coolTubesWater->GetY(4);
5749   xprof[2] = coolTubesWater->GetX(3);
5750   yprof[2] = coolTubesWater->GetY(3);
5751   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5752   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5753   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5754               height, xprof[4], yprof[4]);
5755   xprof[5] = xprof[0];
5756   yprof[5] = yprof[0] + height;
5757
5758   coolTubesAir->DefinePolygon(6, xprof, yprof);
5759   coolTubesAir->DefineSection(0,-kSideACoolTubesWide/2);
5760   coolTubesAir->DefineSection(1, kSideACoolTubesWide/2);
5761
5762   // The optical fiber connectors: three boxes
5763   TGeoBBox *optConnPBT = new TGeoBBox(kSideAOptConnWide/2,
5764                  kSideAOptConnPBTFrac*kSideACoolManifHigh/2,
5765                                       kSideAOptConnLen/2);
5766
5767   TGeoBBox *optConnSteel = new TGeoBBox(kSideAOptConnWide/2,
5768                  kSideAOptConnSteelFrac*kSideACoolManifHigh/2,
5769                                         kSideAOptConnLen/2);
5770
5771   TGeoBBox *optConnAl = new TGeoBBox(kSideAOptConnWide/2,
5772                  kSideAOptConnAlFrac*kSideACoolManifHigh/2,
5773                                      kSideAOptConnLen/2);
5774
5775   // The optical fibers: a Xtru
5776   TGeoXtru *opticalFibs = new TGeoXtru(2);
5777
5778   xprof[0] = kSideAOptConnLen;
5779   yprof[0] = coolTubesPUR->GetY(0);
5780   xprof[1] = coolTubesPUR->GetX(1);
5781   yprof[1] = coolTubesPUR->GetY(1);
5782   xprof[2] = coolTubesPUR->GetX(2);
5783   yprof[2] = coolTubesPUR->GetY(2);
5784   xprof[3] = xprof[2] - kSideAOptFibsHigh*SinD(kTrayAZRot);
5785   yprof[3] = yprof[2] + kSideAOptFibsHigh*CosD(kTrayAZRot);
5786   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5787               kSideAOptFibsHigh, xprof[4], yprof[4]);
5788   xprof[5] = xprof[0];
5789   yprof[5] = yprof[0] + kSideAOptFibsHigh;
5790
5791   opticalFibs->DefinePolygon(6, xprof, yprof);
5792   opticalFibs->DefineSection(0,-kSideAOptFibsWide/2);
5793   opticalFibs->DefineSection(1, kSideAOptFibsWide/2);
5794
5795   // The input cables: five boxes
5796   TGeoBBox *inputCabsCu = new TGeoBBox(kSideAInputCablesWide/2,
5797                    kSideAInputCablesCu*kSideAInputCablesHigh/2,
5798                                        kSideAInputCablesLen/2);
5799
5800   TGeoBBox *inputCabsPlast = new TGeoBBox(kSideAInputCablesWide/2,
5801                    kSideAInputCablesPlast*kSideAInputCablesHigh/2,
5802                                           kSideAInputCablesLen/2);
5803
5804   TGeoBBox *inputCabsAl = new TGeoBBox(kSideAInputCablesWide/2,
5805                    kSideAInputCablesAl*kSideAInputCablesHigh/2,
5806                                        kSideAInputCablesLen/2);
5807
5808   TGeoBBox *inputCabsKapton = new TGeoBBox(kSideAInputCablesWide/2,
5809                    kSideAInputCablesKapton*kSideAInputCablesHigh/2,
5810                                            kSideAInputCablesLen/2);
5811
5812   TGeoBBox *inputCabsPOLYAX = new TGeoBBox(kSideAInputCablesWide/2,
5813                    kSideAInputCablesPOLYAX*kSideAInputCablesHigh/2,
5814                                            kSideAInputCablesLen/2);
5815
5816   // The output cables: five Xtru
5817   TGeoXtru *outputCabsCu = new TGeoXtru(2);
5818
5819   height = kSideAOutputCablesCu*kSideAOutputCablesHigh;
5820
5821   xprof[0] = kSideAInputCablesLen/2 + kSideAPCBBoardsLen/2;
5822   yprof[0] = coolTubesAir->GetY(5);
5823   xprof[1] = coolTubesAir->GetX(4);
5824   yprof[1] = coolTubesAir->GetY(4);
5825   xprof[2] = coolTubesAir->GetX(3);
5826   yprof[2] = coolTubesAir->GetY(3);
5827   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5828   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5829   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5830               height, xprof[4], yprof[4]);
5831   xprof[5] = xprof[0];
5832   yprof[5] = yprof[0] + height;
5833
5834   outputCabsCu->DefinePolygon(6, xprof, yprof);
5835   outputCabsCu->DefineSection(0,-kSideAOutputCablesWide/2);
5836   outputCabsCu->DefineSection(1, kSideAOutputCablesWide/2);
5837
5838   TGeoXtru *outputCabsPlast = new TGeoXtru(2);
5839
5840   height = kSideAOutputCablesPlast*kSideAOutputCablesHigh;
5841
5842   xprof[0] = outputCabsCu->GetX(5);
5843   yprof[0] = outputCabsCu->GetY(5);
5844   xprof[1] = outputCabsCu->GetX(4);
5845   yprof[1] = outputCabsCu->GetY(4);
5846   xprof[2] = outputCabsCu->GetX(3);
5847   yprof[2] = outputCabsCu->GetY(3);
5848   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5849   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5850   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5851               height, xprof[4], yprof[4]);
5852   xprof[5] = xprof[0];
5853   yprof[5] = yprof[0] + height;
5854
5855   outputCabsPlast->DefinePolygon(6, xprof, yprof);
5856   outputCabsPlast->DefineSection(0,-kSideAOutputCablesWide/2);
5857   outputCabsPlast->DefineSection(1, kSideAOutputCablesWide/2);
5858
5859   TGeoXtru *outputCabsAl = new TGeoXtru(2);
5860
5861   height = kSideAOutputCablesAl*kSideAOutputCablesHigh;
5862
5863   xprof[0] = outputCabsPlast->GetX(5);
5864   yprof[0] = outputCabsPlast->GetY(5);
5865   xprof[1] = outputCabsPlast->GetX(4);
5866   yprof[1] = outputCabsPlast->GetY(4);
5867   xprof[2] = outputCabsPlast->GetX(3);
5868   yprof[2] = outputCabsPlast->GetY(3);
5869   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5870   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5871   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5872               height, xprof[4], yprof[4]);
5873   xprof[5] = xprof[0];
5874   yprof[5] = yprof[0] + height;
5875
5876   outputCabsAl->DefinePolygon(6, xprof, yprof);
5877   outputCabsAl->DefineSection(0,-kSideAOutputCablesWide/2);
5878   outputCabsAl->DefineSection(1, kSideAOutputCablesWide/2);
5879
5880   TGeoXtru *outputCabsKapton = new TGeoXtru(2);
5881
5882   height = kSideAOutputCablesKapton*kSideAOutputCablesHigh;
5883
5884   xprof[0] = outputCabsAl->GetX(5);
5885   yprof[0] = outputCabsAl->GetY(5);
5886   xprof[1] = outputCabsAl->GetX(4);
5887   yprof[1] = outputCabsAl->GetY(4);
5888   xprof[2] = outputCabsAl->GetX(3);
5889   yprof[2] = outputCabsAl->GetY(3);
5890   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5891   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5892   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5893               height, xprof[4], yprof[4]);
5894   xprof[5] = xprof[0];
5895   yprof[5] = yprof[0] + height;
5896
5897   outputCabsKapton->DefinePolygon(6, xprof, yprof);
5898   outputCabsKapton->DefineSection(0,-kSideAOutputCablesWide/2);
5899   outputCabsKapton->DefineSection(1, kSideAOutputCablesWide/2);
5900
5901   TGeoXtru *outputCabsPOLYAX = new TGeoXtru(2);
5902
5903   height = kSideAOutputCablesPOLYAX*kSideAOutputCablesHigh;
5904
5905   xprof[0] = outputCabsKapton->GetX(5);
5906   yprof[0] = outputCabsKapton->GetY(5);
5907   xprof[1] = outputCabsKapton->GetX(4);
5908   yprof[1] = outputCabsKapton->GetY(4);
5909   xprof[2] = outputCabsKapton->GetX(3);
5910   yprof[2] = outputCabsKapton->GetY(3);
5911   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5912   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5913   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5914               height, xprof[4], yprof[4]);
5915   xprof[5] = xprof[0];
5916   yprof[5] = yprof[0] + height;
5917
5918   outputCabsPOLYAX->DefinePolygon(6, xprof, yprof);
5919   outputCabsPOLYAX->DefineSection(0,-kSideAOutputCablesWide/2);
5920   outputCabsPOLYAX->DefineSection(1, kSideAOutputCablesWide/2);
5921
5922   // The PCB boards: five boxes
5923   TGeoBBox *pcbBoardsCu = new TGeoBBox(kSideAPCBBoardsWide/2,
5924                      kSideAPCBBoardsCu*kSideAPCBBoardsHigh/2,
5925                                        kSideAPCBBoardsLen/2);
5926
5927   TGeoBBox *pcbBoardsEpoxy = new TGeoBBox(kSideAPCBBoardsWide/2,
5928                      kSideAPCBBoardsEpoxy*kSideAPCBBoardsHigh/2,
5929                                           kSideAPCBBoardsLen/2);
5930
5931   TGeoBBox *pcbBoardsPlast = new TGeoBBox(kSideAPCBBoardsWide/2,
5932                      kSideAPCBBoardsPlast*kSideAPCBBoardsHigh/2,
5933                                           kSideAPCBBoardsLen/2);
5934
5935   TGeoBBox *pcbBoardsSteel = new TGeoBBox(kSideAPCBBoardsWide/2,
5936                      kSideAPCBBoardsSteel*kSideAPCBBoardsHigh/2,
5937                                           kSideAPCBBoardsLen/2);
5938
5939   TGeoBBox *pcbBoardsPPS = new TGeoBBox(kSideAPCBBoardsWide/2,
5940                      kSideAPCBBoardsPPS*kSideAPCBBoardsHigh/2,
5941                                         kSideAPCBBoardsLen/2);
5942
5943
5944   // We have all shapes: now create the real volumes
5945   TGeoMedium *medAl     = mgr->GetMedium("ITS_ALUMINUM$");
5946   TGeoMedium *medAntic  = mgr->GetMedium("ITS_ANTICORODAL$");
5947   TGeoMedium *medPOM    = mgr->GetMedium("ITS_POLYOXYMETHYLENE$");
5948   TGeoMedium *medSteel  = mgr->GetMedium("ITS_INOX$");
5949   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
5950   TGeoMedium *medPUR    = mgr->GetMedium("ITS_POLYURETHANE$");
5951   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
5952   TGeoMedium *medPBT    = mgr->GetMedium("ITS_PBT$");
5953   TGeoMedium *medOptFib = mgr->GetMedium("ITS_SDD OPTICFIB$");
5954   TGeoMedium *medCu     = mgr->GetMedium("ITS_COPPER$");
5955   TGeoMedium *medKapton = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
5956   TGeoMedium *medPOLYAX = mgr->GetMedium("ITS_POLYAX$");
5957   TGeoMedium *medPPS    = mgr->GetMedium("ITS_PPS$");
5958   TGeoMedium *medEpoxy  = mgr->GetMedium("ITS_EPOXY$");
5959
5960   TGeoVolume *forwardTrayCover = new TGeoVolume("ITSsuppSDDSideAForwTrayCover",
5961                                                 forwardCover, medAl);
5962
5963   forwardTrayCover->SetVisibility(kTRUE);
5964   forwardTrayCover->SetLineColor(kMagenta+1); // Purple
5965   forwardTrayCover->SetLineWidth(1);
5966   forwardTrayCover->SetFillColor(forwardTrayCover->GetLineColor());
5967   forwardTrayCover->SetFillStyle(4000); // 0% transparent
5968
5969   TGeoVolume *externalTraySDD = new TGeoVolume("ITSsuppSDDSideAExternalTray",
5970                                                externalTray, medAl);
5971
5972   externalTraySDD->SetVisibility(kTRUE);
5973   externalTraySDD->SetLineColor(6); // Purple
5974   externalTraySDD->SetLineWidth(1);
5975   externalTraySDD->SetFillColor(externalTraySDD->GetLineColor());
5976   externalTraySDD->SetFillStyle(4000); // 0% transparent
5977
5978   TGeoVolume *externTrayCover = new TGeoVolume("ITSsuppSDDSideAExtTrayCover",
5979                                                externCover, medAntic);
5980
5981   externTrayCover->SetVisibility(kTRUE);
5982   externTrayCover->SetLineColor(kMagenta+1); // Purple
5983   externTrayCover->SetLineWidth(1);
5984   externTrayCover->SetFillColor(externTrayCover->GetLineColor());
5985   externTrayCover->SetFillStyle(4000); // 0% transparent
5986
5987   TGeoVolume *pomCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifPOM",
5988                                             coolManifPOM, medPOM);
5989
5990   pomCoolManif->SetVisibility(kTRUE);
5991   pomCoolManif->SetLineColor(kRed); // Red
5992   pomCoolManif->SetLineWidth(1);
5993   pomCoolManif->SetFillColor(pomCoolManif->GetLineColor());
5994   pomCoolManif->SetFillStyle(4000); // 0% transparent
5995
5996   TGeoVolume *steelCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifSteel",
5997                                               coolManifSteel, medSteel);
5998
5999   steelCoolManif->SetVisibility(kTRUE);
6000   steelCoolManif->SetLineColor(kBlue); // Blue
6001   steelCoolManif->SetLineWidth(1);
6002   steelCoolManif->SetFillColor(steelCoolManif->GetLineColor());
6003   steelCoolManif->SetFillStyle(4000); // 0% transparent
6004
6005   TGeoVolume *waterCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifWater",
6006                                               coolManifWater, medWater);
6007
6008   waterCoolManif->SetVisibility(kTRUE);
6009   waterCoolManif->SetLineColor(33); // Light Blue
6010   waterCoolManif->SetLineWidth(1);
6011   waterCoolManif->SetFillColor(waterCoolManif->GetLineColor());
6012   waterCoolManif->SetFillStyle(4000); // 0% transparent
6013
6014   TGeoVolume *alCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifAl",
6015                                            coolManifAl, medAl);
6016
6017   alCoolManif->SetVisibility(kTRUE);
6018   alCoolManif->SetLineColor(6); // Purple
6019   alCoolManif->SetLineWidth(1);
6020   alCoolManif->SetFillColor(alCoolManif->GetLineColor());
6021   alCoolManif->SetFillStyle(4000); // 0% transparent
6022
6023   TGeoVolume *purCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesPUR",
6024                                             coolTubesPUR, medPUR);
6025
6026   purCoolTubes->SetVisibility(kTRUE);
6027   purCoolTubes->SetLineColor(kRed); // Red
6028   purCoolTubes->SetLineWidth(1);
6029   purCoolTubes->SetFillColor(purCoolTubes->GetLineColor());
6030   purCoolTubes->SetFillStyle(4000); // 0% transparent
6031
6032   TGeoVolume *waterCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesWater",
6033                                               coolTubesWater, medWater);
6034
6035   waterCoolTubes->SetVisibility(kTRUE);
6036   waterCoolTubes->SetLineColor(33); // Light Blue
6037   waterCoolTubes->SetLineWidth(1);
6038   waterCoolTubes->SetFillColor(waterCoolTubes->GetLineColor());
6039   waterCoolTubes->SetFillStyle(4000); // 0% transparent
6040
6041   TGeoVolume *airCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesAir",
6042                                             coolTubesAir, medAir);
6043
6044   airCoolTubes->SetVisibility(kTRUE);
6045   airCoolTubes->SetLineColor(41);
6046   airCoolTubes->SetLineWidth(1);
6047   airCoolTubes->SetFillColor(airCoolTubes->GetLineColor());
6048   airCoolTubes->SetFillStyle(4000); // 0% transparent
6049
6050   TGeoVolume *pbtOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnPBT",
6051                                           optConnPBT, medPBT);
6052
6053   pbtOptConn->SetVisibility(kTRUE);
6054   pbtOptConn->SetLineColor(kRed); // Red
6055   pbtOptConn->SetLineWidth(1);
6056   pbtOptConn->SetFillColor(pbtOptConn->GetLineColor());
6057   pbtOptConn->SetFillStyle(4000); // 0% transparent
6058
6059   TGeoVolume *steelOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnSteel",
6060                                             optConnSteel, medSteel);
6061
6062   steelOptConn->SetVisibility(kTRUE);
6063   steelOptConn->SetLineColor(kBlue); // Blue
6064   steelOptConn->SetLineWidth(1);
6065   steelOptConn->SetFillColor(steelOptConn->GetLineColor());
6066   steelOptConn->SetFillStyle(4000); // 0% transparent
6067
6068   TGeoVolume *alOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnAl",
6069                                          optConnAl, medAl);
6070
6071   alOptConn->SetVisibility(kTRUE);
6072   alOptConn->SetLineColor(6); // Purple
6073   alOptConn->SetLineWidth(1);
6074   alOptConn->SetFillColor(alOptConn->GetLineColor());
6075   alOptConn->SetFillStyle(4000); // 0% transparent
6076
6077   TGeoVolume *optFibs = new TGeoVolume("ITSsuppSDDSideAOptFibs",
6078                                        opticalFibs, medOptFib);
6079
6080   optFibs->SetVisibility(kTRUE);
6081   optFibs->SetLineColor(kOrange+2); // Orange
6082   optFibs->SetLineWidth(1);
6083   optFibs->SetFillColor(optFibs->GetLineColor());
6084   optFibs->SetFillStyle(4000); // 0% transparent
6085
6086   TGeoVolume *cuInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsCu",
6087                                            inputCabsCu, medCu);
6088
6089   cuInputCabs->SetVisibility(kTRUE);
6090   cuInputCabs->SetLineColor(kBlack); // Black
6091   cuInputCabs->SetLineWidth(1);
6092   cuInputCabs->SetFillColor(cuInputCabs->GetLineColor());
6093   cuInputCabs->SetFillStyle(4000); // 0% transparent
6094
6095   TGeoVolume *plastInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsPlast",
6096                                               inputCabsPlast, medPUR);
6097
6098   plastInputCabs->SetVisibility(kTRUE);
6099   plastInputCabs->SetLineColor(kRed); // Red
6100   plastInputCabs->SetLineWidth(1);
6101   plastInputCabs->SetFillColor(plastInputCabs->GetLineColor());
6102   plastInputCabs->SetFillStyle(4000); // 0% transparent
6103
6104   TGeoVolume *alInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsAl",
6105                                            inputCabsAl, medAl);
6106
6107   alInputCabs->SetVisibility(kTRUE);
6108   alInputCabs->SetLineColor(6); // Purple
6109   alInputCabs->SetLineWidth(1);
6110   alInputCabs->SetFillColor(alInputCabs->GetLineColor());
6111   alInputCabs->SetFillStyle(4000); // 0% transparent
6112
6113   TGeoVolume *kaptonInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsKapton",
6114                                                inputCabsKapton, medKapton);
6115
6116   kaptonInputCabs->SetVisibility(kTRUE);
6117   kaptonInputCabs->SetLineColor(14); // 
6118   kaptonInputCabs->SetLineWidth(1);
6119   kaptonInputCabs->SetFillColor(kaptonInputCabs->GetLineColor());
6120   kaptonInputCabs->SetFillStyle(4000); // 0% transparent
6121
6122   TGeoVolume *polyaxInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsPOLYAX",
6123                                                inputCabsPOLYAX, medPOLYAX);
6124
6125   polyaxInputCabs->SetVisibility(kTRUE);
6126   polyaxInputCabs->SetLineColor(34); // 
6127   polyaxInputCabs->SetLineWidth(1);
6128   polyaxInputCabs->SetFillColor(polyaxInputCabs->GetLineColor());
6129   polyaxInputCabs->SetFillStyle(4000); // 0% transparent
6130
6131   TGeoVolume *cuOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsCu",
6132                                             outputCabsCu, medCu);
6133
6134   cuOutputCabs->SetVisibility(kTRUE);
6135   cuOutputCabs->SetLineColor(kBlack); // Black
6136   cuOutputCabs->SetLineWidth(1);
6137   cuOutputCabs->SetFillColor(cuOutputCabs->GetLineColor());
6138   cuOutputCabs->SetFillStyle(4000); // 0% transparent
6139
6140   TGeoVolume *plastOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsPlast",
6141                                                outputCabsPlast, medPUR);
6142
6143   plastOutputCabs->SetVisibility(kTRUE);
6144   plastOutputCabs->SetLineColor(kRed); // Red
6145   plastOutputCabs->SetLineWidth(1);
6146   plastOutputCabs->SetFillColor(plastOutputCabs->GetLineColor());
6147   plastOutputCabs->SetFillStyle(4000); // 0% transparent
6148
6149   TGeoVolume *alOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsAl",
6150                                             outputCabsAl, medAl);
6151
6152   alOutputCabs->SetVisibility(kTRUE);
6153   alOutputCabs->SetLineColor(6); // Purple
6154   alOutputCabs->SetLineWidth(1);
6155   alOutputCabs->SetFillColor(alOutputCabs->GetLineColor());
6156   alOutputCabs->SetFillStyle(4000); // 0% transparent
6157
6158   TGeoVolume *kaptonOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsKapton",
6159                                                 outputCabsKapton, medKapton);
6160
6161   kaptonOutputCabs->SetVisibility(kTRUE);
6162   kaptonOutputCabs->SetLineColor(14); // 
6163   kaptonOutputCabs->SetLineWidth(1);
6164   kaptonOutputCabs->SetFillColor(kaptonOutputCabs->GetLineColor());
6165   kaptonOutputCabs->SetFillStyle(4000); // 0% transparent
6166
6167   TGeoVolume *polyaxOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsPOLYAX",
6168                                                 outputCabsPOLYAX, medPOLYAX);
6169
6170   polyaxOutputCabs->SetVisibility(kTRUE);
6171   polyaxOutputCabs->SetLineColor(34); // 
6172   polyaxOutputCabs->SetLineWidth(1);
6173   polyaxOutputCabs->SetFillColor(polyaxOutputCabs->GetLineColor());
6174   polyaxOutputCabs->SetFillStyle(4000); // 0% transparent
6175
6176   TGeoVolume *cuPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsCu",
6177                                            pcbBoardsCu, medCu);
6178
6179   cuPCBBoards->SetVisibility(kTRUE);
6180   cuPCBBoards->SetLineColor(kBlack); // Black
6181   cuPCBBoards->SetLineWidth(1);
6182   cuPCBBoards->SetFillColor(cuPCBBoards->GetLineColor());
6183   cuPCBBoards->SetFillStyle(4000); // 0% transparent
6184
6185   TGeoVolume *epoxyPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsEpoxy",
6186                                               pcbBoardsEpoxy, medEpoxy);
6187
6188   epoxyPCBBoards->SetVisibility(kTRUE);
6189   epoxyPCBBoards->SetLineColor(22); //
6190   epoxyPCBBoards->SetLineWidth(1);
6191   epoxyPCBBoards->SetFillColor(epoxyPCBBoards->GetLineColor());
6192   epoxyPCBBoards->SetFillStyle(4000); // 0% transparent
6193
6194   TGeoVolume *plastPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsPlast",
6195                                               pcbBoardsPlast, medPUR);
6196
6197   plastPCBBoards->SetVisibility(kTRUE);
6198   plastPCBBoards->SetLineColor(kRed); // Red
6199   plastPCBBoards->SetLineWidth(1);
6200   plastPCBBoards->SetFillColor(plastPCBBoards->GetLineColor());
6201   plastPCBBoards->SetFillStyle(4000); // 0% transparent
6202
6203   TGeoVolume *steelPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsSteel",
6204                                               pcbBoardsSteel, medSteel);
6205
6206   steelPCBBoards->SetVisibility(kTRUE);
6207   steelPCBBoards->SetLineColor(kBlue); // Blue
6208   steelPCBBoards->SetLineWidth(1);
6209   steelPCBBoards->SetFillColor(steelPCBBoards->GetLineColor());
6210   steelPCBBoards->SetFillStyle(4000); // 0% transparent
6211
6212   TGeoVolume *ppsPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsPPS",
6213                                             pcbBoardsPPS, medPPS);
6214
6215   ppsPCBBoards->SetVisibility(kTRUE);
6216   ppsPCBBoards->SetLineColor(kGreen); // Green
6217   ppsPCBBoards->SetLineWidth(1);
6218   ppsPCBBoards->SetFillColor(ppsPCBBoards->GetLineColor());
6219   ppsPCBBoards->SetFillStyle(4000); // 0% transparent
6220
6221
6222   // Now build up the tray
6223   yloc = kForwardTrayTotalHeight - forwardCover->GetY(3);
6224   zloc = kForwardTrayUpperLength - kForwardCoverLength;
6225   cableTrayA->AddNode(forwardTrayCover, 1,
6226                       new TGeoTranslation( 0, yloc, zloc) );
6227
6228   Double_t totalhi = kExternTrayTotalHeight + kExternCoverThick
6229                    - kExternCoverYTrans;
6230
6231   yloc = totalhi*(1 - CosD(kTrayAZRot)) + kExternTrayYTrans -
6232          kExternTrayTotalHeight*CosD(kTrayAZRot);
6233   zloc = kExternTrayZTrans + totalhi*SinD(kTrayAZRot);
6234   cableTrayA->AddNode(externalTraySDD, 1,
6235                       new TGeoCombiTrans( 0, yloc, zloc,
6236                       new TGeoRotation("", 0,-kTrayAZRot, 0)        ) );
6237
6238   yloc = kExternCoverThick*(1 - CosD(kTrayAZRot)) + kExternTrayYTrans -
6239          kExternCoverYTrans*CosD(kTrayAZRot)/2-0.01;
6240   zloc = kExternTrayZTrans + kExternCoverThick*SinD(kTrayAZRot);
6241   cableTrayA->AddNode(externTrayCover,1,
6242                       new TGeoCombiTrans( 0, yloc, zloc,
6243                       new TGeoRotation("", 0,-kTrayAZRot, 0)        ) );
6244
6245   yloc = kForwardTrayThick + coolManifPOM->GetDY();
6246   zloc = coolManifPOM->GetDZ();
6247   cableTrayA->AddNode(pomCoolManif, 1,
6248                       new TGeoTranslation( 0, yloc, zloc) );
6249
6250   yloc += coolManifPOM->GetDY() + coolManifSteel->GetDY();
6251   cableTrayA->AddNode(steelCoolManif, 1,
6252                       new TGeoTranslation( 0, yloc, zloc) );
6253
6254   yloc += coolManifSteel->GetDY() + coolManifWater->GetDY();
6255   cableTrayA->AddNode(waterCoolManif, 1,
6256                       new TGeoTranslation( 0, yloc, zloc) );
6257
6258   yloc += coolManifWater->GetDY() + coolManifAl->GetDY();
6259   cableTrayA->AddNode(alCoolManif, 1,
6260                       new TGeoTranslation( 0, yloc, zloc) );
6261
6262   cableTrayA->AddNode(purCoolTubes,1,
6263                       new TGeoCombiTrans( 0, 0, 0,
6264                       new TGeoRotation("",-90, 90, 90)        ) );
6265   cableTrayA->AddNode(waterCoolTubes,1,
6266                       new TGeoCombiTrans( 0, 0, 0,
6267                       new TGeoRotation("",-90, 90, 90)        ) );
6268   cableTrayA->AddNode(airCoolTubes,1,
6269                       new TGeoCombiTrans( 0, 0, 0,
6270                       new TGeoRotation("",-90, 90, 90)        ) );
6271
6272   xloc = coolManifPOM->GetDX() + optConnPBT->GetDX();
6273   yloc = kForwardTrayThick + optConnPBT->GetDY();
6274   zloc = optConnPBT->GetDZ();
6275   cableTrayA->AddNode(pbtOptConn, 1,
6276                       new TGeoTranslation( xloc, yloc, zloc) );
6277   cableTrayA->AddNode(pbtOptConn, 2,
6278                       new TGeoTranslation(-xloc, yloc, zloc) );
6279
6280   yloc += optConnPBT->GetDY() + optConnSteel->GetDY();
6281   cableTrayA->AddNode(steelOptConn, 1,
6282                       new TGeoTranslation( xloc, yloc, zloc) );
6283   cableTrayA->AddNode(steelOptConn, 2,
6284                       new TGeoTranslation(-xloc, yloc, zloc) );
6285
6286   yloc += optConnSteel->GetDY() + optConnAl->GetDY();
6287   cableTrayA->AddNode(alOptConn, 1,
6288                       new TGeoTranslation( xloc, yloc, zloc) );
6289   cableTrayA->AddNode(alOptConn, 2,
6290                       new TGeoTranslation(-xloc, yloc, zloc) );
6291
6292
6293   xloc = kSideACoolTubesWide/2 + kSideAOptFibsWide/2;
6294   cableTrayA->AddNode(optFibs,1,
6295                       new TGeoCombiTrans( xloc, 0, 0,
6296                       new TGeoRotation("",-90, 90, 90)        ) );
6297   cableTrayA->AddNode(optFibs,2,
6298                       new TGeoCombiTrans(-xloc, 0, 0,
6299                       new TGeoRotation("",-90, 90, 90)        ) );
6300
6301   yloc = kForwardTrayTotalHeight - forwardCover->GetY(3) -
6302          kSideAInputCablesYTrans - inputCabsPOLYAX->GetDY();
6303   zloc = inputCabsPOLYAX->GetDZ();
6304   cableTrayA->AddNode(polyaxInputCabs, 1,
6305                       new TGeoTranslation( 0, yloc, zloc) );
6306
6307   yloc -= (inputCabsPOLYAX->GetDY() + inputCabsKapton->GetDY());
6308   cableTrayA->AddNode(kaptonInputCabs, 1,
6309                       new TGeoTranslation( 0, yloc, zloc) );
6310
6311   yloc -= (inputCabsKapton->GetDY() + inputCabsAl->GetDY());
6312   cableTrayA->AddNode(alInputCabs, 1,
6313                       new TGeoTranslation( 0, yloc, zloc) );
6314
6315   yloc -= (inputCabsAl->GetDY() + inputCabsPlast->GetDY());
6316   cableTrayA->AddNode(plastInputCabs, 1,
6317                       new TGeoTranslation( 0, yloc, zloc) );
6318
6319   yloc -= (inputCabsPlast->GetDY() + inputCabsCu->GetDY());
6320   cableTrayA->AddNode(cuInputCabs, 1,
6321                       new TGeoTranslation( 0, yloc, zloc) );
6322
6323   yloc -= (inputCabsCu->GetDY()+pcbBoardsPPS->GetDY()+kSideAPCBBoardsYTrans);
6324   zloc += pcbBoardsPPS->GetDZ();
6325   cableTrayA->AddNode(ppsPCBBoards, 1,
6326                       new TGeoTranslation( 0, yloc, zloc) );
6327
6328   yloc -= (pcbBoardsPPS->GetDY()+pcbBoardsSteel->GetDY());
6329   cableTrayA->AddNode(steelPCBBoards, 1,
6330                       new TGeoTranslation( 0, yloc, zloc) );
6331
6332   yloc -= (pcbBoardsSteel->GetDY()+pcbBoardsPlast->GetDY());
6333   cableTrayA->AddNode(plastPCBBoards, 1,
6334                       new TGeoTranslation( 0, yloc, zloc) );
6335
6336   yloc -= (pcbBoardsPlast->GetDY()+pcbBoardsEpoxy->GetDY());
6337   cableTrayA->AddNode(epoxyPCBBoards, 1,
6338                       new TGeoTranslation( 0, yloc, zloc) );
6339
6340   yloc -= (pcbBoardsEpoxy->GetDY()+pcbBoardsCu->GetDY());
6341   cableTrayA->AddNode(cuPCBBoards, 1,
6342                       new TGeoTranslation( 0, yloc, zloc) );
6343
6344   cableTrayA->AddNode(cuOutputCabs,1,
6345                       new TGeoCombiTrans( 0, 0, 0,
6346                       new TGeoRotation("",-90, 90, 90)        ) );
6347   cableTrayA->AddNode(plastOutputCabs,1,
6348                       new TGeoCombiTrans( 0, 0, 0,
6349                       new TGeoRotation("",-90, 90, 90)        ) );
6350   cableTrayA->AddNode(alOutputCabs,1,
6351                       new TGeoCombiTrans( 0, 0, 0,
6352                       new TGeoRotation("",-90, 90, 90)        ) );
6353   cableTrayA->AddNode(kaptonOutputCabs,1,
6354                       new TGeoCombiTrans( 0, 0, 0,
6355                       new TGeoRotation("",-90, 90, 90)        ) );
6356   cableTrayA->AddNode(polyaxOutputCabs,1,
6357                       new TGeoCombiTrans( 0, 0, 0,
6358                       new TGeoRotation("",-90, 90, 90)        ) );
6359
6360
6361   // Finally put everything in the mother volume
6362   Double_t rforw = kTrayARTrans + kExternTrayTotalHeight +
6363                    kExternCoverSideThick -
6364                    kForwardTrayTailHeight;
6365
6366   alpharot = -kTrayAFirstRotAng;
6367   xloc = rforw*SinD(alpharot);
6368   yloc = rforw*CosD(alpharot);
6369   zloc = kTrayAZTrans + kTrayAZToSupportRing - kForwardTrayUpperLength;
6370
6371   moth->AddNode(cableTrayA,1,
6372                             new TGeoCombiTrans( xloc, yloc, zloc,
6373                             new TGeoRotation("",-alpharot,0,0)   )   );
6374
6375   alpharot += 180;
6376   xloc = rforw*SinD(alpharot);
6377   yloc = rforw*CosD(alpharot);
6378   moth->AddNode(cableTrayA,2,
6379                             new TGeoCombiTrans( xloc, yloc, zloc,
6380                             new TGeoRotation("",-alpharot,0,0)   )   );
6381
6382   alpharot = kTrayAFirstRotAng + 2*kTrayASecondRotAng;
6383   xloc = rforw*SinD(alpharot);
6384   yloc = rforw*CosD(alpharot);
6385   moth->AddNode(cableTrayA,3,
6386                             new TGeoCombiTrans( xloc, yloc, zloc,
6387                             new TGeoRotation("",-alpharot,0,0)   )   );
6388
6389   alpharot += 180;
6390   xloc = rforw*SinD(alpharot);
6391   yloc = rforw*CosD(alpharot);
6392   moth->AddNode(cableTrayA,4,
6393                             new TGeoCombiTrans( xloc, yloc, zloc,
6394                             new TGeoRotation("",-alpharot,0,0)   )   );
6395
6396
6397   return;
6398 }
6399
6400 //______________________________________________________________________
6401 void AliITSv11GeometrySupport::SDDCableTraysSideC(TGeoVolume *moth,
6402                                             const TGeoManager *mgr){
6403 //
6404 // Creates the SDD cable trays which are outside the ITS support cones
6405 // but still inside the TPC on Side C
6406 // (part of this code is taken or anyway inspired to ServicesCableSupport
6407 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
6408 //
6409 // Input:
6410 //         moth : the TGeoVolume owing the volume structure
6411 //         mgr  : the GeoManager (default gGeoManager)
6412 // Output:
6413 //
6414 // Created:         ???       Bjorn S. Nilsen
6415 // Updated:      17 Apr 2010  Mario Sitta
6416 //
6417 // Technical data are taken from AutoCAD drawings and other (oral)
6418 // information given by F.Tosello
6419 //
6420
6421   // Dimensions and positions of the C-Side Cable Tray
6422   // (Change accordingly to CreateSDDSSDTraysSideC !)
6423   const Int_t    kNumTraySideC           =    4;
6424
6425   const Double_t kSideCHalfThick         =    0.100   *fgkcm;
6426   const Double_t kSideCLength1           =  172.800   *fgkcm;
6427   const Double_t kSideCLength2           =  189.300   *fgkcm;
6428   const Double_t kBarCoolRmax            =    0.4     *fgkcm;
6429   const Double_t kXShiftBarCool          =   13.00    *fgkcm;
6430
6431   const Double_t kSideCFoldAngle         =    5.00 *fgkDegree;
6432
6433   // Dimensions and positions of the Cable Tray elements
6434   const Double_t kSideCCoolManifHalfX    =    4.25    *fgkcm;
6435   const Double_t kSideCCoolManifHalfY    =    4.03    *fgkcm;
6436   const Double_t kSideCCoolManifHalfZ    =    2.17    *fgkcm;
6437   const Double_t kSideCCoolManifPOMFrac  =    0.0051;
6438   const Double_t kSideCCoolManifSteelFrac=    0.8502;
6439   const Double_t kSideCCoolManifWaterFrac=    0.0868;
6440   const Double_t kSideCCoolManifAlFrac   =    0.0579;
6441
6442   const Double_t kSideCCoolTubesHigh     =    1.88    *fgkcm;
6443   const Double_t kSideCCoolTubesTrans    =    0.85    *fgkcm;
6444   const Double_t kSideCCoolTubesPURFrac  =    0.5884;
6445   const Double_t kSideCCoolTubesWaterFrac=    0.4114;
6446   const Double_t kSideCCoolTubesAirFrac  =    0.0002;
6447
6448   const Double_t kSideCOptConnHalfX      =    0.90    *fgkcm;
6449   const Double_t kSideCOptConnHalfZ      =    1.37    *fgkcm;
6450   const Double_t kSideCOptConnPBTFrac    =    0.6798;
6451   const Double_t kSideCOptConnSteelFrac  =    0.2421;
6452   const Double_t kSideCOptConnAlFrac     =    0.0781;
6453
6454   const Double_t kSideCOptFibsWide       =    0.71    *fgkcm;
6455   const Double_t kSideCOptFibsHigh       =    3.20    *fgkcm;
6456   const Double_t kSideCOptFibsTrans      =    0.20    *fgkcm;
6457
6458   const Double_t kSideCInputCablesLen    =   31.45    *fgkcm;
6459   const Double_t kSideCInputCablesWide   =   12.50    *fgkcm;
6460   const Double_t kSideCInputCablesHigh   =    0.95    *fgkcm;
6461   const Double_t kSideCInputCablesTrans  =    1.15    *fgkcm;
6462   const Double_t kSideCInputCablesCu     =    0.7405;
6463   const Double_t kSideCInputCablesPlast  =    0.1268;
6464   const Double_t kSideCInputCablesAl     =    0.0057;
6465   const Double_t kSideCInputCablesKapton =    0.0172;
6466   const Double_t kSideCInputCablesPOLYAX =    0.1098;
6467
6468   const Double_t kSideCOutputCablesX0    =   27.40    *fgkcm;
6469   const Double_t kSideCOutputCablesWide  =    8.50    *fgkcm;
6470   const Double_t kSideCOutputCablesHigh  =    1.18    *fgkcm;
6471   const Double_t kSideCOutputCablesCu    =    0.6775;
6472   const Double_t kSideCOutputCablesPlast =    0.1613;
6473   const Double_t kSideCOutputCablesAl    =    0.0078;
6474   const Double_t kSideCOutputCablesKapton=    0.0234;
6475   const Double_t kSideCOutputCablesPOLYAX=    0.1300;
6476
6477   const Double_t kSideCPCBBoardsHalfX    =    6.30    *fgkcm;
6478   const Double_t kSideCPCBBoardsHalfY    =    2.00    *fgkcm;
6479   const Double_t kSideCPCBBoardsHalfZ    =   21.93    *fgkcm;
6480   const Double_t kSideCPCBBoardsCu       =    0.3864;
6481   const Double_t kSideCPCBBoardsEpoxy    =    0.1491;
6482   const Double_t kSideCPCBBoardsPlast    =    0.0579;
6483   const Double_t kSideCPCBBoardsSteel    =    0.1517;
6484   const Double_t kSideCPCBBoardsPPS      =    0.2549;
6485
6486   // Overall position and rotation of the C-Side Cable Trays
6487   const Double_t kTraySideCRPos          =   45.30    *fgkcm;
6488   const Double_t kTraySideCZPos          = -102.40    *fgkcm;
6489   const Double_t kTraySideCAlphaRot[kNumTraySideC]  = {    -23.0,      59.0,
6490     /* from SSD tray position */                       180.-23.0, 180.+59.0};
6491
6492
6493   // Local variables
6494   Double_t xprof[6], yprof[6];
6495   Double_t height, xloc, yloc, zloc, alpharot, alphafold;
6496
6497
6498   // The assembly holding the metallic structure
6499   TGeoVolumeAssembly *trayStructure = CreateSDDSSDTraysSideC("ITSsupportSDDTrayC");
6500
6501   // Now the volumes inside it
6502   // The cooling manifold: four boxes
6503   // (X and Z are inverted on tray reference system)
6504   TGeoBBox *coolManifPOM = new TGeoBBox(kSideCCoolManifHalfZ,
6505                  kSideCCoolManifPOMFrac*kSideCCoolManifHalfY,
6506                                         kSideCCoolManifHalfX);
6507
6508   TGeoBBox *coolManifSteel = new TGeoBBox(kSideCCoolManifHalfZ,
6509                  kSideCCoolManifSteelFrac*kSideCCoolManifHalfY,
6510                                           kSideCCoolManifHalfX);
6511
6512   TGeoBBox *coolManifWater = new TGeoBBox(kSideCCoolManifHalfZ,
6513                  kSideCCoolManifWaterFrac*kSideCCoolManifHalfY,
6514                                           kSideCCoolManifHalfX);
6515
6516   TGeoBBox *coolManifAl = new TGeoBBox(kSideCCoolManifHalfZ,
6517                  kSideCCoolManifAlFrac*kSideCCoolManifHalfY,
6518                                        kSideCCoolManifHalfX);
6519
6520   // The cooling tubes: three Xtru's
6521   alpharot = kSideCFoldAngle*TMath::DegToRad();
6522
6523   TGeoXtru *coolTubesPUR = new TGeoXtru(2);
6524
6525   height = kSideCCoolTubesHigh*kSideCCoolTubesPURFrac;
6526
6527   xprof[0] = 2*kSideCCoolManifHalfZ;
6528   yprof[0] = 2*kSideCHalfThick + kSideCCoolTubesTrans;
6529   xprof[1] = kSideCLength1;
6530   yprof[1] = yprof[0];
6531   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(alpharot);
6532   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(alpharot);
6533   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6534   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6535   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6536               height, xprof[4], yprof[4]);
6537   xprof[5] = xprof[0];
6538   yprof[5] = yprof[0] + height;
6539
6540   coolTubesPUR->DefinePolygon(6, xprof, yprof);
6541   coolTubesPUR->DefineSection(0,-kSideCCoolManifHalfX);
6542   coolTubesPUR->DefineSection(1, kSideCCoolManifHalfX);
6543
6544   TGeoXtru *coolTubesWater = new TGeoXtru(2);
6545
6546   height = kSideCCoolTubesHigh*kSideCCoolTubesWaterFrac;
6547
6548   xprof[0] = coolTubesPUR->GetX(5);
6549   yprof[0] = coolTubesPUR->GetY(5);
6550   xprof[1] = coolTubesPUR->GetX(4);
6551   yprof[1] = coolTubesPUR->GetY(4);
6552   xprof[2] = coolTubesPUR->GetX(3);
6553   yprof[2] = coolTubesPUR->GetY(3);
6554   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6555   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6556   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6557               height, xprof[4], yprof[4]);
6558   xprof[5] = xprof[0];
6559   yprof[5] = yprof[0] + height;
6560
6561   coolTubesWater->DefinePolygon(6, xprof, yprof);
6562   coolTubesWater->DefineSection(0,-kSideCCoolManifHalfX);
6563   coolTubesWater->DefineSection(1, kSideCCoolManifHalfX);
6564
6565   TGeoXtru *coolTubesAir = new TGeoXtru(2);
6566
6567   height = kSideCCoolTubesHigh*kSideCCoolTubesAirFrac;
6568
6569   xprof[0] = coolTubesWater->GetX(5);
6570   yprof[0] = coolTubesWater->GetY(5);
6571   xprof[1] = coolTubesWater->GetX(4);
6572   yprof[1] = coolTubesWater->GetY(4);
6573   xprof[2] = coolTubesWater->GetX(3);
6574   yprof[2] = coolTubesWater->GetY(3);
6575   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6576   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6577   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6578               height, xprof[4], yprof[4]);
6579   xprof[5] = xprof[0];
6580   yprof[5] = yprof[0] + height;
6581
6582   coolTubesAir->DefinePolygon(6, xprof, yprof);
6583   coolTubesAir->DefineSection(0,-kSideCCoolManifHalfX);
6584   coolTubesAir->DefineSection(1, kSideCCoolManifHalfX);
6585
6586   // The optical fiber connectors: three boxes
6587   // (X and Z are inverted on tray reference system)
6588   TGeoBBox *optConnPBT = new TGeoBBox(kSideCOptConnHalfZ,
6589                  kSideCOptConnPBTFrac*kSideCCoolManifHalfY,
6590                                       kSideCOptConnHalfX);
6591
6592   TGeoBBox *optConnSteel = new TGeoBBox(kSideCOptConnHalfZ,
6593                  kSideCOptConnSteelFrac*kSideCCoolManifHalfY,
6594                                         kSideCOptConnHalfX);
6595
6596   TGeoBBox *optConnAl = new TGeoBBox(kSideCOptConnHalfZ,
6597                  kSideCOptConnAlFrac*kSideCCoolManifHalfY,
6598                                      kSideCOptConnHalfX);
6599
6600   // The optical fibers: a Xtru
6601   TGeoXtru *opticalFibs = new TGeoXtru(2);
6602
6603   xprof[0] = 2*kSideCOptConnHalfZ;
6604   yprof[0] = 2*kSideCHalfThick + kSideCOptFibsTrans;
6605   xprof[1] = kSideCLength1;
6606   yprof[1] = yprof[0];
6607   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(alpharot);
6608   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(alpharot);
6609   xprof[3] = xprof[2] - kSideCOptFibsHigh*TMath::Sin(alpharot);
6610   yprof[3] = yprof[2] + kSideCOptFibsHigh*TMath::Cos(alpharot);
6611   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6612               kSideCOptFibsHigh, xprof[4], yprof[4]);
6613   xprof[5] = xprof[0];
6614   yprof[5] = yprof[0] + kSideCOptFibsHigh;
6615
6616   opticalFibs->DefinePolygon(6, xprof, yprof);
6617   opticalFibs->DefineSection(0,-kSideCOptFibsWide/2);
6618   opticalFibs->DefineSection(1, kSideCOptFibsWide/2);
6619
6620   // The input cables: five boxes
6621   // (X and Z are inverted on tray reference system)
6622   TGeoBBox *inputCabsCu = new TGeoBBox(kSideCInputCablesLen/2,
6623                    kSideCInputCablesCu*kSideCInputCablesHigh/2,
6624                                        kSideCInputCablesWide/2);
6625
6626   TGeoBBox *inputCabsPlast = new TGeoBBox(kSideCInputCablesLen/2,
6627                    kSideCInputCablesPlast*kSideCInputCablesHigh/2,
6628                                           kSideCInputCablesWide/2);
6629
6630   TGeoBBox *inputCabsAl = new TGeoBBox(kSideCInputCablesLen/2,
6631                    kSideCInputCablesAl*kSideCInputCablesHigh/2,
6632                                        kSideCInputCablesWide/2);
6633
6634   TGeoBBox *inputCabsKapton = new TGeoBBox(kSideCInputCablesLen/2,
6635                    kSideCInputCablesKapton*kSideCInputCablesHigh/2,
6636                                            kSideCInputCablesWide/2);
6637
6638   TGeoBBox *inputCabsPOLYAX = new TGeoBBox(kSideCInputCablesLen/2,
6639                    kSideCInputCablesPOLYAX*kSideCInputCablesHigh/2,
6640                                            kSideCInputCablesWide/2);
6641
6642   // The output cables: five Xtru
6643   TGeoXtru *outputCabsCu = new TGeoXtru(2);
6644
6645   height = kSideCOutputCablesCu*kSideCOutputCablesHigh;
6646
6647   xprof[0] = coolTubesAir->GetX(5) + kSideCOutputCablesX0;
6648   yprof[0] = coolTubesAir->GetY(5);
6649   xprof[1] = coolTubesAir->GetX(4);
6650   yprof[1] = coolTubesAir->GetY(4);
6651   xprof[2] = coolTubesAir->GetX(3);
6652   yprof[2] = coolTubesAir->GetY(3);
6653   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6654   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6655   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6656               height, xprof[4], yprof[4]);
6657   xprof[5] = xprof[0];
6658   yprof[5] = yprof[0] + height;
6659
6660   outputCabsCu->DefinePolygon(6, xprof, yprof);
6661   outputCabsCu->DefineSection(0,-kSideCOutputCablesWide/2);
6662   outputCabsCu->DefineSection(1, kSideCOutputCablesWide/2);
6663
6664   TGeoXtru *outputCabsPlast = new TGeoXtru(2);
6665
6666   height = kSideCOutputCablesPlast*kSideCOutputCablesHigh;
6667
6668   xprof[0] = outputCabsCu->GetX(5);
6669   yprof[0] = outputCabsCu->GetY(5);
6670   xprof[1] = outputCabsCu->GetX(4);
6671   yprof[1] = outputCabsCu->GetY(4);
6672   xprof[2] = outputCabsCu->GetX(3);
6673   yprof[2] = outputCabsCu->GetY(3);
6674   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6675   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6676   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6677               height, xprof[4], yprof[4]);
6678   xprof[5] = xprof[0];
6679   yprof[5] = yprof[0] + height;
6680
6681   outputCabsPlast->DefinePolygon(6, xprof, yprof);
6682   outputCabsPlast->DefineSection(0,-kSideCOutputCablesWide/2);
6683   outputCabsPlast->DefineSection(1, kSideCOutputCablesWide/2);
6684
6685   TGeoXtru *outputCabsAl = new TGeoXtru(2);
6686
6687   height = kSideCOutputCablesAl*kSideCOutputCablesHigh;
6688
6689   xprof[0] = outputCabsPlast->GetX(5);
6690   yprof[0] = outputCabsPlast->GetY(5);
6691   xprof[1] = outputCabsPlast->GetX(4);
6692   yprof[1] = outputCabsPlast->GetY(4);
6693   xprof[2] = outputCabsPlast->GetX(3);
6694   yprof[2] = outputCabsPlast->GetY(3);
6695   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6696   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6697   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6698               height, xprof[4], yprof[4]);
6699   xprof[5] = xprof[0];
6700   yprof[5] = yprof[0] + height;
6701
6702   outputCabsAl->DefinePolygon(6, xprof, yprof);
6703   outputCabsAl->DefineSection(0,-kSideCOutputCablesWide/2);
6704   outputCabsAl->DefineSection(1, kSideCOutputCablesWide/2);
6705
6706   TGeoXtru *outputCabsKapton = new TGeoXtru(2);
6707
6708   height = kSideCOutputCablesKapton*kSideCOutputCablesHigh;
6709
6710   xprof[0] = outputCabsAl->GetX(5);
6711   yprof[0] = outputCabsAl->GetY(5);
6712   xprof[1] = outputCabsAl->GetX(4);
6713   yprof[1] = outputCabsAl->GetY(4);
6714   xprof[2] = outputCabsAl->GetX(3);
6715   yprof[2] = outputCabsAl->GetY(3);
6716   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6717   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6718   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6719               height, xprof[4], yprof[4]);
6720   xprof[5] = xprof[0];
6721   yprof[5] = yprof[0] + height;
6722
6723   outputCabsKapton->DefinePolygon(6, xprof, yprof);
6724   outputCabsKapton->DefineSection(0,-kSideCOutputCablesWide/2);
6725   outputCabsKapton->DefineSection(1, kSideCOutputCablesWide/2);
6726
6727   TGeoXtru *outputCabsPOLYAX = new TGeoXtru(2);
6728
6729   height = kSideCOutputCablesPOLYAX*kSideCOutputCablesHigh;
6730
6731   xprof[0] = outputCabsKapton->GetX(5);
6732   yprof[0] = outputCabsKapton->GetY(5);
6733   xprof[1] = outputCabsKapton->GetX(4);
6734   yprof[1] = outputCabsKapton->GetY(4);
6735   xprof[2] = outputCabsKapton->GetX(3);
6736   yprof[2] = outputCabsKapton->GetY(3);
6737   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6738   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6739   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6740               height, xprof[4], yprof[4]);
6741   xprof[5] = xprof[0];
6742   yprof[5] = yprof[0] + height;
6743
6744   outputCabsPOLYAX->DefinePolygon(6, xprof, yprof);
6745   outputCabsPOLYAX->DefineSection(0,-kSideCOutputCablesWide/2);
6746   outputCabsPOLYAX->DefineSection(1, kSideCOutputCablesWide/2);
6747
6748   // The PCB boards: five boxes
6749   // (X and Z are inverted on tray reference system)
6750   TGeoBBox *pcbBoardsCu = new TGeoBBox(kSideCPCBBoardsHalfZ,
6751                      kSideCPCBBoardsCu*kSideCPCBBoardsHalfY,
6752                                        kSideCPCBBoardsHalfX);
6753
6754   TGeoBBox *pcbBoardsEpoxy = new TGeoBBox(kSideCPCBBoardsHalfZ,
6755                      kSideCPCBBoardsEpoxy*kSideCPCBBoardsHalfY,
6756                                           kSideCPCBBoardsHalfX);
6757
6758   TGeoBBox *pcbBoardsPlast = new TGeoBBox(kSideCPCBBoardsHalfZ,
6759                      kSideCPCBBoardsPlast*kSideCPCBBoardsHalfY,
6760                                           kSideCPCBBoardsHalfX);
6761
6762   TGeoBBox *pcbBoardsSteel = new TGeoBBox(kSideCPCBBoardsHalfZ,
6763                      kSideCPCBBoardsSteel*kSideCPCBBoardsHalfY,
6764                                           kSideCPCBBoardsHalfX);
6765
6766   TGeoBBox *pcbBoardsPPS = new TGeoBBox(kSideCPCBBoardsHalfZ,
6767                      kSideCPCBBoardsPPS*kSideCPCBBoardsHalfY,
6768                                         kSideCPCBBoardsHalfX);
6769
6770
6771   // We have all shapes: now create the real volumes
6772   TGeoMedium *medPOM    = mgr->GetMedium("ITS_POLYOXYMETHYLENE$");
6773   TGeoMedium *medSteel  = mgr->GetMedium("ITS_INOX$");
6774   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
6775   TGeoMedium *medAl     = mgr->GetMedium("ITS_ALUMINUM$");
6776   TGeoMedium *medCu     = mgr->GetMedium("ITS_COPPER$");
6777   TGeoMedium *medPUR    = mgr->GetMedium("ITS_POLYURETHANE$");
6778   TGeoMedium *medPOLYAX = mgr->GetMedium("ITS_POLYAX$");
6779   TGeoMedium *medKapton = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
6780   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
6781   TGeoMedium *medPBT    = mgr->GetMedium("ITS_PBT$");
6782   TGeoMedium *medOptFib = mgr->GetMedium("ITS_SDD OPTICFIB$");
6783   TGeoMedium *medPPS    = mgr->GetMedium("ITS_PPS$");
6784   TGeoMedium *medEpoxy  = mgr->GetMedium("ITS_EPOXY$");
6785
6786   TGeoVolume *pomCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifPOM",
6787                                             coolManifPOM, medPOM);
6788
6789   pomCoolManif->SetVisibility(kTRUE);
6790   pomCoolManif->SetLineColor(kRed); // Red
6791   pomCoolManif->SetLineWidth(1);
6792   pomCoolManif->SetFillColor(pomCoolManif->GetLineColor());
6793   pomCoolManif->SetFillStyle(4000); // 0% transparent
6794
6795   TGeoVolume *steelCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifSteel",
6796                                               coolManifSteel, medSteel);
6797
6798   steelCoolManif->SetVisibility(kTRUE);
6799   steelCoolManif->SetLineColor(kBlue); // Blue
6800   steelCoolManif->SetLineWidth(1);
6801   steelCoolManif->SetFillColor(steelCoolManif->GetLineColor());
6802   steelCoolManif->SetFillStyle(4000); // 0% transparent
6803
6804   TGeoVolume *waterCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifWater",
6805                                               coolManifWater, medWater);
6806
6807   waterCoolManif->SetVisibility(kTRUE);
6808   waterCoolManif->SetLineColor(33); // Light Blue
6809   waterCoolManif->SetLineWidth(1);
6810   waterCoolManif->SetFillColor(waterCoolManif->GetLineColor());
6811   waterCoolManif->SetFillStyle(4000); // 0% transparent
6812
6813   TGeoVolume *alCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifAl",
6814                                            coolManifAl, medAl);
6815
6816   alCoolManif->SetVisibility(kTRUE);
6817   alCoolManif->SetLineColor(6); // Purple
6818   alCoolManif->SetLineWidth(1);
6819   alCoolManif->SetFillColor(alCoolManif->GetLineColor());
6820   alCoolManif->SetFillStyle(4000); // 0% transparent
6821
6822   TGeoVolume *purCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesPUR",
6823                                             coolTubesPUR, medPUR);
6824
6825   purCoolTubes->SetVisibility(kTRUE);
6826   purCoolTubes->SetLineColor(kRed); // Red
6827   purCoolTubes->SetLineWidth(1);
6828   purCoolTubes->SetFillColor(purCoolTubes->GetLineColor());
6829   purCoolTubes->SetFillStyle(4000); // 0% transparent
6830
6831   TGeoVolume *waterCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesWater",
6832                                               coolTubesWater, medWater);
6833
6834   waterCoolTubes->SetVisibility(kTRUE);
6835   waterCoolTubes->SetLineColor(33); // Light Blue
6836   waterCoolTubes->SetLineWidth(1);
6837   waterCoolTubes->SetFillColor(waterCoolTubes->GetLineColor());
6838   waterCoolTubes->SetFillStyle(4000); // 0% transparent
6839
6840   TGeoVolume *airCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesAir",
6841                                             coolTubesAir, medAir);
6842
6843   airCoolTubes->SetVisibility(kTRUE);
6844   airCoolTubes->SetLineColor(41);
6845   airCoolTubes->SetLineWidth(1);
6846   airCoolTubes->SetFillColor(airCoolTubes->GetLineColor());
6847   airCoolTubes->SetFillStyle(4000); // 0% transparent
6848
6849   TGeoVolume *pbtOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnPBT",
6850                                           optConnPBT, medPBT);
6851
6852   pbtOptConn->SetVisibility(kTRUE);
6853   pbtOptConn->SetLineColor(kRed); // Red
6854   pbtOptConn->SetLineWidth(1);
6855   pbtOptConn->SetFillColor(pbtOptConn->GetLineColor());
6856   pbtOptConn->SetFillStyle(4000); // 0% transparent
6857
6858   TGeoVolume *steelOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnSteel",
6859                                             optConnSteel, medSteel);
6860
6861   steelOptConn->SetVisibility(kTRUE);
6862   steelOptConn->SetLineColor(kBlue); // Blue
6863   steelOptConn->SetLineWidth(1);
6864   steelOptConn->SetFillColor(steelOptConn->GetLineColor());
6865   steelOptConn->SetFillStyle(4000); // 0% transparent
6866
6867   TGeoVolume *alOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnAl",
6868                                          optConnAl, medAl);
6869
6870   alOptConn->SetVisibility(kTRUE);
6871   alOptConn->SetLineColor(6); // Purple
6872   alOptConn->SetLineWidth(1);
6873   alOptConn->SetFillColor(alOptConn->GetLineColor());
6874   alOptConn->SetFillStyle(4000); // 0% transparent
6875
6876   TGeoVolume *optFibs = new TGeoVolume("ITSsuppSDDSideCOptFibs",
6877                                        opticalFibs, medOptFib);
6878
6879   optFibs->SetVisibility(kTRUE);
6880   optFibs->SetLineColor(kOrange+2); // Orange
6881   optFibs->SetLineWidth(1);
6882   optFibs->SetFillColor(optFibs->GetLineColor());
6883   optFibs->SetFillStyle(4000); // 0% transparent
6884
6885   TGeoVolume *cuInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsCu",
6886                                            inputCabsCu, medCu);
6887
6888   cuInputCabs->SetVisibility(kTRUE);
6889   cuInputCabs->SetLineColor(kBlack); // Black
6890   cuInputCabs->SetLineWidth(1);
6891   cuInputCabs->SetFillColor(cuInputCabs->GetLineColor());
6892   cuInputCabs->SetFillStyle(4000); // 0% transparent
6893
6894   TGeoVolume *plastInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsPlast",
6895                                               inputCabsPlast, medPUR);
6896
6897   plastInputCabs->SetVisibility(kTRUE);
6898   plastInputCabs->SetLineColor(kRed); // Red
6899   plastInputCabs->SetLineWidth(1);
6900   plastInputCabs->SetFillColor(plastInputCabs->GetLineColor());
6901   plastInputCabs->SetFillStyle(4000); // 0% transparent
6902
6903   TGeoVolume *alInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsAl",
6904                                            inputCabsAl, medAl);
6905
6906   alInputCabs->SetVisibility(kTRUE);
6907   alInputCabs->SetLineColor(6); // Purple
6908   alInputCabs->SetLineWidth(1);
6909   alInputCabs->SetFillColor(alInputCabs->GetLineColor());
6910   alInputCabs->SetFillStyle(4000); // 0% transparent
6911
6912   TGeoVolume *kaptonInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsKapton",
6913                                                inputCabsKapton, medKapton);
6914
6915   kaptonInputCabs->SetVisibility(kTRUE);
6916   kaptonInputCabs->SetLineColor(14); // 
6917   kaptonInputCabs->SetLineWidth(1);
6918   kaptonInputCabs->SetFillColor(kaptonInputCabs->GetLineColor());
6919   kaptonInputCabs->SetFillStyle(4000); // 0% transparent
6920
6921   TGeoVolume *polyaxInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsPOLYAX",
6922                                                inputCabsPOLYAX, medPOLYAX);
6923
6924   polyaxInputCabs->SetVisibility(kTRUE);
6925   polyaxInputCabs->SetLineColor(34); // 
6926   polyaxInputCabs->SetLineWidth(1);
6927   polyaxInputCabs->SetFillColor(polyaxInputCabs->GetLineColor());
6928   polyaxInputCabs->SetFillStyle(4000); // 0% transparent
6929
6930   TGeoVolume *cuOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsCu",
6931                                             outputCabsCu, medCu);
6932
6933   cuOutputCabs->SetVisibility(kTRUE);
6934   cuOutputCabs->SetLineColor(kBlack); // Black
6935   cuOutputCabs->SetLineWidth(1);
6936   cuOutputCabs->SetFillColor(cuOutputCabs->GetLineColor());
6937   cuOutputCabs->SetFillStyle(4000); // 0% transparent
6938
6939   TGeoVolume *plastOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsPlast",
6940                                                outputCabsPlast, medPUR);
6941
6942   plastOutputCabs->SetVisibility(kTRUE);
6943   plastOutputCabs->SetLineColor(kRed); // Red
6944   plastOutputCabs->SetLineWidth(1);
6945   plastOutputCabs->SetFillColor(plastOutputCabs->GetLineColor());
6946   plastOutputCabs->SetFillStyle(4000); // 0% transparent
6947
6948   TGeoVolume *alOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsAl",
6949                                             outputCabsAl, medAl);
6950
6951   alOutputCabs->SetVisibility(kTRUE);
6952   alOutputCabs->SetLineColor(6); // Purple
6953   alOutputCabs->SetLineWidth(1);
6954   alOutputCabs->SetFillColor(alOutputCabs->GetLineColor());
6955   alOutputCabs->SetFillStyle(4000); // 0% transparent
6956
6957   TGeoVolume *kaptonOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsKapton",
6958                                                 outputCabsKapton, medKapton);
6959
6960   kaptonOutputCabs->SetVisibility(kTRUE);
6961   kaptonOutputCabs->SetLineColor(14); // 
6962   kaptonOutputCabs->SetLineWidth(1);
6963   kaptonOutputCabs->SetFillColor(kaptonOutputCabs->GetLineColor());
6964   kaptonOutputCabs->SetFillStyle(4000); // 0% transparent
6965
6966   TGeoVolume *polyaxOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsPOLYAX",
6967                                                 outputCabsPOLYAX, medPOLYAX);
6968
6969   polyaxOutputCabs->SetVisibility(kTRUE);
6970   polyaxOutputCabs->SetLineColor(34); // 
6971   polyaxOutputCabs->SetLineWidth(1);
6972   polyaxOutputCabs->SetFillColor(polyaxOutputCabs->GetLineColor());
6973   polyaxOutputCabs->SetFillStyle(4000); // 0% transparent
6974
6975   TGeoVolume *cuPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsCu",
6976                                            pcbBoardsCu, medCu);
6977
6978   cuPCBBoards->SetVisibility(kTRUE);
6979   cuPCBBoards->SetLineColor(kBlack); // Black
6980   cuPCBBoards->SetLineWidth(1);
6981   cuPCBBoards->SetFillColor(cuPCBBoards->GetLineColor());
6982   cuPCBBoards->SetFillStyle(4000); // 0% transparent
6983
6984   TGeoVolume *epoxyPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsEpoxy",
6985                                               pcbBoardsEpoxy, medEpoxy);
6986
6987   epoxyPCBBoards->SetVisibility(kTRUE);
6988   epoxyPCBBoards->SetLineColor(22); //
6989   epoxyPCBBoards->SetLineWidth(1);
6990   epoxyPCBBoards->SetFillColor(epoxyPCBBoards->GetLineColor());
6991   epoxyPCBBoards->SetFillStyle(4000); // 0% transparent
6992
6993   TGeoVolume *plastPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsPlast",
6994                                               pcbBoardsPlast, medPUR);
6995
6996   plastPCBBoards->SetVisibility(kTRUE);
6997   plastPCBBoards->SetLineColor(kRed); // Red
6998   plastPCBBoards->SetLineWidth(1);
6999   plastPCBBoards->SetFillColor(plastPCBBoards->GetLineColor());
7000   plastPCBBoards->SetFillStyle(4000); // 0% transparent
7001
7002   TGeoVolume *steelPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsSteel",
7003                                               pcbBoardsSteel, medSteel);
7004
7005   steelPCBBoards->SetVisibility(kTRUE);
7006   steelPCBBoards->SetLineColor(kBlue); // Blue
7007   steelPCBBoards->SetLineWidth(1);
7008   steelPCBBoards->SetFillColor(steelPCBBoards->GetLineColor());
7009   steelPCBBoards->SetFillStyle(4000); // 0% transparent
7010
7011   TGeoVolume *ppsPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsPPS",
7012                                             pcbBoardsPPS, medPPS);
7013
7014   ppsPCBBoards->SetVisibility(kTRUE);
7015   ppsPCBBoards->SetLineColor(kGreen); // Green
7016   ppsPCBBoards->SetLineWidth(1);
7017   ppsPCBBoards->SetFillColor(ppsPCBBoards->GetLineColor());
7018   ppsPCBBoards->SetFillStyle(4000); // 0% transparent
7019
7020
7021   // Now fill the tray
7022   xloc = coolManifPOM->GetDX();
7023   yloc = 2*kSideCHalfThick + coolManifPOM->GetDY();
7024   trayStructure->AddNode(pomCoolManif, 1,
7025                          new TGeoTranslation( xloc, yloc, 0) );
7026
7027   yloc += coolManifPOM->GetDY() + coolManifSteel->GetDY();
7028   trayStructure->AddNode(steelCoolManif, 1,
7029                          new TGeoTranslation( xloc, yloc, 0) );
7030
7031   yloc += coolManifSteel->GetDY() + coolManifWater->GetDY();
7032   trayStructure->AddNode(waterCoolManif, 1,
7033                          new TGeoTranslation( xloc, yloc, 0) );
7034
7035   yloc += coolManifWater->GetDY() + coolManifAl->GetDY();
7036   trayStructure->AddNode(alCoolManif, 1,
7037                          new TGeoTranslation( xloc, yloc, 0) );
7038
7039   xloc = inputCabsCu->GetDX();
7040   yloc += coolManifWater->GetDY() + inputCabsCu->GetDY()
7041         + kSideCInputCablesTrans;
7042   trayStructure->AddNode(cuInputCabs, 1,
7043                          new TGeoTranslation( xloc, yloc, 0) );
7044
7045   yloc += inputCabsCu->GetDY() + inputCabsPlast->GetDY();
7046   trayStructure->AddNode(plastInputCabs, 1,
7047                          new TGeoTranslation( xloc, yloc, 0) );
7048
7049   yloc += inputCabsPlast->GetDY() + inputCabsAl->GetDY();
7050   trayStructure->AddNode(alInputCabs, 1,
7051                          new TGeoTranslation( xloc, yloc, 0) );
7052
7053   yloc += inputCabsAl->GetDY() + inputCabsKapton->GetDY();
7054   trayStructure->AddNode(kaptonInputCabs, 1,
7055                          new TGeoTranslation( xloc, yloc, 0) );
7056
7057   yloc += inputCabsKapton->GetDY() + inputCabsPOLYAX->GetDY();
7058   trayStructure->AddNode(polyaxInputCabs, 1,
7059                          new TGeoTranslation( xloc, yloc, 0) );
7060
7061   trayStructure->AddNode(purCoolTubes  , 1, 0);
7062   trayStructure->AddNode(waterCoolTubes, 1, 0);
7063   trayStructure->AddNode(airCoolTubes  , 1, 0);
7064
7065   xloc = optConnPBT->GetDX();
7066   yloc = 2*kSideCHalfThick + optConnPBT->GetDY();
7067   zloc = coolManifPOM->GetDZ() + optConnPBT->GetDZ();
7068   trayStructure->AddNode(pbtOptConn, 1,
7069                          new TGeoTranslation( xloc, yloc, zloc) );
7070   trayStructure->AddNode(pbtOptConn, 2,
7071                          new TGeoTranslation( xloc, yloc,-zloc) );
7072
7073   yloc += optConnPBT->GetDY() + optConnSteel->GetDY();
7074   trayStructure->AddNode(steelOptConn, 1,
7075                          new TGeoTranslation( xloc, yloc, zloc) );
7076   trayStructure->AddNode(steelOptConn, 2,
7077                          new TGeoTranslation( xloc, yloc,-zloc) );
7078
7079   yloc += optConnSteel->GetDY() + optConnAl->GetDY();
7080   trayStructure->AddNode(alOptConn, 1,
7081                          new TGeoTranslation( xloc, yloc, zloc) );
7082   trayStructure->AddNode(alOptConn, 2,
7083                          new TGeoTranslation( xloc, yloc,-zloc) );
7084
7085   trayStructure->AddNode(optFibs, 1,
7086                          new TGeoTranslation( 0, 0, zloc) );
7087   trayStructure->AddNode(optFibs, 2,
7088                          new TGeoTranslation( 0, 0,-zloc) );
7089
7090   trayStructure->AddNode(cuOutputCabs    , 1, 0);
7091   trayStructure->AddNode(plastOutputCabs , 1, 0);
7092   trayStructure->AddNode(alOutputCabs    , 1, 0);
7093   trayStructure->AddNode(kaptonOutputCabs, 1, 0);
7094   trayStructure->AddNode(polyaxOutputCabs, 1, 0);
7095
7096   xloc = kXShiftBarCool + kBarCoolRmax + pcbBoardsCu->GetDX();
7097   yloc = outputCabsPOLYAX->GetY(5) + pcbBoardsCu->GetDY();
7098   trayStructure->AddNode(cuPCBBoards, 1,
7099                          new TGeoTranslation( xloc, yloc , 0) );
7100
7101   yloc += pcbBoardsCu->GetDY() + pcbBoardsEpoxy->GetDY();
7102   trayStructure->AddNode(epoxyPCBBoards, 1,
7103                          new TGeoTranslation( xloc, yloc , 0) );
7104
7105   yloc += pcbBoardsEpoxy->GetDY() + pcbBoardsPlast->GetDY();
7106   trayStructure->AddNode(plastPCBBoards, 1,
7107                          new TGeoTranslation( xloc, yloc , 0) );
7108
7109   yloc += pcbBoardsPlast->GetDY() + pcbBoardsSteel->GetDY();
7110   trayStructure->AddNode(steelPCBBoards, 1,
7111                          new TGeoTranslation( xloc, yloc , 0) );
7112
7113   yloc += pcbBoardsSteel->GetDY() + pcbBoardsPPS->GetDY();
7114   trayStructure->AddNode(ppsPCBBoards, 1,
7115                          new TGeoTranslation( xloc, yloc , 0) );
7116
7117
7118   // Finally put everything in the mother volume
7119   alphafold = kSideCFoldAngle;
7120
7121   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
7122     alpharot = kTraySideCAlphaRot[jt];
7123     xloc = kTraySideCRPos*SinD(alpharot);
7124     yloc = kTraySideCRPos*CosD(alpharot);
7125     moth->AddNode(trayStructure,jt+1,
7126                        new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
7127                        new TGeoRotation("",-90.+alpharot,-90.,90.+alphafold)));
7128   }
7129
7130
7131   return;
7132 }
7133
7134
7135 //______________________________________________________________________
7136 void AliITSv11GeometrySupport::SSDCableTraysSideA(TGeoVolume *moth,
7137                                             const TGeoManager *mgr){
7138 //
7139 // Creates the SSD cable trays which are outside the ITS support cones
7140 // but still inside the TPC on Side A
7141 // (part of this code is taken or anyway inspired to ServicesCableSupport
7142 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
7143 //
7144 // Input:
7145 //         moth : the TGeoVolume owing the volume structure
7146 //         mgr  : the GeoManager (default gGeoManager)
7147 // Output:
7148 //
7149 // Created:         ???       Bjorn S. Nilsen
7150 // Updated:      30 Dec 2009  Mario Sitta
7151 //
7152 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
7153 // drawings and other (oral) information given by F.Tosello and
7154 // Ton van den Brink
7155 // Cables and cooling tubes are approximated with proper materials and
7156 // rectangular cross sections, always preserving the total material budget.
7157 //
7158
7159   // Dimensions and positions of the A-Side Cable Trays
7160   // (parts of 0872/G/D)
7161   const Double_t kTrayARTrans            =  408.35 *fgkmm;
7162   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
7163   const Double_t kForwardSideYTrans      =   12.00 *fgkmm;//!!!TO BE CHECKED!!!
7164   const Double_t kCoversYTrans           =    2.00 *fgkmm;
7165   const Double_t kTrayAZRot              = (180-169.5);// Degrees
7166   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
7167   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
7168
7169   const Double_t kTrayTotalHeight        =   52.00 *fgkmm;
7170   const Double_t kTrayHeighToBend        =   32.00 *fgkmm;
7171   const Double_t kTrayWidth              =  130.00 *fgkmm;
7172   const Double_t kTrayThick              =    2.00 *fgkmm;
7173
7174   const Double_t kTrayBendAngle          =   22.00 *TMath::DegToRad();
7175
7176   const Double_t kForwardTrayTotalLen    =  853.00 *fgkmm;
7177   const Double_t kForwardTrayFirstLen    =  350.00 *fgkmm;
7178   const Double_t kForwardTrayFirstHeight =   47.00 *fgkmm;
7179   const Double_t kForwardCoverLen        =  420.00 *fgkmm;
7180
7181   const Double_t kForwardSideLength      = kForwardTrayFirstLen;//!!!TO BE CHECKED!!!
7182   const Double_t kForwardSideHeight      =   90.00 *fgkmm;//!!!TO BE CHECKED!!!
7183   const Double_t kForwardSideThick       =    1.00 *fgkmm;//!!!TO BE CHECKED!!!
7184   const Double_t kForwardCoverHeight     =   10.00 *fgkmm;//!!!TO BE CHECKED!!!
7185
7186   const Double_t kExternalTrayTotalLen   = 1200.00 *fgkmm;
7187   const Double_t kExternalCoverLen       = kExternalTrayTotalLen;
7188   const Double_t kExternalCoverThick     =    5.00 *fgkmm;
7189
7190   const Int_t    kForwardTrayNpoints     =   16;
7191
7192   const Double_t kServicesWidth          =  100.00 *fgkmm;
7193   const Double_t kCopperHeight           =   11.20 *fgkmm;// 1120 mm^2
7194   const Double_t kCablePlasticHeight     =   11.50 *fgkmm;// 1150 mm^2
7195   const Double_t kCoolingWaterHeight     =    2.65 *fgkmm;//  265 mm^2
7196   const Double_t kPoliUrethaneHeight     =    4.62 *fgkmm;//  462 mm^2
7197
7198
7199   // Local variables
7200   Double_t xprof[kForwardTrayNpoints], yprof[kForwardTrayNpoints];
7201   Double_t xloc, yloc, zloc, alpharot, totalhi;
7202
7203
7204   // The two tray components as assemblies
7205   TGeoVolumeAssembly *cableTrayAForw =
7206     new TGeoVolumeAssembly("ITSsupportSSDTrayAForw");
7207   TGeoVolumeAssembly *cableTrayAExt =
7208     new TGeoVolumeAssembly("ITSsupportSSDTrayAExt");
7209   
7210
7211   // First create all needed shapes
7212
7213   // The first part of the forward tray (part of 0872/G/D/07): a Xtru
7214   TGeoXtru *forwTrayPart1 = new TGeoXtru(2);
7215
7216   xprof[3] = kTrayWidth/2;
7217   yprof[3] = kForwardTrayFirstHeight;
7218   xprof[2] = xprof[3] - kTrayThick;
7219   yprof[2] = yprof[3];
7220   xprof[4] = xprof[3];
7221   yprof[4] = kTrayTotalHeight - kTrayHeighToBend;
7222   xprof[5] = xprof[4] - yprof[4]*TMath::Tan(kTrayBendAngle);
7223   yprof[5] = 0;
7224
7225   InsidePoint( xprof[3], yprof[3], xprof[4], yprof[4], xprof[5], yprof[5],
7226               -kTrayThick, xprof[1], yprof[1]);
7227
7228   xprof[6] = -xprof[5];
7229   yprof[6] =  yprof[5];
7230
7231   InsidePoint( xprof[4], yprof[4], xprof[5], yprof[5], xprof[6], yprof[6],
7232               -kTrayThick, xprof[0], yprof[0]);
7233
7234   // We did the right side, now reflex on the left side
7235   for (Int_t jp = 0; jp < 6; jp++) {
7236     xprof[6+jp] = -xprof[5-jp];
7237     yprof[6+jp] =  yprof[5-jp];
7238   }
7239
7240   // And now the actual Xtru
7241   forwTrayPart1->DefinePolygon(12, xprof, yprof);
7242   forwTrayPart1->DefineSection(0, 0);
7243   forwTrayPart1->DefineSection(1, kForwardTrayFirstLen);
7244
7245   // The second part of the forward tray (part of 0872/G/D/07): a Xtru
7246   TGeoXtru *forwTrayPart2 =
7247     CreateSDDSSDTraysSideA(kForwardTrayTotalLen - kForwardTrayFirstLen,
7248                            kTrayTotalHeight);
7249
7250   // The external tray (as 0872/G/D/03): a Xtru with same profile
7251   TGeoXtru *externalTray = CreateSDDSSDTraysSideA(kExternalTrayTotalLen,
7252                                                   kTrayTotalHeight);
7253
7254   // The side wall of the forward tray: a BBox
7255   TGeoBBox *forwSide = new TGeoBBox(kForwardSideThick/2,
7256                                     kForwardSideHeight/2,
7257                                     kForwardSideLength/2);
7258
7259   // The side cover over the walls: a Xtru
7260   TGeoXtru *forwSideCover = new TGeoXtru(2);
7261   forwSideCover->SetName("ITSsuppSSDForwCover");
7262
7263   xprof[0] = kTrayWidth/2 + 2*kForwardSideThick;
7264   yprof[0] = kForwardCoverHeight;
7265   xprof[1] = xprof[0];
7266   yprof[1] = 0;
7267   xprof[2] = xprof[1] - kForwardSideThick;
7268   yprof[2] = yprof[1];
7269   xprof[3] = xprof[2];
7270   yprof[3] = yprof[0] - kForwardSideThick;
7271
7272   // We did the right side, now reflex on the left side
7273   for (Int_t jp = 0; jp < 4; jp++) {
7274     xprof[4+jp] = -xprof[3-jp];
7275     yprof[4+jp] =  yprof[3-jp];
7276   }
7277
7278   forwSideCover->DefinePolygon(8, xprof, yprof);
7279   forwSideCover->DefineSection(0, 0);
7280   forwSideCover->DefineSection(1, kForwardSideLength);
7281
7282   // The forward and external covers: two Composite Shape's
7283   TGeoCompositeShape *forwardCover = CreateTrayAForwardCover(kForwardCoverLen);
7284
7285   TGeoCompositeShape *externCover = CreateTrayAExternalCover(kExternalCoverLen);
7286
7287   // The cable copper inside the forward tray: a BBox
7288   TGeoBBox *forwCopper = new TGeoBBox(kServicesWidth/2,
7289                                       kCopperHeight/2,
7290                                       kForwardTrayTotalLen/2);
7291
7292   // The cable copper inside the forward tray: a Xtru
7293   TGeoXtru *extCopper = new TGeoXtru(2);
7294   extCopper->SetName("ITSsuppSSDExtTrayCopper");
7295
7296   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7297           - kTrayThick;
7298
7299   xprof[0] = -totalhi*TanD(kTrayAZRot);
7300   yprof[0] = kTrayThick;
7301   xprof[1] = kExternalTrayTotalLen;
7302   yprof[1] = yprof[0];
7303   xprof[2] = xprof[1];
7304   yprof[2] = yprof[1] + kCopperHeight;
7305   totalhi -= kCopperHeight;
7306   xprof[3] = -totalhi*TanD(kTrayAZRot);
7307   yprof[3] = yprof[2];
7308
7309   extCopper->DefinePolygon(4, xprof, yprof);
7310   extCopper->DefineSection(0, 0);
7311   extCopper->DefineSection(1, kServicesWidth);
7312
7313   // The cable plastic inside the forward tray: a BBox
7314   TGeoBBox *forwPlastic = new TGeoBBox(kServicesWidth/2,
7315                                        kCablePlasticHeight/2,
7316                                        kForwardTrayTotalLen/2);
7317
7318   // The cable plastic inside the forward tray: a Xtru
7319   TGeoXtru *extPlastic = new TGeoXtru(2);
7320   extPlastic->SetName("ITSsuppSSDExtTrayPlastic");
7321
7322   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7323           - kTrayThick - kCopperHeight;
7324
7325   xprof[0] = -totalhi*TanD(kTrayAZRot);
7326   yprof[0] = kTrayThick;
7327   xprof[1] = kExternalTrayTotalLen;
7328   yprof[1] = yprof[0];
7329   xprof[2] = xprof[1];
7330   yprof[2] = yprof[1] + kCablePlasticHeight;
7331   totalhi -= kCablePlasticHeight;
7332   xprof[3] = -totalhi*TanD(kTrayAZRot);
7333   yprof[3] = yprof[2];
7334
7335   extPlastic->DefinePolygon(4, xprof, yprof);
7336   extPlastic->DefineSection(0, 0);
7337   extPlastic->DefineSection(1, kServicesWidth);
7338
7339   // The cooling water inside the forward tray: a BBox
7340   TGeoBBox *forwWater = new TGeoBBox(kServicesWidth/2,
7341                                      kCoolingWaterHeight/2,
7342                                      kForwardTrayTotalLen/2);
7343
7344   // The cooling water inside the forward tray: a Xtru
7345   TGeoXtru *extWater = new TGeoXtru(2);
7346   extWater->SetName("ITSsuppSSDExtTrayWater");
7347
7348   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7349           - kTrayThick - kCopperHeight - kCablePlasticHeight;
7350
7351   xprof[0] = -totalhi*TanD(kTrayAZRot);
7352   yprof[0] = kTrayThick;
7353   xprof[1] = kExternalTrayTotalLen;
7354   yprof[1] = yprof[0];
7355   xprof[2] = xprof[1];
7356   yprof[2] = yprof[1] + kCoolingWaterHeight;
7357   totalhi -= kCoolingWaterHeight;
7358   xprof[3] = -totalhi*TanD(kTrayAZRot);
7359   yprof[3] = yprof[2];
7360
7361   extWater->DefinePolygon(4, xprof, yprof);
7362   extWater->DefineSection(0, 0);
7363   extWater->DefineSection(1, kServicesWidth);
7364
7365   // The polyurethane inside the forward tray: a BBox
7366   TGeoBBox *forwPUR = new TGeoBBox(kServicesWidth/2,
7367                                    kPoliUrethaneHeight/2,
7368                                    kForwardTrayTotalLen/2);
7369
7370   // The poliurethane inside the forward tray: a Xtru
7371   TGeoXtru *extPUR = new TGeoXtru(2);
7372   extPUR->SetName("ITSsuppSSDExtTrayPUR");
7373
7374   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7375           - kTrayThick - kCopperHeight - kCablePlasticHeight
7376           - kCoolingWaterHeight;
7377
7378   xprof[0] = -totalhi*TanD(kTrayAZRot);
7379   yprof[0] = kTrayThick;
7380   xprof[1] = kExternalTrayTotalLen;
7381   yprof[1] = yprof[0];
7382   xprof[2] = xprof[1];
7383   yprof[2] = yprof[1] + kPoliUrethaneHeight;
7384   totalhi -= kPoliUrethaneHeight;
7385   xprof[3] = -totalhi*TanD(kTrayAZRot);
7386   yprof[3] = yprof[2];
7387
7388   extPUR->DefinePolygon(4, xprof, yprof);
7389   extPUR->DefineSection(0, 0);
7390   extPUR->DefineSection(1, kServicesWidth);
7391
7392
7393   // We have all shapes: now create the real volumes
7394   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
7395   TGeoMedium *medAntic = mgr->GetMedium("ITS_ANTICORODAL$");
7396   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
7397   TGeoMedium *medFEP   = mgr->GetMedium("ITS_SSD FEP$");
7398   TGeoMedium *medH2O   = mgr->GetMedium("ITS_WATER$");
7399   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
7400
7401   TGeoVolume *forwTrayFirst = new TGeoVolume("ITSsuppSSDSideAForwTrayFirst",
7402                                              forwTrayPart1, medAl);
7403
7404   forwTrayFirst->SetVisibility(kTRUE);
7405   forwTrayFirst->SetLineColor(6); // Purple
7406   forwTrayFirst->SetLineWidth(1);
7407   forwTrayFirst->SetFillColor(forwTrayFirst->GetLineColor());
7408   forwTrayFirst->SetFillStyle(4000); // 0% transparent
7409
7410   TGeoVolume *forwTraySecond = new TGeoVolume("ITSsuppSSDSideAForwTraySecond",
7411                                               forwTrayPart2, medAl);
7412
7413   forwTraySecond->SetVisibility(kTRUE);
7414   forwTraySecond->SetLineColor(6); // Purple
7415   forwTraySecond->SetLineWidth(1);
7416   forwTraySecond->SetFillColor(forwTraySecond->GetLineColor());
7417   forwTraySecond->SetFillStyle(4000); // 0% transparent
7418
7419   TGeoVolume *forwTraySide = new TGeoVolume("ITSsuppSSDSideAForwTraySide",
7420                                             forwSide, medAl);
7421
7422   forwTraySide->SetVisibility(kTRUE);
7423   forwTraySide->SetLineColor(6); // Purple
7424   forwTraySide->SetLineWidth(1);
7425   forwTraySide->SetFillColor(forwTraySide->GetLineColor());
7426   forwTraySide->SetFillStyle(4000); // 0% transparent
7427
7428   TGeoVolume *forwTraySideCover = new TGeoVolume("ITSsuppSSDSideAForwTraySideCover",
7429                                             forwSideCover, medAl);
7430
7431   forwTraySideCover->SetVisibility(kTRUE);
7432   forwTraySideCover->SetLineColor(6); // Purple
7433   forwTraySideCover->SetLineWidth(1);
7434   forwTraySideCover->SetFillColor(forwTraySideCover->GetLineColor());
7435   forwTraySideCover->SetFillStyle(4000); // 0% transparent
7436
7437   TGeoVolume *externalTraySSD = new TGeoVolume("ITSsuppSSDSideAExternalTray",
7438                                                externalTray, medAl);
7439
7440   externalTraySSD->SetVisibility(kTRUE);
7441   externalTraySSD->SetLineColor(6); // Purple
7442   externalTraySSD->SetLineWidth(1);
7443   externalTraySSD->SetFillColor(externalTraySSD->GetLineColor());
7444   externalTraySSD->SetFillStyle(4000); // 0% transparent
7445
7446   TGeoVolume *forwardTrayCover = new TGeoVolume("ITSsuppSSDSideAForwTrayCover",
7447                                                 forwardCover, medAntic);
7448
7449   forwardTrayCover->SetVisibility(kTRUE);
7450   forwardTrayCover->SetLineColor(kMagenta+1); // Purple
7451   forwardTrayCover->SetLineWidth(1);
7452   forwardTrayCover->SetFillColor(forwardTrayCover->GetLineColor());
7453   forwardTrayCover->SetFillStyle(4000); // 0% transparent
7454
7455   TGeoVolume *externTrayCover = new TGeoVolume("ITSsuppSSDSideAExtTrayCover",
7456                                                externCover, medAntic);
7457
7458   externTrayCover->SetVisibility(kTRUE);
7459   externTrayCover->SetLineColor(kMagenta+1); // Purple
7460   externTrayCover->SetLineWidth(1);
7461   externTrayCover->SetFillColor(externTrayCover->GetLineColor());
7462   externTrayCover->SetFillStyle(4000); // 0% transparent
7463
7464   TGeoVolume *forwCableCu = new TGeoVolume("ITSsuppSSDSideAForwCableCu",
7465                                            forwCopper, medCu);
7466
7467   forwCableCu->SetVisibility(kTRUE);
7468   forwCableCu->SetLineColor(kRed); // Red
7469   forwCableCu->SetLineWidth(1);
7470   forwCableCu->SetFillColor(forwCableCu->GetLineColor());
7471   forwCableCu->SetFillStyle(4000); // 0% transparent
7472
7473   TGeoVolume *extCableCu = new TGeoVolume("ITSsuppSSDSideAExtCableCu",
7474                                           extCopper, medCu);
7475
7476   extCableCu->SetVisibility(kTRUE);
7477   extCableCu->SetLineColor(kRed); // Red
7478   extCableCu->SetLineWidth(1);
7479   extCableCu->SetFillColor(extCableCu->GetLineColor());
7480   extCableCu->SetFillStyle(4000); // 0% transparent
7481
7482   TGeoVolume *forwCableFEP = new TGeoVolume("ITSsuppSSDSideAForwCableFEP",
7483                                             forwPlastic, medFEP);
7484
7485   forwCableFEP->SetVisibility(kTRUE);
7486   forwCableFEP->SetLineColor(kYellow); // Yellow
7487   forwCableFEP->SetLineWidth(1);
7488   forwCableFEP->SetFillColor(forwCableFEP->GetLineColor());
7489   forwCableFEP->SetFillStyle(4000); // 0% transparent
7490
7491   TGeoVolume *extCableFEP = new TGeoVolume("ITSsuppSSDSideAExtCableFEP",
7492                                            extPlastic, medFEP);
7493
7494   extCableFEP->SetVisibility(kTRUE);
7495   extCableFEP->SetLineColor(kYellow); // Yellow
7496   extCableFEP->SetLineWidth(1);
7497   extCableFEP->SetFillColor(extCableFEP->GetLineColor());
7498   extCableFEP->SetFillStyle(4000); // 0% transparent
7499
7500   TGeoVolume *forwTrayWater = new TGeoVolume("ITSsuppSSDSideAForwTrayWater",
7501                                              forwWater, medH2O);
7502
7503   forwTrayWater->SetVisibility(kTRUE);
7504   forwTrayWater->SetLineColor(kBlue); // Blue
7505   forwTrayWater->SetLineWidth(1);
7506   forwTrayWater->SetFillColor(forwTrayWater->GetLineColor());
7507   forwTrayWater->SetFillStyle(4000); // 0% transparent
7508
7509   TGeoVolume *extTrayWater = new TGeoVolume("ITSsuppSSDSideAExtTrayWater",
7510                                             extWater, medH2O);
7511
7512   extTrayWater->SetVisibility(kTRUE);
7513   extTrayWater->SetLineColor(kBlue); // Blue
7514   extTrayWater->SetLineWidth(1);
7515   extTrayWater->SetFillColor(extTrayWater->GetLineColor());
7516   extTrayWater->SetFillStyle(4000); // 0% transparent
7517
7518   TGeoVolume *forwPolyUr = new TGeoVolume("ITSsuppSSDSideAForwPolyUr",
7519                                           forwPUR, medPUR);
7520
7521   forwPolyUr->SetVisibility(kTRUE);
7522   forwPolyUr->SetLineColor(kGray); // Gray
7523   forwPolyUr->SetLineWidth(1);
7524   forwPolyUr->SetFillColor(forwPolyUr->GetLineColor());
7525   forwPolyUr->SetFillStyle(4000); // 0% transparent
7526
7527   TGeoVolume *extPolyUr = new TGeoVolume("ITSsuppSSDSideAExtPolyUr",
7528                                          extPUR, medPUR);
7529
7530   extPolyUr->SetVisibility(kTRUE);
7531   extPolyUr->SetLineColor(kGray); // Gray
7532   extPolyUr->SetLineWidth(1);
7533   extPolyUr->SetFillColor(extPolyUr->GetLineColor());
7534   extPolyUr->SetFillStyle(4000); // 0% transparent
7535
7536
7537   // Now build up the tray
7538   cableTrayAForw->AddNode(forwTrayFirst, 1, 0);
7539
7540   cableTrayAForw->AddNode(forwTraySecond, 1,
7541                         new TGeoTranslation(0, 0, kForwardTrayFirstLen) );
7542
7543   xloc = kTrayWidth/2 + kForwardSideThick/2;
7544   yloc = kForwardTrayFirstHeight + kForwardSideHeight/2 - kForwardSideYTrans;
7545   zloc = kForwardSideLength/2;
7546   cableTrayAForw->AddNode(forwTraySide,1,
7547                         new TGeoTranslation( xloc, yloc, zloc) );
7548   cableTrayAForw->AddNode(forwTraySide,2,
7549                         new TGeoTranslation(-xloc, yloc, zloc) );
7550
7551   yloc = kForwardTrayFirstHeight + kForwardSideHeight - kForwardSideYTrans
7552        - kForwardCoverHeight;
7553   cableTrayAForw->AddNode(forwTraySideCover,1,
7554                         new TGeoTranslation(0, yloc, 0) );
7555
7556   yloc = kTrayTotalHeight - kCoversYTrans;
7557   zloc = kForwardTrayTotalLen - kForwardCoverLen;
7558   cableTrayAForw->AddNode(forwardTrayCover,1,
7559                         new TGeoTranslation(0, yloc, zloc) );
7560
7561   yloc = kTrayThick + forwCopper->GetDY();
7562   zloc = forwCopper->GetDZ();
7563   cableTrayAForw->AddNode(forwCableCu, 1,
7564                         new TGeoTranslation(0, yloc, zloc) );
7565
7566   yloc = kTrayThick + kCopperHeight + forwPlastic->GetDY();
7567   zloc = forwPlastic->GetDZ();
7568   cableTrayAForw->AddNode(forwCableFEP, 1,
7569                         new TGeoTranslation(0, yloc, zloc) );
7570
7571   yloc = kTrayThick + kCopperHeight + kCablePlasticHeight + forwWater->GetDY();
7572   zloc = forwWater->GetDZ();
7573   cableTrayAForw->AddNode(forwTrayWater, 1,
7574                         new TGeoTranslation(0, yloc, zloc) );
7575
7576   yloc = kTrayThick + kCopperHeight + kCablePlasticHeight
7577        + kCoolingWaterHeight + forwPUR->GetDY();
7578   zloc = forwPUR->GetDZ();
7579   cableTrayAForw->AddNode(forwPolyUr, 1,
7580                         new TGeoTranslation(0, yloc, zloc) );
7581
7582   // To simplify following placement in MARS, origin is on top
7583   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans;
7584
7585   yloc = -totalhi;
7586   cableTrayAExt->AddNode(externalTraySSD, 1,
7587                         new TGeoTranslation(0, yloc, 0) );
7588
7589   yloc = -totalhi + kTrayTotalHeight - kCoversYTrans;
7590   cableTrayAExt->AddNode(externTrayCover,1,
7591                         new TGeoTranslation(0, yloc, 0) );
7592
7593   xloc = extCopper->GetDZ();
7594   yloc = -totalhi;
7595   cableTrayAExt->AddNode(extCableCu,1,
7596                         new TGeoCombiTrans( xloc, yloc, 0,
7597                         new TGeoRotation("",-90, 90, 90)        ) );
7598
7599   xloc = extPlastic->GetDZ();
7600   yloc = -totalhi + kCopperHeight;
7601   cableTrayAExt->AddNode(extCableFEP,1,
7602                         new TGeoCombiTrans( xloc, yloc, 0,
7603                         new TGeoRotation("",-90, 90, 90)        ) );
7604
7605   xloc = extWater->GetDZ();
7606   yloc = -totalhi + kCopperHeight + kCablePlasticHeight;
7607   cableTrayAExt->AddNode(extTrayWater,1,
7608                         new TGeoCombiTrans( xloc, yloc, 0,
7609                         new TGeoRotation("",-90, 90, 90)        ) );
7610
7611   xloc = extPUR->GetDZ();
7612   yloc = -totalhi + kCopperHeight + kCablePlasticHeight + kCoolingWaterHeight;
7613   cableTrayAExt->AddNode(extPolyUr,1,
7614                         new TGeoCombiTrans( xloc, yloc, 0,
7615                         new TGeoRotation("",-90, 90, 90)        ) );
7616
7617
7618   // Finally put everything in the mother volume
7619   zloc = kTrayAZTrans;
7620   Double_t zlocext = zloc + kForwardTrayTotalLen;
7621   Double_t rExtTray = kTrayARTrans + kTrayTotalHeight;
7622
7623   alpharot = kTrayAFirstRotAng;
7624   xloc = kTrayARTrans*SinD(alpharot);
7625   yloc = kTrayARTrans*CosD(alpharot);
7626   moth->AddNode(cableTrayAForw,1,
7627                             new TGeoCombiTrans( xloc, yloc, zloc,
7628                             new TGeoRotation("",-alpharot,0,0)   )   );
7629   xloc = rExtTray*SinD(alpharot);
7630   yloc = rExtTray*CosD(alpharot);
7631   moth->AddNode(cableTrayAExt,1,
7632                             new TGeoCombiTrans( xloc, yloc, zlocext,
7633                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7634
7635   alpharot += 180;
7636   xloc = kTrayARTrans*SinD(alpharot);
7637   yloc = kTrayARTrans*CosD(alpharot);
7638   moth->AddNode(cableTrayAForw,2,
7639                             new TGeoCombiTrans( xloc, yloc, zloc,
7640                             new TGeoRotation("",-alpharot,0,0)   )   );
7641   xloc = rExtTray*SinD(alpharot);
7642   yloc = rExtTray*CosD(alpharot);
7643   moth->AddNode(cableTrayAExt,2,
7644                             new TGeoCombiTrans( xloc, yloc, zlocext,
7645                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7646
7647   alpharot = -kTrayAFirstRotAng - 2*kTrayASecondRotAng;
7648   xloc = kTrayARTrans*SinD(alpharot);
7649   yloc = kTrayARTrans*CosD(alpharot);
7650   moth->AddNode(cableTrayAForw,3,
7651                             new TGeoCombiTrans( xloc, yloc, zloc,
7652                             new TGeoRotation("",-alpharot,0,0)   )   );
7653   xloc = rExtTray*SinD(alpharot);
7654   yloc = rExtTray*CosD(alpharot);
7655   moth->AddNode(cableTrayAExt,3,
7656                             new TGeoCombiTrans( xloc, yloc, zlocext,
7657                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7658
7659   alpharot += 180;
7660   xloc = kTrayARTrans*SinD(alpharot);
7661   yloc = kTrayARTrans*CosD(alpharot);
7662   moth->AddNode(cableTrayAForw,4,
7663                             new TGeoCombiTrans( xloc, yloc, zloc,
7664                             new TGeoRotation("",-alpharot,0,0)   )   );
7665   xloc = rExtTray*SinD(alpharot);
7666   yloc = rExtTray*CosD(alpharot);
7667   moth->AddNode(cableTrayAExt,4,
7668                             new TGeoCombiTrans( xloc, yloc, zlocext,
7669                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7670
7671
7672   return;
7673 }
7674
7675 //______________________________________________________________________
7676 void AliITSv11GeometrySupport::SSDCableTraysSideC(TGeoVolume *moth,
7677                                             const TGeoManager *mgr){
7678 //
7679 // Creates the SSD cable trays which are outside the ITS support cones
7680 // but still inside the TPC on Side C
7681 // (part of this code is taken or anyway inspired to ServicesCableSupport
7682 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
7683 //
7684 // Input:
7685 //         moth : the TGeoVolume owing the volume structure
7686 //         mgr  : the GeoManager (default gGeoManager)
7687 // Output:
7688 //
7689 // Created:         ???       Bjorn S. Nilsen
7690 // Updated:      15 Apr 2010  Mario Sitta
7691 //
7692 // Technical data are taken from AutoCAD drawings and other (oral)
7693 // information given by F.Tosello
7694 //
7695
7696   // Dimensions and positions of the C-Side Cable Tray elements
7697   const Int_t    kNumTraySideC           =    4;
7698
7699   const Double_t kSideCFoldAngle         =    5.00 *fgkDegree;
7700
7701   const Double_t kServicesWidth          =  100.00 *fgkmm;
7702   const Double_t kCopperHeight           =   11.20 *fgkmm;// 1120 mm^2
7703   const Double_t kCablePlasticHeight     =   11.50 *fgkmm;// 1150 mm^2
7704   const Double_t kCoolingWaterHeight     =    2.65 *fgkmm;//  265 mm^2
7705   const Double_t kPoliUrethaneHeight     =    4.62 *fgkmm;//  462 mm^2
7706   const Double_t kCablesYtrans           =    2.50 *fgkmm;// Avoid ovlps
7707
7708   // Overall position and rotation of the C-Side Cable Trays
7709   const Double_t kTraySideCRPos          =   45.30    *fgkcm;
7710   const Double_t kTraySideCZPos          = -102.40    *fgkcm;
7711   const Double_t kTraySideCAlphaRot[kNumTraySideC]  = {     23.0,     -59.0,
7712     /* from Patch panel position */                    180.+23.0, 180.-59.0};
7713
7714
7715   // Local variables
7716   Double_t xprof[6], yprof[6];
7717   Double_t xloc, yloc, alpharot, alphafold;
7718
7719
7720   // The assembly holding the metallic structure
7721   TGeoVolumeAssembly *trayStructure =
7722                                 CreateSDDSSDTraysSideC("ITSsupportSSDTrayC");
7723
7724   // The cable copper inside the tray: a Xtru
7725   TGeoXtru *copper = new TGeoXtru(2);
7726   copper->SetName("ITSsuppSSDTrayCCopper");
7727
7728   // Copper lies on the lower plate: get position of its points
7729   TGeoXtru *lowerplate = (TGeoXtru*)(mgr->GetVolume("ITSsuppTraySideCLower")->GetShape());
7730   xprof[0] = lowerplate->GetX(5);
7731   yprof[0] = lowerplate->GetY(5) + kCablesYtrans;
7732   xprof[1] = lowerplate->GetX(4);
7733   yprof[1] = lowerplate->GetY(4) + kCablesYtrans;
7734   xprof[2] = lowerplate->GetX(3);
7735   yprof[2] = lowerplate->GetY(3) + kCablesYtrans;
7736   xprof[3] = xprof[2] - kCopperHeight*SinD(kSideCFoldAngle);
7737   yprof[3] = yprof[2] + kCopperHeight*CosD(kSideCFoldAngle);
7738   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7739               kCopperHeight , xprof[4], yprof[4]);
7740   xprof[5] = xprof[0];
7741   yprof[5] = yprof[0] + kCopperHeight;
7742
7743   copper->DefinePolygon(6, xprof, yprof);
7744   copper->DefineSection(0, -kServicesWidth/2);
7745   copper->DefineSection(1,  kServicesWidth/2);
7746
7747   // The cable plastic inside the tray: a Xtru
7748   TGeoXtru *plastic = new TGeoXtru(2);
7749   plastic->SetName("ITSsuppSSDTrayCPlastic");
7750
7751   xprof[0] = copper->GetX(5);
7752   yprof[0] = copper->GetY(5);
7753   xprof[1] = copper->GetX(4);
7754   yprof[1] = copper->GetY(4);
7755   xprof[2] = copper->GetX(3);
7756   yprof[2] = copper->GetY(3);
7757   xprof[3] = xprof[2] - kCablePlasticHeight*SinD(kSideCFoldAngle);
7758   yprof[3] = yprof[2] + kCablePlasticHeight*CosD(kSideCFoldAngle);
7759   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7760               kCablePlasticHeight , xprof[4], yprof[4]);
7761   xprof[5] = xprof[0];
7762   yprof[5] = yprof[0] + kCablePlasticHeight;
7763
7764   plastic->DefinePolygon(6, xprof, yprof);
7765   plastic->DefineSection(0, -kServicesWidth/2);
7766   plastic->DefineSection(1,  kServicesWidth/2);
7767
7768   // The cooling water inside the tray: a Xtru
7769   TGeoXtru *water = new TGeoXtru(2);
7770   water->SetName("ITSsuppSSDTrayCWater");
7771
7772   xprof[0] = plastic->GetX(5);
7773   yprof[0] = plastic->GetY(5);
7774   xprof[1] = plastic->GetX(4);
7775   yprof[1] = plastic->GetY(4);
7776   xprof[2] = plastic->GetX(3);
7777   yprof[2] = plastic->GetY(3);
7778   xprof[3] = xprof[2] - kCoolingWaterHeight*SinD(kSideCFoldAngle);
7779   yprof[3] = yprof[2] + kCoolingWaterHeight*CosD(kSideCFoldAngle);
7780   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7781               kCoolingWaterHeight , xprof[4], yprof[4]);
7782   xprof[5] = xprof[0];
7783   yprof[5] = yprof[0] + kCoolingWaterHeight;
7784
7785   water->DefinePolygon(6, xprof, yprof);
7786   water->DefineSection(0, -kServicesWidth/2);
7787   water->DefineSection(1,  kServicesWidth/2);
7788
7789   // The poliurethane inside the tray: a Xtru
7790   TGeoXtru *pur = new TGeoXtru(2);
7791   pur->SetName("ITSsuppSSDTrayCPUR");
7792   xprof[0] = water->GetX(5);
7793   yprof[0] = water->GetY(5);
7794   xprof[1] = water->GetX(4);
7795   yprof[1] = water->GetY(4);
7796   xprof[2] = water->GetX(3);
7797   yprof[2] = water->GetY(3);
7798   xprof[3] = xprof[2] - kPoliUrethaneHeight*SinD(kSideCFoldAngle);
7799   yprof[3] = yprof[2] + kPoliUrethaneHeight*CosD(kSideCFoldAngle);
7800   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7801               kPoliUrethaneHeight , xprof[4], yprof[4]);
7802   xprof[5] = xprof[0];
7803   yprof[5] = yprof[0] + kPoliUrethaneHeight;
7804
7805   pur->DefinePolygon(6, xprof, yprof);
7806   pur->DefineSection(0, -kServicesWidth/2);
7807   pur->DefineSection(1,  kServicesWidth/2);
7808
7809
7810   // We have all shapes: now create the real volumes
7811   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
7812   TGeoMedium *medFEP   = mgr->GetMedium("ITS_SSD FEP$");
7813   TGeoMedium *medH2O   = mgr->GetMedium("ITS_WATER$");
7814   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
7815
7816   TGeoVolume *copperCable = new TGeoVolume("ITSsuppSSDSideCCableCu",
7817                                            copper, medCu);
7818
7819   copperCable->SetVisibility(kTRUE);
7820   copperCable->SetLineColor(kRed); // Red
7821   copperCable->SetLineWidth(1);
7822   copperCable->SetFillColor(copperCable->GetLineColor());
7823   copperCable->SetFillStyle(4000); // 0% transparent
7824
7825   TGeoVolume *cableFEP = new TGeoVolume("ITSsuppSSDSideCCableFEP",
7826                                         plastic, medFEP);
7827
7828   cableFEP->SetVisibility(kTRUE);
7829   cableFEP->SetLineColor(kYellow); // Yellow
7830   cableFEP->SetLineWidth(1);
7831   cableFEP->SetFillColor(cableFEP->GetLineColor());
7832   cableFEP->SetFillStyle(4000); // 0% transparent
7833
7834   TGeoVolume *trayWater = new TGeoVolume("ITSsuppSSDSideCTrayWater",
7835                                          water, medH2O);
7836
7837   trayWater->SetVisibility(kTRUE);
7838   trayWater->SetLineColor(kBlue); // Blue
7839   trayWater->SetLineWidth(1);
7840   trayWater->SetFillColor(trayWater->GetLineColor());
7841   trayWater->SetFillStyle(4000); // 0% transparent
7842
7843   TGeoVolume *trayPolyUr = new TGeoVolume("ITSsuppSSDSideCPolyUr",
7844                                           pur, medPUR);
7845
7846   trayPolyUr->SetVisibility(kTRUE);
7847   trayPolyUr->SetLineColor(kGray); // Gray
7848   trayPolyUr->SetLineWidth(1);
7849   trayPolyUr->SetFillColor(trayPolyUr->GetLineColor());
7850   trayPolyUr->SetFillStyle(4000); // 0% transparent
7851
7852
7853   // Now fill in the tray
7854   trayStructure->AddNode(copperCable,1,0);
7855   trayStructure->AddNode(cableFEP,1,0);
7856   trayStructure->AddNode(trayWater,1,0);
7857   trayStructure->AddNode(trayPolyUr,1,0);
7858
7859
7860   // Finally put everything in the mother volume
7861   alphafold = kSideCFoldAngle;
7862
7863   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
7864     alpharot = kTraySideCAlphaRot[jt];
7865     xloc = kTraySideCRPos*SinD(alpharot);
7866     yloc = kTraySideCRPos*CosD(alpharot);
7867     moth->AddNode(trayStructure,jt+1,
7868                        new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
7869                        new TGeoRotation("",-90.+alpharot,-90.,90.+alphafold)));
7870   }
7871
7872
7873   return;
7874 }
7875
7876 //______________________________________________________________________
7877 void AliITSv11GeometrySupport::CreateSDDForwardTraySideA(TGeoVolumeAssembly *tray,
7878                                                    const TGeoManager *mgr){
7879 //
7880 // Creates the forward SDD tray on Side A (0872/G/D/01)
7881 //
7882 // Input:
7883 //         tray : the TGeoVolumeAssembly to put the elements in
7884 //         mgr  : the GeoManager (used only to get the proper material)
7885 //
7886 // Output:
7887 //
7888 // Return:
7889 //
7890 // Created:      08 Jan 2010  Mario Sitta
7891 // Updated:      07 Sep 2010  Mario Sitta
7892 //
7893 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
7894 // drawings and other (oral) information given by F.Tosello
7895 //
7896
7897   // Dimensions of the A-Side Forward Cable Tray (0872/G/D/01)
7898   const Double_t kForwardTrayThick        =    2.00 *fgkmm;
7899   const Double_t kForwardTraySideLength   =  823.00 *fgkmm;
7900   const Double_t kForwardTrayTailLength   =  212.00 *fgkmm;
7901   const Double_t kForwardTrayBaseHalfWide =   55.00 *fgkmm;
7902   const Double_t kForwardTrayNotchLength  =   47.20 *fgkmm;
7903   const Double_t kForwardTrayNotchHeight  =   25.00 *fgkmm;
7904   const Double_t kForwardTrayNotchDown    =   10.00 *fgkmm;
7905   const Double_t kForwardTraySide1Height  =   39.00 *fgkmm;
7906   const Double_t kForwardTraySide2Height  =   26.00 *fgkmm;
7907   const Double_t kForwardTraySide2Expand  =   10.50 *fgkmm;
7908   const Double_t kForwardTraySide3TailLen =  418.00 *fgkmm;
7909   const Double_t kForwardTraySide3TailHi  =   31.00 *fgkmm;
7910   const Double_t kForwardTraySide3HeadLen =  425.00 *fgkmm;
7911   const Double_t kForwardTraySide3HeadHi  =   72.00 *fgkmm;
7912   const Double_t kForwardTrayHorWingWide  =   10.50 *fgkmm;
7913   const Double_t kForwardTrayVertWingWide =   15.00 *fgkmm;
7914
7915   const Int_t    kForwardTraySideNpoints  =    9;
7916
7917
7918   // Local variables
7919   Double_t xprof[kForwardTraySideNpoints], yprof[kForwardTraySideNpoints];
7920   Double_t ylen, zlen;
7921   Double_t xloc, yloc, zloc;
7922
7923
7924   // The tray has a very complex shape, so it is made by assembling
7925   // different elements (with some small simplifications)
7926
7927   // The tray base: a BBox
7928   zlen = (kForwardTraySideLength-kForwardTrayTailLength)/2;
7929   TGeoBBox *trayBase = new TGeoBBox(kForwardTrayBaseHalfWide,
7930                                     kForwardTrayThick/2, zlen);
7931
7932   // The first part of the side wall: a Xtru
7933   TGeoXtru *traySide1 = new TGeoXtru(2);
7934
7935   xprof[0] = 0;
7936   yprof[0] = kForwardTrayThick;
7937   xprof[1] = kForwardTraySideLength-kForwardTrayTailLength;
7938   yprof[1] = yprof[0];
7939   xprof[2] = kForwardTraySideLength;
7940   yprof[2] = kForwardTraySide1Height + kForwardTrayThick;
7941   xprof[3] = 0;
7942   yprof[3] = yprof[2];
7943
7944   traySide1->DefinePolygon(4, xprof, yprof);
7945   traySide1->DefineSection(0, 0);
7946   traySide1->DefineSection(1, kForwardTrayThick);
7947
7948   // The second part of the side wall: a Xtru
7949   TGeoXtru *traySide2 = new TGeoXtru(2);
7950
7951   xprof[0] = kForwardTrayBaseHalfWide - kForwardTrayThick;
7952   yprof[0] = traySide1->GetY(2);
7953   xprof[1] = kForwardTrayBaseHalfWide;
7954   yprof[1] = yprof[0];
7955   xprof[2] = xprof[1] + kForwardTraySide2Expand;
7956   yprof[2] = yprof[1] + kForwardTraySide2Height;
7957   xprof[3] = xprof[2] - kForwardTrayThick;
7958   yprof[3] = yprof[2];
7959
7960   traySide2->DefinePolygon(4, xprof, yprof);
7961   traySide2->DefineSection(0, 0);
7962   traySide2->DefineSection(1, kForwardTraySideLength);
7963
7964   // The third part of the side wall: a Xtru
7965   TGeoXtru *traySide3 = new TGeoXtru(2);
7966
7967   xprof[0] = 0;
7968   yprof[0] = traySide2->GetY(2);
7969   xprof[1] = kForwardTraySideLength;
7970   yprof[1] = yprof[0];
7971   xprof[2] = xprof[1];
7972   yprof[2] = yprof[1] + kForwardTraySide3TailHi - kForwardTrayThick;
7973   xprof[3] = xprof[2] - kForwardTraySide3TailLen - kForwardTrayThick;
7974   yprof[3] = yprof[2];
7975   xprof[4] = xprof[3];
7976   yprof[4] = yprof[3] + kForwardTraySide3HeadHi + kForwardTrayThick;
7977   xprof[5] = xprof[4] - kForwardTraySide3HeadLen;
7978   yprof[5] = yprof[4];
7979   xprof[6] = xprof[5];
7980   yprof[6] = yprof[5] - kForwardTrayNotchHeight;
7981   xprof[7] = xprof[6] + kForwardTrayNotchLength;
7982   yprof[7] = yprof[6];
7983   xprof[8] = xprof[7];
7984   yprof[8] = yprof[7] - kForwardTrayNotchDown;
7985
7986   traySide3->DefinePolygon(9, xprof, yprof);
7987   traySide3->DefineSection(0, 0);
7988   traySide3->DefineSection(1, kForwardTrayThick);
7989
7990   // The horizontal wing: a BBox
7991   TGeoBBox *trayHorWing = new TGeoBBox(kForwardTrayHorWingWide/2,
7992                                        kForwardTrayThick/2,
7993                                        kForwardTraySide3TailLen/2);
7994
7995   // The vertical wing: a BBox
7996   ylen = (traySide3->GetY(4) - traySide3->GetY(3))/2;
7997   TGeoBBox *trayVertWing = new TGeoBBox(kForwardTrayVertWingWide/2,
7998                                         ylen, kForwardTrayThick/2);
7999
8000
8001   // We have all shapes: now create the real volumes
8002   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
8003
8004   TGeoVolume *forwTrayBase = new TGeoVolume("ITSsuppSDDSideAForwTrayBase",
8005                                             trayBase, medAl);
8006
8007   forwTrayBase->SetVisibility(kTRUE);
8008   forwTrayBase->SetLineColor(6); // Purple
8009   forwTrayBase->SetLineWidth(1);
8010   forwTrayBase->SetFillColor(forwTrayBase->GetLineColor());
8011   forwTrayBase->SetFillStyle(4000); // 0% transparent
8012
8013   TGeoVolume *forwTraySide1 = new TGeoVolume("ITSsuppSDDSideAForwTraySide1",
8014                                             traySide1, medAl);
8015
8016   forwTraySide1->SetVisibility(kTRUE);
8017   forwTraySide1->SetLineColor(6); // Purple
8018   forwTraySide1->SetLineWidth(1);
8019   forwTraySide1->SetFillColor(forwTraySide1->GetLineColor());
8020   forwTraySide1->SetFillStyle(4000); // 0% transparent
8021
8022   TGeoVolume *forwTraySide2 = new TGeoVolume("ITSsuppSDDSideAForwTraySide2",
8023                                             traySide2, medAl);
8024
8025   forwTraySide2->SetVisibility(kTRUE);
8026   forwTraySide2->SetLineColor(6); // Purple
8027   forwTraySide2->SetLineWidth(1);
8028   forwTraySide2->SetFillColor(forwTraySide2->GetLineColor());
8029   forwTraySide2->SetFillStyle(4000); // 0% transparent
8030
8031   TGeoVolume *forwTraySide3 = new TGeoVolume("ITSsuppSDDSideAForwTraySide3",
8032                                             traySide3, medAl);
8033
8034   forwTraySide3->SetVisibility(kTRUE);
8035   forwTraySide3->SetLineColor(6); // Purple
8036   forwTraySide3->SetLineWidth(1);
8037   forwTraySide3->SetFillColor(forwTraySide3->GetLineColor());
8038   forwTraySide3->SetFillStyle(4000); // 0% transparent
8039
8040   TGeoVolume *forwTrayHWing = new TGeoVolume("ITSsuppSDDSideAForwTrayHorWing",
8041                                             trayHorWing, medAl);
8042
8043   forwTrayHWing->SetVisibility(kTRUE);
8044   forwTrayHWing->SetLineColor(6); // Purple
8045   forwTrayHWing->SetLineWidth(1);
8046   forwTrayHWing->SetFillColor(forwTrayHWing->GetLineColor());
8047   forwTrayHWing->SetFillStyle(4000); // 0% transparent
8048
8049   TGeoVolume *forwTrayVWing = new TGeoVolume("ITSsuppSDDSideAForwTrayVertWing",
8050                                             trayVertWing, medAl);
8051
8052   forwTrayVWing->SetVisibility(kTRUE);
8053   forwTrayVWing->SetLineColor(6); // Purple
8054   forwTrayVWing->SetLineWidth(1);
8055   forwTrayVWing->SetFillColor(forwTrayVWing->GetLineColor());
8056   forwTrayVWing->SetFillStyle(4000); // 0% transparent
8057
8058
8059   // Now build up the tray
8060   yloc = kForwardTrayThick/2;
8061   zloc = zlen;
8062   tray->AddNode(forwTrayBase, 1,
8063                 new TGeoTranslation(0, yloc, zloc) );
8064
8065   xloc = kForwardTrayBaseHalfWide;
8066   tray->AddNode(forwTraySide1, 1,
8067                 new TGeoCombiTrans(xloc, 0, 0,
8068                                    new TGeoRotation("",90,-90,-90)));
8069   xloc = -xloc + kForwardTrayThick;
8070   tray->AddNode(forwTraySide1, 2,
8071                 new TGeoCombiTrans(xloc, 0, 0,
8072                                    new TGeoRotation("",90,-90,-90)));
8073
8074   tray->AddNode(forwTraySide2, 1, 0);
8075   zloc = kForwardTraySideLength;
8076   tray->AddNode(forwTraySide2, 2,
8077                 new TGeoCombiTrans(0, 0, zloc,
8078                                    new TGeoRotation("",90,-180,-90)));
8079
8080   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand;
8081   tray->AddNode(forwTraySide3, 1,
8082                 new TGeoCombiTrans(xloc, 0, 0,
8083                                    new TGeoRotation("",90,-90,-90)));
8084   xloc = -xloc + kForwardTrayThick;
8085   tray->AddNode(forwTraySide3, 2,
8086                 new TGeoCombiTrans(xloc, 0, 0,
8087                                    new TGeoRotation("",90,-90,-90)));
8088
8089   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand
8090        - kForwardTrayHorWingWide/2;
8091   yloc = traySide3->GetY(2) + kForwardTrayThick/2;
8092   zloc = kForwardTraySideLength - trayHorWing->GetDZ();
8093   tray->AddNode(forwTrayHWing, 1,
8094                 new TGeoTranslation( xloc, yloc, zloc) );
8095   tray->AddNode(forwTrayHWing, 2,
8096                 new TGeoTranslation(-xloc, yloc, zloc) );
8097
8098   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand
8099        - kForwardTrayVertWingWide/2;
8100   yloc = traySide3->GetY(2) + trayVertWing->GetDY();
8101   zloc = traySide3->GetX(3) + kForwardTrayThick/2;
8102   tray->AddNode(forwTrayVWing, 1,
8103                 new TGeoTranslation( xloc, yloc, zloc) );
8104   tray->AddNode(forwTrayVWing, 2,
8105                 new TGeoTranslation(-xloc, yloc, zloc) );
8106
8107
8108   return;
8109 }
8110
8111 //______________________________________________________________________
8112 TGeoCompositeShape* AliITSv11GeometrySupport::CreateTrayAForwardCover(const Double_t coverLen){
8113 //
8114 // Creates the forward cover of the SDD and SSD cable trays on Side A
8115 // (0872/G/D/02)
8116 //
8117 // Input:
8118 //             coverLen: the total length of the cover
8119 //
8120 // Output:
8121 //
8122 // Return:     a TGeoCompositeShape for the cover
8123 //
8124 // Created:      03 Jan 2010  Mario Sitta
8125 //
8126 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8127 // drawings and other (oral) information given by F.Tosello
8128 //
8129
8130   // Dimensions and positions of the A-Side Cable Tray Forward Cover
8131   // (0872/G/D/02)
8132   const Double_t kForwardCoverWide        =  130.00 *fgkmm;
8133   const Double_t kForwardCoverSideWide    =   10.00 *fgkmm;
8134   const Double_t kForwardCoverHoleLen     =  160.00 *fgkmm;
8135   const Double_t kForwardCoverHoleWide    =   90.00 *fgkmm;
8136   const Double_t kForwardCoverHoleR10     =   10.00 *fgkmm;
8137   const Double_t kForwardCoverTotalThick  =    5.00 *fgkmm;
8138   const Double_t kForwardCoverSideThick   =    3.00 *fgkmm;
8139   const Double_t kForwardCoverInternThick =    2.00 *fgkmm;
8140
8141   const Double_t kForwardCoverHoleZTrans  =   40.00 *fgkmm;
8142
8143
8144   // Local variables
8145   Double_t xprof[16], yprof[16];
8146   Double_t yloc, zloc;
8147
8148
8149   // The main shape: a Xtru
8150   TGeoXtru *forwCoverMain = new TGeoXtru(2);
8151   forwCoverMain->SetName("ITSsuppForwCoverMain");
8152
8153   xprof[0] = kForwardCoverWide/2;
8154   yprof[0] = kForwardCoverTotalThick;
8155   xprof[1] = xprof[0];
8156   yprof[1] = yprof[0] - kForwardCoverSideThick;
8157   xprof[2] = xprof[1] - kForwardCoverSideWide;
8158   yprof[2] = yprof[1];
8159   xprof[3] = xprof[2];
8160   yprof[3] = 0;
8161
8162   // We did the right side, now reflex on the left side
8163   for (Int_t jp = 0; jp < 4; jp++) {
8164     xprof[4+jp] = -xprof[3-jp];
8165     yprof[4+jp] =  yprof[3-jp];
8166   }
8167
8168   // And now the actual Xtru
8169   forwCoverMain->DefinePolygon(8, xprof, yprof);
8170   forwCoverMain->DefineSection(0, 0);
8171   forwCoverMain->DefineSection(1, coverLen);
8172
8173   // The hole: another Xtru (rounded corners approximated with segments)
8174   TGeoXtru *forwCoverHole = new TGeoXtru(2);
8175   forwCoverHole->SetName("ITSsuppForwCoverHole");
8176
8177   CreateTrayACoverHolesShape(kForwardCoverHoleWide, kForwardCoverHoleLen,
8178                              kForwardCoverHoleR10 , xprof, yprof);
8179
8180   // And now the actual Xtru
8181   forwCoverHole->DefinePolygon(16, xprof, yprof);
8182   forwCoverHole->DefineSection(0, 0);
8183   forwCoverHole->DefineSection(1, kForwardCoverTotalThick-kForwardCoverInternThick);
8184
8185   // Now the proper rototranslation matrices for the two holes
8186   yloc = kForwardCoverTotalThick-kForwardCoverInternThick-0.01;//Precision fix
8187   zloc = kForwardCoverHoleZTrans;
8188   TGeoCombiTrans *mf1 = new TGeoCombiTrans(0, yloc, zloc,
8189                                            new TGeoRotation("", 0, 90, 0) );
8190   mf1->SetName("mf1");
8191   mf1->RegisterYourself();
8192
8193   zloc = coverLen - kForwardCoverHoleZTrans - kForwardCoverHoleLen;
8194   TGeoCombiTrans *mf2 = new TGeoCombiTrans(0, yloc, zloc,
8195                                            new TGeoRotation("", 0, 90, 0) );
8196   mf2->SetName("mf2");
8197   mf2->RegisterYourself();
8198
8199   // Finally the actual cover shape
8200   TGeoCompositeShape *cover = new TGeoCompositeShape("ITSsuppForwardCoverMain",
8201     "ITSsuppForwCoverMain-ITSsuppForwCoverHole:mf1-ITSsuppForwCoverHole:mf2");
8202
8203   return cover;
8204 }
8205
8206 //______________________________________________________________________
8207 TGeoCompositeShape* AliITSv11GeometrySupport::CreateTrayAExternalCover(const Double_t coverLen){
8208 //
8209 // Creates the external cover of the SDD and SSD cable trays on Side A
8210 // (0872/G/D/04)
8211 //
8212 // Input:
8213 //             coverLen: the total length of the cover
8214 //
8215 // Output:
8216 //
8217 // Return:     a TGeoCompositeShape for the cover
8218 //
8219 // Created:      03 Jan 2010  Mario Sitta
8220 //
8221 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8222 // drawings and other (oral) information given by F.Tosello
8223 //
8224
8225   // Dimensions and positions of the A-Side Cable Tray External Cover
8226   // (0872/G/D/04)
8227   const Double_t kExternalCoverWide        =  130.00 *fgkmm;
8228   const Double_t kExternalCoverSideWide    =   10.00 *fgkmm;
8229   const Double_t kExternalCoverHoleLen1    =  262.00 *fgkmm;
8230   const Double_t kExternalCoverHoleLen2    =  280.00 *fgkmm;
8231   const Double_t kExternalCoverHoleLen3    =  205.00 *fgkmm;
8232   const Double_t kExternalCoverHoleLen4    =   55.00 *fgkmm;
8233   const Double_t kExternalCoverHoleWide    =   90.00 *fgkmm;
8234   const Double_t kExternalCoverHoleR10     =   10.00 *fgkmm;
8235   const Double_t kExternalCoverTotalThick  =    5.00 *fgkmm;
8236   const Double_t kExternalCoverSideThick   =    3.00 *fgkmm;
8237   const Double_t kExternalCoverInternThick =    2.00 *fgkmm;
8238
8239   const Double_t kExternalCoverHole1ZTrans =   28.00 *fgkmm;
8240   const Double_t kExternalCoverHolesZTrans =   20.00 *fgkmm;
8241
8242
8243   // Local variables
8244   Double_t xprof[16], yprof[16];
8245   Double_t yloc, zloc;
8246
8247
8248   // The main shape: a Xtru
8249   TGeoXtru *externCoverMain = new TGeoXtru(2);
8250   externCoverMain->SetName("ITSsuppExternCoverMain");
8251
8252   xprof[0] = kExternalCoverWide/2;
8253   yprof[0] = kExternalCoverTotalThick;
8254   xprof[1] = xprof[0];
8255   yprof[1] = yprof[0] - kExternalCoverSideThick;
8256   xprof[2] = xprof[1] - kExternalCoverSideWide;
8257   yprof[2] = yprof[1];
8258   xprof[3] = xprof[2];
8259   yprof[3] = 0;
8260
8261   // We did the right side, now reflex on the left side
8262   for (Int_t jp = 0; jp < 4; jp++) {
8263     xprof[4+jp] = -xprof[3-jp];
8264     yprof[4+jp] =  yprof[3-jp];
8265   }
8266
8267   // And now the actual Xtru
8268   externCoverMain->DefinePolygon(8, xprof, yprof);
8269   externCoverMain->DefineSection(0, 0);
8270   externCoverMain->DefineSection(1, coverLen);
8271
8272   // The first hole: a Xtru (rounded corners approximated with segments)
8273   Double_t holethick = kExternalCoverTotalThick-kExternalCoverInternThick;
8274
8275   TGeoXtru *extCoverHole1 = new TGeoXtru(2);
8276   extCoverHole1->SetName("ITSsuppExtCoverHole1");
8277
8278   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen1,
8279                              kExternalCoverHoleR10 , xprof, yprof);
8280
8281   extCoverHole1->DefinePolygon(16, xprof, yprof);
8282   extCoverHole1->DefineSection(0, 0);
8283   extCoverHole1->DefineSection(1, holethick);
8284
8285   // The second (and third) hole: another Xtru
8286   TGeoXtru *extCoverHole2 = new TGeoXtru(2);
8287   extCoverHole2->SetName("ITSsuppExtCoverHole2");
8288
8289   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen2,
8290                              kExternalCoverHoleR10 , xprof, yprof);
8291
8292   extCoverHole2->DefinePolygon(16, xprof, yprof);
8293   extCoverHole2->DefineSection(0, 0);
8294   extCoverHole2->DefineSection(1, holethick);
8295
8296   // The fourth hole: another Xtru
8297   TGeoXtru *extCoverHole3 = new TGeoXtru(2);
8298   extCoverHole3->SetName("ITSsuppExtCoverHole3");
8299
8300   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen3,
8301                              kExternalCoverHoleR10 , xprof, yprof);
8302
8303   extCoverHole3->DefinePolygon(16, xprof, yprof);
8304   extCoverHole3->DefineSection(0, 0);
8305   extCoverHole3->DefineSection(1, holethick);
8306
8307   // The fifth and last hole: another Xtru
8308   TGeoXtru *extCoverHole4 = new TGeoXtru(2);
8309   extCoverHole4->SetName("ITSsuppExtCoverHole4");
8310
8311   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen4,
8312                              kExternalCoverHoleR10 , xprof, yprof);
8313
8314   extCoverHole4->DefinePolygon(16, xprof, yprof);
8315   extCoverHole4->DefineSection(0, 0);
8316   extCoverHole4->DefineSection(1, holethick);
8317
8318   // Now the proper rototranslation matrices for the holes
8319   yloc = kExternalCoverTotalThick - kExternalCoverInternThick-0.01;
8320   zloc = kExternalCoverHole1ZTrans;
8321   TGeoCombiTrans *me1 = new TGeoCombiTrans(0, yloc, zloc,
8322                                            new TGeoRotation("", 0, 90, 0) );
8323   me1->SetName("me1");
8324   me1->RegisterYourself();
8325
8326   zloc += (kExternalCoverHoleLen1 + kExternalCoverHolesZTrans);
8327   TGeoCombiTrans *me2 = new TGeoCombiTrans(0, yloc, zloc,
8328                                            new TGeoRotation("", 0, 90, 0) );
8329   me2->SetName("me2");
8330   me2->RegisterYourself();
8331
8332   zloc += (kExternalCoverHoleLen2 + kExternalCoverHolesZTrans);
8333   TGeoCombiTrans *me3 = new TGeoCombiTrans(0, yloc, zloc,
8334                                            new TGeoRotation("", 0, 90, 0) );
8335   me3->SetName("me3");
8336   me3->RegisterYourself();
8337
8338   zloc += (kExternalCoverHoleLen2 + kExternalCoverHolesZTrans);
8339   TGeoCombiTrans *me4 = new TGeoCombiTrans(0, yloc, zloc,
8340                                            new TGeoRotation("", 0, 90, 0) );
8341   me4->SetName("me4");
8342   me4->RegisterYourself();
8343
8344   zloc += (kExternalCoverHoleLen3 + kExternalCoverHolesZTrans);
8345   TGeoCombiTrans *me5 = new TGeoCombiTrans(0, yloc, zloc,
8346                                            new TGeoRotation("", 0, 90, 0) );
8347   me5->SetName("me5");
8348   me5->RegisterYourself();
8349
8350   // Finally the actual cover shape
8351   TGeoCompositeShape *cover = new TGeoCompositeShape("ITSsuppExternCoverMain",
8352     "ITSsuppExternCoverMain-ITSsuppExtCoverHole1:me1-ITSsuppExtCoverHole2:me2-ITSsuppExtCoverHole2:me3-ITSsuppExtCoverHole3:me4-ITSsuppExtCoverHole4:me5");
8353
8354   return cover;
8355 }
8356
8357 //______________________________________________________________________
8358 void AliITSv11GeometrySupport::CreateTrayACoverHolesShape(const Double_t wide,
8359                                const Double_t length, const Double_t r10,
8360                                Double_t *x, Double_t *y){
8361 //
8362 // Creates the proper sequence of X and Y coordinates to determine
8363 // the base XTru polygon for the holes in the SDD and SSD tray covers
8364 // (here the rounded corners are approximated with segments)
8365 //
8366 // Input:
8367 //        wide   : the hole wide
8368 //        length : the hole length
8369 //        r10    : the radius of the rounded corners
8370 //
8371 // Output:
8372 //        x, y : coordinate vectors [16]
8373 //
8374 // Created:      03 Jan 2010  Mario Sitta
8375 //
8376 // Caller must guarantee that x and y have the correct dimensions
8377 // (but being this a private method it's easy to tell)
8378 //
8379
8380   x[0] = wide/2 - r10;
8381   y[0] = length;
8382   x[1] = x[0] + r10*SinD(30);
8383   y[1] = y[0] - r10*(1 - CosD(30));
8384   x[2] = x[0] + r10*SinD(60);
8385   y[2] = y[0] - r10*(1 - CosD(60));
8386   x[3] = x[0] + r10;
8387   y[3] = y[0] - r10;
8388   x[4] = x[3];
8389   y[4] = r10;
8390   x[5] = x[4] - r10*(1 - CosD(30));
8391   y[5] = y[4] - r10*SinD(30);
8392   x[6] = x[4] - r10*(1 - CosD(60));
8393   y[6] = y[4] - r10*SinD(60);
8394   x[7] = x[4] - r10;
8395   y[7] = 0;
8396
8397   // We did the right side, now reflex on the left side
8398   for (Int_t jp = 0; jp < 8; jp++) {
8399     x[8+jp] = -x[7-jp];
8400     y[8+jp] =  y[7-jp];
8401   }
8402
8403   return;
8404 }
8405
8406 //______________________________________________________________________
8407 TGeoXtru* AliITSv11GeometrySupport::CreateSDDSSDTraysSideA(
8408                                               const Double_t trayLen,
8409                                               const Double_t trayHi){
8410 //
8411 // Creates parts of the SDD and SSD Trays on Side A which are identical
8412 // (0872/G/D/03, part of 0872/G/D/07, 0872/G/C/11)
8413 //
8414 // Input:
8415 //         trayLen : the length of the tray part
8416 //         trayHi  : the height of the tray part
8417 //
8418 // Output:
8419 //
8420 // Return:     a TGeoXtru
8421 //
8422 // Created:      26 Feb 2010  Mario Sitta
8423 //
8424 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8425 // drawings and other (oral) information given by F.Tosello
8426 //
8427
8428   // Dimensions and positions of the A-Side Cable Trays
8429   // (parts of 0872/G/C)
8430   const Double_t kTrayWidth              =  130.00 *fgkmm;
8431   const Double_t kTrayWingWidth          =   10.00 *fgkmm;
8432   const Double_t kTrayHeightToBend       =   20.00 *fgkmm;
8433   const Double_t kTrayThick              =    2.00 *fgkmm;
8434
8435   const Double_t kTrayBendAngle          =   22.00 *TMath::DegToRad();
8436
8437   const Int_t    kTrayNpoints            =   16;
8438
8439   // Local variables
8440   Double_t xprof[kTrayNpoints], yprof[kTrayNpoints];
8441
8442
8443   // The tray shape: a Xtru
8444   TGeoXtru *trayPart = new TGeoXtru(2);
8445
8446   xprof[2] = kTrayWidth/2 - kTrayThick;
8447   yprof[2] = trayHi - kTrayThick;
8448   xprof[3] = kTrayWidth/2 - kTrayWingWidth;
8449   yprof[3] = yprof[2];
8450   xprof[4] = xprof[3];
8451   yprof[4] = trayHi;
8452   xprof[5] = kTrayWidth/2;
8453   yprof[5] = yprof[4];
8454   xprof[6] = xprof[5];
8455   yprof[6] = kTrayHeightToBend;
8456   xprof[7] = xprof[6] - yprof[6]*TMath::Tan(kTrayBendAngle);
8457   yprof[7] = 0;
8458
8459   InsidePoint( xprof[5], yprof[5], xprof[6], yprof[6], xprof[7], yprof[7],
8460               -kTrayThick, xprof[1], yprof[1]);
8461
8462   xprof[8] = -xprof[7];
8463   yprof[8] =  yprof[7];
8464
8465   InsidePoint( xprof[6], yprof[6], xprof[7], yprof[7], xprof[8], yprof[8],
8466               -kTrayThick, xprof[0], yprof[0]);
8467
8468   // We did the right side, now reflex on the left side
8469   for (Int_t jp = 0; jp < 8; jp++) {
8470     xprof[8+jp] = -xprof[7-jp];
8471     yprof[8+jp] =  yprof[7-jp];
8472   }
8473
8474   // And now the actual Xtru
8475   trayPart->DefinePolygon(kTrayNpoints, xprof, yprof);
8476   trayPart->DefineSection(0, 0);
8477   trayPart->DefineSection(1, trayLen);
8478
8479
8480   return trayPart;
8481 }
8482
8483 //______________________________________________________________________
8484 TGeoVolumeAssembly* AliITSv11GeometrySupport::CreateSDDSSDTraysSideC(
8485                                                        const char *trayName,
8486                                                        const TGeoManager *mgr){
8487
8488 //
8489 // Creates the SDD and SSD Trays on Side C which are supposedly identical
8490 //
8491 // Input:
8492 //         trayName : the assembly name
8493 //
8494 // Output:
8495 //
8496 // Return:     a TGeoVolumeAssembly
8497 //
8498 // Created:      16 Apr 2010  Mario Sitta
8499 //
8500 // Technical data are taken from AutoCAD drawings and other (oral)
8501 // information given by F.Tosello
8502 //
8503
8504   const Double_t kSideCHalfThick      =    0.100   *fgkcm;
8505   const Double_t kSideCFoldAngle      =    5.000   *TMath::DegToRad();
8506
8507   const Double_t kSideCLength1        =  172.800   *fgkcm;
8508   const Double_t kSideCLength2        =  189.300   *fgkcm;
8509   const Double_t kSideCHalfWide       =    6.350   *fgkcm;
8510   const Double_t kSideCHeight1        =   11.800   *fgkcm;
8511   const Double_t kSideCHeight2        =    4.300   *fgkcm;
8512   const Double_t kSideCSideLength1    =   10.800   *fgkcm;
8513   const Double_t kSideCSideLength2    =   63.800   *fgkcm;
8514   const Double_t kSideCSideHeight     =    8.800   *fgkcm;
8515   const Int_t    kNPointsLowerFace    =    6;
8516   const Int_t    kNPointsLateralFace  =    9;
8517
8518   const Double_t kSideCWingAHalfLen   =    5.000   *fgkcm;
8519   const Double_t kSideCWingBHalfLen   =   30.500   *fgkcm;
8520   const Double_t kSideCWingCHalfLen   =    2.000   *fgkcm;
8521   const Double_t kSideCWingDHalfLen   =   48.500   *fgkcm;
8522   const Double_t kSideCWingEHalfLen   =   83.000   *fgkcm;
8523   const Double_t kSideCWingsHalfWide  =    0.450   *fgkcm;
8524
8525   const Int_t    kNPointsCoverFace    =   12;
8526
8527   const Double_t kPlateHalfLen        =    6.000   *fgkcm;
8528   const Double_t kPlateThick          =    0.600   *fgkcm;
8529   const Double_t kPlateHeight         =    4.200   *fgkcm;
8530   const Int_t    kNPointsPlate        =    6;
8531
8532   const Double_t kBarCoolRmax         =    0.4     *fgkcm;
8533   const Int_t    kNumBarCool          =    2;
8534   const Double_t kXShiftBarCool[kNumBarCool] = { 8.7, 13.0 };
8535   const Double_t kYShiftBarCool[kNumBarCool] = { 8.5,  5.0 };
8536
8537
8538   // Local variables
8539   Double_t xprof[12], yprof[12];
8540   Double_t xloc, yloc, zloc, delta, alpharot;
8541
8542   // The single C-Side Cable tray as an assembly
8543   TGeoVolumeAssembly *cableTrayC = new TGeoVolumeAssembly(trayName);
8544
8545   // First create all needed shapes
8546
8547   // The Cable Tray lower face: a Xtru
8548   TGeoXtru *sideCLowerFace = new TGeoXtru(2);
8549
8550   xprof[0] = 0.;
8551   yprof[0] = 0.;
8552   xprof[1] = kSideCLength1;
8553   yprof[1] = 0.;
8554   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(kSideCFoldAngle);
8555   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(kSideCFoldAngle);
8556   xprof[3] = xprof[2] - 2*kSideCHalfThick*TMath::Sin(kSideCFoldAngle);
8557   yprof[3] = yprof[2] + 2*kSideCHalfThick*TMath::Cos(kSideCFoldAngle);
8558   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8559               2*kSideCHalfThick , xprof[4], yprof[4]);
8560   xprof[5] = 0.;
8561   yprof[5] = 2*kSideCHalfThick;
8562
8563   sideCLowerFace->DefinePolygon(kNPointsLowerFace, xprof, yprof);
8564   sideCLowerFace->DefineSection(0,-kSideCHalfWide);
8565   sideCLowerFace->DefineSection(1, kSideCHalfWide);
8566
8567   // The Cable Tray lateral face: a Xtru
8568   TGeoXtru *sideCLateralFace = new TGeoXtru(2);
8569
8570   xprof[0] = 0.;
8571   yprof[0] = 0.;
8572   xprof[1] = kSideCLength1;
8573   yprof[1] = 0.;
8574   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(kSideCFoldAngle);
8575   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(kSideCFoldAngle);
8576   xprof[3] = xprof[2] - kSideCHeight2*TMath::Sin(kSideCFoldAngle);
8577   yprof[3] = yprof[2] + kSideCHeight2*TMath::Cos(kSideCFoldAngle);
8578   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8579               kSideCHeight2, xprof[4], yprof[4]);
8580   xprof[5] = kSideCSideLength1 + kSideCSideLength2;
8581   yprof[5] = kSideCHeight2;
8582   xprof[6] = xprof[5];
8583   yprof[6] = kSideCSideHeight;
8584   xprof[7] = kSideCSideLength1;
8585   yprof[7] = kSideCHeight1;
8586   xprof[8] = 0;
8587   yprof[8] = yprof[7];
8588
8589   sideCLateralFace->DefinePolygon(kNPointsLateralFace, xprof, yprof);
8590   sideCLateralFace->DefineSection(0,-kSideCHalfThick);
8591   sideCLateralFace->DefineSection(1, kSideCHalfThick);
8592
8593   // The lateral wings: four BBox's
8594   TGeoBBox *sideCLateralWingA = new TGeoBBox(kSideCWingAHalfLen,
8595                                              kSideCHalfThick,
8596                                              kSideCWingsHalfWide);
8597
8598   TGeoBBox *sideCLateralWingB = new TGeoBBox(kSideCWingBHalfLen,
8599                                              kSideCHalfThick,
8600                                              kSideCWingsHalfWide);
8601
8602   TGeoBBox *sideCLateralWingC = new TGeoBBox(kSideCHalfThick,    // With these
8603                                              kSideCWingCHalfLen, // X,Y avoid
8604                                              kSideCWingsHalfWide);//rotations
8605
8606   TGeoBBox *sideCLateralWingD = new TGeoBBox(kSideCWingDHalfLen,
8607                                              kSideCHalfThick,
8608                                              kSideCWingsHalfWide);
8609
8610   TGeoBBox *sideCLateralWingE = new TGeoBBox(kSideCWingEHalfLen,
8611                                              kSideCHalfThick,
8612                                              kSideCWingsHalfWide);
8613
8614   // The connecting lower plate: a Xtru
8615   TGeoXtru *sideCLowerPlate =  new TGeoXtru(2);
8616
8617   xprof[0] = 0.;
8618   yprof[0] = 0.;
8619   xprof[1] = kPlateHalfLen;
8620   yprof[1] = 0.;
8621   xprof[2] = xprof[1] + kPlateHalfLen*TMath::Cos(kSideCFoldAngle);
8622   yprof[2] = kPlateHalfLen*TMath::Sin(kSideCFoldAngle);
8623   xprof[3] = xprof[2] - kPlateThick*TMath::Sin(kSideCFoldAngle);
8624   yprof[3] = yprof[2] + kPlateThick*TMath::Cos(kSideCFoldAngle);
8625   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8626               kPlateThick, xprof[4], yprof[4]);
8627   xprof[5] = 0.;
8628   yprof[5] = kPlateThick;
8629
8630   sideCLowerPlate->DefinePolygon(kNPointsPlate, xprof, yprof);
8631   Double_t zwide = kSideCHalfWide + 2*kSideCHalfThick;
8632   sideCLowerPlate->DefineSection(0,-zwide);
8633   sideCLowerPlate->DefineSection(1, zwide);
8634
8635   // The connecting side plate: a Xtru
8636   TGeoXtru *sideCLateralPlate = new TGeoXtru(2);
8637
8638   xprof[0] = 0.;
8639   yprof[0] = 0.;
8640   xprof[1] = kPlateHalfLen;
8641   yprof[1] = 0.;
8642   xprof[2] = xprof[1] + kPlateHalfLen*TMath::Cos(kSideCFoldAngle);
8643   yprof[2] = kPlateHalfLen*TMath::Sin(kSideCFoldAngle);
8644   xprof[3] = xprof[2] - kPlateHeight*TMath::Sin(kSideCFoldAngle);
8645   yprof[3] = yprof[2] + kPlateHeight*TMath::Cos(kSideCFoldAngle);
8646   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8647               kPlateHeight, xprof[4], yprof[4]); // Avoid small overlap
8648   xprof[5] = 0.;
8649   yprof[5] = kPlateHeight;
8650
8651   sideCLateralPlate->DefinePolygon(kNPointsPlate, xprof, yprof);
8652   sideCLateralPlate->DefineSection(0,-kPlateThick/2);
8653   sideCLateralPlate->DefineSection(1, kPlateThick/2);
8654
8655   // The bar fixing the cooling tubes: a Tube
8656   TGeoTube *coolBar = new TGeoTube(0., kBarCoolRmax, kSideCHalfWide);
8657
8658   // The Cable Tray cover: a (complex) Xtru
8659   TGeoXtru *sideCCoverFace = new TGeoXtru(2);
8660
8661   xprof[ 0] = sideCLateralFace->GetX(8);
8662   yprof[ 0] = sideCLateralFace->GetY(8);
8663   xprof[ 1] = sideCLateralFace->GetX(7);
8664   yprof[ 1] = sideCLateralFace->GetY(7);
8665   xprof[ 2] = sideCLateralFace->GetX(6);
8666   yprof[ 2] = sideCLateralFace->GetY(6);
8667   xprof[ 3] = sideCLateralFace->GetX(5);
8668   yprof[ 3] = sideCLateralFace->GetY(5);
8669   xprof[ 4] = sideCLateralFace->GetX(4);
8670   yprof[ 4] = sideCLateralFace->GetY(4);
8671
8672   xloc = (kSideCLength1 + (kSideCSideLength1+kSideCSideLength2))/2;
8673   delta  = kSideCLength1 - (xloc + kSideCWingDHalfLen);
8674   xprof[ 5] = xprof[4]
8675             + (delta + 2*kSideCWingEHalfLen)*TMath::Cos(kSideCFoldAngle);
8676   yprof[ 5] = yprof[4]
8677             + (delta + 2*kSideCWingEHalfLen)*TMath::Sin(kSideCFoldAngle);
8678
8679   xprof[ 6] = xprof[5] - 2*kSideCHalfThick*TMath::Sin(kSideCFoldAngle);
8680   yprof[ 6] = yprof[5] + 2*kSideCHalfThick*TMath::Cos(kSideCFoldAngle);
8681   InsidePoint(xprof[3], yprof[3], xprof[4], yprof[4], xprof[5], yprof[5],
8682               2*kSideCHalfThick, xprof[7], yprof[7]);
8683   InsidePoint(xprof[2], yprof[2], xprof[3], yprof[3], xprof[4], yprof[4],
8684               2*kSideCHalfThick, xprof[8], yprof[8]);
8685   xprof[ 9] = xprof[2] + 2*kSideCHalfThick;
8686   yprof[ 9] = yprof[2] + 2*kSideCHalfThick;
8687   xprof[10] = xprof[1];
8688   yprof[10] = yprof[1] + 2*kSideCHalfThick;
8689   xprof[11] = xprof[0];
8690   yprof[11] = yprof[0] + 2*kSideCHalfThick;
8691
8692   sideCCoverFace->DefinePolygon(kNPointsCoverFace, xprof, yprof);
8693   zloc = kSideCHalfWide + 2*kSideCHalfThick + 2*kSideCWingsHalfWide;
8694   sideCCoverFace->DefineSection(0,-zloc);
8695   sideCCoverFace->DefineSection(1, zloc);
8696
8697
8698   // We have all shapes: now create the real volumes
8699   TGeoMedium *medAl      = mgr->GetMedium("ITS_ALUMINUM$");
8700
8701   TGeoVolume *traySideCLowerFace  = new TGeoVolume("ITSsuppTraySideCLower",
8702                                                    sideCLowerFace, medAl);
8703
8704   traySideCLowerFace->SetVisibility(kTRUE);
8705   traySideCLowerFace->SetLineColor(6); // Purple
8706   traySideCLowerFace->SetLineWidth(1);
8707   traySideCLowerFace->SetFillColor(traySideCLowerFace->GetLineColor());
8708   traySideCLowerFace->SetFillStyle(4000); // 0% transparent
8709
8710   TGeoVolume *traySideCLateralFace  = new TGeoVolume("ITSsuppTraySideCLateral",
8711                                                      sideCLateralFace, medAl);
8712
8713   traySideCLateralFace->SetVisibility(kTRUE);
8714   traySideCLateralFace->SetLineColor(6); // Purple
8715   traySideCLateralFace->SetLineWidth(1);
8716   traySideCLateralFace->SetFillColor(traySideCLateralFace->GetLineColor());
8717   traySideCLateralFace->SetFillStyle(4000); // 0% transparent
8718
8719   TGeoVolume *traySideCLateralWingA =
8720     new TGeoVolume("ITSsuppTraySideCLateralWingA", sideCLateralWingA,  medAl);
8721
8722   traySideCLateralWingA->SetVisibility(kTRUE);
8723   traySideCLateralWingA->SetLineColor(6); // Purple
8724   traySideCLateralWingA->SetLineWidth(1);
8725   traySideCLateralWingA->SetFillColor(traySideCLateralWingA->GetLineColor());
8726   traySideCLateralWingA->SetFillStyle(4000); // 0% transparent
8727
8728   TGeoVolume *traySideCLateralWingB =
8729     new TGeoVolume("ITSsuppTraySideCLateralWingB", sideCLateralWingB,  medAl);
8730
8731   traySideCLateralWingB->SetVisibility(kTRUE);
8732   traySideCLateralWingB->SetLineColor(6); // Purple
8733   traySideCLateralWingB->SetLineWidth(1);
8734   traySideCLateralWingB->SetFillColor(traySideCLateralWingB->GetLineColor());
8735   traySideCLateralWingB->SetFillStyle(4000); // 0% transparent
8736
8737   TGeoVolume *traySideCLateralWingC =
8738     new TGeoVolume("ITSsuppTraySideCLateralWingC", sideCLateralWingC,  medAl);
8739
8740   traySideCLateralWingC->SetVisibility(kTRUE);
8741   traySideCLateralWingC->SetLineColor(6); // Purple
8742   traySideCLateralWingC->SetLineWidth(1);
8743   traySideCLateralWingC->SetFillColor(traySideCLateralWingC->GetLineColor());
8744   traySideCLateralWingC->SetFillStyle(4000); // 0% transparent
8745
8746   TGeoVolume *traySideCLateralWingD =
8747     new TGeoVolume("ITSsuppTraySideCLateralWingD", sideCLateralWingD,  medAl);
8748
8749   traySideCLateralWingD->SetVisibility(kTRUE);
8750   traySideCLateralWingD->SetLineColor(6); // Purple
8751   traySideCLateralWingD->SetLineWidth(1);
8752   traySideCLateralWingD->SetFillColor(traySideCLateralWingD->GetLineColor());
8753   traySideCLateralWingD->SetFillStyle(4000); // 0% transparent
8754
8755   TGeoVolume *traySideCLateralWingE =
8756     new TGeoVolume("ITSsuppTraySideCLateralWingE", sideCLateralWingE,  medAl);
8757
8758   traySideCLateralWingE->SetVisibility(kTRUE);
8759   traySideCLateralWingE->SetLineColor(6); // Purple
8760   traySideCLateralWingE->SetLineWidth(1);
8761   traySideCLateralWingE->SetFillColor(traySideCLateralWingE->GetLineColor());
8762   traySideCLateralWingE->SetFillStyle(4000); // 0% transparent
8763
8764   TGeoVolume *traySideCLowerPlate =
8765     new TGeoVolume("ITSsuppTraySideCLowerPlate", sideCLowerPlate,  medAl);
8766
8767   traySideCLowerPlate->SetVisibility(kTRUE);
8768   traySideCLowerPlate->SetLineColor(6); // Purple
8769   traySideCLowerPlate->SetLineWidth(1);
8770   traySideCLowerPlate->SetFillColor(traySideCLowerPlate->GetLineColor());
8771   traySideCLowerPlate->SetFillStyle(4000); // 0% transparent
8772
8773   TGeoVolume *traySideCLateralPlate =
8774     new TGeoVolume("ITSsuppTraySideCLateralPlate", sideCLateralPlate,  medAl);
8775
8776   traySideCLateralPlate->SetVisibility(kTRUE);
8777   traySideCLateralPlate->SetLineColor(6); // Purple
8778   traySideCLateralPlate->SetLineWidth(1);
8779   traySideCLateralPlate->SetFillColor(traySideCLateralPlate->GetLineColor());
8780   traySideCLateralPlate->SetFillStyle(4000); // 0% transparent
8781
8782   TGeoVolume *traySideCCoverFace =
8783     new TGeoVolume("ITSsuppTraySideCCoverFace", sideCCoverFace,  medAl);
8784
8785   traySideCCoverFace->SetVisibility(kTRUE);
8786   traySideCCoverFace->SetLineColor(6); // Purple
8787   traySideCCoverFace->SetLineWidth(1);
8788   traySideCCoverFace->SetFillColor(traySideCCoverFace->GetLineColor());
8789   traySideCCoverFace->SetFillStyle(4000); // 0% transparent
8790
8791   TGeoVolume *coolingTubeBar = new TGeoVolume("ITSsuppTraySideCCoolBar",
8792                                               coolBar, medAl);
8793
8794   coolingTubeBar->SetVisibility(kTRUE);
8795   coolingTubeBar->SetLineColor(6); // Purple
8796   coolingTubeBar->SetLineWidth(1);
8797   coolingTubeBar->SetFillColor(coolingTubeBar->GetLineColor());
8798   coolingTubeBar->SetFillStyle(4000); // 0% transparent
8799
8800
8801   // Now build up the tray
8802   cableTrayC->AddNode(traySideCLowerFace,1,0);
8803
8804   zloc = kSideCHalfWide + kSideCHalfThick;
8805   cableTrayC->AddNode(traySideCLateralFace,1,
8806                             new TGeoTranslation(0., 0., zloc) );
8807   cableTrayC->AddNode(traySideCLateralFace,2,
8808                             new TGeoTranslation(0., 0.,-zloc) );
8809
8810   xloc = kSideCWingAHalfLen;
8811   yloc = kSideCHeight1 - kSideCHalfThick;
8812   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8813   cableTrayC->AddNode(traySideCLateralWingA,1,
8814                             new TGeoTranslation(xloc, yloc, zloc) );
8815   cableTrayC->AddNode(traySideCLateralWingA,2,
8816                             new TGeoTranslation(xloc, yloc,-zloc) );
8817
8818   xloc = kSideCSideLength1 + kSideCSideLength2/2;
8819   yloc = Yfrom2Points(kSideCSideLength1,kSideCHeight1,
8820                       kSideCSideLength1+kSideCSideLength2,kSideCSideHeight,
8821                       xloc) - kSideCHalfThick -0.0012; // Avoid small overlap
8822   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8823   alpharot = (-(kSideCHeight1 - kSideCSideHeight)/kSideCSideLength2 )*
8824                 TMath::RadToDeg();
8825   cableTrayC->AddNode(traySideCLateralWingB,1,
8826                             new TGeoCombiTrans(xloc, yloc, zloc,
8827                                         new TGeoRotation("",alpharot,0,0) ) );
8828   cableTrayC->AddNode(traySideCLateralWingB,2,
8829                             new TGeoCombiTrans(xloc, yloc,-zloc,
8830                                         new TGeoRotation("",alpharot,0,0) ) );
8831
8832   xloc = kSideCSideLength1 + kSideCSideLength2 - kSideCHalfThick;
8833   yloc = kSideCSideHeight - kSideCWingCHalfLen;
8834   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8835   cableTrayC->AddNode(traySideCLateralWingC,1,
8836                             new TGeoTranslation(xloc, yloc, zloc) );
8837   cableTrayC->AddNode(traySideCLateralWingC,2,
8838                             new TGeoTranslation(xloc, yloc,-zloc) );
8839
8840   xloc = (kSideCLength1 + (kSideCSideLength1+kSideCSideLength2))/2;
8841   yloc = kSideCHeight2 - kSideCHalfThick;
8842   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8843   cableTrayC->AddNode(traySideCLateralWingD,1,
8844                             new TGeoTranslation(xloc, yloc, zloc) );
8845   cableTrayC->AddNode(traySideCLateralWingD,2,
8846                             new TGeoTranslation(xloc, yloc,-zloc) );
8847
8848   delta = kSideCLength1 - (xloc + kSideCWingDHalfLen);
8849   xloc = kSideCLength1 + delta + kSideCWingEHalfLen;
8850   yloc = (xloc - kSideCLength1)*TMath::Tan(kSideCFoldAngle) +
8851           kSideCHeight2*TMath::Cos(kSideCFoldAngle) - kSideCHalfThick;
8852   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8853   alpharot = kSideCFoldAngle*TMath::RadToDeg();
8854   cableTrayC->AddNode(traySideCLateralWingE,1,
8855                             new TGeoCombiTrans(xloc, yloc, zloc,
8856                                         new TGeoRotation("",alpharot,0,0) ) );
8857   cableTrayC->AddNode(traySideCLateralWingE,2,
8858                             new TGeoCombiTrans(xloc, yloc,-zloc,
8859                                         new TGeoRotation("",alpharot,0,0) ) );
8860
8861   xloc = kSideCLength1 - kPlateHalfLen;
8862   yloc = -kPlateThick -0.0025; // Avoid small overlap
8863   cableTrayC->AddNode(traySideCLowerPlate,1,
8864                             new TGeoTranslation(xloc, yloc, 0.) );
8865
8866   xloc = kSideCLength1 - kPlateHalfLen;
8867   yloc = -kPlateThick;
8868   zloc = kSideCHalfWide + 2*kSideCHalfThick + kPlateThick/2;
8869   cableTrayC->AddNode(traySideCLateralPlate,1,
8870                             new TGeoTranslation(xloc, yloc, zloc) );
8871   cableTrayC->AddNode(traySideCLateralPlate,2,
8872                             new TGeoTranslation(xloc, yloc,-zloc) );
8873
8874   for (Int_t jc = 0; jc <kNumBarCool; jc++) {
8875     xloc = kXShiftBarCool[jc];
8876     yloc = kYShiftBarCool[jc];
8877     cableTrayC->AddNode(coolingTubeBar,jc+1,
8878                               new TGeoTranslation(xloc, yloc, 0.) );
8879   }
8880
8881   cableTrayC->AddNode(traySideCCoverFace,1,0);
8882
8883
8884   // Finally return what we made up
8885
8886   return cableTrayC;
8887 }
8888
8889 //______________________________________________________________________
8890 void AliITSv11GeometrySupport::ITSTPCSupports(TGeoVolume *moth,
8891                                         const TGeoManager *mgr){
8892 //
8893 // Creates the elements suspending the ITS to the TPC and other fixed
8894 // elements used to hook the rails (0872/C and its daughters)
8895 //
8896 // Input:
8897 //         moth : the TGeoVolume owing the volume structure
8898 //         mgr  : the GeoManager (default gGeoManager)
8899 // Output:
8900 //
8901 // Return:
8902 //
8903 // Created:      28 Oct 2010  Mario Sitta
8904 // Updated:      18 Feb 2011  Mario Sitta
8905 //
8906 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8907 // drawings and other (oral) information given by F.Tosello
8908 //
8909
8910   // Dimensions and positions of the half ring C2/C3 (0872/C/04)
8911   const Double_t kRingCZPos           =   733.000*fgkmm;
8912   const Double_t kRingCZToTPC         =     5.500*fgkmm;
8913
8914   const Double_t kRingCThick          =    12.000*fgkmm;
8915   const Double_t kRingCRmin           =   565.000*fgkmm;
8916   const Double_t kRingCRmax           =   592.000*fgkmm;
8917   const Double_t kRingCHeight         =   560.000*fgkmm;
8918   const Double_t kRingCXToInsert      =   515.000*fgkmm;
8919   const Double_t kRingCYToInsert      =   113.000*fgkmm;
8920
8921   const Int_t kNumberOfRingPoints     =    23; // N.points to approximate arc
8922
8923   // Dimensions of the forward upper hook (0872/C/09)
8924   const Double_t kForwUpHookThick     =    20.000*fgkmm;
8925   const Double_t kForwUpHookRext      =   590.000*fgkmm;
8926   const Double_t kForwUpHookRint      =    20.000*fgkmm;
8927   const Double_t kForwUpHookHiTot     =    89.000*fgkmm;
8928   const Double_t kForwUpHookHiInt     =    59.000*fgkmm;
8929   const Double_t kForwUpHookWide      =    96.000*fgkmm;
8930   const Double_t kForwUpHookHalfBase  =    25.000*fgkmm;
8931   const Double_t kForwUpHookBaseCut   =    10.000*fgkmm;
8932   const Double_t kForwUpHookHoleWide  =    25.000*fgkmm;
8933   const Double_t kForwUpHookHoleHi    =    22.500*fgkmm;
8934   const Double_t kForwUpHookHoleBase  =     5.000*fgkmm;
8935   const Double_t kForwUpHookHoleR5    =     5.000*fgkmm;
8936   const Double_t kForwUpHookHoleY     =     8.000*fgkmm;
8937   const Double_t kForwUpHookHollowHi  =    35.000*fgkmm;
8938   const Double_t kForwUpHookHollowWide=     5.000*fgkmm;
8939
8940   const Int_t kNumberOfForwUpHookPts  =    11;
8941   const Int_t kNumbOfForwUpHookHolePts=     5;
8942
8943   // Dimensions of the forward lower hook (0872/C/08)
8944   const Double_t kForwLwHookThick     =    20.000*fgkmm;
8945   const Double_t kForwLwHookRext      =   590.000*fgkmm;
8946   const Double_t kForwLwHookRint      =    20.000*fgkmm;
8947   const Double_t kForwLwHookHiTot     =    88.500*fgkmm;
8948   const Double_t kForwLwHookWide      =    96.000*fgkmm;
8949   const Double_t kForwLwHookHalfBase  =    25.000*fgkmm;
8950   const Double_t kForwLwHookBaseCut   =    10.000*fgkmm;
8951   const Double_t kForwLwHookYToHollow =     3.500*fgkmm;
8952   const Double_t kForwLwHookHoleR     =     7.500*fgkmm;
8953   const Double_t kForwLwHookHoleIntHi =    35.000*fgkmm;
8954   const Double_t kForwLwHookHoleYPos  =    13.500*fgkmm;
8955   const Double_t kForwLwHookHollowHi  =    62.000*fgkmm;
8956   const Double_t kForwLwHookHollowWide=     5.000*fgkmm;
8957
8958   const Int_t kNumberOfForwLwHookPts  =    11;
8959   const Int_t kNumbOfForwLwHookHolePts=     7;
8960
8961   // Dimensions of the rear upper hook (0872/C/10)
8962   const Double_t kRearUpHookThick     =    15.000*fgkmm;
8963   const Double_t kRearUpHookRext      =   590.000*fgkmm;
8964   const Double_t kRearUpHookRint      =    20.000*fgkmm;
8965   const Double_t kRearUpHookHiTot     =    53.500*fgkmm;
8966   const Double_t kRearUpHookHiInt     =    23.500*fgkmm;
8967   const Double_t kRearUpHookWide      =    96.000*fgkmm;
8968   const Double_t kRearUpHookHalfBase  =    25.000*fgkmm;
8969   const Double_t kRearUpHookHoleWide  =    25.000*fgkmm;
8970   const Double_t kRearUpHookHoleHi    =    22.500*fgkmm;
8971   const Double_t kRearUpHookHoleBase  =     5.000*fgkmm;
8972   const Double_t kRearUpHookHoleR5    =     5.000*fgkmm;
8973   const Double_t kRearUpHookHoleY     =     8.000*fgkmm;
8974
8975   const Int_t kNumberOfRearUpHookPts  =    10;
8976   const Int_t kNumbOfRearUpHookHolePts=     5;
8977
8978   // Dimensions of the forward lower hook (0872/C/11)
8979   const Double_t kRearLwHookThick     =    20.000*fgkmm;
8980   const Double_t kRearLwHookRext      =   590.000*fgkmm;
8981   const Double_t kRearLwHookHiTot     =    30.000*fgkmm;
8982   const Double_t kRearLwHookWide      =    96.000*fgkmm;
8983
8984   const Int_t kNumberOfRearLwHookPts  =     3;
8985
8986   // Dimensions of the rear lower brackets (0872/C/16)
8987   const Double_t kRearLwBracketThick  =    15.000*fgkmm;
8988   const Double_t kRearLwBracketHi1    =    42.000*fgkmm;
8989   const Double_t kRearLwBracketHi2    =    12.000*fgkmm;
8990   const Double_t kRearLwBracketWide1  =    34.000*fgkmm;
8991   const Double_t kRearLwBracketWide2  =    10.000*fgkmm;
8992 //  const Double_t kRearLwBracketR5     =     5.000*fgkmm
8993
8994   // Dimensions of the forward webcam supports (0872/C/V/01-03-04)
8995   const Double_t kForwWebSStirrDep    =    20.000*fgkmm;
8996   const Double_t kForwWebSStirrLen1   =    15.000*fgkmm;
8997   const Double_t kForwWebSStirrLen2   =    55.000*fgkmm;
8998   const Double_t kForwWebSStirrLen3   =    10.000*fgkmm;
8999   const Double_t kForwWebSStirrWide1  =    45.000*fgkmm;
9000   const Double_t kForwWebSStirrWide2  =    38.000*fgkmm;
9001   const Double_t kForwWebSStirrWide3  =    23.000*fgkmm;
9002   const Double_t kForwWebTStirrThick  =     5.000*fgkmm;
9003   const Double_t kForwWebTStirrWide1  =    30.000*fgkmm;
9004   const Double_t kForwWebTStirrWide2  =    10.000*fgkmm;
9005   const Double_t kForwWebTStirrTotLen3=    58.500*fgkmm;
9006   const Double_t kForwWebTStirrTotLen4=    36.000*fgkmm;
9007   const Double_t kForwWebTStirrLen1   =    10.000*fgkmm;
9008
9009   // Dimensions of the forward and rear webcam clamps (0872/C/V/02)
9010   const Double_t kFRWebClampThick     =    10.000*fgkmm;
9011   const Double_t kFRWebClampExtWide   =    30.000*fgkmm;
9012   const Double_t kFRWebClampIntWide   =    18.000*fgkmm;
9013   const Double_t kFRWebClampExtHi     =    22.000*fgkmm;
9014   const Double_t kFRWebClampIntHi     =    17.000*fgkmm;
9015
9016   // Dimensions of the webcam itself
9017   const Double_t kWebcamLength        =    35.000*fgkmm;//ESTIMATED!!!
9018
9019   // Dimensions of the rear upper webcam supports (0872/C/V/05-06)
9020   const Double_t kRearUpWebStirrWide  =    76.000*fgkmm;
9021   const Double_t kRearUpWebStirrDep   =    15.000*fgkmm;
9022   const Double_t kRearUpWebStirrThick =     5.000*fgkmm;
9023   const Double_t kRearUpWebStirrH1    =    27.000*fgkmm;
9024   const Double_t kRearUpWebStirrH2    =    32.000*fgkmm;
9025   const Double_t kRearUpWebBarLen     =   130.000*fgkmm;
9026   const Double_t kRearUpWebBarHi      =    20.000*fgkmm;
9027   const Double_t kRearUpWebBarThick   =     5.000*fgkmm;
9028
9029   // Dimensions of the upper wheel slides (0872/C/Z/00-01-02)
9030   const Double_t kUpperSlideTotHeight =    93.500*fgkmm;
9031   const Double_t kUpperSlideBlockHi   =    62.500*fgkmm;
9032   const Double_t kUpperSlideWidth     =    36.000*fgkmm;
9033   const Double_t kUpperSlideTotDepth  =    51.000*fgkmm;
9034   const Double_t kUpperSlideIntDepth  =    36.000*fgkmm;
9035   const Double_t kUpperSlideStubHi    =    15.000*fgkmm;
9036   const Double_t kUpperSlideStubDep   =     8.000*fgkmm;
9037   const Double_t kUpperSlideWheelHi   =    18.500*fgkmm;
9038   const Double_t kUpperSlideHoleRout  =    11.000*fgkmm;
9039   const Double_t kUpperSlideHoleRint1 =     9.000*fgkmm;
9040   const Double_t kUpperSlideHoleRint2 =    11.500*fgkmm;
9041   const Double_t kUpperSlideHoleH1    =     7.000*fgkmm;
9042   const Double_t kUpperSlideHoleH2    =    46.000*fgkmm;
9043   const Double_t kUpperSlideHoleH3    =     1.100*fgkmm;
9044   const Double_t kUpperSlideHoleXPos  =    20.000*fgkmm;
9045   const Double_t kUpperSlidePinRmin   =     4.000*fgkmm;
9046   const Double_t kUpperSlidePinRmax   =     6.000*fgkmm;
9047   const Double_t kUpperSlidePinH1     =     7.000*fgkmm;
9048   const Double_t kUpperSlidePinH2     =    46.000*fgkmm;
9049   const Double_t kUpperSlidePinH3     =    25.500*fgkmm;
9050
9051   // Dimensions of the lower wheel slides (0872/C/W/00-01-02-03)
9052   const Double_t kLowerSlideTotHeight =    80.000*fgkmm;
9053   const Double_t kLowerSlideBlockHi   =    28.000*fgkmm;
9054   const Double_t kLowerSlideWidth     =    36.000*fgkmm;
9055   const Double_t kLowerSlideTotDepth  =    60.000*fgkmm;
9056   const Double_t kLowerSlideHoleRout  =     9.500*fgkmm;
9057   const Double_t kLowerSlideHoleRint  =     4.700*fgkmm;
9058   const Double_t kLowerSlideHoleH1    =    12.000*fgkmm;
9059   const Double_t kLowerSlideNoseBase  =    40.000*fgkmm;
9060   const Double_t kLowerSlideNoseBasHi =     6.000*fgkmm;//Computed
9061   const Double_t kLowerSlideNoseUpWid =    25.000*fgkmm;
9062   const Double_t kLowerSlideNoseDepth =    10.000*fgkmm;
9063   const Double_t kLowerSlidePinRmin   =     3.000*fgkmm;
9064   const Double_t kLowerSlidePinRmax   =     4.000*fgkmm;
9065   const Double_t kLowerSlidePinH1     =    12.000*fgkmm;
9066   const Double_t kLowerSlidePinH2     =    10.000*fgkmm;
9067
9068   // Dimensions and positions of the C1/C2 rail stirrups (0872/C/01-02)
9069   const Double_t kStirrCXPos          =   759.000*fgkmm;
9070   const Double_t kStirrCZPos          =  1867.000*fgkmm;
9071
9072   const Double_t kStirrC12Thick       =    15.000*fgkmm;
9073   const Double_t kStirrC12TotLen      =   314.000*fgkmm;
9074   const Double_t kStirrC12BodyHalfHi  =    95.000*fgkmm;
9075   const Double_t kStirrC12BodyLen     =   153.000*fgkmm;
9076   const Double_t kStirrC12HeadLen     =    50.000*fgkmm;
9077   const Double_t kStirrC12HeadHalfHi  =   165.000*fgkmm;
9078   const Double_t kStirrC12HeadIntHi   =   114.000*fgkmm;
9079   const Double_t kStirrC12HeadIntLen  =    45.000*fgkmm;
9080   const Double_t kStirrC12TailLen     =    14.000*fgkmm;
9081   const Double_t kStirrC12R100        =   100.000*fgkmm;
9082   const Double_t kStirrC12R50         =    50.000*fgkmm;
9083   const Double_t kStirrC12R10         =    10.000*fgkmm;
9084   const Double_t kStirrC12HeadAng     =    40.000; // Degree
9085
9086   const Int_t kNumberOfStirrCPoints   =    23;
9087
9088   // Dimensions and positions of the C5 rail stirrups (0872/C/05)
9089   const Double_t kStirrC5BodyLen      =   155.000*fgkmm;
9090
9091
9092   // Local variables
9093   Double_t xprof[2*kNumberOfStirrCPoints+1],yprof[2*kNumberOfStirrCPoints+1];
9094   Double_t xpos, ypos, zpos, alpha;
9095   Double_t xdummy, ydummy;
9096   
9097
9098   // First create all needed shapes
9099
9100   // The Supporting Ring (0872/C/04): a really complex Xtru
9101   // to approximate the arc with a polyline
9102   TGeoXtru *ringC2C3 = new TGeoXtru(2);
9103
9104   for (Int_t j=0; j<11; j++) { // The external arc
9105     xprof[j] = kRingCRmax*SinD(90*j/10);
9106     yprof[j] = kRingCRmax*CosD(90*j/10);
9107   }
9108
9109   xprof[11] = kRingCRmin;
9110   yprof[11] = yprof[10];
9111
9112   alpha = TMath::ASin(kRingCYToInsert/kRingCRmin); // Now the insert
9113   xprof[12] = kRingCRmin*TMath::Cos(alpha/2);
9114   yprof[12] = kRingCRmin*TMath::Sin(alpha/2);
9115   xprof[13] = kRingCRmin*TMath::Cos(alpha);
9116   yprof[13] = kRingCRmin*TMath::Sin(alpha);
9117
9118   xprof[14] = kRingCXToInsert;
9119   yprof[14] = yprof[13];
9120
9121   alpha = TMath::ACos(kRingCXToInsert/kRingCRmin); // The insert ending angle
9122   xprof[15] = kRingCRmin*TMath::Cos(alpha);
9123   yprof[15] = kRingCRmin*TMath::Sin(alpha);
9124
9125   for (Int_t j=7; j>1; j--) { // The internal arc
9126     xprof[23-j] = kRingCRmin*SinD(90*j/10);
9127     yprof[23-j] = kRingCRmin*CosD(90*j/10);
9128   }
9129
9130   alpha = TMath::ASin(kRingCHeight/kRingCRmin);    // The angle till the notch
9131   xprof[22] = kRingCRmin*TMath::Cos(alpha);
9132   yprof[22] = kRingCRmin*TMath::Sin(alpha);
9133
9134   xprof[23] = xprof[0];
9135   yprof[23] = yprof[22];
9136
9137   // We did the right side, now reflex on the left side
9138   for (Int_t jp = 0; jp < 22; jp++) {
9139     xprof[24+jp] = -xprof[23-1-jp];
9140     yprof[24+jp] =  yprof[23-1-jp];
9141   }
9142
9143   // wow! now the actual Xtru
9144   ringC2C3->DefinePolygon(2*kNumberOfRingPoints, xprof, yprof);
9145   ringC2C3->DefineSection(0, 0);
9146   ringC2C3->DefineSection(1, kRingCThick);
9147
9148   // The Forward Upper Hook (0872/C/09): a Composite Shape made of
9149   // a really complex Xtru to approximate the arc with a polyline,
9150   // another Xtru for the hole, and a BBox for the hollow
9151   // The main body
9152   TGeoXtru *forwUpHookMainBody = new TGeoXtru(2);
9153   forwUpHookMainBody->SetName("ITSforwUpHookMainBody");
9154
9155   xprof[ 0] = kForwUpHookHalfBase - kForwUpHookBaseCut;
9156   yprof[ 0] = kForwUpHookRext - kForwUpHookHiTot;
9157   xprof[ 1] = kForwUpHookHalfBase;
9158   yprof[ 1] = yprof[0] + kForwUpHookBaseCut;
9159   xprof[ 2] = xprof[1];
9160   yprof[ 2] = yprof[0] + (kForwUpHookHiInt - kForwUpHookRint);
9161   for (Int_t j=1; j<6; j++) {
9162     xprof[2+j] = xprof[2] + kForwUpHookRint*(1 - CosD(90*j/5));
9163     yprof[2+j] = yprof[2] + kForwUpHookRint*SinD(90*j/5);
9164   }
9165   xprof[ 8] = kForwUpHookWide/2;
9166   yprof[ 8] = yprof[7];
9167   xprof[ 9] = xprof[8];
9168   alpha = TMath::ASin(0.5*kForwUpHookWide/kForwUpHookRext);
9169   yprof[ 9] = kForwUpHookRext*TMath::Cos(alpha);
9170   xprof[10] = kForwUpHookRext*TMath::Sin(alpha/2);
9171   yprof[10] = kForwUpHookRext*TMath::Cos(alpha/2);
9172   xprof[11] = 0;
9173   yprof[11] = kForwUpHookRext;
9174
9175   // We did the right side, now reflex on the left side
9176   for (Int_t jp = 0; jp < kNumberOfForwUpHookPts; jp++) {
9177     xprof[12+jp] = -xprof[10-jp];
9178     yprof[12+jp] =  yprof[10-jp];
9179   }
9180
9181   // Now the actual Xtru
9182   forwUpHookMainBody->DefinePolygon(2*kNumberOfForwUpHookPts+1, xprof, yprof);
9183   forwUpHookMainBody->DefineSection(0, 0);
9184   forwUpHookMainBody->DefineSection(1, kForwUpHookThick);
9185
9186   // The hole
9187   TGeoXtru *forwUpHookHole = new TGeoXtru(2);
9188   forwUpHookHole->SetName("ITSforwUpHookHole");
9189
9190   xprof[0] = kForwUpHookHoleBase/2;
9191   yprof[0] = forwUpHookMainBody->GetY(0) + kForwUpHookHoleY;
9192   xprof[1] = kForwUpHookHoleWide/2;
9193   yprof[1] = yprof[0] + (xprof[1] - xprof[0]); // Go at 45deg
9194   xprof[2] = xprof[1];
9195   yprof[2] = yprof[0] + kForwUpHookHoleHi - kForwUpHookHoleR5;
9196   xprof[3] = xprof[2] - kForwUpHookHoleR5*(1 - CosD(45));
9197   yprof[3] = yprof[2] + kForwUpHookHoleR5*SinD(45);
9198   xprof[4] = xprof[2] - kForwUpHookHoleR5;
9199   yprof[4] = yprof[0] + kForwUpHookHoleHi;
9200
9201   // We did the right side, now reflex on the left side
9202   for (Int_t jp = 0; jp < kNumbOfForwUpHookHolePts; jp++) {
9203     xprof[5+jp] = -xprof[4-jp];
9204     yprof[5+jp] =  yprof[4-jp];
9205   }
9206
9207   // Now the actual Xtru
9208   forwUpHookHole->DefinePolygon(2*kNumbOfForwUpHookHolePts, xprof, yprof);
9209   forwUpHookHole->DefineSection(0, -0.1);
9210   forwUpHookHole->DefineSection(1, kForwUpHookThick+0.1);
9211
9212   // The hollow
9213   TGeoBBox *forwUpHookHollow = new TGeoBBox(2.1 *kForwUpHookHalfBase,
9214                                             0.55*kForwUpHookHollowHi,
9215                                             0.55*kForwUpHookHollowWide);
9216   forwUpHookHollow->SetName("ITSforwUpHookHollow");
9217
9218   TGeoTranslation *forwUpHookHollPos = new TGeoTranslation(0.,
9219                       forwUpHookMainBody->GetY(0) + 0.5*kForwUpHookHollowHi,
9220                       forwUpHookMainBody->GetZ(1) - 0.5*kForwUpHookHollowWide);
9221   forwUpHookHollPos->SetName("ITSforwUpHookHollPos");
9222   forwUpHookHollPos->RegisterYourself();
9223
9224   // Finally the actual shape: a CompositeShape
9225   TGeoCompositeShape *forwUpHookShape = new TGeoCompositeShape("ITSforwUpHookMainBody-ITSforwUpHookHole-ITSforwUpHookHollow:ITSforwUpHookHollPos");
9226
9227   // The Forward Lower Hook (0872/C/08): a Composite Shape made of
9228   // a really complex Xtru to approximate the arc with a polyline,
9229   // another Xtru for the hole, and a BBox for the hollow
9230   // The main body
9231   TGeoXtru *forwLwHookMainBody = new TGeoXtru(2);
9232   forwLwHookMainBody->SetName("ITSforwLwHookMainBody");
9233
9234   xprof[ 0] = kForwLwHookHalfBase - kForwLwHookBaseCut;
9235   yprof[ 0] = kForwLwHookRext - kForwLwHookHiTot;
9236   xprof[ 1] = kForwLwHookHalfBase;
9237   yprof[ 1] = yprof[0] + kForwLwHookBaseCut;
9238   xprof[ 2] = xprof[1];
9239   yprof[ 2] = yprof[0] + (kForwLwHookHollowHi - kForwLwHookYToHollow
9240                           - kForwLwHookRint);
9241   for (Int_t j=1; j<6; j++) {
9242     xprof[2+j] = xprof[2] + kForwLwHookRint*(1 - CosD(90*j/5));
9243     yprof[2+j] = yprof[2] + kForwLwHookRint*SinD(90*j/5);
9244   }
9245   xprof[ 8] = kForwLwHookWide/2;
9246   yprof[ 8] = yprof[7];
9247   xprof[ 9] = xprof[8];
9248   alpha = TMath::ASin(0.5*kForwLwHookWide/kForwLwHookRext);
9249   yprof[ 9] = kForwLwHookRext*TMath::Cos(alpha);
9250   xprof[10] = kForwLwHookRext*TMath::Sin(alpha/2);
9251   yprof[10] = kForwLwHookRext*TMath::Cos(alpha/2);
9252   xprof[11] = 0;
9253   yprof[11] = kForwLwHookRext;
9254
9255   // We did the right side, now reflex on the left side
9256   for (Int_t jp = 0; jp < kNumberOfForwLwHookPts; jp++) {
9257     xprof[12+jp] = -xprof[10-jp];
9258     yprof[12+jp] =  yprof[10-jp];
9259   }
9260
9261   // Now the actual Xtru
9262   forwLwHookMainBody->DefinePolygon(2*kNumberOfForwLwHookPts+1, xprof, yprof);
9263   forwLwHookMainBody->DefineSection(0, 0);
9264   forwLwHookMainBody->DefineSection(1, kForwLwHookThick);
9265
9266   // The hole
9267   TGeoXtru *forwLwHookHole = new TGeoXtru(2);
9268   forwLwHookHole->SetName("ITSforwLwHookHole");
9269
9270   xprof[0] = 0;
9271   yprof[0] = forwLwHookMainBody->GetY(0) + kForwLwHookHoleYPos
9272            - kForwLwHookHoleR;
9273   for (Int_t j=1; j<3; j++) {
9274     xprof[0+j] = xprof[0] + kForwLwHookHoleR*SinD(90*j/3);
9275     yprof[0+j] = yprof[0] + kForwLwHookHoleR*(1 - CosD(90*j/3));
9276   }
9277   xprof[3] = xprof[0] + kForwLwHookHoleR;
9278   yprof[3] = yprof[0] + kForwLwHookHoleR;
9279   xprof[4] = xprof[3];
9280   yprof[4] = yprof[3] + kForwLwHookHoleIntHi;
9281   for (Int_t j=1; j<3; j++) {
9282     xprof[4+j] = xprof[4] - kForwLwHookHoleR*(1 - CosD(90*j/3));
9283     yprof[4+j] = yprof[4] + kForwLwHookHoleR*SinD(90*j/3);
9284   }
9285   xprof[7] = xprof[0];
9286   yprof[7] = yprof[4] + kForwLwHookHoleR;
9287
9288   // We did the right side, now reflex on the left side
9289   for (Int_t jp = 0; jp < kNumbOfForwLwHookHolePts-1; jp++) {
9290     xprof[8+jp] = -xprof[6-jp];
9291     yprof[8+jp] =  yprof[6-jp];
9292   }
9293
9294   // Now the actual Xtru
9295   forwLwHookHole->DefinePolygon(2*kNumbOfForwLwHookHolePts, xprof, yprof);
9296   forwLwHookHole->DefineSection(0, -0.1);
9297   forwLwHookHole->DefineSection(1, kForwLwHookThick+0.1);
9298
9299   // The hollow
9300   TGeoBBox *forwLwHookHollow = new TGeoBBox(2.1 *kForwLwHookHalfBase,
9301                                             0.55*kForwLwHookHollowHi,
9302                                             0.55*kForwLwHookHollowWide);
9303   forwLwHookHollow->SetName("ITSforwLwHookHollow");
9304
9305   TGeoTranslation *forwLwHookHollPos = new TGeoTranslation(0.,
9306                       forwLwHookMainBody->GetY(0) + 0.5*kForwLwHookHollowHi,
9307                       forwLwHookMainBody->GetZ(1) - 0.5*kForwLwHookHollowWide);
9308   forwLwHookHollPos->SetName("ITSforwLwHookHollPos");
9309   forwLwHookHollPos->RegisterYourself();
9310
9311   // Finally the actual shape: a CompositeShape
9312   TGeoCompositeShape *forwLwHookShape = new TGeoCompositeShape("ITSforwLwHookMainBody-ITSforwLwHookHole-ITSforwLwHookHollow:ITSforwLwHookHollPos");
9313
9314   // The Rear Upper Hook (0872/C/10): a Composite Shape made of
9315   // a really complex Xtru to approximate the arc with a polyline,
9316   // and another Xtru for the hole
9317   // The main body
9318   TGeoXtru *rearUpHookMainBody = new TGeoXtru(2);
9319   rearUpHookMainBody->SetName("ITSrearUpHookMainBody");
9320
9321   xprof[0] = kRearUpHookHalfBase;
9322   yprof[0] = kRearUpHookRext - kRearUpHookHiTot;
9323   xprof[1] = xprof[0];
9324   yprof[1] = yprof[0] + (kRearUpHookHiInt - kRearUpHookRint); 
9325   for (Int_t j=1; j<6; j++) {
9326     xprof[1+j] = xprof[1] + kRearUpHookRint*(1 - CosD(90*j/5));
9327     yprof[1+j] = yprof[1] + kRearUpHookRint*SinD(90*j/5);
9328   }
9329   xprof[ 7] = kRearUpHookWide/2;
9330   yprof[ 7] = yprof[5];
9331   xprof[ 8] = xprof[7];
9332   alpha = TMath::ASin(0.5*kRearUpHookWide/kRearUpHookRext);
9333   yprof[ 8] = kRearUpHookRext*TMath::Cos(alpha);
9334   xprof[ 9] = kRearUpHookRext*TMath::Sin(alpha/2);
9335   yprof[ 9] = kRearUpHookRext*TMath::Cos(alpha/2);
9336   xprof[10] = 0;
9337   yprof[10] = kRearUpHookRext;
9338
9339   // We did the right side, now reflex on the left side
9340   for (Int_t jp = 0; jp < kNumberOfRearUpHookPts; jp++) {
9341     xprof[11+jp] = -xprof[9-jp];
9342     yprof[11+jp] =  yprof[9-jp];
9343   }
9344
9345   // Now the actual Xtru
9346   rearUpHookMainBody->DefinePolygon(2*kNumberOfRearUpHookPts+1, xprof, yprof);
9347   rearUpHookMainBody->DefineSection(0, 0);
9348   rearUpHookMainBody->DefineSection(1, kRearUpHookThick);
9349
9350   // The hole
9351   TGeoXtru *rearUpHookHole = new TGeoXtru(2);
9352   rearUpHookHole->SetName("ITSrearUpHookHole");
9353
9354   xprof[0] = kRearUpHookHoleBase/2;
9355   yprof[0] = rearUpHookMainBody->GetY(0) + kRearUpHookHoleY;
9356   xprof[1] = kRearUpHookHoleWide/2;
9357   yprof[1] = yprof[0] + (xprof[1] - xprof[0]); // Go at 45deg
9358   xprof[2] = xprof[1];
9359   yprof[2] = yprof[0] + kRearUpHookHoleHi - kRearUpHookHoleR5;
9360   xprof[3] = xprof[2] - kRearUpHookHoleR5*(1 - CosD(45));
9361   yprof[3] = yprof[2] + kRearUpHookHoleR5*SinD(45);
9362   xprof[4] = xprof[2] - kRearUpHookHoleR5;
9363   yprof[4] = yprof[0] + kRearUpHookHoleHi;
9364
9365   // We did the right side, now reflex on the left side
9366   for (Int_t jp = 0; jp < kNumbOfRearUpHookHolePts; jp++) {
9367     xprof[5+jp] = -xprof[4-jp];
9368     yprof[5+jp] =  yprof[4-jp];
9369   }
9370
9371   // Now the actual Xtru
9372   rearUpHookHole->DefinePolygon(2*kNumbOfRearUpHookHolePts, xprof, yprof);
9373   rearUpHookHole->DefineSection(0, -0.1);
9374   rearUpHookHole->DefineSection(1, kRearUpHookThick+0.1);
9375
9376   // Finally the actual shape: a CompositeShape
9377   TGeoCompositeShape *rearUpHookShape = new TGeoCompositeShape("ITSrearUpHookMainBody-ITSrearUpHookHole");
9378
9379   // The Rear Lower Hook (0872/C/11): a Xtru
9380   TGeoXtru *rearLwHookShape = new TGeoXtru(2);
9381   rearLwHookShape->SetName("ITSrearLwHookShape");
9382
9383   xprof[0] = kRearLwHookWide/2;
9384   yprof[0] = kRearLwHookRext - kRearLwHookHiTot;
9385   xprof[1] = xprof[0];
9386   alpha = TMath::ASin(0.5*kRearLwHookWide/kRearLwHookRext);
9387   yprof[1] = kRearLwHookRext*TMath::Cos(alpha);
9388   xprof[2] = kRearLwHookRext*TMath::Sin(alpha/2);
9389   yprof[2] = kRearLwHookRext*TMath::Cos(alpha/2);
9390   xprof[3] = 0;
9391   yprof[3] = kRearLwHookRext;
9392
9393   // We did the right side, now reflex on the left side
9394   for (Int_t jp = 0; jp < kNumberOfRearLwHookPts; jp++) {
9395     xprof[4+jp] = -xprof[2-jp];
9396     yprof[4+jp] =  yprof[2-jp];
9397   }
9398
9399   // Now the actual Xtru
9400   rearLwHookShape->DefinePolygon(2*kNumberOfRearLwHookPts+1, xprof, yprof);
9401   rearLwHookShape->DefineSection(0, 0);
9402   rearLwHookShape->DefineSection(1, kRearLwHookThick);
9403
9404   // The Rear Lower Bracket (0872/C/16): a Xtru
9405   TGeoXtru *rearLwBrackShape = new TGeoXtru(2);
9406   rearLwBrackShape->SetName("ITSrearLwBrackShape");
9407
9408   xprof[0] = 0;
9409   yprof[0] = 0;
9410   xprof[1] = xprof[0] + kRearLwBracketWide1 - kRearLwBracketWide2;
9411   yprof[1] = yprof[0];
9412   xprof[2] = xprof[1];
9413   yprof[2] = yprof[0] + kRearLwBracketHi2;
9414   xprof[3] = xprof[2] - kRearLwBracketWide1;
9415   yprof[3] = yprof[2];
9416   xprof[4] = xprof[3];
9417   yprof[4] = yprof[3] - kRearLwBracketHi1;
9418   xprof[5] = xprof[0];
9419   yprof[5] = yprof[4];
9420
9421   rearLwBrackShape->DefinePolygon(6, xprof, yprof);
9422   rearLwBrackShape->DefineSection(0,-kRearLwBracketThick/2);
9423   rearLwBrackShape->DefineSection(1, kRearLwBracketThick/2);
9424
9425   // The Forward S-shaped Stirrup for the webcam (0872/C/V/01): a Xtru
9426   TGeoXtru *forwWebSStirrSh = new TGeoXtru(2);
9427
9428   xprof[0] = 0;
9429   yprof[0] = 0;
9430   xprof[1] = xprof[0] + kForwWebSStirrLen1;
9431   yprof[1] = yprof[0];
9432   xprof[2] = xprof[1];
9433   yprof[2] = yprof[1] + kForwWebSStirrWide1;
9434   xprof[3] = xprof[0] - kForwWebSStirrLen2 + kForwWebSStirrLen3;
9435   yprof[3] = yprof[2];
9436   xprof[4] = xprof[3];
9437   yprof[4] = yprof[3] + kForwWebSStirrWide3;
9438   xprof[5] = xprof[4] - kForwWebSStirrLen3;
9439   yprof[5] = yprof[4];
9440   xprof[6] = xprof[5];
9441   yprof[6] = yprof[0] + kForwWebSStirrWide2;
9442   xprof[7] = xprof[0];
9443   yprof[7] = yprof[6];
9444
9445   forwWebSStirrSh->DefinePolygon(8, xprof, yprof);
9446   forwWebSStirrSh->DefineSection(0,-kForwWebSStirrDep/2);
9447   forwWebSStirrSh->DefineSection(1, kForwWebSStirrDep/2);
9448
9449   // The Forward T-shaped Stirrups for the webcam (0872/C/V/03-04): two Xtru
9450   TGeoXtru *forwWebTStirr3Sh = new TGeoXtru(2);
9451
9452   xprof[0] = -kForwWebTStirrWide2/2;
9453   yprof[0] = 0;
9454   xprof[1] = -kForwWebTStirrWide1/2;
9455   yprof[1] = yprof[0];
9456   xprof[2] = xprof[1];
9457   yprof[2] = yprof[1] - kForwWebTStirrLen1;
9458   xprof[3] =-xprof[2];
9459   yprof[3] = yprof[2];
9460   xprof[4] = xprof[3];
9461   yprof[4] = yprof[1];
9462   xprof[5] =-xprof[0];
9463   yprof[5] = yprof[4];
9464   xprof[6] = xprof[5];
9465   yprof[6] = kForwWebTStirrTotLen3 - kForwWebTStirrLen1;
9466   xprof[7] = xprof[0];
9467   yprof[7] = yprof[6];
9468
9469   forwWebTStirr3Sh->DefinePolygon(8, xprof, yprof);
9470   forwWebTStirr3Sh->DefineSection(0, 0);
9471   forwWebTStirr3Sh->DefineSection(1, kForwWebTStirrThick);
9472
9473   TGeoXtru *forwWebTStirr4Sh = new TGeoXtru(2);
9474
9475   yprof[6] = kForwWebTStirrTotLen4 - kForwWebTStirrLen1;
9476   yprof[7] = yprof[6];
9477
9478   forwWebTStirr4Sh->DefinePolygon(8, xprof, yprof);
9479   forwWebTStirr4Sh->DefineSection(0, 0);
9480   forwWebTStirr4Sh->DefineSection(1, kForwWebTStirrThick);
9481
9482   // The Forward and Rear clamp for the webcam (0872/C/V/02): a Xtru
9483   TGeoXtru *frWebClampSh = new TGeoXtru(2);
9484
9485   xprof[0] = kFRWebClampIntWide/2;
9486   yprof[0] = kFRWebClampIntHi;
9487   xprof[1] = xprof[0];
9488   yprof[1] = 0;
9489   xprof[2] = kFRWebClampExtWide/2;
9490   yprof[2] = yprof[1];
9491   xprof[3] = xprof[2];
9492   yprof[3] = kFRWebClampExtHi;
9493   for (Int_t jp = 0; jp < 4; jp++) {
9494     xprof[4+jp] = -xprof[3-jp];
9495     yprof[4+jp] =  yprof[3-jp];
9496   }
9497
9498   frWebClampSh->DefinePolygon(8, xprof, yprof);
9499   frWebClampSh->DefineSection(0,-kFRWebClampThick/2);
9500   frWebClampSh->DefineSection(1, kFRWebClampThick/2);
9501
9502   // The Rear Upper Stirrup for the webcam (0872/C/V/05): a Xtru
9503   TGeoXtru *upWebStirrSh = new TGeoXtru(2);
9504
9505   xprof[0] = 0;
9506   yprof[0] = 0;
9507   xprof[1] = xprof[0] - (kRearUpWebStirrWide - 2*kRearUpWebStirrThick);
9508   yprof[1] = yprof[0];
9509   xprof[2] = xprof[1];
9510   yprof[2] = yprof[1] + (kRearUpWebStirrH1 - kRearUpWebStirrThick);
9511   xprof[3] = xprof[2] - kRearUpWebStirrThick;
9512   yprof[3] = yprof[2];
9513   xprof[4] = xprof[3];
9514   yprof[4] = yprof[3] - kRearUpWebStirrH1;
9515   xprof[5] = xprof[4] + kRearUpWebStirrWide;
9516   yprof[5] = yprof[4];
9517   xprof[6] = xprof[5];
9518   yprof[6] = yprof[5] + kRearUpWebStirrH2;
9519   xprof[7] = xprof[0];
9520   yprof[7] = yprof[6];
9521
9522   upWebStirrSh->DefinePolygon(8, xprof, yprof);
9523   upWebStirrSh->DefineSection(0,-kRearUpWebStirrDep/2);
9524   upWebStirrSh->DefineSection(1, kRearUpWebStirrDep/2);
9525
9526   // The Rear Upper Bar for the webcam (0872/C/V/06): a BBox
9527   TGeoBBox *upRearWebBarSh = new TGeoBBox(kRearUpWebBarLen/2,
9528                                           kRearUpWebBarHi/2,
9529                                           kRearUpWebBarThick/2);
9530
9531   // The Webcam: a BBox
9532   TGeoBBox *webcamShape = new TGeoBBox(kFRWebClampIntWide/2,
9533                                        kWebcamLength/2,
9534                                        kFRWebClampIntHi/2);
9535
9536   // The Upper Wheel Slide (0872/C/Z/00-01-02)
9537   // A mother volume of air (to avoid assembly) contains the Alluminum block
9538   // (a Composite Shape: a Xtru and a Pcon for the hole) and the Steel pin
9539   // (a Pcon) (The wheels are approximated as part of the block itself)
9540   // The Air mother volume
9541   TGeoXtru *upSlideAirSh = new TGeoXtru(2);
9542   upSlideAirSh->SetName("ITSupperSlideAirShape");
9543
9544   xprof[0] = 0;
9545   yprof[0] = 0;
9546   xprof[1] = xprof[0];
9547   yprof[1] = kUpperSlideBlockHi + kUpperSlideStubHi - kUpperSlideWheelHi;
9548   xprof[2] = xprof[1] - kUpperSlideIntDepth;
9549   yprof[2] = yprof[1];
9550   xprof[3] = xprof[2];
9551   yprof[3] = yprof[2] - kUpperSlideTotHeight;
9552   xprof[4] = xprof[3] + kUpperSlideTotDepth;
9553   yprof[4] = yprof[3];
9554   xprof[5] = xprof[4];
9555   yprof[5] = yprof[0];
9556
9557   upSlideAirSh->DefinePolygon(6, xprof, yprof);
9558   upSlideAirSh->DefineSection(0,-kUpperSlideWidth/2);
9559   upSlideAirSh->DefineSection(1, kUpperSlideWidth/2);
9560
9561   // The (filled) Aluminum block: a Xtru
9562   TGeoXtru *upSlideAluSh = new TGeoXtru(2);
9563   upSlideAluSh->SetName("ITSupperSlideAluShape");
9564
9565   xprof[0] = upSlideAirSh->GetX(0);
9566   yprof[0] = upSlideAirSh->GetY(0);
9567   xprof[1] = upSlideAirSh->GetX(1);
9568   yprof[1] = upSlideAirSh->GetY(1);
9569   xprof[2] = xprof[1] - kUpperSlideStubDep;
9570   yprof[2] = yprof[1];
9571   xprof[3] = xprof[2];
9572   yprof[3] = yprof[2] - kUpperSlideStubHi;
9573   xprof[4] = upSlideAirSh->GetX(2);
9574   yprof[4] = yprof[3];
9575   xprof[5] = xprof[4];
9576   yprof[5] = yprof[4] - kUpperSlideBlockHi;
9577   xprof[6] = upSlideAirSh->GetX(5);
9578   yprof[6] = yprof[5];
9579   xprof[7] = xprof[6];
9580   yprof[7] = yprof[0];
9581
9582   upSlideAluSh->DefinePolygon(8, xprof, yprof);
9583   upSlideAluSh->DefineSection(0, upSlideAirSh->GetZ(0));
9584   upSlideAluSh->DefineSection(1, upSlideAirSh->GetZ(1));
9585
9586   // The cylindrical hole in the block; a Pcon
9587   TGeoPcon *upSlideHoleSh = new TGeoPcon(0, 360, 10);
9588   upSlideHoleSh->SetName("ITSupperSlideHoleShape");
9589
9590   zpos = upSlideAluSh->GetY(5);
9591   upSlideHoleSh->DefineSection(0, zpos-0.1, 0, kUpperSlideHoleRout);
9592   zpos += (kUpperSlideBlockHi - kUpperSlideHoleH3 - kUpperSlideHoleH2
9593         - 2*kUpperSlideHoleH1);
9594   upSlideHoleSh->DefineSection(1, zpos, 0, kUpperSlideHoleRout);
9595   upSlideHoleSh->DefineSection(2, zpos, 0, kUpperSlideHoleRint2);
9596   zpos += kUpperSlideHoleH3;
9597   upSlideHoleSh->DefineSection(3, zpos, 0, kUpperSlideHoleRint2);
9598   upSlideHoleSh->DefineSection(4, zpos, 0, kUpperSlideHoleRout);
9599   zpos += kUpperSlideHoleH1;
9600   upSlideHoleSh->DefineSection(5, zpos, 0, kUpperSlideHoleRout);
9601   upSlideHoleSh->DefineSection(6, zpos, 0, kUpperSlideHoleRint1);
9602   zpos += kUpperSlideHoleH2;
9603   upSlideHoleSh->DefineSection(7, zpos, 0, kUpperSlideHoleRint1);
9604   upSlideHoleSh->DefineSection(8, zpos, 0, kUpperSlideHoleRout);
9605   zpos += kUpperSlideHoleH1;
9606   upSlideHoleSh->DefineSection(9, zpos+0.1, 0, kUpperSlideHoleRout);
9607
9608   TGeoCombiTrans *upSlideHolePos = new TGeoCombiTrans(-kUpperSlideHoleXPos,0,0,
9609                                    new TGeoRotation("",0,-90,0) );
9610   upSlideHolePos->SetName("ITSupperSlideHolePos");
9611   upSlideHolePos->RegisterYourself();
9612
9613   // The actual block: a CompositeShape
9614   TGeoCompositeShape *upSlideBlockSh = new TGeoCompositeShape("ITSupperSlideAluShape-ITSupperSlideHoleShape:ITSupperSlideHolePos");
9615
9616   // The Steel pin in the block; a Pcon
9617   TGeoPcon *upSlidePinSh = new TGeoPcon(0, 360, 6);
9618   upSlidePinSh->SetName("ITSupperSlidePinShape");
9619
9620   zpos = upSlideAluSh->GetY(5) - (kUpperSlidePinH1 + kUpperSlidePinH2
9621        + kUpperSlidePinH3 - kUpperSlideBlockHi);
9622   upSlidePinSh->DefineSection(0, zpos, 0, kUpperSlidePinRmin);
9623   zpos += kUpperSlidePinH3;
9624   upSlidePinSh->DefineSection(1, zpos, 0, kUpperSlidePinRmin);
9625   upSlidePinSh->DefineSection(2, zpos, 0, kUpperSlidePinRmax);
9626   zpos += kUpperSlidePinH2;
9627   upSlidePinSh->DefineSection(3, zpos, 0, kUpperSlidePinRmax);
9628   upSlidePinSh->DefineSection(4, zpos, 0, kUpperSlidePinRmin);
9629   zpos += kUpperSlidePinH1;
9630   upSlidePinSh->DefineSection(5, zpos, 0, kUpperSlidePinRmin);
9631
9632   // The Lower Wheel Slide (0872/C/W/00-01-02-03)
9633   // A mother volume of air (to avoid assembly) contains the Alluminum block
9634   // (a Composite Shape: a Xtru and a Pcon for the hole), the Alluminum nose
9635   // (a Xtru) and the Steel pin (a Pcon)
9636   // (The wheels are approximated as part of the block itself)
9637   // The Air mother volume
9638   TGeoXtru *lwSlideAirSh = new TGeoXtru(2);
9639   lwSlideAirSh->SetName("ITSlowerSlideAirShape");
9640
9641   xprof[0] = 0;
9642   yprof[0] = 0;
9643   xprof[1] = xprof[0] + kLowerSlideTotDepth/2 - kLowerSlideNoseBase/2;
9644   yprof[1] = yprof[0];
9645   xprof[2] = xprof[1];
9646   yprof[2] = yprof[1] - (kLowerSlideBlockHi + kLowerSlidePinH2);
9647   xprof[3] = xprof[2] - kLowerSlideTotDepth;
9648   yprof[3] = yprof[2];
9649   xprof[4] = xprof[3];
9650   yprof[4] = yprof[3] + kLowerSlidePinH2 + kLowerSlideTotHeight;
9651   xprof[5] = xprof[0];
9652   yprof[5] = yprof[4];
9653
9654   lwSlideAirSh->DefinePolygon(6, xprof, yprof);
9655   lwSlideAirSh->DefineSection(0,-kLowerSlideWidth/2);
9656   lwSlideAirSh->DefineSection(1, kLowerSlideWidth/2);
9657
9658   // The (filled) Aluminum block: a Xtru
9659   TGeoXtru *lwSlideAluSh = new TGeoXtru(2);
9660   lwSlideAluSh->SetName("ITSlowerSlideAluShape");
9661
9662   xprof[0] = lwSlideAirSh->GetX(0);
9663   yprof[0] = lwSlideAirSh->GetY(0);
9664   xprof[1] = lwSlideAirSh->GetX(1);
9665   yprof[1] = lwSlideAirSh->GetY(1);
9666   xprof[2] = xprof[1];
9667   yprof[2] = yprof[1] - kLowerSlideBlockHi;
9668   xprof[3] = lwSlideAirSh->GetX(3);
9669   yprof[3] = yprof[2];
9670   xprof[4] = xprof[3];
9671   yprof[4] = yprof[3] + kLowerSlideBlockHi;
9672   xprof[5] = xprof[4] + kLowerSlideTotDepth/2;
9673   yprof[5] = yprof[4];
9674   xprof[6] = xprof[5];
9675   yprof[6] = lwSlideAirSh->GetY(4);
9676   xprof[7] = xprof[0];
9677   yprof[7] = yprof[6];
9678
9679   lwSlideAluSh->DefinePolygon(8, xprof, yprof);
9680   lwSlideAluSh->DefineSection(0, lwSlideAirSh->GetZ(0));
9681   lwSlideAluSh->DefineSection(1, lwSlideAirSh->GetZ(1));
9682
9683   // The cylindrical hole in the block; a Pcon
9684   TGeoPcon *lwSlideHoleSh = new TGeoPcon(0, 360, 4);
9685   lwSlideHoleSh->SetName("ITSlowerSlideHoleShape");
9686
9687   zpos = lwSlideAluSh->GetY(2);
9688   lwSlideHoleSh->DefineSection(0, zpos-0.1, 0, kLowerSlideHoleRout);
9689   zpos += kLowerSlideHoleH1;
9690   lwSlideHoleSh->DefineSection(1, zpos, 0, kLowerSlideHoleRout);
9691   lwSlideHoleSh->DefineSection(2, zpos, 0, kLowerSlideHoleRint);
9692   zpos = lwSlideAluSh->GetY(4);
9693   lwSlideHoleSh->DefineSection(3, zpos, 0, kLowerSlideHoleRint);
9694
9695   TGeoCombiTrans *lwSlideHolePos = new TGeoCombiTrans(lwSlideAluSh->GetX(5),
9696                                                       0, 0,
9697                                    new TGeoRotation("",0,-90,0) );
9698   lwSlideHolePos->SetName("ITSlowerSlideHolePos");
9699   lwSlideHolePos->RegisterYourself();
9700
9701   // The actual block: a CompositeShape
9702   TGeoCompositeShape *lwSlideBlockSh = new TGeoCompositeShape("ITSlowerSlideAluShape-ITSlowerSlideHoleShape:ITSlowerSlideHolePos");
9703
9704   // The Aluminum nose: a Xtru
9705   TGeoXtru *lwSlideNoseSh = new TGeoXtru(2);
9706   lwSlideNoseSh->SetName("ITSlowerSlideNoseShape");
9707
9708   xprof[0] = lwSlideAluSh->GetX(5);
9709   yprof[0] = lwSlideAluSh->GetY(5);
9710   xprof[1] = xprof[0] - kLowerSlideNoseBase/2;
9711   yprof[1] = yprof[0];
9712   xprof[2] = xprof[1];
9713   yprof[2] = yprof[1] + kLowerSlideNoseBasHi;
9714   xprof[3] = lwSlideAluSh->GetX(0) - kLowerSlideNoseUpWid;
9715   yprof[3] = lwSlideAluSh->GetY(6);
9716   xprof[4] = xprof[0];
9717   yprof[4] = yprof[3];
9718
9719   lwSlideNoseSh->DefinePolygon(5, xprof, yprof);
9720   lwSlideNoseSh->DefineSection(0,-kLowerSlideNoseDepth/2);
9721   lwSlideNoseSh->DefineSection(1, kLowerSlideNoseDepth/2);
9722
9723   // The Steel pin in the block; a Pcon
9724   TGeoPcon *lwSlidePinSh = new TGeoPcon(0, 360, 4);
9725   lwSlidePinSh->SetName("ITSlowerSlidePinShape");
9726
9727   zpos = lwSlideAirSh->GetY(2);
9728   lwSlidePinSh->DefineSection(0, zpos, 0, kLowerSlidePinRmax);
9729   zpos += kLowerSlidePinH2;
9730   lwSlidePinSh->DefineSection(1, zpos, 0, kLowerSlidePinRmax);
9731   lwSlidePinSh->DefineSection(2, zpos, 0, kLowerSlidePinRmin);
9732   zpos += kLowerSlidePinH1;
9733   lwSlidePinSh->DefineSection(3, zpos, 0, kLowerSlidePinRmin);
9734
9735   // The Stirrup on the Muon side (0872/C/01-02): a really complex Xtru
9736   // to approximate arcs with polylines
9737   TGeoXtru *stirrupC1C2Sh = new TGeoXtru(2);
9738
9739   for (Int_t j=0; j<11; j++) { // The internal arc
9740     xprof[j] = kStirrC12R50*(1 - CosD(90*j/10));
9741     yprof[j] = kStirrC12R50*SinD(90*j/10);
9742   }
9743
9744   xprof[11] = xprof[10] + kStirrC12TailLen;
9745   yprof[11] = yprof[10];
9746   xprof[12] = xprof[11];
9747   yprof[12] = kStirrC12BodyHalfHi;
9748   xprof[13] = xprof[12] - kStirrC12BodyLen;
9749   yprof[13] = yprof[12];
9750
9751   xprof[17] = xprof[12] - kStirrC12TotLen + kStirrC12HeadLen;
9752   yprof[17] = kStirrC12HeadHalfHi;
9753   IntersectCircle(-TanD(kStirrC12HeadAng), xprof[17], yprof[17],
9754                   kStirrC12R100, xprof[13], yprof[13]+kStirrC12R100,
9755                   xprof[16], yprof[16], xdummy, ydummy);
9756   alpha = TMath::ASin((xprof[13]-xprof[16])/kStirrC12R100);
9757   xprof[14] = xprof[13] - kStirrC12R100*TMath::Sin(alpha/3);
9758   yprof[14] = yprof[13] + kStirrC12R100*(1 - TMath::Cos(alpha/3));
9759   xprof[15] = xprof[13] - kStirrC12R100*TMath::Sin(2*alpha/3);
9760   yprof[15] = yprof[13] + kStirrC12R100*(1 - TMath::Cos(2*alpha/3));
9761
9762   xprof[18] = xprof[17] - kStirrC12HeadLen;
9763   yprof[18] = yprof[17];
9764   xprof[19] = xprof[18];
9765   yprof[19] = kStirrC12HeadIntHi;
9766   xprof[20] = xprof[19] + kStirrC12HeadIntLen - kStirrC12R10;
9767   yprof[20] = yprof[19];
9768   for (Int_t j=1; j<4; j++) {
9769     xprof[20+j] = xprof[20] + kStirrC12R10*SinD(90*j/3);
9770     yprof[20+j] = yprof[20] - kStirrC12R10*(1 - CosD(90*j/3));
9771   }
9772
9773   // We did the up side, now reflex on the bottom side
9774   for (Int_t jp = 0; jp < kNumberOfStirrCPoints; jp++) {
9775     xprof[24+jp] =  xprof[23-jp];
9776     yprof[24+jp] = -yprof[23-jp];
9777   }
9778
9779   // Now the actual Xtru
9780   stirrupC1C2Sh->DefinePolygon(2*kNumberOfStirrCPoints+1, xprof, yprof);
9781   stirrupC1C2Sh->DefineSection(0,-kStirrC12Thick/2);
9782   stirrupC1C2Sh->DefineSection(1, kStirrC12Thick/2);
9783
9784   // The first element of the Stirrup on the Forward side (0872/C/05):
9785   // a really complex Xtru (equal to part of the Muon Stirrup)
9786   // (0872/C/06 and 0872/C/07 are dismounted after positioning the TPC to I.P.)
9787   TGeoXtru *stirrupC5Sh = new TGeoXtru(2);
9788
9789   for (Int_t j=0; j<13; j++) { // The internal arc and the tail
9790     xprof[j] = stirrupC1C2Sh->GetX(j);
9791     yprof[j] = stirrupC1C2Sh->GetY(j);
9792   }
9793
9794   xprof[13] = xprof[12] - kStirrC5BodyLen;
9795   yprof[13] = yprof[12];
9796
9797   // We did the up side, now reflex on the bottom side
9798   for (Int_t jp = 0; jp < 13; jp++) {
9799     xprof[14+jp] =  xprof[13-jp];
9800     yprof[14+jp] = -yprof[13-jp];
9801   }
9802
9803   // Now the actual Xtru
9804   stirrupC5Sh->DefinePolygon(27, xprof, yprof);
9805   stirrupC5Sh->DefineSection(0,-kStirrC12Thick/2);
9806   stirrupC5Sh->DefineSection(1, kStirrC12Thick/2);
9807
9808
9809   // We have all shapes: now create the real volumes
9810   TGeoMedium *medAlcoa   = mgr->GetMedium("ITS_ALUMINUM$"); // To code!!!!!!
9811   TGeoMedium *medHokotol = mgr->GetMedium("ITS_HOKOTOL$");
9812   TGeoMedium *medAnticor = mgr->GetMedium("ITS_ANTICORODAL$");
9813   TGeoMedium *medErgal   = mgr->GetMedium("ITS_ERGAL$");
9814   TGeoMedium *medAisi    = mgr->GetMedium("ITS_AISI304L$");
9815   TGeoMedium *medAir     = mgr->GetMedium("ITS_AIR$");
9816   TGeoMedium *medPlexy   = mgr->GetMedium("ITS_PLEXYGLAS$");
9817   TGeoMedium *medPVC     = mgr->GetMedium("ITS_PVC$");
9818
9819
9820   TGeoVolume *suppRingC2C3  = new TGeoVolume("ITSTPCsupportRingC2C3",
9821                                              ringC2C3, medAlcoa);
9822
9823   suppRingC2C3->SetVisibility(kTRUE);
9824   suppRingC2C3->SetLineColor(6); // Purple
9825   suppRingC2C3->SetLineWidth(1);
9826   suppRingC2C3->SetFillColor(suppRingC2C3->GetLineColor());
9827   suppRingC2C3->SetFillStyle(4000); // 0% transparent
9828
9829   TGeoVolume *forwUpHook  = new TGeoVolume("ITSTPCsupportForwUpHook",
9830                                            forwUpHookShape, medHokotol);
9831
9832   forwUpHook->SetVisibility(kTRUE);
9833   forwUpHook->SetLineColor(6); // Purple
9834   forwUpHook->SetLineWidth(1);
9835   forwUpHook->SetFillColor(forwUpHook->GetLineColor());
9836   forwUpHook->SetFillStyle(4000); // 0% transparent
9837
9838   TGeoVolume *forwLwHook  = new TGeoVolume("ITSTPCsupportForwLwHook",
9839                                            forwLwHookShape, medHokotol);
9840
9841   forwLwHook->SetVisibility(kTRUE);
9842   forwLwHook->SetLineColor(6); // Purple
9843   forwLwHook->SetLineWidth(1);
9844   forwLwHook->SetFillColor(forwLwHook->GetLineColor());
9845   forwLwHook->SetFillStyle(4000); // 0% transparent
9846
9847   TGeoVolume *rearUpHook  = new TGeoVolume("ITSTPCsupportRearUpHook",
9848                                            rearUpHookShape, medHokotol);
9849
9850   rearUpHook->SetVisibility(kTRUE);
9851   rearUpHook->SetLineColor(6); // Purple
9852   rearUpHook->SetLineWidth(1);
9853   rearUpHook->SetFillColor(rearUpHook->GetLineColor());
9854   rearUpHook->SetFillStyle(4000); // 0% transparent
9855
9856   TGeoVolume *rearLwHook  = new TGeoVolume("ITSTPCsupportRearLwHook",
9857                                            rearLwHookShape, medAnticor);
9858
9859   rearLwHook->SetVisibility(kTRUE);
9860   rearLwHook->SetLineColor(6); // Purple
9861   rearLwHook->SetLineWidth(1);
9862   rearLwHook->SetFillColor(rearLwHook->GetLineColor());
9863   rearLwHook->SetFillStyle(4000); // 0% transparent
9864
9865   TGeoVolume *rearLwBrack  = new TGeoVolume("ITSTPCsupportRearLwBracket",
9866                                             rearLwBrackShape, medAnticor);
9867
9868   rearLwBrack->SetVisibility(kTRUE);
9869   rearLwBrack->SetLineColor(6); // Purple
9870   rearLwBrack->SetLineWidth(1);
9871   rearLwBrack->SetFillColor(rearLwBrack->GetLineColor());
9872   rearLwBrack->SetFillStyle(4000); // 0% transparent
9873
9874   TGeoVolume *forwWebSStirrup  = new TGeoVolume("ITSTPCsupportForwWebSStirrup",
9875                                                 forwWebSStirrSh, medAnticor);
9876
9877   forwWebSStirrup->SetVisibility(kTRUE);
9878   forwWebSStirrup->SetLineColor(6); // Purple
9879   forwWebSStirrup->SetLineWidth(1);
9880   forwWebSStirrup->SetFillColor(forwWebSStirrup->GetLineColor());
9881   forwWebSStirrup->SetFillStyle(4000); // 0% transparent
9882
9883   TGeoVolume *forwWebTStirr3  = new TGeoVolume("ITSTPCsupportForwWebTStirrup3",
9884                                                forwWebTStirr3Sh, medAnticor);
9885
9886   forwWebTStirr3->SetVisibility(kTRUE);
9887   forwWebTStirr3->SetLineColor(6); // Purple
9888   forwWebTStirr3->SetLineWidth(1);
9889   forwWebTStirr3->SetFillColor(forwWebTStirr3->GetLineColor());
9890   forwWebTStirr3->SetFillStyle(4000); // 0% transparent
9891
9892   TGeoVolume *forwWebTStirr4  = new TGeoVolume("ITSTPCsupportForwWebTStirrup4",
9893                                                forwWebTStirr4Sh, medAnticor);
9894
9895   forwWebTStirr4->SetVisibility(kTRUE);
9896   forwWebTStirr4->SetLineColor(6); // Purple
9897   forwWebTStirr4->SetLineWidth(1);
9898   forwWebTStirr4->SetFillColor(forwWebTStirr4->GetLineColor());
9899   forwWebTStirr4->SetFillStyle(4000); // 0% transparent
9900
9901   TGeoVolume *frWebClamp  = new TGeoVolume("ITSTPCsupportForwRearWebClamp",
9902                                            frWebClampSh, medPlexy);
9903
9904   frWebClamp->SetVisibility(kTRUE);
9905   frWebClamp->SetLineColor(kAzure);
9906   frWebClamp->SetLineWidth(1);
9907   frWebClamp->SetFillColor(frWebClamp->GetLineColor());
9908   frWebClamp->SetFillStyle(4000); // 0% transparent
9909
9910   TGeoVolume *upWebStirrup  = new TGeoVolume("ITSTPCsupportUpperWebStirrup",
9911                                              upWebStirrSh, medAnticor);
9912
9913   upWebStirrup->SetVisibility(kTRUE);
9914   upWebStirrup->SetLineColor(6); // Purple
9915   upWebStirrup->SetLineWidth(1);
9916   upWebStirrup->SetFillColor(upWebStirrup->GetLineColor());
9917   upWebStirrup->SetFillStyle(4000); // 0% transparent
9918
9919   TGeoVolume *upRearWebBar  = new TGeoVolume("ITSTPCsupportUpperRearWebBar",
9920                                              upRearWebBarSh, medPlexy);
9921
9922   upRearWebBar->SetVisibility(kTRUE);
9923   upRearWebBar->SetLineColor(kAzure);
9924   upRearWebBar->SetLineWidth(1);
9925   upRearWebBar->SetFillColor(upRearWebBar->GetLineColor());
9926   upRearWebBar->SetFillStyle(4000); // 0% transparent
9927
9928   TGeoVolume *webCam  = new TGeoVolume("ITSTPCsupportWebcam",
9929                                        webcamShape, medPVC);
9930
9931   webCam->SetVisibility(kTRUE);
9932   webCam->SetLineColor(kBlack);
9933   webCam->SetLineWidth(1);
9934   webCam->SetFillColor(webCam->GetLineColor());
9935   webCam->SetFillStyle(4000); // 0% transparent
9936
9937   TGeoVolume *upSlideVol  = new TGeoVolume("ITSTPCsupportUpperSlide",
9938                                            upSlideAirSh, medAir);
9939
9940   upSlideVol->SetVisibility(kFALSE);
9941
9942   TGeoVolume *upSlideBlock  = new TGeoVolume("ITSTPCsupportUpperSlideBlock",
9943                                              upSlideBlockSh, medAnticor);
9944
9945   upSlideBlock->SetVisibility(kTRUE);
9946   upSlideBlock->SetLineColor(6); // Purple
9947   upSlideBlock->SetLineWidth(1);
9948   upSlideBlock->SetFillColor(upSlideBlock->GetLineColor());
9949   upSlideBlock->SetFillStyle(4000); // 0% transparent
9950
9951   TGeoVolume *upSlidePin  = new TGeoVolume("ITSTPCsupportUpperSlidePin",
9952                                            upSlidePinSh, medAisi);
9953
9954   upSlidePin->SetVisibility(kTRUE);
9955   upSlidePin->SetLineColor(kGray);
9956   upSlidePin->SetLineWidth(1);
9957   upSlidePin->SetFillColor(upSlidePin->GetLineColor());
9958   upSlidePin->SetFillStyle(4000); // 0% transparent
9959
9960   TGeoVolume *lwSlideVol  = new TGeoVolume("ITSTPCsupportLowerSlide",
9961                                            lwSlideAirSh, medAir);
9962
9963   lwSlideVol->SetVisibility(kFALSE);
9964
9965   TGeoVolume *lwSlideBlock  = new TGeoVolume("ITSTPCsupportLowerSlideBlock",
9966                                              lwSlideBlockSh, medAnticor);
9967
9968   lwSlideBlock->SetVisibility(kTRUE);
9969   lwSlideBlock->SetLineColor(6); // Purple
9970   lwSlideBlock->SetLineWidth(1);
9971   lwSlideBlock->SetFillColor(lwSlideBlock->GetLineColor());
9972   lwSlideBlock->SetFillStyle(4000); // 0% transparent
9973
9974   TGeoVolume *lwSlideNose  = new TGeoVolume("ITSTPCsupportLowerSlideNose",
9975                                             lwSlideNoseSh, medAnticor);
9976
9977   lwSlideNose->SetVisibility(kTRUE);
9978   lwSlideNose->SetLineColor(6); // Purple
9979   lwSlideNose->SetLineWidth(1);
9980   lwSlideNose->SetFillColor(lwSlideNose->GetLineColor());
9981   lwSlideNose->SetFillStyle(4000); // 0% transparent
9982
9983   TGeoVolume *lwSlidePin  = new TGeoVolume("ITSTPCsupportLowerSlidePin",
9984                                            lwSlidePinSh, medAisi);
9985
9986   lwSlidePin->SetVisibility(kTRUE);
9987   lwSlidePin->SetLineColor(kGray);
9988   lwSlidePin->SetLineWidth(1);
9989   lwSlidePin->SetFillColor(lwSlidePin->GetLineColor());
9990   lwSlidePin->SetFillStyle(4000); // 0% transparent
9991
9992   TGeoVolume *stirrC1C2  = new TGeoVolume("ITSTPCsupportStirrupC1C2",
9993                                           stirrupC1C2Sh, medErgal);
9994
9995   stirrC1C2->SetVisibility(kTRUE);
9996   stirrC1C2->SetLineColor(6); // Purple
9997   stirrC1C2->SetLineWidth(1);
9998   stirrC1C2->SetFillColor(stirrC1C2->GetLineColor());
9999   stirrC1C2->SetFillStyle(4000); // 0% transparent
10000
10001   TGeoVolume *stirrC5  = new TGeoVolume("ITSTPCsupportStirrupC5",
10002                                         stirrupC5Sh, medErgal);
10003
10004   stirrC5->SetVisibility(kTRUE);
10005   stirrC5->SetLineColor(6); // Purple
10006   stirrC5->SetLineWidth(1);
10007   stirrC5->SetFillColor(stirrC5->GetLineColor());
10008   stirrC5->SetFillStyle(4000); // 0% transparent
10009
10010
10011   // Build up the wheel slides
10012   upSlideVol->AddNode(upSlideBlock,1,0);
10013   upSlideVol->AddNode(upSlidePin,  1,
10014                       new TGeoCombiTrans(-kUpperSlideHoleXPos, 0, 0,
10015                                          new TGeoRotation("",0,-90,0) ) );
10016
10017   lwSlideVol->AddNode(lwSlideBlock,1,0);
10018   lwSlideVol->AddNode(lwSlideNose ,1,0);
10019   lwSlideVol->AddNode(lwSlidePin,  1,
10020                       new TGeoCombiTrans(lwSlideAluSh->GetX(5), 0, 0,
10021                                          new TGeoRotation("",0,-90,0) ) );
10022
10023
10024   // Finally put everything in the mother volume
10025   moth->AddNode(suppRingC2C3,1,
10026                 new TGeoTranslation(0, 0, kRingCZPos+kRingCZToTPC) );
10027   moth->AddNode(suppRingC2C3,2,
10028                 new TGeoCombiTrans( 0, 0,-kRingCZPos,
10029                                    new TGeoRotation("",0.,180.,0.) ) );
10030   moth->AddNode(suppRingC2C3,3,
10031                 new TGeoCombiTrans( 0, 0, kRingCZPos+kRingCZToTPC,
10032                                    new TGeoRotation("",0.,0.,180.) ) );
10033   moth->AddNode(suppRingC2C3,4,
10034                 new TGeoCombiTrans( 0, 0,-kRingCZPos,
10035                                    new TGeoRotation("",0.,180.,180.) ) );
10036
10037   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10038   moth->AddNode(forwUpHook,1,
10039                 new TGeoTranslation( 0, 0, zpos) );
10040
10041   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10042   moth->AddNode(forwLwHook,1,
10043                 new TGeoCombiTrans( 0, 0, zpos,
10044                                    new TGeoRotation("",0.,0.,180.) ) );
10045
10046   zpos = kRingCZPos + kRingCThick + kRearUpHookThick;
10047   moth->AddNode(rearUpHook,1,
10048                 new TGeoTranslation( 0, 0,-zpos) );
10049
10050   zpos = kRingCZPos + kRingCThick + kRearLwHookThick;
10051   moth->AddNode(rearLwHook,1,
10052                 new TGeoCombiTrans( 0, 0,-zpos,
10053                                    new TGeoRotation("",0.,0.,180.) ) );
10054
10055   xpos =  kRearLwHookWide/2 + kRearLwBracketThick/2;
10056   ypos = -kRingCHeight;
10057   moth->AddNode(rearLwBrack,1,
10058                 new TGeoCombiTrans( xpos, ypos,-zpos,
10059                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10060   moth->AddNode(rearLwBrack,2,
10061                 new TGeoCombiTrans(-xpos, ypos,-zpos,
10062                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10063
10064   xpos = kForwUpHookWide/2;
10065   ypos = (forwUpHookMainBody->GetY(8) + forwUpHookMainBody->GetY(9))/2;
10066   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10067   moth->AddNode(forwWebSStirrup,1,
10068                 new TGeoCombiTrans( xpos, ypos, zpos,
10069                                    new TGeoRotation("", 0., 90., 0.) ) );
10070   xpos = kForwLwHookWide/2;
10071   ypos = (forwLwHookMainBody->GetY(8) + forwLwHookMainBody->GetY(9))/2;
10072   moth->AddNode(forwWebSStirrup,2,
10073                 new TGeoCombiTrans( xpos,-ypos, zpos,
10074                                    new TGeoRotation("", 0., 90., 0.) ) );
10075
10076   xpos = kForwUpHookWide/2
10077         + (forwWebSStirrSh->GetX(4) + forwWebSStirrSh->GetX(5))/2;
10078   ypos = (forwUpHookMainBody->GetY(8) + forwUpHookMainBody->GetY(9))/2
10079         +  forwWebSStirrSh->GetZ(1) - forwWebTStirr3Sh->GetY(7);
10080   zpos += (forwWebSStirrSh->GetY(4) - forwWebSStirrSh->GetY(0));
10081   moth->AddNode(forwWebTStirr3,1,
10082                 new TGeoTranslation( xpos, ypos, zpos) );
10083
10084   ypos -= frWebClampSh->GetZ(1);
10085   moth->AddNode(frWebClamp,1,
10086                 new TGeoCombiTrans( xpos, ypos, zpos+forwWebTStirr3Sh->GetZ(1),
10087                                    new TGeoRotation("", 0., 90., 0.) ) );
10088
10089   ypos -= webcamShape->GetDY()/2;
10090   moth->AddNode(webCam,1,
10091                 new TGeoTranslation( xpos, ypos,
10092                      zpos+forwWebTStirr3Sh->GetZ(1)+webcamShape->GetDZ()) );
10093
10094   xpos = kForwLwHookWide/2
10095         + (forwWebSStirrSh->GetX(4) + forwWebSStirrSh->GetX(5))/2;
10096   ypos = (forwLwHookMainBody->GetY(8) + forwLwHookMainBody->GetY(9))/2
10097         +  forwWebSStirrSh->GetZ(1) - forwWebTStirr4Sh->GetY(7);
10098   moth->AddNode(forwWebTStirr4,1,
10099                 new TGeoCombiTrans( xpos,-ypos, zpos,
10100                                    new TGeoRotation("", 180., 0., 0.) ) );
10101
10102   ypos -= frWebClampSh->GetZ(1);
10103   moth->AddNode(frWebClamp,2,
10104                 new TGeoCombiTrans( xpos,-ypos, zpos+forwWebTStirr4Sh->GetZ(1),
10105                                    new TGeoRotation("", 0., 90., 0.) ) );
10106
10107   ypos -= webcamShape->GetDY()/2;
10108   moth->AddNode(webCam,2,
10109                 new TGeoTranslation( xpos,-ypos,
10110                      zpos+forwWebTStirr4Sh->GetZ(1)+webcamShape->GetDZ()) );
10111
10112   xpos = kRearUpHookWide/2 + kRearUpWebStirrDep/2;
10113   ypos = kRingCHeight;
10114   zpos = kRingCZPos + kRingCThick;
10115   moth->AddNode(upWebStirrup,1,
10116                 new TGeoCombiTrans( xpos, ypos,-zpos,
10117                                    new TGeoRotation("",-90.,-90., 90.) ) );
10118   moth->AddNode(upWebStirrup,2,
10119                 new TGeoCombiTrans(-xpos, ypos,-zpos,
10120                                    new TGeoRotation("",-90.,-90., 90.) ) );
10121
10122   ypos = kRingCHeight + upWebStirrSh->GetY(2) - upRearWebBarSh->GetDY();
10123   zpos = kRingCZPos + kRingCThick + upWebStirrSh->GetX(3)
10124        - upRearWebBarSh->GetDZ();
10125   moth->AddNode(upRearWebBar,1,
10126                 new TGeoTranslation( 0, ypos,-zpos) );
10127
10128   zpos -= upRearWebBarSh->GetDZ();
10129   moth->AddNode(frWebClamp,3,
10130                 new TGeoCombiTrans( 0, ypos,-zpos,
10131                                    new TGeoRotation("", 0., 90., 0.) ) );
10132
10133   ypos -= webcamShape->GetDY()/2;
10134   zpos -= webcamShape->GetDZ();
10135   moth->AddNode(webCam,3,
10136                 new TGeoTranslation( 0, ypos,-zpos) );
10137
10138   xpos = ringC2C3->GetX(14) + kUpperSlideWidth/2;
10139   ypos = ringC2C3->GetY(14);
10140   zpos = kRingCZPos + kRingCThick;
10141   moth->AddNode(upSlideVol,1,
10142                 new TGeoCombiTrans( xpos, ypos, zpos + kRingCZToTPC,
10143                                    new TGeoRotation("",-90.,-90., 90.) ) );
10144   moth->AddNode(upSlideVol,2,
10145                 new TGeoCombiTrans(-xpos, ypos, zpos + kRingCZToTPC,
10146                                    new TGeoRotation("",-90.,-90., 90.) ) );
10147   moth->AddNode(upSlideVol,3,
10148                 new TGeoCombiTrans( xpos, ypos, -zpos,
10149                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10150   moth->AddNode(upSlideVol,4,
10151                 new TGeoCombiTrans(-xpos, ypos, -zpos,
10152                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10153
10154   moth->AddNode(lwSlideVol,1,
10155                 new TGeoCombiTrans( xpos,-ypos, zpos + kRingCZToTPC,
10156                                    new TGeoRotation("", 90.,-90., 90.) ) );
10157   moth->AddNode(lwSlideVol,2,
10158                 new TGeoCombiTrans(-xpos,-ypos, zpos + kRingCZToTPC,
10159                                    new TGeoRotation("", 90.,-90., 90.) ) );
10160   moth->AddNode(lwSlideVol,3,
10161                 new TGeoCombiTrans( xpos,-ypos,-zpos,
10162                                    new TGeoRotation("",-90.,-90.,-90.) ) );
10163   moth->AddNode(lwSlideVol,4,
10164                 new TGeoCombiTrans(-xpos,-ypos,-zpos,
10165                                    new TGeoRotation("",-90.,-90.,-90.) ) );
10166
10167   xpos = kStirrCXPos;
10168   zpos = kRingCZPos + kStirrCZPos + stirrupC1C2Sh->GetZ(1) + kRingCZToTPC;
10169   moth->AddNode(stirrC1C2,1,
10170                 new TGeoTranslation( xpos, 0, zpos) );
10171   moth->AddNode(stirrC1C2,2,
10172                 new TGeoCombiTrans(-xpos, 0, zpos,
10173                                    new TGeoRotation("", 90.,-180.,-90.) ) );
10174
10175   xpos = kStirrCXPos + stirrupC1C2Sh->GetX(18) + kUpperSlideWidth/2;
10176   ypos = ringC2C3->GetY(14); // Slides are all at the same height
10177   zpos = kRingCZPos + kStirrCZPos + kStirrC12Thick + kRingCZToTPC;
10178   moth->AddNode(upSlideVol,5,
10179                 new TGeoCombiTrans( xpos, ypos, zpos,
10180                                    new TGeoRotation("",-90.,-90., 90.) ) );
10181   moth->AddNode(upSlideVol,6,
10182                 new TGeoCombiTrans(-xpos, ypos, zpos,
10183                                    new TGeoRotation("",-90.,-90., 90.) ) );
10184   moth->AddNode(lwSlideVol,5,
10185                 new TGeoCombiTrans( xpos,-ypos, zpos,
10186                                    new TGeoRotation("", 90.,-90., 90.) ) );
10187   moth->AddNode(lwSlideVol,6,
10188                 new TGeoCombiTrans(-xpos,-ypos, zpos,
10189                                    new TGeoRotation("", 90.,-90., 90.) ) );
10190
10191   xpos = kStirrCXPos;
10192   zpos = kRingCZPos + kStirrCZPos + stirrupC5Sh->GetZ(1);
10193   moth->AddNode(stirrC5,1,
10194                 new TGeoTranslation( xpos, 0,-zpos) );
10195   moth->AddNode(stirrC5,2,
10196                 new TGeoCombiTrans(-xpos, 0,-zpos,
10197                                    new TGeoRotation("", 90.,-180.,-90.) ) );
10198
10199
10200   return;
10201 }
10202