]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySupport.cxx
Extend q_ij range for pp and pPb
[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 // Updated:      12 Oct 2012  Mario Sitta  Composite Shape also for EndCap
64 //
65 // Technical data are taken from:  ALICE-Thermal Screen "Cone transition"
66 // (thermal-screen1_a3.ps), "Cylinder" (thermal-screen2_a3.ps), "Half
67 // assembly" (thermal-screen3_a3.ps), "Flange" (thermal-screen4_a3.ps)
68
69
70   // Dimensions of the Central shield
71   const Double_t kHalfLengthCentral  = 399.9*fgkmm;
72   const Double_t kThicknessCentral   = 0.4*fgkmm;
73   const Double_t kInnerRadiusCentral = 8.1475*fgkcm;
74   const Double_t kOuterRadiusCentral = 9.9255*fgkcm;
75   const Double_t kInnerACentral = 3.1674*fgkcm;
76   const Double_t kInnerBCentral = 2.023 *fgkcm;
77   const Double_t kOuterACentral = 2.4374*fgkcm;
78   const Double_t kOuterBCentral = 3.8162*fgkcm;
79   const Double_t kCoolManifHoleWid  = 24.0*fgkmm; // TO BE CHECKED!
80   const Double_t kCoolManifHoleLen  = 57.5*fgkmm; // 54.2 + 1.5*2 + 0.3 toll.
81   const Double_t kCoolManifHoleZPos = 36.47*fgkcm;// MUST match SPD class
82   const Double_t kCoolSuppHoleWid  = 15.0*fgkmm;
83   const Double_t kCoolSuppHoleLen  = 38.4*fgkmm; // 35.1 + 1.5*2 + 0.3 toll.// TO BE CHECKED!
84   const Double_t kCoolSuppHoleZPos = 26.5*fgkcm;
85   // Dimensions of the EndCap shield
86   const Double_t kHalfLengthEndCap  = 25.*fgkmm;
87   const Double_t kThicknessEndCap   = 2.0*fgkmm;
88   const Double_t kInnerRadiusEndCap = 8.0775*fgkcm;
89   const Double_t kOuterRadiusEndCap = 9.9955*fgkcm;
90   const Double_t kInnerAEndCap = 3.1453*fgkcm;
91   const Double_t kInnerBEndCap = 2.0009*fgkcm;
92   const Double_t kOuterAEndCap = 2.4596*fgkcm;
93   const Double_t kOuterBEndCap = 3.8384*fgkcm;
94   // Dimensions of the Cone shield
95   const Double_t kHalfLengthCone  = 145.*fgkmm;
96   const Double_t kThicknessCone   = 0.3*fgkmm;
97   const Double_t kInnerRadialCone = 37.3*fgkcm;
98   const Double_t kOuterRadialCone = 39.0*fgkcm;
99   const Double_t kInnerACone = 14.2344*fgkcm;
100   const Double_t kInnerBCone =  9.0915*fgkcm;
101   const Double_t kOuterACone =  9.5058*fgkcm;
102   const Double_t kOuterBCone = 14.8831*fgkcm;
103   // Dimensions of the filler blocks and bars
104   const Double_t kFillerBlockLength = 20.0*fgkmm;
105   const Double_t kFillerBlockHoleR  = 2.4*fgkmm;
106   const Double_t kFillerBlockZTrans = 1.5*fgkmm;
107   const Double_t kFillerBarLength = 220.0*fgkmm;
108   const Double_t kFillerBarThick  =   1.0*fgkmm;
109   // Dimensions of the Flange's Ring and Wing
110   const Double_t kHalfLengthRing  = 7.5*fgkmm;
111   const Double_t kThicknessRing   = 0.3*fgkmm;
112   const Double_t kInnerRadiusRing = 37.3*fgkcm;
113   const Double_t kOuterRadiusRing = 42.0*fgkcm;
114   const Double_t kOuterRadiusWing = 49.25*fgkcm;
115   const Double_t kWideWing      = 6.0*fgkcm;
116   const Double_t kThetaWing     = 45.0;
117   // Common data
118   const Double_t kThetaDeg = 36.0;
119   const Double_t kTheta = kThetaDeg*TMath::DegToRad();
120   const Double_t kThicknessOmega = 0.3*fgkmm;
121
122   // Local variables
123   Double_t xpos, ypos, zpos;
124   Double_t xXtru[24], yXtru[24];
125   Double_t xshld[24], yshld[24]; // Coord. of external thermal shape
126   Double_t xair[24] , yair[24];  // Coord. of whole air shape
127   Double_t xomega[48], yomega[48];
128
129
130   // The entire shield is made up of two half central shields
131   // symmetric with respect to the XZ plane, four half end cap
132   // shields, again symmetric with respect to the XZ plane, and four
133   // half cones, symmetric with respect to the XZ plane too.
134
135   TGeoVolumeAssembly *vM = new TGeoVolumeAssembly("ITSspdThermalShield");
136
137   // The central half shield: a Composite Shape of carbon fiber.
138   // We need Composite Shapes because we have holes in which the SPD
139   // cooling manifolds and their supports will be placed.
140   // All Composite elements are XTru shapes
141
142   // First determine the external shape points
143   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
144                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
145                         kTheta,xshld,yshld);
146
147   // Now rescale to get the air volume dimensions
148     InsidePoint(xshld[23], yshld[23],
149                 xshld[ 0], yshld[ 0],
150                 xshld[ 1], yshld[ 1], kThicknessCentral,
151                 xair[0], yair[0]);
152   for (Int_t i=1; i<23; i++) {
153     InsidePoint(xshld[i-1], yshld[i-1],
154                 xshld[ i ], yshld[ i ],
155                 xshld[i+1], yshld[i+1], kThicknessCentral,
156                 xair[i], yair[i]);
157   }
158     InsidePoint(xshld[22], yshld[22],
159                 xshld[23], yshld[23],
160                 xshld[ 0], yshld[ 0], kThicknessCentral,
161                 xair[23], yair[23]);
162
163   // Then use them to determine the Omega shape points
164   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
165
166   // Finally create the single Xtru volumes
167   TGeoXtru *uppershape = new TGeoXtru(2);
168   uppershape->SetName("upTS");
169
170   for (Int_t j=0; j<6; j++) {
171     xXtru[j  ] = xair[11-j];
172     yXtru[j  ] = yair[11-j];
173     xXtru[j+6] = xshld[j+6];
174     yXtru[j+6] = yshld[j+6];
175   }
176   yXtru[5] = yXtru[6];  // Air is not at same Y as thermal shield
177   for (Int_t j=0; j<12; j++) {
178     xXtru[23-j] = -xXtru[j];
179     yXtru[23-j] =  yXtru[j];
180   }
181
182   uppershape->DefinePolygon(24,xXtru,yXtru);
183   uppershape->DefineSection(0,-kHalfLengthCentral);
184   uppershape->DefineSection(1, kHalfLengthCentral);
185
186   TGeoXtru *lowershape = new TGeoXtru(2);
187   lowershape->SetName("lwTS");
188
189   for (Int_t j=0; j<6; j++) {
190     xXtru[j  ] = xshld[j];
191     yXtru[j  ] = yshld[j];
192     xXtru[j+6] = xair[5-j];
193     yXtru[j+6] = yair[5-j];
194   }
195   yXtru[6] = yXtru[5];  // Air is not at same Y as thermal shield
196   for (Int_t j=0; j<12; j++) {
197     xXtru[23-j] = -xXtru[j];
198     yXtru[23-j] =  yXtru[j];
199   }
200
201   lowershape->DefinePolygon(24,xXtru,yXtru);
202   lowershape->DefineSection(0,-kHalfLengthCentral);
203   lowershape->DefineSection(1, kHalfLengthCentral);
204
205   yomega[10] = yshld[6];   // Add also base thickness
206   yomega[11] = yomega[10];
207   yomega[36] = yshld[17];
208   yomega[37] = yomega[36];
209
210   TGeoXtru *omegashape = new TGeoXtru(2);
211   omegashape->SetName("omTS");
212
213   omegashape->DefinePolygon(48,xomega,yomega);
214   omegashape->DefineSection(0,-kHalfLengthCentral);
215   omegashape->DefineSection(1, kHalfLengthCentral);
216
217   // And now the holes and their position matrices
218   Double_t radius = 0.5*(uppershape->GetY(11)+lowershape->GetY(0));
219
220   TGeoBBox *manifhole = new TGeoBBox(kCoolManifHoleWid/2,
221           0.55*(uppershape->GetY(11)-lowershape->GetY(0)),
222                                      kCoolManifHoleLen/2);
223   manifhole->SetName("mhTS");
224
225   zpos = kCoolManifHoleZPos;
226
227   TGeoTranslation *m1p = new TGeoTranslation("m1p",0,radius, zpos);
228   TGeoTranslation *m1n = new TGeoTranslation("m1n",0,radius,-zpos);
229   m1p->RegisterYourself();
230   m1n->RegisterYourself();
231
232   TGeoCombiTrans *m2p = new TGeoCombiTrans("m2p",radius*SinD(kThetaDeg),
233                                                  radius*CosD(kThetaDeg),
234                                            zpos,
235                                         new TGeoRotation("",-kThetaDeg,0,0));
236   TGeoCombiTrans *m2n = new TGeoCombiTrans("m2n",radius*SinD(kThetaDeg),
237                                                  radius*CosD(kThetaDeg),
238                                           -zpos,
239                                         new TGeoRotation("",-kThetaDeg,0,0));
240   m2p->RegisterYourself();
241   m2n->RegisterYourself();
242
243   TGeoCombiTrans *m3p = new TGeoCombiTrans("m3p",radius*SinD(-kThetaDeg),
244                                                  radius*CosD(-kThetaDeg),
245                                            zpos,
246                                         new TGeoRotation("",kThetaDeg,0,0));
247   TGeoCombiTrans *m3n = new TGeoCombiTrans("m3n",radius*SinD(-kThetaDeg),
248                                                  radius*CosD(-kThetaDeg),
249                                           -zpos,
250                                         new TGeoRotation("",kThetaDeg,0,0));
251   m3p->RegisterYourself();
252   m3n->RegisterYourself();
253
254   TGeoCombiTrans *m4p = new TGeoCombiTrans("m4p",radius*SinD(2*kThetaDeg),
255                                                  radius*CosD(2*kThetaDeg),
256                                            zpos,
257                                         new TGeoRotation("",-2*kThetaDeg,0,0));
258   TGeoCombiTrans *m4n = new TGeoCombiTrans("m4n",radius*SinD(2*kThetaDeg),
259                                                  radius*CosD(2*kThetaDeg),
260                                           -zpos,
261                                         new TGeoRotation("",-2*kThetaDeg,0,0));
262   m4p->RegisterYourself();
263   m4n->RegisterYourself();
264
265   TGeoCombiTrans *m5p = new TGeoCombiTrans("m5p",radius*SinD(-2*kThetaDeg),
266                                                  radius*CosD(-2*kThetaDeg),
267                                            zpos,
268                                         new TGeoRotation("",2*kThetaDeg,0,0));
269   TGeoCombiTrans *m5n = new TGeoCombiTrans("m5n",radius*SinD(-2*kThetaDeg),
270                                                  radius*CosD(-2*kThetaDeg),
271                                           -zpos,
272                                         new TGeoRotation("",2*kThetaDeg,0,0));
273   m5p->RegisterYourself();
274   m5n->RegisterYourself();
275
276   TGeoBBox *supphole = new TGeoBBox(kCoolSuppHoleWid/2,
277          0.55*(uppershape->GetY(11)-lowershape->GetY(0)),
278                                     kCoolSuppHoleLen/2);
279   supphole->SetName("shTS");
280
281   zpos = kCoolSuppHoleZPos;
282
283   TGeoTranslation *s1p = new TGeoTranslation("s1p",0,radius, zpos);
284   TGeoTranslation *s1n = new TGeoTranslation("s1n",0,radius,-zpos);
285   s1p->RegisterYourself();
286   s1n->RegisterYourself();
287
288   TGeoCombiTrans *s2p = new TGeoCombiTrans("s2p",radius*SinD(kThetaDeg),
289                                                  radius*CosD(kThetaDeg),
290                                            zpos,
291                                         new TGeoRotation("",-kThetaDeg,0,0));
292   TGeoCombiTrans *s2n = new TGeoCombiTrans("s2n",radius*SinD(kThetaDeg),
293                                                  radius*CosD(kThetaDeg),
294                                           -zpos,
295                                         new TGeoRotation("",-kThetaDeg,0,0));
296   s2p->RegisterYourself();
297   s2n->RegisterYourself();
298
299   TGeoCombiTrans *s3p = new TGeoCombiTrans("s3p",radius*SinD(-kThetaDeg),
300                                                  radius*CosD(-kThetaDeg),
301                                            zpos,
302                                         new TGeoRotation("",kThetaDeg,0,0));
303   TGeoCombiTrans *s3n = new TGeoCombiTrans("s3n",radius*SinD(-kThetaDeg),
304                                                  radius*CosD(-kThetaDeg),
305                                           -zpos,
306                                         new TGeoRotation("",kThetaDeg,0,0));
307   s3p->RegisterYourself();
308   s3n->RegisterYourself();
309
310   TGeoCombiTrans *s4p = new TGeoCombiTrans("s4p",radius*SinD(2*kThetaDeg),
311                                                  radius*CosD(2*kThetaDeg),
312                                            zpos,
313                                         new TGeoRotation("",-2*kThetaDeg,0,0));
314   TGeoCombiTrans *s4n = new TGeoCombiTrans("s4n",radius*SinD(2*kThetaDeg),
315                                                  radius*CosD(2*kThetaDeg),
316                                           -zpos,
317                                         new TGeoRotation("",-2*kThetaDeg,0,0));
318   s4p->RegisterYourself();
319   s4n->RegisterYourself();
320
321   TGeoCombiTrans *s5p = new TGeoCombiTrans("s5p",radius*SinD(-2*kThetaDeg),
322                                                  radius*CosD(-2*kThetaDeg),
323                                            zpos,
324                                         new TGeoRotation("",2*kThetaDeg,0,0));
325   TGeoCombiTrans *s5n = new TGeoCombiTrans("s5n",radius*SinD(-2*kThetaDeg),
326                                                  radius*CosD(-2*kThetaDeg),
327                                           -zpos,
328                                         new TGeoRotation("",2*kThetaDeg,0,0));
329   s5p->RegisterYourself();
330   s5n->RegisterYourself();
331
332   // Finally the actual shape
333   TGeoCompositeShape *centralshape = new TGeoCompositeShape("centralTS",
334     "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");
335
336   // The end cap half shield: a Composite Shape of carbon fiber.
337   // We need Composite Shapes because we have elements partially
338   // entering the empty spaces, and this would create overlaps or
339   // extrusions.
340   // All Composite elements are XTru shapes
341
342   // First determine the external shape points
343   CreateSPDThermalShape(kInnerAEndCap,kInnerBEndCap,kInnerRadiusEndCap,
344                         kOuterAEndCap,kOuterBEndCap,kOuterRadiusEndCap,
345                         kTheta,xshld,yshld);
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 Xtru volumes
367   TGeoXtru *upendcapshape = new TGeoXtru(2);
368   upendcapshape->SetName("upEC");
369
370   for (Int_t j=0; j<6; j++) {
371     xXtru[j  ] = xair[11-j];
372     yXtru[j  ] = yair[11-j];
373     xXtru[j+6] = xshld[j+6];
374     yXtru[j+6] = yshld[j+6];
375   }
376   yXtru[5] = yXtru[6];  // Air is not at same Y as thermal shield
377   for (Int_t j=0; j<12; j++) {
378     xXtru[23-j] = -xXtru[j];
379     yXtru[23-j] =  yXtru[j];
380   }
381
382   upendcapshape->DefinePolygon(24,xXtru,yXtru);
383   upendcapshape->DefineSection(0,-kHalfLengthEndCap);
384   upendcapshape->DefineSection(1, kHalfLengthEndCap);
385
386   TGeoXtru *lowendcapshape = new TGeoXtru(2);
387   lowendcapshape->SetName("lwEC");
388
389   for (Int_t j=0; j<6; j++) {
390     xXtru[j  ] = xshld[j];
391     yXtru[j  ] = yshld[j];
392     xXtru[j+6] = xair[5-j];
393     yXtru[j+6] = yair[5-j];
394   }
395   yXtru[6] = yXtru[5];  // Air is not at same Y as thermal shield
396   for (Int_t j=0; j<12; j++) {
397     xXtru[23-j] = -xXtru[j];
398     yXtru[23-j] =  yXtru[j];
399   }
400
401   lowendcapshape->DefinePolygon(24,xXtru,yXtru);
402   lowendcapshape->DefineSection(0,-kHalfLengthEndCap);
403   lowendcapshape->DefineSection(1, kHalfLengthEndCap);
404
405   yomega[10] = yshld[6];   // Add also base thickness
406   yomega[11] = yomega[10];
407   yomega[36] = yshld[17];
408   yomega[37] = yomega[36];
409
410   TGeoXtru *omgendcapshape = new TGeoXtru(2);
411   omgendcapshape->SetName("omEC");
412
413   omgendcapshape->DefinePolygon(48,xomega,yomega);
414   omgendcapshape->DefineSection(0,-kHalfLengthEndCap);
415   omgendcapshape->DefineSection(1, kHalfLengthEndCap);
416
417   // Finally the actual shape
418   TGeoCompositeShape *endcapshape = new TGeoCompositeShape("endcapTS",
419                                                            "upEC+lwEC+omEC");
420
421   // The filler block: a Xtru
422   TGeoXtru *fillershape = new TGeoXtru(2);
423
424   xXtru[0] = omgendcapshape->GetX(1) + 0.0002; // Avoid thiny extrusion
425   yXtru[0] = omgendcapshape->GetY(1);
426   xXtru[1] = omgendcapshape->GetX(0) + 0.0002;
427   yXtru[1] = omgendcapshape->GetY(0);
428   xXtru[2] = omgendcapshape->GetX(47) - 0.0002;
429   yXtru[2] = omgendcapshape->GetY(47);
430   xXtru[3] = omgendcapshape->GetX(46);
431   yXtru[3] = omgendcapshape->GetY(46);
432
433   fillershape->DefinePolygon(4,xXtru,yXtru);
434   fillershape->DefineSection(0,-kFillerBlockLength/2);
435   fillershape->DefineSection(1, kFillerBlockLength/2);
436
437   // The hole in the filler: a Tube (made of air)
438   TGeoTube *fillerholeshape = new TGeoTube(0, kFillerBlockHoleR,
439                                            kFillerBlockLength/2);
440
441   // The filler bar: a BBox
442   Double_t fside = omgendcapshape->GetY(14) - omgendcapshape->GetY(13);
443   TGeoBBox *fillbarshape = new TGeoBBox(fside/2, fside/2, kFillerBarLength/2);
444
445   // The hole in the bar filler: a smaller BBox (made of air)
446   fside -= 2*kFillerBarThick;
447   TGeoBBox *fillbarholeshape = new TGeoBBox(fside/2, fside/2,
448                                             kFillerBarLength/2);
449
450   // The cone half shield is more complex since there is no basic
451   // TGeo shape to describe it correctly. So it is a Composite Shape
452   // of a series of TGeoArb8 shapes, in which TGeoArb8 shapes filled
453   // with air are placed, which all together make up the cone AND
454   // its internal insert. Part of the following code is adapted from
455   // old SPDThermalSheald method.
456
457   // sCn : Filled portions, sChn : Air holes
458   TGeoArb8 *sC1  = new TGeoArb8(kHalfLengthCone);
459   TGeoArb8 *sC2  = new TGeoArb8(kHalfLengthCone);
460   TGeoArb8 *sC3  = new TGeoArb8(kHalfLengthCone);
461   TGeoArb8 *sC4  = new TGeoArb8(kHalfLengthCone);
462   TGeoArb8 *sC5  = new TGeoArb8(kHalfLengthCone);
463   TGeoArb8 *sC6  = new TGeoArb8(kHalfLengthCone);
464   TGeoArb8 *sC7  = new TGeoArb8(kHalfLengthCone);
465   TGeoArb8 *sC8  = new TGeoArb8(kHalfLengthCone);
466   TGeoArb8 *sC9  = new TGeoArb8(kHalfLengthCone);
467   TGeoArb8 *sC10 = new TGeoArb8(kHalfLengthCone);
468   TGeoArb8 *sC11 = new TGeoArb8(kHalfLengthCone);
469
470   sC1->SetName("sC1");
471   sC2->SetName("sC2");
472   sC3->SetName("sC3");
473   sC4->SetName("sC4");
474   sC5->SetName("sC5");
475   sC6->SetName("sC6");
476   sC7->SetName("sC7");
477   sC8->SetName("sC8");
478   sC9->SetName("sC9");
479   sC10->SetName("sC10");
480   sC11->SetName("sC11");
481
482   TGeoArb8 *sCh1  = new TGeoArb8(kHalfLengthCone);
483   TGeoArb8 *sCh2  = new TGeoArb8(kHalfLengthCone);
484   TGeoArb8 *sCh3  = new TGeoArb8(kHalfLengthCone);
485   TGeoArb8 *sCh4  = new TGeoArb8(kHalfLengthCone);
486   TGeoArb8 *sCh5  = new TGeoArb8(kHalfLengthCone);
487   TGeoArb8 *sCh6  = new TGeoArb8(kHalfLengthCone);
488   TGeoArb8 *sCh7  = new TGeoArb8(kHalfLengthCone);
489   TGeoArb8 *sCh8  = new TGeoArb8(kHalfLengthCone);
490   TGeoArb8 *sCh9  = new TGeoArb8(kHalfLengthCone);
491   TGeoArb8 *sCh10 = new TGeoArb8(kHalfLengthCone);
492   TGeoArb8 *sCh11 = new TGeoArb8(kHalfLengthCone);
493
494   sCh1->SetName("sCh1");
495   sCh2->SetName("sCh2");
496   sCh3->SetName("sCh3");
497   sCh4->SetName("sCh4");
498   sCh5->SetName("sCh5");
499   sCh6->SetName("sCh6");
500   sCh7->SetName("sCh7");
501   sCh8->SetName("sCh8");
502   sCh9->SetName("sCh9");
503   sCh10->SetName("sCh10");
504   sCh11->SetName("sCh11");
505
506   // Smaller end: determine the coordinates of the points of carbon fiber
507   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
508                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
509                         kTheta,xshld,yshld);
510
511   sC1->SetVertex(0, xshld[12], yshld[12]);
512   sC1->SetVertex(1, xshld[11], yshld[11]);
513   sC1->SetVertex(2, xshld[ 0], yshld[ 0]);
514   sC1->SetVertex(3, xshld[23], yshld[23]);
515
516   sC2->SetVertex(0, xshld[11], yshld[11]);
517   sC2->SetVertex(1, xshld[10], yshld[10]);
518   sC2->SetVertex(2, xshld[ 1], yshld[ 1]);
519   sC2->SetVertex(3, xshld[ 0], yshld[ 0]);
520
521   sC3->SetVertex(0, xshld[10], yshld[10]);
522   sC3->SetVertex(1, xshld[ 9], yshld[ 9]);
523   sC3->SetVertex(2, xshld[ 2], yshld[ 2]);
524   sC3->SetVertex(3, xshld[ 1], yshld[ 1]);
525
526   sC4->SetVertex(0, xshld[ 9], yshld[ 9]);
527   sC4->SetVertex(1, xshld[ 8], yshld[ 8]);
528   sC4->SetVertex(2, xshld[ 3], yshld[ 3]);
529   sC4->SetVertex(3, xshld[ 2], yshld[ 2]);
530
531   sC5->SetVertex(0, xshld[ 8], yshld[ 8]);
532   sC5->SetVertex(1, xshld[ 7], yshld[ 7]);
533   sC5->SetVertex(2, xshld[ 4], yshld[ 4]);
534   sC5->SetVertex(3, xshld[ 3], yshld[ 3]);
535
536   sC6->SetVertex(0, xshld[ 7], yshld[ 7]);
537   sC6->SetVertex(1, xshld[ 6], yshld[ 6]);
538   sC6->SetVertex(2, xshld[ 5], yshld[ 5]);
539   sC6->SetVertex(3, xshld[ 4], yshld[ 4]);
540
541   sC7->SetVertex(0,-xshld[10], yshld[10]);
542   sC7->SetVertex(1,-xshld[11], yshld[11]);
543   sC7->SetVertex(2,-xshld[ 0], yshld[ 0]);
544   sC7->SetVertex(3,-xshld[ 1], yshld[ 1]);
545
546   sC8->SetVertex(0,-xshld[ 9], yshld[ 9]);
547   sC8->SetVertex(1,-xshld[10], yshld[10]);
548   sC8->SetVertex(2,-xshld[ 1], yshld[ 1]);
549   sC8->SetVertex(3,-xshld[ 2], yshld[ 2]);
550
551   sC9->SetVertex(0,-xshld[ 8], yshld[ 8]);
552   sC9->SetVertex(1,-xshld[ 9], yshld[ 9]);
553   sC9->SetVertex(2,-xshld[ 2], yshld[ 2]);
554   sC9->SetVertex(3,-xshld[ 3], yshld[ 3]);
555
556   sC10->SetVertex(0,-xshld[ 7], yshld[ 7]);
557   sC10->SetVertex(1,-xshld[ 8], yshld[ 8]);
558   sC10->SetVertex(2,-xshld[ 3], yshld[ 3]);
559   sC10->SetVertex(3,-xshld[ 4], yshld[ 4]);
560
561   sC11->SetVertex(0,-xshld[ 6], yshld[ 6]);
562   sC11->SetVertex(1,-xshld[ 7], yshld[ 7]);
563   sC11->SetVertex(2,-xshld[ 4], yshld[ 4]);
564   sC11->SetVertex(3,-xshld[ 5], yshld[ 5]);
565
566   // Then rescale to get the air volume dimensions
567     InsidePoint(xshld[23], yshld[23],
568                 xshld[ 0], yshld[ 0],
569                 xshld[ 1], yshld[ 1], kThicknessCone,
570                 xair[0], yair[0]);
571   for (Int_t i=1; i<23; i++) {
572     InsidePoint(xshld[i-1], yshld[i-1],
573                 xshld[ i ], yshld[ i ],
574                 xshld[i+1], yshld[i+1], kThicknessCone,
575                 xair[i], yair[i]);
576   }
577     InsidePoint(xshld[22], yshld[22],
578                 xshld[23], yshld[23],
579                 xshld[ 0], yshld[ 0], kThicknessCone,
580                 xair[23], yair[23]);
581
582   // Then use them to determine the Omega shape points
583   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
584
585   // Finally fill the small end coordinates of the air shapes
586   sCh1->SetVertex(0, xomega[ 0], yomega[ 0]);
587   sCh1->SetVertex(1, xomega[ 1], yomega[ 1]);
588   sCh1->SetVertex(2,-xomega[ 1], yomega[ 1]);
589   sCh1->SetVertex(3,-xomega[ 0], yomega[ 0]);
590
591   sCh2->SetVertex(0, xomega[20], yomega[20]);
592   sCh2->SetVertex(1, xomega[21], yomega[21]);
593   sCh2->SetVertex(2, xomega[22], yomega[22]);
594   sCh2->SetVertex(3, xomega[23], yomega[23]);
595
596   sCh3->SetVertex(0, xomega[ 2], yomega[ 2]);
597   sCh3->SetVertex(1, xomega[ 3], yomega[ 3]);
598   sCh3->SetVertex(2, xomega[ 4], yomega[ 4]);
599   sCh3->SetVertex(3, xomega[ 5], yomega[ 5]);
600
601   sCh4->SetVertex(0, xomega[16], yomega[16]);
602   sCh4->SetVertex(1, xomega[17], yomega[17]);
603   sCh4->SetVertex(2, xomega[18], yomega[18]);
604   sCh4->SetVertex(3, xomega[19], yomega[19]);
605
606   sCh5->SetVertex(0, xomega[ 6], yomega[ 6]);
607   sCh5->SetVertex(1, xomega[ 7], yomega[ 7]);
608   sCh5->SetVertex(2, xomega[ 8], yomega[ 8]);
609   sCh5->SetVertex(3, xomega[ 9], yomega[ 9]);
610
611   sCh6->SetVertex(0, xomega[12], yomega[12]);
612   sCh6->SetVertex(1, xomega[13], yomega[13]);
613   sCh6->SetVertex(2, xomega[14], yomega[14]);
614   sCh6->SetVertex(3, xomega[15], yomega[15]);
615
616   sCh7->SetVertex(0,-xomega[21], yomega[21]);
617   sCh7->SetVertex(1,-xomega[20], yomega[20]);
618   sCh7->SetVertex(2,-xomega[23], yomega[23]);
619   sCh7->SetVertex(3,-xomega[22], yomega[22]);
620
621   sCh8->SetVertex(0,-xomega[ 3], yomega[ 3]);
622   sCh8->SetVertex(1,-xomega[ 2], yomega[ 2]);
623   sCh8->SetVertex(2,-xomega[ 5], yomega[ 5]);
624   sCh8->SetVertex(3,-xomega[ 4], yomega[ 4]);
625
626   sCh9->SetVertex(0,-xomega[17], yomega[17]);
627   sCh9->SetVertex(1,-xomega[16], yomega[16]);
628   sCh9->SetVertex(2,-xomega[19], yomega[19]);
629   sCh9->SetVertex(3,-xomega[18], yomega[18]);
630
631   sCh10->SetVertex(0,-xomega[ 7], yomega[ 7]);
632   sCh10->SetVertex(1,-xomega[ 6], yomega[ 6]);
633   sCh10->SetVertex(2,-xomega[ 9], yomega[ 9]);
634   sCh10->SetVertex(3,-xomega[ 8], yomega[ 8]);
635
636   sCh11->SetVertex(0,-xomega[13], yomega[13]);
637   sCh11->SetVertex(1,-xomega[12], yomega[12]);
638   sCh11->SetVertex(2,-xomega[15], yomega[15]);
639   sCh11->SetVertex(3,-xomega[14], yomega[14]);
640
641   // Bigger end: determine the coordinates of the points of carbon fiber
642
643   // Drawings give only the radius, convert it to the apothegm
644   Double_t kInnerRadiusCone = TMath::Sqrt(kInnerRadialCone*kInnerRadialCone
645                                           - 0.25*kInnerACone*kInnerACone);
646   Double_t kOuterRadiusCone = TMath::Sqrt(kOuterRadialCone*kOuterRadialCone
647                                           - 0.25*kOuterACone*kOuterACone);
648
649   CreateSPDThermalShape(kInnerACone,kInnerBCone,kInnerRadiusCone,
650                         kOuterACone,kOuterBCone,kOuterRadiusCone,
651                         kTheta,xshld,yshld);
652
653   sC1->SetVertex(4, xshld[12], yshld[12]);
654   sC1->SetVertex(5, xshld[11], yshld[11]);
655   sC1->SetVertex(6, xshld[ 0], yshld[ 0]);
656   sC1->SetVertex(7, xshld[23], yshld[23]);
657
658   sC2->SetVertex(4, xshld[11], yshld[11]);
659   sC2->SetVertex(5, xshld[10], yshld[10]);
660   sC2->SetVertex(6, xshld[ 1], yshld[ 1]);
661   sC2->SetVertex(7, xshld[ 0], yshld[ 0]);
662
663   sC3->SetVertex(4, xshld[10], yshld[10]);
664   sC3->SetVertex(5, xshld[ 9], yshld[ 9]);
665   sC3->SetVertex(6, xshld[ 2], yshld[ 2]);
666   sC3->SetVertex(7, xshld[ 1], yshld[ 1]);
667
668   sC4->SetVertex(4, xshld[ 9], yshld[ 9]);
669   sC4->SetVertex(5, xshld[ 8], yshld[ 8]);
670   sC4->SetVertex(6, xshld[ 3], yshld[ 3]);
671   sC4->SetVertex(7, xshld[ 2], yshld[ 2]);
672
673   sC5->SetVertex(4, xshld[ 8], yshld[ 8]);
674   sC5->SetVertex(5, xshld[ 7], yshld[ 7]);
675   sC5->SetVertex(6, xshld[ 4], yshld[ 4]);
676   sC5->SetVertex(7, xshld[ 3], yshld[ 3]);
677
678   sC6->SetVertex(4, xshld[ 7], yshld[ 7]);
679   sC6->SetVertex(5, xshld[ 6], yshld[ 6]);
680   sC6->SetVertex(6, xshld[ 5], yshld[ 5]);
681   sC6->SetVertex(7, xshld[ 4], yshld[ 4]);
682
683   sC7->SetVertex(4,-xshld[10], yshld[10]);
684   sC7->SetVertex(5,-xshld[11], yshld[11]);
685   sC7->SetVertex(6,-xshld[ 0], yshld[ 0]);
686   sC7->SetVertex(7,-xshld[ 1], yshld[ 1]);
687
688   sC8->SetVertex(4,-xshld[ 9], yshld[ 9]);
689   sC8->SetVertex(5,-xshld[10], yshld[10]);
690   sC8->SetVertex(6,-xshld[ 1], yshld[ 1]);
691   sC8->SetVertex(7,-xshld[ 2], yshld[ 2]);
692
693   sC9->SetVertex(4,-xshld[ 8], yshld[ 8]);
694   sC9->SetVertex(5,-xshld[ 9], yshld[ 9]);
695   sC9->SetVertex(6,-xshld[ 2], yshld[ 2]);
696   sC9->SetVertex(7,-xshld[ 3], yshld[ 3]);
697
698   sC10->SetVertex(4,-xshld[ 7], yshld[ 7]);
699   sC10->SetVertex(5,-xshld[ 8], yshld[ 8]);
700   sC10->SetVertex(6,-xshld[ 3], yshld[ 3]);
701   sC10->SetVertex(7,-xshld[ 4], yshld[ 4]);
702
703   sC11->SetVertex(4,-xshld[ 6], yshld[ 6]);
704   sC11->SetVertex(5,-xshld[ 7], yshld[ 7]);
705   sC11->SetVertex(6,-xshld[ 4], yshld[ 4]);
706   sC11->SetVertex(7,-xshld[ 5], yshld[ 5]);
707
708   // Then rescale to get the air volume dimensions
709     InsidePoint(xshld[23], yshld[23],
710                 xshld[ 0], yshld[ 0],
711                 xshld[ 1], yshld[ 1], kThicknessCone,
712                 xair[0], yair[0]);
713   for (Int_t i=1; i<23; i++) {
714     InsidePoint(xshld[i-1], yshld[i-1],
715                 xshld[ i ], yshld[ i ],
716                 xshld[i+1], yshld[i+1], kThicknessCone,
717                 xair[i], yair[i]);
718   }
719     InsidePoint(xshld[22], yshld[22],
720                 xshld[23], yshld[23],
721                 xshld[ 0], yshld[ 0], kThicknessCone,
722                 xair[23], yair[23]);
723
724   // Then use them to determine the Omega shape points
725   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
726
727   // Finally fill the big end coordinates of the air shapes
728   sCh1->SetVertex(4, xomega[ 0], yomega[ 0]);
729   sCh1->SetVertex(5, xomega[ 1], yomega[ 1]);
730   sCh1->SetVertex(6,-xomega[ 1], yomega[ 1]);
731   sCh1->SetVertex(7,-xomega[ 0], yomega[ 0]);
732
733   sCh2->SetVertex(4, xomega[20], yomega[20]);
734   sCh2->SetVertex(5, xomega[21], yomega[21]);
735   sCh2->SetVertex(6, xomega[22], yomega[22]);
736   sCh2->SetVertex(7, xomega[23], yomega[23]);
737
738   sCh3->SetVertex(4, xomega[ 2], yomega[ 2]);
739   sCh3->SetVertex(5, xomega[ 3], yomega[ 3]);
740   sCh3->SetVertex(6, xomega[ 4], yomega[ 4]);
741   sCh3->SetVertex(7, xomega[ 5], yomega[ 5]);
742
743   sCh4->SetVertex(4, xomega[16], yomega[16]);
744   sCh4->SetVertex(5, xomega[17], yomega[17]);
745   sCh4->SetVertex(6, xomega[18], yomega[18]);
746   sCh4->SetVertex(7, xomega[19], yomega[19]);
747
748   sCh5->SetVertex(4, xomega[ 6], yomega[ 6]);
749   sCh5->SetVertex(5, xomega[ 7], yomega[ 7]);
750   sCh5->SetVertex(6, xomega[ 8], yomega[ 8]);
751   sCh5->SetVertex(7, xomega[ 9], yomega[ 9]);
752
753   sCh6->SetVertex(4, xomega[12], yomega[12]);
754   sCh6->SetVertex(5, xomega[13], yomega[13]);
755   sCh6->SetVertex(6, xomega[14], yomega[14]);
756   sCh6->SetVertex(7, xomega[15], yomega[15]);
757
758   sCh7->SetVertex(4,-xomega[21], yomega[21]);
759   sCh7->SetVertex(5,-xomega[20], yomega[20]);
760   sCh7->SetVertex(6,-xomega[23], yomega[23]);
761   sCh7->SetVertex(7,-xomega[22], yomega[22]);
762
763   sCh8->SetVertex(4,-xomega[ 3], yomega[ 3]);
764   sCh8->SetVertex(5,-xomega[ 2], yomega[ 2]);
765   sCh8->SetVertex(6,-xomega[ 5], yomega[ 5]);
766   sCh8->SetVertex(7,-xomega[ 4], yomega[ 4]);
767
768   sCh9->SetVertex(4,-xomega[17], yomega[17]);
769   sCh9->SetVertex(5,-xomega[16], yomega[16]);
770   sCh9->SetVertex(6,-xomega[19], yomega[19]);
771   sCh9->SetVertex(7,-xomega[18], yomega[18]);
772
773   sCh10->SetVertex(4,-xomega[ 7], yomega[ 7]);
774   sCh10->SetVertex(5,-xomega[ 6], yomega[ 6]);
775   sCh10->SetVertex(6,-xomega[ 9], yomega[ 9]);
776   sCh10->SetVertex(7,-xomega[ 8], yomega[ 8]);
777
778   sCh11->SetVertex(4,-xomega[13], yomega[13]);
779   sCh11->SetVertex(5,-xomega[12], yomega[12]);
780   sCh11->SetVertex(6,-xomega[15], yomega[15]);
781   sCh11->SetVertex(7,-xomega[14], yomega[14]);
782
783   // Now the actual carbon fiber cone: a CompositeShape
784   TGeoCompositeShape *sCone = new TGeoCompositeShape("sCone",
785                             "sC1+sC2+sC3+sC4+sC5+sC6+sC7+sC8+sC9+sC10+sC11");
786
787   // Finally the carbon fiber Ring with its Wings and their
788   // stesalite inserts. They are Tube and TubeSeg shapes
789
790   TGeoTube *ringshape = new TGeoTube(kInnerRadiusRing,kOuterRadiusRing,
791                                      kHalfLengthRing);
792
793   TGeoTube *ringinsertshape = new TGeoTube(kInnerRadiusRing+kThicknessRing,
794                                            kOuterRadiusRing-kThicknessRing,
795                                            kHalfLengthRing-kThicknessRing);
796
797   Double_t angleWideWing, angleWideWingThickness;
798   angleWideWing = (kWideWing/kOuterRadiusWing)*TMath::RadToDeg();
799   angleWideWingThickness = (kThicknessRing/kOuterRadiusWing)*TMath::RadToDeg();
800
801   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kOuterRadiusRing,kOuterRadiusWing,
802                                            kHalfLengthRing, 0, angleWideWing);
803
804   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kOuterRadiusRing,
805              kOuterRadiusWing-kThicknessRing, kHalfLengthRing-kThicknessRing,
806              angleWideWingThickness, angleWideWing-angleWideWingThickness);
807
808
809   // We have the shapes: now create the real volumes
810
811   TGeoMedium *medSPDcf  = mgr->GetMedium("ITS_SPD shield$");
812   TGeoMedium *medSPDair = mgr->GetMedium("ITS_SPD AIR$");
813   TGeoMedium *medSPDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
814
815   TGeoVolume *centralshield = new TGeoVolume("SPDcentralshield",
816                                              centralshape,medSPDcf);
817   centralshield->SetVisibility(kTRUE);
818   centralshield->SetLineColor(7);
819   centralshield->SetLineWidth(1);
820   centralshield->SetFillColor(centralshield->GetLineColor());
821   centralshield->SetFillStyle(4090); // 90% transparent
822
823   TGeoVolume *endcapshield = new TGeoVolume("SPDendcapshield",
824                                              endcapshape,medSPDcf);
825   endcapshield->SetVisibility(kTRUE);
826   endcapshield->SetLineColor(7);
827   endcapshield->SetLineWidth(1);
828   endcapshield->SetFillColor(endcapshield->GetLineColor());
829   endcapshield->SetFillStyle(4090); // 90% transparent
830
831   TGeoVolume *fillerblock = new TGeoVolume("SPDfillerblock",
832                                            fillershape,medSPDcf);
833   fillerblock->SetVisibility(kTRUE);
834   fillerblock->SetLineColor(7);
835   fillerblock->SetLineWidth(1);
836   fillerblock->SetFillColor(fillerblock->GetLineColor());
837   fillerblock->SetFillStyle(4090); // 90% transparent
838
839   TGeoVolume *fillerhole = new TGeoVolume("SPDfillerhole",
840                                           fillerholeshape,medSPDair);
841   fillerhole->SetVisibility(kTRUE);
842   fillerhole->SetLineColor(5); // Yellow
843   fillerhole->SetLineWidth(1);
844   fillerhole->SetFillColor(fillerhole->GetLineColor());
845   fillerhole->SetFillStyle(4090); // 90% transparent
846
847   ypos = (fillershape->GetY(0)+fillershape->GetY(1))/2;
848   fillerblock->AddNode(fillerhole, 1, new TGeoTranslation(0, ypos, 0));
849
850   zpos = omgendcapshape->GetZ(1) - fillershape->GetZ(1) - kFillerBlockZTrans;
851   endcapshield->AddNode(fillerblock, 1, new TGeoTranslation(0, 0, zpos));
852   endcapshield->AddNode(fillerblock, 2, new TGeoCombiTrans(0, 0, zpos,
853                                        new TGeoRotation("", kThetaDeg,0,0)));
854   endcapshield->AddNode(fillerblock, 3, new TGeoCombiTrans(0, 0, zpos,
855                                        new TGeoRotation("",-kThetaDeg,0,0)));
856   endcapshield->AddNode(fillerblock, 4, new TGeoCombiTrans(0, 0, zpos,
857                                        new TGeoRotation("", 2*kThetaDeg,0,0)));
858   endcapshield->AddNode(fillerblock, 5, new TGeoCombiTrans(0, 0, zpos,
859                                        new TGeoRotation("",-2*kThetaDeg,0,0)));
860
861   TGeoVolume *fillerbar = new TGeoVolume("SPDfillerbar",
862                                          fillbarshape,medSPDcf);
863   fillerbar->SetVisibility(kTRUE);
864   fillerbar->SetLineColor(7);
865   fillerbar->SetLineWidth(1);
866   fillerbar->SetFillColor(fillerbar->GetLineColor());
867   fillerbar->SetFillStyle(4090); // 90% transparent
868
869   TGeoVolume *fillbarhole = new TGeoVolume("SPDfillerbarhole",
870                                              fillbarholeshape,medSPDair);
871   fillbarhole->SetVisibility(kTRUE);
872   fillbarhole->SetLineColor(5); // Yellow
873   fillbarhole->SetLineWidth(1);
874   fillbarhole->SetFillColor(fillbarhole->GetLineColor());
875   fillbarhole->SetFillStyle(4090); // 90% transparent
876
877   fillerbar->AddNode(fillbarhole, 1, 0);
878
879   TGeoVolume *vCone = new TGeoVolume("SPDconeshield",sCone,medSPDcf);
880   vCone->SetVisibility(kTRUE);
881   vCone->SetLineColor(7);
882   vCone->SetLineWidth(1);
883   vCone->SetFillColor(vCone->GetLineColor());
884   vCone->SetFillStyle(4090); // 90% transparent
885
886   TGeoVolume *vCh1 = new TGeoVolume("SPDconeshieldH1",sCh1,medSPDair);
887   vCh1->SetVisibility(kTRUE);
888   vCh1->SetLineColor(5); // Yellow
889   vCh1->SetLineWidth(1);
890   vCh1->SetFillColor(vCh1->GetLineColor());
891   vCh1->SetFillStyle(4090); // 90% transparent
892
893   TGeoVolume *vCh2 = new TGeoVolume("SPDconeshieldH2",sCh2,medSPDair);
894   vCh2->SetVisibility(kTRUE);
895   vCh2->SetLineColor(5); // Yellow
896   vCh2->SetLineWidth(1);
897   vCh2->SetFillColor(vCh2->GetLineColor());
898   vCh2->SetFillStyle(4090); // 90% transparent
899
900   TGeoVolume *vCh3 = new TGeoVolume("SPDconeshieldH3",sCh3,medSPDair);
901   vCh3->SetVisibility(kTRUE);
902   vCh3->SetLineColor(5); // Yellow
903   vCh3->SetLineWidth(1);
904   vCh3->SetFillColor(vCh3->GetLineColor());
905   vCh3->SetFillStyle(4090); // 90% transparent
906
907   TGeoVolume *vCh4 = new TGeoVolume("SPDconeshieldH4",sCh4,medSPDair);
908   vCh4->SetVisibility(kTRUE);
909   vCh4->SetLineColor(5); // Yellow
910   vCh4->SetLineWidth(1);
911   vCh4->SetFillColor(vCh4->GetLineColor());
912   vCh4->SetFillStyle(4090); // 90% transparent
913
914   TGeoVolume *vCh5 = new TGeoVolume("SPDconeshieldH5",sCh5,medSPDair);
915   vCh5->SetVisibility(kTRUE);
916   vCh5->SetLineColor(5); // Yellow
917   vCh5->SetLineWidth(1);
918   vCh5->SetFillColor(vCh5->GetLineColor());
919   vCh5->SetFillStyle(4090); // 90% transparent
920
921   TGeoVolume *vCh6 = new TGeoVolume("SPDconeshieldH6",sCh6,medSPDair);
922   vCh6->SetVisibility(kTRUE);
923   vCh6->SetLineColor(5); // Yellow
924   vCh6->SetLineWidth(1);
925   vCh6->SetFillColor(vCh6->GetLineColor());
926   vCh6->SetFillStyle(4090); // 90% transparent
927
928   TGeoVolume *vCh7 = new TGeoVolume("SPDconeshieldH7",sCh7,medSPDair);
929   vCh7->SetVisibility(kTRUE);
930   vCh7->SetLineColor(5); // Yellow
931   vCh7->SetLineWidth(1);
932   vCh7->SetFillColor(vCh7->GetLineColor());
933   vCh7->SetFillStyle(4090); // 90% transparent
934
935   TGeoVolume *vCh8 = new TGeoVolume("SPDconeshieldH8",sCh8,medSPDair);
936   vCh8->SetVisibility(kTRUE);
937   vCh8->SetLineColor(5); // Yellow
938   vCh8->SetLineWidth(1);
939   vCh8->SetFillColor(vCh8->GetLineColor());
940   vCh8->SetFillStyle(4090); // 90% transparent
941
942   TGeoVolume *vCh9 = new TGeoVolume("SPDconeshieldH9",sCh9,medSPDair);
943   vCh9->SetVisibility(kTRUE);
944   vCh9->SetLineColor(5); // Yellow
945   vCh9->SetLineWidth(1);
946   vCh9->SetFillColor(vCh9->GetLineColor());
947   vCh9->SetFillStyle(4090); // 90% transparent
948
949   TGeoVolume *vCh10 = new TGeoVolume("SPDconeshieldH10",sCh10,medSPDair);
950   vCh10->SetVisibility(kTRUE);
951   vCh10->SetLineColor(5); // Yellow
952   vCh10->SetLineWidth(1);
953   vCh10->SetFillColor(vCh10->GetLineColor());
954   vCh10->SetFillStyle(4090); // 90% transparent
955
956   TGeoVolume *vCh11 = new TGeoVolume("SPDconeshieldH11",sCh11,medSPDair);
957   vCh11->SetVisibility(kTRUE);
958   vCh11->SetLineColor(5); // Yellow
959   vCh11->SetLineWidth(1);
960   vCh11->SetFillColor(vCh11->GetLineColor());
961   vCh11->SetFillStyle(4090); // 90% transparent
962
963   vCone->AddNode(vCh1 ,1,0);
964   vCone->AddNode(vCh2 ,1,0);
965   vCone->AddNode(vCh3 ,1,0);
966   vCone->AddNode(vCh4 ,1,0);
967   vCone->AddNode(vCh5 ,1,0);
968   vCone->AddNode(vCh6 ,1,0);
969   vCone->AddNode(vCh7 ,1,0);
970   vCone->AddNode(vCh8 ,1,0);
971   vCone->AddNode(vCh9 ,1,0);
972   vCone->AddNode(vCh10,1,0);
973   vCone->AddNode(vCh11,1,0);
974
975   TGeoVolume *ring = new TGeoVolume("SPDshieldring",ringshape,medSPDcf);
976   ring->SetVisibility(kTRUE);
977   ring->SetLineColor(7);
978   ring->SetLineWidth(1);
979
980   TGeoVolume *ringinsert = new TGeoVolume("SPDshieldringinsert",
981                                           ringinsertshape,medSPDste);
982   ringinsert->SetVisibility(kTRUE);
983   ringinsert->SetLineColor(3); // Green
984 //  ringinsert->SetLineWidth(1);
985   ringinsert->SetFillColor(ringinsert->GetLineColor());
986   ringinsert->SetFillStyle(4010); // 10% transparent
987
988   ring->AddNode(ringinsert,1,0);
989
990   TGeoVolume *wing = new TGeoVolume("SPDshieldringwing",wingshape,medSPDcf);
991   wing->SetVisibility(kTRUE);
992   wing->SetLineColor(7);
993   wing->SetLineWidth(1);
994
995   TGeoVolume *winginsert = new TGeoVolume("SPDshieldwinginsert",
996                                           winginsertshape,medSPDste);
997   winginsert->SetVisibility(kTRUE);
998   winginsert->SetLineColor(3); // Green
999 //  winginsert->SetLineWidth(1);
1000   winginsert->SetFillColor(winginsert->GetLineColor());
1001   winginsert->SetFillStyle(4010); // 10% transparent
1002
1003   wing->AddNode(winginsert,1,0);
1004
1005
1006   // Add all volumes in the assembly
1007   const Double_t kLittleZTrans = 0.1*fgkmm;
1008   vM->AddNode(centralshield,1,new TGeoTranslation(0,0,-kLittleZTrans));
1009   vM->AddNode(centralshield,2,new TGeoCombiTrans( 0,0,-kLittleZTrans,
1010                                   new TGeoRotation("",180,0,0)));
1011
1012   zpos = kHalfLengthCentral+kHalfLengthEndCap;
1013   vM->AddNode(endcapshield,1,
1014               new TGeoTranslation(0,0, zpos-kLittleZTrans));
1015   vM->AddNode(endcapshield,2,new TGeoCombiTrans(
1016               0, 0,-zpos-kLittleZTrans, new TGeoRotation("",  0,180,0) ) );
1017   vM->AddNode(endcapshield,3,new TGeoCombiTrans(
1018               0, 0, zpos-kLittleZTrans, new TGeoRotation("",180,  0,0) ) );
1019   vM->AddNode(endcapshield,4,new TGeoCombiTrans(
1020               0, 0,-zpos-kLittleZTrans, new TGeoRotation("",180,180,0) ) );
1021
1022   xpos = omgendcapshape->GetX(13) + fillbarshape->GetDX();
1023   ypos = omgendcapshape->GetY(13) + fillbarshape->GetDY();
1024   zpos -= fillbarshape->GetDZ();
1025   vM->AddNode(fillerbar, 1, new TGeoTranslation( xpos, ypos, zpos));
1026   vM->AddNode(fillerbar, 2, new TGeoTranslation(-xpos, ypos, zpos));
1027   vM->AddNode(fillerbar, 3, new TGeoTranslation( xpos,-ypos, zpos));
1028   vM->AddNode(fillerbar, 4, new TGeoTranslation(-xpos,-ypos, zpos));
1029   vM->AddNode(fillerbar, 5, new TGeoTranslation( xpos, ypos,-zpos));
1030   vM->AddNode(fillerbar, 6, new TGeoTranslation(-xpos, ypos,-zpos));
1031   vM->AddNode(fillerbar, 7, new TGeoTranslation( xpos,-ypos,-zpos));
1032   vM->AddNode(fillerbar, 8, new TGeoTranslation(-xpos,-ypos,-zpos));
1033
1034   zpos = kHalfLengthCentral+2*kHalfLengthEndCap+kHalfLengthCone;
1035   vM->AddNode(vCone ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1036
1037   vM->AddNode(vCone ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1038                                 new TGeoRotation("", 0, 0, 180)   ));
1039
1040   vM->AddNode(vCone ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1041                                 new TGeoRotation("", 0, 180, 0)   ));
1042
1043   vM->AddNode(vCone ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1044                                 new TGeoRotation("", 0, 180, 180)   ));
1045
1046   zpos = kHalfLengthCentral+2*kHalfLengthEndCap+2*kHalfLengthCone
1047        + kHalfLengthRing;
1048   vM->AddNode(ring,1,new TGeoTranslation(0, 0, zpos-kLittleZTrans));
1049   vM->AddNode(ring,2,new TGeoTranslation(0, 0,-zpos-kLittleZTrans));
1050
1051   for (Int_t i=0; i<4; i++) {
1052     Double_t thetaW = kThetaWing*(2*i+1) - angleWideWing/2.;
1053     vM->AddNode(wing,2*i+1,new TGeoCombiTrans(0, 0, zpos-kLittleZTrans,
1054                                new TGeoRotation("",thetaW,0,0) ) );
1055     vM->AddNode(wing,2*i+2,new TGeoCombiTrans(0, 0,-zpos-kLittleZTrans,
1056                                new TGeoRotation("",thetaW,0,0) ) );
1057   }
1058
1059   // Some debugging if requested
1060   if(GetDebug(1)){
1061     vM->PrintNodes();
1062     vM->InspectShape();
1063   }
1064
1065   // Finally put the entire shield in the mother volume
1066   moth->AddNode(vM,1,0);
1067
1068   return;
1069 }
1070
1071 //______________________________________________________________________
1072 void AliITSv11GeometrySupport::CreateSPDThermalShape(
1073      Double_t ina, Double_t inb, Double_t inr,
1074      Double_t oua, Double_t oub, Double_t our,
1075      Double_t   t, Double_t *x , Double_t *y ) const
1076 {
1077 //
1078 // Creates the proper sequence of X and Y coordinates to determine
1079 // the base XTru polygon for the SPD thermal shapes
1080 //
1081 // Input:
1082 //        ina, inb : inner shape sides
1083 //        inr      : inner radius
1084 //        oua, oub : outer shape sides
1085 //        our      : outer radius
1086 //        t        : theta angle
1087 //
1088 // Output:
1089 //        x, y : coordinate vectors [24]
1090 //
1091 // Created:      14 Nov 2007  Mario Sitta
1092 // Updated:      11 Dec 2007  Mario Sitta
1093 //
1094   Double_t xlocal[6],ylocal[6];
1095
1096   //Create the first inner quadrant (X > 0)
1097   FillSPDXtruShape(ina,inb,inr,t,xlocal,ylocal);
1098   for (Int_t i=0; i<6; i++) {
1099     x[i] = xlocal[i];
1100     y[i] = ylocal[i];
1101   }
1102
1103   // Then reflex on the second quadrant (X < 0)
1104   for (Int_t i=0; i<6; i++) {
1105     x[23-i] = -x[i];
1106     y[23-i] =  y[i];
1107   }
1108
1109   // Now create the first outer quadrant (X > 0)
1110   FillSPDXtruShape(oua,oub,our,t,xlocal,ylocal);
1111   for (Int_t i=0; i<6; i++) {
1112     x[11-i] = xlocal[i];
1113     y[11-i] = ylocal[i];
1114   }
1115
1116   // Finally reflex on the second quadrant (X < 0)
1117   for (Int_t i=0; i<6; i++) {
1118     x[12+i] = -x[11-i];
1119     y[12+i] =  y[11-i];
1120   }
1121
1122   return;
1123 }
1124
1125 //______________________________________________________________________
1126 void AliITSv11GeometrySupport::CreateSPDOmegaShape(
1127                    const Double_t *xin, const Double_t *yin, Double_t  d,
1128                    Double_t   *x, Double_t *y)
1129 {
1130 //
1131 // Creates the proper sequence of X and Y coordinates to determine
1132 // the SPD Omega XTru polygon
1133 //
1134 // Input:
1135 //        xin, yin : coordinates of the air volume
1136 //        d        : Omega shape thickness
1137 //        t        : theta angle
1138 //
1139 // Output:
1140 //        x, y     : coordinate vectors [48]
1141 //
1142 // Created:      17 Nov 2007  Mario Sitta
1143 // Updated:      11 Dec 2007  Mario Sitta
1144 // Updated:      20 Feb 2009  Mario Sitta       New algorithm (the old one
1145 //                                              gives erroneous vertexes)
1146 //
1147
1148   // This vector contains the index of those points which coincide
1149   // with the corresponding points in the air shape
1150   Int_t indexAir2Omega[12] = {1, 2, 5, 6, 9, 10, 11, 15, 16, 19, 20, 23};
1151
1152   // First fill those vertexes corresponding to
1153   // the edges aligned to the air shape edges
1154   for (Int_t j=0; j<12; j++) {
1155     x[*(indexAir2Omega+j)] = xin[j];
1156     y[*(indexAir2Omega+j)] = yin[j];
1157   }
1158
1159   // Now get the coordinates of the first inner point
1160   PointFromParallelLines(x[23],y[23],x[1],y[1],d,x[0],y[0]);
1161
1162   // Knowing this, the second internal point can be determined
1163   InsidePoint(x[0],y[0],x[1],y[1],x[2],y[2],d,x[22],y[22]);
1164
1165   // The third point is now computable
1166   ReflectPoint(x[1],y[1],x[2],y[2],x[22],y[22],x[21],y[21]);
1167
1168   // Repeat this logic
1169   InsidePoint(x[21],y[21],x[20],y[20],x[19],y[19],-d,x[3],y[3]);
1170
1171   ReflectPoint(x[20],y[20],x[19],y[19],x[3],y[3],x[4],y[4]);
1172
1173   InsidePoint(x[4],y[4],x[5],y[5],x[6],y[6],d,x[18],y[18]);
1174
1175   ReflectPoint(x[5],y[5],x[6],y[6],x[18],y[18],x[17],y[17]);
1176
1177   InsidePoint(x[17],y[17],x[16],y[16],x[15],y[15],-d,x[7],y[7]);
1178
1179   ReflectPoint(x[16],y[16],x[15],y[15],x[7],y[7],x[8],y[8]);
1180
1181   InsidePoint(x[8],y[8],x[9],y[9],x[10],y[10],d,x[14],y[14]);
1182
1183   // These need to be fixed explicitly
1184   x[12] = x[11];
1185   y[12] = y[11] + d;
1186   x[13] = x[10] + d;
1187   y[13] = y[12];
1188
1189   // Finally reflect on the negative side
1190   for (Int_t i=0; i<24; i++) {
1191     x[24+i] = -x[23-i];
1192     y[24+i] =  y[23-i];
1193   }
1194
1195   // Wow ! We've finished
1196   return;
1197 }
1198
1199 //______________________________________________________________________
1200 void AliITSv11GeometrySupport::FillSPDXtruShape(Double_t a, Double_t b,
1201                                                 Double_t r, Double_t t,
1202                                                 Double_t *x, Double_t *y) const
1203 {
1204 //
1205 // Creates the partial sequence of X and Y coordinates to determine
1206 // the lateral part of the SPD thermal shield
1207 //
1208 // Input:
1209 //        a, b : shape sides
1210 //        r    : radius
1211 //        t    : theta angle
1212 //
1213 // Output:
1214 //        x, y : coordinate vectors [6]
1215 //
1216 // Created:      14 Nov 2007  Mario Sitta
1217 //
1218   x[0] = a/2;
1219   y[0] = r;
1220
1221   x[1] = x[0] + b * TMath::Cos(t/2);
1222   y[1] = y[0] - b * TMath::Sin(t/2);
1223
1224   x[2] = x[1] + a * TMath::Cos(t);
1225   y[2] = y[1] - a * TMath::Sin(t);
1226
1227   x[3] = x[2] + b * TMath::Cos(3*t/2);
1228   y[3] = y[2] - b * TMath::Sin(3*t/2);
1229
1230   x[4] = x[3] + a * TMath::Cos(2*t);
1231   y[4] = y[3] - a * TMath::Sin(2*t);
1232
1233   x[5] = x[4];
1234   y[5] = 0.;
1235
1236   return;
1237 }
1238
1239 //______________________________________________________________________
1240 void AliITSv11GeometrySupport::PointFromParallelLines(Double_t x1, Double_t y1,
1241                               Double_t x2, Double_t y2, Double_t d,
1242                               Double_t &x, Double_t &y) const
1243 {
1244 //
1245 // Determines the X and Y of the first internal point of the Omega shape
1246 // (i.e. the coordinates of a point given two parallel lines passing by
1247 // two points and placed at a known distance)
1248 //
1249 // Input:
1250 //        x1, y1 : first point
1251 //        x2, y2 : second point
1252 //        d      : distance between the two lines
1253 //
1254 // Output:
1255 //        x, y   : coordinate of the point
1256 //
1257 // Created:      22 Feb 2009  Mario Sitta
1258 //
1259 //Begin_Html
1260 /*
1261 <img src="ITS/doc/PointFromParallelLines.gif">
1262 */
1263 //End_Html
1264
1265   // The slope of the paralles lines at a distance d
1266   Double_t m; 
1267
1268   // The parameters of the solving equation
1269   // a x^2 - 2 b x + c = 0
1270   Double_t a = (x1 - x2)*(x1 - x2) - d*d;
1271   Double_t b = (x1 - x2)*(y1 - y2);
1272   Double_t c = (y1 - y2)*(y1 - y2) - d*d;
1273
1274   // (delta4 is Delta/4 because we use the reduced formula)
1275   Double_t delta4 = b*b - a*c;
1276
1277   // Compute the slope of the two parallel lines
1278   // (one of the two possible slopes, the one with the smaller
1279   // absolute value is needed)
1280   if (delta4 < 0) { // Should never happen with our data, but just to be sure
1281     x = -1;         // x is expected positive, so this flags an error
1282     return;
1283   } else
1284     m = (b + TMath::Sqrt(delta4))/a;  // b is negative with our data
1285
1286   // Finally compute the coordinates of the point
1287   x = x2 + (y1 - y2 - d)/m;
1288   y = y1 - d;
1289
1290   // Done
1291   return;
1292 }
1293
1294 //______________________________________________________________________
1295 void AliITSv11GeometrySupport::ReflectPoint(Double_t x1, Double_t y1,
1296                                             Double_t x2, Double_t y2,
1297                                             Double_t x3, Double_t y3,
1298                                             Double_t &x, Double_t &y) const
1299 {
1300 //
1301 // Given two points (x1,y1) and (x2,y2), determines the point (x,y)
1302 // lying on the line parallel to the line passing by these points,
1303 // at a distance d and passing by the point (x3,y3), which is symmetric to
1304 // the third point with respect to the axis of the segment delimited by
1305 // the two first points.
1306 //
1307 // Input:
1308 //        x1, y1 : first point
1309 //        x2, y2 : second point
1310 //        x3, y3 : third point
1311 //        d      : distance between the two lines
1312 //
1313 // Output:
1314 //        x, y   : coordinate of the reflected point
1315 //
1316 // Created:      22 Feb 2009  Mario Sitta
1317 //
1318 //Begin_Html
1319 /*
1320 <img src="ITS/doc/ReflectPoint.gif">
1321 */
1322 //End_Html
1323
1324   // The slope of the line passing by the first two points
1325   Double_t k = (y2 - y1)/(x2 - x1);
1326
1327   // The middle point of the segment 1-2
1328   Double_t xK = (x1 + x2)/2.;
1329   Double_t yK = (y1 + y2)/2.;
1330
1331   // The intercept between the axis of the segment 1-2 and the line
1332   // passing by 3 and parallel to the line passing by 1-2
1333   Double_t xH = (k*k*x3 + k*(yK - y3) + xK)/(k*k + 1);
1334   Double_t yH = k*(xH - x3) + y3;
1335
1336   // The point symmetric to 3 with respect to H
1337   x = 2*xH - x3;
1338   y = 2*yH - y3;
1339
1340   // Done
1341   return;
1342 }
1343
1344 //______________________________________________________________________
1345 void AliITSv11GeometrySupport::SDDCone(TGeoVolume *moth,const TGeoManager *mgr)
1346 {
1347 //
1348 // Creates the SDD support cone and cylinder geometry as a
1349 // volume assembly and adds it to the mother volume
1350 // (part of this code is taken or anyway inspired to SDDCone method
1351 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
1352 //
1353 // Input:
1354 //         moth : the TGeoVolume owing the volume structure
1355 //         mgr  : the GeoManager (default gGeoManager)
1356 // Output:
1357 //
1358 // Created:         ???       Bjorn S. Nilsen
1359 // Updated:      18 Feb 2008  Mario Sitta
1360 // Updated:      25 Jul 2008  Mario Sitta   SDDCarbonFiberCone simpler
1361 // Updated:      10 Jun 2010  Mario Sitta   Cables across cone holes added
1362 //
1363 // Technical data are taken from:  "Supporto Generale Settore SDD"
1364 // (technical drawings ALR-0816/1-B), "Supporto Globale Settore SDD"
1365 // (technical drawings ALR-0816/2A, ALR-0816/2B, ALR-0816/2C, ALR-0816/2D), 
1366 // private communication with B. Giraudo
1367
1368   // Dimensions of the Central cylinder and flanges
1369   const Double_t kCylinderHalfLength = (790.0/2)*fgkmm;
1370   const Double_t kCylinderInnerR     = (210.0/2)*fgkmm;
1371   const Double_t kCylinderOuterR     = (231.0/2)*fgkmm;
1372   const Double_t kFlangeHalfLength   = ( 15.0/2)*fgkmm;
1373   const Double_t kFlangeInnerR       = (210.5/2)*fgkmm;
1374   const Double_t kFlangeOuterR       = (230.5/2)*fgkmm;
1375   const Double_t kInsertoHalfLength  =
1376                                      kCylinderHalfLength - 2*kFlangeHalfLength;
1377 //  const Double_t kCFThickness        = kFlangeInnerR - kCylinderInnerR;
1378   const Double_t kBoltDiameter       =       6.0*fgkmm; // M6 screw
1379   const Double_t kBoltDepth          =       6.0*fgkmm; // In the flange
1380   const Double_t kBoltRadius         = (220.0/2)*fgkmm; // Radius in flange
1381   const Double_t kThetaBolt          =      30.0*fgkDegree;
1382   const Int_t    kNBolts             = (Int_t)(360.0/kThetaBolt);
1383   // Dimensions of the Cone
1384   const Double_t kConeROutMin        = (540.0/2)*fgkmm;
1385   const Double_t kConeROutMax        = (560.0/2)*fgkmm;
1386   const Double_t kConeRCurv          =      10.0*fgkmm; // Radius of curvature
1387   const Double_t kConeRinMin         = (210.0/2)*fgkmm;
1388 //  const Double_t kConeRinMax         = (216.0/2)*fgkmm;
1389   const Double_t kConeRinCylinder    = (231.0/2)*fgkmm;
1390   const Double_t kConeZCylinder      =     192.0*fgkmm;
1391   const Double_t kConeZOuterMilled   =      23.0*fgkmm;
1392   const Double_t kConeDZin           =      15.0*fgkmm; // ???
1393   const Double_t kConeThickness      =      10.0*fgkmm; // Rohacell + Carb.Fib.
1394   const Double_t kConeTheta          =      45.0*fgkDegree; // SDD cone angle
1395   const Double_t kSinConeTheta       =
1396                                      TMath::Sin(kConeTheta*TMath::DegToRad());
1397   const Double_t kCosConeTheta       =
1398                                      TMath::Cos(kConeTheta*TMath::DegToRad());
1399   const Double_t kTanConeTheta       =
1400                                      TMath::Tan(kConeTheta*TMath::DegToRad());
1401   // Dimensions of the Cone Inserts
1402   const Double_t kConeCFThickness    =       1.5*fgkmm;//Carbon fiber thickness
1403   // Dimensions of the Cone Holes
1404   const Double_t kHole1RMin          = (450.0/2)*fgkmm;
1405   const Double_t kHole1RMax          = (530.0/2)*fgkmm;
1406   const Double_t kHole2RMin          = (280.0/2)*fgkmm;
1407   const Double_t kHole2RMax          = (375.0/2)*fgkmm;
1408   const Double_t kHole1Phi           =      25.0*fgkDegree;
1409   const Double_t kHole2Phi           =      50.0*fgkDegree;
1410   const Double_t kHole3RMin          =     205.0*fgkmm;
1411   const Double_t kHole3DeltaR        =        15*fgkmm;
1412   const Double_t kHole3Width         =        30*fgkmm;
1413   const Int_t    kNHole3             =         6      ;
1414   const Double_t kHole4RMin          =     116.0*fgkmm;
1415   const Double_t kHole4DeltaR        =        15*fgkmm;
1416   const Double_t kHole4Width         =        30*fgkmm;
1417   //  const Int_t    kNHole4             =         3      ;
1418   // Fraction of materials in holes
1419   const Double_t kHolePlasticFrac    =       0.55846;
1420   const Double_t kHoleCuFrac         =       0.06319;
1421   const Double_t kHoleGlassFrac      =       0.02652;
1422
1423   // Local variables
1424   Double_t x, y, z, t, dza, rmin, rmax;
1425
1426
1427   // Recover the needed materials
1428   TGeoMedium *medSDDcf    = mgr->GetMedium("ITS_SDD C (M55J)$");
1429   TGeoMedium *medSDDair   = mgr->GetMedium("ITS_SDD AIR$");
1430   TGeoMedium *medSDDste   = mgr->GetMedium("ITS_G10FR4$"); // stesalite
1431   TGeoMedium *medSDDroh   = mgr->GetMedium("ITS_ROHACELL$");
1432   TGeoMedium *medSDDss    = mgr->GetMedium("ITS_INOX$");
1433   TGeoMedium *medSDDplast = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
1434   TGeoMedium *medSDDCu    = mgr->GetMedium("ITS_COPPER$");
1435   TGeoMedium *medSDDglass = mgr->GetMedium("ITS_SDD OPTICFIB$");
1436
1437   // First define the geometrical shapes
1438
1439   // Central cylinder with its internal foam and the lateral flanges:
1440   // a carbon fiber Tube which contains a rohacell Tube and two
1441   // stesalite Tube's
1442   TGeoTube *cylindershape = new TGeoTube(kCylinderInnerR,kCylinderOuterR,
1443                                          kCylinderHalfLength);
1444
1445   TGeoTube *insertoshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
1446                                         kInsertoHalfLength);
1447
1448   TGeoTube *flangeshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
1449                                        kFlangeHalfLength);
1450
1451   // The flange bolt: it is a Tube
1452   TGeoTube *boltshape = new TGeoTube(0.0, 0.5*kBoltDiameter, 0.5*kBoltDepth);
1453
1454   // Debug if requested
1455   if (GetDebug(1)) {
1456     cylindershape->InspectShape();
1457     insertoshape->InspectShape();
1458     flangeshape->InspectShape();
1459     boltshape->InspectShape();
1460   }
1461
1462
1463   // We have the shapes: now create the real volumes
1464
1465   TGeoVolume *cfcylinder = new TGeoVolume("SDDCarbonFiberCylinder",
1466                                           cylindershape,medSDDcf);
1467   cfcylinder->SetVisibility(kTRUE);
1468   cfcylinder->SetLineColor(4); // Blue
1469   cfcylinder->SetLineWidth(1);
1470   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
1471   cfcylinder->SetFillStyle(4000); // 0% transparent
1472
1473   TGeoVolume *foamcylinder = new TGeoVolume("SDDFoamCylinder",
1474                                             insertoshape,medSDDroh);
1475   foamcylinder->SetVisibility(kTRUE);
1476   foamcylinder->SetLineColor(3); // Green
1477   foamcylinder->SetLineWidth(1);
1478   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
1479   foamcylinder->SetFillStyle(4050); // 50% transparent
1480
1481   TGeoVolume *flangecylinder = new TGeoVolume("SDDFlangeCylinder",
1482                                               flangeshape,medSDDste);
1483   flangecylinder->SetVisibility(kTRUE);
1484   flangecylinder->SetLineColor(2); // Red
1485   flangecylinder->SetLineWidth(1);
1486   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
1487   flangecylinder->SetFillStyle(4050); // 50% transparent
1488
1489   TGeoVolume *bolt = new TGeoVolume("SDDFlangeBolt",boltshape,medSDDss);
1490   bolt->SetVisibility(kTRUE);
1491   bolt->SetLineColor(1);  // Black
1492   bolt->SetLineWidth(1);
1493   bolt->SetFillColor(bolt->GetLineColor());
1494   bolt->SetFillStyle(4050); // 50% transparent
1495
1496   // Mount up the cylinder
1497   for(Int_t i=0; i<kNBolts; i++){
1498     t = kThetaBolt*i;
1499     x = kBoltRadius*CosD(t);
1500     y = kBoltRadius*SinD(t);
1501     z = kFlangeHalfLength-kBoltDepth;
1502     flangecylinder->AddNode(bolt, i+1, new TGeoTranslation("",x,y,z));
1503   }
1504
1505   cfcylinder->AddNode(foamcylinder,1,0);
1506   cfcylinder->AddNode(flangecylinder,1,
1507               new TGeoTranslation(0, 0, kInsertoHalfLength+kFlangeHalfLength));
1508   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
1509               0, 0, -kInsertoHalfLength-kFlangeHalfLength,
1510               new TGeoRotation("",0,180,0)     ) );
1511
1512
1513   // SDD Support Cone with its internal inserts: a carbon fiber Pcon
1514   // with holes which contains a stesalite Pcon which on turn contains a
1515   // rohacell Pcon
1516
1517   dza = kConeThickness/kSinConeTheta-(kConeROutMax-kConeROutMin)/kTanConeTheta;
1518
1519   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 10);
1520
1521   coneshape->Z(0)     = 0.0;
1522   coneshape->Rmin(0)  = kConeROutMin;
1523   coneshape->Rmax(0)  = kConeROutMax;
1524
1525   coneshape->Z(1)     = kConeZOuterMilled - dza;
1526   coneshape->Rmin(1)  = coneshape->GetRmin(0);
1527   coneshape->Rmax(1)  = coneshape->GetRmax(0);
1528
1529   coneshape->Z(2)     = kConeZOuterMilled;
1530   coneshape->Rmax(2)  = coneshape->GetRmax(0);
1531
1532   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(1),
1533                     coneshape->GetRmin(1),kConeTheta,z,rmin);
1534   coneshape->Z(3)     = z;
1535   coneshape->Rmin(3)  = rmin;
1536
1537   coneshape->Rmin(2)  = RminFrom2Points(coneshape,3,1,coneshape->GetZ(2));
1538
1539   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(2),
1540                     coneshape->GetRmax(2),kConeTheta,z,rmax);
1541   coneshape->Z(4)     = z;
1542   coneshape->Rmax(4)  = rmax;
1543   coneshape->Rmin(4)  = RminFromZpCone(coneshape,3,kConeTheta,
1544                                        coneshape->GetZ(4),0.0);
1545
1546   coneshape->Rmax(3)  = RmaxFrom2Points(coneshape,4,2,coneshape->GetZ(3));
1547
1548   coneshape->Z(6)     = kConeZCylinder - kConeDZin;
1549
1550   RadiusOfCurvature(kConeRCurv,90.0,coneshape->GetZ(6),0.0,
1551                     90.0-kConeTheta,z,rmin);
1552   coneshape->Z(5)     = z;
1553   coneshape->Rmin(5)  = RminFromZpCone(coneshape,3,kConeTheta,z);
1554   coneshape->Rmax(5)  = RmaxFromZpCone(coneshape,4,kConeTheta,z);
1555
1556   RadiusOfCurvature(kConeRCurv,90.-kConeTheta,
1557                     0.0,coneshape->Rmin(5),90.0,z,rmin);
1558   coneshape->Rmin(6)  = rmin;
1559   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,4,kConeTheta,
1560                                        coneshape->GetZ(6));
1561
1562   coneshape->Z(7)     = coneshape->GetZ(6);
1563   coneshape->Rmin(7)  = kConeRinMin;
1564   coneshape->Rmax(7)  = coneshape->GetRmax(6);
1565
1566   coneshape->Rmin(8)  = kConeRinMin;
1567
1568   RadiusOfCurvature(kConeRCurv,90.0,kConeZCylinder,kConeRinCylinder,
1569                     90.0-kConeTheta,z,rmax);
1570   coneshape->Z(8)     = z;
1571   coneshape->Rmax(8)  = rmax;
1572
1573   coneshape->Z(9)     = kConeZCylinder;
1574   coneshape->Rmin(9)  = kConeRinMin;
1575   coneshape->Rmax(9)  = kConeRinCylinder;
1576
1577
1578   // SDD Cone Insert: another Pcon
1579   Double_t x0, y0, x1, y1, x2, y2;
1580   TGeoPcon *coneinsertshape = new TGeoPcon(0.0, 360.0, 9);
1581
1582   coneinsertshape->Z(0)    = coneshape->GetZ(0) + kConeCFThickness;
1583   coneinsertshape->Rmin(0) = coneshape->GetRmin(0) + kConeCFThickness;
1584   coneinsertshape->Rmax(0) = coneshape->GetRmax(0) - kConeCFThickness;
1585
1586   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1587   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1588   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1589   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1590   coneinsertshape->Z(1)    = z;
1591   coneinsertshape->Rmin(1) = rmin;
1592   coneinsertshape->Rmax(1) = coneinsertshape->GetRmax(0);
1593
1594   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmax(1);
1595   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmax(2);
1596   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmax(3);
1597   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1598   coneinsertshape->Z(2)    = z;
1599   coneinsertshape->Rmax(2) = rmax;
1600
1601   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1602   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1603   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1604   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1605   coneinsertshape->Z(3)    = z;
1606   coneinsertshape->Rmin(3) = rmin;
1607
1608   x0 = coneinsertshape->GetZ(1); y0 = coneinsertshape->GetRmin(1);
1609   x1 = coneinsertshape->GetZ(3); y1 = coneinsertshape->GetRmin(3);
1610   coneinsertshape->Rmin(2) = Yfrom2Points(x0, y0, x1, y1,
1611                                           coneinsertshape->Z(2));
1612
1613   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
1614   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
1615   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
1616   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1617   coneinsertshape->Z(4)    = z;
1618   coneinsertshape->Rmax(4) = rmax;
1619
1620   x0 = coneinsertshape->GetZ(2); y0 = coneinsertshape->GetRmax(2);
1621   x1 = coneinsertshape->GetZ(4); y1 = coneinsertshape->GetRmax(4);
1622   coneinsertshape->Rmax(3) = Yfrom2Points(x0, y0, x1, y1,
1623                                           coneinsertshape->Z(3));
1624
1625   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmin(4);
1626   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmin(5);
1627   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmin(6);
1628   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1629   coneinsertshape->Z(5)    = z;
1630   coneinsertshape->Rmin(5) = rmin;
1631   coneinsertshape->Rmax(5) = coneinsertshape->GetRmax(4) -
1632           kTanConeTheta*(coneinsertshape->GetZ(5) - coneinsertshape->GetZ(4));
1633
1634   x0 = coneinsertshape->GetZ(3); y0 = coneinsertshape->GetRmin(3);
1635   x1 = coneinsertshape->GetZ(5); y1 = coneinsertshape->GetRmin(5);
1636   coneinsertshape->Rmin(4) = Yfrom2Points(x0, y0, x1, y1,
1637                                           coneinsertshape->Z(4));
1638
1639   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmin(5);
1640   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmin(6);
1641   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmin(7);
1642   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1643   coneinsertshape->Z(6)    = z;
1644   coneinsertshape->Rmin(6) = rmin;
1645   coneinsertshape->Rmax(6) = coneinsertshape->GetRmax(4) -
1646           kTanConeTheta*(coneinsertshape->GetZ(6) - coneinsertshape->GetZ(4));
1647
1648   coneinsertshape->Z(7)    = coneinsertshape->GetZ(6);
1649   coneinsertshape->Rmin(7) = coneshape->GetRmin(7) + kConeCFThickness;
1650   coneinsertshape->Rmax(7) = coneinsertshape->GetRmax(6);
1651
1652   coneinsertshape->Z(8)    = coneshape->GetZ(9) - kConeCFThickness;
1653   coneinsertshape->Rmin(8) = coneinsertshape->GetRmin(7);
1654   coneinsertshape->Rmax(8) = coneinsertshape->GetRmax(4) -
1655           kTanConeTheta*(coneinsertshape->GetZ(8) - coneinsertshape->GetZ(4));
1656
1657   // SDD Cone Foam: another Pcon
1658   TGeoPcon *conefoamshape = new TGeoPcon(0.0, 360.0, 4);
1659
1660   RadiusOfCurvature(kConeRCurv+kConeCFThickness,0.0,coneinsertshape->GetZ(1),
1661                     coneinsertshape->GetRmin(1),kConeTheta,z,rmin);
1662
1663   conefoamshape->Z(0)    = z;
1664   conefoamshape->Rmin(0) = rmin;
1665   conefoamshape->Rmax(0) = conefoamshape->GetRmin(0);
1666
1667   conefoamshape->Z(1)    = conefoamshape->GetZ(0)+
1668                          (kConeThickness-2.0*kConeCFThickness)/kSinConeTheta;
1669   conefoamshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1670                                           conefoamshape->GetZ(1));
1671   conefoamshape->Rmax(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1672                                           conefoamshape->GetZ(1));
1673
1674   conefoamshape->Z(2)    = coneshape->GetZ(5)-kConeCFThickness;
1675   conefoamshape->Rmin(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1676                                           conefoamshape->GetZ(2));
1677   conefoamshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1678                                           conefoamshape->GetZ(2));
1679
1680   conefoamshape->Z(3)    = coneinsertshape->GetZ(5)+
1681                          (kConeThickness-2.0*kConeCFThickness)*kCosConeTheta;
1682   conefoamshape->Rmax(3) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1683                                           conefoamshape->GetZ(3));
1684   conefoamshape->Rmin(3) = conefoamshape->GetRmax(3);
1685
1686   // SDD Cone Holes: Pcon's
1687   // A single hole volume gives an overlap with coneinsert, so
1688   // three contiguous volumes are created: one to be put in the cone foam
1689   // and two in the cone carbon fiber envelope
1690   TGeoPcon *hole1shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1691
1692   hole1shape->Rmin(0) = kHole1RMax;
1693   hole1shape->Rmax(0) = hole1shape->GetRmin(0);
1694   hole1shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1695                                        hole1shape->GetRmin(0));
1696
1697   hole1shape->Rmax(1) = hole1shape->GetRmax(0);
1698   hole1shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1699                                        hole1shape->GetRmax(1));
1700   hole1shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1701                                        hole1shape->GetZ(1));
1702
1703   hole1shape->Rmin(2) = kHole1RMin;
1704   hole1shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1705                                        hole1shape->GetRmin(2));
1706   hole1shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1707                                        hole1shape->GetZ(2));
1708
1709   hole1shape->Rmin(3) = hole1shape->GetRmin(2);
1710   hole1shape->Rmax(3) = hole1shape->GetRmin(3);
1711   hole1shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1712                                        hole1shape->GetRmax(3));
1713
1714   TGeoPcon *hole11shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1715
1716   hole11shape->Rmin(0) = kHole1RMax;
1717   hole11shape->Rmax(0) = hole11shape->GetRmin(0);
1718   hole11shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1719                                         hole11shape->GetRmin(0));
1720
1721   hole11shape->Rmax(1) = hole11shape->GetRmax(0);
1722   hole11shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1723                                         hole11shape->GetRmax(1));
1724   hole11shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1725                                         hole11shape->GetZ(1));
1726
1727   hole11shape->Rmin(2) = kHole1RMin;
1728   hole11shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1729                                         hole11shape->GetRmin(2));
1730   hole11shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1731                                         hole11shape->GetZ(2));
1732
1733   hole11shape->Rmin(3) = hole11shape->GetRmin(2);
1734   hole11shape->Rmax(3) = hole11shape->GetRmin(3);
1735   hole11shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1736                                         hole11shape->GetRmax(3));
1737
1738   TGeoPcon *hole12shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1739
1740   hole12shape->Rmin(0) = kHole1RMax;
1741   hole12shape->Rmax(0) = hole12shape->GetRmin(0);
1742   hole12shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1743                                         hole12shape->GetRmin(0));
1744
1745   hole12shape->Rmax(1) = hole12shape->GetRmax(0);
1746   hole12shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1747                                         hole12shape->GetRmax(1));
1748   hole12shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1749                                         hole12shape->GetZ(1));
1750
1751   hole12shape->Rmin(2) = kHole1RMin;
1752   hole12shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1753                                         hole12shape->GetRmin(2));
1754   hole12shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1755                                         hole12shape->GetZ(2));
1756
1757   hole12shape->Rmin(3) = hole12shape->GetRmin(2);
1758   hole12shape->Rmax(3) = hole12shape->GetRmin(3);
1759   hole12shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1760                                         hole12shape->GetRmax(3));
1761
1762   //
1763   TGeoPcon *hole2shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1764
1765   hole2shape->Rmin(0) = kHole2RMax;
1766   hole2shape->Rmax(0) = hole2shape->GetRmin(0);
1767   hole2shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1768                                        hole2shape->GetRmin(0));
1769
1770   hole2shape->Rmax(1) = hole2shape->GetRmax(0);
1771   hole2shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1772                                        hole2shape->GetRmax(1));
1773   hole2shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1774                                        hole2shape->GetZ(1));
1775
1776   hole2shape->Rmin(2) = kHole2RMin;
1777   hole2shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1778                                        hole2shape->GetRmin(2));
1779   hole2shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1780                                        hole2shape->GetZ(2));
1781
1782   hole2shape->Rmin(3) = hole2shape->GetRmin(2);
1783   hole2shape->Rmax(3) = hole2shape->GetRmin(3);
1784   hole2shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1785                                        hole2shape->GetRmax(3));
1786
1787   TGeoPcon *hole21shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1788
1789   hole21shape->Rmin(0) = kHole2RMax;
1790   hole21shape->Rmax(0) = hole21shape->GetRmin(0);
1791   hole21shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1792                                         hole21shape->GetRmin(0));
1793
1794   hole21shape->Rmax(1) = hole21shape->GetRmax(0);
1795   hole21shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1796                                         hole21shape->GetRmax(1));
1797   hole21shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1798                                         hole21shape->GetZ(1));
1799
1800   hole21shape->Rmin(2) = kHole2RMin;
1801   hole21shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1802                                         hole21shape->GetRmin(2));
1803   hole21shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1804                                         hole21shape->GetZ(2));
1805
1806   hole21shape->Rmin(3) = hole21shape->GetRmin(2);
1807   hole21shape->Rmax(3) = hole21shape->GetRmin(3);
1808   hole21shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1809                                         hole21shape->GetRmax(3));
1810
1811   TGeoPcon *hole22shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1812
1813   hole22shape->Rmin(0) = kHole2RMax;
1814   hole22shape->Rmax(0) = hole22shape->GetRmin(0);
1815   hole22shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1816                                         hole22shape->GetRmin(0));
1817
1818   hole22shape->Rmax(1) = hole22shape->GetRmax(0);
1819   hole22shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1820                                         hole22shape->GetRmax(1));
1821   hole22shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1822                                         hole22shape->GetZ(1));
1823
1824   hole22shape->Rmin(2) = kHole2RMin;
1825   hole22shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1826                                         hole22shape->GetRmin(2));
1827   hole22shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1828                                         hole22shape->GetZ(2));
1829
1830   hole22shape->Rmin(3) = hole22shape->GetRmin(2);
1831   hole22shape->Rmax(3) = hole22shape->GetRmin(3);
1832   hole22shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1833                                         hole22shape->GetRmax(3));
1834
1835   //
1836   Double_t holePhi;
1837   holePhi = (kHole3Width/kHole3RMin)*TMath::RadToDeg();
1838
1839   TGeoPcon *hole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1840
1841   hole3shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1842   hole3shape->Rmax(0) = hole3shape->GetRmin(0);
1843   hole3shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1844                                        hole3shape->GetRmin(0));
1845
1846   hole3shape->Rmax(1) = hole3shape->GetRmax(0);
1847   hole3shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1848                                        hole3shape->GetRmax(1));
1849   hole3shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1850                                        hole3shape->GetZ(1));
1851
1852   hole3shape->Rmin(2) = kHole3RMin;
1853   hole3shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1854                                        hole3shape->GetRmin(2));
1855   hole3shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1856                                        hole3shape->GetZ(2));
1857
1858   hole3shape->Rmin(3) = hole3shape->GetRmin(2);
1859   hole3shape->Rmax(3) = hole3shape->GetRmin(3);
1860   hole3shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1861                                        hole3shape->GetRmax(3));
1862
1863   TGeoPcon *hole31shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1864
1865   hole31shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1866   hole31shape->Rmax(0) = hole31shape->GetRmin(0);
1867   hole31shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1868                                         hole31shape->GetRmin(0));
1869
1870   hole31shape->Rmax(1) = hole31shape->GetRmax(0);
1871   hole31shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1872                                         hole31shape->GetRmax(1));
1873   hole31shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1874                                         hole31shape->GetZ(1));
1875
1876   hole31shape->Rmin(2) = kHole3RMin;
1877   hole31shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1878                                         hole31shape->GetRmin(2));
1879   hole31shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1880                                         hole31shape->GetZ(2));
1881
1882   hole31shape->Rmin(3) = hole31shape->GetRmin(2);
1883   hole31shape->Rmax(3) = hole31shape->GetRmin(3);
1884   hole31shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1885                                         hole31shape->GetRmax(3));
1886
1887   TGeoPcon *hole32shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1888
1889   hole32shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1890   hole32shape->Rmax(0) = hole32shape->GetRmin(0);
1891   hole32shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1892                                         hole32shape->GetRmin(0));
1893
1894   hole32shape->Rmax(1) = hole32shape->GetRmax(0);
1895   hole32shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1896                                         hole32shape->GetRmax(1));
1897   hole32shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1898                                         hole32shape->GetZ(1));
1899
1900   hole32shape->Rmin(2) = kHole3RMin;
1901   hole32shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1902                                         hole32shape->GetRmin(2));
1903   hole32shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1904                                         hole32shape->GetZ(2));
1905
1906   hole32shape->Rmin(3) = hole32shape->GetRmin(2);
1907   hole32shape->Rmax(3) = hole32shape->GetRmin(3);
1908   hole32shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1909                                         hole32shape->GetRmax(3));
1910
1911   //
1912   holePhi = (kHole4Width/kHole4RMin)*TMath::RadToDeg();
1913
1914   TGeoPcon *hole4shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1915
1916   hole4shape->Rmin(0) = kHole4RMin + kHole4DeltaR;
1917   hole4shape->Rmax(0) = hole4shape->GetRmin(0);
1918   hole4shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1919                                        hole4shape->GetRmin(0));
1920
1921   hole4shape->Rmax(1) = hole4shape->GetRmax(0);
1922   hole4shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1923                                        hole4shape->GetRmax(1));
1924   hole4shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1925                                        hole4shape->GetZ(1));
1926
1927   hole4shape->Rmin(2) = kHole4RMin;
1928   hole4shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1929                                        hole4shape->GetRmin(2));
1930   hole4shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1931                                        hole4shape->GetZ(2));
1932
1933   hole4shape->Rmin(3) = hole4shape->GetRmin(2);
1934   hole4shape->Rmax(3) = hole4shape->GetRmin(3);
1935   hole4shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1936                                        hole4shape->GetRmax(3));
1937
1938   // Cables to be put inside the holes: Pcon's
1939   // (fractions are manually computed from AliITSv11GeometrySDD::SDDCables
1940   TGeoPcon *hole1plastshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1941
1942   hole1plastshape->Rmin(0) = hole1shape->GetRmin(0);
1943   hole1plastshape->Rmax(0) = hole1shape->GetRmax(0);
1944   hole1plastshape->Z(0)    = hole1shape->GetZ(0);
1945
1946   hole1plastshape->Rmin(1) = hole1shape->GetRmin(1);
1947   hole1plastshape->Rmax(1) = hole1shape->GetRmax(1);
1948   hole1plastshape->Z(1)    = hole1shape->GetZ(1);
1949
1950   dza = hole1plastshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHolePlasticFrac;
1951
1952   hole1plastshape->Rmin(2) = dza;
1953   hole1plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1954                                             hole1plastshape->GetRmin(2));
1955   hole1plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1956                                             hole1plastshape->GetZ(2));
1957
1958   hole1plastshape->Rmin(3) = hole1plastshape->GetRmin(2);
1959   hole1plastshape->Rmax(3) = hole1plastshape->GetRmin(3);
1960   hole1plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1961                                             hole1plastshape->GetRmax(3));
1962
1963   TGeoPcon *hole1Cushape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1964
1965   hole1Cushape->Rmin(0) = hole1plastshape->GetRmin(2);
1966   hole1Cushape->Rmax(0) = hole1Cushape->GetRmin(0);
1967   hole1Cushape->Z(0)    = hole1plastshape->GetZ(2);
1968
1969   dza = hole1Cushape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleCuFrac;
1970
1971   hole1Cushape->Rmin(1) = dza;
1972   hole1Cushape->Rmax(1) = hole1Cushape->GetRmax(0);
1973   hole1Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1974                                          hole1Cushape->GetRmin(1));
1975
1976   hole1Cushape->Rmax(2) = hole1Cushape->GetRmax(0);
1977   hole1Cushape->Rmin(2) = hole1Cushape->GetRmin(1);
1978   hole1Cushape->Z(2)    = hole1plastshape->GetZ(3);
1979
1980   hole1Cushape->Rmin(3) = hole1Cushape->GetRmin(1);
1981   hole1Cushape->Rmax(3) = hole1Cushape->GetRmin(3);
1982   hole1Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1983                                          hole1Cushape->GetRmax(3));
1984
1985   TGeoPcon *hole1glassshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1986
1987   hole1glassshape->Rmin(0) = hole1Cushape->GetRmin(1);
1988   hole1glassshape->Rmax(0) = hole1glassshape->GetRmin(0);
1989   hole1glassshape->Z(0)    = hole1Cushape->GetZ(1);
1990
1991   dza = hole1glassshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleGlassFrac;
1992
1993   hole1glassshape->Rmin(1) = dza;
1994   hole1glassshape->Rmax(1) = hole1glassshape->GetRmax(0);
1995   hole1glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1996                                             hole1glassshape->GetRmin(1));
1997
1998   hole1glassshape->Rmax(2) = hole1glassshape->GetRmax(0);
1999   hole1glassshape->Rmin(2) = hole1glassshape->GetRmin(1);
2000   hole1glassshape->Z(2)    = hole1Cushape->GetZ(3);
2001
2002   hole1glassshape->Rmin(3) = hole1glassshape->GetRmin(1);
2003   hole1glassshape->Rmax(3) = hole1glassshape->GetRmin(3);
2004   hole1glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2005                                             hole1glassshape->GetRmax(3));
2006   //
2007   TGeoPcon *hole2plastshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2008
2009   hole2plastshape->Rmin(0) = hole2shape->GetRmin(0);
2010   hole2plastshape->Rmax(0) = hole2shape->GetRmax(0);
2011   hole2plastshape->Z(0)    = hole2shape->GetZ(0);
2012
2013   hole2plastshape->Rmin(1) = hole2shape->GetRmin(1);
2014   hole2plastshape->Rmax(1) = hole2shape->GetRmax(1);
2015   hole2plastshape->Z(1)    = hole2shape->GetZ(1);
2016
2017   dza = hole2plastshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHolePlasticFrac;
2018
2019   hole2plastshape->Rmin(2) = dza;
2020   hole2plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2021                                             hole2plastshape->GetRmin(2));
2022   hole2plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
2023                                             hole2plastshape->GetZ(2));
2024
2025   hole2plastshape->Rmin(3) = hole2plastshape->GetRmin(2);
2026   hole2plastshape->Rmax(3) = hole2plastshape->GetRmin(3);
2027   hole2plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2028                                             hole2plastshape->GetRmax(3));
2029
2030   TGeoPcon *hole2Cushape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2031
2032   hole2Cushape->Rmin(0) = hole2plastshape->GetRmin(2);
2033   hole2Cushape->Rmax(0) = hole2Cushape->GetRmin(0);
2034   hole2Cushape->Z(0)    = hole2plastshape->GetZ(2);
2035
2036   dza = hole2Cushape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleCuFrac;
2037
2038   hole2Cushape->Rmin(1) = dza;
2039   hole2Cushape->Rmax(1) = hole2Cushape->GetRmax(0);
2040   hole2Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2041                                          hole2Cushape->GetRmin(1));
2042
2043   hole2Cushape->Rmax(2) = hole2Cushape->GetRmax(0);
2044   hole2Cushape->Rmin(2) = hole2Cushape->GetRmin(1);
2045   hole2Cushape->Z(2)    = hole2plastshape->GetZ(3);
2046
2047   hole2Cushape->Rmin(3) = hole2Cushape->GetRmin(1);
2048   hole2Cushape->Rmax(3) = hole2Cushape->GetRmin(3);
2049   hole2Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2050                                          hole2Cushape->GetRmax(3));
2051
2052   TGeoPcon *hole2glassshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2053
2054   hole2glassshape->Rmin(0) = hole2Cushape->GetRmin(1);
2055   hole2glassshape->Rmax(0) = hole2glassshape->GetRmin(0);
2056   hole2glassshape->Z(0)    = hole2Cushape->GetZ(1);
2057
2058   dza = hole2glassshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleGlassFrac;
2059
2060   hole2glassshape->Rmin(1) = dza;
2061   hole2glassshape->Rmax(1) = hole2glassshape->GetRmax(0);
2062   hole2glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2063                                             hole2glassshape->GetRmin(1));
2064
2065   hole2glassshape->Rmax(2) = hole2glassshape->GetRmax(0);
2066   hole2glassshape->Rmin(2) = hole2glassshape->GetRmin(1);
2067   hole2glassshape->Z(2)    = hole2Cushape->GetZ(3);
2068
2069   hole2glassshape->Rmin(3) = hole2glassshape->GetRmin(1);
2070   hole2glassshape->Rmax(3) = hole2glassshape->GetRmin(3);
2071   hole2glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2072                                             hole2glassshape->GetRmax(3));
2073
2074
2075   // Debug if requested
2076   if (GetDebug(1)) {
2077     coneshape->InspectShape();
2078     coneinsertshape->InspectShape();
2079     conefoamshape->InspectShape();
2080     hole1shape->InspectShape();
2081     hole2shape->InspectShape();
2082     hole3shape->InspectShape();
2083     hole4shape->InspectShape();
2084   }
2085
2086
2087   // We have the shapes: now create the real volumes
2088
2089   TGeoVolume *cfcone = new TGeoVolume("SDDCarbonFiberCone",
2090                                       coneshape,medSDDcf);
2091   cfcone->SetVisibility(kTRUE);
2092   cfcone->SetLineColor(4); // Blue
2093   cfcone->SetLineWidth(1);
2094   cfcone->SetFillColor(cfcone->GetLineColor());
2095   cfcone->SetFillStyle(4000); // 0% transparent
2096
2097   TGeoVolume *cfconeinsert = new TGeoVolume("SDDCarbonFiberConeInsert",
2098                                             coneinsertshape,medSDDste);
2099   cfconeinsert->SetVisibility(kTRUE);
2100   cfconeinsert->SetLineColor(2); // Red
2101   cfconeinsert->SetLineWidth(1);
2102   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2103   cfconeinsert->SetFillStyle(4050); // 50% transparent
2104
2105   TGeoVolume *cfconefoam = new TGeoVolume("SDDCarbonFiberConeFoam",
2106                                           conefoamshape,medSDDroh);
2107   cfconefoam->SetVisibility(kTRUE);
2108   cfconefoam->SetLineColor(7); // Light blue
2109   cfconefoam->SetLineWidth(1);
2110   cfconefoam->SetFillColor(cfconefoam->GetLineColor());
2111   cfconefoam->SetFillStyle(4050); // 50% transparent
2112
2113   TGeoVolume *hole1 = new TGeoVolume("SDDCableHole1",
2114                                      hole1shape,medSDDair);
2115   hole1->SetVisibility(kTRUE);
2116   hole1->SetLineColor(5); // Yellow
2117   hole1->SetLineWidth(1);
2118   hole1->SetFillColor(hole1->GetLineColor());
2119   hole1->SetFillStyle(4090); // 90% transparent
2120
2121   TGeoVolume *hole11 = new TGeoVolume("SDDCableHole11",
2122                                       hole11shape,medSDDair);
2123   hole11->SetVisibility(kTRUE);
2124   hole11->SetLineColor(5); // Yellow
2125   hole11->SetLineWidth(1);
2126   hole11->SetFillColor(hole11->GetLineColor());
2127   hole11->SetFillStyle(4090); // 90% transparent
2128
2129   TGeoVolume *hole12 = new TGeoVolume("SDDCableHole12",
2130                                       hole12shape,medSDDair);
2131   hole12->SetVisibility(kTRUE);
2132   hole12->SetLineColor(5); // Yellow
2133   hole12->SetLineWidth(1);
2134   hole12->SetFillColor(hole12->GetLineColor());
2135   hole12->SetFillStyle(4090); // 90% transparent
2136
2137   TGeoVolume *hole1plast = new TGeoVolume("SDDCableHole1Plast",
2138                                           hole1plastshape,medSDDplast);
2139   hole1plast->SetVisibility(kTRUE);
2140   hole1plast->SetLineColor(kBlue);
2141   hole1plast->SetLineWidth(1);
2142   hole1plast->SetFillColor(hole1plast->GetLineColor());
2143   hole1plast->SetFillStyle(4090); // 90% transparent
2144
2145   TGeoVolume *hole1Cu = new TGeoVolume("SDDCableHole1Cu",
2146                                        hole1Cushape,medSDDCu);
2147   hole1Cu->SetVisibility(kTRUE);
2148   hole1Cu->SetLineColor(kRed);
2149   hole1Cu->SetLineWidth(1);
2150   hole1Cu->SetFillColor(hole1Cu->GetLineColor());
2151   hole1Cu->SetFillStyle(4090); // 90% transparent
2152
2153   TGeoVolume *hole1glass = new TGeoVolume("SDDCableHole1glass",
2154                                           hole1glassshape,medSDDglass);
2155   hole1glass->SetVisibility(kTRUE);
2156   hole1glass->SetLineColor(kGreen);
2157   hole1glass->SetLineWidth(1);
2158   hole1glass->SetFillColor(hole1glass->GetLineColor());
2159   hole1glass->SetFillStyle(4090); // 90% transparent
2160
2161   TGeoVolume *hole2 = new TGeoVolume("SDDCableHole2",
2162                                      hole2shape,medSDDair);
2163   hole2->SetVisibility(kTRUE);
2164   hole2->SetLineColor(5); // Yellow
2165   hole2->SetLineWidth(1);
2166   hole2->SetFillColor(hole2->GetLineColor());
2167   hole2->SetFillStyle(4090); // 90% transparent
2168
2169   TGeoVolume *hole21 = new TGeoVolume("SDDCableHole21",
2170                                       hole21shape,medSDDair);
2171   hole21->SetVisibility(kTRUE);
2172   hole21->SetLineColor(5); // Yellow
2173   hole21->SetLineWidth(1);
2174   hole21->SetFillColor(hole21->GetLineColor());
2175   hole21->SetFillStyle(4090); // 90% transparent
2176
2177   TGeoVolume *hole22 = new TGeoVolume("SDDCableHole22",
2178                                       hole22shape,medSDDair);
2179   hole22->SetVisibility(kTRUE);
2180   hole22->SetLineColor(5); // Yellow
2181   hole22->SetLineWidth(1);
2182   hole22->SetFillColor(hole22->GetLineColor());
2183   hole22->SetFillStyle(4090); // 90% transparent
2184
2185   TGeoVolume *hole2plast = new TGeoVolume("SDDCableHole2Plast",
2186                                           hole2plastshape,medSDDplast);
2187   hole2plast->SetVisibility(kTRUE);
2188   hole2plast->SetLineColor(kBlue);
2189   hole2plast->SetLineWidth(1);
2190   hole2plast->SetFillColor(hole2plast->GetLineColor());
2191   hole2plast->SetFillStyle(4090); // 90% transparent
2192
2193   TGeoVolume *hole2Cu = new TGeoVolume("SDDCableHole2Cu",
2194                                        hole2Cushape,medSDDCu);
2195   hole2Cu->SetVisibility(kTRUE);
2196   hole2Cu->SetLineColor(kRed);
2197   hole2Cu->SetLineWidth(1);
2198   hole2Cu->SetFillColor(hole2Cu->GetLineColor());
2199   hole2Cu->SetFillStyle(4090); // 90% transparent
2200
2201   TGeoVolume *hole2glass = new TGeoVolume("SDDCableHole2glass",
2202                                           hole2glassshape,medSDDglass);
2203   hole2glass->SetVisibility(kTRUE);
2204   hole2glass->SetLineColor(kGreen);
2205   hole2glass->SetLineWidth(1);
2206   hole2glass->SetFillColor(hole2glass->GetLineColor());
2207   hole2glass->SetFillStyle(4090); // 90% transparent
2208
2209   TGeoVolume *hole3 = new TGeoVolume("SDDCableHole3",
2210                                      hole3shape,medSDDair);
2211   hole3->SetVisibility(kTRUE);
2212   hole3->SetLineColor(5); // Yellow
2213   hole3->SetLineWidth(1);
2214   hole3->SetFillColor(hole3->GetLineColor());
2215   hole3->SetFillStyle(4090); // 90% transparent
2216
2217   TGeoVolume *hole31 = new TGeoVolume("SDDCableHole31",
2218                                       hole31shape,medSDDair);
2219   hole31->SetVisibility(kTRUE);
2220   hole31->SetLineColor(5); // Yellow
2221   hole31->SetLineWidth(1);
2222   hole31->SetFillColor(hole31->GetLineColor());
2223   hole31->SetFillStyle(4090); // 90% transparent
2224
2225   TGeoVolume *hole32 = new TGeoVolume("SDDCableHole32",
2226                                       hole32shape,medSDDair);
2227   hole32->SetVisibility(kTRUE);
2228   hole32->SetLineColor(5); // Yellow
2229   hole32->SetLineWidth(1);
2230   hole32->SetFillColor(hole32->GetLineColor());
2231   hole32->SetFillStyle(4090); // 90% transparent
2232
2233   TGeoVolume *hole4 = new TGeoVolume("SDDCableHole4",
2234                                      hole4shape,medSDDair);
2235   hole4->SetVisibility(kTRUE);
2236   hole4->SetLineColor(5); // Yellow
2237   hole4->SetLineWidth(1);
2238   hole4->SetFillColor(hole4->GetLineColor());
2239   hole4->SetFillStyle(4090); // 90% transparent
2240
2241   // Mount up a cone
2242   cfconeinsert->AddNode(cfconefoam,1,0);
2243
2244   hole1->AddNode(hole1plast, 1, 0);
2245   hole1->AddNode(hole1Cu, 1, 0);
2246   hole1->AddNode(hole1glass, 1, 0);
2247
2248   hole2->AddNode(hole2plast, 1, 0);
2249   hole2->AddNode(hole2Cu, 1, 0);
2250   hole2->AddNode(hole2glass, 1, 0);
2251
2252   for (Int_t i=0; i<12; i++) {
2253     Double_t phiH = i*30.0;
2254     cfconefoam->AddNode(hole1 , i+1, new TGeoRotation("", 0, 0, phiH));
2255         cfcone->AddNode(hole11, i+1, new TGeoRotation("", 0, 0, phiH));
2256         cfcone->AddNode(hole12, i+1, new TGeoRotation("", 0, 0, phiH));
2257   }
2258
2259   for (Int_t i=0; i<6; i++) {
2260     Double_t phiH = i*60.0;
2261     cfconefoam->AddNode(hole2 , i+1, new TGeoRotation("", 0, 0, phiH));
2262         cfcone->AddNode(hole21, i+1, new TGeoRotation("", 0, 0, phiH));
2263         cfcone->AddNode(hole22, i+1, new TGeoRotation("", 0, 0, phiH));
2264   }
2265
2266   for (Int_t i=0; i<kNHole3; i++) {
2267     Double_t phiH0 = 360./(Double_t)kNHole3;
2268     Double_t phiH  = i*phiH0 + 0.5*phiH0;
2269     cfconefoam->AddNode(hole3 , i+1, new TGeoRotation("", phiH, 0, 0));
2270         cfcone->AddNode(hole31, i+1, new TGeoRotation("", phiH, 0, 0));
2271         cfcone->AddNode(hole32, i+1, new TGeoRotation("", phiH, 0, 0));
2272   }
2273
2274   cfcone->AddNode(cfconeinsert,1,0);
2275
2276 /*
2277   for (Int_t i=0; i<kNHole4; i++) {
2278     Double_t phiH0 = 360./(Double_t)kNHole4;
2279     Double_t phiH  = i*phiH0 + 0.25*phiH0;
2280     cfcone->AddNode(hole4, i+1, new TGeoRotation("", phiH, 0, 0));
2281   }
2282 */
2283   // Finally put everything in the mother volume
2284   moth->AddNode(cfcylinder,1,0);
2285
2286   z = coneshape->Z(9);
2287   moth->AddNode(cfcone,1,new TGeoTranslation(0, 0, -z - kCylinderHalfLength));
2288   moth->AddNode(cfcone,2,new TGeoCombiTrans (0, 0,  z + kCylinderHalfLength,
2289                          new TGeoRotation("", 0, 180, 0)                   ));
2290
2291
2292   return;
2293 }
2294
2295 //______________________________________________________________________
2296 void AliITSv11GeometrySupport::SSDCone(TGeoVolume *moth,const TGeoManager *mgr)
2297 {
2298 //
2299 // Creates the SSD support cone and cylinder geometry. as a
2300 // volume assembly and adds it to the mother volume
2301 // (part of this code is taken or anyway inspired to SSDCone method
2302 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
2303 //
2304 // Input:
2305 //         moth : the TGeoVolume owing the volume structure
2306 //         mgr  : the GeoManager (default gGeoManager)
2307 // Output:
2308 //
2309 // Created:         ???       Bjorn S. Nilsen
2310 // Updated:      08 Mar 2008  Mario Sitta
2311 //
2312 // Technical data are taken from:  "ITS Supporto Generale" (technical
2313 // drawings ALR3-0743/1, ALR3-0743/1A and ALR3-0743/1B), "Supporto Generale
2314 // Settore SSD" (technical drawings ALR3-0743/2A and ALR3-0743/2E), private
2315 // communication with B. Giraudo
2316 //
2317 // Updated:      11 Apr 2008  Mario Sitta
2318 // Measures from drawings give overlaps with SPD thermal shield wings,
2319 // so the terminal part of the SSD cone was reduced
2320 //
2321 // Updated:      30 Mar 2010  Mario Sitta
2322 // Following M. van Leeuwen's suggestion on material budget, the thickness
2323 // of the carbon fiber cylinder was increased from 0.6 to 0.625mm
2324
2325   // Dimensions of the Central cylinder and flanges
2326   const Double_t kCylinderHalfLength   = (1143.6/2) *fgkmm;
2327   const Double_t kCylinderOuterRadius  = ( 595.0/2) *fgkmm;
2328   const Double_t kCylinderThickness    =       0.625*fgkmm;
2329   const Double_t kFoamHalfLength       = (1020.0/2) *fgkmm;
2330   const Double_t kFoamThickness        =        5.0 *fgkmm;
2331   const Double_t kFlangeHalfLength     =
2332                                       (kCylinderHalfLength-kFoamHalfLength)/2.;
2333   const Double_t kFlangeInnerRadius    = ( 563.0/2) *fgkmm;
2334   // Dimensions of the Cone
2335   const Double_t kConeROuterMin        = ( 957.0/2) *fgkmm;
2336   const Double_t kConeROuterMax        = ( 997.0/2) *fgkmm;
2337   const Double_t kConeRInnerMin        = ( 564.0/2) *fgkmm;
2338   const Double_t kConeRCurv1           =       10.0 *fgkmm;
2339   const Double_t kConeRCurv2           =       25.0 *fgkmm;
2340   const Double_t kConeCent1RCurv2      = ( 578.0/2) *fgkmm;
2341   const Double_t kConeCent2RCurv2      = ( 592.0/2) *fgkmm;
2342 //  const Double_t kConeZOuterRing       =       47.0 *fgkmm;
2343 //  const Double_t kConeZOuterRingInside =       30.25*fgkmm;
2344 //  const Double_t kConeZInnerRing       =      161.5 *fgkmm;
2345 //  const Double_t kConeZLength          =      176.5 *fgkmm;
2346   const Double_t kConeZOuterRing       =       38.5 *fgkmm;
2347   const Double_t kConeZOuterRingInside =       22.2 *fgkmm;
2348   const Double_t kConeZInnerRing       =      153.0 *fgkmm;
2349   const Double_t kConeZLength          =      168.0 *fgkmm;
2350   const Double_t kConeZPosition        = kConeZLength + kCylinderHalfLength;
2351   const Double_t kConeThickness        =       13.0 *fgkmm; // Cone thickness
2352   const Double_t kConeTheta            =       39.1 *fgkDegree; // Cone angle
2353   const Double_t kSinConeTheta         =
2354                                       TMath::Sin(kConeTheta*TMath::DegToRad());
2355   const Double_t kCosConeTheta         =
2356                                       TMath::Cos(kConeTheta*TMath::DegToRad());
2357   // Dimensions of the Foam cores
2358   const Double_t kConeFoam1Length      =      112.3 *fgkmm;
2359   const Double_t kConeFoam2Length      =       58.4 *fgkmm;
2360   // Dimensions of the Cone Holes
2361   const Double_t kCoolingHoleWidth     =       40.0 *fgkmm;
2362   const Double_t kCoolingHoleHight     =       30.0 *fgkmm;
2363   const Double_t kCoolingHoleRmin      =      350.0 *fgkmm;
2364   const Double_t kCoolingHolePhi       =       45.0 *fgkDegree;
2365   const Double_t kMountingHoleWidth    =       20.0 *fgkmm;
2366   const Double_t kMountingHoleHight    =       20.0 *fgkmm;
2367   const Double_t kMountingHoleRmin     =      317.5 *fgkmm;
2368   const Double_t kMountingHolePhi      =       60.0 *fgkDegree;
2369   const Double_t kCableHoleRin         = ( 800.0/2) *fgkmm;
2370   const Double_t kCableHoleRout        = ( 920.0/2) *fgkmm;
2371   const Double_t kCableHoleWidth       =      200.0 *fgkmm;
2372 //  const Double_t kCableHoleAngle       =       42.0 *fgkDegree;
2373   // Dimensions of the Cone Wings
2374   const Double_t kWingRmax             =      527.5 *fgkmm;
2375   const Double_t kWingWidth            =       70.0 *fgkmm;
2376   const Double_t kWingHalfThick        = (  10.0/2) *fgkmm;
2377   const Double_t kThetaWing            =       45.0 *fgkDegree;
2378   // Dimensions of the SSD-SDD Mounting Brackets
2379   const Double_t kBracketRmin          = ( 541.0/2) *fgkmm;// See SDD ROutMin
2380   const Double_t kBracketRmax          = ( 585.0/2) *fgkmm;
2381   const Double_t kBracketHalfLength    = (   4.0/2) *fgkmm;
2382   const Double_t kBracketPhi           = (70.*fgkmm/kBracketRmax)*fgkRadian;
2383   // Common data
2384   const Double_t kCFThickness          =        0.75*fgkmm; //Carb. fib. thick.
2385
2386
2387   // Local variables
2388   Double_t rmin1, rmin2, rmax, z;
2389
2390   //
2391   //Begin_Html
2392   /*
2393     <img src="picts/ITS/file_name.gif">
2394     <P>
2395     <FONT FACE'"TIMES">
2396     ITS SSD central support and thermal shield cylinder.
2397     </FONT>
2398     </P>
2399   */
2400   //End_Html
2401   //
2402
2403   // Central cylinder with its internal foam and the lateral flanges:
2404   // a carbon fiber Pcon which contains a rohacell Tube and two
2405   // stesalite Cone's
2406   TGeoPcon *externalcylshape = new TGeoPcon(0,360,4);
2407
2408   rmax  = kCylinderOuterRadius;
2409   rmin1 = kFlangeInnerRadius - kCylinderThickness;
2410   rmin2 = rmax - 2*kCylinderThickness - kFoamThickness;
2411   externalcylshape->DefineSection(0,-kCylinderHalfLength,rmin1,rmax);
2412   externalcylshape->DefineSection(1,-kFoamHalfLength    ,rmin2,rmax);
2413   externalcylshape->DefineSection(2, kFoamHalfLength    ,rmin2,rmax);
2414   externalcylshape->DefineSection(3, kCylinderHalfLength,rmin1,rmax);
2415
2416   rmax  = kCylinderOuterRadius - kCylinderThickness;
2417   rmin1 = rmax - kFoamThickness;
2418   TGeoTube *foamshape = new TGeoTube(rmin1,rmax,kFoamHalfLength);
2419
2420   rmax  = kCylinderOuterRadius - kCylinderThickness;
2421   rmin1 = rmax - kFoamThickness;
2422   rmin2 = kFlangeInnerRadius;
2423   TGeoCone *flangeshape = new TGeoCone(kFlangeHalfLength,
2424                                        rmin1,rmax,rmin2,rmax);
2425
2426
2427   // We have the shapes: now create the real volumes
2428
2429   TGeoMedium *medSSDcf  = mgr->GetMedium("ITS_SSD C (M55J)$");
2430   TGeoMedium *medSSDair = mgr->GetMedium("ITS_SSD AIR$");
2431   TGeoMedium *medSSDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
2432   TGeoMedium *medSSDroh = mgr->GetMedium("ITS_ROHACELL$");
2433   TGeoMedium *medSSDal  = mgr->GetMedium("ITS_ALUMINUM$");
2434
2435   TGeoVolume *cfcylinder = new TGeoVolume("SSDexternalcylinder",
2436                                            externalcylshape,medSSDcf);
2437   cfcylinder->SetVisibility(kTRUE);
2438   cfcylinder->SetLineColor(4); // blue
2439   cfcylinder->SetLineWidth(1);
2440   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
2441   cfcylinder->SetFillStyle(4000); // 0% transparent
2442
2443   TGeoVolume *foamcylinder = new TGeoVolume("SSDfoamcylinder",
2444                                             foamshape,medSSDroh);
2445   foamcylinder->SetVisibility(kTRUE);
2446   foamcylinder->SetLineColor(3); // green
2447   foamcylinder->SetLineWidth(1);
2448   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
2449   foamcylinder->SetFillStyle(4050); // 50% transparent
2450
2451   TGeoVolume *flangecylinder = new TGeoVolume("SSDflangecylinder",
2452                                               flangeshape,medSSDste);
2453   flangecylinder->SetVisibility(kTRUE);
2454   flangecylinder->SetLineColor(2); // red
2455   flangecylinder->SetLineWidth(1);
2456   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
2457   flangecylinder->SetFillStyle(4050); // 50% transparent
2458
2459   // Mount up the cylinder
2460   cfcylinder->AddNode(foamcylinder,1,0);
2461   cfcylinder->AddNode(flangecylinder,1,
2462               new TGeoTranslation(0, 0, kFoamHalfLength+kFlangeHalfLength));
2463   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
2464               0, 0, -kFoamHalfLength-kFlangeHalfLength,
2465               new TGeoRotation("",0,180,0)     ) );
2466
2467
2468   // The whole Cone as an assembly
2469   TGeoVolumeAssembly *vC = new TGeoVolumeAssembly("ITSssdCone");
2470
2471
2472   // SSD Support Cone with its internal inserts: a carbon fiber Pcon
2473   // with holes which contains a stesalite Pcon which on turn contains a
2474   // rohacell Pcon
2475   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 12);
2476
2477   coneshape->Z(0)     = 0.0;
2478   coneshape->Rmin(0)  = kConeROuterMin;
2479   coneshape->Rmax(0)  = kConeROuterMax;
2480
2481   coneshape->Z(1)     = kConeZOuterRingInside - kConeRCurv1;
2482   coneshape->Rmin(1)  = coneshape->GetRmin(0);
2483   coneshape->Rmax(1)  = coneshape->GetRmax(0);
2484
2485   coneshape->Z(2)     = kConeZOuterRingInside;
2486   coneshape->Rmin(2)  = coneshape->GetRmin(1) - kConeRCurv1;
2487   coneshape->Rmax(2)  = coneshape->GetRmax(0);
2488
2489   coneshape->Z(3)     = coneshape->GetZ(2);
2490   coneshape->Rmax(3)  = coneshape->GetRmax(0);
2491
2492   coneshape->Z(4)     = kConeZOuterRing - kConeRCurv1;
2493   coneshape->Rmax(4)  = coneshape->GetRmax(0);
2494
2495   coneshape->Z(5)     = kConeZOuterRing;
2496   coneshape->Rmax(5)  = coneshape->GetRmax(4) - kConeRCurv1;
2497
2498   coneshape->Z(6)     = coneshape->GetZ(5);
2499
2500   RadiusOfCurvature(kConeRCurv2,90.0,kConeZInnerRing,kConeCent1RCurv2,
2501                     90.0-kConeTheta,z,rmin1);
2502   coneshape->Z(7)     = z;
2503   coneshape->Rmin(7)  = rmin1;
2504
2505   coneshape->Rmin(3)  = RminFromZpCone(coneshape,7,90.-kConeTheta,
2506                                        coneshape->GetZ(3));
2507
2508   coneshape->Rmin(4)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(4));
2509
2510   coneshape->Rmin(5)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(5));
2511
2512   coneshape->Rmin(6) = coneshape->GetRmin(5);
2513
2514   coneshape->Z(8)     = kConeZInnerRing;
2515   coneshape->Rmin(8)  = kConeCent1RCurv2;
2516
2517   coneshape->Z(9)     = coneshape->GetZ(8);
2518   coneshape->Rmin(9)  = kConeRInnerMin;
2519
2520   RadiusOfCurvature(kConeRCurv2,90.0,kConeZLength,kConeCent2RCurv2,
2521                     90.0-kConeTheta,z,rmax);
2522
2523   coneshape->Z(10)    = z;
2524   coneshape->Rmin(10) = coneshape->GetRmin(9);
2525   coneshape->Rmax(10) = rmax;
2526
2527   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,10,90.-kConeTheta,
2528                                        coneshape->GetZ(6));
2529
2530   coneshape->Rmax(7)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(7));
2531
2532   coneshape->Rmax(8)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(8));
2533
2534   coneshape->Rmax(9)  = coneshape->GetRmax(8);
2535
2536   coneshape->Z(11)    = kConeZLength;
2537   coneshape->Rmin(11) = coneshape->GetRmin(10);
2538   coneshape->Rmax(11) = kConeCent2RCurv2;
2539
2540   // SSD Cone Insert: another Pcon
2541   Double_t x0, y0, x1, y1, x2, y2;
2542   TGeoPcon *coneinsertshape = new TGeoPcon(0.0,360.0,12);
2543
2544   coneinsertshape->Z(0)     = coneshape->GetZ(0) + kCFThickness;
2545   coneinsertshape->Rmin(0)  = coneshape->GetRmin(0) + kCFThickness;
2546   coneinsertshape->Rmax(0)  = coneshape->GetRmax(0) - kCFThickness;
2547
2548   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
2549   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
2550   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
2551   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2552   coneinsertshape->Z(1)     = z;
2553   coneinsertshape->Rmin(1)  = rmin1;
2554   coneinsertshape->Rmax(1)  = coneinsertshape->GetRmax(0);
2555
2556   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmin(1);
2557   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmin(2);
2558   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmin(3);
2559   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2560   coneinsertshape->Z(2)     = z;
2561   coneinsertshape->Rmin(2)  = rmin1;
2562   coneinsertshape->Rmax(2)  = coneinsertshape->GetRmax(1);
2563
2564   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
2565   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
2566   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
2567   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2568   coneinsertshape->Z(3)     = z;
2569   coneinsertshape->Rmin(3)  = rmin1;
2570   coneinsertshape->Rmax(3)  = coneinsertshape->GetRmax(2);
2571
2572   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
2573   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
2574   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
2575   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2576   coneinsertshape->Z(4)     = z;
2577   coneinsertshape->Rmax(4)  = rmax;
2578
2579   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmax(4);
2580   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmax(5);
2581   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmax(6);
2582   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2583   coneinsertshape->Z(5)     = z;
2584   coneinsertshape->Rmax(5)  = rmax;
2585
2586   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmax(5);
2587   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmax(6);
2588   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmax(7);
2589   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2590   coneinsertshape->Z(6)     = z;
2591   coneinsertshape->Rmax(6)  = rmax;
2592
2593   x0 = coneshape->GetZ(6); y0 = coneshape->GetRmin(6);
2594   x1 = coneshape->GetZ(7); y1 = coneshape->GetRmin(7);
2595   x2 = coneshape->GetZ(8); y2 = coneshape->GetRmin(8);
2596   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2597   coneinsertshape->Z(7)     = z;
2598   coneinsertshape->Rmin(7)  = rmin1;
2599
2600   coneinsertshape->Rmin(4)  = RminFrom2Points(coneinsertshape,3,7,
2601                                               coneinsertshape->GetZ(4));
2602
2603   coneinsertshape->Rmin(5)  = RminFrom2Points(coneinsertshape,3,7,
2604                                               coneinsertshape->GetZ(5));
2605
2606   coneinsertshape->Rmin(6)  = coneinsertshape->GetRmin(5);
2607
2608   x0 = coneshape->GetZ(7); y0 = coneshape->GetRmin(7);
2609   x1 = coneshape->GetZ(8); y1 = coneshape->GetRmin(8);
2610   x2 = coneshape->GetZ(9); y2 = coneshape->GetRmin(9);
2611   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2612   coneinsertshape->Z(8)     = z;
2613   coneinsertshape->Rmin(8)  = rmin1;
2614
2615   x0 = coneshape->GetZ( 8); y0 = coneshape->GetRmin( 8);
2616   x1 = coneshape->GetZ( 9); y1 = coneshape->GetRmin( 9);
2617   x2 = coneshape->GetZ(10); y2 = coneshape->GetRmin(10);
2618   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2619   coneinsertshape->Z(9)     = z;
2620   coneinsertshape->Rmin(9)  = rmin1;
2621
2622   x0 = coneshape->GetZ( 9); y0 = coneshape->GetRmax( 9);
2623   x1 = coneshape->GetZ(10); y1 = coneshape->GetRmax(10);
2624   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmax(11);
2625   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2626   coneinsertshape->Z(10)    = z;
2627   coneinsertshape->Rmax(10) = rmax;
2628   coneinsertshape->Rmin(10) = coneinsertshape->GetRmin(9);
2629
2630   coneinsertshape->Rmax(7)  = RmaxFrom2Points(coneinsertshape,6,10,
2631                                               coneinsertshape->GetZ(7));
2632
2633   coneinsertshape->Rmax(8)  = RmaxFrom2Points(coneinsertshape,6,10,
2634                                               coneinsertshape->GetZ(8));
2635
2636   coneinsertshape->Rmax(9)  = coneinsertshape->GetRmax(8);
2637
2638   x0 = coneshape->GetZ(10); y0 = coneshape->GetRmax(10);
2639   x1 = coneshape->GetZ(11); y1 = coneshape->GetRmax(11);
2640   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmin(11);
2641   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2642   coneinsertshape->Z(11)    = z;
2643   coneinsertshape->Rmax(11) = rmax;
2644   coneinsertshape->Rmin(11) = coneinsertshape->GetRmin(10);
2645
2646   // SSD Cone Foams: two other Pcon's
2647   TGeoPcon *conefoam1shape = new TGeoPcon(0.0, 360.0, 4);
2648
2649   conefoam1shape->Z(0)    = coneinsertshape->GetZ(3);
2650   conefoam1shape->Rmin(0) = coneinsertshape->GetRmin(3);
2651   conefoam1shape->Rmax(0) = conefoam1shape->GetRmin(0);
2652
2653   conefoam1shape->Rmax(1) = conefoam1shape->GetRmax(0);
2654   conefoam1shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2655                                            conefoam1shape->GetRmax(1));
2656   conefoam1shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2657                                            conefoam1shape->GetZ(1));
2658
2659   Double_t t = kConeThickness - 2*kCFThickness;
2660   conefoam1shape->Rmin(2) = conefoam1shape->GetRmax(0) -
2661                            (kConeFoam1Length*kCosConeTheta - t*kSinConeTheta);
2662   conefoam1shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2663                                            conefoam1shape->GetRmin(2));
2664   conefoam1shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2665                                            conefoam1shape->GetZ(2));
2666
2667   conefoam1shape->Rmin(3) = conefoam1shape->GetRmin(2);
2668   conefoam1shape->Rmax(3) = conefoam1shape->GetRmin(3);
2669   conefoam1shape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2670                                            conefoam1shape->GetRmax(3));
2671
2672   TGeoPcon *conefoam2shape = new TGeoPcon(0.0, 360.0, 4);
2673
2674   conefoam2shape->Z(3)    = coneinsertshape->GetZ(10);
2675   conefoam2shape->Rmin(3) = coneinsertshape->GetRmax(10);
2676   conefoam2shape->Rmax(3) = conefoam2shape->GetRmin(3);
2677
2678   conefoam2shape->Rmin(2) = conefoam2shape->GetRmin(3);
2679   conefoam2shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2680                                            conefoam2shape->GetRmin(2));
2681   conefoam2shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2682                                            conefoam2shape->GetZ(2));
2683
2684   conefoam2shape->Rmin(0) = conefoam2shape->GetRmax(2) +
2685                            (kConeFoam2Length*kCosConeTheta - t*kSinConeTheta);
2686   conefoam2shape->Rmax(0) = conefoam2shape->GetRmin(0);
2687   conefoam2shape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2688                                            conefoam2shape->GetRmin(0));
2689
2690   conefoam2shape->Rmax(1) = conefoam2shape->GetRmax(0);
2691   conefoam2shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2692                                            conefoam2shape->GetRmax(1));
2693   conefoam2shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2694                                            conefoam2shape->GetZ(1));
2695
2696   // SSD Cone Holes: Pcon's
2697   // A single hole volume gives an overlap with coneinsert, so
2698   // three contiguous volumes are created: one to be put in coneinsert
2699   // and two in the cone carbon fiber envelope
2700   Double_t holePhi;
2701   holePhi = (kCoolingHoleWidth/kCoolingHoleRmin)*TMath::RadToDeg();
2702
2703   TGeoPcon *coolingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2704
2705   coolingholeshape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2706   coolingholeshape->Rmax(0) = coolingholeshape->GetRmin(0);
2707   coolingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2708                                              coolingholeshape->GetRmin(0));
2709
2710   coolingholeshape->Rmax(1) = coolingholeshape->GetRmax(0);
2711   coolingholeshape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2712                                              coolingholeshape->GetRmax(1));
2713   coolingholeshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2714                                              coolingholeshape->GetZ(1));
2715
2716   coolingholeshape->Rmin(2) = kCoolingHoleRmin;
2717   coolingholeshape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2718                                              coolingholeshape->GetRmin(2));
2719   coolingholeshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2720                                              coolingholeshape->GetZ(2));
2721
2722   coolingholeshape->Rmin(3) = coolingholeshape->GetRmin(2);
2723   coolingholeshape->Rmax(3) = coolingholeshape->GetRmin(3);
2724   coolingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2725                                              coolingholeshape->GetRmax(3));
2726
2727   TGeoPcon *coolinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2728
2729   coolinghole2shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2730   coolinghole2shape->Rmax(0) = coolinghole2shape->GetRmin(0);
2731   coolinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2732                                               coolinghole2shape->GetRmin(0));
2733
2734   coolinghole2shape->Rmax(1) = coolinghole2shape->GetRmax(0);
2735   coolinghole2shape->Z(1)    = coolingholeshape->GetZ(0);
2736   coolinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2737                                               coolinghole2shape->GetZ(1));
2738
2739   coolinghole2shape->Rmin(2) = kCoolingHoleRmin;
2740   coolinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2741                                               coolinghole2shape->GetRmin(2));
2742   coolinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2743                                               coolinghole2shape->GetZ(2));
2744
2745   coolinghole2shape->Rmin(3) = coolinghole2shape->GetRmin(2);
2746   coolinghole2shape->Rmax(3) = coolinghole2shape->GetRmin(3);
2747   coolinghole2shape->Z(3)    = coolingholeshape->GetZ(2);
2748
2749   TGeoPcon *coolinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2750
2751   coolinghole3shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2752   coolinghole3shape->Rmax(0) = coolinghole3shape->GetRmin(0);
2753   coolinghole3shape->Z(0)    = coolingholeshape->GetZ(1);
2754
2755   coolinghole3shape->Rmax(1) = coolinghole3shape->GetRmax(0);
2756   coolinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2757                                               coolinghole3shape->GetRmax(1));
2758   coolinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2759                                               coolinghole3shape->GetZ(1));
2760
2761   coolinghole3shape->Rmin(2) = kCoolingHoleRmin;
2762   coolinghole3shape->Z(2)    = coolingholeshape->GetZ(3);
2763   coolinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2764                                               coolinghole3shape->GetZ(2));
2765
2766   coolinghole3shape->Rmin(3) = coolinghole3shape->GetRmin(2);
2767   coolinghole3shape->Rmax(3) = coolinghole3shape->GetRmin(3);
2768   coolinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2769                                               coolinghole3shape->GetRmax(3));
2770
2771   //
2772   holePhi = (kMountingHoleWidth/kMountingHoleRmin)*TMath::RadToDeg();
2773
2774   TGeoPcon *mountingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2775
2776   mountingholeshape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2777   mountingholeshape->Rmax(0) = mountingholeshape->GetRmin(0);
2778   mountingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2779                                               mountingholeshape->GetRmin(0));
2780
2781   mountingholeshape->Rmin(1) = kMountingHoleRmin;
2782   mountingholeshape->Rmax(1) = mountingholeshape->GetRmax(0);
2783   mountingholeshape->Z(1)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2784                                               mountingholeshape->GetRmin(1));
2785
2786   mountingholeshape->Rmin(2) = mountingholeshape->GetRmin(1);
2787   mountingholeshape->Rmax(2) = mountingholeshape->GetRmax(1);
2788   mountingholeshape->Z(2)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2789                                               mountingholeshape->GetRmax(2));
2790
2791   mountingholeshape->Rmin(3) = mountingholeshape->GetRmin(2);
2792   mountingholeshape->Rmax(3) = mountingholeshape->GetRmin(3);
2793   mountingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2794                                               mountingholeshape->GetRmax(3));
2795
2796   TGeoPcon *mountinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2797
2798   mountinghole2shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2799   mountinghole2shape->Rmax(0) = mountingholeshape->GetRmin(0);
2800   mountinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2801                                                mountinghole2shape->GetRmin(0));
2802
2803   mountinghole2shape->Rmax(1) = mountinghole2shape->GetRmax(0);
2804   mountinghole2shape->Z(1)    = mountingholeshape->Z(0);
2805   mountinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2806                                                mountinghole2shape->GetZ(1));
2807
2808   mountinghole2shape->Rmin(2) = kMountingHoleRmin;
2809   mountinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2810                                                mountinghole2shape->GetRmin(2));
2811   mountinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2812                                                mountinghole2shape->GetZ(2));
2813
2814   mountinghole2shape->Rmin(3) = mountinghole2shape->Rmin(2);
2815   mountinghole2shape->Rmax(3) = mountinghole2shape->Rmin(3);
2816   mountinghole2shape->Z(3)    = mountingholeshape->Z(1);
2817
2818   TGeoPcon *mountinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2819
2820   mountinghole3shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2821   mountinghole3shape->Rmax(0) = mountingholeshape->GetRmin(0);
2822   mountinghole3shape->Z(0)    = mountingholeshape->GetZ(2);
2823
2824   mountinghole3shape->Rmax(1) = mountinghole3shape->GetRmax(0);
2825   mountinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2826                                                mountinghole3shape->GetRmax(1));
2827   mountinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2828                                                mountinghole3shape->GetZ(1));
2829
2830   mountinghole3shape->Rmin(2) = kMountingHoleRmin;
2831   mountinghole3shape->Z(2)    = mountingholeshape->Z(3);
2832   mountinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2833                                                mountinghole3shape->GetZ(2));
2834
2835   mountinghole3shape->Rmin(3) = mountinghole3shape->Rmin(2);
2836   mountinghole3shape->Rmax(3) = mountinghole3shape->Rmin(3);
2837   mountinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2838                                                mountinghole3shape->GetRmax(3));
2839
2840   // The Cable Hole is even more complicated, a Composite Shape
2841   // is unavoidable here (gosh!)
2842   TGeoPcon *coneshapecopy = new TGeoPcon("conecopy",0.0, 360.0, 12);
2843
2844   for (Int_t i=0; i<12; i++) {
2845     coneshapecopy->Rmin(i) = coneshape->GetRmin(i);
2846     coneshapecopy->Rmax(i) = coneshape->GetRmax(i);
2847     coneshapecopy->Z(i)    = coneshape->GetZ(i);
2848   }
2849
2850   holePhi = (kCableHoleWidth/kCableHoleRout)*TMath::RadToDeg();
2851   TGeoConeSeg *chCS = new TGeoConeSeg("chCS", 0.5*kConeZLength,
2852                                       kCableHoleRin, kCableHoleRout,
2853                                       kCableHoleRin, kCableHoleRout,
2854                                       -0.5*holePhi, 0.5*holePhi);
2855
2856   TGeoCompositeShape *cableholeshape = new TGeoCompositeShape(
2857                                            "SSDCableHoleShape",
2858                                            "conecopy*chCS");
2859
2860   if(GetDebug(1)){
2861     chCS->InspectShape();
2862     cableholeshape->InspectShape();
2863   }
2864
2865   // SSD Cone Wings: Tube and TubeSeg shapes
2866   Double_t angleWideWing, angleWideWingThickness;
2867   angleWideWing = (kWingWidth/kWingRmax)*TMath::RadToDeg();
2868   angleWideWingThickness = (kCFThickness/kWingRmax)*TMath::RadToDeg();
2869
2870   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kConeROuterMax, kWingRmax,
2871                                            kWingHalfThick,
2872                                            0, angleWideWing);
2873
2874   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kConeROuterMax,
2875                                  kWingRmax-kCFThickness,
2876                                  kWingHalfThick-kCFThickness,
2877                                  angleWideWingThickness,
2878                                  angleWideWing-angleWideWingThickness);
2879
2880   // SDD support plate, SSD side (Mounting Bracket): a TubeSeg
2881   TGeoTubeSeg *bracketshape = new TGeoTubeSeg(kBracketRmin, kBracketRmax,
2882                             kBracketHalfLength, -kBracketPhi/2, kBracketPhi/2);
2883
2884
2885   // We have the shapes: now create the real volumes
2886
2887   TGeoVolume *cfcone = new TGeoVolume("SSDCarbonFiberCone",
2888                                       coneshape,medSSDcf);
2889   cfcone->SetVisibility(kTRUE);
2890   cfcone->SetLineColor(4); // Blue
2891   cfcone->SetLineWidth(1);
2892   cfcone->SetFillColor(cfcone->GetLineColor());
2893   cfcone->SetFillStyle(4000); // 0% transparent
2894
2895   TGeoVolume *cfconeinsert = new TGeoVolume("SSDCarbonFiberConeInsert",
2896                                             coneinsertshape,medSSDste);
2897   cfconeinsert->SetVisibility(kTRUE);
2898   cfconeinsert->SetLineColor(2); // Red
2899   cfconeinsert->SetLineWidth(1);
2900   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2901   cfconeinsert->SetFillStyle(4050); // 50% transparent
2902
2903   TGeoVolume *cfconefoam1 = new TGeoVolume("SSDCarbonFiberConeFoam1",
2904                                             conefoam1shape,medSSDroh);
2905   cfconefoam1->SetVisibility(kTRUE);
2906   cfconefoam1->SetLineColor(3); // Green
2907   cfconefoam1->SetLineWidth(1);
2908   cfconefoam1->SetFillColor(cfconefoam1->GetLineColor());
2909   cfconefoam1->SetFillStyle(4050); // 50% transparent
2910
2911   TGeoVolume *cfconefoam2 = new TGeoVolume("SSDCarbonFiberConeFoam2",
2912                                             conefoam2shape,medSSDroh);
2913   cfconefoam2->SetVisibility(kTRUE);
2914   cfconefoam2->SetLineColor(3); // Green
2915   cfconefoam2->SetLineWidth(1);
2916   cfconefoam2->SetFillColor(cfconefoam2->GetLineColor());
2917   cfconefoam2->SetFillStyle(4050); // 50% transparent
2918
2919   TGeoVolume *coolinghole = new TGeoVolume("SSDCoolingHole",
2920                                            coolingholeshape,medSSDair);
2921   coolinghole->SetVisibility(kTRUE);
2922   coolinghole->SetLineColor(5); // Yellow
2923   coolinghole->SetLineWidth(1);
2924   coolinghole->SetFillColor(coolinghole->GetLineColor());
2925   coolinghole->SetFillStyle(4090); // 90% transparent
2926
2927   TGeoVolume *coolinghole2 = new TGeoVolume("SSDCoolingHole2",
2928                                             coolinghole2shape,medSSDair);
2929   coolinghole2->SetVisibility(kTRUE);
2930   coolinghole2->SetLineColor(5); // Yellow
2931   coolinghole2->SetLineWidth(1);
2932   coolinghole2->SetFillColor(coolinghole2->GetLineColor());
2933   coolinghole2->SetFillStyle(4090); // 90% transparent
2934
2935   TGeoVolume *coolinghole3 = new TGeoVolume("SSDCoolingHole3",
2936                                             coolinghole3shape,medSSDair);
2937   coolinghole3->SetVisibility(kTRUE);
2938   coolinghole3->SetLineColor(5); // Yellow
2939   coolinghole3->SetLineWidth(1);
2940   coolinghole3->SetFillColor(coolinghole3->GetLineColor());
2941   coolinghole3->SetFillStyle(4090); // 90% transparent
2942
2943   TGeoVolume *mountinghole = new TGeoVolume("SSDMountingHole",
2944                                             mountingholeshape,medSSDair);
2945   mountinghole->SetVisibility(kTRUE);
2946   mountinghole->SetLineColor(5); // Yellow
2947   mountinghole->SetLineWidth(1);
2948   mountinghole->SetFillColor(mountinghole->GetLineColor());
2949   mountinghole->SetFillStyle(4090); // 90% transparent
2950
2951   TGeoVolume *mountinghole2 = new TGeoVolume("SSDMountingHole2",
2952                                              mountinghole2shape,medSSDair);
2953   mountinghole2->SetVisibility(kTRUE);
2954   mountinghole2->SetLineColor(5); // Yellow
2955   mountinghole2->SetLineWidth(1);
2956   mountinghole2->SetFillColor(mountinghole2->GetLineColor());
2957   mountinghole2->SetFillStyle(4090); // 90% transparent
2958
2959   TGeoVolume *mountinghole3 = new TGeoVolume("SSDMountingHole3",
2960                                              mountinghole3shape,medSSDair);
2961   mountinghole3->SetVisibility(kTRUE);
2962   mountinghole3->SetLineColor(5); // Yellow
2963   mountinghole3->SetLineWidth(1);
2964   mountinghole3->SetFillColor(mountinghole3->GetLineColor());
2965   mountinghole3->SetFillStyle(4090); // 90% transparent
2966
2967   TGeoVolume *wing = new TGeoVolume("SSDWing",wingshape,medSSDcf);
2968   wing->SetVisibility(kTRUE);
2969   wing->SetLineColor(4); // Blue
2970   wing->SetLineWidth(1);
2971   wing->SetFillColor(wing->GetLineColor());
2972   wing->SetFillStyle(4000); // 0% transparent
2973
2974   TGeoVolume *cablehole = new TGeoVolume("SSDCableHole",
2975                                          cableholeshape,medSSDair);
2976   cablehole->SetVisibility(kTRUE);
2977   cablehole->SetLineColor(5); // Yellow
2978   cablehole->SetLineWidth(1);
2979   cablehole->SetFillColor(cablehole->GetLineColor());
2980   cablehole->SetFillStyle(4090); // 90% transparent
2981
2982   TGeoVolume *winginsert = new TGeoVolume("SSDWingInsert",
2983                                           winginsertshape,medSSDste);
2984   winginsert->SetVisibility(kTRUE);
2985   winginsert->SetLineColor(2); // Red
2986   winginsert->SetLineWidth(1);
2987   winginsert->SetFillColor(winginsert->GetLineColor());
2988   winginsert->SetFillStyle(4050); // 50% transparent
2989
2990   TGeoVolume *bracket = new TGeoVolume("SSDMountingBracket",
2991                                        bracketshape,medSSDal);
2992   bracket->SetVisibility(kTRUE);
2993   bracket->SetLineColor(6); // Purple
2994   bracket->SetLineWidth(1);
2995   bracket->SetFillColor(bracket->GetLineColor());
2996   bracket->SetFillStyle(4000); // 0% transparent
2997
2998   // Mount up a cone
2999   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
3000     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
3001     cfconefoam2->AddNode(mountinghole,i+1, new TGeoRotation("", phiH, 0, 0));
3002   }
3003
3004   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
3005     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
3006     cfconeinsert->AddNodeOverlap(coolinghole,i+1, new TGeoRotation("", phiH, 0, 0));
3007   }
3008
3009   cfconeinsert->AddNode(cfconefoam1,1,0);
3010   cfconeinsert->AddNode(cfconefoam2,1,0);
3011
3012   cfcone->AddNode(cfconeinsert,1,0);
3013
3014   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
3015     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
3016     cfcone->AddNode(coolinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
3017     cfcone->AddNode(coolinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
3018     cfcone->AddNodeOverlap(cablehole,i+1, new TGeoRotation("", phiH, 0, 0));
3019   }
3020
3021   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
3022     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
3023     cfcone->AddNode(mountinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
3024     cfcone->AddNode(mountinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
3025   }
3026
3027   wing->AddNode(winginsert,1,0);
3028
3029   // Add all volumes in the Cone assembly
3030   vC->AddNode(cfcone,1,new TGeoTranslation(0,0,-kConeZPosition));
3031
3032   for (Int_t i=0; i<4; i++) {
3033     Double_t thetaW = kThetaWing + 90.*i + angleWideWing/2.;
3034     vC->AddNode(wing, i+1, new TGeoCombiTrans(0, 0, -kConeZPosition+kWingHalfThick,
3035                            new TGeoRotation("",thetaW,180,0)));
3036   }
3037
3038   Double_t zBracket = kConeZPosition - coneshape->GetZ(9) +
3039                       2*bracketshape->GetDz();
3040   for (Int_t i=0; i<3; i++) {
3041     Double_t thetaB = 60 + 120.*i;
3042     vC->AddNode(bracket, i+1, new TGeoCombiTrans(0, 0, -zBracket,
3043                               new TGeoRotation("",thetaB,0,0)));
3044   }
3045
3046   // Finally put everything in the mother volume
3047   moth->AddNode(cfcylinder,1,0);
3048
3049   moth->AddNode(vC, 1, 0 );
3050   moth->AddNode(vC, 2, new TGeoRotation("",180, 180, 0) );
3051
3052   // Some debugging if requested
3053   if(GetDebug(1)){
3054     vC->PrintNodes();
3055     vC->InspectShape();
3056   }
3057
3058   return;
3059 }
3060
3061 //______________________________________________________________________
3062 void AliITSv11GeometrySupport::ServicesCableSupport(TGeoVolume *moth,
3063                                                     TGeoManager *mgr){
3064 //
3065 // Creates the cable trays which are outside the ITS support cones
3066 // but still inside the TPC
3067 // This is now a stearing routine, the actual work is done by three
3068 // specialized methods to avoid a really huge unique method
3069 //
3070 // Input:
3071 //         moth : the TGeoVolume owing the volume structure
3072 //         mgr  : the GeoManager (default gGeoManager)
3073 // Output:
3074 //
3075 // Created:      15 Nov 2009  Mario Sitta
3076 //
3077
3078   TraySupportsSideA(moth, mgr);
3079
3080   ServicesCableSupportSPD(moth, mgr);
3081   ServicesCableSupportSDD(moth, mgr);
3082   ServicesCableSupportSSD(moth, mgr);
3083
3084   return;
3085 }
3086
3087 //______________________________________________________________________
3088 void AliITSv11GeometrySupport::TraySupportsSideA(TGeoVolume *moth,
3089                                            const TGeoManager *mgr){
3090 //
3091 // Creates the structure supporting the ITS cable trays on Side A
3092 //
3093 // Input:
3094 //         moth : the TGeoVolume owing the volume structure
3095 //         mgr  : the GeoManager (default gGeoManager)
3096 // Output:
3097 //
3098 // Created:      14 Dec 2009  Mario Sitta
3099 // Updated:      26 Feb 2010  Mario Sitta
3100 //
3101 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
3102 // drawings and other (oral) information given by F.Tosello
3103 //
3104
3105   // Dimensions and positions of the A-Side Cable Tray Support Ring
3106   // (0872/G/A/01)
3107   const Double_t kSuppRingYTrans      =  110.00 *fgkmm;
3108   const Double_t kSuppRingZTrans      =(1011.00+435.00) *fgkmm;
3109   const Double_t kSuppForwYTrans      =  185.00 *fgkmm;
3110
3111   const Double_t kExtSuppRingSpace1   =   33.00 *fgkmm;
3112   const Double_t kExtSuppRingSpace2   =   45.00 *fgkmm;
3113   const Double_t kExtSuppRingSpcAbov  =   30.00 *fgkmm;
3114   const Double_t kExtSuppRingBase     =  491.50 *fgkmm;
3115   const Double_t kExtSuppRingInward   =   35.00 *fgkmm;
3116   const Double_t kExtSuppRingRmax     =  540.00 *fgkmm;
3117   const Double_t kExtSuppRingRint1    =  465.00 *fgkmm;
3118   const Double_t kExtSuppRingRint2    =  467.00 *fgkmm;
3119   const Double_t kExtSuppRingInnerHi  =  450.00 *fgkmm;
3120   const Double_t kExtSuppRingInWide   =  100.00 *fgkmm;
3121   const Double_t kExtSuppRingR7       =    7.00 *fgkmm;
3122   const Double_t kExtSuppRingR5       =    5.00 *fgkmm;
3123   const Double_t kExtSuppRingThick    =   20.00 *fgkmm;
3124
3125   const Double_t kExtSuppRingSpcAng   =   10.50 *TMath::DegToRad();
3126   const Double_t kExtSuppRingPartPhi  =   15.00 *TMath::DegToRad();
3127   const Double_t kExtSuppRingIntAng   =    7.00 *TMath::DegToRad();
3128   const Double_t kExtSuppRingBaseAng  =   75.00 *TMath::DegToRad();
3129   const Double_t kExtSuppRingR7Ang    =  100.00 *TMath::DegToRad(); // Guessed
3130
3131   const Int_t    kExtSuppRingNPtsArc  =   10; // N.points to approximate arc
3132
3133   const Double_t kIntSuppRingThick1   =   15.00 *fgkmm;
3134   const Double_t kIntSuppRingThick2   =   13.00 *fgkmm;
3135   const Double_t kIntSuppRingInward   =   24.00 *fgkmm;
3136   const Double_t kIntSuppRingThick    =   20.00 *fgkmm;
3137
3138   const Double_t kSuppCylHeight       =  340.00 *fgkmm;
3139   const Double_t kSuppCylRint         =  475.00 *fgkmm;
3140   const Double_t kSuppCylRext         =  478.00 *fgkmm;
3141   const Double_t kSuppCylDispl        =  137.70 *fgkmm;
3142
3143   const Double_t kSuppSpacerHeight    =   30.00 *fgkmm;
3144   const Double_t kSuppSpacerThick     =   10.00 *fgkmm;
3145
3146   const Double_t kSuppSpacerAngle     =   15.00;  // Degrees
3147
3148   const Double_t kSuppForwRingRint1   =  500.00 *fgkmm;
3149   const Double_t kSuppForwRingRint2   =  540.00 *fgkmm;
3150   const Double_t kSuppForwRingRext    =  560.00 *fgkmm;
3151   const Double_t kSuppForwRingThikAll =   50.00 *fgkmm;
3152   const Double_t kSuppForwRingThikInt =   20.00 *fgkmm;
3153
3154   // (0872/G/B/01)
3155   const Double_t kSuppForwConeRmin    =  558.00 *fgkmm;
3156   const Double_t kSuppForwConeRmax    =  681.00 *fgkmm;
3157   const Double_t kSuppForwConeLen1    =  318.00 *fgkmm;
3158   const Double_t kSuppForwConeLen2    =  662.00 *fgkmm;
3159   const Double_t kSuppForwConeThick   =    3.00 *fgkmm;
3160
3161   const Double_t kSuppBackRingPlacTop =   90.00 *fgkmm;
3162   const Double_t kSuppBackRingPlacSid =   50.00 *fgkmm;
3163   const Double_t kSuppBackRingHeight  =  760.00 *fgkmm;
3164   const Double_t kSuppBackRingRext    =  760.00 *fgkmm;
3165   const Double_t kSuppBackRingRint    =  685.00 *fgkmm;
3166 //  const Double_t kSuppBackRingRint2   =  675.00 *fgkmm;
3167   const Double_t kSuppBackRingR10     =   10.00 *fgkmm;
3168   const Double_t kSuppBackRingBase    =  739.00 *fgkmm;
3169   const Double_t kSuppBackRingThikAll =   50.00 *fgkmm;
3170   const Double_t kSuppBackRingThick1  =   20.00 *fgkmm;
3171   const Double_t kSuppBackRingThick2  =   20.00 *fgkmm;
3172
3173 //  const Double_t kSuppBackRingPlacAng =   10.00 *TMath::DegToRad();
3174   const Double_t kSuppBackRingPlacAng =   10.25 *TMath::DegToRad();//Fix ovlp.
3175   const Double_t kSuppBackRing2ndAng1 =   78.40 *TMath::DegToRad();
3176   const Double_t kSuppBackRing2ndAng2 =   45.00 *TMath::DegToRad();
3177
3178   const Int_t    kSuppBackRingNPtsArc =   10; // N.points to approximate arc
3179
3180   // (0872/G/C/01)
3181   const Double_t kRearSuppZTransGlob  =(1011.00+9315.00-6040.00) *fgkmm;
3182   const Double_t kBackRodZTrans       = 2420.00 *fgkmm;
3183
3184   const Double_t kBackRodLength       = 1160.00 *fgkmm;
3185   const Double_t kBackRodThickLen     =   20.00 *fgkmm;
3186   const Double_t kBackRodDiameter     =   20.00 *fgkmm;
3187
3188   const Double_t kSuppRearRingRint    =  360.00 *fgkmm;
3189   const Double_t kSuppRearRingRext1   =  410.00 *fgkmm;
3190   const Double_t kSuppRearRingRext2   =  414.00 *fgkmm;
3191   const Double_t kSuppRearRingHeight  =  397.00 *fgkmm;
3192   const Double_t kSuppRearRingTopWide =  111.87 *fgkmm;
3193   const Double_t kSuppRearRingBase    =  451.50 *fgkmm;
3194   const Double_t kSuppRearRingBaseHi  =   58.00 *fgkmm;
3195   const Double_t kSuppRearRingSideHi  =   52.00 *fgkmm;
3196   const Double_t kSuppRearRingInside  =   40.00 *fgkmm;
3197   const Double_t kSuppRearRingInsideHi=   12.00 *fgkmm;
3198   const Double_t kSuppRearRingThick   =   20.00 *fgkmm;
3199   const Double_t kSuppRearRingXRodHole=  441.50 *fgkmm;
3200   const Double_t kSuppRearRingYRodHole=   42.00 *fgkmm;
3201
3202   const Double_t kSuppRearRing1stAng  =   22.00 *TMath::DegToRad();
3203   const Double_t kSuppRearRingStepAng =   15.00 *TMath::DegToRad();
3204
3205   const Int_t    kSuppRearRingNPtsArc =   10; // N.points to approximate arc
3206
3207
3208   // Local variables
3209   Double_t xprof[2*(15+kExtSuppRingNPtsArc)],yprof[2*(15+kExtSuppRingNPtsArc)];
3210   Double_t slp1, slp2, phi, xm, ym;
3211   Double_t xloc, yloc, zloc, rmin, rmax, deltaR;
3212   Int_t npoints;
3213
3214
3215   // The whole support as an assembly
3216   TGeoVolumeAssembly *trayASuppStruct = new TGeoVolumeAssembly("ITSsuppSideAStructure");
3217   
3218
3219   // First create all needed shapes
3220
3221   // The External Ring (part of 0872/G/A/01): a really complex Xtru
3222   TGeoXtru *extSuppRing = new TGeoXtru(2);
3223
3224   // First the upper notch...
3225   xprof[ 0] = kExtSuppRingSpace1;
3226   yprof[ 0] = kExtSuppRingInnerHi + kExtSuppRingSpcAbov;
3227
3228   slp1 = TMath::Tan(TMath::Pi()/2 - kExtSuppRingSpcAng);
3229   IntersectCircle(slp1, xprof[0], yprof[0], kExtSuppRingRmax, 0., 0.,
3230                   xprof[5], yprof[5], xm, ym); // Ignore dummy xm,ym
3231
3232   xprof[ 4] = xprof[5];
3233   yprof[ 4] = yprof[5] - kExtSuppRingR5/TMath::Tan(kExtSuppRingSpcAng);
3234   xprof[ 3] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/6));
3235   yprof[ 3] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/6));
3236   xprof[ 2] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/3));
3237   yprof[ 2] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/3));
3238   xprof[ 1] = xprof[4] - kExtSuppRingR5;
3239   yprof[ 1] = yprof[4] - kExtSuppRingR5;
3240
3241   Int_t indx = 5+kExtSuppRingNPtsArc;
3242   // ...then the external arc, approximated with segments,...
3243   xprof[indx] = kExtSuppRingBase;
3244   yprof[indx] = TMath::Sqrt(kExtSuppRingRmax*kExtSuppRingRmax -
3245                             kExtSuppRingBase*kExtSuppRingBase);
3246   Double_t alphamin = TMath::ASin(kExtSuppRingSpace2/kExtSuppRingRmax);
3247   Double_t alphamax = TMath::Pi()/2 -
3248                     TMath::ASin(yprof[5+kExtSuppRingNPtsArc]/kExtSuppRingRmax);
3249
3250   for (Int_t jp = 1; jp < kExtSuppRingNPtsArc; jp++) {
3251     Double_t alpha = jp*(alphamax-alphamin)/kExtSuppRingNPtsArc;
3252     xprof[5+jp] = kExtSuppRingRmax*TMath::Sin(alpha);
3253     yprof[5+jp] = kExtSuppRingRmax*TMath::Cos(alpha);
3254   }
3255   // ...and finally the interior profile
3256   xprof[indx+1] = kExtSuppRingBase;
3257   yprof[indx+1] = kSuppRingYTrans;
3258   xprof[indx+2] = xprof[indx+1] - kExtSuppRingInward;
3259   yprof[indx+2] = yprof[indx+1];
3260
3261   phi  = TMath::Pi()/2 - 4*kExtSuppRingPartPhi - kExtSuppRingIntAng;
3262   slp1 = TMath::Tan(TMath::Pi() - kExtSuppRingBaseAng);
3263   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3264   xm   = kExtSuppRingRint2*TMath::Cos(phi);
3265   ym   = kExtSuppRingRint2*TMath::Sin(phi);
3266   IntersectLines(slp1, xprof[indx+2], yprof[indx+2], slp2, xm, ym,
3267                  xprof[indx+3], yprof[indx+3]);
3268
3269   slp1 = slp2;
3270   phi += kExtSuppRingPartPhi;
3271   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3272   xm   = kExtSuppRingRint1*TMath::Cos(phi);
3273   ym   = kExtSuppRingRint1*TMath::Sin(phi);
3274   IntersectLines(slp1, xprof[indx+3], yprof[indx+3], slp2, xm, ym,
3275                  xprof[indx+4], yprof[indx+4]);
3276   
3277   slp1 = slp2;
3278   phi += kExtSuppRingPartPhi;
3279   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3280   xm   = kExtSuppRingRint2*TMath::Cos(phi);
3281   ym   = kExtSuppRingRint2*TMath::Sin(phi);
3282   IntersectLines(slp1, xprof[indx+4], yprof[indx+4], slp2, xm, ym,
3283                  xprof[indx+5], yprof[indx+5]);
3284   
3285   slp1 = slp2;
3286   phi += kExtSuppRingPartPhi;
3287   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3288   xm   = kExtSuppRingRint1*TMath::Cos(phi);
3289   ym   = kExtSuppRingRint1*TMath::Sin(phi);
3290   IntersectLines(slp1, xprof[indx+5], yprof[indx+5], slp2, xm, ym,
3291                  xprof[indx+6], yprof[indx+6]);
3292   
3293   xprof[indx+9] = kExtSuppRingInWide;
3294   yprof[indx+9] = kExtSuppRingInnerHi;
3295   xprof[indx+8] = xprof[indx+9] +
3296                   (1 - TMath::Cos(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
3297   yprof[indx+8] = yprof[indx+9] +
3298                   (    TMath::Sin(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
3299   xprof[indx+7] = xprof[indx+9] +
3300                   (1 + TMath::Cos(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
3301   yprof[indx+7] = yprof[indx+9] +
3302                   (    TMath::Sin(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
3303   // Gosh, we did the right side! now reflex on the left side
3304   npoints = (sizeof(xprof)/sizeof(Double_t))/2;
3305   for (Int_t jp = 0; jp < npoints; jp++) {
3306     xprof[npoints+jp] = -xprof[npoints-1-jp];
3307     yprof[npoints+jp] =  yprof[npoints-1-jp];
3308   }
3309   // wow! now the actual Xtru
3310   extSuppRing->DefinePolygon(2*npoints, xprof, yprof);
3311   extSuppRing->DefineSection(0,0);
3312   extSuppRing->DefineSection(1,kExtSuppRingThick);
3313
3314   // The Internal Ring (part of 0872/G/A/01): another complex Xtru
3315   TGeoXtru *intSuppRing = new TGeoXtru(2);
3316
3317   // First the external profile...
3318   npoints = 0;
3319
3320   slp1 = 0;
3321   phi  = TMath::Pi()/2 - kExtSuppRingPartPhi - kExtSuppRingIntAng;
3322   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3323   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
3324   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
3325   IntersectLines(slp1,  0, kExtSuppRingInnerHi+kExtSuppRingSpcAbov,
3326                  slp2, xm, ym,
3327                  xprof[npoints], yprof[npoints]);
3328   npoints++;
3329
3330   slp1 = slp2;
3331   phi -= kExtSuppRingPartPhi;
3332   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3333   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
3334   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
3335   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3336                  slp2, xm, ym,
3337                  xprof[npoints], yprof[npoints]);
3338   npoints++;
3339
3340   slp1 = slp2;
3341   phi -= kExtSuppRingPartPhi;
3342   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3343   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
3344   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
3345   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3346                  slp2, xm, ym,
3347                  xprof[npoints], yprof[npoints]);
3348   npoints++;
3349
3350   slp1 = slp2;
3351   phi -= kExtSuppRingPartPhi;
3352   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3353   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
3354   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
3355   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3356                  slp2, xm, ym,
3357                  xprof[npoints], yprof[npoints]);
3358   npoints++;
3359
3360   xprof[npoints] = kExtSuppRingBase-kIntSuppRingInward;
3361   yprof[npoints] = Yfrom2Points(xprof[npoints-1], yprof[npoints-1], xm, ym,
3362                                 xprof[npoints]);
3363   npoints++;
3364
3365   xprof[npoints] = xprof[npoints-1];
3366   yprof[npoints] = kSuppRingYTrans;
3367   npoints++;
3368   // ...and then the interior profile, which is identical to extSuppRing one
3369   for (Int_t jp=0; jp < 8; jp++) {
3370     xprof[npoints] = extSuppRing->GetX(17+jp);
3371     yprof[npoints] = extSuppRing->GetY(17+jp);
3372     npoints++;
3373   }
3374   // We did the right side! now reflex on the left side
3375   for (Int_t jp = 0; jp < npoints; jp++) {
3376     xprof[npoints+jp] = -xprof[npoints-1-jp];
3377     yprof[npoints+jp] =  yprof[npoints-1-jp];
3378   }
3379   // And now the actual Xtru
3380   intSuppRing->DefinePolygon(2*npoints, xprof, yprof);
3381   intSuppRing->DefineSection(0,0);
3382   intSuppRing->DefineSection(1,kIntSuppRingThick);
3383
3384   // The intermediate cylinder (0872/G/A/03): a TubeSeg
3385   alphamin = TMath::ASin(kSuppCylDispl/kSuppCylRint)*TMath::RadToDeg();
3386   alphamax = 180 - alphamin;
3387   TGeoTubeSeg *interCylind = new TGeoTubeSeg(kSuppCylRint, kSuppCylRext,
3388                                      kSuppCylHeight/2, alphamin, alphamax);
3389
3390   // The spacer (0872/G/A/03): a simple Xtru
3391   TGeoXtru *suppSpacer = new TGeoXtru(2);
3392
3393   xprof[0] = kSuppSpacerHeight;
3394   yprof[0] = kSuppSpacerThick;
3395   xprof[1] = xprof[0];
3396   yprof[1] = 0;
3397   xprof[2] = 0;
3398   yprof[2] = 0;
3399   xprof[3] = kSuppSpacerThick*SinD(kSuppSpacerAngle);
3400   yprof[3] = yprof[0];
3401
3402   suppSpacer->DefinePolygon(4, xprof, yprof);
3403   suppSpacer->DefineSection(0,-kSuppCylHeight/2);
3404   suppSpacer->DefineSection(1, kSuppCylHeight/2);
3405
3406   // The forward ring (0872/G/B/02): a Pcon (slight oversimplification)
3407   Double_t rmean = (kSuppForwRingRint1+kSuppForwRingRext)/2;
3408   alphamin = TMath::ASin(kSuppForwYTrans/rmean)*TMath::RadToDeg();
3409   alphamax = 180 - alphamin;
3410
3411   TGeoPcon *forwardRing = new TGeoPcon(alphamin,alphamax-alphamin,4);
3412
3413   forwardRing->DefineSection(0,0,
3414                              kSuppForwRingRint1,kSuppForwRingRext);
3415   forwardRing->DefineSection(1,kSuppForwRingThikInt,
3416                              kSuppForwRingRint1,kSuppForwRingRext);
3417   forwardRing->DefineSection(2,kSuppForwRingThikInt,
3418                              kSuppForwRingRint2,kSuppForwRingRext);
3419   forwardRing->DefineSection(3,kSuppForwRingThikAll,
3420                              kSuppForwRingRint2,kSuppForwRingRext);
3421
3422   // The forward cone (0872/G/B/03): a TGeoPcon
3423   TGeoPcon *forwardCone = new TGeoPcon(alphamin,alphamax-alphamin,3);
3424
3425   forwardCone->DefineSection(0,0,
3426                              kSuppForwConeRmin-kSuppForwConeThick,
3427                              kSuppForwConeRmin);
3428   forwardCone->DefineSection(1,kSuppForwConeLen1,
3429                              kSuppForwConeRmin-kSuppForwConeThick,
3430                              kSuppForwConeRmin);
3431   forwardCone->DefineSection(2,kSuppForwConeLen1+kSuppForwConeLen2,
3432                              kSuppForwConeRmax-kSuppForwConeThick,
3433                              kSuppForwConeRmax);
3434
3435   // The first part of the Back Ring (part of 0872/G/B/01): a complex Xtru
3436   TGeoXtru *firstSuppBackRing = new TGeoXtru(2);
3437
3438   // First the external profile... (the arc is approximated with segments)
3439   npoints = 0;
3440
3441   xprof[npoints] = kSuppBackRingPlacTop;
3442   yprof[npoints] = kSuppBackRingHeight;
3443   npoints++;
3444
3445   alphamax = TMath::Pi()/2 - TMath::ASin(kSuppBackRingPlacTop/kSuppBackRingRext);
3446   alphamin = TMath::ASin((kSuppForwYTrans+kSuppBackRingPlacSid)/kSuppBackRingRext);
3447
3448   xprof[npoints] = xprof[npoints-1];
3449   yprof[npoints] = kSuppBackRingRext*TMath::Sin(alphamax);
3450   npoints++;
3451
3452   for (Int_t jp = 1; jp <= kSuppBackRingNPtsArc; jp++) {
3453     Double_t alpha = alphamax - jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
3454     xprof[npoints] = kSuppBackRingRext*TMath::Cos(alpha);
3455     yprof[npoints] = kSuppBackRingRext*TMath::Sin(alpha);
3456     npoints++;
3457   }
3458
3459   xprof[npoints] = kSuppBackRingBase -
3460                    kSuppBackRingPlacSid*TMath::Tan(kSuppBackRingPlacAng);
3461   yprof[npoints] = yprof[npoints-1];
3462   npoints++;
3463
3464   xprof[npoints] = kSuppBackRingBase;
3465   yprof[npoints] = kSuppForwYTrans;
3466   npoints++;
3467   // ...then the internal profile (the arc is approximated with segments)
3468   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint);
3469   alphamax = TMath::Pi()/2;
3470
3471   for (Int_t jp = 0; jp < kSuppBackRingNPtsArc; jp++) {
3472     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
3473     xprof[npoints] = kSuppBackRingRint*TMath::Cos(alpha);
3474     yprof[npoints] = kSuppBackRingRint*TMath::Sin(alpha);
3475     npoints++;
3476   }
3477
3478   xprof[npoints] = 0;
3479   yprof[npoints] = kSuppBackRingRint;
3480   npoints++;
3481   // We did the right side! now reflex on the left side (except last point)
3482   for (Int_t jp = 0; jp < npoints-1; jp++) {
3483     xprof[npoints+jp] = -xprof[npoints-jp-2];
3484     yprof[npoints+jp] =  yprof[npoints-jp-2];
3485   }
3486   // And now the actual Xtru
3487   firstSuppBackRing->DefinePolygon(2*npoints-1, xprof, yprof);
3488   firstSuppBackRing->DefineSection(0,0);
3489   firstSuppBackRing->DefineSection(1,kSuppBackRingThick1);
3490
3491   // The second part of the Back Ring (part of 0872/G/B/01): a Pcon
3492   // (slight oversimplification)
3493   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint)*TMath::RadToDeg();
3494   alphamax = 180 - alphamin;
3495
3496   TGeoPcon *secondSuppBackRing = new TGeoPcon(alphamin,alphamax-alphamin,6);
3497
3498   deltaR = kSuppBackRingThick2/TMath::Sin(kSuppBackRing2ndAng1);
3499   rmin = kSuppBackRingRint - kSuppBackRingThick1/TMath::Tan(kSuppBackRing2ndAng1);
3500   rmax = rmin + deltaR + kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
3501   secondSuppBackRing->DefineSection(0, 0, rmin, rmax);
3502
3503   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1/3));
3504   rmax -= kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1/3);
3505   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3506   secondSuppBackRing->DefineSection(1, zloc, rmin, rmax);
3507
3508   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1*2/3));
3509   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1*2/3);
3510   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3511   secondSuppBackRing->DefineSection(2, zloc, rmin, rmax);
3512
3513   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1));
3514   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
3515   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3516   secondSuppBackRing->DefineSection(3, zloc, rmin, rmax);
3517
3518   slp1 = TMath::Tan(kSuppBackRing2ndAng2);
3519   slp2 = TMath::Tan(TMath::Pi()/2 + kSuppBackRing2ndAng1);
3520   IntersectLines(-slp1,kSuppBackRingThikAll,deltaR/2,
3521                   slp2,kSuppBackRingThikAll,deltaR,
3522                   xm, ym);
3523
3524   zloc = xm - kSuppBackRingThick1;
3525   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3526   rmax = rmin + deltaR;
3527   secondSuppBackRing->DefineSection(4, zloc, rmin, rmax);
3528
3529   zloc = kSuppBackRingThikAll - kSuppBackRingThick1;
3530   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3531   rmax = rmin + deltaR/2;
3532   secondSuppBackRing->DefineSection(5, zloc, rmin, rmax);
3533
3534   // The supporting rod: a Tube
3535   TGeoTube *suppRod = new TGeoTube(0, kBackRodDiameter/2,
3536                                    (kBackRodLength - kBackRodThickLen)/2);
3537
3538   // The Back Ring (0872/G/C/01): another complex Xtru
3539   TGeoXtru *suppRearRing = new TGeoXtru(2);
3540
3541   // First the external profile...
3542   npoints = 0;
3543
3544   xprof[npoints] = kSuppRearRingTopWide;
3545   yprof[npoints] = kSuppRearRingHeight;
3546   npoints++;
3547
3548   phi = kSuppRearRing1stAng;
3549   slp1 = TMath::Tan(TMath::Pi() - phi);
3550   phi += kSuppRearRingStepAng;
3551   slp2 = TMath::Tan(TMath::Pi() - phi);
3552   xm = kSuppRearRingRext2*TMath::Sin(phi);
3553   ym = kSuppRearRingRext2*TMath::Cos(phi);
3554   IntersectLines(slp1, kSuppRearRingTopWide, kSuppRearRingHeight,
3555                  slp2, xm, ym,
3556                  xprof[npoints], yprof[npoints]);
3557   npoints++;
3558
3559   slp1 = slp2;
3560   phi += kSuppRearRingStepAng;
3561   slp2 = TMath::Tan(TMath::Pi() - phi);
3562   xm = kSuppRearRingRext1*TMath::Sin(phi);
3563   ym = kSuppRearRingRext1*TMath::Cos(phi);
3564   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3565                  slp2, xm, ym,
3566                  xprof[npoints], yprof[npoints]);
3567   npoints++;
3568
3569   slp1 = slp2;
3570   phi += kSuppRearRingStepAng;
3571   slp2 = TMath::Tan(TMath::Pi() - phi);
3572   xm = kSuppRearRingRext2*TMath::Sin(phi);
3573   ym = kSuppRearRingRext2*TMath::Cos(phi);
3574   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3575                  slp2, xm, ym,
3576                  xprof[npoints], yprof[npoints]);
3577   npoints++;
3578
3579   slp1 = slp2;
3580   slp2 = 0;
3581   xm = kSuppRearRingBase;
3582   ym = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3583   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3584                  slp2, xm, ym,
3585                  xprof[npoints], yprof[npoints]);
3586   npoints++;
3587
3588   xprof[npoints] = kSuppRearRingBase;
3589   yprof[npoints] = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3590   npoints++;
3591   xprof[npoints] = xprof[npoints - 1];
3592   yprof[npoints] = kSuppRearRingBaseHi;
3593   npoints++;
3594   xprof[npoints] = xprof[npoints - 1] - kSuppRearRingInside;
3595   yprof[npoints] = yprof[npoints - 1];
3596   npoints++;
3597   xprof[npoints] = xprof[npoints - 1];
3598   yprof[npoints] = yprof[npoints - 1] + kSuppRearRingInsideHi;
3599   npoints++;
3600   // ...then the internal arc, approximated with segments,...
3601   xprof[npoints] = kSuppRearRingRint;
3602   yprof[npoints] = yprof[npoints - 1];
3603
3604   alphamin = TMath::ASin(kSuppRearRingBaseHi/kSuppRearRingRint);
3605   alphamax = TMath::Pi()/2;
3606
3607   for (Int_t jp = 1; jp < kSuppRearRingNPtsArc; jp++) {
3608     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppRearRingNPtsArc;
3609     xprof[npoints+jp] = kSuppRearRingRint*TMath::Cos(alpha);
3610     yprof[npoints+jp] = kSuppRearRingRint*TMath::Sin(alpha);
3611   }
3612
3613   xprof[npoints+kSuppRearRingNPtsArc] = 0;
3614   yprof[npoints+kSuppRearRingNPtsArc] = kSuppRearRingRint;
3615   // We did the right side! now reflex on the left side
3616   Int_t nTotalPoints = npoints+kSuppRearRingNPtsArc;
3617   for (Int_t jp = 0; jp < nTotalPoints; jp++) {
3618     xprof[nTotalPoints+1+jp] = -xprof[nTotalPoints-1-jp];
3619     yprof[nTotalPoints+1+jp] =  yprof[nTotalPoints-1-jp];
3620   }
3621
3622   // And now the actual Xtru
3623   suppRearRing->DefinePolygon(2*nTotalPoints+1, xprof, yprof);
3624   suppRearRing->DefineSection(0,0);
3625   suppRearRing->DefineSection(1,kSuppRearRingThick);
3626
3627
3628   // We have all shapes: now create the real volumes
3629   TGeoMedium *medAl = mgr->GetMedium("ITS_ANTICORODAL$");
3630
3631   TGeoVolume *sideAExtSuppRing = new TGeoVolume("ITSsuppSideAExtSuppRing",
3632                                                  extSuppRing, medAl);
3633
3634   sideAExtSuppRing->SetVisibility(kTRUE);
3635   sideAExtSuppRing->SetLineColor(kMagenta+1);
3636   sideAExtSuppRing->SetLineWidth(1);
3637   sideAExtSuppRing->SetFillColor(sideAExtSuppRing->GetLineColor());
3638   sideAExtSuppRing->SetFillStyle(4000); // 0% transparent
3639
3640   TGeoVolume *sideAIntSuppRing = new TGeoVolume("ITSsuppSideAIntSuppRing",
3641                                                  intSuppRing, medAl);
3642
3643   sideAIntSuppRing->SetVisibility(kTRUE);
3644   sideAIntSuppRing->SetLineColor(kMagenta+1);
3645   sideAIntSuppRing->SetLineWidth(1);
3646   sideAIntSuppRing->SetFillColor(sideAIntSuppRing->GetLineColor());
3647   sideAIntSuppRing->SetFillStyle(4000); // 0% transparent
3648
3649   TGeoVolume *sideASuppCyl = new TGeoVolume("ITSsuppSideASuppCyl",
3650                                             interCylind, medAl);
3651
3652   sideASuppCyl->SetVisibility(kTRUE);
3653   sideASuppCyl->SetLineColor(kMagenta+1);
3654   sideASuppCyl->SetLineWidth(1);
3655   sideASuppCyl->SetFillColor(sideASuppCyl->GetLineColor());
3656   sideASuppCyl->SetFillStyle(4000); // 0% transparent
3657
3658   TGeoVolume *sideASuppSpacer = new TGeoVolume("ITSsuppSideASuppSpacer",
3659                                                suppSpacer, medAl);
3660
3661   sideASuppSpacer->SetVisibility(kTRUE);
3662   sideASuppSpacer->SetLineColor(kMagenta+1);
3663   sideASuppSpacer->SetLineWidth(1);
3664   sideASuppSpacer->SetFillColor(sideASuppSpacer->GetLineColor());
3665   sideASuppSpacer->SetFillStyle(4000); // 0% transparent
3666
3667   TGeoVolume *sideASuppForwRing = new TGeoVolume("ITSsuppSideASuppForwRing",
3668                                                  forwardRing, medAl);
3669
3670   sideASuppForwRing->SetVisibility(kTRUE);
3671   sideASuppForwRing->SetLineColor(kMagenta+1);
3672   sideASuppForwRing->SetLineWidth(1);
3673   sideASuppForwRing->SetFillColor(sideASuppForwRing->GetLineColor());
3674   sideASuppForwRing->SetFillStyle(4000); // 0% transparent
3675
3676   TGeoVolume *sideASuppForwCone = new TGeoVolume("ITSsuppSideASuppForwCone",
3677                                                  forwardCone, medAl);
3678
3679   sideASuppForwCone->SetVisibility(kTRUE);
3680   sideASuppForwCone->SetLineColor(kMagenta+1);
3681   sideASuppForwCone->SetLineWidth(1);
3682   sideASuppForwCone->SetFillColor(sideASuppForwCone->GetLineColor());
3683   sideASuppForwCone->SetFillStyle(4000); // 0% transparent
3684
3685   TGeoVolume *sideAFirstSuppBackRing = new TGeoVolume("ITSsuppSideAFirstSuppBackRing",
3686                                                      firstSuppBackRing, medAl);
3687
3688   sideAFirstSuppBackRing->SetVisibility(kTRUE);
3689   sideAFirstSuppBackRing->SetLineColor(kMagenta+1);
3690   sideAFirstSuppBackRing->SetLineWidth(1);
3691   sideAFirstSuppBackRing->SetFillColor(sideAFirstSuppBackRing->GetLineColor());
3692   sideAFirstSuppBackRing->SetFillStyle(4000); // 0% transparent
3693
3694   TGeoVolume *sideASecondSuppBackRing = new TGeoVolume("ITSsuppSideASecondSuppBackRing",
3695                                                        secondSuppBackRing, medAl);
3696
3697   sideASecondSuppBackRing->SetVisibility(kTRUE);
3698   sideASecondSuppBackRing->SetLineColor(kMagenta+1);
3699   sideASecondSuppBackRing->SetLineWidth(1);
3700   sideASecondSuppBackRing->SetFillColor(sideASecondSuppBackRing->GetLineColor());
3701   sideASecondSuppBackRing->SetFillStyle(4000); // 0% transparent
3702
3703   TGeoVolume *sideASuppRod = new TGeoVolume("ITSsuppSideASuppRod",
3704                                             suppRod, medAl);
3705
3706   sideASuppRod->SetVisibility(kTRUE);
3707   sideASuppRod->SetLineColor(kMagenta+1);
3708   sideASuppRod->SetLineWidth(1);
3709   sideASuppRod->SetFillColor(sideASuppRod->GetLineColor());
3710   sideASuppRod->SetFillStyle(4000); // 0% transparent
3711
3712   TGeoVolume *sideASuppRearRing = new TGeoVolume("ITSsuppSideASuppRearRing",
3713                                                  suppRearRing, medAl);
3714
3715   sideASuppRearRing->SetVisibility(kTRUE);
3716   sideASuppRearRing->SetLineColor(kMagenta+1);
3717   sideASuppRearRing->SetLineWidth(1);
3718   sideASuppRearRing->SetFillColor(sideASuppRearRing->GetLineColor());
3719   sideASuppRearRing->SetFillStyle(4000); // 0% transparent
3720
3721
3722   // Now build up the support structure
3723   zloc = kSuppRingZTrans;
3724   trayASuppStruct->AddNode(sideAExtSuppRing, 1,
3725                            new TGeoTranslation(0, 0, zloc) );
3726   trayASuppStruct->AddNode(sideAExtSuppRing, 2,
3727                            new TGeoCombiTrans( 0, 0, zloc,
3728                                                new TGeoRotation("",180,0,0)));
3729
3730   zloc += kExtSuppRingThick;
3731   trayASuppStruct->AddNode(sideAIntSuppRing, 1,
3732                            new TGeoTranslation(0, 0, zloc) );
3733   trayASuppStruct->AddNode(sideAIntSuppRing, 2,
3734                            new TGeoCombiTrans( 0, 0, zloc,
3735                                                new TGeoRotation("",180,0,0)));
3736
3737   xloc = kExtSuppRingBase - kIntSuppRingInward;
3738   yloc = kSuppRingYTrans;
3739   zloc += (kIntSuppRingThick + kSuppCylHeight/2);
3740   trayASuppStruct->AddNode(sideASuppCyl, 1,
3741                            new TGeoTranslation(0, 0, zloc) );
3742   trayASuppStruct->AddNode(sideASuppCyl, 2,
3743                            new TGeoCombiTrans( 0, 0, zloc,
3744                                                new TGeoRotation("",180,0,0)));
3745   trayASuppStruct->AddNode(sideASuppSpacer, 1,
3746                            new TGeoCombiTrans( xloc, yloc, zloc,
3747                            new TGeoRotation("",90+kSuppSpacerAngle,0,0)));
3748   trayASuppStruct->AddNode(sideASuppSpacer, 2,
3749                            new TGeoCombiTrans(-xloc, yloc, zloc,
3750                            new TGeoRotation("",0,180,kSuppSpacerAngle-90)));
3751   trayASuppStruct->AddNode(sideASuppSpacer, 3,
3752                            new TGeoCombiTrans( xloc,-yloc, zloc,
3753                            new TGeoRotation("",180,180,kSuppSpacerAngle-90)));
3754   trayASuppStruct->AddNode(sideASuppSpacer, 4,
3755                            new TGeoCombiTrans(-xloc,-yloc, zloc,
3756                            new TGeoRotation("",270+kSuppSpacerAngle,0,0)));
3757
3758
3759   zloc += kSuppCylHeight/2;
3760   trayASuppStruct->AddNode(sideAIntSuppRing, 3,
3761                            new TGeoTranslation(0, 0, zloc) );
3762   trayASuppStruct->AddNode(sideAIntSuppRing, 4,
3763                            new TGeoCombiTrans( 0, 0, zloc,
3764                                                new TGeoRotation("",180,0,0)));
3765
3766   zloc += kIntSuppRingThick;
3767   trayASuppStruct->AddNode(sideAExtSuppRing, 3,
3768                            new TGeoTranslation(0, 0, zloc) );
3769   trayASuppStruct->AddNode(sideAExtSuppRing, 4,
3770                            new TGeoCombiTrans( 0, 0, zloc,
3771                                                new TGeoRotation("",180,0,0)));
3772
3773   zloc += kExtSuppRingThick;
3774   trayASuppStruct->AddNode(sideASuppForwRing, 1,
3775                            new TGeoTranslation(0, 0, zloc) );
3776   trayASuppStruct->AddNode(sideASuppForwRing, 2,
3777                            new TGeoCombiTrans( 0, 0, zloc,
3778                                                new TGeoRotation("",180,0,0)));
3779
3780   zloc += kSuppForwRingThikAll;
3781   trayASuppStruct->AddNode(sideASuppForwCone, 1,
3782                            new TGeoTranslation(0, 0, zloc) );
3783   trayASuppStruct->AddNode(sideASuppForwCone, 2,
3784                            new TGeoCombiTrans( 0, 0, zloc,
3785                                                new TGeoRotation("",180,0,0)));
3786
3787   zloc += (kSuppForwConeLen1+kSuppForwConeLen2);
3788   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 1,
3789                            new TGeoTranslation(0, 0, zloc) );
3790   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 2,
3791                            new TGeoCombiTrans( 0, 0, zloc,
3792                                                new TGeoRotation("",180,0,0)));
3793
3794   zloc += kSuppBackRingThick1;
3795   trayASuppStruct->AddNode(sideASecondSuppBackRing, 1,
3796                            new TGeoTranslation(0, 0, zloc) );
3797   trayASuppStruct->AddNode(sideASecondSuppBackRing, 2,
3798                            new TGeoCombiTrans( 0, 0, zloc,
3799                                                new TGeoRotation("",180,0,0)));
3800
3801   xloc = kSuppRearRingXRodHole;
3802   yloc = kSuppRearRingBaseHi + kSuppRearRingYRodHole;
3803   zloc = kRearSuppZTransGlob - kBackRodZTrans + suppRod->GetDz();
3804   trayASuppStruct->AddNode(sideASuppRod, 1,
3805                            new TGeoTranslation( xloc, yloc, zloc) );
3806   trayASuppStruct->AddNode(sideASuppRod, 2,
3807                            new TGeoTranslation(-xloc, yloc, zloc) );
3808   trayASuppStruct->AddNode(sideASuppRod, 3,
3809                            new TGeoTranslation( xloc,-yloc, zloc) );
3810   trayASuppStruct->AddNode(sideASuppRod, 4,
3811                            new TGeoTranslation(-xloc,-yloc, zloc) );
3812
3813   zloc += suppRod->GetDz();
3814   trayASuppStruct->AddNode(sideASuppRearRing, 1,
3815                            new TGeoTranslation( 0, 0, zloc) );
3816   trayASuppStruct->AddNode(sideASuppRearRing, 2,
3817                            new TGeoCombiTrans( 0, 0, zloc,
3818                                                new TGeoRotation("",180,0,0)));
3819
3820
3821   // Finally put everything in the mother volume
3822   moth->AddNode(trayASuppStruct,1,0);
3823
3824   return;
3825 }
3826
3827 //______________________________________________________________________
3828 void AliITSv11GeometrySupport::ServicesCableSupportSPD(TGeoVolume *moth,
3829                                                        TGeoManager *mgr){
3830 //
3831 // Creates the all SPD cable trays which are outside the ITS support cones
3832 // but still inside the TPC
3833 // In order to avoid a huge monolithic routine, this method actually
3834 // calls inner methods to create and assemble the various (macro)pieces
3835 //
3836 // Input:
3837 //         moth : the TGeoVolume owing the volume structure
3838 //         mgr  : the GeoManager (default gGeoManager)
3839 // Output:
3840 //
3841 // Created:         ???       Bjorn S. Nilsen
3842 // Updated:      15 Nov 2009  Mario Sitta
3843 //
3844 // Technical data are taken from AutoCAD drawings and other (oral)
3845 // information given by F.Tosello
3846 //
3847
3848   SPDCableTraysSideA(moth, mgr);
3849   SPDCableTraysSideC(moth, mgr);
3850
3851 }
3852
3853 //______________________________________________________________________
3854 void AliITSv11GeometrySupport::ServicesCableSupportSDD(TGeoVolume *moth,
3855                                                        TGeoManager *mgr){
3856 //
3857 // Creates the all SDD cable trays which are outside the ITS support cones
3858 // but still inside the TPC
3859 // In order to avoid a huge monolithic routine, this method actually
3860 // calls inner methods to create and assemble the various (macro)pieces
3861 //
3862 // Input:
3863 //         moth : the TGeoVolume owing the volume structure
3864 //         mgr  : the GeoManager (default gGeoManager)
3865 // Output:
3866 //
3867 // Created:      14 Dec 2009  Mario Sitta
3868 //
3869
3870   SDDCableTraysSideA(moth, mgr);
3871   SDDCableTraysSideC(moth, mgr);
3872
3873   return;
3874 }
3875
3876 //______________________________________________________________________
3877 void AliITSv11GeometrySupport::ServicesCableSupportSSD(TGeoVolume *moth,
3878                                                        TGeoManager *mgr){
3879 //
3880 // Creates the SSD cable trays which are outside the ITS support cones
3881 // but still inside the TPC
3882 // In order to avoid a huge monolithic routine, this method actually
3883 // calls inner methods to create and assemble the various (macro)pieces
3884 //
3885 // Input:
3886 //         moth : the TGeoVolume owing the volume structure
3887 //         mgr  : the GeoManager (default gGeoManager)
3888 // Output:
3889 //
3890 // Created:      15 Nov 2009  Mario Sitta
3891 //
3892
3893   SSDCableTraysSideA(moth, mgr);
3894   SSDCableTraysSideC(moth, mgr);
3895
3896   return;
3897 }
3898
3899 //______________________________________________________________________
3900 void AliITSv11GeometrySupport::SPDCableTraysSideA(TGeoVolume *moth,
3901                                             const TGeoManager *mgr){
3902 //
3903 // Creates the SPD cable trays which are outside the ITS support cones
3904 // but still inside the TPC on Side A
3905 // (part of this code is taken or anyway inspired to ServicesCableSupport
3906 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
3907 //
3908 // Input:
3909 //         moth : the TGeoVolume owing the volume structure
3910 //         mgr  : the GeoManager (default gGeoManager)
3911 // Output:
3912 //
3913 // Created:      15 Feb 2010  Mario Sitta
3914 // Updated:      10 Jun 2010  Mario Sitta  Freon inside cooling pipes
3915 // Updated:      08 Sep 2010  Mario Sitta
3916 // Updated:      14 Sep 2010  Mario Sitta  Cables prolonged till cone
3917 //
3918 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
3919 // drawings and other (oral) information given by F.Tosello and D.Elia
3920 // (small differences with blueprints - e.g. -0.07mm in R1Trans and
3921 // R2Trans - fix small overlaps; they are then compensated in positioning
3922 // the Rear Tray to avoid its own overlaps with the rear supporting ring)
3923 // Optical fibers and voltage cables are approximated with mean materials
3924 // and square cross sections, but preserving the total material budget.
3925 //
3926
3927   // Overall position and rotation of the A-Side Cable Trays
3928   // (parts of 0872/G/D)
3929   const Double_t kTrayAR1Trans           =  396.93 *fgkmm;
3930   const Double_t kTrayAR2Trans           =  413.93 *fgkmm;
3931   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
3932   const Double_t kTrayAZRot              = (180-169.5);// Degrees
3933   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
3934   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
3935
3936   const Double_t kForwardTrayWide        =   94.00 *fgkmm;//!!!TO BE CHECKED!!!
3937   const Double_t kForwardTrayFirstHigh   =   83.00 *fgkmm;//!!!TO BE CHECKED!!!
3938   const Double_t kForwardTraySecondHigh  =   52.70 *fgkmm;//!!!TO BE CHECKED!!!
3939   const Double_t kForwardTrayTotalLen    =  853.00 *fgkmm;
3940   const Double_t kForwardTrayFirstLen    =  435.00 *fgkmm;
3941   const Double_t kForwardTrayWingWide    =   16.00 *fgkmm;//!!!TO BE CHECKED!!!
3942   const Double_t kForwardTrayInterSpace  =   18.00 *fgkmm;//!!!TO BE CHECKED!!!
3943   const Double_t kForwardTrayThick       =    2.00 *fgkmm;
3944
3945   const Int_t    kForwardSideNpoints     =    6;
3946
3947   const Double_t kExternalTrayLen        = 1200.00 *fgkmm;
3948   const Double_t kExternalTrayWide       = kForwardTrayWide;
3949   const Double_t kExternalTrayHigh       = kForwardTraySecondHigh;
3950   const Double_t kExternalTrayThick      = kForwardTrayThick;
3951
3952   const Double_t kCoolingTubeRmin        =    2.00 *fgkmm;
3953   const Double_t kCoolingTubeRmax        =    3.00 *fgkmm;
3954
3955   const Double_t kOpticalFibersSect      =    8.696*fgkmm;//!!!ESTIMATED!!!
3956   const Double_t kLowVoltageCableSectCu  =    7.675*fgkmm;// Computed
3957   const Double_t kLowVoltageCableHighPUR =    1.000*fgkmm;// Computed
3958   const Double_t kHiVoltageCableSectCu   =    1.535*fgkmm;// Computed
3959   const Double_t kHiVoltageCableHighPUR  =    0.500*fgkmm;// Computed
3960   const Double_t kCoaxCableSectCu        =    6.024*fgkmm;// Computed
3961   const Double_t kCoaxCableHighMeg       =    5.695*fgkmm;// Computed
3962
3963   const Double_t kTrayCCablesRot         =   75.000*fgkDegree;// Computed
3964   const Double_t kTrayCCablesZLenOut     =  227.000*fgkmm;// Computed
3965
3966
3967   // Local variables
3968   Double_t xprof[kForwardSideNpoints], yprof[kForwardSideNpoints];
3969   Double_t xloc, yloc, zloc, alpharot;
3970
3971
3972   // The two tray components as assemblies
3973   TGeoVolumeAssembly *cableTrayAForw =
3974     new TGeoVolumeAssembly("ITSsupportSPDTrayAForwRear");
3975   TGeoVolumeAssembly *cableTrayAExt =
3976     new TGeoVolumeAssembly("ITSsupportSPDTrayAExt");
3977   
3978
3979   // First create all needed shapes
3980
3981   // The lower face of the forward tray: a BBox
3982   TGeoBBox *forwTrayLowerFace = new TGeoBBox(kForwardTrayWide/2,
3983                                              kForwardTrayThick/2,
3984                                              kForwardTrayTotalLen/2);
3985
3986   // The side face of the forward tray: a Xtru
3987   TGeoXtru *forwTraySideFace = new TGeoXtru(2);
3988   forwTraySideFace->SetName("ITSsuppSPDForwTraySide");
3989
3990   xprof[0] = 0;
3991   yprof[0] = kForwardTrayThick;
3992   xprof[1] = kForwardTrayTotalLen;
3993   yprof[1] = yprof[0];
3994   xprof[2] = xprof[1];
3995   yprof[2] = kForwardTraySecondHigh - kForwardTrayThick;
3996   xprof[3] = kForwardTrayFirstLen;
3997   yprof[3] = yprof[2];
3998   xprof[4] = xprof[3];
3999   yprof[4] = kForwardTrayFirstHigh - kForwardTrayThick;
4000   xprof[5] = xprof[0];
4001   yprof[5] = yprof[4];
4002
4003   forwTraySideFace->DefinePolygon(6, xprof, yprof);
4004   forwTraySideFace->DefineSection(0, 0);
4005   forwTraySideFace->DefineSection(1, kForwardTrayThick);
4006
4007   // The covers of the forward tray: two BBox's
4008   TGeoBBox *forwTrayShortCover = new TGeoBBox(kForwardTrayWide/2,
4009                                               kForwardTrayThick/2,
4010                                               kForwardTrayFirstLen/2);
4011
4012   TGeoBBox *forwTrayLongCover = new TGeoBBox(kForwardTrayWide/2,
4013                                              kForwardTrayThick/2,
4014                              (kForwardTrayTotalLen - kForwardTrayFirstLen)/2);
4015
4016   // Each small wing of the forward tray: a BBox
4017   TGeoBBox *forwTrayWing = new TGeoBBox(kForwardTrayWingWide/2,
4018                              (kForwardTrayFirstHigh-kForwardTraySecondHigh)/2,
4019                                         kForwardTrayThick/2);
4020
4021   // The internal plane of the forward tray: a BBox
4022   TGeoBBox *forwTrayPlane = new TGeoBBox(kForwardTrayWide/2-kForwardTrayThick,
4023                                          kForwardTrayThick/2,
4024                                          kForwardTrayTotalLen/2);
4025
4026   // The internal wall of the forward tray: a BBox
4027   TGeoBBox *forwTrayWall = new TGeoBBox(kForwardTrayThick/2,
4028                                  (kForwardTrayInterSpace-kForwardTrayThick)/2,
4029                                         kForwardTrayTotalLen/2);
4030
4031   // Each horizontal face of the external tray: a BBox
4032   TGeoBBox *extTrayHorFace = new TGeoBBox(kExternalTrayWide/2-kExternalTrayThick,
4033                                           kExternalTrayThick/2,
4034                                           kExternalTrayLen/2);
4035
4036   // Each vertical face of the external tray: a BBox
4037   TGeoBBox *extTrayVerFace = new TGeoBBox(kExternalTrayThick/2,
4038                                           kExternalTrayHigh/2,
4039                                           kExternalTrayLen/2);
4040
4041   // The internal wall of the external tray: a BBox
4042   TGeoBBox *extTrayWall = new TGeoBBox(kExternalTrayThick/2,
4043                                  (kForwardTrayInterSpace-kExternalTrayThick)/2,
4044                                        kExternalTrayLen/2);
4045
4046   // The cooling tube inside the forward tray: a Tube
4047   Double_t zelong = (kForwardTraySecondHigh - 2*kForwardTrayThick
4048                 - 2*forwTrayWall->GetDY() - kCoolingTubeRmax)*SinD(kTrayAZRot);
4049   Double_t zlen = (zelong + kForwardTrayTotalLen)/2;
4050   TGeoTube *coolTubeForw = new TGeoTube(0, kCoolingTubeRmax, zlen);
4051
4052   // The freon inside the forward tray tubes: a Tube
4053   TGeoTube *freonTubeForw = new TGeoTube(0, kCoolingTubeRmin, zlen);
4054
4055   // The cooling tube inside the external tray: a Ctub
4056   TGeoCtub *coolTubeExt = new TGeoCtub(0, kCoolingTubeRmax,
4057                                        kExternalTrayLen/2, 0, 360,
4058                                        0, SinD(kTrayAZRot),-CosD(kTrayAZRot),
4059                                        0,                0,               1);
4060
4061   // The freon inside the forward tray tubes: a Tube
4062   TGeoCtub *freonTubeExt = new TGeoCtub(0, kCoolingTubeRmin,
4063                                         kExternalTrayLen/2, 0, 360,
4064                                         0, SinD(kTrayAZRot),-CosD(kTrayAZRot),
4065                                         0,                0,               1);
4066
4067   // The optical fibers inside the forward tray: a Xtru
4068   TGeoXtru *optFibsForw = new TGeoXtru(2);
4069
4070   xprof[0] = -kTrayCCablesZLenOut;
4071   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4072   xprof[1] = 0;
4073   yprof[1] = 0;
4074   xprof[2] = kForwardTrayTotalLen;
4075   yprof[2] = yprof[1];
4076   xprof[3] = xprof[2];
4077   yprof[3] = yprof[2] + kOpticalFibersSect;
4078   xprof[4] = xprof[1];
4079   yprof[4] = yprof[3];
4080   xprof[5] = xprof[0];
4081   yprof[5] = yprof[0] + kOpticalFibersSect;
4082
4083   optFibsForw->DefinePolygon(6, xprof, yprof);
4084   optFibsForw->DefineSection(0,-kOpticalFibersSect/2);
4085   optFibsForw->DefineSection(1, kOpticalFibersSect/2);
4086
4087   // The optical fibers inside the external tray: a Xtru
4088   TGeoXtru *optFibsExt = new TGeoXtru(2);
4089   optFibsExt->SetName("ITSsuppSPDExtTrayOptFibs");
4090
4091   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4092            + 2*forwTrayWall->GetDY();
4093   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4094   xprof[1] = kExternalTrayLen;
4095   yprof[1] = yprof[0];
4096   xprof[2] = xprof[1];
4097   yprof[2] = yprof[1] + kOpticalFibersSect;
4098   yprof[3] = yprof[2];
4099   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4100
4101   optFibsExt->DefinePolygon(4, xprof, yprof);
4102   optFibsExt->DefineSection(0, 0);
4103   optFibsExt->DefineSection(1, kOpticalFibersSect);
4104
4105   // The Low Voltage cables inside the forward tray: two Xtru
4106   TGeoXtru *lowCablesForwCu = new TGeoXtru(2);
4107
4108   xprof[0] = -kTrayCCablesZLenOut;
4109   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4110   xprof[1] = 0;
4111   yprof[1] = 0;
4112   xprof[2] = kForwardTrayTotalLen;
4113   yprof[2] = yprof[1];
4114   xprof[3] = xprof[2];
4115   yprof[3] = yprof[2] + kLowVoltageCableSectCu/2;
4116   xprof[4] = xprof[1];
4117   yprof[4] = yprof[3];
4118   xprof[5] = xprof[0];
4119   yprof[5] = yprof[0] + kLowVoltageCableSectCu/2;
4120
4121   lowCablesForwCu->DefinePolygon(6, xprof, yprof);
4122   lowCablesForwCu->DefineSection(0,-kLowVoltageCableSectCu);
4123   lowCablesForwCu->DefineSection(1, kLowVoltageCableSectCu);
4124
4125   TGeoXtru *lowCablesForwPUR = new TGeoXtru(2);
4126
4127   xprof[0] = lowCablesForwCu->GetX(5);
4128   yprof[0] = lowCablesForwCu->GetY(5);
4129   xprof[1] = lowCablesForwCu->GetX(4);
4130   yprof[1] = lowCablesForwCu->GetY(4);
4131   xprof[2] = lowCablesForwCu->GetX(3);
4132   yprof[2] = lowCablesForwCu->GetY(3);
4133   xprof[3] = xprof[2];
4134   yprof[3] = yprof[2] + kLowVoltageCableHighPUR/2;
4135   xprof[4] = xprof[1];
4136   yprof[4] = yprof[3];
4137   xprof[5] = xprof[0];
4138   yprof[5] = yprof[0] + kLowVoltageCableHighPUR/2;
4139
4140   lowCablesForwPUR->DefinePolygon(6, xprof, yprof);
4141   lowCablesForwPUR->DefineSection(0,-kLowVoltageCableSectCu);
4142   lowCablesForwPUR->DefineSection(1, kLowVoltageCableSectCu);
4143
4144   // The Low Voltage inside the external tray: two Xtru
4145   TGeoXtru *lowCablesExtCu = new TGeoXtru(2);
4146   lowCablesExtCu->SetName("ITSsuppSPDExtTrayLowVoltageCu");
4147
4148   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4149            + 2*forwTrayWall->GetDY();
4150   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4151   xprof[1] = kExternalTrayLen;
4152   yprof[1] = yprof[0];
4153   xprof[2] = xprof[1];
4154   yprof[2] = yprof[1] + kLowVoltageCableSectCu/2;
4155   yprof[3] = yprof[2];
4156   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4157
4158   lowCablesExtCu->DefinePolygon(4, xprof, yprof);
4159   lowCablesExtCu->DefineSection(0, 0);
4160   lowCablesExtCu->DefineSection(1, kLowVoltageCableSectCu*2);
4161
4162   TGeoXtru *lowCablesExtPUR = new TGeoXtru(2);
4163   lowCablesExtPUR->SetName("ITSsuppSPDExtTrayLowVoltagePUR");
4164
4165   xprof[0] = lowCablesExtCu->GetX(3);
4166   yprof[0] = lowCablesExtCu->GetY(3);
4167   xprof[1] = lowCablesExtCu->GetX(2);
4168   yprof[1] = lowCablesExtCu->GetY(2);
4169   xprof[2] = xprof[1];
4170   yprof[2] = yprof[1] + kLowVoltageCableHighPUR/2;
4171   yprof[3] = yprof[2];
4172   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4173
4174   lowCablesExtPUR->DefinePolygon(4, xprof, yprof);
4175   lowCablesExtPUR->DefineSection(0, 0);
4176   lowCablesExtPUR->DefineSection(1, kLowVoltageCableSectCu*2);
4177
4178   // The High Voltage cables inside the forward tray: two Xtru
4179   TGeoXtru *hiCablesForwCu = new TGeoXtru(2);
4180
4181   xprof[0] = -kTrayCCablesZLenOut;
4182   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4183   xprof[1] = 0;
4184   yprof[1] = 0;
4185   xprof[2] = kForwardTrayTotalLen;
4186   yprof[2] = yprof[1];
4187   xprof[3] = xprof[2];
4188   yprof[3] = yprof[2] + kHiVoltageCableSectCu/2;
4189   xprof[4] = xprof[1];
4190   yprof[4] = yprof[3];
4191   xprof[5] = xprof[0];
4192   yprof[5] = yprof[0] + kHiVoltageCableSectCu/2;
4193
4194   hiCablesForwCu->DefinePolygon(6, xprof, yprof);
4195   hiCablesForwCu->DefineSection(0,-kHiVoltageCableSectCu);
4196   hiCablesForwCu->DefineSection(1, kHiVoltageCableSectCu);
4197
4198   TGeoXtru *hiCablesForwPUR = new TGeoXtru(2);
4199
4200   xprof[0] = hiCablesForwCu->GetX(5);
4201   yprof[0] = hiCablesForwCu->GetY(5);
4202   xprof[1] = hiCablesForwCu->GetX(4);
4203   yprof[1] = hiCablesForwCu->GetY(4);
4204   xprof[2] = hiCablesForwCu->GetX(3);
4205   yprof[2] = hiCablesForwCu->GetY(3);
4206   xprof[3] = xprof[2];
4207   yprof[3] = yprof[2] + kHiVoltageCableHighPUR/2;
4208   xprof[4] = xprof[1];
4209   yprof[4] = yprof[3];
4210   xprof[5] = xprof[0];
4211   yprof[5] = yprof[0] + kHiVoltageCableHighPUR/2;
4212
4213   hiCablesForwPUR->DefinePolygon(6, xprof, yprof);
4214   hiCablesForwPUR->DefineSection(0,-kHiVoltageCableSectCu);
4215   hiCablesForwPUR->DefineSection(1, kHiVoltageCableSectCu);
4216
4217   // The High Voltage inside the external tray: two Xtru
4218   TGeoXtru *hiCablesExtCu = new TGeoXtru(2);
4219   hiCablesExtCu->SetName("ITSsuppSPDExtTrayHiVoltageCu");
4220
4221   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4222            + 2*forwTrayWall->GetDY();
4223   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4224   xprof[1] = kExternalTrayLen;
4225   yprof[1] = yprof[0];
4226   xprof[2] = xprof[1];
4227   yprof[2] = yprof[1] + kHiVoltageCableSectCu/2;
4228   yprof[3] = yprof[2];
4229   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4230
4231   hiCablesExtCu->DefinePolygon(4, xprof, yprof);
4232   hiCablesExtCu->DefineSection(0, 0);
4233   hiCablesExtCu->DefineSection(1, kHiVoltageCableSectCu*2);
4234
4235   TGeoXtru *hiCablesExtPUR = new TGeoXtru(2);
4236   hiCablesExtPUR->SetName("ITSsuppSPDExtTrayHiVoltagePUR");
4237
4238   xprof[0] = hiCablesExtCu->GetX(3);
4239   yprof[0] = hiCablesExtCu->GetY(3);
4240   xprof[1] = hiCablesExtCu->GetX(2);
4241   yprof[1] = hiCablesExtCu->GetY(2);
4242   xprof[2] = xprof[1];
4243   yprof[2] = yprof[1] + kHiVoltageCableHighPUR/2;
4244   yprof[3] = yprof[2];
4245   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4246
4247   hiCablesExtPUR->DefinePolygon(4, xprof, yprof);
4248   hiCablesExtPUR->DefineSection(0, 0);
4249   hiCablesExtPUR->DefineSection(1, kHiVoltageCableSectCu*2);
4250
4251   // The Coaxial cables inside the forward tray: two Xtru
4252   TGeoXtru *coaxCablesForwCu = new TGeoXtru(2);
4253   coaxCablesForwCu->SetName("ITSsuppSPDForwTrayCoaxCu");
4254
4255   xprof[0] = -kTrayCCablesZLenOut;
4256   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4257   xprof[1] = 0;
4258   yprof[1] = 0;
4259   xprof[2] = kForwardTrayTotalLen;
4260   yprof[2] = yprof[1];
4261   xprof[3] = xprof[2];
4262   yprof[3] = yprof[2] + kCoaxCableSectCu/2;
4263   xprof[4] = xprof[1];
4264   yprof[4] = yprof[3];
4265   xprof[5] = xprof[0];
4266   yprof[5] = yprof[0] + kCoaxCableSectCu/2;
4267
4268   coaxCablesForwCu->DefinePolygon(6, xprof, yprof);
4269   coaxCablesForwCu->DefineSection(0,-kCoaxCableSectCu);
4270   coaxCablesForwCu->DefineSection(1, kCoaxCableSectCu);
4271
4272   TGeoXtru *coaxCablesForwMeg = new TGeoXtru(2);
4273   coaxCablesForwMeg->SetName("ITSsuppSPDForwTrayCoaxMeg");
4274
4275   xprof[0] = coaxCablesForwCu->GetX(5);
4276   yprof[0] = coaxCablesForwCu->GetY(5);
4277   xprof[1] = coaxCablesForwCu->GetX(4);
4278   yprof[1] = coaxCablesForwCu->GetY(4);
4279   xprof[2] = coaxCablesForwCu->GetX(3);
4280   yprof[2] = coaxCablesForwCu->GetY(3);
4281   xprof[3] = xprof[2];
4282   yprof[3] = yprof[2] + kCoaxCableHighMeg/2;
4283   xprof[4] = xprof[1];
4284   yprof[4] = yprof[3];
4285   xprof[5] = xprof[0];
4286   yprof[5] = yprof[0] + kCoaxCableHighMeg/2;
4287
4288   coaxCablesForwMeg->DefinePolygon(6, xprof, yprof);
4289   coaxCablesForwMeg->DefineSection(0,-kCoaxCableSectCu);
4290   coaxCablesForwMeg->DefineSection(1, kCoaxCableSectCu);
4291
4292   // The Coaxial inside the external tray: two Xtru
4293   TGeoXtru *coaxCablesExtCu = new TGeoXtru(2);
4294   coaxCablesExtCu->SetName("ITSsuppSPDExtTrayCoaxCu");
4295
4296   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4297            + 2*forwTrayWall->GetDY();
4298   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4299   xprof[1] = kExternalTrayLen;
4300   yprof[1] = yprof[0];
4301   xprof[2] = xprof[1];
4302   yprof[2] = yprof[1] + kCoaxCableSectCu/2;
4303   yprof[3] = yprof[2];
4304   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4305
4306   coaxCablesExtCu->DefinePolygon(4, xprof, yprof);
4307   coaxCablesExtCu->DefineSection(0, 0);
4308   coaxCablesExtCu->DefineSection(1, kCoaxCableSectCu*2);
4309
4310   TGeoXtru *coaxCablesExtMeg = new TGeoXtru(2);
4311   coaxCablesExtMeg->SetName("ITSsuppSPDExtTrayCoaxMeg");
4312
4313   xprof[0] = coaxCablesExtCu->GetX(3);
4314   yprof[0] = coaxCablesExtCu->GetY(3);
4315   xprof[1] = coaxCablesExtCu->GetX(2);
4316   yprof[1] = coaxCablesExtCu->GetY(2);
4317   xprof[2] = xprof[1];
4318   yprof[2] = yprof[1] + kCoaxCableHighMeg/2;
4319   yprof[3] = yprof[2];
4320   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4321
4322   coaxCablesExtMeg->DefinePolygon(4, xprof, yprof);
4323   coaxCablesExtMeg->DefineSection(0, 0);
4324   coaxCablesExtMeg->DefineSection(1, kCoaxCableSectCu*2);
4325
4326
4327   // We have all shapes: now create the real volumes
4328   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
4329   TGeoMedium *medIn    = mgr->GetMedium("ITS_INOX$");
4330   TGeoMedium *medFreon = mgr->GetMedium("ITS_GASEOUS FREON$");
4331   TGeoMedium *medFibs  = mgr->GetMedium("ITS_SDD OPTICFIB$");//!TO BE CHECKED!
4332   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
4333   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
4334   TGeoMedium *medMeg   = mgr->GetMedium("ITS_MEGOLON$");
4335
4336   TGeoVolume *forwTrayABase = new TGeoVolume("ITSsuppSPDSideAForwTrayABase",
4337                                             forwTrayLowerFace, medAl);
4338
4339   forwTrayABase->SetVisibility(kTRUE);
4340   forwTrayABase->SetLineColor(6); // Purple
4341   forwTrayABase->SetLineWidth(1);
4342   forwTrayABase->SetFillColor(forwTrayABase->GetLineColor());
4343   forwTrayABase->SetFillStyle(4000); // 0% transparent
4344
4345   TGeoVolume *forwTrayASide = new TGeoVolume("ITSsuppSPDSideAForwTrayASide",
4346                                             forwTraySideFace, medAl);
4347
4348   forwTrayASide->SetVisibility(kTRUE);
4349   forwTrayASide->SetLineColor(6); // Purple
4350   forwTrayASide->SetLineWidth(1);
4351   forwTrayASide->SetFillColor(forwTrayASide->GetLineColor());
4352   forwTrayASide->SetFillStyle(4000); // 0% transparent
4353
4354   TGeoVolume *forwTrayACoverShort = new TGeoVolume("ITSsuppSPDSideAForwTrayASC",
4355                                                   forwTrayShortCover, medAl);
4356
4357   forwTrayACoverShort->SetVisibility(kTRUE);
4358   forwTrayACoverShort->SetLineColor(6); // Purple
4359   forwTrayACoverShort->SetLineWidth(1);
4360   forwTrayACoverShort->SetFillColor(forwTrayACoverShort->GetLineColor());
4361   forwTrayACoverShort->SetFillStyle(4000); // 0% transparent
4362
4363   TGeoVolume *forwTrayACoverLong = new TGeoVolume("ITSsuppSPDSideAForwTrayALC",
4364                                                  forwTrayLongCover, medAl);
4365
4366   forwTrayACoverLong->SetVisibility(kTRUE);
4367   forwTrayACoverLong->SetLineColor(6); // Purple
4368   forwTrayACoverLong->SetLineWidth(1);
4369   forwTrayACoverLong->SetFillColor(forwTrayACoverLong->GetLineColor());
4370   forwTrayACoverLong->SetFillStyle(4000); // 0% transparent
4371
4372   TGeoVolume *forwTrayAWing = new TGeoVolume("ITSsuppSPDSideAForwTrayAWing",
4373                                              forwTrayWing, medAl);
4374
4375   forwTrayAWing->SetVisibility(kTRUE);
4376   forwTrayAWing->SetLineColor(6); // Purple
4377   forwTrayAWing->SetLineWidth(1);
4378   forwTrayAWing->SetFillColor(forwTrayAWing->GetLineColor());
4379   forwTrayAWing->SetFillStyle(4000); // 0% transparent
4380
4381   TGeoVolume *forwTrayAPlane = new TGeoVolume("ITSsuppSPDSideAForwTrayAPlane",
4382                                               forwTrayPlane, medAl);
4383
4384   forwTrayAPlane->SetVisibility(kTRUE);
4385   forwTrayAPlane->SetLineColor(6); // Purple
4386   forwTrayAPlane->SetLineWidth(1);
4387   forwTrayAPlane->SetFillColor(forwTrayAPlane->GetLineColor());
4388   forwTrayAPlane->SetFillStyle(4000); // 0% transparent
4389
4390   TGeoVolume *forwTrayAWall = new TGeoVolume("ITSsuppSPDSideAForwTrayAWall",
4391                                              forwTrayWall, medAl);
4392
4393   forwTrayAWall->SetVisibility(kTRUE);
4394   forwTrayAWall->SetLineColor(6); // Purple
4395   forwTrayAWall->SetLineWidth(1);
4396   forwTrayAWall->SetFillColor(forwTrayAWall->GetLineColor());
4397   forwTrayAWall->SetFillStyle(4000); // 0% transparent
4398
4399   TGeoVolume *extTrayAHorFace = new TGeoVolume("ITSsuppSPDSideAExtTrayHorFace",
4400                                                extTrayHorFace, medAl);
4401
4402   extTrayAHorFace->SetVisibility(kTRUE);
4403   extTrayAHorFace->SetLineColor(6); // Purple
4404   extTrayAHorFace->SetLineWidth(1);
4405   extTrayAHorFace->SetFillColor(extTrayAHorFace->GetLineColor());
4406   extTrayAHorFace->SetFillStyle(4000); // 0% transparent
4407
4408   TGeoVolume *extTrayAVerFace = new TGeoVolume("ITSsuppSPDSideAExtTrayVerFace",
4409                                                extTrayVerFace, medAl);
4410
4411   extTrayAVerFace->SetVisibility(kTRUE);
4412   extTrayAVerFace->SetLineColor(6); // Purple
4413   extTrayAVerFace->SetLineWidth(1);
4414   extTrayAVerFace->SetFillColor(extTrayAVerFace->GetLineColor());
4415   extTrayAVerFace->SetFillStyle(4000); // 0% transparent
4416
4417   TGeoVolume *extTrayAWall = new TGeoVolume("ITSsuppSPDSideAExtTrayWall",
4418                                             extTrayWall, medAl);
4419
4420   extTrayAWall->SetVisibility(kTRUE);
4421   extTrayAWall->SetLineColor(6); // Purple
4422   extTrayAWall->SetLineWidth(1);
4423   extTrayAWall->SetFillColor(extTrayAWall->GetLineColor());
4424   extTrayAWall->SetFillStyle(4000); // 0% transparent
4425
4426   TGeoVolume *forwCoolTube = new TGeoVolume("ITSsuppSPDSideAForwTrayCoolTube",
4427                                             coolTubeForw, medIn);
4428
4429   forwCoolTube->SetVisibility(kTRUE);
4430   forwCoolTube->SetLineColor(kGray); // as in GeometrySPD
4431   forwCoolTube->SetLineWidth(1);
4432   forwCoolTube->SetFillColor(forwCoolTube->GetLineColor());
4433   forwCoolTube->SetFillStyle(4000); // 0% transparent
4434
4435   TGeoVolume *forwCoolFreon = new TGeoVolume("ITSsuppSPDSideAForwTrayFreon",
4436                                              freonTubeForw, medFreon);
4437
4438   forwCoolFreon->SetVisibility(kTRUE);
4439   forwCoolFreon->SetLineColor(kBlue); // Blue
4440   forwCoolFreon->SetLineWidth(1);
4441   forwCoolFreon->SetFillColor(forwCoolFreon->GetLineColor());
4442   forwCoolFreon->SetFillStyle(4000); // 0% transparent
4443
4444   TGeoVolume *extCoolTube = new TGeoVolume("ITSsuppSPDSideAExtTrayCoolTube",
4445                                            coolTubeExt, medIn);
4446
4447   extCoolTube->SetVisibility(kTRUE);
4448   extCoolTube->SetLineColor(kGray); // as in GeometrySPD
4449   extCoolTube->SetLineWidth(1);
4450   extCoolTube->SetFillColor(extCoolTube->GetLineColor());
4451   extCoolTube->SetFillStyle(4000); // 0% transparent
4452
4453   TGeoVolume *extCoolFreon = new TGeoVolume("ITSsuppSPDSideAExtTrayFreon",
4454                                             freonTubeExt, medFreon);
4455
4456   extCoolFreon->SetVisibility(kTRUE);
4457   extCoolFreon->SetLineColor(kBlue); // Blue
4458   extCoolFreon->SetLineWidth(1);
4459   extCoolFreon->SetFillColor(extCoolFreon->GetLineColor());
4460   extCoolFreon->SetFillStyle(4000); // 0% transparent
4461
4462   TGeoVolume *forwOptFibs = new TGeoVolume("ITSsuppSPDSideAForwTrayOptFibs",
4463                                            optFibsForw, medFibs);
4464
4465   forwOptFibs->SetVisibility(kTRUE);
4466   forwOptFibs->SetLineColor(kOrange); // Orange
4467   forwOptFibs->SetLineWidth(1);
4468   forwOptFibs->SetFillColor(forwOptFibs->GetLineColor());
4469   forwOptFibs->SetFillStyle(4000); // 0% transparent
4470
4471   TGeoVolume *extOptFibs = new TGeoVolume("ITSsuppSPDSideAExtTrayOptFibs",
4472                                           optFibsExt, medFibs);
4473
4474   extOptFibs->SetVisibility(kTRUE);
4475   extOptFibs->SetLineColor(kOrange); // Orange
4476   extOptFibs->SetLineWidth(1);
4477   extOptFibs->SetFillColor(extOptFibs->GetLineColor());
4478   extOptFibs->SetFillStyle(4000); // 0% transparent
4479
4480   TGeoVolume *forwLowCabsCu = new TGeoVolume("ITSsuppSPDSideAForwLowCabsCu",
4481                                              lowCablesForwCu, medCu);
4482
4483   forwLowCabsCu->SetVisibility(kTRUE);
4484   forwLowCabsCu->SetLineColor(kRed); // Red
4485   forwLowCabsCu->SetLineWidth(1);
4486   forwLowCabsCu->SetFillColor(forwLowCabsCu->GetLineColor());
4487   forwLowCabsCu->SetFillStyle(4000); // 0% transparent
4488
4489   TGeoVolume *forwLowCabsPUR = new TGeoVolume("ITSsuppSPDSideAForwLowCabsPUR",
4490                                               lowCablesForwPUR, medPUR);
4491
4492   forwLowCabsPUR->SetVisibility(kTRUE);
4493   forwLowCabsPUR->SetLineColor(kBlack); // Black
4494   forwLowCabsPUR->SetLineWidth(1);
4495   forwLowCabsPUR->SetFillColor(forwLowCabsPUR->GetLineColor());
4496   forwLowCabsPUR->SetFillStyle(4000); // 0% transparent
4497
4498   TGeoVolume *extLowCabsCu = new TGeoVolume("ITSsuppSPDSideAExtLowCabsCu",
4499                                             lowCablesExtCu, medCu);
4500
4501   extLowCabsCu->SetVisibility(kTRUE);
4502   extLowCabsCu->SetLineColor(kRed); // Red
4503   extLowCabsCu->SetLineWidth(1);
4504   extLowCabsCu->SetFillColor(extLowCabsCu->GetLineColor());
4505   extLowCabsCu->SetFillStyle(4000); // 0% transparent
4506
4507   TGeoVolume *extLowCabsPUR = new TGeoVolume("ITSsuppSPDSideAExtLowCabsPUR",
4508                                              lowCablesExtPUR, medPUR);
4509
4510   extLowCabsPUR->SetVisibility(kTRUE);
4511   extLowCabsPUR->SetLineColor(kBlack); // Black
4512   extLowCabsPUR->SetLineWidth(1);
4513   extLowCabsPUR->SetFillColor(extLowCabsPUR->GetLineColor());
4514   extLowCabsPUR->SetFillStyle(4000); // 0% transparent
4515
4516   TGeoVolume *forwHiCabsCu = new TGeoVolume("ITSsuppSPDSideAForwTrayHiCabsCu",
4517                                             hiCablesForwCu, medCu);
4518
4519   forwHiCabsCu->SetVisibility(kTRUE);
4520   forwHiCabsCu->SetLineColor(kRed); // Red
4521   forwHiCabsCu->SetLineWidth(1);
4522   forwHiCabsCu->SetFillColor(forwHiCabsCu->GetLineColor());
4523   forwHiCabsCu->SetFillStyle(4000); // 0% transparent
4524
4525   TGeoVolume *forwHiCabsPUR = new TGeoVolume("ITSsuppSPDSideAForwTrayHiCabsPUR",
4526                                              hiCablesForwPUR, medPUR);
4527
4528   forwHiCabsPUR->SetVisibility(kTRUE);
4529   forwHiCabsPUR->SetLineColor(kBlack); // Black
4530   forwHiCabsPUR->SetLineWidth(1);
4531   forwHiCabsPUR->SetFillColor(forwHiCabsPUR->GetLineColor());
4532   forwHiCabsPUR->SetFillStyle(4000); // 0% transparent
4533
4534   TGeoVolume *extHiCabsCu = new TGeoVolume("ITSsuppSPDSideAExtTrayHiCabsCu",
4535                                            hiCablesExtCu, medCu);
4536
4537   extHiCabsCu->SetVisibility(kTRUE);
4538   extHiCabsCu->SetLineColor(kRed); // Red
4539   extHiCabsCu->SetLineWidth(1);
4540   extHiCabsCu->SetFillColor(extHiCabsCu->GetLineColor());
4541   extHiCabsCu->SetFillStyle(4000); // 0% transparent
4542
4543   TGeoVolume *extHiCabsPUR = new TGeoVolume("ITSsuppSPDSideAExtTrayHiCabsPUR",
4544                                             hiCablesExtPUR, medPUR);
4545
4546   extHiCabsPUR->SetVisibility(kTRUE);
4547   extHiCabsPUR->SetLineColor(kBlack); // Black
4548   extHiCabsPUR->SetLineWidth(1);
4549   extHiCabsPUR->SetFillColor(extHiCabsPUR->GetLineColor());
4550   extHiCabsPUR->SetFillStyle(4000); // 0% transparent
4551
4552   TGeoVolume *forwCoaxCu = new TGeoVolume("ITSsuppSPDSideAForwTrayCoaxCu",
4553                                           coaxCablesForwCu, medCu);
4554
4555   forwCoaxCu->SetVisibility(kTRUE);
4556   forwCoaxCu->SetLineColor(kRed); // Red
4557   forwCoaxCu->SetLineWidth(1);
4558   forwCoaxCu->SetFillColor(forwCoaxCu->GetLineColor());
4559   forwCoaxCu->SetFillStyle(4000); // 0% transparent
4560
4561   TGeoVolume *forwCoaxMeg = new TGeoVolume("ITSsuppSPDSideAForwTrayCoaxMeg",
4562                                            coaxCablesForwMeg, medMeg);
4563
4564   forwCoaxMeg->SetVisibility(kTRUE);
4565   forwCoaxMeg->SetLineColor(kBlack); // Black
4566   forwCoaxMeg->SetLineWidth(1);
4567   forwCoaxMeg->SetFillColor(forwCoaxMeg->GetLineColor());
4568   forwCoaxMeg->SetFillStyle(4000); // 0% transparent
4569
4570   TGeoVolume *extCoaxCu = new TGeoVolume("ITSsuppSPDSideAExtTrayCoaxCu",
4571                                          coaxCablesExtCu, medCu);
4572
4573   extCoaxCu->SetVisibility(kTRUE);
4574   extCoaxCu->SetLineColor(kRed); // Red
4575   extCoaxCu->SetLineWidth(1);
4576   extCoaxCu->SetFillColor(extCoaxCu->GetLineColor());
4577   extCoaxCu->SetFillStyle(4000); // 0% transparent
4578
4579   TGeoVolume *extCoaxMeg = new TGeoVolume("ITSsuppSPDSideAExtTrayCoaxMeg",
4580                                           coaxCablesExtMeg, medMeg);
4581
4582   extCoaxMeg->SetVisibility(kTRUE);
4583   extCoaxMeg->SetLineColor(kBlack); // Black
4584   extCoaxMeg->SetLineWidth(1);
4585   extCoaxMeg->SetFillColor(extCoaxMeg->GetLineColor());
4586   extCoaxMeg->SetFillStyle(4000); // 0% transparent
4587
4588
4589   // Now build up the trays
4590   yloc = forwTrayLowerFace->GetDY();
4591   zloc = forwTrayLowerFace->GetDZ();
4592   cableTrayAForw->AddNode(forwTrayABase, 1,
4593                       new TGeoTranslation(0, yloc, zloc));
4594
4595   xloc = kForwardTrayWide/2;
4596   cableTrayAForw->AddNode(forwTrayASide, 1,
4597                       new TGeoCombiTrans( xloc, 0, 0,
4598                                          new TGeoRotation("",90,-90,-90)));
4599   cableTrayAForw->AddNode(forwTrayASide, 2,
4600                       new TGeoCombiTrans(-xloc+kForwardTrayThick, 0, 0,
4601                                          new TGeoRotation("",90,-90,-90)));
4602
4603   yloc = kForwardTrayFirstHigh - forwTrayShortCover->GetDY();
4604   zloc = forwTrayShortCover->GetDZ();
4605   cableTrayAForw->AddNode(forwTrayACoverShort, 1,
4606                       new TGeoTranslation(0, yloc, zloc));
4607
4608   yloc = kForwardTraySecondHigh - forwTrayLongCover->GetDY();
4609   zloc = kForwardTrayFirstLen + forwTrayLongCover->GetDZ();
4610   cableTrayAForw->AddNode(forwTrayACoverLong, 1,
4611                       new TGeoTranslation(0, yloc, zloc));
4612
4613   xloc = kForwardTrayWide/2 - kForwardTrayThick - forwTrayWing->GetDX();
4614   yloc = kForwardTrayFirstHigh - kForwardTrayThick - forwTrayWing->GetDY();
4615   zloc = kForwardTrayFirstLen - forwTrayWing->GetDZ();
4616   cableTrayAForw->AddNode(forwTrayAWing, 1,
4617                       new TGeoTranslation( xloc, yloc, zloc));
4618   cableTrayAForw->AddNode(forwTrayAWing, 2,
4619                       new TGeoTranslation(-xloc, yloc, zloc));
4620
4621   yloc = kForwardTrayThick + kForwardTrayInterSpace - forwTrayPlane->GetDY();
4622   zloc = forwTrayPlane->GetDZ();
4623   cableTrayAForw->AddNode(forwTrayAPlane, 1,
4624                       new TGeoTranslation(0, yloc, zloc));
4625
4626   yloc = kForwardTrayThick + forwTrayWall->GetDY();
4627   zloc = forwTrayWall->GetDZ();
4628   cableTrayAForw->AddNode(forwTrayAWall, 1,
4629                       new TGeoTranslation(0, yloc, zloc));
4630
4631   forwCoolTube->AddNode(forwCoolFreon, 1, 0);
4632
4633   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY()
4634        + coolTubeForw->GetRmax();
4635   zloc = coolTubeForw->GetDz();
4636   cableTrayAForw->AddNode(forwCoolTube, 1,
4637                       new TGeoTranslation(0, yloc, zloc));
4638
4639   xloc = optFibsForw->GetZ(1) + coolTubeForw->GetRmax();
4640   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4641   cableTrayAForw->AddNode(forwOptFibs, 1,
4642                       new TGeoCombiTrans( xloc, yloc, 0,
4643                                          new TGeoRotation("",-90.,90.,90.)));
4644
4645   xloc = lowCablesForwCu->GetZ(1) + coolTubeForw->GetRmax();
4646   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4647   cableTrayAForw->AddNode(forwLowCabsCu, 1,
4648                       new TGeoCombiTrans(-xloc, yloc, 0,
4649                                          new TGeoRotation("",-90.,90.,90.)));
4650   cableTrayAForw->AddNode(forwLowCabsPUR, 1,
4651                       new TGeoCombiTrans(-xloc, yloc, 0,
4652                                          new TGeoRotation("",-90.,90.,90.)));
4653
4654   xloc = 2*lowCablesForwCu->GetZ(1) +
4655          hiCablesForwCu->GetZ(1) + coolTubeForw->GetRmax();
4656   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4657   cableTrayAForw->AddNode(forwHiCabsCu, 1,
4658                       new TGeoCombiTrans(-xloc, yloc, 0,
4659                                          new TGeoRotation("",-90.,90.,90.)));
4660   cableTrayAForw->AddNode(forwHiCabsPUR, 1,
4661                       new TGeoCombiTrans(-xloc, yloc, 0,
4662                                          new TGeoRotation("",-90.,90.,90.)));
4663
4664   xloc = 2*optFibsForw->GetZ(1) + coaxCablesForwCu->GetZ(1) +
4665          coolTubeForw->GetRmax();
4666   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4667   cableTrayAForw->AddNode(forwCoaxCu, 1,
4668                       new TGeoCombiTrans( xloc, yloc, 0,
4669                                          new TGeoRotation("",-90.,90.,90.)));
4670   cableTrayAForw->AddNode(forwCoaxMeg, 1,
4671                       new TGeoCombiTrans( xloc, yloc, 0,
4672                                          new TGeoRotation("",-90.,90.,90.)));
4673
4674   // To simplify following placement in MARS, origin is on top
4675   yloc = -kExternalTrayHigh + kExternalTrayThick/2;
4676   zloc = kExternalTrayLen/2;
4677   cableTrayAExt->AddNode(extTrayAHorFace, 1,
4678                       new TGeoTranslation( 0, yloc, zloc));
4679
4680   xloc = kExternalTrayWide/2 - kExternalTrayThick/2;
4681   yloc = -kExternalTrayHigh/2;
4682   cableTrayAExt->AddNode(extTrayAVerFace, 1,
4683                       new TGeoTranslation( xloc, yloc, zloc));
4684   cableTrayAExt->AddNode(extTrayAVerFace, 2,
4685                       new TGeoTranslation(-xloc, yloc, zloc));
4686
4687   yloc = -kExternalTrayThick/2;
4688   cableTrayAExt->AddNode(extTrayAHorFace, 2,
4689                       new TGeoTranslation( 0, yloc, zloc));
4690
4691   yloc = -kExternalTrayHigh
4692        + kExternalTrayThick + kForwardTrayInterSpace - kExternalTrayThick/2;
4693   cableTrayAExt->AddNode(extTrayAHorFace, 3,
4694                       new TGeoTranslation( 0, yloc, zloc));
4695
4696   yloc = -kExternalTrayHigh + kExternalTrayThick + extTrayWall->GetDY();
4697   cableTrayAExt->AddNode(extTrayAWall, 1,
4698                       new TGeoTranslation( 0, yloc, zloc));
4699
4700   extCoolTube->AddNode(extCoolFreon, 1, 0);
4701
4702   yloc = -kExternalTrayHigh + 2*kExternalTrayThick + 2*extTrayWall->GetDY()
4703        + coolTubeExt->GetRmax();
4704   zloc = coolTubeExt->GetDz();
4705   cableTrayAExt->AddNode(extCoolTube, 1,
4706                       new TGeoTranslation(0, yloc, zloc));
4707
4708   xloc = optFibsExt->GetZ(1) + coolTubeExt->GetRmax();
4709   cableTrayAExt->AddNode(extOptFibs, 1,
4710                       new TGeoCombiTrans( xloc, 0, 0,
4711                                          new TGeoRotation("",90,-90,-90)));
4712
4713   xloc = coolTubeExt->GetRmax();
4714   cableTrayAExt->AddNode(extLowCabsCu, 1,
4715                       new TGeoCombiTrans(-xloc, 0, 0,
4716                                          new TGeoRotation("",90,-90,-90)));
4717   cableTrayAExt->AddNode(extLowCabsPUR, 1,
4718                       new TGeoCombiTrans(-xloc, 0, 0,
4719                                          new TGeoRotation("",90,-90,-90)));
4720
4721   xloc = lowCablesExtCu->GetZ(1) + coolTubeExt->GetRmax();
4722   cableTrayAExt->AddNode(extHiCabsCu, 1,
4723                       new TGeoCombiTrans(-xloc, 0, 0,
4724                                          new TGeoRotation("",90,-90,-90)));
4725   cableTrayAExt->AddNode(extHiCabsPUR, 1,
4726                       new TGeoCombiTrans(-xloc, 0, 0,
4727                                          new TGeoRotation("",90,-90,-90)));
4728
4729   xloc = coaxCablesExtCu->GetZ(1) + optFibsExt->GetZ(1) +
4730          coolTubeExt->GetRmax();
4731   cableTrayAExt->AddNode(extCoaxCu, 1,
4732                       new TGeoCombiTrans( xloc, 0, 0,
4733                                          new TGeoRotation("",90,-90,-90)));
4734   cableTrayAExt->AddNode(extCoaxMeg, 1,
4735                       new TGeoCombiTrans( xloc, 0, 0,
4736                                          new TGeoRotation("",90,-90,-90)));
4737
4738
4739   // Finally put everything in the mother volume
4740   Double_t rExtTray = kTrayAR2Trans + kExternalTrayHigh;
4741
4742   moth->AddNode(cableTrayAForw,1,
4743                 new TGeoTranslation( 0, kTrayAR1Trans, kTrayAZTrans));
4744   moth->AddNode(cableTrayAForw,2,
4745                 new TGeoCombiTrans(  0,-kTrayAR1Trans, kTrayAZTrans,
4746                                     new TGeoRotation("",180, 0, 0)));
4747
4748   yloc = kTrayAR1Trans + kExternalTrayHigh;
4749   zloc = kTrayAZTrans + kForwardTrayTotalLen;
4750   moth->AddNode(cableTrayAExt,1,
4751                 new TGeoCombiTrans( 0, yloc, zloc,
4752                                     new TGeoRotation("",  0,-kTrayAZRot, 0)));
4753   moth->AddNode(cableTrayAExt,2,
4754                 new TGeoCombiTrans( 0,-yloc, zloc,
4755                                     new TGeoRotation("",180,-kTrayAZRot, 0)));
4756
4757   alpharot = kTrayAFirstRotAng + kTrayASecondRotAng;
4758   xloc = kTrayAR2Trans*SinD(alpharot);
4759   yloc = kTrayAR2Trans*CosD(alpharot);
4760   moth->AddNode(cableTrayAForw,3,
4761                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4762                             new TGeoRotation("",-alpharot,0,0)   )   );
4763   xloc = rExtTray*SinD(alpharot);
4764   yloc = rExtTray*CosD(alpharot);
4765   moth->AddNode(cableTrayAExt,3,
4766                             new TGeoCombiTrans( xloc, yloc, zloc,
4767                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4768
4769   alpharot += 180;
4770   xloc = kTrayAR2Trans*SinD(alpharot);
4771   yloc = kTrayAR2Trans*CosD(alpharot);
4772   moth->AddNode(cableTrayAForw,4,
4773                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4774                             new TGeoRotation("",-alpharot,0,0)   )   );
4775   xloc = rExtTray*SinD(alpharot);
4776   yloc = rExtTray*CosD(alpharot);
4777   moth->AddNode(cableTrayAExt,4,
4778                             new TGeoCombiTrans( xloc, yloc, zloc,
4779                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4780
4781   alpharot = - kTrayAFirstRotAng - kTrayASecondRotAng;
4782   xloc = kTrayAR2Trans*SinD(alpharot);
4783   yloc = kTrayAR2Trans*CosD(alpharot);
4784   moth->AddNode(cableTrayAForw,5,
4785                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4786                             new TGeoRotation("",-alpharot,0,0)   )   );
4787   xloc = rExtTray*SinD(alpharot);
4788   yloc = rExtTray*CosD(alpharot);
4789   moth->AddNode(cableTrayAExt,5,
4790                             new TGeoCombiTrans( xloc, yloc, zloc,
4791                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4792
4793   alpharot += 180;
4794   xloc = kTrayAR2Trans*SinD(alpharot);
4795   yloc = kTrayAR2Trans*CosD(alpharot);
4796   moth->AddNode(cableTrayAForw,6,
4797                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4798                             new TGeoRotation("",-alpharot,0,0)   )   );
4799   xloc = rExtTray*SinD(alpharot);
4800   yloc = rExtTray*CosD(alpharot);
4801   moth->AddNode(cableTrayAExt,6,
4802                             new TGeoCombiTrans( xloc, yloc, zloc,
4803                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4804
4805   alpharot = kTrayAFirstRotAng + 3*kTrayASecondRotAng;
4806   xloc = kTrayAR2Trans*SinD(alpharot);
4807   yloc = kTrayAR2Trans*CosD(alpharot);
4808   moth->AddNode(cableTrayAForw,7,
4809                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4810                             new TGeoRotation("",-alpharot,0,0)   )   );
4811   xloc = rExtTray*SinD(alpharot);
4812   yloc = rExtTray*CosD(alpharot);
4813   moth->AddNode(cableTrayAExt,7,
4814                             new TGeoCombiTrans( xloc, yloc, zloc,
4815                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4816
4817   alpharot += 180;
4818   xloc = kTrayAR2Trans*SinD(alpharot);
4819   yloc = kTrayAR2Trans*CosD(alpharot);
4820   moth->AddNode(cableTrayAForw,8,
4821                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4822                             new TGeoRotation("",-alpharot,0,0)   )   );
4823   xloc = rExtTray*SinD(alpharot);
4824   yloc = rExtTray*CosD(alpharot);
4825   moth->AddNode(cableTrayAExt,8,
4826                             new TGeoCombiTrans( xloc, yloc, zloc,
4827                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4828
4829   alpharot = - kTrayAFirstRotAng - 3*kTrayASecondRotAng;
4830   xloc = kTrayAR2Trans*SinD(alpharot);
4831   yloc = kTrayAR2Trans*CosD(alpharot);
4832   moth->AddNode(cableTrayAForw,9,
4833                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4834                             new TGeoRotation("",-alpharot,0,0)   )   );
4835   xloc = rExtTray*SinD(alpharot);
4836   yloc = rExtTray*CosD(alpharot);
4837   moth->AddNode(cableTrayAExt,9,
4838                             new TGeoCombiTrans( xloc, yloc, zloc,
4839                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4840
4841   alpharot += 180;
4842   xloc = kTrayAR2Trans*SinD(alpharot);
4843   yloc = kTrayAR2Trans*CosD(alpharot);
4844   moth->AddNode(cableTrayAForw,10,
4845                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4846                             new TGeoRotation("",-alpharot,0,0)   )   );
4847   xloc = rExtTray*SinD(alpharot);
4848   yloc = rExtTray*CosD(alpharot);
4849   moth->AddNode(cableTrayAExt,10,
4850                             new TGeoCombiTrans( xloc, yloc, zloc,
4851                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4852
4853
4854   return;
4855 }
4856
4857 //______________________________________________________________________
4858 void AliITSv11GeometrySupport::SPDCableTraysSideC(TGeoVolume *moth,
4859                                             const TGeoManager *mgr){
4860 //
4861 // Creates the SPD cable trays which are outside the ITS support cones
4862 // but still inside the TPC on Side C
4863 // (part of this code is taken or anyway inspired to ServicesCableSupport
4864 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
4865 //
4866 // Input:
4867 //         moth : the TGeoVolume owing the volume structure
4868 //         mgr  : the GeoManager (default gGeoManager)
4869 // Output:
4870 //
4871 // Return:
4872 //
4873 // Created:         ???       Bjorn S. Nilsen
4874 // Updated:      22 Apr 2010  Mario Sitta
4875 // Updated:      10 Jun 2010  Mario Sitta  Freon inside cooling pipes
4876 // Updated:      08 Sep 2010  Mario Sitta
4877 // Updated:      14 Sep 2010  Mario Sitta  Cables prolonged till cone
4878 // Updated:      20 Dec 2011  Mario Sitta  Composite vol to avoid new overlap
4879 //
4880 // Technical data are taken from AutoCAD drawings and other (oral)
4881 // information given by D.Elia
4882 // Optical fibers and voltage cables are approximated with mean materials
4883 // and square cross sections, but preserving the total material budget.
4884 //
4885
4886   // Dimensions and positions of the C-Side Cable Tray elements
4887   const Int_t    kNumTraysSideC       =   10;
4888
4889   const Double_t kTrayCCablesOutRot   =   75.000 *fgkDegree;// Computed
4890   const Double_t kTrayCCablesZLenOut  =  245.000 *fgkmm;// Computed
4891
4892   const Double_t kTrayCHalfWide       =    6.350 *fgkcm;
4893   const Double_t kTrayCLength1        =  172.800 *fgkcm;
4894   const Double_t kTrayCLength2        =  189.300 *fgkcm;
4895   const Double_t kTrayCFirstLen       =  435.000 *fgkmm;
4896   const Double_t kTrayCFirstHigh      =   83.000 *fgkmm;//!!!TO BE CHECKED!!!
4897   const Double_t kTrayCSecondHigh     =   52.700 *fgkmm;//!!!TO BE CHECKED!!!
4898   const Double_t kTrayCThick          =    0.200 *fgkcm;
4899   const Double_t kTrayCInterSpace     =   18.000 *fgkmm;//!!!TO BE CHECKED!!!
4900   const Double_t kTrayCFoldAngle      =    5.000 *fgkDegree;
4901
4902   const Double_t kCoolingTubeRmin     =    2.000 *fgkmm;
4903   const Double_t kCoolingTubeRmax     =    3.000 *fgkmm;
4904   const Double_t kOpticalFibersSect   =    8.696 *fgkmm;//!!!ESTIMATED!!!
4905   const Double_t kLowVoltCableSectCu  =    7.675 *fgkmm;// Computed
4906   const Double_t kLowVoltCableHighPUR =    1.000 *fgkmm;// Computed
4907   const Double_t kHiVoltCableSectCu   =    1.535 *fgkmm;// Computed
4908   const Double_t kHiVoltCableHighPUR  =    0.500 *fgkmm;// Computed
4909   const Double_t kCoaxCableSectCu     =    6.024 *fgkmm;// Computed
4910   const Double_t kCoaxCableHighMeg    =    5.695 *fgkmm;// Computed
4911
4912   const Double_t kCablesYtrans        =    2.500 *fgkmm;// Avoid ovlps
4913
4914   // Overall position and rotation of the C-Side Cable Trays
4915   const Double_t kTraySideCRPos       =   45.300 *fgkcm;
4916   const Double_t kTraySideCZPos       = -102.400 *fgkcm;
4917   const Double_t kTraySideCAlphaRot[kNumTraysSideC/2]  =
4918     {    0.0,      41.0,     -41.0,      76.0,      -76.0};
4919   // From position of the other trays
4920
4921
4922   // Local variables
4923   Double_t xprof[8], yprof[8];
4924   Double_t xloc, yloc, zloc, delta, alpharot;
4925
4926
4927   // The single C-Side Cable tray as an assembly
4928   TGeoVolumeAssembly *cableTrayC = new TGeoVolumeAssembly("ITSsupportSPDTrayC");
4929
4930   // First create all needed shapes
4931
4932   // The Cable Tray lower face: a Xtru
4933   TGeoXtru *sideCHorFace = new TGeoXtru(2);
4934   sideCHorFace->SetName("ITSsuppSPDTraySideCHor");
4935
4936   xprof[0] = 0.;
4937   yprof[0] = 0.;
4938   xprof[1] = kTrayCLength1;
4939   yprof[1] = 0.;
4940   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4941   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4942   xprof[3] = xprof[2] - kTrayCThick*SinD(kTrayCFoldAngle);
4943   yprof[3] = yprof[2] + kTrayCThick*CosD(kTrayCFoldAngle);
4944   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4945               kTrayCThick , xprof[4], yprof[4]);
4946   xprof[5] = 0.;
4947   yprof[5] = kTrayCThick;
4948
4949   delta = kTrayCHalfWide - kTrayCThick;
4950
4951   sideCHorFace->DefinePolygon(6, xprof, yprof);
4952   sideCHorFace->DefineSection(0,-delta);
4953   sideCHorFace->DefineSection(1, delta);
4954
4955   // The Cable Tray middle face: a Xtru
4956   // (somehow duplicate of HorFace, but in this way avoid an overlap with Wall)
4957   TGeoXtru *sideCMidFace = new TGeoXtru(2);
4958
4959   xprof[0] = 0.;
4960   yprof[0] = kTrayCInterSpace + kTrayCThick;
4961   xprof[1] = kTrayCLength1;
4962   yprof[1] = yprof[0];
4963   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4964   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4965   xprof[3] = xprof[2] - kTrayCThick*SinD(kTrayCFoldAngle);
4966   yprof[3] = yprof[2] + kTrayCThick*CosD(kTrayCFoldAngle);
4967   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4968               kTrayCThick , xprof[4], yprof[4]);
4969   xprof[5] = 0.;
4970   yprof[5] = yprof[0] + kTrayCThick;
4971
4972   delta = kTrayCHalfWide - kTrayCThick;
4973
4974   sideCMidFace->DefinePolygon(6, xprof, yprof);
4975   sideCMidFace->DefineSection(0,-delta);
4976   sideCMidFace->DefineSection(1, delta);
4977
4978   // The Cable Tray lower face: a Xtru
4979   TGeoXtru *sideCSideFace = new TGeoXtru(2);
4980
4981   xprof[0] = 0.;
4982   yprof[0] = 0.;
4983   xprof[1] = kTrayCLength1;
4984   yprof[1] = 0.;
4985   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4986   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4987   xprof[3] = xprof[2] - kTrayCSecondHigh*SinD(kTrayCFoldAngle);
4988   yprof[3] = yprof[2] + kTrayCSecondHigh*CosD(kTrayCFoldAngle);
4989   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4990               kTrayCSecondHigh , xprof[4], yprof[4]);
4991   xprof[5] = kTrayCFirstLen;
4992   yprof[5] = kTrayCSecondHigh;
4993   xprof[6] = xprof[5];
4994   yprof[6] = kTrayCFirstHigh;
4995   xprof[7] = xprof[0];
4996   yprof[7] = yprof[6];
4997
4998   sideCSideFace->DefinePolygon(8, xprof, yprof);
4999   sideCSideFace->DefineSection(0, 0);
5000   sideCSideFace->DefineSection(1, kTrayCThick);
5001
5002   // The short cover: a BBox
5003   TGeoBBox *sideCShortCover = new TGeoBBox(kTrayCFirstLen/2,
5004                                            kTrayCThick/2,
5005                                            kTrayCHalfWide-kTrayCThick);
5006
5007   // The long cover: a Xtru
5008   TGeoXtru *sideCLongCover = new TGeoXtru(2);
5009
5010   xprof[5] = sideCSideFace->GetX(5);
5011   yprof[5] = sideCSideFace->GetY(5);
5012   xprof[4] = sideCSideFace->GetX(4);
5013   yprof[4] = sideCSideFace->GetY(4);
5014   xprof[3] = sideCSideFace->GetX(3);
5015   yprof[3] = sideCSideFace->GetY(3);
5016   xprof[2] = xprof[3] + kTrayCThick*SinD(kTrayCFoldAngle);
5017   yprof[2] = yprof[3] - kTrayCThick*CosD(kTrayCFoldAngle);
5018   InsidePoint(xprof[5], yprof[5], xprof[4], yprof[4], xprof[3], yprof[3],
5019              -kTrayCThick , xprof[1], yprof[1]);
5020   xprof[0] = xprof[5];
5021   yprof[0] = yprof[5] - kTrayCThick;
5022
5023   delta = kTrayCHalfWide - kTrayCThick;
5024
5025   sideCLongCover->DefinePolygon(6, xprof, yprof);
5026   sideCLongCover->DefineSection(0,-delta);
5027   sideCLongCover->DefineSection(1, delta);
5028
5029   // The internal wall: a Xtru
5030   TGeoXtru *intWall = new TGeoXtru(2);
5031   intWall->SetName("ITSsuppSPDTraySideCWall");
5032
5033   xprof[0] = sideCHorFace->GetX(5);
5034   yprof[0] = sideCHorFace->GetY(5);
5035   xprof[1] = sideCHorFace->GetX(4);
5036   yprof[1] = sideCHorFace->GetY(4);
5037   xprof[2] = sideCHorFace->GetX(3);
5038   yprof[2] = sideCHorFace->GetY(3);
5039   xprof[3] = sideCMidFace->GetX(2);
5040   yprof[3] = sideCMidFace->GetY(2);
5041   xprof[4] = sideCMidFace->GetX(1);
5042   yprof[4] = sideCMidFace->GetY(1);
5043   xprof[5] = sideCMidFace->GetX(0);
5044   yprof[5] = sideCMidFace->GetY(0);
5045
5046   intWall->DefinePolygon(6, xprof, yprof);
5047   intWall->DefineSection(0,-kTrayCThick/2);
5048   intWall->DefineSection(1, kTrayCThick/2);
5049
5050   // The horizontal part of the cooling tube inside the tray: a Tube
5051   delta = sideCMidFace->GetX(4) - sideCMidFace->GetX(5);
5052   TGeoTube *horTube = new TGeoTube(0, kCoolingTubeRmax, delta/2);
5053
5054   // The freon inside the horizontal part of the cooling tube: a Tube
5055   TGeoTube *horFreon = new TGeoTube(0, kCoolingTubeRmin, delta/2);
5056
5057   // The inclined part of the cooling tube inside the tray: a Ctub
5058   Double_t x3, y3, x4, y4;
5059   x3 = sideCMidFace->GetX(3);
5060   y3 = sideCMidFace->GetY(3);
5061   x4 = sideCMidFace->GetX(4);
5062   y4 = sideCMidFace->GetY(4);
5063   delta = TMath::Sqrt( (x4 - x3 + kCoolingTubeRmax*SinD(kTrayCFoldAngle))*
5064                        (x4 - x3 + kCoolingTubeRmax*SinD(kTrayCFoldAngle))    +
5065        (y4 + kCoolingTubeRmax - y3 - kCoolingTubeRmax*SinD(kTrayCFoldAngle))*
5066        (y4 + kCoolingTubeRmax - y3 - kCoolingTubeRmax*SinD(kTrayCFoldAngle)) );
5067
5068   TGeoCtub *incTube = new TGeoCtub(0, kCoolingTubeRmax, delta/2, 0, 360,
5069                                0, SinD(kTrayCFoldAngle),-CosD(kTrayCFoldAngle),
5070                                0,                     0,                    1);
5071
5072   // The freon inside the inclined part of the cooling tube: a Ctub
5073   TGeoCtub *incFreon = new TGeoCtub(0, kCoolingTubeRmin, delta/2, 0, 360,
5074                                0, SinD(kTrayCFoldAngle),-CosD(kTrayCFoldAngle),
5075                                0,                     0,                    1);
5076
5077   // The part of the cooling tube outside the tray: a Ctub
5078   TGeoCtub *outTube = new TGeoCtub(0, kCoolingTubeRmax,
5079                         0.5*kTrayCCablesZLenOut/SinD(kTrayCCablesOutRot),
5080                         0, 360,
5081                         0,                        0,                      -1,
5082                         0,-SinD(kTrayCCablesOutRot), CosD(kTrayCCablesOutRot));
5083
5084   // The freon inside the part of the cooling tube outside the tray: a Ctub
5085   TGeoCtub *outFreon = new TGeoCtub(0, kCoolingTubeRmin,
5086                         outTube->GetDz(),
5087                         0, 360,
5088                         0,                        0,                      -1,
5089                         0,-SinD(kTrayCCablesOutRot), CosD(kTrayCCablesOutRot));
5090
5091   // The optical fibers inside the tray: a Xtru
5092   TGeoXtru *optFibs = new TGeoXtru(2);
5093
5094   xprof[0] = -kTrayCCablesZLenOut;
5095   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5096   xprof[1] = sideCMidFace->GetX(5);
5097   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5098   xprof[2] = sideCMidFace->GetX(4);
5099   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5100   xprof[3] = sideCMidFace->GetX(3);
5101   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5102   xprof[4] = xprof[3] - kOpticalFibersSect*SinD(kTrayCFoldAngle);
5103   yprof[4] = yprof[3] + kOpticalFibersSect*CosD(kTrayCFoldAngle);
5104   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5105               kOpticalFibersSect , xprof[5], yprof[5]);
5106   xprof[6] = 0.;
5107   yprof[6] = yprof[1] + kOpticalFibersSect;
5108   xprof[7] = xprof[0];
5109   yprof[7] = yprof[0] + kOpticalFibersSect;
5110
5111   optFibs->DefinePolygon(8, xprof, yprof);
5112   optFibs->DefineSection(0, 0);
5113   optFibs->DefineSection(1, kOpticalFibersSect);
5114
5115   // The low voltage cables inside the tray: two Xtru
5116   TGeoXtru *lowCablesCu = new TGeoXtru(2);
5117
5118   xprof[0] = -kTrayCCablesZLenOut;
5119   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5120   xprof[1] = sideCMidFace->GetX(5);
5121   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5122   xprof[2] = sideCMidFace->GetX(4);
5123   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5124   xprof[3] = sideCMidFace->GetX(3);
5125   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5126   xprof[4] = xprof[3] - kLowVoltCableSectCu*SinD(kTrayCFoldAngle);
5127   yprof[4] = yprof[3] + kLowVoltCableSectCu*CosD(kTrayCFoldAngle);
5128   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5129               kLowVoltCableSectCu , xprof[5], yprof[5]);
5130   xprof[6] = 0.;
5131   yprof[6] = yprof[1] + kLowVoltCableSectCu;
5132   xprof[7] = xprof[0];
5133   yprof[7] = yprof[0] + kLowVoltCableSectCu;
5134
5135   lowCablesCu->DefinePolygon(8, xprof, yprof);
5136   lowCablesCu->DefineSection(0, 0);
5137   lowCablesCu->DefineSection(1, kLowVoltCableSectCu);
5138
5139   TGeoXtru *lowCablesPUR = new TGeoXtru(2);
5140
5141   xprof[0] = lowCablesCu->GetX(7);
5142   yprof[0] = lowCablesCu->GetY(7);
5143   xprof[1] = lowCablesCu->GetX(6);
5144   yprof[1] = lowCablesCu->GetY(6);
5145   xprof[2] = lowCablesCu->GetX(5);
5146   yprof[2] = lowCablesCu->GetY(5);
5147   xprof[3] = lowCablesCu->GetX(4);
5148   yprof[3] = lowCablesCu->GetY(4);
5149   xprof[4] = xprof[3] - kLowVoltCableHighPUR*SinD(kTrayCFoldAngle);
5150   yprof[4] = yprof[3] + kLowVoltCableHighPUR*CosD(kTrayCFoldAngle);
5151   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5152               kLowVoltCableHighPUR , xprof[5], yprof[5]);
5153   xprof[6] = 0.;
5154   yprof[6] = yprof[1] + kLowVoltCableHighPUR;
5155   xprof[7] = xprof[0];
5156   yprof[7] = yprof[0] + kLowVoltCableHighPUR;
5157
5158   lowCablesPUR->DefinePolygon(8, xprof, yprof);
5159   lowCablesPUR->DefineSection(0, 0);
5160   lowCablesPUR->DefineSection(1, kLowVoltCableSectCu);
5161
5162   // The high voltage cables inside the tray: two Xtru
5163   TGeoXtru *hiCablesCu = new TGeoXtru(2);
5164
5165   xprof[0] = -kTrayCCablesZLenOut;
5166   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5167   xprof[1] = sideCMidFace->GetX(5);
5168   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5169   xprof[2] = sideCMidFace->GetX(4);
5170   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5171   xprof[3] = sideCMidFace->GetX(3);
5172   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5173   xprof[4] = xprof[3] - kHiVoltCableSectCu*SinD(kTrayCFoldAngle);
5174   yprof[4] = yprof[3] + kHiVoltCableSectCu*CosD(kTrayCFoldAngle);
5175   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5176               kHiVoltCableSectCu , xprof[5], yprof[5]);
5177   xprof[6] = 0.;
5178   yprof[6] = yprof[1] + kHiVoltCableSectCu;
5179   xprof[7] = xprof[0];
5180   yprof[7] = yprof[0] + kHiVoltCableSectCu;
5181
5182   hiCablesCu->DefinePolygon(8, xprof, yprof);
5183   hiCablesCu->DefineSection(0, 0);
5184   hiCablesCu->DefineSection(1, kHiVoltCableSectCu);
5185
5186   TGeoXtru *hiCablesPUR = new TGeoXtru(2);
5187
5188   xprof[0] = hiCablesCu->GetX(7);
5189   yprof[0] = hiCablesCu->GetY(7);
5190   xprof[1] = hiCablesCu->GetX(6);
5191   yprof[1] = hiCablesCu->GetY(6);
5192   xprof[2] = hiCablesCu->GetX(5);
5193   yprof[2] = hiCablesCu->GetY(5);
5194   xprof[3] = hiCablesCu->GetX(4);
5195   yprof[3] = hiCablesCu->GetY(4);
5196   xprof[4] = xprof[3] - kHiVoltCableHighPUR*SinD(kTrayCFoldAngle);
5197   yprof[4] = yprof[3] + kHiVoltCableHighPUR*CosD(kTrayCFoldAngle);
5198   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5199               kHiVoltCableHighPUR , xprof[5], yprof[5]);
5200   xprof[6] = 0.;
5201   yprof[6] = yprof[1] + kHiVoltCableHighPUR;
5202   xprof[7] = xprof[0];
5203   yprof[7] = yprof[0] + kHiVoltCableHighPUR;
5204
5205   hiCablesPUR->DefinePolygon(8, xprof, yprof);
5206   hiCablesPUR->DefineSection(0, 0);
5207   hiCablesPUR->DefineSection(1, kHiVoltCableSectCu);
5208
5209   // The coaxial cables inside the tray: two Xtru
5210   TGeoXtru *coaxCablesCu = new TGeoXtru(2);
5211
5212   xprof[0] = -kTrayCCablesZLenOut;
5213   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5214   xprof[1] = sideCMidFace->GetX(5);
5215   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5216   xprof[2] = sideCMidFace->GetX(4);
5217   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5218   xprof[3] = sideCMidFace->GetX(3);
5219   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5220   xprof[4] = xprof[3] - kCoaxCableSectCu*SinD(kTrayCFoldAngle);
5221   yprof[4] = yprof[3] + kCoaxCableSectCu*CosD(kTrayCFoldAngle);
5222   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5223               kCoaxCableSectCu , xprof[5], yprof[5]);
5224   xprof[6] = 0.;
5225   yprof[6] = yprof[1] + kCoaxCableSectCu;
5226   xprof[7] = xprof[0];
5227   yprof[7] = yprof[0] + kCoaxCableSectCu;
5228
5229   coaxCablesCu->DefinePolygon(8, xprof, yprof);
5230   coaxCablesCu->DefineSection(0, 0);
5231   coaxCablesCu->DefineSection(1, kCoaxCableSectCu);
5232
5233   TGeoXtru *coaxCablesMeg = new TGeoXtru(2);
5234
5235   xprof[0] = coaxCablesCu->GetX(7);
5236   yprof[0] = coaxCablesCu->GetY(7);
5237   xprof[1] = coaxCablesCu->GetX(6);
5238   yprof[1] = coaxCablesCu->GetY(6);
5239   xprof[2] = coaxCablesCu->GetX(5);
5240   yprof[2] = coaxCablesCu->GetY(5);
5241   xprof[3] = coaxCablesCu->GetX(4);
5242   yprof[3] = coaxCablesCu->GetY(4);
5243   xprof[4] = xprof[3] - kCoaxCableHighMeg*SinD(kTrayCFoldAngle);
5244   yprof[4] = yprof[3] + kCoaxCableHighMeg*CosD(kTrayCFoldAngle);
5245   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5246               kCoaxCableHighMeg , xprof[5], yprof[5]);
5247   xprof[6] = 0.;
5248   yprof[6] = yprof[1] + kCoaxCableHighMeg;
5249   xprof[7] = xprof[0];
5250   yprof[7] = yprof[0] + kCoaxCableHighMeg;
5251
5252   coaxCablesMeg->DefinePolygon(8, xprof, yprof);
5253   coaxCablesMeg->DefineSection(0, 0);
5254   coaxCablesMeg->DefineSection(1, kCoaxCableSectCu);
5255
5256   // To avoid a newly discovered overlap,
5257   // transform the two overlapping volumes into a Composite Shape
5258   TGeoCompositeShape *trayIntern =
5259     new TGeoCompositeShape("ITSSPDInternalTrayC",
5260                            "ITSsuppSPDTraySideCHor+ITSsuppSPDTraySideCWall");
5261
5262   // We have all shapes: now create the real volumes
5263   TGeoMedium *medAl   = mgr->GetMedium("ITS_ALUMINUM$");
5264   TGeoMedium *medIn   = mgr->GetMedium("ITS_INOX$");
5265   TGeoMedium *medFr   = mgr->GetMedium("ITS_Freon$");
5266   TGeoMedium *medFibs = mgr->GetMedium("ITS_SDD OPTICFIB$");//!!TO BE CHECKED!!
5267   TGeoMedium *medCu   = mgr->GetMedium("ITS_COPPER$");
5268   TGeoMedium *medPUR  = mgr->GetMedium("ITS_POLYURETHANE$");
5269   TGeoMedium *medMeg  = mgr->GetMedium("ITS_MEGOLON$");
5270
5271   TGeoVolume *traySideCIntern  = new TGeoVolume("ITSsuppSPDTraySideCInternal",
5272                                                 trayIntern, medAl);
5273
5274   traySideCIntern->SetVisibility(kTRUE);
5275   traySideCIntern->SetLineColor(6); // Purple
5276   traySideCIntern->SetLineWidth(1);
5277   traySideCIntern->SetFillColor(traySideCIntern->GetLineColor());
5278   traySideCIntern->SetFillStyle(4000); // 0% transparent
5279
5280   TGeoVolume *traySideCMidFace  = new TGeoVolume("ITSsuppSPDTraySideCMid",
5281                                                  sideCMidFace, medAl);
5282
5283   traySideCMidFace->SetVisibility(kTRUE);
5284   traySideCMidFace->SetLineColor(6); // Purple
5285   traySideCMidFace->SetLineWidth(1);
5286   traySideCMidFace->SetFillColor(traySideCMidFace->GetLineColor());
5287   traySideCMidFace->SetFillStyle(4000); // 0% transparent
5288
5289   TGeoVolume *traySideCSideFace  = new TGeoVolume("ITSsuppSPDTraySideCSide",
5290                                                   sideCSideFace, medAl);
5291
5292   traySideCSideFace->SetVisibility(kTRUE);
5293   traySideCSideFace->SetLineColor(6); // Purple
5294   traySideCSideFace->SetLineWidth(1);
5295   traySideCSideFace->SetFillColor(traySideCSideFace->GetLineColor());
5296   traySideCSideFace->SetFillStyle(4000); // 0% transparent
5297
5298   TGeoVolume *traySideCShortCover  = new TGeoVolume("ITSsuppSPDTraySideCShCov",
5299                                                     sideCShortCover, medAl);
5300
5301   traySideCShortCover->SetVisibility(kTRUE);
5302   traySideCShortCover->SetLineColor(6); // Purple
5303   traySideCShortCover->SetLineWidth(1);
5304   traySideCShortCover->SetFillColor(traySideCShortCover->GetLineColor());
5305   traySideCShortCover->SetFillStyle(4000); // 0% transparent
5306
5307   TGeoVolume *traySideCLongCover  = new TGeoVolume("ITSsuppSPDTraySideCLnCov",
5308                                                    sideCLongCover, medAl);
5309
5310   traySideCLongCover->SetVisibility(kTRUE);
5311   traySideCLongCover->SetLineColor(6); // Purple
5312   traySideCLongCover->SetLineWidth(1);
5313   traySideCLongCover->SetFillColor(traySideCLongCover->GetLineColor());
5314   traySideCLongCover->SetFillStyle(4000); // 0% transparent
5315
5316   TGeoVolume *traySideCHorTube = new TGeoVolume("ITSsuppSPDTraySideCHorTube",
5317                                                 horTube, medIn);
5318
5319   traySideCHorTube->SetVisibility(kTRUE);
5320   traySideCHorTube->SetLineColor(kGray); // as in GeometrySPD
5321   traySideCHorTube->SetLineWidth(1);
5322   traySideCHorTube->SetFillColor(traySideCHorTube->GetLineColor());
5323   traySideCHorTube->SetFillStyle(4000); // 0% transparent
5324
5325   TGeoVolume *traySideCHorFreon = new TGeoVolume("ITSsuppSPDTraySideCHorFreon",
5326                                                  horFreon, medFr);
5327
5328   traySideCHorFreon->SetVisibility(kTRUE);
5329   traySideCHorFreon->SetLineColor(kBlue); // Blue
5330   traySideCHorFreon->SetLineWidth(1);
5331   traySideCHorFreon->SetFillColor(traySideCHorFreon->GetLineColor());
5332   traySideCHorFreon->SetFillStyle(4000); // 0% transparent
5333
5334   TGeoVolume *traySideCIncTube = new TGeoVolume("ITSsuppSPDTraySideCIncTube",
5335                                                 incTube, medIn);
5336
5337   traySideCIncTube->SetVisibility(kTRUE);
5338   traySideCIncTube->SetLineColor(kGray); // as in GeometrySPD
5339   traySideCIncTube->SetLineWidth(1);
5340   traySideCIncTube->SetFillColor(traySideCIncTube->GetLineColor());
5341   traySideCIncTube->SetFillStyle(4000); // 0% transparent
5342
5343   TGeoVolume *traySideCIncFreon = new TGeoVolume("ITSsuppSPDTraySideCIncFreon",
5344                                                  incFreon, medFr);
5345
5346   traySideCIncFreon->SetVisibility(kTRUE);
5347   traySideCIncFreon->SetLineColor(kBlue); // Blue
5348   traySideCIncFreon->SetLineWidth(1);
5349   traySideCIncFreon->SetFillColor(traySideCIncFreon->GetLineColor());
5350   traySideCIncFreon->SetFillStyle(4000); // 0% transparent
5351
5352   TGeoVolume *traySideCOutTube = new TGeoVolume("ITSsuppSPDTraySideCOutTube",
5353                                                 outTube, medIn);
5354
5355   traySideCOutTube->SetVisibility(kTRUE);
5356   traySideCOutTube->SetLineColor(kGray); // as in GeometrySPD
5357   traySideCOutTube->SetLineWidth(1);
5358   traySideCOutTube->SetFillColor(traySideCOutTube->GetLineColor());
5359   traySideCOutTube->SetFillStyle(4000); // 0% transparent
5360
5361   TGeoVolume *traySideCOutFreon = new TGeoVolume("ITSsuppSPDTraySideCOutFreon",
5362                                                  outFreon, medFr);
5363
5364   traySideCOutFreon->SetVisibility(kTRUE);
5365   traySideCOutFreon->SetLineColor(kBlue); // Blue
5366   traySideCOutFreon->SetLineWidth(1);
5367   traySideCOutFreon->SetFillColor(traySideCOutFreon->GetLineColor());
5368   traySideCOutFreon->SetFillStyle(4000); // 0% transparent
5369
5370   TGeoVolume *traySideCOptFibs = new TGeoVolume("ITSsuppSPDTraySideCOptFibs",
5371                                                 optFibs, medFibs);
5372
5373   traySideCOptFibs->SetVisibility(kTRUE);
5374   traySideCOptFibs->SetLineColor(kOrange); // Orange
5375   traySideCOptFibs->SetLineWidth(1);
5376   traySideCOptFibs->SetFillColor(traySideCOptFibs->GetLineColor());
5377   traySideCOptFibs->SetFillStyle(4000); // 0% transparent
5378
5379   TGeoVolume *traySideCLowCabsCu = new TGeoVolume("ITSsuppSPDTraySideCLVCu",
5380                                                   lowCablesCu, medCu);
5381
5382   traySideCLowCabsCu->SetVisibility(kTRUE);
5383   traySideCLowCabsCu->SetLineColor(kRed); // Red
5384   traySideCLowCabsCu->SetLineWidth(1);
5385   traySideCLowCabsCu->SetFillColor(traySideCLowCabsCu->GetLineColor());
5386   traySideCLowCabsCu->SetFillStyle(4000); // 0% transparent
5387
5388   TGeoVolume *traySideCLowCabsPUR = new TGeoVolume("ITSsuppSPDTraySideCLVPUR",
5389                                                    lowCablesPUR, medPUR);
5390
5391   traySideCLowCabsPUR->SetVisibility(kTRUE);
5392   traySideCLowCabsPUR->SetLineColor(kBlack); // Black
5393   traySideCLowCabsPUR->SetLineWidth(1);
5394   traySideCLowCabsPUR->SetFillColor(traySideCLowCabsPUR->GetLineColor());
5395   traySideCLowCabsPUR->SetFillStyle(4000); // 0% transparent
5396
5397   TGeoVolume *traySideCHiCabsCu = new TGeoVolume("ITSsuppSPDTraySideCHVCu",
5398                                                  hiCablesCu, medCu);
5399
5400   traySideCHiCabsCu->SetVisibility(kTRUE);
5401   traySideCHiCabsCu->SetLineColor(kRed); // Red
5402   traySideCHiCabsCu->SetLineWidth(1);
5403   traySideCHiCabsCu->SetFillColor(traySideCHiCabsCu->GetLineColor());
5404   traySideCHiCabsCu->SetFillStyle(4000); // 0% transparent
5405
5406   TGeoVolume *traySideCHiCabsPUR = new TGeoVolume("ITSsuppSPDTraySideCHVPUR",
5407                                                   hiCablesPUR, medPUR);
5408
5409   traySideCHiCabsPUR->SetVisibility(kTRUE);
5410   traySideCHiCabsPUR->SetLineColor(kBlack); // Black
5411   traySideCHiCabsPUR->SetLineWidth(1);
5412   traySideCHiCabsPUR->SetFillColor(traySideCHiCabsPUR->GetLineColor());
5413   traySideCHiCabsPUR->SetFillStyle(4000); // 0% transparent
5414
5415   TGeoVolume *traySideCCoaxCu = new TGeoVolume("ITSsuppSPDTraySideCCoaxCu",
5416                                                coaxCablesCu, medCu);
5417
5418   traySideCCoaxCu->SetVisibility(kTRUE);
5419   traySideCCoaxCu->SetLineColor(kRed); // Red
5420   traySideCCoaxCu->SetLineWidth(1);
5421   traySideCCoaxCu->SetFillColor(traySideCCoaxCu->GetLineColor());
5422   traySideCCoaxCu->SetFillStyle(4000); // 0% transparent
5423
5424   TGeoVolume *traySideCCoaxMeg = new TGeoVolume("ITSsuppSPDTraySideCCoaxMeg",
5425                                                 coaxCablesMeg, medMeg);
5426
5427   traySideCCoaxMeg->SetVisibility(kTRUE);
5428   traySideCCoaxMeg->SetLineColor(kBlack); // Black
5429   traySideCCoaxMeg->SetLineWidth(1);
5430   traySideCCoaxMeg->SetFillColor(traySideCCoaxMeg->GetLineColor());
5431   traySideCCoaxMeg->SetFillStyle(4000); // 0% transparent
5432
5433
5434   // Now build up the trays
5435   cableTrayC->AddNode(traySideCIntern,1,0);
5436
5437   cableTrayC->AddNode(traySideCMidFace,1,0);
5438
5439   zloc = kTrayCHalfWide - kTrayCThick;
5440   cableTrayC->AddNode(traySideCSideFace, 1,
5441                       new TGeoTranslation( 0, 0, zloc));
5442   zloc = -kTrayCHalfWide;
5443   cableTrayC->AddNode(traySideCSideFace, 2,
5444                       new TGeoTranslation( 0, 0, zloc));
5445
5446   xloc = sideCShortCover->GetDX();
5447   yloc = kTrayCFirstHigh - sideCShortCover->GetDY();
5448   cableTrayC->AddNode(traySideCShortCover, 1,
5449                       new TGeoTranslation( xloc, yloc, 0));
5450
5451   cableTrayC->AddNode(traySideCLongCover,1,0);
5452
5453   traySideCHorTube->AddNode(traySideCHorFreon, 1, 0);
5454   traySideCIncTube->AddNode(traySideCIncFreon, 1, 0);
5455   traySideCOutTube->AddNode(traySideCOutFreon, 1, 0);
5456
5457   xloc = horTube->GetDz();
5458   yloc = sideCMidFace->GetY(5) + horTube->GetRmax();
5459   cableTrayC->AddNode(traySideCHorTube, 1,
5460                       new TGeoCombiTrans( xloc, yloc, 0,
5461                       new TGeoRotation("",-90.,-90.,90.)));
5462
5463   xloc = sideCMidFace->GetX(4) + (incTube->GetDz())*CosD(kTrayCFoldAngle);
5464   yloc = sideCMidFace->GetY(4) +  incTube->GetRmax() +
5465             (incTube->GetDz())*SinD(kTrayCFoldAngle)+0.005;//Avoid small ovrlp
5466   cableTrayC->AddNode(traySideCIncTube, 1,
5467                       new TGeoCombiTrans( xloc, yloc, 0,
5468                       new TGeoRotation("",-90.+kTrayCFoldAngle,-90.,90.)));
5469
5470   xloc = -kTrayCCablesZLenOut/2 - outTube->GetRmax();
5471   yloc = xloc/TanD(kTrayCCablesOutRot) + sideCMidFace->GetY(4) -
5472          2*outTube->GetRmax();
5473   cableTrayC->AddNode(traySideCOutTube, 1,
5474                       new TGeoCombiTrans( xloc, yloc, 0,
5475                       new TGeoRotation("",-70.,-90.,90.)));
5476
5477   zloc = horTube->GetRmax();
5478   cableTrayC->AddNode(traySideCOptFibs, 1,
5479                       new TGeoTranslation( 0, 0, zloc));
5480
5481   zloc = kLowVoltCableSectCu + horTube->GetRmax();
5482   cableTrayC->AddNode(traySideCLowCabsCu, 1,
5483                       new TGeoTranslation( 0, 0,-zloc));
5484   cableTrayC->AddNode(traySideCLowCabsPUR, 1,
5485                       new TGeoTranslation( 0, 0,-zloc));
5486
5487   zloc = kHiVoltCableSectCu + kLowVoltCableSectCu + horTube->GetRmax();
5488   cableTrayC->AddNode(traySideCHiCabsCu, 1,
5489                       new TGeoTranslation( 0, 0,-zloc));
5490   cableTrayC->AddNode(traySideCHiCabsPUR, 1,
5491                       new TGeoTranslation( 0, 0,-zloc));
5492
5493   zloc = kOpticalFibersSect + kCoaxCableSectCu + horTube->GetRmax();
5494   cableTrayC->AddNode(traySideCCoaxCu, 1,
5495                       new TGeoTranslation( 0, 0, zloc));
5496   cableTrayC->AddNode(traySideCCoaxMeg, 1,
5497                       new TGeoTranslation( 0, 0, zloc));
5498
5499
5500   // Finally put everything in the mother volume
5501   for (Int_t jt = 0; jt < kNumTraysSideC/2; jt++) {
5502     alpharot = kTraySideCAlphaRot[jt];
5503
5504     xloc = kTraySideCRPos*SinD(alpharot);
5505     yloc = kTraySideCRPos*CosD(alpharot);
5506     moth->AddNode(cableTrayC,2*jt+1,
5507                 new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
5508                 new TGeoRotation("",-90.+alpharot,-90.,90.+kTrayCFoldAngle)));
5509     alpharot += 180;
5510     xloc = kTraySideCRPos*SinD(alpharot);
5511     yloc = kTraySideCRPos*CosD(alpharot);
5512     moth->AddNode(cableTrayC,2*jt+2,
5513                 new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
5514                 new TGeoRotation("",-90.+alpharot,-90.,90.+kTrayCFoldAngle)));
5515   }
5516
5517
5518   return;
5519 }
5520
5521 //______________________________________________________________________
5522 void AliITSv11GeometrySupport::SDDCableTraysSideA(TGeoVolume *moth,
5523                                              const TGeoManager *mgr){
5524 //
5525 // Creates the SDD cable trays which are outside the ITS support cones
5526 // but still inside the TPC on Side A
5527 // (part of this code is taken or anyway inspired to ServicesCableSupport
5528 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
5529 //
5530 // Input:
5531 //         moth : the TGeoVolume owing the volume structure
5532 //         mgr  : the GeoManager (default gGeoManager)
5533 // Output:
5534 //
5535 // Created:         ???       Bjorn S. Nilsen
5536 // Updated:       5 Jan 2010  Mario Sitta
5537 // Updated:      26 Feb 2010  Mario Sitta
5538 // Updated:      06 Sep 2010  Mario Sitta
5539 //
5540 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
5541 // drawings and other (oral) information given by F.Tosello
5542 //
5543
5544   // Overall position and rotation of the A-Side Cable Trays
5545   // (parts of 0872/G/D)
5546   const Double_t kTrayARTrans            =  408.35 *fgkmm;
5547   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
5548   const Double_t kTrayAZToSupportRing    =  435.00 *fgkmm;
5549   const Double_t kExternTrayYTrans       =   96.00 *fgkmm; // Computed
5550   const Double_t kExternTrayZTrans       =  823.00 *fgkmm;
5551   const Double_t kExternCoverYTrans      =    2.00 *fgkmm;
5552   const Double_t kTrayAZRot              = (180-169.5);// Degrees
5553   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
5554   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
5555
5556   const Double_t kForwardTrayThick       =    2.00 *fgkmm;
5557   const Double_t kForwardTrayTailHeight  =  100.00 *fgkmm; // Computed
5558   const Double_t kForwardTrayTotalHeight =  170.00 *fgkmm; // Computed
5559   const Double_t kForwardTrayUpperLength =  405.00 *fgkmm; // Computed
5560   const Double_t kForwardCoverLength     =  380.00 *fgkmm;
5561   const Double_t kForwardCoverWide       =  133.00 *fgkmm;
5562   const Double_t kForwardCoverHeight     =   10.00 *fgkmm;
5563   const Double_t kForwardCoverThick      =    1.00 *fgkmm;
5564
5565   const Double_t kExternTrayTotalLen     = 1200.00 *fgkmm;
5566   const Double_t kExternTrayTotalHeight  =   52.00 *fgkmm;
5567   const Double_t kExternCoverLen         = kExternTrayTotalLen;
5568   const Double_t kExternCoverThick       =    5.00 *fgkmm;
5569   const Double_t kExternCoverSideThick   =    3.00 *fgkmm;
5570
5571   const Int_t    kForwardTrayNpoints     =    8;
5572
5573   // Dimensions and positions of the Cable Tray elements
5574   const Double_t kSideACoolManifWide     =    8.23 *fgkcm;
5575   const Double_t kSideACoolManifHigh     =    8.06 *fgkcm;
5576   const Double_t kSideACoolManifLen      =    3.90 *fgkcm;
5577   const Double_t kSideACoolManifPOMFrac  =    0.0054;
5578   const Double_t kSideACoolManifSteelFrac=    0.8850;
5579   const Double_t kSideACoolManifWaterFrac=    0.0913;
5580   const Double_t kSideACoolManifAlFrac   =    0.0183;
5581
5582   const Double_t kSideACoolTubesWide     =    9.07 *fgkcm;
5583   const Double_t kSideACoolTubesHigh     =    1.88 *fgkcm;
5584   const Double_t kSideACoolTubesTrans    =    0.88 *fgkcm;
5585   const Double_t kSideACoolTubesPURFrac  =    0.5897;
5586   const Double_t kSideACoolTubesWaterFrac=    0.4101;
5587   const Double_t kSideACoolTubesAirFrac  =    0.0002;
5588
5589   const Double_t kSideAOptConnWide       =    0.90    *fgkcm;
5590   const Double_t kSideAOptConnLen        =    1.37    *fgkcm;
5591   const Double_t kSideAOptConnPBTFrac    =    0.5010;
5592   const Double_t kSideAOptConnSteelFrac  =    0.1784;
5593   const Double_t kSideAOptConnAlFrac     =    0.3206;
5594
5595   const Double_t kSideAOptFibsWide       =    0.71    *fgkcm;
5596   const Double_t kSideAOptFibsHigh       =    3.20    *fgkcm;
5597
5598   const Double_t kSideAInputCablesWide   =   12.50    *fgkcm;
5599   const Double_t kSideAInputCablesHigh   =    1.24    *fgkcm;
5600   const Double_t kSideAInputCablesLen    =   25.20    *fgkcm;
5601   const Double_t kSideAInputCablesYTrans =    1.15    *fgkcm;
5602   const Double_t kSideAInputCablesCu     =    0.7404;
5603   const Double_t kSideAInputCablesPlast  =    0.1269;
5604   const Double_t kSideAInputCablesAl     =    0.0057;
5605   const Double_t kSideAInputCablesKapton =    0.0172;
5606   const Double_t kSideAInputCablesPOLYAX =    0.1098;
5607
5608   const Double_t kSideAOutputCablesWide  =    8.30    *fgkcm;
5609   const Double_t kSideAOutputCablesHigh  =    1.56    *fgkcm;
5610   const Double_t kSideAOutputCablesCu    =    0.6783;
5611   const Double_t kSideAOutputCablesPlast =    0.1605;
5612   const Double_t kSideAOutputCablesAl    =    0.0078;
5613   const Double_t kSideAOutputCablesKapton=    0.0232;
5614   const Double_t kSideAOutputCablesPOLYAX=    0.1302;
5615
5616   const Double_t kSideAPCBBoardsWide     =   12.50    *fgkcm;
5617   const Double_t kSideAPCBBoardsHigh     =    6.32    *fgkcm;
5618   const Double_t kSideAPCBBoardsLen      =   24.00    *fgkcm;
5619   const Double_t kSideAPCBBoardsYTrans   =    0.75    *fgkcm;
5620   const Double_t kSideAPCBBoardsCu       =    0.3864;
5621   const Double_t kSideAPCBBoardsEpoxy    =    0.1486;
5622   const Double_t kSideAPCBBoardsPlast    =    0.0578;
5623   const Double_t kSideAPCBBoardsSteel    =    0.1521;
5624   const Double_t kSideAPCBBoardsPPS      =    0.2551;
5625
5626
5627   // Local variables
5628   Double_t xprof[kForwardTrayNpoints], yprof[kForwardTrayNpoints];
5629   Double_t xloc, yloc, zloc, alpharot, height;
5630
5631
5632   // The whole tray as an assembly
5633   TGeoVolumeAssembly *cableTrayA = new TGeoVolumeAssembly("ITSsupportSDDTrayA");
5634   
5635
5636   // First create all needed shapes
5637
5638   // The forward tray is very complex and deserves a dedicated method
5639   CreateSDDForwardTraySideA(cableTrayA,mgr);
5640
5641   // The forward cover: a Xtru
5642   TGeoXtru *forwardCover = new TGeoXtru(2);
5643   forwardCover->SetName("ITSsuppSDDForwCover");
5644
5645   xprof[0] = kForwardCoverWide/2;
5646   yprof[0] = kForwardCoverHeight;
5647   xprof[1] = xprof[0];
5648   yprof[1] = 0;
5649   xprof[2] = xprof[1] - kForwardCoverThick;
5650   yprof[2] = yprof[1];
5651   xprof[3] = xprof[2];
5652   yprof[3] = yprof[0] - kForwardCoverThick;
5653
5654   // We did the right side, now reflex on the left side
5655   for (Int_t jp = 0; jp < 4; jp++) {
5656     xprof[4+jp] = -xprof[3-jp];
5657     yprof[4+jp] =  yprof[3-jp];
5658   }
5659
5660   forwardCover->DefinePolygon(8, xprof, yprof);
5661   forwardCover->DefineSection(0, 0);
5662   forwardCover->DefineSection(1, kForwardCoverLength);
5663
5664   // The external tray (as 0872/G/D/03): a Xtru
5665   TGeoXtru *externalTray = CreateSDDSSDTraysSideA(kExternTrayTotalLen,
5666                                                   kExternTrayTotalHeight);
5667
5668   // The external covers: a Composite Shape
5669   TGeoCompositeShape *externCover = CreateTrayAExternalCover(kExternCoverLen);
5670
5671   // Now the volumes inside it
5672   // The cooling manifold: four boxes
5673   TGeoBBox *coolManifPOM = new TGeoBBox(kSideACoolManifWide/2,
5674                  kSideACoolManifPOMFrac*kSideACoolManifHigh/2,
5675                                         kSideACoolManifLen/2);
5676
5677   TGeoBBox *coolManifSteel = new TGeoBBox(kSideACoolManifWide/2,
5678                  kSideACoolManifSteelFrac*kSideACoolManifHigh/2,
5679                                           kSideACoolManifLen/2);
5680
5681   TGeoBBox *coolManifWater = new TGeoBBox(kSideACoolManifWide/2,
5682                  kSideACoolManifWaterFrac*kSideACoolManifHigh/2,
5683                                           kSideACoolManifLen/2);
5684
5685   TGeoBBox *coolManifAl = new TGeoBBox(kSideACoolManifWide/2,
5686                  kSideACoolManifAlFrac*kSideACoolManifHigh/2,
5687                                        kSideACoolManifLen/2);
5688
5689   // The cooling tubes: three Xtru's
5690   TGeoXtru *coolTubesPUR = new TGeoXtru(2);
5691
5692   height = kSideACoolTubesHigh*kSideACoolTubesPURFrac;
5693
5694   xprof[0] = kSideACoolManifLen;
5695   yprof[0] = kForwardTrayThick + kSideACoolTubesTrans;
5696   xprof[2] = kExternTrayZTrans + kForwardTrayTotalHeight*SinD(kTrayAZRot) +
5697              kExternTrayTotalLen*CosD(kTrayAZRot) - xprof[0]/2;
5698   yprof[2] = kForwardTrayTotalHeight*(1 - CosD(kTrayAZRot)) +
5699              kExternTrayYTrans - kExternTrayTotalHeight*CosD(kTrayAZRot) +
5700              kExternTrayTotalLen*SinD(kTrayAZRot) + yprof[0];
5701   IntersectLines(              0 , xprof[0], yprof[0],
5702                  TanD(kTrayAZRot), xprof[2], yprof[2],
5703                                    xprof[1], yprof[1]);
5704   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5705   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5706   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5707               height, xprof[4], yprof[4]);
5708   xprof[5] = xprof[0];
5709   yprof[5] = yprof[0] + height;
5710
5711   coolTubesPUR->DefinePolygon(6, xprof, yprof);
5712   coolTubesPUR->DefineSection(0,-kSideACoolTubesWide/2);
5713   coolTubesPUR->DefineSection(1, kSideACoolTubesWide/2);
5714
5715   TGeoXtru *coolTubesWater = new TGeoXtru(2);
5716
5717   height = kSideACoolTubesHigh*kSideACoolTubesWaterFrac;
5718
5719   xprof[0] = coolTubesPUR->GetX(5);
5720   yprof[0] = coolTubesPUR->GetY(5);
5721   xprof[1] = coolTubesPUR->GetX(4);
5722   yprof[1] = coolTubesPUR->GetY(4);
5723   xprof[2] = coolTubesPUR->GetX(3);
5724   yprof[2] = coolTubesPUR->GetY(3);
5725   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5726   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5727   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5728               height, xprof[4], yprof[4]);
5729   xprof[5] = xprof[0];
5730   yprof[5] = yprof[0] + height;
5731
5732   coolTubesWater->DefinePolygon(6, xprof, yprof);
5733   coolTubesWater->DefineSection(0,-kSideACoolTubesWide/2);
5734   coolTubesWater->DefineSection(1, kSideACoolTubesWide/2);
5735
5736   TGeoXtru *coolTubesAir = new TGeoXtru(2);
5737
5738   height = kSideACoolTubesHigh*kSideACoolTubesAirFrac;
5739
5740   xprof[0] = coolTubesWater->GetX(5);
5741   yprof[0] = coolTubesWater->GetY(5);
5742   xprof[1] = coolTubesWater->GetX(4);
5743   yprof[1] = coolTubesWater->GetY(4);
5744   xprof[2] = coolTubesWater->GetX(3);
5745   yprof[2] = coolTubesWater->GetY(3);
5746   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5747   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5748   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5749               height, xprof[4], yprof[4]);
5750   xprof[5] = xprof[0];
5751   yprof[5] = yprof[0] + height;
5752
5753   coolTubesAir->DefinePolygon(6, xprof, yprof);
5754   coolTubesAir->DefineSection(0,-kSideACoolTubesWide/2);
5755   coolTubesAir->DefineSection(1, kSideACoolTubesWide/2);
5756
5757   // The optical fiber connectors: three boxes
5758   TGeoBBox *optConnPBT = new TGeoBBox(kSideAOptConnWide/2,
5759                  kSideAOptConnPBTFrac*kSideACoolManifHigh/2,
5760                                       kSideAOptConnLen/2);
5761
5762   TGeoBBox *optConnSteel = new TGeoBBox(kSideAOptConnWide/2,
5763                  kSideAOptConnSteelFrac*kSideACoolManifHigh/2,
5764                                         kSideAOptConnLen/2);
5765
5766   TGeoBBox *optConnAl = new TGeoBBox(kSideAOptConnWide/2,
5767                  kSideAOptConnAlFrac*kSideACoolManifHigh/2,
5768                                      kSideAOptConnLen/2);
5769
5770   // The optical fibers: a Xtru
5771   TGeoXtru *opticalFibs = new TGeoXtru(2);
5772
5773   xprof[0] = kSideAOptConnLen;
5774   yprof[0] = coolTubesPUR->GetY(0);
5775   xprof[1] = coolTubesPUR->GetX(1);
5776   yprof[1] = coolTubesPUR->GetY(1);
5777   xprof[2] = coolTubesPUR->GetX(2);
5778   yprof[2] = coolTubesPUR->GetY(2);
5779   xprof[3] = xprof[2] - kSideAOptFibsHigh*SinD(kTrayAZRot);
5780   yprof[3] = yprof[2] + kSideAOptFibsHigh*CosD(kTrayAZRot);
5781   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5782               kSideAOptFibsHigh, xprof[4], yprof[4]);
5783   xprof[5] = xprof[0];
5784   yprof[5] = yprof[0] + kSideAOptFibsHigh;
5785
5786   opticalFibs->DefinePolygon(6, xprof, yprof);
5787   opticalFibs->DefineSection(0,-kSideAOptFibsWide/2);
5788   opticalFibs->DefineSection(1, kSideAOptFibsWide/2);
5789
5790   // The input cables: five boxes
5791   TGeoBBox *inputCabsCu = new TGeoBBox(kSideAInputCablesWide/2,
5792                    kSideAInputCablesCu*kSideAInputCablesHigh/2,
5793                                        kSideAInputCablesLen/2);
5794
5795   TGeoBBox *inputCabsPlast = new TGeoBBox(kSideAInputCablesWide/2,
5796                    kSideAInputCablesPlast*kSideAInputCablesHigh/2,
5797                                           kSideAInputCablesLen/2);
5798
5799   TGeoBBox *inputCabsAl = new TGeoBBox(kSideAInputCablesWide/2,
5800                    kSideAInputCablesAl*kSideAInputCablesHigh/2,
5801                                        kSideAInputCablesLen/2);
5802
5803   TGeoBBox *inputCabsKapton = new TGeoBBox(kSideAInputCablesWide/2,
5804                    kSideAInputCablesKapton*kSideAInputCablesHigh/2,
5805                                            kSideAInputCablesLen/2);
5806
5807   TGeoBBox *inputCabsPOLYAX = new TGeoBBox(kSideAInputCablesWide/2,
5808                    kSideAInputCablesPOLYAX*kSideAInputCablesHigh/2,
5809                                            kSideAInputCablesLen/2);
5810
5811   // The output cables: five Xtru
5812   TGeoXtru *outputCabsCu = new TGeoXtru(2);
5813
5814   height = kSideAOutputCablesCu*kSideAOutputCablesHigh;
5815
5816   xprof[0] = kSideAInputCablesLen/2 + kSideAPCBBoardsLen/2;
5817   yprof[0] = coolTubesAir->GetY(5);
5818   xprof[1] = coolTubesAir->GetX(4);
5819   yprof[1] = coolTubesAir->GetY(4);
5820   xprof[2] = coolTubesAir->GetX(3);
5821   yprof[2] = coolTubesAir->GetY(3);
5822   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5823   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5824   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5825               height, xprof[4], yprof[4]);
5826   xprof[5] = xprof[0];
5827   yprof[5] = yprof[0] + height;
5828
5829   outputCabsCu->DefinePolygon(6, xprof, yprof);
5830   outputCabsCu->DefineSection(0,-kSideAOutputCablesWide/2);
5831   outputCabsCu->DefineSection(1, kSideAOutputCablesWide/2);
5832
5833   TGeoXtru *outputCabsPlast = new TGeoXtru(2);
5834
5835   height = kSideAOutputCablesPlast*kSideAOutputCablesHigh;
5836
5837   xprof[0] = outputCabsCu->GetX(5);
5838   yprof[0] = outputCabsCu->GetY(5);
5839   xprof[1] = outputCabsCu->GetX(4);
5840   yprof[1] = outputCabsCu->GetY(4);
5841   xprof[2] = outputCabsCu->GetX(3);
5842   yprof[2] = outputCabsCu->GetY(3);
5843   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5844   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5845   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5846               height, xprof[4], yprof[4]);
5847   xprof[5] = xprof[0];
5848   yprof[5] = yprof[0] + height;
5849
5850   outputCabsPlast->DefinePolygon(6, xprof, yprof);
5851   outputCabsPlast->DefineSection(0,-kSideAOutputCablesWide/2);
5852   outputCabsPlast->DefineSection(1, kSideAOutputCablesWide/2);
5853
5854   TGeoXtru *outputCabsAl = new TGeoXtru(2);
5855
5856   height = kSideAOutputCablesAl*kSideAOutputCablesHigh;
5857
5858   xprof[0] = outputCabsPlast->GetX(5);
5859   yprof[0] = outputCabsPlast->GetY(5);
5860   xprof[1] = outputCabsPlast->GetX(4);
5861   yprof[1] = outputCabsPlast->GetY(4);
5862   xprof[2] = outputCabsPlast->GetX(3);
5863   yprof[2] = outputCabsPlast->GetY(3);
5864   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5865   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5866   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5867               height, xprof[4], yprof[4]);
5868   xprof[5] = xprof[0];
5869   yprof[5] = yprof[0] + height;
5870
5871   outputCabsAl->DefinePolygon(6, xprof, yprof);
5872   outputCabsAl->DefineSection(0,-kSideAOutputCablesWide/2);
5873   outputCabsAl->DefineSection(1, kSideAOutputCablesWide/2);
5874
5875   TGeoXtru *outputCabsKapton = new TGeoXtru(2);
5876
5877   height = kSideAOutputCablesKapton*kSideAOutputCablesHigh;
5878
5879   xprof[0] = outputCabsAl->GetX(5);
5880   yprof[0] = outputCabsAl->GetY(5);
5881   xprof[1] = outputCabsAl->GetX(4);
5882   yprof[1] = outputCabsAl->GetY(4);
5883   xprof[2] = outputCabsAl->GetX(3);
5884   yprof[2] = outputCabsAl->GetY(3);
5885   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5886   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5887   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5888               height, xprof[4], yprof[4]);
5889   xprof[5] = xprof[0];
5890   yprof[5] = yprof[0] + height;
5891
5892   outputCabsKapton->DefinePolygon(6, xprof, yprof);
5893   outputCabsKapton->DefineSection(0,-kSideAOutputCablesWide/2);
5894   outputCabsKapton->DefineSection(1, kSideAOutputCablesWide/2);
5895
5896   TGeoXtru *outputCabsPOLYAX = new TGeoXtru(2);
5897
5898   height = kSideAOutputCablesPOLYAX*kSideAOutputCablesHigh;
5899
5900   xprof[0] = outputCabsKapton->GetX(5);
5901   yprof[0] = outputCabsKapton->GetY(5);
5902   xprof[1] = outputCabsKapton->GetX(4);
5903   yprof[1] = outputCabsKapton->GetY(4);
5904   xprof[2] = outputCabsKapton->GetX(3);
5905   yprof[2] = outputCabsKapton->GetY(3);
5906   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5907   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5908   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5909               height, xprof[4], yprof[4]);
5910   xprof[5] = xprof[0];
5911   yprof[5] = yprof[0] + height;
5912
5913   outputCabsPOLYAX->DefinePolygon(6, xprof, yprof);
5914   outputCabsPOLYAX->DefineSection(0,-kSideAOutputCablesWide/2);
5915   outputCabsPOLYAX->DefineSection(1, kSideAOutputCablesWide/2);
5916
5917   // The PCB boards: five boxes
5918   TGeoBBox *pcbBoardsCu = new TGeoBBox(kSideAPCBBoardsWide/2,
5919                      kSideAPCBBoardsCu*kSideAPCBBoardsHigh/2,
5920                                        kSideAPCBBoardsLen/2);
5921
5922   TGeoBBox *pcbBoardsEpoxy = new TGeoBBox(kSideAPCBBoardsWide/2,
5923                      kSideAPCBBoardsEpoxy*kSideAPCBBoardsHigh/2,
5924                                           kSideAPCBBoardsLen/2);
5925
5926   TGeoBBox *pcbBoardsPlast = new TGeoBBox(kSideAPCBBoardsWide/2,
5927                      kSideAPCBBoardsPlast*kSideAPCBBoardsHigh/2,
5928                                           kSideAPCBBoardsLen/2);
5929
5930   TGeoBBox *pcbBoardsSteel = new TGeoBBox(kSideAPCBBoardsWide/2,
5931                      kSideAPCBBoardsSteel*kSideAPCBBoardsHigh/2,
5932                                           kSideAPCBBoardsLen/2);
5933
5934   TGeoBBox *pcbBoardsPPS = new TGeoBBox(kSideAPCBBoardsWide/2,
5935                      kSideAPCBBoardsPPS*kSideAPCBBoardsHigh/2,
5936                                         kSideAPCBBoardsLen/2);
5937
5938
5939   // We have all shapes: now create the real volumes
5940   TGeoMedium *medAl     = mgr->GetMedium("ITS_ALUMINUM$");
5941   TGeoMedium *medAntic  = mgr->GetMedium("ITS_ANTICORODAL$");
5942   TGeoMedium *medPOM    = mgr->GetMedium("ITS_POLYOXYMETHYLENE$");
5943   TGeoMedium *medSteel  = mgr->GetMedium("ITS_INOX$");
5944   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
5945   TGeoMedium *medPUR    = mgr->GetMedium("ITS_POLYURETHANE$");
5946   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
5947   TGeoMedium *medPBT    = mgr->GetMedium("ITS_PBT$");
5948   TGeoMedium *medOptFib = mgr->GetMedium("ITS_SDD OPTICFIB$");
5949   TGeoMedium *medCu     = mgr->GetMedium("ITS_COPPER$");
5950   TGeoMedium *medKapton = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
5951   TGeoMedium *medPOLYAX = mgr->GetMedium("ITS_POLYAX$");
5952   TGeoMedium *medPPS    = mgr->GetMedium("ITS_PPS$");
5953   TGeoMedium *medEpoxy  = mgr->GetMedium("ITS_EPOXY$");
5954
5955   TGeoVolume *forwardTrayCover = new TGeoVolume("ITSsuppSDDSideAForwTrayCover",
5956                                                 forwardCover, medAl);
5957
5958   forwardTrayCover->SetVisibility(kTRUE);
5959   forwardTrayCover->SetLineColor(kMagenta+1); // Purple
5960   forwardTrayCover->SetLineWidth(1);
5961   forwardTrayCover->SetFillColor(forwardTrayCover->GetLineColor());
5962   forwardTrayCover->SetFillStyle(4000); // 0% transparent
5963
5964   TGeoVolume *externalTraySDD = new TGeoVolume("ITSsuppSDDSideAExternalTray",
5965                                                externalTray, medAl);
5966
5967   externalTraySDD->SetVisibility(kTRUE);
5968   externalTraySDD->SetLineColor(6); // Purple
5969   externalTraySDD->SetLineWidth(1);
5970   externalTraySDD->SetFillColor(externalTraySDD->GetLineColor());
5971   externalTraySDD->SetFillStyle(4000); // 0% transparent
5972
5973   TGeoVolume *externTrayCover = new TGeoVolume("ITSsuppSDDSideAExtTrayCover",
5974                                                externCover, medAntic);
5975
5976   externTrayCover->SetVisibility(kTRUE);
5977   externTrayCover->SetLineColor(kMagenta+1); // Purple
5978   externTrayCover->SetLineWidth(1);
5979   externTrayCover->SetFillColor(externTrayCover->GetLineColor());
5980   externTrayCover->SetFillStyle(4000); // 0% transparent
5981
5982   TGeoVolume *pomCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifPOM",
5983                                             coolManifPOM, medPOM);
5984
5985   pomCoolManif->SetVisibility(kTRUE);
5986   pomCoolManif->SetLineColor(kRed); // Red
5987   pomCoolManif->SetLineWidth(1);
5988   pomCoolManif->SetFillColor(pomCoolManif->GetLineColor());
5989   pomCoolManif->SetFillStyle(4000); // 0% transparent
5990
5991   TGeoVolume *steelCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifSteel",
5992                                               coolManifSteel, medSteel);
5993
5994   steelCoolManif->SetVisibility(kTRUE);
5995   steelCoolManif->SetLineColor(kBlue); // Blue
5996   steelCoolManif->SetLineWidth(1);
5997   steelCoolManif->SetFillColor(steelCoolManif->GetLineColor());
5998   steelCoolManif->SetFillStyle(4000); // 0% transparent
5999
6000   TGeoVolume *waterCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifWater",
6001                                               coolManifWater, medWater);
6002
6003   waterCoolManif->SetVisibility(kTRUE);
6004   waterCoolManif->SetLineColor(33); // Light Blue
6005   waterCoolManif->SetLineWidth(1);
6006   waterCoolManif->SetFillColor(waterCoolManif->GetLineColor());
6007   waterCoolManif->SetFillStyle(4000); // 0% transparent
6008
6009   TGeoVolume *alCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifAl",
6010                                            coolManifAl, medAl);
6011
6012   alCoolManif->SetVisibility(kTRUE);
6013   alCoolManif->SetLineColor(6); // Purple
6014   alCoolManif->SetLineWidth(1);
6015   alCoolManif->SetFillColor(alCoolManif->GetLineColor());
6016   alCoolManif->SetFillStyle(4000); // 0% transparent
6017
6018   TGeoVolume *purCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesPUR",
6019                                             coolTubesPUR, medPUR);
6020
6021   purCoolTubes->SetVisibility(kTRUE);
6022   purCoolTubes->SetLineColor(kRed); // Red
6023   purCoolTubes->SetLineWidth(1);
6024   purCoolTubes->SetFillColor(purCoolTubes->GetLineColor());
6025   purCoolTubes->SetFillStyle(4000); // 0% transparent
6026
6027   TGeoVolume *waterCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesWater",
6028                                               coolTubesWater, medWater);
6029
6030   waterCoolTubes->SetVisibility(kTRUE);
6031   waterCoolTubes->SetLineColor(33); // Light Blue
6032   waterCoolTubes->SetLineWidth(1);
6033   waterCoolTubes->SetFillColor(waterCoolTubes->GetLineColor());
6034   waterCoolTubes->SetFillStyle(4000); // 0% transparent
6035
6036   TGeoVolume *airCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesAir",
6037                                             coolTubesAir, medAir);
6038
6039   airCoolTubes->SetVisibility(kTRUE);
6040   airCoolTubes->SetLineColor(41);
6041   airCoolTubes->SetLineWidth(1);
6042   airCoolTubes->SetFillColor(airCoolTubes->GetLineColor());
6043   airCoolTubes->SetFillStyle(4000); // 0% transparent
6044
6045   TGeoVolume *pbtOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnPBT",
6046                                           optConnPBT, medPBT);
6047
6048   pbtOptConn->SetVisibility(kTRUE);
6049   pbtOptConn->SetLineColor(kRed); // Red
6050   pbtOptConn->SetLineWidth(1);
6051   pbtOptConn->SetFillColor(pbtOptConn->GetLineColor());
6052   pbtOptConn->SetFillStyle(4000); // 0% transparent
6053
6054   TGeoVolume *steelOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnSteel",
6055                                             optConnSteel, medSteel);
6056
6057   steelOptConn->SetVisibility(kTRUE);
6058   steelOptConn->SetLineColor(kBlue); // Blue
6059   steelOptConn->SetLineWidth(1);
6060   steelOptConn->SetFillColor(steelOptConn->GetLineColor());
6061   steelOptConn->SetFillStyle(4000); // 0% transparent
6062
6063   TGeoVolume *alOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnAl",
6064                                          optConnAl, medAl);
6065
6066   alOptConn->SetVisibility(kTRUE);
6067   alOptConn->SetLineColor(6); // Purple
6068   alOptConn->SetLineWidth(1);
6069   alOptConn->SetFillColor(alOptConn->GetLineColor());
6070   alOptConn->SetFillStyle(4000); // 0% transparent
6071
6072   TGeoVolume *optFibs = new TGeoVolume("ITSsuppSDDSideAOptFibs",
6073                                        opticalFibs, medOptFib);
6074
6075   optFibs->SetVisibility(kTRUE);
6076   optFibs->SetLineColor(kOrange+2); // Orange
6077   optFibs->SetLineWidth(1);
6078   optFibs->SetFillColor(optFibs->GetLineColor());
6079   optFibs->SetFillStyle(4000); // 0% transparent
6080
6081   TGeoVolume *cuInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsCu",
6082                                            inputCabsCu, medCu);
6083
6084   cuInputCabs->SetVisibility(kTRUE);
6085   cuInputCabs->SetLineColor(kBlack); // Black
6086   cuInputCabs->SetLineWidth(1);
6087   cuInputCabs->SetFillColor(cuInputCabs->GetLineColor());
6088   cuInputCabs->SetFillStyle(4000); // 0% transparent
6089
6090   TGeoVolume *plastInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsPlast",
6091                                               inputCabsPlast, medPUR);
6092
6093   plastInputCabs->SetVisibility(kTRUE);
6094   plastInputCabs->SetLineColor(kRed); // Red
6095   plastInputCabs->SetLineWidth(1);
6096   plastInputCabs->SetFillColor(plastInputCabs->GetLineColor());
6097   plastInputCabs->SetFillStyle(4000); // 0% transparent
6098
6099   TGeoVolume *alInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsAl",
6100                                            inputCabsAl, medAl);
6101
6102   alInputCabs->SetVisibility(kTRUE);
6103   alInputCabs->SetLineColor(6); // Purple
6104   alInputCabs->SetLineWidth(1);
6105   alInputCabs->SetFillColor(alInputCabs->GetLineColor());
6106   alInputCabs->SetFillStyle(4000); // 0% transparent
6107
6108   TGeoVolume *kaptonInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsKapton",
6109                                                inputCabsKapton, medKapton);
6110
6111   kaptonInputCabs->SetVisibility(kTRUE);
6112   kaptonInputCabs->SetLineColor(14); // 
6113   kaptonInputCabs->SetLineWidth(1);
6114   kaptonInputCabs->SetFillColor(kaptonInputCabs->GetLineColor());
6115   kaptonInputCabs->SetFillStyle(4000); // 0% transparent
6116
6117   TGeoVolume *polyaxInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsPOLYAX",
6118                                                inputCabsPOLYAX, medPOLYAX);
6119
6120   polyaxInputCabs->SetVisibility(kTRUE);
6121   polyaxInputCabs->SetLineColor(34); // 
6122   polyaxInputCabs->SetLineWidth(1);
6123   polyaxInputCabs->SetFillColor(polyaxInputCabs->GetLineColor());
6124   polyaxInputCabs->SetFillStyle(4000); // 0% transparent
6125
6126   TGeoVolume *cuOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsCu",
6127                                             outputCabsCu, medCu);
6128
6129   cuOutputCabs->SetVisibility(kTRUE);
6130   cuOutputCabs->SetLineColor(kBlack); // Black
6131   cuOutputCabs->SetLineWidth(1);
6132   cuOutputCabs->SetFillColor(cuOutputCabs->GetLineColor());
6133   cuOutputCabs->SetFillStyle(4000); // 0% transparent
6134
6135   TGeoVolume *plastOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsPlast",
6136                                                outputCabsPlast, medPUR);
6137
6138   plastOutputCabs->SetVisibility(kTRUE);
6139   plastOutputCabs->SetLineColor(kRed); // Red
6140   plastOutputCabs->SetLineWidth(1);
6141   plastOutputCabs->SetFillColor(plastOutputCabs->GetLineColor());
6142   plastOutputCabs->SetFillStyle(4000); // 0% transparent
6143
6144   TGeoVolume *alOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsAl",
6145                                             outputCabsAl, medAl);
6146
6147   alOutputCabs->SetVisibility(kTRUE);
6148   alOutputCabs->SetLineColor(6); // Purple
6149   alOutputCabs->SetLineWidth(1);
6150   alOutputCabs->SetFillColor(alOutputCabs->GetLineColor());
6151   alOutputCabs->SetFillStyle(4000); // 0% transparent
6152
6153   TGeoVolume *kaptonOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsKapton",
6154                                                 outputCabsKapton, medKapton);
6155
6156   kaptonOutputCabs->SetVisibility(kTRUE);
6157   kaptonOutputCabs->SetLineColor(14); // 
6158   kaptonOutputCabs->SetLineWidth(1);
6159   kaptonOutputCabs->SetFillColor(kaptonOutputCabs->GetLineColor());
6160   kaptonOutputCabs->SetFillStyle(4000); // 0% transparent
6161
6162   TGeoVolume *polyaxOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsPOLYAX",
6163                                                 outputCabsPOLYAX, medPOLYAX);
6164
6165   polyaxOutputCabs->SetVisibility(kTRUE);
6166   polyaxOutputCabs->SetLineColor(34); // 
6167   polyaxOutputCabs->SetLineWidth(1);
6168   polyaxOutputCabs->SetFillColor(polyaxOutputCabs->GetLineColor());
6169   polyaxOutputCabs->SetFillStyle(4000); // 0% transparent
6170
6171   TGeoVolume *cuPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsCu",
6172                                            pcbBoardsCu, medCu);
6173
6174   cuPCBBoards->SetVisibility(kTRUE);
6175   cuPCBBoards->SetLineColor(kBlack); // Black
6176   cuPCBBoards->SetLineWidth(1);
6177   cuPCBBoards->SetFillColor(cuPCBBoards->GetLineColor());
6178   cuPCBBoards->SetFillStyle(4000); // 0% transparent
6179
6180   TGeoVolume *epoxyPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsEpoxy",
6181                                               pcbBoardsEpoxy, medEpoxy);
6182
6183   epoxyPCBBoards->SetVisibility(kTRUE);
6184   epoxyPCBBoards->SetLineColor(22); //
6185   epoxyPCBBoards->SetLineWidth(1);
6186   epoxyPCBBoards->SetFillColor(epoxyPCBBoards->GetLineColor());
6187   epoxyPCBBoards->SetFillStyle(4000); // 0% transparent
6188
6189   TGeoVolume *plastPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsPlast",
6190                                               pcbBoardsPlast, medPUR);
6191
6192   plastPCBBoards->SetVisibility(kTRUE);
6193   plastPCBBoards->SetLineColor(kRed); // Red
6194   plastPCBBoards->SetLineWidth(1);
6195   plastPCBBoards->SetFillColor(plastPCBBoards->GetLineColor());
6196   plastPCBBoards->SetFillStyle(4000); // 0% transparent
6197
6198   TGeoVolume *steelPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsSteel",
6199                                               pcbBoardsSteel, medSteel);
6200
6201   steelPCBBoards->SetVisibility(kTRUE);
6202   steelPCBBoards->SetLineColor(kBlue); // Blue
6203   steelPCBBoards->SetLineWidth(1);
6204   steelPCBBoards->SetFillColor(steelPCBBoards->GetLineColor());
6205   steelPCBBoards->SetFillStyle(4000); // 0% transparent
6206
6207   TGeoVolume *ppsPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsPPS",
6208                                             pcbBoardsPPS, medPPS);
6209
6210   ppsPCBBoards->SetVisibility(kTRUE);
6211   ppsPCBBoards->SetLineColor(kGreen); // Green
6212   ppsPCBBoards->SetLineWidth(1);
6213   ppsPCBBoards->SetFillColor(ppsPCBBoards->GetLineColor());
6214   ppsPCBBoards->SetFillStyle(4000); // 0% transparent
6215
6216
6217   // Now build up the tray
6218   yloc = kForwardTrayTotalHeight - forwardCover->GetY(3);
6219   zloc = kForwardTrayUpperLength - kForwardCoverLength;
6220   cableTrayA->AddNode(forwardTrayCover, 1,
6221                       new TGeoTranslation( 0, yloc, zloc) );
6222
6223   Double_t totalhi = kExternTrayTotalHeight + kExternCoverThick
6224                    - kExternCoverYTrans;
6225
6226   yloc = totalhi*(1 - CosD(kTrayAZRot)) + kExternTrayYTrans -
6227          kExternTrayTotalHeight*CosD(kTrayAZRot);
6228   zloc = kExternTrayZTrans + totalhi*SinD(kTrayAZRot);
6229   cableTrayA->AddNode(externalTraySDD, 1,
6230                       new TGeoCombiTrans( 0, yloc, zloc,
6231                       new TGeoRotation("", 0,-kTrayAZRot, 0)        ) );
6232
6233   yloc = kExternCoverThick*(1 - CosD(kTrayAZRot)) + kExternTrayYTrans -
6234          kExternCoverYTrans*CosD(kTrayAZRot)/2-0.01;
6235   zloc = kExternTrayZTrans + kExternCoverThick*SinD(kTrayAZRot);
6236   cableTrayA->AddNode(externTrayCover,1,
6237                       new TGeoCombiTrans( 0, yloc, zloc,
6238                       new TGeoRotation("", 0,-kTrayAZRot, 0)        ) );
6239
6240   yloc = kForwardTrayThick + coolManifPOM->GetDY();
6241   zloc = coolManifPOM->GetDZ();
6242   cableTrayA->AddNode(pomCoolManif, 1,
6243                       new TGeoTranslation( 0, yloc, zloc) );
6244
6245   yloc += coolManifPOM->GetDY() + coolManifSteel->GetDY();
6246   cableTrayA->AddNode(steelCoolManif, 1,
6247                       new TGeoTranslation( 0, yloc, zloc) );
6248
6249   yloc += coolManifSteel->GetDY() + coolManifWater->GetDY();
6250   cableTrayA->AddNode(waterCoolManif, 1,
6251                       new TGeoTranslation( 0, yloc, zloc) );
6252
6253   yloc += coolManifWater->GetDY() + coolManifAl->GetDY();
6254   cableTrayA->AddNode(alCoolManif, 1,
6255                       new TGeoTranslation( 0, yloc, zloc) );
6256
6257   cableTrayA->AddNode(purCoolTubes,1,
6258                       new TGeoCombiTrans( 0, 0, 0,
6259                       new TGeoRotation("",-90, 90, 90)        ) );
6260   cableTrayA->AddNode(waterCoolTubes,1,
6261                       new TGeoCombiTrans( 0, 0, 0,
6262                       new TGeoRotation("",-90, 90, 90)        ) );
6263   cableTrayA->AddNode(airCoolTubes,1,
6264                       new TGeoCombiTrans( 0, 0, 0,
6265                       new TGeoRotation("",-90, 90, 90)        ) );
6266
6267   xloc = coolManifPOM->GetDX() + optConnPBT->GetDX();
6268   yloc = kForwardTrayThick + optConnPBT->GetDY();
6269   zloc = optConnPBT->GetDZ();
6270   cableTrayA->AddNode(pbtOptConn, 1,
6271                       new TGeoTranslation( xloc, yloc, zloc) );
6272   cableTrayA->AddNode(pbtOptConn, 2,
6273                       new TGeoTranslation(-xloc, yloc, zloc) );
6274
6275   yloc += optConnPBT->GetDY() + optConnSteel->GetDY();
6276   cableTrayA->AddNode(steelOptConn, 1,
6277                       new TGeoTranslation( xloc, yloc, zloc) );
6278   cableTrayA->AddNode(steelOptConn, 2,
6279                       new TGeoTranslation(-xloc, yloc, zloc) );
6280
6281   yloc += optConnSteel->GetDY() + optConnAl->GetDY();
6282   cableTrayA->AddNode(alOptConn, 1,
6283                       new TGeoTranslation( xloc, yloc, zloc) );
6284   cableTrayA->AddNode(alOptConn, 2,
6285                       new TGeoTranslation(-xloc, yloc, zloc) );
6286
6287
6288   xloc = kSideACoolTubesWide/2 + kSideAOptFibsWide/2;
6289   cableTrayA->AddNode(optFibs,1,
6290                       new TGeoCombiTrans( xloc, 0, 0,
6291                       new TGeoRotation("",-90, 90, 90)        ) );
6292   cableTrayA->AddNode(optFibs,2,
6293                       new TGeoCombiTrans(-xloc, 0, 0,
6294                       new TGeoRotation("",-90, 90, 90)        ) );
6295
6296   yloc = kForwardTrayTotalHeight - forwardCover->GetY(3) -
6297          kSideAInputCablesYTrans - inputCabsPOLYAX->GetDY();
6298   zloc = inputCabsPOLYAX->GetDZ();
6299   cableTrayA->AddNode(polyaxInputCabs, 1,
6300                       new TGeoTranslation( 0, yloc, zloc) );
6301
6302   yloc -= (inputCabsPOLYAX->GetDY() + inputCabsKapton->GetDY());
6303   cableTrayA->AddNode(kaptonInputCabs, 1,
6304                       new TGeoTranslation( 0, yloc, zloc) );
6305
6306   yloc -= (inputCabsKapton->GetDY() + inputCabsAl->GetDY());
6307   cableTrayA->AddNode(alInputCabs, 1,
6308                       new TGeoTranslation( 0, yloc, zloc) );
6309
6310   yloc -= (inputCabsAl->GetDY() + inputCabsPlast->GetDY());
6311   cableTrayA->AddNode(plastInputCabs, 1,
6312                       new TGeoTranslation( 0, yloc, zloc) );
6313
6314   yloc -= (inputCabsPlast->GetDY() + inputCabsCu->GetDY());
6315   cableTrayA->AddNode(cuInputCabs, 1,
6316                       new TGeoTranslation( 0, yloc, zloc) );
6317
6318   yloc -= (inputCabsCu->GetDY()+pcbBoardsPPS->GetDY()+kSideAPCBBoardsYTrans);
6319   zloc += pcbBoardsPPS->GetDZ();
6320   cableTrayA->AddNode(ppsPCBBoards, 1,
6321                       new TGeoTranslation( 0, yloc, zloc) );
6322
6323   yloc -= (pcbBoardsPPS->GetDY()+pcbBoardsSteel->GetDY());
6324   cableTrayA->AddNode(steelPCBBoards, 1,
6325                       new TGeoTranslation( 0, yloc, zloc) );
6326
6327   yloc -= (pcbBoardsSteel->GetDY()+pcbBoardsPlast->GetDY());
6328   cableTrayA->AddNode(plastPCBBoards, 1,
6329                       new TGeoTranslation( 0, yloc, zloc) );
6330
6331   yloc -= (pcbBoardsPlast->GetDY()+pcbBoardsEpoxy->GetDY());
6332   cableTrayA->AddNode(epoxyPCBBoards, 1,
6333                       new TGeoTranslation( 0, yloc, zloc) );
6334
6335   yloc -= (pcbBoardsEpoxy->GetDY()+pcbBoardsCu->GetDY());
6336   cableTrayA->AddNode(cuPCBBoards, 1,
6337                       new TGeoTranslation( 0, yloc, zloc) );
6338
6339   cableTrayA->AddNode(cuOutputCabs,1,
6340                       new TGeoCombiTrans( 0, 0, 0,
6341                       new TGeoRotation("",-90, 90, 90)        ) );
6342   cableTrayA->AddNode(plastOutputCabs,1,
6343                       new TGeoCombiTrans( 0, 0, 0,
6344                       new TGeoRotation("",-90, 90, 90)        ) );
6345   cableTrayA->AddNode(alOutputCabs,1,
6346                       new TGeoCombiTrans( 0, 0, 0,
6347                       new TGeoRotation("",-90, 90, 90)        ) );
6348   cableTrayA->AddNode(kaptonOutputCabs,1,
6349                       new TGeoCombiTrans( 0, 0, 0,
6350                       new TGeoRotation("",-90, 90, 90)        ) );
6351   cableTrayA->AddNode(polyaxOutputCabs,1,
6352                       new TGeoCombiTrans( 0, 0, 0,
6353                       new TGeoRotation("",-90, 90, 90)        ) );
6354
6355
6356   // Finally put everything in the mother volume
6357   Double_t rforw = kTrayARTrans + kExternTrayTotalHeight +
6358                    kExternCoverSideThick -
6359                    kForwardTrayTailHeight;
6360
6361   alpharot = -kTrayAFirstRotAng;
6362   xloc = rforw*SinD(alpharot);
6363   yloc = rforw*CosD(alpharot);
6364   zloc = kTrayAZTrans + kTrayAZToSupportRing - kForwardTrayUpperLength;
6365
6366   moth->AddNode(cableTrayA,1,
6367                             new TGeoCombiTrans( xloc, yloc, zloc,
6368                             new TGeoRotation("",-alpharot,0,0)   )   );
6369
6370   alpharot += 180;
6371   xloc = rforw*SinD(alpharot);
6372   yloc = rforw*CosD(alpharot);
6373   moth->AddNode(cableTrayA,2,
6374                             new TGeoCombiTrans( xloc, yloc, zloc,
6375                             new TGeoRotation("",-alpharot,0,0)   )   );
6376
6377   alpharot = kTrayAFirstRotAng + 2*kTrayASecondRotAng;
6378   xloc = rforw*SinD(alpharot);
6379   yloc = rforw*CosD(alpharot);
6380   moth->AddNode(cableTrayA,3,
6381                             new TGeoCombiTrans( xloc, yloc, zloc,
6382                             new TGeoRotation("",-alpharot,0,0)   )   );
6383
6384   alpharot += 180;
6385   xloc = rforw*SinD(alpharot);
6386   yloc = rforw*CosD(alpharot);
6387   moth->AddNode(cableTrayA,4,
6388                             new TGeoCombiTrans( xloc, yloc, zloc,
6389                             new TGeoRotation("",-alpharot,0,0)   )   );
6390
6391
6392   return;
6393 }
6394
6395 //______________________________________________________________________
6396 void AliITSv11GeometrySupport::SDDCableTraysSideC(TGeoVolume *moth,
6397                                             const TGeoManager *mgr){
6398 //
6399 // Creates the SDD cable trays which are outside the ITS support cones
6400 // but still inside the TPC on Side C
6401 // (part of this code is taken or anyway inspired to ServicesCableSupport
6402 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
6403 //
6404 // Input:
6405 //         moth : the TGeoVolume owing the volume structure
6406 //         mgr  : the GeoManager (default gGeoManager)
6407 // Output:
6408 //
6409 // Created:         ???       Bjorn S. Nilsen
6410 // Updated:      17 Apr 2010  Mario Sitta
6411 //
6412 // Technical data are taken from AutoCAD drawings and other (oral)
6413 // information given by F.Tosello
6414 //
6415
6416   // Dimensions and positions of the C-Side Cable Tray
6417   // (Change accordingly to CreateSDDSSDTraysSideC !)
6418   const Int_t    kNumTraySideC           =    4;
6419
6420   const Double_t kSideCHalfThick         =    0.100   *fgkcm;
6421   const Double_t kSideCLength1           =  172.800   *fgkcm;
6422   const Double_t kSideCLength2           =  189.300   *fgkcm;
6423   const Double_t kBarCoolRmax            =    0.4     *fgkcm;
6424   const Double_t kXShiftBarCool          =   13.00    *fgkcm;
6425
6426   const Double_t kSideCFoldAngle         =    5.00 *fgkDegree;
6427
6428   // Dimensions and positions of the Cable Tray elements
6429   const Double_t kSideCCoolManifHalfX    =    4.25    *fgkcm;
6430   const Double_t kSideCCoolManifHalfY    =    4.03    *fgkcm;
6431   const Double_t kSideCCoolManifHalfZ    =    2.17    *fgkcm;
6432   const Double_t kSideCCoolManifPOMFrac  =    0.0051;
6433   const Double_t kSideCCoolManifSteelFrac=    0.8502;
6434   const Double_t kSideCCoolManifWaterFrac=    0.0868;
6435   const Double_t kSideCCoolManifAlFrac   =    0.0579;
6436
6437   const Double_t kSideCCoolTubesHigh     =    1.88    *fgkcm;
6438   const Double_t kSideCCoolTubesTrans    =    0.85    *fgkcm;
6439   const Double_t kSideCCoolTubesPURFrac  =    0.5884;
6440   const Double_t kSideCCoolTubesWaterFrac=    0.4114;
6441   const Double_t kSideCCoolTubesAirFrac  =    0.0002;
6442
6443   const Double_t kSideCOptConnHalfX      =    0.90    *fgkcm;
6444   const Double_t kSideCOptConnHalfZ      =    1.37    *fgkcm;
6445   const Double_t kSideCOptConnPBTFrac    =    0.6798;
6446   const Double_t kSideCOptConnSteelFrac  =    0.2421;
6447   const Double_t kSideCOptConnAlFrac     =    0.0781;
6448
6449   const Double_t kSideCOptFibsWide       =    0.71    *fgkcm;
6450   const Double_t kSideCOptFibsHigh       =    3.20    *fgkcm;
6451   const Double_t kSideCOptFibsTrans      =    0.20    *fgkcm;
6452
6453   const Double_t kSideCInputCablesLen    =   31.45    *fgkcm;
6454   const Double_t kSideCInputCablesWide   =   12.50    *fgkcm;
6455   const Double_t kSideCInputCablesHigh   =    0.95    *fgkcm;
6456   const Double_t kSideCInputCablesTrans  =    1.15    *fgkcm;
6457   const Double_t kSideCInputCablesCu     =    0.7405;
6458   const Double_t kSideCInputCablesPlast  =    0.1268;
6459   const Double_t kSideCInputCablesAl     =    0.0057;
6460   const Double_t kSideCInputCablesKapton =    0.0172;
6461   const Double_t kSideCInputCablesPOLYAX =    0.1098;
6462
6463   const Double_t kSideCOutputCablesX0    =   27.40    *fgkcm;
6464   const Double_t kSideCOutputCablesWide  =    8.50    *fgkcm;
6465   const Double_t kSideCOutputCablesHigh  =    1.18    *fgkcm;
6466   const Double_t kSideCOutputCablesCu    =    0.6775;
6467   const Double_t kSideCOutputCablesPlast =    0.1613;
6468   const Double_t kSideCOutputCablesAl    =    0.0078;
6469   const Double_t kSideCOutputCablesKapton=    0.0234;
6470   const Double_t kSideCOutputCablesPOLYAX=    0.1300;
6471
6472   const Double_t kSideCPCBBoardsHalfX    =    6.30    *fgkcm;
6473   const Double_t kSideCPCBBoardsHalfY    =    2.00    *fgkcm;
6474   const Double_t kSideCPCBBoardsHalfZ    =   21.93    *fgkcm;
6475   const Double_t kSideCPCBBoardsCu       =    0.3864;
6476   const Double_t kSideCPCBBoardsEpoxy    =    0.1491;
6477   const Double_t kSideCPCBBoardsPlast    =    0.0579;
6478   const Double_t kSideCPCBBoardsSteel    =    0.1517;
6479   const Double_t kSideCPCBBoardsPPS      =    0.2549;
6480
6481   // Overall position and rotation of the C-Side Cable Trays
6482   const Double_t kTraySideCRPos          =   45.30    *fgkcm;
6483   const Double_t kTraySideCZPos          = -102.40    *fgkcm;
6484   const Double_t kTraySideCAlphaRot[kNumTraySideC]  = {    -23.0,      59.0,
6485     /* from SSD tray position */                       180.-23.0, 180.+59.0};
6486
6487
6488   // Local variables
6489   Double_t xprof[6], yprof[6];
6490   Double_t height, xloc, yloc, zloc, alpharot, alphafold;
6491
6492
6493   // The assembly holding the metallic structure
6494   TGeoVolumeAssembly *trayStructure = CreateSDDSSDTraysSideC("ITSsupportSDDTrayC");
6495
6496   // Now the volumes inside it
6497   // The cooling manifold: four boxes
6498   // (X and Z are inverted on tray reference system)
6499   TGeoBBox *coolManifPOM = new TGeoBBox(kSideCCoolManifHalfZ,
6500                  kSideCCoolManifPOMFrac*kSideCCoolManifHalfY,
6501                                         kSideCCoolManifHalfX);
6502
6503   TGeoBBox *coolManifSteel = new TGeoBBox(kSideCCoolManifHalfZ,
6504                  kSideCCoolManifSteelFrac*kSideCCoolManifHalfY,
6505                                           kSideCCoolManifHalfX);
6506
6507   TGeoBBox *coolManifWater = new TGeoBBox(kSideCCoolManifHalfZ,
6508                  kSideCCoolManifWaterFrac*kSideCCoolManifHalfY,
6509                                           kSideCCoolManifHalfX);
6510
6511   TGeoBBox *coolManifAl = new TGeoBBox(kSideCCoolManifHalfZ,
6512                  kSideCCoolManifAlFrac*kSideCCoolManifHalfY,
6513                                        kSideCCoolManifHalfX);
6514
6515   // The cooling tubes: three Xtru's
6516   alpharot = kSideCFoldAngle*TMath::DegToRad();
6517
6518   TGeoXtru *coolTubesPUR = new TGeoXtru(2);
6519
6520   height = kSideCCoolTubesHigh*kSideCCoolTubesPURFrac;
6521
6522   xprof[0] = 2*kSideCCoolManifHalfZ;
6523   yprof[0] = 2*kSideCHalfThick + kSideCCoolTubesTrans;
6524   xprof[1] = kSideCLength1;
6525   yprof[1] = yprof[0];
6526   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(alpharot);
6527   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(alpharot);
6528   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6529   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6530   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6531               height, xprof[4], yprof[4]);
6532   xprof[5] = xprof[0];
6533   yprof[5] = yprof[0] + height;
6534
6535   coolTubesPUR->DefinePolygon(6, xprof, yprof);
6536   coolTubesPUR->DefineSection(0,-kSideCCoolManifHalfX);
6537   coolTubesPUR->DefineSection(1, kSideCCoolManifHalfX);
6538
6539   TGeoXtru *coolTubesWater = new TGeoXtru(2);
6540
6541   height = kSideCCoolTubesHigh*kSideCCoolTubesWaterFrac;
6542
6543   xprof[0] = coolTubesPUR->GetX(5);
6544   yprof[0] = coolTubesPUR->GetY(5);
6545   xprof[1] = coolTubesPUR->GetX(4);
6546   yprof[1] = coolTubesPUR->GetY(4);
6547   xprof[2] = coolTubesPUR->GetX(3);
6548   yprof[2] = coolTubesPUR->GetY(3);
6549   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6550   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6551   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6552               height, xprof[4], yprof[4]);
6553   xprof[5] = xprof[0];
6554   yprof[5] = yprof[0] + height;
6555
6556   coolTubesWater->DefinePolygon(6, xprof, yprof);
6557   coolTubesWater->DefineSection(0,-kSideCCoolManifHalfX);
6558   coolTubesWater->DefineSection(1, kSideCCoolManifHalfX);
6559
6560   TGeoXtru *coolTubesAir = new TGeoXtru(2);
6561
6562   height = kSideCCoolTubesHigh*kSideCCoolTubesAirFrac;
6563
6564   xprof[0] = coolTubesWater->GetX(5);
6565   yprof[0] = coolTubesWater->GetY(5);
6566   xprof[1] = coolTubesWater->GetX(4);
6567   yprof[1] = coolTubesWater->GetY(4);
6568   xprof[2] = coolTubesWater->GetX(3);
6569   yprof[2] = coolTubesWater->GetY(3);
6570   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6571   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6572   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6573               height, xprof[4], yprof[4]);
6574   xprof[5] = xprof[0];
6575   yprof[5] = yprof[0] + height;
6576
6577   coolTubesAir->DefinePolygon(6, xprof, yprof);
6578   coolTubesAir->DefineSection(0,-kSideCCoolManifHalfX);
6579   coolTubesAir->DefineSection(1, kSideCCoolManifHalfX);
6580
6581   // The optical fiber connectors: three boxes
6582   // (X and Z are inverted on tray reference system)
6583   TGeoBBox *optConnPBT = new TGeoBBox(kSideCOptConnHalfZ,
6584                  kSideCOptConnPBTFrac*kSideCCoolManifHalfY,
6585                                       kSideCOptConnHalfX);
6586
6587   TGeoBBox *optConnSteel = new TGeoBBox(kSideCOptConnHalfZ,
6588                  kSideCOptConnSteelFrac*kSideCCoolManifHalfY,
6589                                         kSideCOptConnHalfX);
6590
6591   TGeoBBox *optConnAl = new TGeoBBox(kSideCOptConnHalfZ,
6592                  kSideCOptConnAlFrac*kSideCCoolManifHalfY,
6593                                      kSideCOptConnHalfX);
6594
6595   // The optical fibers: a Xtru
6596   TGeoXtru *opticalFibs = new TGeoXtru(2);
6597
6598   xprof[0] = 2*kSideCOptConnHalfZ;
6599   yprof[0] = 2*kSideCHalfThick + kSideCOptFibsTrans;
6600   xprof[1] = kSideCLength1;
6601   yprof[1] = yprof[0];
6602   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(alpharot);
6603   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(alpharot);
6604   xprof[3] = xprof[2] - kSideCOptFibsHigh*TMath::Sin(alpharot);
6605   yprof[3] = yprof[2] + kSideCOptFibsHigh*TMath::Cos(alpharot);
6606   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6607               kSideCOptFibsHigh, xprof[4], yprof[4]);
6608   xprof[5] = xprof[0];
6609   yprof[5] = yprof[0] + kSideCOptFibsHigh;
6610
6611   opticalFibs->DefinePolygon(6, xprof, yprof);
6612   opticalFibs->DefineSection(0,-kSideCOptFibsWide/2);
6613   opticalFibs->DefineSection(1, kSideCOptFibsWide/2);
6614
6615   // The input cables: five boxes
6616   // (X and Z are inverted on tray reference system)
6617   TGeoBBox *inputCabsCu = new TGeoBBox(kSideCInputCablesLen/2,
6618                    kSideCInputCablesCu*kSideCInputCablesHigh/2,
6619                                        kSideCInputCablesWide/2);
6620
6621   TGeoBBox *inputCabsPlast = new TGeoBBox(kSideCInputCablesLen/2,
6622                    kSideCInputCablesPlast*kSideCInputCablesHigh/2,
6623                                           kSideCInputCablesWide/2);
6624
6625   TGeoBBox *inputCabsAl = new TGeoBBox(kSideCInputCablesLen/2,
6626                    kSideCInputCablesAl*kSideCInputCablesHigh/2,
6627                                        kSideCInputCablesWide/2);
6628
6629   TGeoBBox *inputCabsKapton = new TGeoBBox(kSideCInputCablesLen/2,
6630                    kSideCInputCablesKapton*kSideCInputCablesHigh/2,
6631                                            kSideCInputCablesWide/2);
6632
6633   TGeoBBox *inputCabsPOLYAX = new TGeoBBox(kSideCInputCablesLen/2,
6634                    kSideCInputCablesPOLYAX*kSideCInputCablesHigh/2,
6635                                            kSideCInputCablesWide/2);
6636
6637   // The output cables: five Xtru
6638   TGeoXtru *outputCabsCu = new TGeoXtru(2);
6639
6640   height = kSideCOutputCablesCu*kSideCOutputCablesHigh;
6641
6642   xprof[0] = coolTubesAir->GetX(5) + kSideCOutputCablesX0;
6643   yprof[0] = coolTubesAir->GetY(5);
6644   xprof[1] = coolTubesAir->GetX(4);
6645   yprof[1] = coolTubesAir->GetY(4);
6646   xprof[2] = coolTubesAir->GetX(3);
6647   yprof[2] = coolTubesAir->GetY(3);
6648   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6649   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6650   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6651               height, xprof[4], yprof[4]);
6652   xprof[5] = xprof[0];
6653   yprof[5] = yprof[0] + height;
6654
6655   outputCabsCu->DefinePolygon(6, xprof, yprof);
6656   outputCabsCu->DefineSection(0,-kSideCOutputCablesWide/2);
6657   outputCabsCu->DefineSection(1, kSideCOutputCablesWide/2);
6658
6659   TGeoXtru *outputCabsPlast = new TGeoXtru(2);
6660
6661   height = kSideCOutputCablesPlast*kSideCOutputCablesHigh;
6662
6663   xprof[0] = outputCabsCu->GetX(5);
6664   yprof[0] = outputCabsCu->GetY(5);
6665   xprof[1] = outputCabsCu->GetX(4);
6666   yprof[1] = outputCabsCu->GetY(4);
6667   xprof[2] = outputCabsCu->GetX(3);
6668   yprof[2] = outputCabsCu->GetY(3);
6669   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6670   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6671   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6672               height, xprof[4], yprof[4]);
6673   xprof[5] = xprof[0];
6674   yprof[5] = yprof[0] + height;
6675
6676   outputCabsPlast->DefinePolygon(6, xprof, yprof);
6677   outputCabsPlast->DefineSection(0,-kSideCOutputCablesWide/2);
6678   outputCabsPlast->DefineSection(1, kSideCOutputCablesWide/2);
6679
6680   TGeoXtru *outputCabsAl = new TGeoXtru(2);
6681
6682   height = kSideCOutputCablesAl*kSideCOutputCablesHigh;
6683
6684   xprof[0] = outputCabsPlast->GetX(5);
6685   yprof[0] = outputCabsPlast->GetY(5);
6686   xprof[1] = outputCabsPlast->GetX(4);
6687   yprof[1] = outputCabsPlast->GetY(4);
6688   xprof[2] = outputCabsPlast->GetX(3);
6689   yprof[2] = outputCabsPlast->GetY(3);
6690   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6691   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6692   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6693               height, xprof[4], yprof[4]);
6694   xprof[5] = xprof[0];
6695   yprof[5] = yprof[0] + height;
6696
6697   outputCabsAl->DefinePolygon(6, xprof, yprof);
6698   outputCabsAl->DefineSection(0,-kSideCOutputCablesWide/2);
6699   outputCabsAl->DefineSection(1, kSideCOutputCablesWide/2);
6700
6701   TGeoXtru *outputCabsKapton = new TGeoXtru(2);
6702
6703   height = kSideCOutputCablesKapton*kSideCOutputCablesHigh;
6704
6705   xprof[0] = outputCabsAl->GetX(5);
6706   yprof[0] = outputCabsAl->GetY(5);
6707   xprof[1] = outputCabsAl->GetX(4);
6708   yprof[1] = outputCabsAl->GetY(4);
6709   xprof[2] = outputCabsAl->GetX(3);
6710   yprof[2] = outputCabsAl->GetY(3);
6711   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6712   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6713   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6714               height, xprof[4], yprof[4]);
6715   xprof[5] = xprof[0];
6716   yprof[5] = yprof[0] + height;
6717
6718   outputCabsKapton->DefinePolygon(6, xprof, yprof);
6719   outputCabsKapton->DefineSection(0,-kSideCOutputCablesWide/2);
6720   outputCabsKapton->DefineSection(1, kSideCOutputCablesWide/2);
6721
6722   TGeoXtru *outputCabsPOLYAX = new TGeoXtru(2);
6723
6724   height = kSideCOutputCablesPOLYAX*kSideCOutputCablesHigh;
6725
6726   xprof[0] = outputCabsKapton->GetX(5);
6727   yprof[0] = outputCabsKapton->GetY(5);
6728   xprof[1] = outputCabsKapton->GetX(4);
6729   yprof[1] = outputCabsKapton->GetY(4);
6730   xprof[2] = outputCabsKapton->GetX(3);
6731   yprof[2] = outputCabsKapton->GetY(3);
6732   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6733   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6734   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6735               height, xprof[4], yprof[4]);
6736   xprof[5] = xprof[0];
6737   yprof[5] = yprof[0] + height;
6738
6739   outputCabsPOLYAX->DefinePolygon(6, xprof, yprof);
6740   outputCabsPOLYAX->DefineSection(0,-kSideCOutputCablesWide/2);
6741   outputCabsPOLYAX->DefineSection(1, kSideCOutputCablesWide/2);
6742
6743   // The PCB boards: five boxes
6744   // (X and Z are inverted on tray reference system)
6745   TGeoBBox *pcbBoardsCu = new TGeoBBox(kSideCPCBBoardsHalfZ,
6746                      kSideCPCBBoardsCu*kSideCPCBBoardsHalfY,
6747                                        kSideCPCBBoardsHalfX);
6748
6749   TGeoBBox *pcbBoardsEpoxy = new TGeoBBox(kSideCPCBBoardsHalfZ,
6750                      kSideCPCBBoardsEpoxy*kSideCPCBBoardsHalfY,
6751                                           kSideCPCBBoardsHalfX);
6752
6753   TGeoBBox *pcbBoardsPlast = new TGeoBBox(kSideCPCBBoardsHalfZ,
6754                      kSideCPCBBoardsPlast*kSideCPCBBoardsHalfY,
6755                                           kSideCPCBBoardsHalfX);
6756
6757   TGeoBBox *pcbBoardsSteel = new TGeoBBox(kSideCPCBBoardsHalfZ,
6758                      kSideCPCBBoardsSteel*kSideCPCBBoardsHalfY,
6759                                           kSideCPCBBoardsHalfX);
6760
6761   TGeoBBox *pcbBoardsPPS = new TGeoBBox(kSideCPCBBoardsHalfZ,
6762                      kSideCPCBBoardsPPS*kSideCPCBBoardsHalfY,
6763                                         kSideCPCBBoardsHalfX);
6764
6765
6766   // We have all shapes: now create the real volumes
6767   TGeoMedium *medPOM    = mgr->GetMedium("ITS_POLYOXYMETHYLENE$");
6768   TGeoMedium *medSteel  = mgr->GetMedium("ITS_INOX$");
6769   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
6770   TGeoMedium *medAl     = mgr->GetMedium("ITS_ALUMINUM$");
6771   TGeoMedium *medCu     = mgr->GetMedium("ITS_COPPER$");
6772   TGeoMedium *medPUR    = mgr->GetMedium("ITS_POLYURETHANE$");
6773   TGeoMedium *medPOLYAX = mgr->GetMedium("ITS_POLYAX$");
6774   TGeoMedium *medKapton = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
6775   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
6776   TGeoMedium *medPBT    = mgr->GetMedium("ITS_PBT$");
6777   TGeoMedium *medOptFib = mgr->GetMedium("ITS_SDD OPTICFIB$");
6778   TGeoMedium *medPPS    = mgr->GetMedium("ITS_PPS$");
6779   TGeoMedium *medEpoxy  = mgr->GetMedium("ITS_EPOXY$");
6780
6781   TGeoVolume *pomCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifPOM",
6782                                             coolManifPOM, medPOM);
6783
6784   pomCoolManif->SetVisibility(kTRUE);
6785   pomCoolManif->SetLineColor(kRed); // Red
6786   pomCoolManif->SetLineWidth(1);
6787   pomCoolManif->SetFillColor(pomCoolManif->GetLineColor());
6788   pomCoolManif->SetFillStyle(4000); // 0% transparent
6789
6790   TGeoVolume *steelCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifSteel",
6791                                               coolManifSteel, medSteel);
6792
6793   steelCoolManif->SetVisibility(kTRUE);
6794   steelCoolManif->SetLineColor(kBlue); // Blue
6795   steelCoolManif->SetLineWidth(1);
6796   steelCoolManif->SetFillColor(steelCoolManif->GetLineColor());
6797   steelCoolManif->SetFillStyle(4000); // 0% transparent
6798
6799   TGeoVolume *waterCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifWater",
6800                                               coolManifWater, medWater);
6801
6802   waterCoolManif->SetVisibility(kTRUE);
6803   waterCoolManif->SetLineColor(33); // Light Blue
6804   waterCoolManif->SetLineWidth(1);
6805   waterCoolManif->SetFillColor(waterCoolManif->GetLineColor());
6806   waterCoolManif->SetFillStyle(4000); // 0% transparent
6807
6808   TGeoVolume *alCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifAl",
6809                                            coolManifAl, medAl);
6810
6811   alCoolManif->SetVisibility(kTRUE);
6812   alCoolManif->SetLineColor(6); // Purple
6813   alCoolManif->SetLineWidth(1);
6814   alCoolManif->SetFillColor(alCoolManif->GetLineColor());
6815   alCoolManif->SetFillStyle(4000); // 0% transparent
6816
6817   TGeoVolume *purCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesPUR",
6818                                             coolTubesPUR, medPUR);
6819
6820   purCoolTubes->SetVisibility(kTRUE);
6821   purCoolTubes->SetLineColor(kRed); // Red
6822   purCoolTubes->SetLineWidth(1);
6823   purCoolTubes->SetFillColor(purCoolTubes->GetLineColor());
6824   purCoolTubes->SetFillStyle(4000); // 0% transparent
6825
6826   TGeoVolume *waterCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesWater",
6827                                               coolTubesWater, medWater);
6828
6829   waterCoolTubes->SetVisibility(kTRUE);
6830   waterCoolTubes->SetLineColor(33); // Light Blue
6831   waterCoolTubes->SetLineWidth(1);
6832   waterCoolTubes->SetFillColor(waterCoolTubes->GetLineColor());
6833   waterCoolTubes->SetFillStyle(4000); // 0% transparent
6834
6835   TGeoVolume *airCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesAir",
6836                                             coolTubesAir, medAir);
6837
6838   airCoolTubes->SetVisibility(kTRUE);
6839   airCoolTubes->SetLineColor(41);
6840   airCoolTubes->SetLineWidth(1);
6841   airCoolTubes->SetFillColor(airCoolTubes->GetLineColor());
6842   airCoolTubes->SetFillStyle(4000); // 0% transparent
6843
6844   TGeoVolume *pbtOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnPBT",
6845                                           optConnPBT, medPBT);
6846
6847   pbtOptConn->SetVisibility(kTRUE);
6848   pbtOptConn->SetLineColor(kRed); // Red
6849   pbtOptConn->SetLineWidth(1);
6850   pbtOptConn->SetFillColor(pbtOptConn->GetLineColor());
6851   pbtOptConn->SetFillStyle(4000); // 0% transparent
6852
6853   TGeoVolume *steelOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnSteel",
6854                                             optConnSteel, medSteel);
6855
6856   steelOptConn->SetVisibility(kTRUE);
6857   steelOptConn->SetLineColor(kBlue); // Blue
6858   steelOptConn->SetLineWidth(1);
6859   steelOptConn->SetFillColor(steelOptConn->GetLineColor());
6860   steelOptConn->SetFillStyle(4000); // 0% transparent
6861
6862   TGeoVolume *alOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnAl",
6863                                          optConnAl, medAl);
6864
6865   alOptConn->SetVisibility(kTRUE);
6866   alOptConn->SetLineColor(6); // Purple
6867   alOptConn->SetLineWidth(1);
6868   alOptConn->SetFillColor(alOptConn->GetLineColor());
6869   alOptConn->SetFillStyle(4000); // 0% transparent
6870
6871   TGeoVolume *optFibs = new TGeoVolume("ITSsuppSDDSideCOptFibs",
6872                                        opticalFibs, medOptFib);
6873
6874   optFibs->SetVisibility(kTRUE);
6875   optFibs->SetLineColor(kOrange+2); // Orange
6876   optFibs->SetLineWidth(1);
6877   optFibs->SetFillColor(optFibs->GetLineColor());
6878   optFibs->SetFillStyle(4000); // 0% transparent
6879
6880   TGeoVolume *cuInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsCu",
6881                                            inputCabsCu, medCu);
6882
6883   cuInputCabs->SetVisibility(kTRUE);
6884   cuInputCabs->SetLineColor(kBlack); // Black
6885   cuInputCabs->SetLineWidth(1);
6886   cuInputCabs->SetFillColor(cuInputCabs->GetLineColor());
6887   cuInputCabs->SetFillStyle(4000); // 0% transparent
6888
6889   TGeoVolume *plastInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsPlast",
6890                                               inputCabsPlast, medPUR);
6891
6892   plastInputCabs->SetVisibility(kTRUE);
6893   plastInputCabs->SetLineColor(kRed); // Red
6894   plastInputCabs->SetLineWidth(1);
6895   plastInputCabs->SetFillColor(plastInputCabs->GetLineColor());
6896   plastInputCabs->SetFillStyle(4000); // 0% transparent
6897
6898   TGeoVolume *alInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsAl",
6899                                            inputCabsAl, medAl);
6900
6901   alInputCabs->SetVisibility(kTRUE);
6902   alInputCabs->SetLineColor(6); // Purple
6903   alInputCabs->SetLineWidth(1);
6904   alInputCabs->SetFillColor(alInputCabs->GetLineColor());
6905   alInputCabs->SetFillStyle(4000); // 0% transparent
6906
6907   TGeoVolume *kaptonInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsKapton",
6908                                                inputCabsKapton, medKapton);
6909
6910   kaptonInputCabs->SetVisibility(kTRUE);
6911   kaptonInputCabs->SetLineColor(14); // 
6912   kaptonInputCabs->SetLineWidth(1);
6913   kaptonInputCabs->SetFillColor(kaptonInputCabs->GetLineColor());
6914   kaptonInputCabs->SetFillStyle(4000); // 0% transparent
6915
6916   TGeoVolume *polyaxInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsPOLYAX",
6917                                                inputCabsPOLYAX, medPOLYAX);
6918
6919   polyaxInputCabs->SetVisibility(kTRUE);
6920   polyaxInputCabs->SetLineColor(34); // 
6921   polyaxInputCabs->SetLineWidth(1);
6922   polyaxInputCabs->SetFillColor(polyaxInputCabs->GetLineColor());
6923   polyaxInputCabs->SetFillStyle(4000); // 0% transparent
6924
6925   TGeoVolume *cuOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsCu",
6926                                             outputCabsCu, medCu);
6927
6928   cuOutputCabs->SetVisibility(kTRUE);
6929   cuOutputCabs->SetLineColor(kBlack); // Black
6930   cuOutputCabs->SetLineWidth(1);
6931   cuOutputCabs->SetFillColor(cuOutputCabs->GetLineColor());
6932   cuOutputCabs->SetFillStyle(4000); // 0% transparent
6933
6934   TGeoVolume *plastOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsPlast",
6935                                                outputCabsPlast, medPUR);
6936
6937   plastOutputCabs->SetVisibility(kTRUE);
6938   plastOutputCabs->SetLineColor(kRed); // Red
6939   plastOutputCabs->SetLineWidth(1);
6940   plastOutputCabs->SetFillColor(plastOutputCabs->GetLineColor());
6941   plastOutputCabs->SetFillStyle(4000); // 0% transparent
6942
6943   TGeoVolume *alOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsAl",
6944                                             outputCabsAl, medAl);
6945
6946   alOutputCabs->SetVisibility(kTRUE);
6947   alOutputCabs->SetLineColor(6); // Purple
6948   alOutputCabs->SetLineWidth(1);
6949   alOutputCabs->SetFillColor(alOutputCabs->GetLineColor());
6950   alOutputCabs->SetFillStyle(4000); // 0% transparent
6951
6952   TGeoVolume *kaptonOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsKapton",
6953                                                 outputCabsKapton, medKapton);
6954
6955   kaptonOutputCabs->SetVisibility(kTRUE);
6956   kaptonOutputCabs->SetLineColor(14); // 
6957   kaptonOutputCabs->SetLineWidth(1);
6958   kaptonOutputCabs->SetFillColor(kaptonOutputCabs->GetLineColor());
6959   kaptonOutputCabs->SetFillStyle(4000); // 0% transparent
6960
6961   TGeoVolume *polyaxOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsPOLYAX",
6962                                                 outputCabsPOLYAX, medPOLYAX);
6963
6964   polyaxOutputCabs->SetVisibility(kTRUE);
6965   polyaxOutputCabs->SetLineColor(34); // 
6966   polyaxOutputCabs->SetLineWidth(1);
6967   polyaxOutputCabs->SetFillColor(polyaxOutputCabs->GetLineColor());
6968   polyaxOutputCabs->SetFillStyle(4000); // 0% transparent
6969
6970   TGeoVolume *cuPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsCu",
6971                                            pcbBoardsCu, medCu);
6972
6973   cuPCBBoards->SetVisibility(kTRUE);
6974   cuPCBBoards->SetLineColor(kBlack); // Black
6975   cuPCBBoards->SetLineWidth(1);
6976   cuPCBBoards->SetFillColor(cuPCBBoards->GetLineColor());
6977   cuPCBBoards->SetFillStyle(4000); // 0% transparent
6978
6979   TGeoVolume *epoxyPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsEpoxy",
6980                                               pcbBoardsEpoxy, medEpoxy);
6981
6982   epoxyPCBBoards->SetVisibility(kTRUE);
6983   epoxyPCBBoards->SetLineColor(22); //
6984   epoxyPCBBoards->SetLineWidth(1);
6985   epoxyPCBBoards->SetFillColor(epoxyPCBBoards->GetLineColor());
6986   epoxyPCBBoards->SetFillStyle(4000); // 0% transparent
6987
6988   TGeoVolume *plastPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsPlast",
6989                                               pcbBoardsPlast, medPUR);
6990
6991   plastPCBBoards->SetVisibility(kTRUE);
6992   plastPCBBoards->SetLineColor(kRed); // Red
6993   plastPCBBoards->SetLineWidth(1);
6994   plastPCBBoards->SetFillColor(plastPCBBoards->GetLineColor());
6995   plastPCBBoards->SetFillStyle(4000); // 0% transparent
6996
6997   TGeoVolume *steelPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsSteel",
6998                                               pcbBoardsSteel, medSteel);
6999
7000   steelPCBBoards->SetVisibility(kTRUE);
7001   steelPCBBoards->SetLineColor(kBlue); // Blue
7002   steelPCBBoards->SetLineWidth(1);
7003   steelPCBBoards->SetFillColor(steelPCBBoards->GetLineColor());
7004   steelPCBBoards->SetFillStyle(4000); // 0% transparent
7005
7006   TGeoVolume *ppsPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsPPS",
7007                                             pcbBoardsPPS, medPPS);
7008
7009   ppsPCBBoards->SetVisibility(kTRUE);
7010   ppsPCBBoards->SetLineColor(kGreen); // Green
7011   ppsPCBBoards->SetLineWidth(1);
7012   ppsPCBBoards->SetFillColor(ppsPCBBoards->GetLineColor());
7013   ppsPCBBoards->SetFillStyle(4000); // 0% transparent
7014
7015
7016   // Now fill the tray
7017   xloc = coolManifPOM->GetDX();
7018   yloc = 2*kSideCHalfThick + coolManifPOM->GetDY();
7019   trayStructure->AddNode(pomCoolManif, 1,
7020                          new TGeoTranslation( xloc, yloc, 0) );
7021
7022   yloc += coolManifPOM->GetDY() + coolManifSteel->GetDY();
7023   trayStructure->AddNode(steelCoolManif, 1,
7024                          new TGeoTranslation( xloc, yloc, 0) );
7025
7026   yloc += coolManifSteel->GetDY() + coolManifWater->GetDY();
7027   trayStructure->AddNode(waterCoolManif, 1,
7028                          new TGeoTranslation( xloc, yloc, 0) );
7029
7030   yloc += coolManifWater->GetDY() + coolManifAl->GetDY();
7031   trayStructure->AddNode(alCoolManif, 1,
7032                          new TGeoTranslation( xloc, yloc, 0) );
7033
7034   xloc = inputCabsCu->GetDX();
7035   yloc += coolManifWater->GetDY() + inputCabsCu->GetDY()
7036         + kSideCInputCablesTrans;
7037   trayStructure->AddNode(cuInputCabs, 1,
7038                          new TGeoTranslation( xloc, yloc, 0) );
7039
7040   yloc += inputCabsCu->GetDY() + inputCabsPlast->GetDY();
7041   trayStructure->AddNode(plastInputCabs, 1,
7042                          new TGeoTranslation( xloc, yloc, 0) );
7043
7044   yloc += inputCabsPlast->GetDY() + inputCabsAl->GetDY();
7045   trayStructure->AddNode(alInputCabs, 1,
7046                          new TGeoTranslation( xloc, yloc, 0) );
7047
7048   yloc += inputCabsAl->GetDY() + inputCabsKapton->GetDY();
7049   trayStructure->AddNode(kaptonInputCabs, 1,
7050                          new TGeoTranslation( xloc, yloc, 0) );
7051
7052   yloc += inputCabsKapton->GetDY() + inputCabsPOLYAX->GetDY();
7053   trayStructure->AddNode(polyaxInputCabs, 1,
7054                          new TGeoTranslation( xloc, yloc, 0) );
7055
7056   trayStructure->AddNode(purCoolTubes  , 1, 0);
7057   trayStructure->AddNode(waterCoolTubes, 1, 0);
7058   trayStructure->AddNode(airCoolTubes  , 1, 0);
7059
7060   xloc = optConnPBT->GetDX();
7061   yloc = 2*kSideCHalfThick + optConnPBT->GetDY();
7062   zloc = coolManifPOM->GetDZ() + optConnPBT->GetDZ();
7063   trayStructure->AddNode(pbtOptConn, 1,
7064                          new TGeoTranslation( xloc, yloc, zloc) );
7065   trayStructure->AddNode(pbtOptConn, 2,
7066                          new TGeoTranslation( xloc, yloc,-zloc) );
7067
7068   yloc += optConnPBT->GetDY() + optConnSteel->GetDY();
7069   trayStructure->AddNode(steelOptConn, 1,
7070                          new TGeoTranslation( xloc, yloc, zloc) );
7071   trayStructure->AddNode(steelOptConn, 2,
7072                          new TGeoTranslation( xloc, yloc,-zloc) );
7073
7074   yloc += optConnSteel->GetDY() + optConnAl->GetDY();
7075   trayStructure->AddNode(alOptConn, 1,
7076                          new TGeoTranslation( xloc, yloc, zloc) );
7077   trayStructure->AddNode(alOptConn, 2,
7078                          new TGeoTranslation( xloc, yloc,-zloc) );
7079
7080   trayStructure->AddNode(optFibs, 1,
7081                          new TGeoTranslation( 0, 0, zloc) );
7082   trayStructure->AddNode(optFibs, 2,
7083                          new TGeoTranslation( 0, 0,-zloc) );
7084
7085   trayStructure->AddNode(cuOutputCabs    , 1, 0);
7086   trayStructure->AddNode(plastOutputCabs , 1, 0);
7087   trayStructure->AddNode(alOutputCabs    , 1, 0);
7088   trayStructure->AddNode(kaptonOutputCabs, 1, 0);
7089   trayStructure->AddNode(polyaxOutputCabs, 1, 0);
7090
7091   xloc = kXShiftBarCool + kBarCoolRmax + pcbBoardsCu->GetDX();
7092   yloc = outputCabsPOLYAX->GetY(5) + pcbBoardsCu->GetDY();
7093   trayStructure->AddNode(cuPCBBoards, 1,
7094                          new TGeoTranslation( xloc, yloc , 0) );
7095
7096   yloc += pcbBoardsCu->GetDY() + pcbBoardsEpoxy->GetDY();
7097   trayStructure->AddNode(epoxyPCBBoards, 1,
7098                          new TGeoTranslation( xloc, yloc , 0) );
7099
7100   yloc += pcbBoardsEpoxy->GetDY() + pcbBoardsPlast->GetDY();
7101   trayStructure->AddNode(plastPCBBoards, 1,
7102                          new TGeoTranslation( xloc, yloc , 0) );
7103
7104   yloc += pcbBoardsPlast->GetDY() + pcbBoardsSteel->GetDY();
7105   trayStructure->AddNode(steelPCBBoards, 1,
7106                          new TGeoTranslation( xloc, yloc , 0) );
7107
7108   yloc += pcbBoardsSteel->GetDY() + pcbBoardsPPS->GetDY();
7109   trayStructure->AddNode(ppsPCBBoards, 1,
7110                          new TGeoTranslation( xloc, yloc , 0) );
7111
7112
7113   // Finally put everything in the mother volume
7114   alphafold = kSideCFoldAngle;
7115
7116   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
7117     alpharot = kTraySideCAlphaRot[jt];
7118     xloc = kTraySideCRPos*SinD(alpharot);
7119     yloc = kTraySideCRPos*CosD(alpharot);
7120     moth->AddNode(trayStructure,jt+1,
7121                        new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
7122                        new TGeoRotation("",-90.+alpharot,-90.,90.+alphafold)));
7123   }
7124
7125
7126   return;
7127 }
7128
7129
7130 //______________________________________________________________________
7131 void AliITSv11GeometrySupport::SSDCableTraysSideA(TGeoVolume *moth,
7132                                             const TGeoManager *mgr){
7133 //
7134 // Creates the SSD cable trays which are outside the ITS support cones
7135 // but still inside the TPC on Side A
7136 // (part of this code is taken or anyway inspired to ServicesCableSupport
7137 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
7138 //
7139 // Input:
7140 //         moth : the TGeoVolume owing the volume structure
7141 //         mgr  : the GeoManager (default gGeoManager)
7142 // Output:
7143 //
7144 // Created:         ???       Bjorn S. Nilsen
7145 // Updated:      30 Dec 2009  Mario Sitta
7146 //
7147 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
7148 // drawings and other (oral) information given by F.Tosello and
7149 // Ton van den Brink
7150 // Cables and cooling tubes are approximated with proper materials and
7151 // rectangular cross sections, always preserving the total material budget.
7152 //
7153
7154   // Dimensions and positions of the A-Side Cable Trays
7155   // (parts of 0872/G/D)
7156   const Double_t kTrayARTrans            =  408.35 *fgkmm;
7157   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
7158   const Double_t kForwardSideYTrans      =   12.00 *fgkmm;//!!!TO BE CHECKED!!!
7159   const Double_t kCoversYTrans           =    2.00 *fgkmm;
7160   const Double_t kTrayAZRot              = (180-169.5);// Degrees
7161   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
7162   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
7163
7164   const Double_t kTrayTotalHeight        =   52.00 *fgkmm;
7165   const Double_t kTrayHeighToBend        =   32.00 *fgkmm;
7166   const Double_t kTrayWidth              =  130.00 *fgkmm;
7167   const Double_t kTrayThick              =    2.00 *fgkmm;
7168
7169   const Double_t kTrayBendAngle          =   22.00 *TMath::DegToRad();
7170
7171   const Double_t kForwardTrayTotalLen    =  853.00 *fgkmm;
7172   const Double_t kForwardTrayFirstLen    =  350.00 *fgkmm;
7173   const Double_t kForwardTrayFirstHeight =   47.00 *fgkmm;
7174   const Double_t kForwardCoverLen        =  420.00 *fgkmm;
7175
7176   const Double_t kForwardSideLength      = kForwardTrayFirstLen;//!!!TO BE CHECKED!!!
7177   const Double_t kForwardSideHeight      =   90.00 *fgkmm;//!!!TO BE CHECKED!!!
7178   const Double_t kForwardSideThick       =    1.00 *fgkmm;//!!!TO BE CHECKED!!!
7179   const Double_t kForwardCoverHeight     =   10.00 *fgkmm;//!!!TO BE CHECKED!!!
7180
7181   const Double_t kExternalTrayTotalLen   = 1200.00 *fgkmm;
7182   const Double_t kExternalCoverLen       = kExternalTrayTotalLen;
7183   const Double_t kExternalCoverThick     =    5.00 *fgkmm;
7184
7185   const Int_t    kForwardTrayNpoints     =   16;
7186
7187   const Double_t kServicesWidth          =  100.00 *fgkmm;
7188   const Double_t kCopperHeight           =   11.20 *fgkmm;// 1120 mm^2
7189   const Double_t kCablePlasticHeight     =   11.50 *fgkmm;// 1150 mm^2
7190   const Double_t kCoolingWaterHeight     =    2.65 *fgkmm;//  265 mm^2
7191   const Double_t kPoliUrethaneHeight     =    4.62 *fgkmm;//  462 mm^2
7192
7193
7194   // Local variables
7195   Double_t xprof[kForwardTrayNpoints], yprof[kForwardTrayNpoints];
7196   Double_t xloc, yloc, zloc, alpharot, totalhi;
7197
7198
7199   // The two tray components as assemblies
7200   TGeoVolumeAssembly *cableTrayAForw =
7201     new TGeoVolumeAssembly("ITSsupportSSDTrayAForw");
7202   TGeoVolumeAssembly *cableTrayAExt =
7203     new TGeoVolumeAssembly("ITSsupportSSDTrayAExt");
7204   
7205
7206   // First create all needed shapes
7207
7208   // The first part of the forward tray (part of 0872/G/D/07): a Xtru
7209   TGeoXtru *forwTrayPart1 = new TGeoXtru(2);
7210
7211   xprof[3] = kTrayWidth/2;
7212   yprof[3] = kForwardTrayFirstHeight;
7213   xprof[2] = xprof[3] - kTrayThick;
7214   yprof[2] = yprof[3];
7215   xprof[4] = xprof[3];
7216   yprof[4] = kTrayTotalHeight - kTrayHeighToBend;
7217   xprof[5] = xprof[4] - yprof[4]*TMath::Tan(kTrayBendAngle);
7218   yprof[5] = 0;
7219
7220   InsidePoint( xprof[3], yprof[3], xprof[4], yprof[4], xprof[5], yprof[5],
7221               -kTrayThick, xprof[1], yprof[1]);
7222
7223   xprof[6] = -xprof[5];
7224   yprof[6] =  yprof[5];
7225
7226   InsidePoint( xprof[4], yprof[4], xprof[5], yprof[5], xprof[6], yprof[6],
7227               -kTrayThick, xprof[0], yprof[0]);
7228
7229   // We did the right side, now reflex on the left side
7230   for (Int_t jp = 0; jp < 6; jp++) {
7231     xprof[6+jp] = -xprof[5-jp];
7232     yprof[6+jp] =  yprof[5-jp];
7233   }
7234
7235   // And now the actual Xtru
7236   forwTrayPart1->DefinePolygon(12, xprof, yprof);
7237   forwTrayPart1->DefineSection(0, 0);
7238   forwTrayPart1->DefineSection(1, kForwardTrayFirstLen);
7239
7240   // The second part of the forward tray (part of 0872/G/D/07): a Xtru
7241   TGeoXtru *forwTrayPart2 =
7242     CreateSDDSSDTraysSideA(kForwardTrayTotalLen - kForwardTrayFirstLen,
7243                            kTrayTotalHeight);
7244
7245   // The external tray (as 0872/G/D/03): a Xtru with same profile
7246   TGeoXtru *externalTray = CreateSDDSSDTraysSideA(kExternalTrayTotalLen,
7247                                                   kTrayTotalHeight);
7248
7249   // The side wall of the forward tray: a BBox
7250   TGeoBBox *forwSide = new TGeoBBox(kForwardSideThick/2,
7251                                     kForwardSideHeight/2,
7252                                     kForwardSideLength/2);
7253
7254   // The side cover over the walls: a Xtru
7255   TGeoXtru *forwSideCover = new TGeoXtru(2);
7256   forwSideCover->SetName("ITSsuppSSDForwCover");
7257
7258   xprof[0] = kTrayWidth/2 + 2*kForwardSideThick;
7259   yprof[0] = kForwardCoverHeight;
7260   xprof[1] = xprof[0];
7261   yprof[1] = 0;
7262   xprof[2] = xprof[1] - kForwardSideThick;
7263   yprof[2] = yprof[1];
7264   xprof[3] = xprof[2];
7265   yprof[3] = yprof[0] - kForwardSideThick;
7266
7267   // We did the right side, now reflex on the left side
7268   for (Int_t jp = 0; jp < 4; jp++) {
7269     xprof[4+jp] = -xprof[3-jp];
7270     yprof[4+jp] =  yprof[3-jp];
7271   }
7272
7273   forwSideCover->DefinePolygon(8, xprof, yprof);
7274   forwSideCover->DefineSection(0, 0);
7275   forwSideCover->DefineSection(1, kForwardSideLength);
7276
7277   // The forward and external covers: two Composite Shape's
7278   TGeoCompositeShape *forwardCover = CreateTrayAForwardCover(kForwardCoverLen);
7279
7280   TGeoCompositeShape *externCover = CreateTrayAExternalCover(kExternalCoverLen);
7281
7282   // The cable copper inside the forward tray: a BBox
7283   TGeoBBox *forwCopper = new TGeoBBox(kServicesWidth/2,
7284                                       kCopperHeight/2,
7285                                       kForwardTrayTotalLen/2);
7286
7287   // The cable copper inside the forward tray: a Xtru
7288   TGeoXtru *extCopper = new TGeoXtru(2);
7289   extCopper->SetName("ITSsuppSSDExtTrayCopper");
7290
7291   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7292           - kTrayThick;
7293
7294   xprof[0] = -totalhi*TanD(kTrayAZRot);
7295   yprof[0] = kTrayThick;
7296   xprof[1] = kExternalTrayTotalLen;
7297   yprof[1] = yprof[0];
7298   xprof[2] = xprof[1];
7299   yprof[2] = yprof[1] + kCopperHeight;
7300   totalhi -= kCopperHeight;
7301   xprof[3] = -totalhi*TanD(kTrayAZRot);
7302   yprof[3] = yprof[2];
7303
7304   extCopper->DefinePolygon(4, xprof, yprof);
7305   extCopper->DefineSection(0, 0);
7306   extCopper->DefineSection(1, kServicesWidth);
7307
7308   // The cable plastic inside the forward tray: a BBox
7309   TGeoBBox *forwPlastic = new TGeoBBox(kServicesWidth/2,
7310                                        kCablePlasticHeight/2,
7311                                        kForwardTrayTotalLen/2);
7312
7313   // The cable plastic inside the forward tray: a Xtru
7314   TGeoXtru *extPlastic = new TGeoXtru(2);
7315   extPlastic->SetName("ITSsuppSSDExtTrayPlastic");
7316
7317   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7318           - kTrayThick - kCopperHeight;
7319
7320   xprof[0] = -totalhi*TanD(kTrayAZRot);
7321   yprof[0] = kTrayThick;
7322   xprof[1] = kExternalTrayTotalLen;
7323   yprof[1] = yprof[0];
7324   xprof[2] = xprof[1];
7325   yprof[2] = yprof[1] + kCablePlasticHeight;
7326   totalhi -= kCablePlasticHeight;
7327   xprof[3] = -totalhi*TanD(kTrayAZRot);
7328   yprof[3] = yprof[2];
7329
7330   extPlastic->DefinePolygon(4, xprof, yprof);
7331   extPlastic->DefineSection(0, 0);
7332   extPlastic->DefineSection(1, kServicesWidth);
7333
7334   // The cooling water inside the forward tray: a BBox
7335   TGeoBBox *forwWater = new TGeoBBox(kServicesWidth/2,
7336                                      kCoolingWaterHeight/2,
7337                                      kForwardTrayTotalLen/2);
7338
7339   // The cooling water inside the forward tray: a Xtru
7340   TGeoXtru *extWater = new TGeoXtru(2);
7341   extWater->SetName("ITSsuppSSDExtTrayWater");
7342
7343   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7344           - kTrayThick - kCopperHeight - kCablePlasticHeight;
7345
7346   xprof[0] = -totalhi*TanD(kTrayAZRot);
7347   yprof[0] = kTrayThick;
7348   xprof[1] = kExternalTrayTotalLen;
7349   yprof[1] = yprof[0];
7350   xprof[2] = xprof[1];
7351   yprof[2] = yprof[1] + kCoolingWaterHeight;
7352   totalhi -= kCoolingWaterHeight;
7353   xprof[3] = -totalhi*TanD(kTrayAZRot);
7354   yprof[3] = yprof[2];
7355
7356   extWater->DefinePolygon(4, xprof, yprof);
7357   extWater->DefineSection(0, 0);
7358   extWater->DefineSection(1, kServicesWidth);
7359
7360   // The polyurethane inside the forward tray: a BBox
7361   TGeoBBox *forwPUR = new TGeoBBox(kServicesWidth/2,
7362                                    kPoliUrethaneHeight/2,
7363                                    kForwardTrayTotalLen/2);
7364
7365   // The poliurethane inside the forward tray: a Xtru
7366   TGeoXtru *extPUR = new TGeoXtru(2);
7367   extPUR->SetName("ITSsuppSSDExtTrayPUR");
7368
7369   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7370           - kTrayThick - kCopperHeight - kCablePlasticHeight
7371           - kCoolingWaterHeight;
7372
7373   xprof[0] = -totalhi*TanD(kTrayAZRot);
7374   yprof[0] = kTrayThick;
7375   xprof[1] = kExternalTrayTotalLen;
7376   yprof[1] = yprof[0];
7377   xprof[2] = xprof[1];
7378   yprof[2] = yprof[1] + kPoliUrethaneHeight;
7379   totalhi -= kPoliUrethaneHeight;
7380   xprof[3] = -totalhi*TanD(kTrayAZRot);
7381   yprof[3] = yprof[2];
7382
7383   extPUR->DefinePolygon(4, xprof, yprof);
7384   extPUR->DefineSection(0, 0);
7385   extPUR->DefineSection(1, kServicesWidth);
7386
7387
7388   // We have all shapes: now create the real volumes
7389   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
7390   TGeoMedium *medAntic = mgr->GetMedium("ITS_ANTICORODAL$");
7391   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
7392   TGeoMedium *medFEP   = mgr->GetMedium("ITS_SSD FEP$");
7393   TGeoMedium *medH2O   = mgr->GetMedium("ITS_WATER$");
7394   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
7395
7396   TGeoVolume *forwTrayFirst = new TGeoVolume("ITSsuppSSDSideAForwTrayFirst",
7397                                              forwTrayPart1, medAl);
7398
7399   forwTrayFirst->SetVisibility(kTRUE);
7400   forwTrayFirst->SetLineColor(6); // Purple
7401   forwTrayFirst->SetLineWidth(1);
7402   forwTrayFirst->SetFillColor(forwTrayFirst->GetLineColor());
7403   forwTrayFirst->SetFillStyle(4000); // 0% transparent
7404
7405   TGeoVolume *forwTraySecond = new TGeoVolume("ITSsuppSSDSideAForwTraySecond",
7406                                               forwTrayPart2, medAl);
7407
7408   forwTraySecond->SetVisibility(kTRUE);
7409   forwTraySecond->SetLineColor(6); // Purple
7410   forwTraySecond->SetLineWidth(1);
7411   forwTraySecond->SetFillColor(forwTraySecond->GetLineColor());
7412   forwTraySecond->SetFillStyle(4000); // 0% transparent
7413
7414   TGeoVolume *forwTraySide = new TGeoVolume("ITSsuppSSDSideAForwTraySide",
7415                                             forwSide, medAl);
7416
7417   forwTraySide->SetVisibility(kTRUE);
7418   forwTraySide->SetLineColor(6); // Purple
7419   forwTraySide->SetLineWidth(1);
7420   forwTraySide->SetFillColor(forwTraySide->GetLineColor());
7421   forwTraySide->SetFillStyle(4000); // 0% transparent
7422
7423   TGeoVolume *forwTraySideCover = new TGeoVolume("ITSsuppSSDSideAForwTraySideCover",
7424                                             forwSideCover, medAl);
7425
7426   forwTraySideCover->SetVisibility(kTRUE);
7427   forwTraySideCover->SetLineColor(6); // Purple
7428   forwTraySideCover->SetLineWidth(1);
7429   forwTraySideCover->SetFillColor(forwTraySideCover->GetLineColor());
7430   forwTraySideCover->SetFillStyle(4000); // 0% transparent
7431
7432   TGeoVolume *externalTraySSD = new TGeoVolume("ITSsuppSSDSideAExternalTray",
7433                                                externalTray, medAl);
7434
7435   externalTraySSD->SetVisibility(kTRUE);
7436   externalTraySSD->SetLineColor(6); // Purple
7437   externalTraySSD->SetLineWidth(1);
7438   externalTraySSD->SetFillColor(externalTraySSD->GetLineColor());
7439   externalTraySSD->SetFillStyle(4000); // 0% transparent
7440
7441   TGeoVolume *forwardTrayCover = new TGeoVolume("ITSsuppSSDSideAForwTrayCover",
7442                                                 forwardCover, medAntic);
7443
7444   forwardTrayCover->SetVisibility(kTRUE);
7445   forwardTrayCover->SetLineColor(kMagenta+1); // Purple
7446   forwardTrayCover->SetLineWidth(1);
7447   forwardTrayCover->SetFillColor(forwardTrayCover->GetLineColor());
7448   forwardTrayCover->SetFillStyle(4000); // 0% transparent
7449
7450   TGeoVolume *externTrayCover = new TGeoVolume("ITSsuppSSDSideAExtTrayCover",
7451                                                externCover, medAntic);
7452
7453   externTrayCover->SetVisibility(kTRUE);
7454   externTrayCover->SetLineColor(kMagenta+1); // Purple
7455   externTrayCover->SetLineWidth(1);
7456   externTrayCover->SetFillColor(externTrayCover->GetLineColor());
7457   externTrayCover->SetFillStyle(4000); // 0% transparent
7458
7459   TGeoVolume *forwCableCu = new TGeoVolume("ITSsuppSSDSideAForwCableCu",
7460                                            forwCopper, medCu);
7461
7462   forwCableCu->SetVisibility(kTRUE);
7463   forwCableCu->SetLineColor(kRed); // Red
7464   forwCableCu->SetLineWidth(1);
7465   forwCableCu->SetFillColor(forwCableCu->GetLineColor());
7466   forwCableCu->SetFillStyle(4000); // 0% transparent
7467
7468   TGeoVolume *extCableCu = new TGeoVolume("ITSsuppSSDSideAExtCableCu",
7469                                           extCopper, medCu);
7470
7471   extCableCu->SetVisibility(kTRUE);
7472   extCableCu->SetLineColor(kRed); // Red
7473   extCableCu->SetLineWidth(1);
7474   extCableCu->SetFillColor(extCableCu->GetLineColor());
7475   extCableCu->SetFillStyle(4000); // 0% transparent
7476
7477   TGeoVolume *forwCableFEP = new TGeoVolume("ITSsuppSSDSideAForwCableFEP",
7478                                             forwPlastic, medFEP);
7479
7480   forwCableFEP->SetVisibility(kTRUE);
7481   forwCableFEP->SetLineColor(kYellow); // Yellow
7482   forwCableFEP->SetLineWidth(1);
7483   forwCableFEP->SetFillColor(forwCableFEP->GetLineColor());
7484   forwCableFEP->SetFillStyle(4000); // 0% transparent
7485
7486   TGeoVolume *extCableFEP = new TGeoVolume("ITSsuppSSDSideAExtCableFEP",
7487                                            extPlastic, medFEP);
7488
7489   extCableFEP->SetVisibility(kTRUE);
7490   extCableFEP->SetLineColor(kYellow); // Yellow
7491   extCableFEP->SetLineWidth(1);
7492   extCableFEP->SetFillColor(extCableFEP->GetLineColor());
7493   extCableFEP->SetFillStyle(4000); // 0% transparent
7494
7495   TGeoVolume *forwTrayWater = new TGeoVolume("ITSsuppSSDSideAForwTrayWater",
7496                                              forwWater, medH2O);
7497
7498   forwTrayWater->SetVisibility(kTRUE);
7499   forwTrayWater->SetLineColor(kBlue); // Blue
7500   forwTrayWater->SetLineWidth(1);
7501   forwTrayWater->SetFillColor(forwTrayWater->GetLineColor());
7502   forwTrayWater->SetFillStyle(4000); // 0% transparent
7503
7504   TGeoVolume *extTrayWater = new TGeoVolume("ITSsuppSSDSideAExtTrayWater",
7505                                             extWater, medH2O);
7506
7507   extTrayWater->SetVisibility(kTRUE);
7508   extTrayWater->SetLineColor(kBlue); // Blue
7509   extTrayWater->SetLineWidth(1);
7510   extTrayWater->SetFillColor(extTrayWater->GetLineColor());
7511   extTrayWater->SetFillStyle(4000); // 0% transparent
7512
7513   TGeoVolume *forwPolyUr = new TGeoVolume("ITSsuppSSDSideAForwPolyUr",
7514                                           forwPUR, medPUR);
7515
7516   forwPolyUr->SetVisibility(kTRUE);
7517   forwPolyUr->SetLineColor(kGray); // Gray
7518   forwPolyUr->SetLineWidth(1);
7519   forwPolyUr->SetFillColor(forwPolyUr->GetLineColor());
7520   forwPolyUr->SetFillStyle(4000); // 0% transparent
7521
7522   TGeoVolume *extPolyUr = new TGeoVolume("ITSsuppSSDSideAExtPolyUr",
7523                                          extPUR, medPUR);
7524
7525   extPolyUr->SetVisibility(kTRUE);
7526   extPolyUr->SetLineColor(kGray); // Gray
7527   extPolyUr->SetLineWidth(1);
7528   extPolyUr->SetFillColor(extPolyUr->GetLineColor());
7529   extPolyUr->SetFillStyle(4000); // 0% transparent
7530
7531
7532   // Now build up the tray
7533   cableTrayAForw->AddNode(forwTrayFirst, 1, 0);
7534
7535   cableTrayAForw->AddNode(forwTraySecond, 1,
7536                         new TGeoTranslation(0, 0, kForwardTrayFirstLen) );
7537
7538   xloc = kTrayWidth/2 + kForwardSideThick/2;
7539   yloc = kForwardTrayFirstHeight + kForwardSideHeight/2 - kForwardSideYTrans;
7540   zloc = kForwardSideLength/2;
7541   cableTrayAForw->AddNode(forwTraySide,1,
7542                         new TGeoTranslation( xloc, yloc, zloc) );
7543   cableTrayAForw->AddNode(forwTraySide,2,
7544                         new TGeoTranslation(-xloc, yloc, zloc) );
7545
7546   yloc = kForwardTrayFirstHeight + kForwardSideHeight - kForwardSideYTrans
7547        - kForwardCoverHeight;
7548   cableTrayAForw->AddNode(forwTraySideCover,1,
7549                         new TGeoTranslation(0, yloc, 0) );
7550
7551   yloc = kTrayTotalHeight - kCoversYTrans;
7552   zloc = kForwardTrayTotalLen - kForwardCoverLen;
7553   cableTrayAForw->AddNode(forwardTrayCover,1,
7554                         new TGeoTranslation(0, yloc, zloc) );
7555
7556   yloc = kTrayThick + forwCopper->GetDY();
7557   zloc = forwCopper->GetDZ();
7558   cableTrayAForw->AddNode(forwCableCu, 1,
7559                         new TGeoTranslation(0, yloc, zloc) );
7560
7561   yloc = kTrayThick + kCopperHeight + forwPlastic->GetDY();
7562   zloc = forwPlastic->GetDZ();
7563   cableTrayAForw->AddNode(forwCableFEP, 1,
7564                         new TGeoTranslation(0, yloc, zloc) );
7565
7566   yloc = kTrayThick + kCopperHeight + kCablePlasticHeight + forwWater->GetDY();
7567   zloc = forwWater->GetDZ();
7568   cableTrayAForw->AddNode(forwTrayWater, 1,
7569                         new TGeoTranslation(0, yloc, zloc) );
7570
7571   yloc = kTrayThick + kCopperHeight + kCablePlasticHeight
7572        + kCoolingWaterHeight + forwPUR->GetDY();
7573   zloc = forwPUR->GetDZ();
7574   cableTrayAForw->AddNode(forwPolyUr, 1,
7575                         new TGeoTranslation(0, yloc, zloc) );
7576
7577   // To simplify following placement in MARS, origin is on top
7578   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans;
7579
7580   yloc = -totalhi;
7581   cableTrayAExt->AddNode(externalTraySSD, 1,
7582                         new TGeoTranslation(0, yloc, 0) );
7583
7584   yloc = -totalhi + kTrayTotalHeight - kCoversYTrans;
7585   cableTrayAExt->AddNode(externTrayCover,1,
7586                         new TGeoTranslation(0, yloc, 0) );
7587
7588   xloc = extCopper->GetDZ();
7589   yloc = -totalhi;
7590   cableTrayAExt->AddNode(extCableCu,1,
7591                         new TGeoCombiTrans( xloc, yloc, 0,
7592                         new TGeoRotation("",-90, 90, 90)        ) );
7593
7594   xloc = extPlastic->GetDZ();
7595   yloc = -totalhi + kCopperHeight;
7596   cableTrayAExt->AddNode(extCableFEP,1,
7597                         new TGeoCombiTrans( xloc, yloc, 0,
7598                         new TGeoRotation("",-90, 90, 90)        ) );
7599
7600   xloc = extWater->GetDZ();
7601   yloc = -totalhi + kCopperHeight + kCablePlasticHeight;
7602   cableTrayAExt->AddNode(extTrayWater,1,
7603                         new TGeoCombiTrans( xloc, yloc, 0,
7604                         new TGeoRotation("",-90, 90, 90)        ) );
7605
7606   xloc = extPUR->GetDZ();
7607   yloc = -totalhi + kCopperHeight + kCablePlasticHeight + kCoolingWaterHeight;
7608   cableTrayAExt->AddNode(extPolyUr,1,
7609                         new TGeoCombiTrans( xloc, yloc, 0,
7610                         new TGeoRotation("",-90, 90, 90)        ) );
7611
7612
7613   // Finally put everything in the mother volume
7614   zloc = kTrayAZTrans;
7615   Double_t zlocext = zloc + kForwardTrayTotalLen;
7616   Double_t rExtTray = kTrayARTrans + kTrayTotalHeight;
7617
7618   alpharot = kTrayAFirstRotAng;
7619   xloc = kTrayARTrans*SinD(alpharot);
7620   yloc = kTrayARTrans*CosD(alpharot);
7621   moth->AddNode(cableTrayAForw,1,
7622                             new TGeoCombiTrans( xloc, yloc, zloc,
7623                             new TGeoRotation("",-alpharot,0,0)   )   );
7624   xloc = rExtTray*SinD(alpharot);
7625   yloc = rExtTray*CosD(alpharot);
7626   moth->AddNode(cableTrayAExt,1,
7627                             new TGeoCombiTrans( xloc, yloc, zlocext,
7628                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7629
7630   alpharot += 180;
7631   xloc = kTrayARTrans*SinD(alpharot);
7632   yloc = kTrayARTrans*CosD(alpharot);
7633   moth->AddNode(cableTrayAForw,2,
7634                             new TGeoCombiTrans( xloc, yloc, zloc,
7635                             new TGeoRotation("",-alpharot,0,0)   )   );
7636   xloc = rExtTray*SinD(alpharot);
7637   yloc = rExtTray*CosD(alpharot);
7638   moth->AddNode(cableTrayAExt,2,
7639                             new TGeoCombiTrans( xloc, yloc, zlocext,
7640                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7641
7642   alpharot = -kTrayAFirstRotAng - 2*kTrayASecondRotAng;
7643   xloc = kTrayARTrans*SinD(alpharot);
7644   yloc = kTrayARTrans*CosD(alpharot);
7645   moth->AddNode(cableTrayAForw,3,
7646                             new TGeoCombiTrans( xloc, yloc, zloc,
7647                             new TGeoRotation("",-alpharot,0,0)   )   );
7648   xloc = rExtTray*SinD(alpharot);
7649   yloc = rExtTray*CosD(alpharot);
7650   moth->AddNode(cableTrayAExt,3,
7651                             new TGeoCombiTrans( xloc, yloc, zlocext,
7652                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7653
7654   alpharot += 180;
7655   xloc = kTrayARTrans*SinD(alpharot);
7656   yloc = kTrayARTrans*CosD(alpharot);
7657   moth->AddNode(cableTrayAForw,4,
7658                             new TGeoCombiTrans( xloc, yloc, zloc,
7659                             new TGeoRotation("",-alpharot,0,0)   )   );
7660   xloc = rExtTray*SinD(alpharot);
7661   yloc = rExtTray*CosD(alpharot);
7662   moth->AddNode(cableTrayAExt,4,
7663                             new TGeoCombiTrans( xloc, yloc, zlocext,
7664                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7665
7666
7667   return;
7668 }
7669
7670 //______________________________________________________________________
7671 void AliITSv11GeometrySupport::SSDCableTraysSideC(TGeoVolume *moth,
7672                                             const TGeoManager *mgr){
7673 //
7674 // Creates the SSD cable trays which are outside the ITS support cones
7675 // but still inside the TPC on Side C
7676 // (part of this code is taken or anyway inspired to ServicesCableSupport
7677 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
7678 //
7679 // Input:
7680 //         moth : the TGeoVolume owing the volume structure
7681 //         mgr  : the GeoManager (default gGeoManager)
7682 // Output:
7683 //
7684 // Created:         ???       Bjorn S. Nilsen
7685 // Updated:      15 Apr 2010  Mario Sitta
7686 //
7687 // Technical data are taken from AutoCAD drawings and other (oral)
7688 // information given by F.Tosello
7689 //
7690
7691   // Dimensions and positions of the C-Side Cable Tray elements
7692   const Int_t    kNumTraySideC           =    4;
7693
7694   const Double_t kSideCFoldAngle         =    5.00 *fgkDegree;
7695
7696   const Double_t kServicesWidth          =  100.00 *fgkmm;
7697   const Double_t kCopperHeight           =   11.20 *fgkmm;// 1120 mm^2
7698   const Double_t kCablePlasticHeight     =   11.50 *fgkmm;// 1150 mm^2
7699   const Double_t kCoolingWaterHeight     =    2.65 *fgkmm;//  265 mm^2
7700   const Double_t kPoliUrethaneHeight     =    4.62 *fgkmm;//  462 mm^2
7701   const Double_t kCablesYtrans           =    2.50 *fgkmm;// Avoid ovlps
7702
7703   // Overall position and rotation of the C-Side Cable Trays
7704   const Double_t kTraySideCRPos          =   45.30    *fgkcm;
7705   const Double_t kTraySideCZPos          = -102.40    *fgkcm;
7706   const Double_t kTraySideCAlphaRot[kNumTraySideC]  = {     23.0,     -59.0,
7707     /* from Patch panel position */                    180.+23.0, 180.-59.0};
7708
7709
7710   // Local variables
7711   Double_t xprof[6], yprof[6];
7712   Double_t xloc, yloc, alpharot, alphafold;
7713
7714
7715   // The assembly holding the metallic structure
7716   TGeoVolumeAssembly *trayStructure =
7717                                 CreateSDDSSDTraysSideC("ITSsupportSSDTrayC");
7718
7719   // The cable copper inside the tray: a Xtru
7720   TGeoXtru *copper = new TGeoXtru(2);
7721   copper->SetName("ITSsuppSSDTrayCCopper");
7722
7723   // Copper lies on the lower plate: get position of its points
7724   TGeoXtru *lowerplate = (TGeoXtru*)(mgr->GetVolume("ITSsuppTraySideCLower")->GetShape());
7725   xprof[0] = lowerplate->GetX(5);
7726   yprof[0] = lowerplate->GetY(5) + kCablesYtrans;
7727   xprof[1] = lowerplate->GetX(4);
7728   yprof[1] = lowerplate->GetY(4) + kCablesYtrans;
7729   xprof[2] = lowerplate->GetX(3);
7730   yprof[2] = lowerplate->GetY(3) + kCablesYtrans;
7731   xprof[3] = xprof[2] - kCopperHeight*SinD(kSideCFoldAngle);
7732   yprof[3] = yprof[2] + kCopperHeight*CosD(kSideCFoldAngle);
7733   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7734               kCopperHeight , xprof[4], yprof[4]);
7735   xprof[5] = xprof[0];
7736   yprof[5] = yprof[0] + kCopperHeight;
7737
7738   copper->DefinePolygon(6, xprof, yprof);
7739   copper->DefineSection(0, -kServicesWidth/2);
7740   copper->DefineSection(1,  kServicesWidth/2);
7741
7742   // The cable plastic inside the tray: a Xtru
7743   TGeoXtru *plastic = new TGeoXtru(2);
7744   plastic->SetName("ITSsuppSSDTrayCPlastic");
7745
7746   xprof[0] = copper->GetX(5);
7747   yprof[0] = copper->GetY(5);
7748   xprof[1] = copper->GetX(4);
7749   yprof[1] = copper->GetY(4);
7750   xprof[2] = copper->GetX(3);
7751   yprof[2] = copper->GetY(3);
7752   xprof[3] = xprof[2] - kCablePlasticHeight*SinD(kSideCFoldAngle);
7753   yprof[3] = yprof[2] + kCablePlasticHeight*CosD(kSideCFoldAngle);
7754   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7755               kCablePlasticHeight , xprof[4], yprof[4]);
7756   xprof[5] = xprof[0];
7757   yprof[5] = yprof[0] + kCablePlasticHeight;
7758
7759   plastic->DefinePolygon(6, xprof, yprof);
7760   plastic->DefineSection(0, -kServicesWidth/2);
7761   plastic->DefineSection(1,  kServicesWidth/2);
7762
7763   // The cooling water inside the tray: a Xtru
7764   TGeoXtru *water = new TGeoXtru(2);
7765   water->SetName("ITSsuppSSDTrayCWater");
7766
7767   xprof[0] = plastic->GetX(5);
7768   yprof[0] = plastic->GetY(5);
7769   xprof[1] = plastic->GetX(4);
7770   yprof[1] = plastic->GetY(4);
7771   xprof[2] = plastic->GetX(3);
7772   yprof[2] = plastic->GetY(3);
7773   xprof[3] = xprof[2] - kCoolingWaterHeight*SinD(kSideCFoldAngle);
7774   yprof[3] = yprof[2] + kCoolingWaterHeight*CosD(kSideCFoldAngle);
7775   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7776               kCoolingWaterHeight , xprof[4], yprof[4]);
7777   xprof[5] = xprof[0];
7778   yprof[5] = yprof[0] + kCoolingWaterHeight;
7779
7780   water->DefinePolygon(6, xprof, yprof);
7781   water->DefineSection(0, -kServicesWidth/2);
7782   water->DefineSection(1,  kServicesWidth/2);
7783
7784   // The poliurethane inside the tray: a Xtru
7785   TGeoXtru *pur = new TGeoXtru(2);
7786   pur->SetName("ITSsuppSSDTrayCPUR");
7787   xprof[0] = water->GetX(5);
7788   yprof[0] = water->GetY(5);
7789   xprof[1] = water->GetX(4);
7790   yprof[1] = water->GetY(4);
7791   xprof[2] = water->GetX(3);
7792   yprof[2] = water->GetY(3);
7793   xprof[3] = xprof[2] - kPoliUrethaneHeight*SinD(kSideCFoldAngle);
7794   yprof[3] = yprof[2] + kPoliUrethaneHeight*CosD(kSideCFoldAngle);
7795   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7796               kPoliUrethaneHeight , xprof[4], yprof[4]);
7797   xprof[5] = xprof[0];
7798   yprof[5] = yprof[0] + kPoliUrethaneHeight;
7799
7800   pur->DefinePolygon(6, xprof, yprof);
7801   pur->DefineSection(0, -kServicesWidth/2);
7802   pur->DefineSection(1,  kServicesWidth/2);
7803
7804
7805   // We have all shapes: now create the real volumes
7806   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
7807   TGeoMedium *medFEP   = mgr->GetMedium("ITS_SSD FEP$");
7808   TGeoMedium *medH2O   = mgr->GetMedium("ITS_WATER$");
7809   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
7810
7811   TGeoVolume *copperCable = new TGeoVolume("ITSsuppSSDSideCCableCu",
7812                                            copper, medCu);
7813
7814   copperCable->SetVisibility(kTRUE);
7815   copperCable->SetLineColor(kRed); // Red
7816   copperCable->SetLineWidth(1);
7817   copperCable->SetFillColor(copperCable->GetLineColor());
7818   copperCable->SetFillStyle(4000); // 0% transparent
7819
7820   TGeoVolume *cableFEP = new TGeoVolume("ITSsuppSSDSideCCableFEP",
7821                                         plastic, medFEP);
7822
7823   cableFEP->SetVisibility(kTRUE);
7824   cableFEP->SetLineColor(kYellow); // Yellow
7825   cableFEP->SetLineWidth(1);
7826   cableFEP->SetFillColor(cableFEP->GetLineColor());
7827   cableFEP->SetFillStyle(4000); // 0% transparent
7828
7829   TGeoVolume *trayWater = new TGeoVolume("ITSsuppSSDSideCTrayWater",
7830                                          water, medH2O);
7831
7832   trayWater->SetVisibility(kTRUE);
7833   trayWater->SetLineColor(kBlue); // Blue
7834   trayWater->SetLineWidth(1);
7835   trayWater->SetFillColor(trayWater->GetLineColor());
7836   trayWater->SetFillStyle(4000); // 0% transparent
7837
7838   TGeoVolume *trayPolyUr = new TGeoVolume("ITSsuppSSDSideCPolyUr",
7839                                           pur, medPUR);
7840
7841   trayPolyUr->SetVisibility(kTRUE);
7842   trayPolyUr->SetLineColor(kGray); // Gray
7843   trayPolyUr->SetLineWidth(1);
7844   trayPolyUr->SetFillColor(trayPolyUr->GetLineColor());
7845   trayPolyUr->SetFillStyle(4000); // 0% transparent
7846
7847
7848   // Now fill in the tray
7849   trayStructure->AddNode(copperCable,1,0);
7850   trayStructure->AddNode(cableFEP,1,0);
7851   trayStructure->AddNode(trayWater,1,0);
7852   trayStructure->AddNode(trayPolyUr,1,0);
7853
7854
7855   // Finally put everything in the mother volume
7856   alphafold = kSideCFoldAngle;
7857
7858   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
7859     alpharot = kTraySideCAlphaRot[jt];
7860     xloc = kTraySideCRPos*SinD(alpharot);
7861     yloc = kTraySideCRPos*CosD(alpharot);
7862     moth->AddNode(trayStructure,jt+1,
7863                        new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
7864                        new TGeoRotation("",-90.+alpharot,-90.,90.+alphafold)));
7865   }
7866
7867
7868   return;
7869 }
7870
7871 //______________________________________________________________________
7872 void AliITSv11GeometrySupport::CreateSDDForwardTraySideA(TGeoVolumeAssembly *tray,
7873                                                    const TGeoManager *mgr){
7874 //
7875 // Creates the forward SDD tray on Side A (0872/G/D/01)
7876 //
7877 // Input:
7878 //         tray : the TGeoVolumeAssembly to put the elements in
7879 //         mgr  : the GeoManager (used only to get the proper material)
7880 //
7881 // Output:
7882 //
7883 // Return:
7884 //
7885 // Created:      08 Jan 2010  Mario Sitta
7886 // Updated:      07 Sep 2010  Mario Sitta
7887 //
7888 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
7889 // drawings and other (oral) information given by F.Tosello
7890 //
7891
7892   // Dimensions of the A-Side Forward Cable Tray (0872/G/D/01)
7893   const Double_t kForwardTrayThick        =    2.00 *fgkmm;
7894   const Double_t kForwardTraySideLength   =  823.00 *fgkmm;
7895   const Double_t kForwardTrayTailLength   =  212.00 *fgkmm;
7896   const Double_t kForwardTrayBaseHalfWide =   55.00 *fgkmm;
7897   const Double_t kForwardTrayNotchLength  =   47.20 *fgkmm;
7898   const Double_t kForwardTrayNotchHeight  =   25.00 *fgkmm;
7899   const Double_t kForwardTrayNotchDown    =   10.00 *fgkmm;
7900   const Double_t kForwardTraySide1Height  =   39.00 *fgkmm;
7901   const Double_t kForwardTraySide2Height  =   26.00 *fgkmm;
7902   const Double_t kForwardTraySide2Expand  =   10.50 *fgkmm;
7903   const Double_t kForwardTraySide3TailLen =  418.00 *fgkmm;
7904   const Double_t kForwardTraySide3TailHi  =   31.00 *fgkmm;
7905   const Double_t kForwardTraySide3HeadLen =  425.00 *fgkmm;
7906   const Double_t kForwardTraySide3HeadHi  =   72.00 *fgkmm;
7907   const Double_t kForwardTrayHorWingWide  =   10.50 *fgkmm;
7908   const Double_t kForwardTrayVertWingWide =   15.00 *fgkmm;
7909
7910   const Int_t    kForwardTraySideNpoints  =    9;
7911
7912
7913   // Local variables
7914   Double_t xprof[kForwardTraySideNpoints], yprof[kForwardTraySideNpoints];
7915   Double_t ylen, zlen;
7916   Double_t xloc, yloc, zloc;
7917
7918
7919   // The tray has a very complex shape, so it is made by assembling
7920   // different elements (with some small simplifications)
7921
7922   // The tray base: a BBox
7923   zlen = (kForwardTraySideLength-kForwardTrayTailLength)/2;
7924   TGeoBBox *trayBase = new TGeoBBox(kForwardTrayBaseHalfWide,
7925                                     kForwardTrayThick/2, zlen);
7926
7927   // The first part of the side wall: a Xtru
7928   TGeoXtru *traySide1 = new TGeoXtru(2);
7929
7930   xprof[0] = 0;
7931   yprof[0] = kForwardTrayThick;
7932   xprof[1] = kForwardTraySideLength-kForwardTrayTailLength;
7933   yprof[1] = yprof[0];
7934   xprof[2] = kForwardTraySideLength;
7935   yprof[2] = kForwardTraySide1Height + kForwardTrayThick;
7936   xprof[3] = 0;
7937   yprof[3] = yprof[2];
7938
7939   traySide1->DefinePolygon(4, xprof, yprof);
7940   traySide1->DefineSection(0, 0);
7941   traySide1->DefineSection(1, kForwardTrayThick);
7942
7943   // The second part of the side wall: a Xtru
7944   TGeoXtru *traySide2 = new TGeoXtru(2);
7945
7946   xprof[0] = kForwardTrayBaseHalfWide - kForwardTrayThick;
7947   yprof[0] = traySide1->GetY(2);
7948   xprof[1] = kForwardTrayBaseHalfWide;
7949   yprof[1] = yprof[0];
7950   xprof[2] = xprof[1] + kForwardTraySide2Expand;
7951   yprof[2] = yprof[1] + kForwardTraySide2Height;
7952   xprof[3] = xprof[2] - kForwardTrayThick;
7953   yprof[3] = yprof[2];
7954
7955   traySide2->DefinePolygon(4, xprof, yprof);
7956   traySide2->DefineSection(0, 0);
7957   traySide2->DefineSection(1, kForwardTraySideLength);
7958
7959   // The third part of the side wall: a Xtru
7960   TGeoXtru *traySide3 = new TGeoXtru(2);
7961
7962   xprof[0] = 0;
7963   yprof[0] = traySide2->GetY(2);
7964   xprof[1] = kForwardTraySideLength;
7965   yprof[1] = yprof[0];
7966   xprof[2] = xprof[1];
7967   yprof[2] = yprof[1] + kForwardTraySide3TailHi - kForwardTrayThick;
7968   xprof[3] = xprof[2] - kForwardTraySide3TailLen - kForwardTrayThick;
7969   yprof[3] = yprof[2];
7970   xprof[4] = xprof[3];
7971   yprof[4] = yprof[3] + kForwardTraySide3HeadHi + kForwardTrayThick;
7972   xprof[5] = xprof[4] - kForwardTraySide3HeadLen;
7973   yprof[5] = yprof[4];
7974   xprof[6] = xprof[5];
7975   yprof[6] = yprof[5] - kForwardTrayNotchHeight;
7976   xprof[7] = xprof[6] + kForwardTrayNotchLength;
7977   yprof[7] = yprof[6];
7978   xprof[8] = xprof[7];
7979   yprof[8] = yprof[7] - kForwardTrayNotchDown;
7980
7981   traySide3->DefinePolygon(9, xprof, yprof);
7982   traySide3->DefineSection(0, 0);
7983   traySide3->DefineSection(1, kForwardTrayThick);
7984
7985   // The horizontal wing: a BBox
7986   TGeoBBox *trayHorWing = new TGeoBBox(kForwardTrayHorWingWide/2,
7987                                        kForwardTrayThick/2,
7988                                        kForwardTraySide3TailLen/2);
7989
7990   // The vertical wing: a BBox
7991   ylen = (traySide3->GetY(4) - traySide3->GetY(3))/2;
7992   TGeoBBox *trayVertWing = new TGeoBBox(kForwardTrayVertWingWide/2,
7993                                         ylen, kForwardTrayThick/2);
7994
7995
7996   // We have all shapes: now create the real volumes
7997   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
7998
7999   TGeoVolume *forwTrayBase = new TGeoVolume("ITSsuppSDDSideAForwTrayBase",
8000                                             trayBase, medAl);
8001
8002   forwTrayBase->SetVisibility(kTRUE);
8003   forwTrayBase->SetLineColor(6); // Purple
8004   forwTrayBase->SetLineWidth(1);
8005   forwTrayBase->SetFillColor(forwTrayBase->GetLineColor());
8006   forwTrayBase->SetFillStyle(4000); // 0% transparent
8007
8008   TGeoVolume *forwTraySide1 = new TGeoVolume("ITSsuppSDDSideAForwTraySide1",
8009                                             traySide1, medAl);
8010
8011   forwTraySide1->SetVisibility(kTRUE);
8012   forwTraySide1->SetLineColor(6); // Purple
8013   forwTraySide1->SetLineWidth(1);
8014   forwTraySide1->SetFillColor(forwTraySide1->GetLineColor());
8015   forwTraySide1->SetFillStyle(4000); // 0% transparent
8016
8017   TGeoVolume *forwTraySide2 = new TGeoVolume("ITSsuppSDDSideAForwTraySide2",
8018                                             traySide2, medAl);
8019
8020   forwTraySide2->SetVisibility(kTRUE);
8021   forwTraySide2->SetLineColor(6); // Purple
8022   forwTraySide2->SetLineWidth(1);
8023   forwTraySide2->SetFillColor(forwTraySide2->GetLineColor());
8024   forwTraySide2->SetFillStyle(4000); // 0% transparent
8025
8026   TGeoVolume *forwTraySide3 = new TGeoVolume("ITSsuppSDDSideAForwTraySide3",
8027                                             traySide3, medAl);
8028
8029   forwTraySide3->SetVisibility(kTRUE);
8030   forwTraySide3->SetLineColor(6); // Purple
8031   forwTraySide3->SetLineWidth(1);
8032   forwTraySide3->SetFillColor(forwTraySide3->GetLineColor());
8033   forwTraySide3->SetFillStyle(4000); // 0% transparent
8034
8035   TGeoVolume *forwTrayHWing = new TGeoVolume("ITSsuppSDDSideAForwTrayHorWing",
8036                                             trayHorWing, medAl);
8037
8038   forwTrayHWing->SetVisibility(kTRUE);
8039   forwTrayHWing->SetLineColor(6); // Purple
8040   forwTrayHWing->SetLineWidth(1);
8041   forwTrayHWing->SetFillColor(forwTrayHWing->GetLineColor());
8042   forwTrayHWing->SetFillStyle(4000); // 0% transparent
8043
8044   TGeoVolume *forwTrayVWing = new TGeoVolume("ITSsuppSDDSideAForwTrayVertWing",
8045                                             trayVertWing, medAl);
8046
8047   forwTrayVWing->SetVisibility(kTRUE);
8048   forwTrayVWing->SetLineColor(6); // Purple
8049   forwTrayVWing->SetLineWidth(1);
8050   forwTrayVWing->SetFillColor(forwTrayVWing->GetLineColor());
8051   forwTrayVWing->SetFillStyle(4000); // 0% transparent
8052
8053
8054   // Now build up the tray
8055   yloc = kForwardTrayThick/2;
8056   zloc = zlen;
8057   tray->AddNode(forwTrayBase, 1,
8058                 new TGeoTranslation(0, yloc, zloc) );
8059
8060   xloc = kForwardTrayBaseHalfWide;
8061   tray->AddNode(forwTraySide1, 1,
8062                 new TGeoCombiTrans(xloc, 0, 0,
8063                                    new TGeoRotation("",90,-90,-90)));
8064   xloc = -xloc + kForwardTrayThick;
8065   tray->AddNode(forwTraySide1, 2,
8066                 new TGeoCombiTrans(xloc, 0, 0,
8067                                    new TGeoRotation("",90,-90,-90)));
8068
8069   tray->AddNode(forwTraySide2, 1, 0);
8070   zloc = kForwardTraySideLength;
8071   tray->AddNode(forwTraySide2, 2,
8072                 new TGeoCombiTrans(0, 0, zloc,
8073                                    new TGeoRotation("",90,-180,-90)));
8074
8075   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand;
8076   tray->AddNode(forwTraySide3, 1,
8077                 new TGeoCombiTrans(xloc, 0, 0,
8078                                    new TGeoRotation("",90,-90,-90)));
8079   xloc = -xloc + kForwardTrayThick;
8080   tray->AddNode(forwTraySide3, 2,
8081                 new TGeoCombiTrans(xloc, 0, 0,
8082                                    new TGeoRotation("",90,-90,-90)));
8083
8084   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand
8085        - kForwardTrayHorWingWide/2;
8086   yloc = traySide3->GetY(2) + kForwardTrayThick/2;
8087   zloc = kForwardTraySideLength - trayHorWing->GetDZ();
8088   tray->AddNode(forwTrayHWing, 1,
8089                 new TGeoTranslation( xloc, yloc, zloc) );
8090   tray->AddNode(forwTrayHWing, 2,
8091                 new TGeoTranslation(-xloc, yloc, zloc) );
8092
8093   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand
8094        - kForwardTrayVertWingWide/2;
8095   yloc = traySide3->GetY(2) + trayVertWing->GetDY();
8096   zloc = traySide3->GetX(3) + kForwardTrayThick/2;
8097   tray->AddNode(forwTrayVWing, 1,
8098                 new TGeoTranslation( xloc, yloc, zloc) );
8099   tray->AddNode(forwTrayVWing, 2,
8100                 new TGeoTranslation(-xloc, yloc, zloc) );
8101
8102
8103   return;
8104 }
8105
8106 //______________________________________________________________________
8107 TGeoCompositeShape* AliITSv11GeometrySupport::CreateTrayAForwardCover(const Double_t coverLen){
8108 //
8109 // Creates the forward cover of the SDD and SSD cable trays on Side A
8110 // (0872/G/D/02)
8111 //
8112 // Input:
8113 //             coverLen: the total length of the cover
8114 //
8115 // Output:
8116 //
8117 // Return:     a TGeoCompositeShape for the cover
8118 //
8119 // Created:      03 Jan 2010  Mario Sitta
8120 //
8121 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8122 // drawings and other (oral) information given by F.Tosello
8123 //
8124
8125   // Dimensions and positions of the A-Side Cable Tray Forward Cover
8126   // (0872/G/D/02)
8127   const Double_t kForwardCoverWide        =  130.00 *fgkmm;
8128   const Double_t kForwardCoverSideWide    =   10.00 *fgkmm;
8129   const Double_t kForwardCoverHoleLen     =  160.00 *fgkmm;
8130   const Double_t kForwardCoverHoleWide    =   90.00 *fgkmm;
8131   const Double_t kForwardCoverHoleR10     =   10.00 *fgkmm;
8132   const Double_t kForwardCoverTotalThick  =    5.00 *fgkmm;
8133   const Double_t kForwardCoverSideThick   =    3.00 *fgkmm;
8134   const Double_t kForwardCoverInternThick =    2.00 *fgkmm;
8135
8136   const Double_t kForwardCoverHoleZTrans  =   40.00 *fgkmm;
8137
8138
8139   // Local variables
8140   Double_t xprof[16], yprof[16];
8141   Double_t yloc, zloc;
8142
8143
8144   // The main shape: a Xtru
8145   TGeoXtru *forwCoverMain = new TGeoXtru(2);
8146   forwCoverMain->SetName("ITSsuppForwCoverMain");
8147
8148   xprof[0] = kForwardCoverWide/2;
8149   yprof[0] = kForwardCoverTotalThick;
8150   xprof[1] = xprof[0];
8151   yprof[1] = yprof[0] - kForwardCoverSideThick;
8152   xprof[2] = xprof[1] - kForwardCoverSideWide;
8153   yprof[2] = yprof[1];
8154   xprof[3] = xprof[2];
8155   yprof[3] = 0;
8156
8157   // We did the right side, now reflex on the left side
8158   for (Int_t jp = 0; jp < 4; jp++) {
8159     xprof[4+jp] = -xprof[3-jp];
8160     yprof[4+jp] =  yprof[3-jp];
8161   }
8162
8163   // And now the actual Xtru
8164   forwCoverMain->DefinePolygon(8, xprof, yprof);
8165   forwCoverMain->DefineSection(0, 0);
8166   forwCoverMain->DefineSection(1, coverLen);
8167
8168   // The hole: another Xtru (rounded corners approximated with segments)
8169   TGeoXtru *forwCoverHole = new TGeoXtru(2);
8170   forwCoverHole->SetName("ITSsuppForwCoverHole");
8171
8172   CreateTrayACoverHolesShape(kForwardCoverHoleWide, kForwardCoverHoleLen,
8173                              kForwardCoverHoleR10 , xprof, yprof);
8174
8175   // And now the actual Xtru
8176   forwCoverHole->DefinePolygon(16, xprof, yprof);
8177   forwCoverHole->DefineSection(0, 0);
8178   forwCoverHole->DefineSection(1, kForwardCoverTotalThick-kForwardCoverInternThick);
8179
8180   // Now the proper rototranslation matrices for the two holes
8181   yloc = kForwardCoverTotalThick-kForwardCoverInternThick-0.01;//Precision fix
8182   zloc = kForwardCoverHoleZTrans;
8183   TGeoCombiTrans *mf1 = new TGeoCombiTrans(0, yloc, zloc,
8184                                            new TGeoRotation("", 0, 90, 0) );
8185   mf1->SetName("mf1");
8186   mf1->RegisterYourself();
8187
8188   zloc = coverLen - kForwardCoverHoleZTrans - kForwardCoverHoleLen;
8189   TGeoCombiTrans *mf2 = new TGeoCombiTrans(0, yloc, zloc,
8190                                            new TGeoRotation("", 0, 90, 0) );
8191   mf2->SetName("mf2");
8192   mf2->RegisterYourself();
8193
8194   // Finally the actual cover shape
8195   TGeoCompositeShape *cover = new TGeoCompositeShape("ITSsuppForwardCoverMain",
8196     "ITSsuppForwCoverMain-ITSsuppForwCoverHole:mf1-ITSsuppForwCoverHole:mf2");
8197
8198   return cover;
8199 }
8200
8201 //______________________________________________________________________
8202 TGeoCompositeShape* AliITSv11GeometrySupport::CreateTrayAExternalCover(const Double_t coverLen){
8203 //
8204 // Creates the external cover of the SDD and SSD cable trays on Side A
8205 // (0872/G/D/04)
8206 //
8207 // Input:
8208 //             coverLen: the total length of the cover
8209 //
8210 // Output:
8211 //
8212 // Return:     a TGeoCompositeShape for the cover
8213 //
8214 // Created:      03 Jan 2010  Mario Sitta
8215 //
8216 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8217 // drawings and other (oral) information given by F.Tosello
8218 //
8219
8220   // Dimensions and positions of the A-Side Cable Tray External Cover
8221   // (0872/G/D/04)
8222   const Double_t kExternalCoverWide        =  130.00 *fgkmm;
8223   const Double_t kExternalCoverSideWide    =   10.00 *fgkmm;
8224   const Double_t kExternalCoverHoleLen1    =  262.00 *fgkmm;
8225   const Double_t kExternalCoverHoleLen2    =  280.00 *fgkmm;
8226   const Double_t kExternalCoverHoleLen3    =  205.00 *fgkmm;
8227   const Double_t kExternalCoverHoleLen4    =   55.00 *fgkmm;
8228   const Double_t kExternalCoverHoleWide    =   90.00 *fgkmm;
8229   const Double_t kExternalCoverHoleR10     =   10.00 *fgkmm;
8230   const Double_t kExternalCoverTotalThick  =    5.00 *fgkmm;
8231   const Double_t kExternalCoverSideThick   =    3.00 *fgkmm;
8232   const Double_t kExternalCoverInternThick =    2.00 *fgkmm;
8233
8234   const Double_t kExternalCoverHole1ZTrans =   28.00 *fgkmm;
8235   const Double_t kExternalCoverHolesZTrans =   20.00 *fgkmm;
8236
8237
8238   // Local variables
8239   Double_t xprof[16], yprof[16];
8240   Double_t yloc, zloc;
8241
8242
8243   // The main shape: a Xtru
8244   TGeoXtru *externCoverMain = new TGeoXtru(2);
8245   externCoverMain->SetName("ITSsuppExternCoverMain");
8246
8247   xprof[0] = kExternalCoverWide/2;
8248   yprof[0] = kExternalCoverTotalThick;
8249   xprof[1] = xprof[0];
8250   yprof[1] = yprof[0] - kExternalCoverSideThick;
8251   xprof[2] = xprof[1] - kExternalCoverSideWide;
8252   yprof[2] = yprof[1];
8253   xprof[3] = xprof[2];
8254   yprof[3] = 0;
8255
8256   // We did the right side, now reflex on the left side
8257   for (Int_t jp = 0; jp < 4; jp++) {
8258     xprof[4+jp] = -xprof[3-jp];
8259     yprof[4+jp] =  yprof[3-jp];
8260   }
8261
8262   // And now the actual Xtru
8263   externCoverMain->DefinePolygon(8, xprof, yprof);
8264   externCoverMain->DefineSection(0, 0);
8265   externCoverMain->DefineSection(1, coverLen);
8266
8267   // The first hole: a Xtru (rounded corners approximated with segments)
8268   Double_t holethick = kExternalCoverTotalThick-kExternalCoverInternThick;
8269
8270   TGeoXtru *extCoverHole1 = new TGeoXtru(2);
8271   extCoverHole1->SetName("ITSsuppExtCoverHole1");
8272
8273   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen1,
8274                              kExternalCoverHoleR10 , xprof, yprof);
8275
8276   extCoverHole1->DefinePolygon(16, xprof, yprof);
8277   extCoverHole1->DefineSection(0, 0);
8278   extCoverHole1->DefineSection(1, holethick);
8279
8280   // The second (and third) hole: another Xtru
8281   TGeoXtru *extCoverHole2 = new TGeoXtru(2);
8282   extCoverHole2->SetName("ITSsuppExtCoverHole2");
8283
8284   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen2,
8285                              kExternalCoverHoleR10 , xprof, yprof);
8286
8287   extCoverHole2->DefinePolygon(16, xprof, yprof);
8288   extCoverHole2->DefineSection(0, 0);
8289   extCoverHole2->DefineSection(1, holethick);
8290
8291   // The fourth hole: another Xtru
8292   TGeoXtru *extCoverHole3 = new TGeoXtru(2);
8293   extCoverHole3->SetName("ITSsuppExtCoverHole3");
8294
8295   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen3,
8296                              kExternalCoverHoleR10 , xprof, yprof);
8297
8298   extCoverHole3->DefinePolygon(16, xprof, yprof);
8299   extCoverHole3->DefineSection(0, 0);
8300   extCoverHole3->DefineSection(1, holethick);
8301
8302   // The fifth and last hole: another Xtru
8303   TGeoXtru *extCoverHole4 = new TGeoXtru(2);
8304   extCoverHole4->SetName("ITSsuppExtCoverHole4");
8305
8306   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen4,
8307                              kExternalCoverHoleR10 , xprof, yprof);
8308
8309   extCoverHole4->DefinePolygon(16, xprof, yprof);
8310   extCoverHole4->DefineSection(0, 0);
8311   extCoverHole4->DefineSection(1, holethick);
8312
8313   // Now the proper rototranslation matrices for the holes
8314   yloc = kExternalCoverTotalThick - kExternalCoverInternThick-0.01;
8315   zloc = kExternalCoverHole1ZTrans;
8316   TGeoCombiTrans *me1 = new TGeoCombiTrans(0, yloc, zloc,
8317                                            new TGeoRotation("", 0, 90, 0) );
8318   me1->SetName("me1");
8319   me1->RegisterYourself();
8320
8321   zloc += (kExternalCoverHoleLen1 + kExternalCoverHolesZTrans);
8322   TGeoCombiTrans *me2 = new TGeoCombiTrans(0, yloc, zloc,
8323                                            new TGeoRotation("", 0, 90, 0) );
8324   me2->SetName("me2");
8325   me2->RegisterYourself();
8326
8327   zloc += (kExternalCoverHoleLen2 + kExternalCoverHolesZTrans);
8328   TGeoCombiTrans *me3 = new TGeoCombiTrans(0, yloc, zloc,
8329                                            new TGeoRotation("", 0, 90, 0) );
8330   me3->SetName("me3");
8331   me3->RegisterYourself();
8332
8333   zloc += (kExternalCoverHoleLen2 + kExternalCoverHolesZTrans);
8334   TGeoCombiTrans *me4 = new TGeoCombiTrans(0, yloc, zloc,
8335                                            new TGeoRotation("", 0, 90, 0) );
8336   me4->SetName("me4");
8337   me4->RegisterYourself();
8338
8339   zloc += (kExternalCoverHoleLen3 + kExternalCoverHolesZTrans);
8340   TGeoCombiTrans *me5 = new TGeoCombiTrans(0, yloc, zloc,
8341                                            new TGeoRotation("", 0, 90, 0) );
8342   me5->SetName("me5");
8343   me5->RegisterYourself();
8344
8345   // Finally the actual cover shape
8346   TGeoCompositeShape *cover = new TGeoCompositeShape("ITSsuppExternCoverMain",
8347     "ITSsuppExternCoverMain-ITSsuppExtCoverHole1:me1-ITSsuppExtCoverHole2:me2-ITSsuppExtCoverHole2:me3-ITSsuppExtCoverHole3:me4-ITSsuppExtCoverHole4:me5");
8348
8349   return cover;
8350 }
8351
8352 //______________________________________________________________________
8353 void AliITSv11GeometrySupport::CreateTrayACoverHolesShape(const Double_t wide,
8354                                const Double_t length, const Double_t r10,
8355                                Double_t *x, Double_t *y){
8356 //
8357 // Creates the proper sequence of X and Y coordinates to determine
8358 // the base XTru polygon for the holes in the SDD and SSD tray covers
8359 // (here the rounded corners are approximated with segments)
8360 //
8361 // Input:
8362 //        wide   : the hole wide
8363 //        length : the hole length
8364 //        r10    : the radius of the rounded corners
8365 //
8366 // Output:
8367 //        x, y : coordinate vectors [16]
8368 //
8369 // Created:      03 Jan 2010  Mario Sitta
8370 //
8371 // Caller must guarantee that x and y have the correct dimensions
8372 // (but being this a private method it's easy to tell)
8373 //
8374
8375   x[0] = wide/2 - r10;
8376   y[0] = length;
8377   x[1] = x[0] + r10*SinD(30);
8378   y[1] = y[0] - r10*(1 - CosD(30));
8379   x[2] = x[0] + r10*SinD(60);
8380   y[2] = y[0] - r10*(1 - CosD(60));
8381   x[3] = x[0] + r10;
8382   y[3] = y[0] - r10;
8383   x[4] = x[3];
8384   y[4] = r10;
8385   x[5] = x[4] - r10*(1 - CosD(30));
8386   y[5] = y[4] - r10*SinD(30);
8387   x[6] = x[4] - r10*(1 - CosD(60));
8388   y[6] = y[4] - r10*SinD(60);
8389   x[7] = x[4] - r10;
8390   y[7] = 0;
8391
8392   // We did the right side, now reflex on the left side
8393   for (Int_t jp = 0; jp < 8; jp++) {
8394     x[8+jp] = -x[7-jp];
8395     y[8+jp] =  y[7-jp];
8396   }
8397
8398   return;
8399 }
8400
8401 //______________________________________________________________________
8402 TGeoXtru* AliITSv11GeometrySupport::CreateSDDSSDTraysSideA(
8403                                               const Double_t trayLen,
8404                                               const Double_t trayHi){
8405 //
8406 // Creates parts of the SDD and SSD Trays on Side A which are identical
8407 // (0872/G/D/03, part of 0872/G/D/07, 0872/G/C/11)
8408 //
8409 // Input:
8410 //         trayLen : the length of the tray part
8411 //         trayHi  : the height of the tray part
8412 //
8413 // Output:
8414 //
8415 // Return:     a TGeoXtru
8416 //
8417 // Created:      26 Feb 2010  Mario Sitta
8418 //
8419 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8420 // drawings and other (oral) information given by F.Tosello
8421 //
8422
8423   // Dimensions and positions of the A-Side Cable Trays
8424   // (parts of 0872/G/C)
8425   const Double_t kTrayWidth              =  130.00 *fgkmm;
8426   const Double_t kTrayWingWidth          =   10.00 *fgkmm;
8427   const Double_t kTrayHeightToBend       =   20.00 *fgkmm;
8428   const Double_t kTrayThick              =    2.00 *fgkmm;
8429
8430   const Double_t kTrayBendAngle          =   22.00 *TMath::DegToRad();
8431
8432   const Int_t    kTrayNpoints            =   16;
8433
8434   // Local variables
8435   Double_t xprof[kTrayNpoints], yprof[kTrayNpoints];
8436
8437
8438   // The tray shape: a Xtru
8439   TGeoXtru *trayPart = new TGeoXtru(2);
8440
8441   xprof[2] = kTrayWidth/2 - kTrayThick;
8442   yprof[2] = trayHi - kTrayThick;
8443   xprof[3] = kTrayWidth/2 - kTrayWingWidth;
8444   yprof[3] = yprof[2];
8445   xprof[4] = xprof[3];
8446   yprof[4] = trayHi;
8447   xprof[5] = kTrayWidth/2;
8448   yprof[5] = yprof[4];
8449   xprof[6] = xprof[5];
8450   yprof[6] = kTrayHeightToBend;
8451   xprof[7] = xprof[6] - yprof[6]*TMath::Tan(kTrayBendAngle);
8452   yprof[7] = 0;
8453
8454   InsidePoint( xprof[5], yprof[5], xprof[6], yprof[6], xprof[7], yprof[7],
8455               -kTrayThick, xprof[1], yprof[1]);
8456
8457   xprof[8] = -xprof[7];
8458   yprof[8] =  yprof[7];
8459
8460   InsidePoint( xprof[6], yprof[6], xprof[7], yprof[7], xprof[8], yprof[8],
8461               -kTrayThick, xprof[0], yprof[0]);
8462
8463   // We did the right side, now reflex on the left side
8464   for (Int_t jp = 0; jp < 8; jp++) {
8465     xprof[8+jp] = -xprof[7-jp];
8466     yprof[8+jp] =  yprof[7-jp];
8467   }
8468
8469   // And now the actual Xtru
8470   trayPart->DefinePolygon(kTrayNpoints, xprof, yprof);
8471   trayPart->DefineSection(0, 0);
8472   trayPart->DefineSection(1, trayLen);
8473
8474
8475   return trayPart;
8476 }
8477
8478 //______________________________________________________________________
8479 TGeoVolumeAssembly* AliITSv11GeometrySupport::CreateSDDSSDTraysSideC(
8480                                                        const char *trayName,
8481                                                        const TGeoManager *mgr){
8482
8483 //
8484 // Creates the SDD and SSD Trays on Side C which are supposedly identical
8485 //
8486 // Input:
8487 //         trayName : the assembly name
8488 //
8489 // Output:
8490 //
8491 // Return:     a TGeoVolumeAssembly
8492 //
8493 // Created:      16 Apr 2010  Mario Sitta
8494 //
8495 // Technical data are taken from AutoCAD drawings and other (oral)
8496 // information given by F.Tosello
8497 //
8498
8499   const Double_t kSideCHalfThick      =    0.100   *fgkcm;
8500   const Double_t kSideCFoldAngle      =    5.000   *TMath::DegToRad();
8501
8502   const Double_t kSideCLength1        =  172.800   *fgkcm;
8503   const Double_t kSideCLength2        =  189.300   *fgkcm;
8504   const Double_t kSideCHalfWide       =    6.350   *fgkcm;
8505   const Double_t kSideCHeight1        =   11.800   *fgkcm;
8506   const Double_t kSideCHeight2        =    4.300   *fgkcm;
8507   const Double_t kSideCSideLength1    =   10.800   *fgkcm;
8508   const Double_t kSideCSideLength2    =   63.800   *fgkcm;
8509   const Double_t kSideCSideHeight     =    8.800   *fgkcm;
8510   const Int_t    kNPointsLowerFace    =    6;
8511   const Int_t    kNPointsLateralFace  =    9;
8512
8513   const Double_t kSideCWingAHalfLen   =    5.000   *fgkcm;
8514   const Double_t kSideCWingBHalfLen   =   30.500   *fgkcm;
8515   const Double_t kSideCWingCHalfLen   =    2.000   *fgkcm;
8516   const Double_t kSideCWingDHalfLen   =   48.500   *fgkcm;
8517   const Double_t kSideCWingEHalfLen   =   83.000   *fgkcm;
8518   const Double_t kSideCWingsHalfWide  =    0.450   *fgkcm;
8519
8520   const Int_t    kNPointsCoverFace    =   12;
8521
8522   const Double_t kPlateHalfLen        =    6.000   *fgkcm;
8523   const Double_t kPlateThick          =    0.600   *fgkcm;
8524   const Double_t kPlateHeight         =    4.200   *fgkcm;
8525   const Int_t    kNPointsPlate        =    6;
8526
8527   const Double_t kBarCoolRmax         =    0.4     *fgkcm;
8528   const Int_t    kNumBarCool          =    2;
8529   const Double_t kXShiftBarCool[kNumBarCool] = { 8.7, 13.0 };
8530   const Double_t kYShiftBarCool[kNumBarCool] = { 8.5,  5.0 };
8531
8532
8533   // Local variables
8534   Double_t xprof[12], yprof[12];
8535   Double_t xloc, yloc, zloc, delta, alpharot;
8536
8537   // The single C-Side Cable tray as an assembly
8538   TGeoVolumeAssembly *cableTrayC = new TGeoVolumeAssembly(trayName);
8539
8540   // First create all needed shapes
8541
8542   // The Cable Tray lower face: a Xtru
8543   TGeoXtru *sideCLowerFace = new TGeoXtru(2);
8544
8545   xprof[0] = 0.;
8546   yprof[0] = 0.;
8547   xprof[1] = kSideCLength1;
8548   yprof[1] = 0.;
8549   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(kSideCFoldAngle);
8550   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(kSideCFoldAngle);
8551   xprof[3] = xprof[2] - 2*kSideCHalfThick*TMath::Sin(kSideCFoldAngle);
8552   yprof[3] = yprof[2] + 2*kSideCHalfThick*TMath::Cos(kSideCFoldAngle);
8553   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8554               2*kSideCHalfThick , xprof[4], yprof[4]);
8555   xprof[5] = 0.;
8556   yprof[5] = 2*kSideCHalfThick;
8557
8558   sideCLowerFace->DefinePolygon(kNPointsLowerFace, xprof, yprof);
8559   sideCLowerFace->DefineSection(0,-kSideCHalfWide);
8560   sideCLowerFace->DefineSection(1, kSideCHalfWide);
8561
8562   // The Cable Tray lateral face: a Xtru
8563   TGeoXtru *sideCLateralFace = new TGeoXtru(2);
8564
8565   xprof[0] = 0.;
8566   yprof[0] = 0.;
8567   xprof[1] = kSideCLength1;
8568   yprof[1] = 0.;
8569   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(kSideCFoldAngle);
8570   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(kSideCFoldAngle);
8571   xprof[3] = xprof[2] - kSideCHeight2*TMath::Sin(kSideCFoldAngle);
8572   yprof[3] = yprof[2] + kSideCHeight2*TMath::Cos(kSideCFoldAngle);
8573   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8574               kSideCHeight2, xprof[4], yprof[4]);
8575   xprof[5] = kSideCSideLength1 + kSideCSideLength2;
8576   yprof[5] = kSideCHeight2;
8577   xprof[6] = xprof[5];
8578   yprof[6] = kSideCSideHeight;
8579   xprof[7] = kSideCSideLength1;
8580   yprof[7] = kSideCHeight1;
8581   xprof[8] = 0;
8582   yprof[8] = yprof[7];
8583
8584   sideCLateralFace->DefinePolygon(kNPointsLateralFace, xprof, yprof);
8585   sideCLateralFace->DefineSection(0,-kSideCHalfThick);
8586   sideCLateralFace->DefineSection(1, kSideCHalfThick);
8587
8588   // The lateral wings: four BBox's
8589   TGeoBBox *sideCLateralWingA = new TGeoBBox(kSideCWingAHalfLen,
8590                                              kSideCHalfThick,
8591                                              kSideCWingsHalfWide);
8592
8593   TGeoBBox *sideCLateralWingB = new TGeoBBox(kSideCWingBHalfLen,
8594                                              kSideCHalfThick,
8595                                              kSideCWingsHalfWide);
8596
8597   TGeoBBox *sideCLateralWingC = new TGeoBBox(kSideCHalfThick,    // With these
8598                                              kSideCWingCHalfLen, // X,Y avoid
8599                                              kSideCWingsHalfWide);//rotations
8600
8601   TGeoBBox *sideCLateralWingD = new TGeoBBox(kSideCWingDHalfLen,
8602                                              kSideCHalfThick,
8603                                              kSideCWingsHalfWide);
8604
8605   TGeoBBox *sideCLateralWingE = new TGeoBBox(kSideCWingEHalfLen,
8606                                              kSideCHalfThick,
8607                                              kSideCWingsHalfWide);
8608
8609   // The connecting lower plate: a Xtru
8610   TGeoXtru *sideCLowerPlate =  new TGeoXtru(2);
8611
8612   xprof[0] = 0.;
8613   yprof[0] = 0.;
8614   xprof[1] = kPlateHalfLen;
8615   yprof[1] = 0.;
8616   xprof[2] = xprof[1] + kPlateHalfLen*TMath::Cos(kSideCFoldAngle);
8617   yprof[2] = kPlateHalfLen*TMath::Sin(kSideCFoldAngle);
8618   xprof[3] = xprof[2] - kPlateThick*TMath::Sin(kSideCFoldAngle);
8619   yprof[3] = yprof[2] + kPlateThick*TMath::Cos(kSideCFoldAngle);
8620   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8621               kPlateThick, xprof[4], yprof[4]);
8622   xprof[5] = 0.;
8623   yprof[5] = kPlateThick;
8624
8625   sideCLowerPlate->DefinePolygon(kNPointsPlate, xprof, yprof);
8626   Double_t zwide = kSideCHalfWide + 2*kSideCHalfThick;
8627   sideCLowerPlate->DefineSection(0,-zwide);
8628   sideCLowerPlate->DefineSection(1, zwide);
8629
8630   // The connecting side plate: a Xtru
8631   TGeoXtru *sideCLateralPlate = new TGeoXtru(2);
8632
8633   xprof[0] = 0.;
8634   yprof[0] = 0.;
8635   xprof[1] = kPlateHalfLen;
8636   yprof[1] = 0.;
8637   xprof[2] = xprof[1] + kPlateHalfLen*TMath::Cos(kSideCFoldAngle);
8638   yprof[2] = kPlateHalfLen*TMath::Sin(kSideCFoldAngle);
8639   xprof[3] = xprof[2] - kPlateHeight*TMath::Sin(kSideCFoldAngle);
8640   yprof[3] = yprof[2] + kPlateHeight*TMath::Cos(kSideCFoldAngle);
8641   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8642               kPlateHeight, xprof[4], yprof[4]); // Avoid small overlap
8643   xprof[5] = 0.;
8644   yprof[5] = kPlateHeight;
8645
8646   sideCLateralPlate->DefinePolygon(kNPointsPlate, xprof, yprof);
8647   sideCLateralPlate->DefineSection(0,-kPlateThick/2);
8648   sideCLateralPlate->DefineSection(1, kPlateThick/2);
8649
8650   // The bar fixing the cooling tubes: a Tube
8651   TGeoTube *coolBar = new TGeoTube(0., kBarCoolRmax, kSideCHalfWide);
8652
8653   // The Cable Tray cover: a (complex) Xtru
8654   TGeoXtru *sideCCoverFace = new TGeoXtru(2);
8655
8656   xprof[ 0] = sideCLateralFace->GetX(8);
8657   yprof[ 0] = sideCLateralFace->GetY(8);
8658   xprof[ 1] = sideCLateralFace->GetX(7);
8659   yprof[ 1] = sideCLateralFace->GetY(7);
8660   xprof[ 2] = sideCLateralFace->GetX(6);
8661   yprof[ 2] = sideCLateralFace->GetY(6);
8662   xprof[ 3] = sideCLateralFace->GetX(5);
8663   yprof[ 3] = sideCLateralFace->GetY(5);
8664   xprof[ 4] = sideCLateralFace->GetX(4);
8665   yprof[ 4] = sideCLateralFace->GetY(4);
8666
8667   xloc = (kSideCLength1 + (kSideCSideLength1+kSideCSideLength2))/2;
8668   delta  = kSideCLength1 - (xloc + kSideCWingDHalfLen);
8669   xprof[ 5] = xprof[4]
8670             + (delta + 2*kSideCWingEHalfLen)*TMath::Cos(kSideCFoldAngle);
8671   yprof[ 5] = yprof[4]
8672             + (delta + 2*kSideCWingEHalfLen)*TMath::Sin(kSideCFoldAngle);
8673
8674   xprof[ 6] = xprof[5] - 2*kSideCHalfThick*TMath::Sin(kSideCFoldAngle);
8675   yprof[ 6] = yprof[5] + 2*kSideCHalfThick*TMath::Cos(kSideCFoldAngle);
8676   InsidePoint(xprof[3], yprof[3], xprof[4], yprof[4], xprof[5], yprof[5],
8677               2*kSideCHalfThick, xprof[7], yprof[7]);
8678   InsidePoint(xprof[2], yprof[2], xprof[3], yprof[3], xprof[4], yprof[4],
8679               2*kSideCHalfThick, xprof[8], yprof[8]);
8680   xprof[ 9] = xprof[2] + 2*kSideCHalfThick;
8681   yprof[ 9] = yprof[2] + 2*kSideCHalfThick;
8682   xprof[10] = xprof[1];
8683   yprof[10] = yprof[1] + 2*kSideCHalfThick;
8684   xprof[11] = xprof[0];
8685   yprof[11] = yprof[0] + 2*kSideCHalfThick;
8686
8687   sideCCoverFace->DefinePolygon(kNPointsCoverFace, xprof, yprof);
8688   zloc = kSideCHalfWide + 2*kSideCHalfThick + 2*kSideCWingsHalfWide;
8689   sideCCoverFace->DefineSection(0,-zloc);
8690   sideCCoverFace->DefineSection(1, zloc);
8691
8692
8693   // We have all shapes: now create the real volumes
8694   TGeoMedium *medAl      = mgr->GetMedium("ITS_ALUMINUM$");
8695
8696   TGeoVolume *traySideCLowerFace  = new TGeoVolume("ITSsuppTraySideCLower",
8697                                                    sideCLowerFace, medAl);
8698
8699   traySideCLowerFace->SetVisibility(kTRUE);
8700   traySideCLowerFace->SetLineColor(6); // Purple
8701   traySideCLowerFace->SetLineWidth(1);
8702   traySideCLowerFace->SetFillColor(traySideCLowerFace->GetLineColor());
8703   traySideCLowerFace->SetFillStyle(4000); // 0% transparent
8704
8705   TGeoVolume *traySideCLateralFace  = new TGeoVolume("ITSsuppTraySideCLateral",
8706                                                      sideCLateralFace, medAl);
8707
8708   traySideCLateralFace->SetVisibility(kTRUE);
8709   traySideCLateralFace->SetLineColor(6); // Purple
8710   traySideCLateralFace->SetLineWidth(1);
8711   traySideCLateralFace->SetFillColor(traySideCLateralFace->GetLineColor());
8712   traySideCLateralFace->SetFillStyle(4000); // 0% transparent
8713
8714   TGeoVolume *traySideCLateralWingA =
8715     new TGeoVolume("ITSsuppTraySideCLateralWingA", sideCLateralWingA,  medAl);
8716
8717   traySideCLateralWingA->SetVisibility(kTRUE);
8718   traySideCLateralWingA->SetLineColor(6); // Purple
8719   traySideCLateralWingA->SetLineWidth(1);
8720   traySideCLateralWingA->SetFillColor(traySideCLateralWingA->GetLineColor());
8721   traySideCLateralWingA->SetFillStyle(4000); // 0% transparent
8722
8723   TGeoVolume *traySideCLateralWingB =
8724     new TGeoVolume("ITSsuppTraySideCLateralWingB", sideCLateralWingB,  medAl);
8725
8726   traySideCLateralWingB->SetVisibility(kTRUE);
8727   traySideCLateralWingB->SetLineColor(6); // Purple
8728   traySideCLateralWingB->SetLineWidth(1);
8729   traySideCLateralWingB->SetFillColor(traySideCLateralWingB->GetLineColor());
8730   traySideCLateralWingB->SetFillStyle(4000); // 0% transparent
8731
8732   TGeoVolume *traySideCLateralWingC =
8733     new TGeoVolume("ITSsuppTraySideCLateralWingC", sideCLateralWingC,  medAl);
8734
8735   traySideCLateralWingC->SetVisibility(kTRUE);
8736   traySideCLateralWingC->SetLineColor(6); // Purple
8737   traySideCLateralWingC->SetLineWidth(1);
8738   traySideCLateralWingC->SetFillColor(traySideCLateralWingC->GetLineColor());
8739   traySideCLateralWingC->SetFillStyle(4000); // 0% transparent
8740
8741   TGeoVolume *traySideCLateralWingD =
8742     new TGeoVolume("ITSsuppTraySideCLateralWingD", sideCLateralWingD,  medAl);
8743
8744   traySideCLateralWingD->SetVisibility(kTRUE);
8745   traySideCLateralWingD->SetLineColor(6); // Purple
8746   traySideCLateralWingD->SetLineWidth(1);
8747   traySideCLateralWingD->SetFillColor(traySideCLateralWingD->GetLineColor());
8748   traySideCLateralWingD->SetFillStyle(4000); // 0% transparent
8749
8750   TGeoVolume *traySideCLateralWingE =
8751     new TGeoVolume("ITSsuppTraySideCLateralWingE", sideCLateralWingE,  medAl);
8752
8753   traySideCLateralWingE->SetVisibility(kTRUE);
8754   traySideCLateralWingE->SetLineColor(6); // Purple
8755   traySideCLateralWingE->SetLineWidth(1);
8756   traySideCLateralWingE->SetFillColor(traySideCLateralWingE->GetLineColor());
8757   traySideCLateralWingE->SetFillStyle(4000); // 0% transparent
8758
8759   TGeoVolume *traySideCLowerPlate =
8760     new TGeoVolume("ITSsuppTraySideCLowerPlate", sideCLowerPlate,  medAl);
8761
8762   traySideCLowerPlate->SetVisibility(kTRUE);
8763   traySideCLowerPlate->SetLineColor(6); // Purple
8764   traySideCLowerPlate->SetLineWidth(1);
8765   traySideCLowerPlate->SetFillColor(traySideCLowerPlate->GetLineColor());
8766   traySideCLowerPlate->SetFillStyle(4000); // 0% transparent
8767
8768   TGeoVolume *traySideCLateralPlate =
8769     new TGeoVolume("ITSsuppTraySideCLateralPlate", sideCLateralPlate,  medAl);
8770
8771   traySideCLateralPlate->SetVisibility(kTRUE);
8772   traySideCLateralPlate->SetLineColor(6); // Purple
8773   traySideCLateralPlate->SetLineWidth(1);
8774   traySideCLateralPlate->SetFillColor(traySideCLateralPlate->GetLineColor());
8775   traySideCLateralPlate->SetFillStyle(4000); // 0% transparent
8776
8777   TGeoVolume *traySideCCoverFace =
8778     new TGeoVolume("ITSsuppTraySideCCoverFace", sideCCoverFace,  medAl);
8779
8780   traySideCCoverFace->SetVisibility(kTRUE);
8781   traySideCCoverFace->SetLineColor(6); // Purple
8782   traySideCCoverFace->SetLineWidth(1);
8783   traySideCCoverFace->SetFillColor(traySideCCoverFace->GetLineColor());
8784   traySideCCoverFace->SetFillStyle(4000); // 0% transparent
8785
8786   TGeoVolume *coolingTubeBar = new TGeoVolume("ITSsuppTraySideCCoolBar",
8787                                               coolBar, medAl);
8788
8789   coolingTubeBar->SetVisibility(kTRUE);
8790   coolingTubeBar->SetLineColor(6); // Purple
8791   coolingTubeBar->SetLineWidth(1);
8792   coolingTubeBar->SetFillColor(coolingTubeBar->GetLineColor());
8793   coolingTubeBar->SetFillStyle(4000); // 0% transparent
8794
8795
8796   // Now build up the tray
8797   cableTrayC->AddNode(traySideCLowerFace,1,0);
8798
8799   zloc = kSideCHalfWide + kSideCHalfThick;
8800   cableTrayC->AddNode(traySideCLateralFace,1,
8801                             new TGeoTranslation(0., 0., zloc) );
8802   cableTrayC->AddNode(traySideCLateralFace,2,
8803                             new TGeoTranslation(0., 0.,-zloc) );
8804
8805   xloc = kSideCWingAHalfLen;
8806   yloc = kSideCHeight1 - kSideCHalfThick;
8807   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8808   cableTrayC->AddNode(traySideCLateralWingA,1,
8809                             new TGeoTranslation(xloc, yloc, zloc) );
8810   cableTrayC->AddNode(traySideCLateralWingA,2,
8811                             new TGeoTranslation(xloc, yloc,-zloc) );
8812
8813   xloc = kSideCSideLength1 + kSideCSideLength2/2;
8814   yloc = Yfrom2Points(kSideCSideLength1,kSideCHeight1,
8815                       kSideCSideLength1+kSideCSideLength2,kSideCSideHeight,
8816                       xloc) - kSideCHalfThick -0.0012; // Avoid small overlap
8817   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8818   alpharot = (-(kSideCHeight1 - kSideCSideHeight)/kSideCSideLength2 )*
8819                 TMath::RadToDeg();
8820   cableTrayC->AddNode(traySideCLateralWingB,1,
8821                             new TGeoCombiTrans(xloc, yloc, zloc,
8822                                         new TGeoRotation("",alpharot,0,0) ) );
8823   cableTrayC->AddNode(traySideCLateralWingB,2,
8824                             new TGeoCombiTrans(xloc, yloc,-zloc,
8825                                         new TGeoRotation("",alpharot,0,0) ) );
8826
8827   xloc = kSideCSideLength1 + kSideCSideLength2 - kSideCHalfThick;
8828   yloc = kSideCSideHeight - kSideCWingCHalfLen;
8829   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8830   cableTrayC->AddNode(traySideCLateralWingC,1,
8831                             new TGeoTranslation(xloc, yloc, zloc) );
8832   cableTrayC->AddNode(traySideCLateralWingC,2,
8833                             new TGeoTranslation(xloc, yloc,-zloc) );
8834
8835   xloc = (kSideCLength1 + (kSideCSideLength1+kSideCSideLength2))/2;
8836   yloc = kSideCHeight2 - kSideCHalfThick;
8837   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8838   cableTrayC->AddNode(traySideCLateralWingD,1,
8839                             new TGeoTranslation(xloc, yloc, zloc) );
8840   cableTrayC->AddNode(traySideCLateralWingD,2,
8841                             new TGeoTranslation(xloc, yloc,-zloc) );
8842
8843   delta = kSideCLength1 - (xloc + kSideCWingDHalfLen);
8844   xloc = kSideCLength1 + delta + kSideCWingEHalfLen;
8845   yloc = (xloc - kSideCLength1)*TMath::Tan(kSideCFoldAngle) +
8846           kSideCHeight2*TMath::Cos(kSideCFoldAngle) - kSideCHalfThick;
8847   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8848   alpharot = kSideCFoldAngle*TMath::RadToDeg();
8849   cableTrayC->AddNode(traySideCLateralWingE,1,
8850                             new TGeoCombiTrans(xloc, yloc, zloc,
8851                                         new TGeoRotation("",alpharot,0,0) ) );
8852   cableTrayC->AddNode(traySideCLateralWingE,2,
8853                             new TGeoCombiTrans(xloc, yloc,-zloc,
8854                                         new TGeoRotation("",alpharot,0,0) ) );
8855
8856   xloc = kSideCLength1 - kPlateHalfLen;
8857   yloc = -kPlateThick -0.0025; // Avoid small overlap
8858   cableTrayC->AddNode(traySideCLowerPlate,1,
8859                             new TGeoTranslation(xloc, yloc, 0.) );
8860
8861   xloc = kSideCLength1 - kPlateHalfLen;
8862   yloc = -kPlateThick;
8863   zloc = kSideCHalfWide + 2*kSideCHalfThick + kPlateThick/2;
8864   cableTrayC->AddNode(traySideCLateralPlate,1,
8865                             new TGeoTranslation(xloc, yloc, zloc) );
8866   cableTrayC->AddNode(traySideCLateralPlate,2,
8867                             new TGeoTranslation(xloc, yloc,-zloc) );
8868
8869   for (Int_t jc = 0; jc <kNumBarCool; jc++) {
8870     xloc = kXShiftBarCool[jc];
8871     yloc = kYShiftBarCool[jc];
8872     cableTrayC->AddNode(coolingTubeBar,jc+1,
8873                               new TGeoTranslation(xloc, yloc, 0.) );
8874   }
8875
8876   cableTrayC->AddNode(traySideCCoverFace,1,0);
8877
8878
8879   // Finally return what we made up
8880
8881   return cableTrayC;
8882 }
8883
8884 //______________________________________________________________________
8885 void AliITSv11GeometrySupport::ITSTPCSupports(TGeoVolume *moth,
8886                                         const TGeoManager *mgr){
8887 //
8888 // Creates the elements suspending the ITS to the TPC and other fixed
8889 // elements used to hook the rails (0872/C and its daughters)
8890 //
8891 // Input:
8892 //         moth : the TGeoVolume owing the volume structure
8893 //         mgr  : the GeoManager (default gGeoManager)
8894 // Output:
8895 //
8896 // Return:
8897 //
8898 // Created:      28 Oct 2010  Mario Sitta
8899 // Updated:      18 Feb 2011  Mario Sitta
8900 //
8901 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8902 // drawings and other (oral) information given by F.Tosello
8903 //
8904
8905   // Dimensions and positions of the half ring C2/C3 (0872/C/04)
8906   const Double_t kRingCZPos           =   733.000*fgkmm;
8907   const Double_t kRingCZToTPC         =     5.500*fgkmm;
8908
8909   const Double_t kRingCThick          =    12.000*fgkmm;
8910   const Double_t kRingCRmin           =   565.000*fgkmm;
8911   const Double_t kRingCRmax           =   592.000*fgkmm;
8912   const Double_t kRingCHeight         =   560.000*fgkmm;
8913   const Double_t kRingCXToInsert      =   515.000*fgkmm;
8914   const Double_t kRingCYToInsert      =   113.000*fgkmm;
8915
8916   const Int_t kNumberOfRingPoints     =    23; // N.points to approximate arc
8917
8918   // Dimensions of the forward upper hook (0872/C/09)
8919   const Double_t kForwUpHookThick     =    20.000*fgkmm;
8920   const Double_t kForwUpHookRext      =   590.000*fgkmm;
8921   const Double_t kForwUpHookRint      =    20.000*fgkmm;
8922   const Double_t kForwUpHookHiTot     =    89.000*fgkmm;
8923   const Double_t kForwUpHookHiInt     =    59.000*fgkmm;
8924   const Double_t kForwUpHookWide      =    96.000*fgkmm;
8925   const Double_t kForwUpHookHalfBase  =    25.000*fgkmm;
8926   const Double_t kForwUpHookBaseCut   =    10.000*fgkmm;
8927   const Double_t kForwUpHookHoleWide  =    25.000*fgkmm;
8928   const Double_t kForwUpHookHoleHi    =    22.500*fgkmm;
8929   const Double_t kForwUpHookHoleBase  =     5.000*fgkmm;
8930   const Double_t kForwUpHookHoleR5    =     5.000*fgkmm;
8931   const Double_t kForwUpHookHoleY     =     8.000*fgkmm;
8932   const Double_t kForwUpHookHollowHi  =    35.000*fgkmm;
8933   const Double_t kForwUpHookHollowWide=     5.000*fgkmm;
8934
8935   const Int_t kNumberOfForwUpHookPts  =    11;
8936   const Int_t kNumbOfForwUpHookHolePts=     5;
8937
8938   // Dimensions of the forward lower hook (0872/C/08)
8939   const Double_t kForwLwHookThick     =    20.000*fgkmm;
8940   const Double_t kForwLwHookRext      =   590.000*fgkmm;
8941   const Double_t kForwLwHookRint      =    20.000*fgkmm;
8942   const Double_t kForwLwHookHiTot     =    88.500*fgkmm;
8943   const Double_t kForwLwHookWide      =    96.000*fgkmm;
8944   const Double_t kForwLwHookHalfBase  =    25.000*fgkmm;
8945   const Double_t kForwLwHookBaseCut   =    10.000*fgkmm;
8946   const Double_t kForwLwHookYToHollow =     3.500*fgkmm;
8947   const Double_t kForwLwHookHoleR     =     7.500*fgkmm;
8948   const Double_t kForwLwHookHoleIntHi =    35.000*fgkmm;
8949   const Double_t kForwLwHookHoleYPos  =    13.500*fgkmm;
8950   const Double_t kForwLwHookHollowHi  =    62.000*fgkmm;
8951   const Double_t kForwLwHookHollowWide=     5.000*fgkmm;
8952
8953   const Int_t kNumberOfForwLwHookPts  =    11;
8954   const Int_t kNumbOfForwLwHookHolePts=     7;
8955
8956   // Dimensions of the rear upper hook (0872/C/10)
8957   const Double_t kRearUpHookThick     =    15.000*fgkmm;
8958   const Double_t kRearUpHookRext      =   590.000*fgkmm;
8959   const Double_t kRearUpHookRint      =    20.000*fgkmm;
8960   const Double_t kRearUpHookHiTot     =    53.500*fgkmm;
8961   const Double_t kRearUpHookHiInt     =    23.500*fgkmm;
8962   const Double_t kRearUpHookWide      =    96.000*fgkmm;
8963   const Double_t kRearUpHookHalfBase  =    25.000*fgkmm;
8964   const Double_t kRearUpHookHoleWide  =    25.000*fgkmm;
8965   const Double_t kRearUpHookHoleHi    =    22.500*fgkmm;
8966   const Double_t kRearUpHookHoleBase  =     5.000*fgkmm;
8967   const Double_t kRearUpHookHoleR5    =     5.000*fgkmm;
8968   const Double_t kRearUpHookHoleY     =     8.000*fgkmm;
8969
8970   const Int_t kNumberOfRearUpHookPts  =    10;
8971   const Int_t kNumbOfRearUpHookHolePts=     5;
8972
8973   // Dimensions of the forward lower hook (0872/C/11)
8974   const Double_t kRearLwHookThick     =    20.000*fgkmm;
8975   const Double_t kRearLwHookRext      =   590.000*fgkmm;
8976   const Double_t kRearLwHookHiTot     =    30.000*fgkmm;
8977   const Double_t kRearLwHookWide      =    96.000*fgkmm;
8978
8979   const Int_t kNumberOfRearLwHookPts  =     3;
8980
8981   // Dimensions of the rear lower brackets (0872/C/16)
8982   const Double_t kRearLwBracketThick  =    15.000*fgkmm;
8983   const Double_t kRearLwBracketHi1    =    42.000*fgkmm;
8984   const Double_t kRearLwBracketHi2    =    12.000*fgkmm;
8985   const Double_t kRearLwBracketWide1  =    34.000*fgkmm;
8986   const Double_t kRearLwBracketWide2  =    10.000*fgkmm;
8987 //  const Double_t kRearLwBracketR5     =     5.000*fgkmm
8988
8989   // Dimensions of the forward webcam supports (0872/C/V/01-03-04)
8990   const Double_t kForwWebSStirrDep    =    20.000*fgkmm;
8991   const Double_t kForwWebSStirrLen1   =    15.000*fgkmm;
8992   const Double_t kForwWebSStirrLen2   =    55.000*fgkmm;
8993   const Double_t kForwWebSStirrLen3   =    10.000*fgkmm;
8994   const Double_t kForwWebSStirrWide1  =    45.000*fgkmm;
8995   const Double_t kForwWebSStirrWide2  =    38.000*fgkmm;
8996   const Double_t kForwWebSStirrWide3  =    23.000*fgkmm;
8997   const Double_t kForwWebTStirrThick  =     5.000*fgkmm;
8998   const Double_t kForwWebTStirrWide1  =    30.000*fgkmm;
8999   const Double_t kForwWebTStirrWide2  =    10.000*fgkmm;
9000   const Double_t kForwWebTStirrTotLen3=    58.500*fgkmm;
9001   const Double_t kForwWebTStirrTotLen4=    36.000*fgkmm;
9002   const Double_t kForwWebTStirrLen1   =    10.000*fgkmm;
9003
9004   // Dimensions of the forward and rear webcam clamps (0872/C/V/02)
9005   const Double_t kFRWebClampThick     =    10.000*fgkmm;
9006   const Double_t kFRWebClampExtWide   =    30.000*fgkmm;
9007   const Double_t kFRWebClampIntWide   =    18.000*fgkmm;
9008   const Double_t kFRWebClampExtHi     =    22.000*fgkmm;
9009   const Double_t kFRWebClampIntHi     =    17.000*fgkmm;
9010
9011   // Dimensions of the webcam itself
9012   const Double_t kWebcamLength        =    35.000*fgkmm;//ESTIMATED!!!
9013
9014   // Dimensions of the rear upper webcam supports (0872/C/V/05-06)
9015   const Double_t kRearUpWebStirrWide  =    76.000*fgkmm;
9016   const Double_t kRearUpWebStirrDep   =    15.000*fgkmm;
9017   const Double_t kRearUpWebStirrThick =     5.000*fgkmm;
9018   const Double_t kRearUpWebStirrH1    =    27.000*fgkmm;
9019   const Double_t kRearUpWebStirrH2    =    32.000*fgkmm;
9020   const Double_t kRearUpWebBarLen     =   130.000*fgkmm;
9021   const Double_t kRearUpWebBarHi      =    20.000*fgkmm;
9022   const Double_t kRearUpWebBarThick   =     5.000*fgkmm;
9023
9024   // Dimensions of the upper wheel slides (0872/C/Z/00-01-02)
9025   const Double_t kUpperSlideTotHeight =    93.500*fgkmm;
9026   const Double_t kUpperSlideBlockHi   =    62.500*fgkmm;
9027   const Double_t kUpperSlideWidth     =    36.000*fgkmm;
9028   const Double_t kUpperSlideTotDepth  =    51.000*fgkmm;
9029   const Double_t kUpperSlideIntDepth  =    36.000*fgkmm;
9030   const Double_t kUpperSlideStubHi    =    15.000*fgkmm;
9031   const Double_t kUpperSlideStubDep   =     8.000*fgkmm;
9032   const Double_t kUpperSlideWheelHi   =    18.500*fgkmm;
9033   const Double_t kUpperSlideHoleRout  =    11.000*fgkmm;
9034   const Double_t kUpperSlideHoleRint1 =     9.000*fgkmm;
9035   const Double_t kUpperSlideHoleRint2 =    11.500*fgkmm;
9036   const Double_t kUpperSlideHoleH1    =     7.000*fgkmm;
9037   const Double_t kUpperSlideHoleH2    =    46.000*fgkmm;
9038   const Double_t kUpperSlideHoleH3    =     1.100*fgkmm;
9039   const Double_t kUpperSlideHoleXPos  =    20.000*fgkmm;
9040   const Double_t kUpperSlidePinRmin   =     4.000*fgkmm;
9041   const Double_t kUpperSlidePinRmax   =     6.000*fgkmm;
9042   const Double_t kUpperSlidePinH1     =     7.000*fgkmm;
9043   const Double_t kUpperSlidePinH2     =    46.000*fgkmm;
9044   const Double_t kUpperSlidePinH3     =    25.500*fgkmm;
9045
9046   // Dimensions of the lower wheel slides (0872/C/W/00-01-02-03)
9047   const Double_t kLowerSlideTotHeight =    80.000*fgkmm;
9048   const Double_t kLowerSlideBlockHi   =    28.000*fgkmm;
9049   const Double_t kLowerSlideWidth     =    36.000*fgkmm;
9050   const Double_t kLowerSlideTotDepth  =    60.000*fgkmm;
9051   const Double_t kLowerSlideHoleRout  =     9.500*fgkmm;
9052   const Double_t kLowerSlideHoleRint  =     4.700*fgkmm;
9053   const Double_t kLowerSlideHoleH1    =    12.000*fgkmm;
9054   const Double_t kLowerSlideNoseBase  =    40.000*fgkmm;
9055   const Double_t kLowerSlideNoseBasHi =     6.000*fgkmm;//Computed
9056   const Double_t kLowerSlideNoseUpWid =    25.000*fgkmm;
9057   const Double_t kLowerSlideNoseDepth =    10.000*fgkmm;
9058   const Double_t kLowerSlidePinRmin   =     3.000*fgkmm;
9059   const Double_t kLowerSlidePinRmax   =     4.000*fgkmm;
9060   const Double_t kLowerSlidePinH1     =    12.000*fgkmm;
9061   const Double_t kLowerSlidePinH2     =    10.000*fgkmm;
9062
9063   // Dimensions and positions of the C1/C2 rail stirrups (0872/C/01-02)
9064   const Double_t kStirrCXPos          =   759.000*fgkmm;
9065   const Double_t kStirrCZPos          =  1867.000*fgkmm;
9066
9067   const Double_t kStirrC12Thick       =    15.000*fgkmm;
9068   const Double_t kStirrC12TotLen      =   314.000*fgkmm;
9069   const Double_t kStirrC12BodyHalfHi  =    95.000*fgkmm;
9070   const Double_t kStirrC12BodyLen     =   153.000*fgkmm;
9071   const Double_t kStirrC12HeadLen     =    50.000*fgkmm;
9072   const Double_t kStirrC12HeadHalfHi  =   165.000*fgkmm;
9073   const Double_t kStirrC12HeadIntHi   =   114.000*fgkmm;
9074   const Double_t kStirrC12HeadIntLen  =    45.000*fgkmm;
9075   const Double_t kStirrC12TailLen     =    14.000*fgkmm;
9076   const Double_t kStirrC12R100        =   100.000*fgkmm;
9077   const Double_t kStirrC12R50         =    50.000*fgkmm;
9078   const Double_t kStirrC12R10         =    10.000*fgkmm;
9079   const Double_t kStirrC12HeadAng     =    40.000; // Degree
9080
9081   const Int_t kNumberOfStirrCPoints   =    23;
9082
9083   // Dimensions and positions of the C5 rail stirrups (0872/C/05)
9084   const Double_t kStirrC5BodyLen      =   155.000*fgkmm;
9085
9086
9087   // Local variables
9088   Double_t xprof[2*kNumberOfStirrCPoints+1],yprof[2*kNumberOfStirrCPoints+1];
9089   Double_t xpos, ypos, zpos, alpha;
9090   Double_t xdummy, ydummy;
9091   
9092
9093   // First create all needed shapes
9094
9095   // The Supporting Ring (0872/C/04): a really complex Xtru
9096   // to approximate the arc with a polyline
9097   TGeoXtru *ringC2C3 = new TGeoXtru(2);
9098
9099   for (Int_t j=0; j<11; j++) { // The external arc
9100     xprof[j] = kRingCRmax*SinD(90*j/10);
9101     yprof[j] = kRingCRmax*CosD(90*j/10);
9102   }
9103
9104   xprof[11] = kRingCRmin;
9105   yprof[11] = yprof[10];
9106
9107   alpha = TMath::ASin(kRingCYToInsert/kRingCRmin); // Now the insert
9108   xprof[12] = kRingCRmin*TMath::Cos(alpha/2);
9109   yprof[12] = kRingCRmin*TMath::Sin(alpha/2);
9110   xprof[13] = kRingCRmin*TMath::Cos(alpha);
9111   yprof[13] = kRingCRmin*TMath::Sin(alpha);
9112
9113   xprof[14] = kRingCXToInsert;
9114   yprof[14] = yprof[13];
9115
9116   alpha = TMath::ACos(kRingCXToInsert/kRingCRmin); // The insert ending angle
9117   xprof[15] = kRingCRmin*TMath::Cos(alpha);
9118   yprof[15] = kRingCRmin*TMath::Sin(alpha);
9119
9120   for (Int_t j=7; j>1; j--) { // The internal arc
9121     xprof[23-j] = kRingCRmin*SinD(90*j/10);
9122     yprof[23-j] = kRingCRmin*CosD(90*j/10);
9123   }
9124
9125   alpha = TMath::ASin(kRingCHeight/kRingCRmin);    // The angle till the notch
9126   xprof[22] = kRingCRmin*TMath::Cos(alpha);
9127   yprof[22] = kRingCRmin*TMath::Sin(alpha);
9128
9129   xprof[23] = xprof[0];
9130   yprof[23] = yprof[22];
9131
9132   // We did the right side, now reflex on the left side
9133   for (Int_t jp = 0; jp < 22; jp++) {
9134     xprof[24+jp] = -xprof[23-1-jp];
9135     yprof[24+jp] =  yprof[23-1-jp];
9136   }
9137
9138   // wow! now the actual Xtru
9139   ringC2C3->DefinePolygon(2*kNumberOfRingPoints, xprof, yprof);
9140   ringC2C3->DefineSection(0, 0);
9141   ringC2C3->DefineSection(1, kRingCThick);
9142
9143   // The Forward Upper Hook (0872/C/09): a Composite Shape made of
9144   // a really complex Xtru to approximate the arc with a polyline,
9145   // another Xtru for the hole, and a BBox for the hollow
9146   // The main body
9147   TGeoXtru *forwUpHookMainBody = new TGeoXtru(2);
9148   forwUpHookMainBody->SetName("ITSforwUpHookMainBody");
9149
9150   xprof[ 0] = kForwUpHookHalfBase - kForwUpHookBaseCut;
9151   yprof[ 0] = kForwUpHookRext - kForwUpHookHiTot;
9152   xprof[ 1] = kForwUpHookHalfBase;
9153   yprof[ 1] = yprof[0] + kForwUpHookBaseCut;
9154   xprof[ 2] = xprof[1];
9155   yprof[ 2] = yprof[0] + (kForwUpHookHiInt - kForwUpHookRint);
9156   for (Int_t j=1; j<6; j++) {
9157     xprof[2+j] = xprof[2] + kForwUpHookRint*(1 - CosD(90*j/5));
9158     yprof[2+j] = yprof[2] + kForwUpHookRint*SinD(90*j/5);
9159   }
9160   xprof[ 8] = kForwUpHookWide/2;
9161   yprof[ 8] = yprof[7];
9162   xprof[ 9] = xprof[8];
9163   alpha = TMath::ASin(0.5*kForwUpHookWide/kForwUpHookRext);
9164   yprof[ 9] = kForwUpHookRext*TMath::Cos(alpha);
9165   xprof[10] = kForwUpHookRext*TMath::Sin(alpha/2);
9166   yprof[10] = kForwUpHookRext*TMath::Cos(alpha/2);
9167   xprof[11] = 0;
9168   yprof[11] = kForwUpHookRext;
9169
9170   // We did the right side, now reflex on the left side
9171   for (Int_t jp = 0; jp < kNumberOfForwUpHookPts; jp++) {
9172     xprof[12+jp] = -xprof[10-jp];
9173     yprof[12+jp] =  yprof[10-jp];
9174   }
9175
9176   // Now the actual Xtru
9177   forwUpHookMainBody->DefinePolygon(2*kNumberOfForwUpHookPts+1, xprof, yprof);
9178   forwUpHookMainBody->DefineSection(0, 0);
9179   forwUpHookMainBody->DefineSection(1, kForwUpHookThick);
9180
9181   // The hole
9182   TGeoXtru *forwUpHookHole = new TGeoXtru(2);
9183   forwUpHookHole->SetName("ITSforwUpHookHole");
9184
9185   xprof[0] = kForwUpHookHoleBase/2;
9186   yprof[0] = forwUpHookMainBody->GetY(0) + kForwUpHookHoleY;
9187   xprof[1] = kForwUpHookHoleWide/2;
9188   yprof[1] = yprof[0] + (xprof[1] - xprof[0]); // Go at 45deg
9189   xprof[2] = xprof[1];
9190   yprof[2] = yprof[0] + kForwUpHookHoleHi - kForwUpHookHoleR5;
9191   xprof[3] = xprof[2] - kForwUpHookHoleR5*(1 - CosD(45));
9192   yprof[3] = yprof[2] + kForwUpHookHoleR5*SinD(45);
9193   xprof[4] = xprof[2] - kForwUpHookHoleR5;
9194   yprof[4] = yprof[0] + kForwUpHookHoleHi;
9195
9196   // We did the right side, now reflex on the left side
9197   for (Int_t jp = 0; jp < kNumbOfForwUpHookHolePts; jp++) {
9198     xprof[5+jp] = -xprof[4-jp];
9199     yprof[5+jp] =  yprof[4-jp];
9200   }
9201
9202   // Now the actual Xtru
9203   forwUpHookHole->DefinePolygon(2*kNumbOfForwUpHookHolePts, xprof, yprof);
9204   forwUpHookHole->DefineSection(0, -0.1);
9205   forwUpHookHole->DefineSection(1, kForwUpHookThick+0.1);
9206
9207   // The hollow
9208   TGeoBBox *forwUpHookHollow = new TGeoBBox(2.1 *kForwUpHookHalfBase,
9209                                             0.55*kForwUpHookHollowHi,
9210                                             0.55*kForwUpHookHollowWide);
9211   forwUpHookHollow->SetName("ITSforwUpHookHollow");
9212
9213   TGeoTranslation *forwUpHookHollPos = new TGeoTranslation(0.,
9214                       forwUpHookMainBody->GetY(0) + 0.5*kForwUpHookHollowHi,
9215                       forwUpHookMainBody->GetZ(1) - 0.5*kForwUpHookHollowWide);
9216   forwUpHookHollPos->SetName("ITSforwUpHookHollPos");
9217   forwUpHookHollPos->RegisterYourself();
9218
9219   // Finally the actual shape: a CompositeShape
9220   TGeoCompositeShape *forwUpHookShape = new TGeoCompositeShape("ITSforwUpHookMainBody-ITSforwUpHookHole-ITSforwUpHookHollow:ITSforwUpHookHollPos");
9221
9222   // The Forward Lower Hook (0872/C/08): a Composite Shape made of
9223   // a really complex Xtru to approximate the arc with a polyline,
9224   // another Xtru for the hole, and a BBox for the hollow
9225   // The main body
9226   TGeoXtru *forwLwHookMainBody = new TGeoXtru(2);
9227   forwLwHookMainBody->SetName("ITSforwLwHookMainBody");
9228
9229   xprof[ 0] = kForwLwHookHalfBase - kForwLwHookBaseCut;
9230   yprof[ 0] = kForwLwHookRext - kForwLwHookHiTot;
9231   xprof[ 1] = kForwLwHookHalfBase;
9232   yprof[ 1] = yprof[0] + kForwLwHookBaseCut;
9233   xprof[ 2] = xprof[1];
9234   yprof[ 2] = yprof[0] + (kForwLwHookHollowHi - kForwLwHookYToHollow
9235                           - kForwLwHookRint);
9236   for (Int_t j=1; j<6; j++) {
9237     xprof[2+j] = xprof[2] + kForwLwHookRint*(1 - CosD(90*j/5));
9238     yprof[2+j] = yprof[2] + kForwLwHookRint*SinD(90*j/5);
9239   }
9240   xprof[ 8] = kForwLwHookWide/2;
9241   yprof[ 8] = yprof[7];
9242   xprof[ 9] = xprof[8];
9243   alpha = TMath::ASin(0.5*kForwLwHookWide/kForwLwHookRext);
9244   yprof[ 9] = kForwLwHookRext*TMath::Cos(alpha);
9245   xprof[10] = kForwLwHookRext*TMath::Sin(alpha/2);
9246   yprof[10] = kForwLwHookRext*TMath::Cos(alpha/2);
9247   xprof[11] = 0;
9248   yprof[11] = kForwLwHookRext;
9249
9250   // We did the right side, now reflex on the left side
9251   for (Int_t jp = 0; jp < kNumberOfForwLwHookPts; jp++) {
9252     xprof[12+jp] = -xprof[10-jp];
9253     yprof[12+jp] =  yprof[10-jp];
9254   }
9255
9256   // Now the actual Xtru
9257   forwLwHookMainBody->DefinePolygon(2*kNumberOfForwLwHookPts+1, xprof, yprof);
9258   forwLwHookMainBody->DefineSection(0, 0);
9259   forwLwHookMainBody->DefineSection(1, kForwLwHookThick);
9260
9261   // The hole
9262   TGeoXtru *forwLwHookHole = new TGeoXtru(2);
9263   forwLwHookHole->SetName("ITSforwLwHookHole");
9264
9265   xprof[0] = 0;
9266   yprof[0] = forwLwHookMainBody->GetY(0) + kForwLwHookHoleYPos
9267            - kForwLwHookHoleR;
9268   for (Int_t j=1; j<3; j++) {
9269     xprof[0+j] = xprof[0] + kForwLwHookHoleR*SinD(90*j/3);
9270     yprof[0+j] = yprof[0] + kForwLwHookHoleR*(1 - CosD(90*j/3));
9271   }
9272   xprof[3] = xprof[0] + kForwLwHookHoleR;
9273   yprof[3] = yprof[0] + kForwLwHookHoleR;
9274   xprof[4] = xprof[3];
9275   yprof[4] = yprof[3] + kForwLwHookHoleIntHi;
9276   for (Int_t j=1; j<3; j++) {
9277     xprof[4+j] = xprof[4] - kForwLwHookHoleR*(1 - CosD(90*j/3));
9278     yprof[4+j] = yprof[4] + kForwLwHookHoleR*SinD(90*j/3);
9279   }
9280   xprof[7] = xprof[0];
9281   yprof[7] = yprof[4] + kForwLwHookHoleR;
9282
9283   // We did the right side, now reflex on the left side
9284   for (Int_t jp = 0; jp < kNumbOfForwLwHookHolePts-1; jp++) {
9285     xprof[8+jp] = -xprof[6-jp];
9286     yprof[8+jp] =  yprof[6-jp];
9287   }
9288
9289   // Now the actual Xtru
9290   forwLwHookHole->DefinePolygon(2*kNumbOfForwLwHookHolePts, xprof, yprof);
9291   forwLwHookHole->DefineSection(0, -0.1);
9292   forwLwHookHole->DefineSection(1, kForwLwHookThick+0.1);
9293
9294   // The hollow
9295   TGeoBBox *forwLwHookHollow = new TGeoBBox(2.1 *kForwLwHookHalfBase,
9296                                             0.55*kForwLwHookHollowHi,
9297                                             0.55*kForwLwHookHollowWide);
9298   forwLwHookHollow->SetName("ITSforwLwHookHollow");
9299
9300   TGeoTranslation *forwLwHookHollPos = new TGeoTranslation(0.,
9301                       forwLwHookMainBody->GetY(0) + 0.5*kForwLwHookHollowHi,
9302                       forwLwHookMainBody->GetZ(1) - 0.5*kForwLwHookHollowWide);
9303   forwLwHookHollPos->SetName("ITSforwLwHookHollPos");
9304   forwLwHookHollPos->RegisterYourself();
9305
9306   // Finally the actual shape: a CompositeShape
9307   TGeoCompositeShape *forwLwHookShape = new TGeoCompositeShape("ITSforwLwHookMainBody-ITSforwLwHookHole-ITSforwLwHookHollow:ITSforwLwHookHollPos");
9308
9309   // The Rear Upper Hook (0872/C/10): a Composite Shape made of
9310   // a really complex Xtru to approximate the arc with a polyline,
9311   // and another Xtru for the hole
9312   // The main body
9313   TGeoXtru *rearUpHookMainBody = new TGeoXtru(2);
9314   rearUpHookMainBody->SetName("ITSrearUpHookMainBody");
9315
9316   xprof[0] = kRearUpHookHalfBase;
9317   yprof[0] = kRearUpHookRext - kRearUpHookHiTot;
9318   xprof[1] = xprof[0];
9319   yprof[1] = yprof[0] + (kRearUpHookHiInt - kRearUpHookRint); 
9320   for (Int_t j=1; j<6; j++) {
9321     xprof[1+j] = xprof[1] + kRearUpHookRint*(1 - CosD(90*j/5));
9322     yprof[1+j] = yprof[1] + kRearUpHookRint*SinD(90*j/5);
9323   }
9324   xprof[ 7] = kRearUpHookWide/2;
9325   yprof[ 7] = yprof[5];
9326   xprof[ 8] = xprof[7];
9327   alpha = TMath::ASin(0.5*kRearUpHookWide/kRearUpHookRext);
9328   yprof[ 8] = kRearUpHookRext*TMath::Cos(alpha);
9329   xprof[ 9] = kRearUpHookRext*TMath::Sin(alpha/2);
9330   yprof[ 9] = kRearUpHookRext*TMath::Cos(alpha/2);
9331   xprof[10] = 0;
9332   yprof[10] = kRearUpHookRext;
9333
9334   // We did the right side, now reflex on the left side
9335   for (Int_t jp = 0; jp < kNumberOfRearUpHookPts; jp++) {
9336     xprof[11+jp] = -xprof[9-jp];
9337     yprof[11+jp] =  yprof[9-jp];
9338   }
9339
9340   // Now the actual Xtru
9341   rearUpHookMainBody->DefinePolygon(2*kNumberOfRearUpHookPts+1, xprof, yprof);
9342   rearUpHookMainBody->DefineSection(0, 0);
9343   rearUpHookMainBody->DefineSection(1, kRearUpHookThick);
9344
9345   // The hole
9346   TGeoXtru *rearUpHookHole = new TGeoXtru(2);
9347   rearUpHookHole->SetName("ITSrearUpHookHole");
9348
9349   xprof[0] = kRearUpHookHoleBase/2;
9350   yprof[0] = rearUpHookMainBody->GetY(0) + kRearUpHookHoleY;
9351   xprof[1] = kRearUpHookHoleWide/2;
9352   yprof[1] = yprof[0] + (xprof[1] - xprof[0]); // Go at 45deg
9353   xprof[2] = xprof[1];
9354   yprof[2] = yprof[0] + kRearUpHookHoleHi - kRearUpHookHoleR5;
9355   xprof[3] = xprof[2] - kRearUpHookHoleR5*(1 - CosD(45));
9356   yprof[3] = yprof[2] + kRearUpHookHoleR5*SinD(45);
9357   xprof[4] = xprof[2] - kRearUpHookHoleR5;
9358   yprof[4] = yprof[0] + kRearUpHookHoleHi;
9359
9360   // We did the right side, now reflex on the left side
9361   for (Int_t jp = 0; jp < kNumbOfRearUpHookHolePts; jp++) {
9362     xprof[5+jp] = -xprof[4-jp];
9363     yprof[5+jp] =  yprof[4-jp];
9364   }
9365
9366   // Now the actual Xtru
9367   rearUpHookHole->DefinePolygon(2*kNumbOfRearUpHookHolePts, xprof, yprof);
9368   rearUpHookHole->DefineSection(0, -0.1);
9369   rearUpHookHole->DefineSection(1, kRearUpHookThick+0.1);
9370
9371   // Finally the actual shape: a CompositeShape
9372   TGeoCompositeShape *rearUpHookShape = new TGeoCompositeShape("ITSrearUpHookMainBody-ITSrearUpHookHole");
9373
9374   // The Rear Lower Hook (0872/C/11): a Xtru
9375   TGeoXtru *rearLwHookShape = new TGeoXtru(2);
9376   rearLwHookShape->SetName("ITSrearLwHookShape");
9377
9378   xprof[0] = kRearLwHookWide/2;
9379   yprof[0] = kRearLwHookRext - kRearLwHookHiTot;
9380   xprof[1] = xprof[0];
9381   alpha = TMath::ASin(0.5*kRearLwHookWide/kRearLwHookRext);
9382   yprof[1] = kRearLwHookRext*TMath::Cos(alpha);
9383   xprof[2] = kRearLwHookRext*TMath::Sin(alpha/2);
9384   yprof[2] = kRearLwHookRext*TMath::Cos(alpha/2);
9385   xprof[3] = 0;
9386   yprof[3] = kRearLwHookRext;
9387
9388   // We did the right side, now reflex on the left side
9389   for (Int_t jp = 0; jp < kNumberOfRearLwHookPts; jp++) {
9390     xprof[4+jp] = -xprof[2-jp];
9391     yprof[4+jp] =  yprof[2-jp];
9392   }
9393
9394   // Now the actual Xtru
9395   rearLwHookShape->DefinePolygon(2*kNumberOfRearLwHookPts+1, xprof, yprof);
9396   rearLwHookShape->DefineSection(0, 0);
9397   rearLwHookShape->DefineSection(1, kRearLwHookThick);
9398
9399   // The Rear Lower Bracket (0872/C/16): a Xtru
9400   TGeoXtru *rearLwBrackShape = new TGeoXtru(2);
9401   rearLwBrackShape->SetName("ITSrearLwBrackShape");
9402
9403   xprof[0] = 0;
9404   yprof[0] = 0;
9405   xprof[1] = xprof[0] + kRearLwBracketWide1 - kRearLwBracketWide2;
9406   yprof[1] = yprof[0];
9407   xprof[2] = xprof[1];
9408   yprof[2] = yprof[0] + kRearLwBracketHi2;
9409   xprof[3] = xprof[2] - kRearLwBracketWide1;
9410   yprof[3] = yprof[2];
9411   xprof[4] = xprof[3];
9412   yprof[4] = yprof[3] - kRearLwBracketHi1;
9413   xprof[5] = xprof[0];
9414   yprof[5] = yprof[4];
9415
9416   rearLwBrackShape->DefinePolygon(6, xprof, yprof);
9417   rearLwBrackShape->DefineSection(0,-kRearLwBracketThick/2);
9418   rearLwBrackShape->DefineSection(1, kRearLwBracketThick/2);
9419
9420   // The Forward S-shaped Stirrup for the webcam (0872/C/V/01): a Xtru
9421   TGeoXtru *forwWebSStirrSh = new TGeoXtru(2);
9422
9423   xprof[0] = 0;
9424   yprof[0] = 0;
9425   xprof[1] = xprof[0] + kForwWebSStirrLen1;
9426   yprof[1] = yprof[0];
9427   xprof[2] = xprof[1];
9428   yprof[2] = yprof[1] + kForwWebSStirrWide1;
9429   xprof[3] = xprof[0] - kForwWebSStirrLen2 + kForwWebSStirrLen3;
9430   yprof[3] = yprof[2];
9431   xprof[4] = xprof[3];
9432   yprof[4] = yprof[3] + kForwWebSStirrWide3;
9433   xprof[5] = xprof[4] - kForwWebSStirrLen3;
9434   yprof[5] = yprof[4];
9435   xprof[6] = xprof[5];
9436   yprof[6] = yprof[0] + kForwWebSStirrWide2;
9437   xprof[7] = xprof[0];
9438   yprof[7] = yprof[6];
9439
9440   forwWebSStirrSh->DefinePolygon(8, xprof, yprof);
9441   forwWebSStirrSh->DefineSection(0,-kForwWebSStirrDep/2);
9442   forwWebSStirrSh->DefineSection(1, kForwWebSStirrDep/2);
9443
9444   // The Forward T-shaped Stirrups for the webcam (0872/C/V/03-04): two Xtru
9445   TGeoXtru *forwWebTStirr3Sh = new TGeoXtru(2);
9446
9447   xprof[0] = -kForwWebTStirrWide2/2;
9448   yprof[0] = 0;
9449   xprof[1] = -kForwWebTStirrWide1/2;
9450   yprof[1] = yprof[0];
9451   xprof[2] = xprof[1];
9452   yprof[2] = yprof[1] - kForwWebTStirrLen1;
9453   xprof[3] =-xprof[2];
9454   yprof[3] = yprof[2];
9455   xprof[4] = xprof[3];
9456   yprof[4] = yprof[1];
9457   xprof[5] =-xprof[0];
9458   yprof[5] = yprof[4];
9459   xprof[6] = xprof[5];
9460   yprof[6] = kForwWebTStirrTotLen3 - kForwWebTStirrLen1;
9461   xprof[7] = xprof[0];
9462   yprof[7] = yprof[6];
9463
9464   forwWebTStirr3Sh->DefinePolygon(8, xprof, yprof);
9465   forwWebTStirr3Sh->DefineSection(0, 0);
9466   forwWebTStirr3Sh->DefineSection(1, kForwWebTStirrThick);
9467
9468   TGeoXtru *forwWebTStirr4Sh = new TGeoXtru(2);
9469
9470   yprof[6] = kForwWebTStirrTotLen4 - kForwWebTStirrLen1;
9471   yprof[7] = yprof[6];
9472
9473   forwWebTStirr4Sh->DefinePolygon(8, xprof, yprof);
9474   forwWebTStirr4Sh->DefineSection(0, 0);
9475   forwWebTStirr4Sh->DefineSection(1, kForwWebTStirrThick);
9476
9477   // The Forward and Rear clamp for the webcam (0872/C/V/02): a Xtru
9478   TGeoXtru *frWebClampSh = new TGeoXtru(2);
9479
9480   xprof[0] = kFRWebClampIntWide/2;
9481   yprof[0] = kFRWebClampIntHi;
9482   xprof[1] = xprof[0];
9483   yprof[1] = 0;
9484   xprof[2] = kFRWebClampExtWide/2;
9485   yprof[2] = yprof[1];
9486   xprof[3] = xprof[2];
9487   yprof[3] = kFRWebClampExtHi;
9488   for (Int_t jp = 0; jp < 4; jp++) {
9489     xprof[4+jp] = -xprof[3-jp];
9490     yprof[4+jp] =  yprof[3-jp];
9491   }
9492
9493   frWebClampSh->DefinePolygon(8, xprof, yprof);
9494   frWebClampSh->DefineSection(0,-kFRWebClampThick/2);
9495   frWebClampSh->DefineSection(1, kFRWebClampThick/2);
9496
9497   // The Rear Upper Stirrup for the webcam (0872/C/V/05): a Xtru
9498   TGeoXtru *upWebStirrSh = new TGeoXtru(2);
9499
9500   xprof[0] = 0;
9501   yprof[0] = 0;
9502   xprof[1] = xprof[0] - (kRearUpWebStirrWide - 2*kRearUpWebStirrThick);
9503   yprof[1] = yprof[0];
9504   xprof[2] = xprof[1];
9505   yprof[2] = yprof[1] + (kRearUpWebStirrH1 - kRearUpWebStirrThick);
9506   xprof[3] = xprof[2] - kRearUpWebStirrThick;
9507   yprof[3] = yprof[2];
9508   xprof[4] = xprof[3];
9509   yprof[4] = yprof[3] - kRearUpWebStirrH1;
9510   xprof[5] = xprof[4] + kRearUpWebStirrWide;
9511   yprof[5] = yprof[4];
9512   xprof[6] = xprof[5];
9513   yprof[6] = yprof[5] + kRearUpWebStirrH2;
9514   xprof[7] = xprof[0];
9515   yprof[7] = yprof[6];
9516
9517   upWebStirrSh->DefinePolygon(8, xprof, yprof);
9518   upWebStirrSh->DefineSection(0,-kRearUpWebStirrDep/2);
9519   upWebStirrSh->DefineSection(1, kRearUpWebStirrDep/2);
9520
9521   // The Rear Upper Bar for the webcam (0872/C/V/06): a BBox
9522   TGeoBBox *upRearWebBarSh = new TGeoBBox(kRearUpWebBarLen/2,
9523                                           kRearUpWebBarHi/2,
9524                                           kRearUpWebBarThick/2);
9525
9526   // The Webcam: a BBox
9527   TGeoBBox *webcamShape = new TGeoBBox(kFRWebClampIntWide/2,
9528                                        kWebcamLength/2,
9529                                        kFRWebClampIntHi/2);
9530
9531   // The Upper Wheel Slide (0872/C/Z/00-01-02)
9532   // A mother volume of air (to avoid assembly) contains the Alluminum block
9533   // (a Composite Shape: a Xtru and a Pcon for the hole) and the Steel pin
9534   // (a Pcon) (The wheels are approximated as part of the block itself)
9535   // The Air mother volume
9536   TGeoXtru *upSlideAirSh = new TGeoXtru(2);
9537   upSlideAirSh->SetName("ITSupperSlideAirShape");
9538
9539   xprof[0] = 0;
9540   yprof[0] = 0;
9541   xprof[1] = xprof[0];
9542   yprof[1] = kUpperSlideBlockHi + kUpperSlideStubHi - kUpperSlideWheelHi;
9543   xprof[2] = xprof[1] - kUpperSlideIntDepth;
9544   yprof[2] = yprof[1];
9545   xprof[3] = xprof[2];
9546   yprof[3] = yprof[2] - kUpperSlideTotHeight;
9547   xprof[4] = xprof[3] + kUpperSlideTotDepth;
9548   yprof[4] = yprof[3];
9549   xprof[5] = xprof[4];
9550   yprof[5] = yprof[0];
9551
9552   upSlideAirSh->DefinePolygon(6, xprof, yprof);
9553   upSlideAirSh->DefineSection(0,-kUpperSlideWidth/2);
9554   upSlideAirSh->DefineSection(1, kUpperSlideWidth/2);
9555
9556   // The (filled) Aluminum block: a Xtru
9557   TGeoXtru *upSlideAluSh = new TGeoXtru(2);
9558   upSlideAluSh->SetName("ITSupperSlideAluShape");
9559
9560   xprof[0] = upSlideAirSh->GetX(0);
9561   yprof[0] = upSlideAirSh->GetY(0);
9562   xprof[1] = upSlideAirSh->GetX(1);
9563   yprof[1] = upSlideAirSh->GetY(1);
9564   xprof[2] = xprof[1] - kUpperSlideStubDep;
9565   yprof[2] = yprof[1];
9566   xprof[3] = xprof[2];
9567   yprof[3] = yprof[2] - kUpperSlideStubHi;
9568   xprof[4] = upSlideAirSh->GetX(2);
9569   yprof[4] = yprof[3];
9570   xprof[5] = xprof[4];
9571   yprof[5] = yprof[4] - kUpperSlideBlockHi;
9572   xprof[6] = upSlideAirSh->GetX(5);
9573   yprof[6] = yprof[5];
9574   xprof[7] = xprof[6];
9575   yprof[7] = yprof[0];
9576
9577   upSlideAluSh->DefinePolygon(8, xprof, yprof);
9578   upSlideAluSh->DefineSection(0, upSlideAirSh->GetZ(0));
9579   upSlideAluSh->DefineSection(1, upSlideAirSh->GetZ(1));
9580
9581   // The cylindrical hole in the block; a Pcon
9582   TGeoPcon *upSlideHoleSh = new TGeoPcon(0, 360, 10);
9583   upSlideHoleSh->SetName("ITSupperSlideHoleShape");
9584
9585   zpos = upSlideAluSh->GetY(5);
9586   upSlideHoleSh->DefineSection(0, zpos-0.1, 0, kUpperSlideHoleRout);
9587   zpos += (kUpperSlideBlockHi - kUpperSlideHoleH3 - kUpperSlideHoleH2
9588         - 2*kUpperSlideHoleH1);
9589   upSlideHoleSh->DefineSection(1, zpos, 0, kUpperSlideHoleRout);
9590   upSlideHoleSh->DefineSection(2, zpos, 0, kUpperSlideHoleRint2);
9591   zpos += kUpperSlideHoleH3;
9592   upSlideHoleSh->DefineSection(3, zpos, 0, kUpperSlideHoleRint2);
9593   upSlideHoleSh->DefineSection(4, zpos, 0, kUpperSlideHoleRout);
9594   zpos += kUpperSlideHoleH1;
9595   upSlideHoleSh->DefineSection(5, zpos, 0, kUpperSlideHoleRout);
9596   upSlideHoleSh->DefineSection(6, zpos, 0, kUpperSlideHoleRint1);
9597   zpos += kUpperSlideHoleH2;
9598   upSlideHoleSh->DefineSection(7, zpos, 0, kUpperSlideHoleRint1);
9599   upSlideHoleSh->DefineSection(8, zpos, 0, kUpperSlideHoleRout);
9600   zpos += kUpperSlideHoleH1;
9601   upSlideHoleSh->DefineSection(9, zpos+0.1, 0, kUpperSlideHoleRout);
9602
9603   TGeoCombiTrans *upSlideHolePos = new TGeoCombiTrans(-kUpperSlideHoleXPos,0,0,
9604                                    new TGeoRotation("",0,-90,0) );
9605   upSlideHolePos->SetName("ITSupperSlideHolePos");
9606   upSlideHolePos->RegisterYourself();
9607
9608   // The actual block: a CompositeShape
9609   TGeoCompositeShape *upSlideBlockSh = new TGeoCompositeShape("ITSupperSlideAluShape-ITSupperSlideHoleShape:ITSupperSlideHolePos");
9610
9611   // The Steel pin in the block; a Pcon
9612   TGeoPcon *upSlidePinSh = new TGeoPcon(0, 360, 6);
9613   upSlidePinSh->SetName("ITSupperSlidePinShape");
9614
9615   zpos = upSlideAluSh->GetY(5) - (kUpperSlidePinH1 + kUpperSlidePinH2
9616        + kUpperSlidePinH3 - kUpperSlideBlockHi);
9617   upSlidePinSh->DefineSection(0, zpos, 0, kUpperSlidePinRmin);
9618   zpos += kUpperSlidePinH3;
9619   upSlidePinSh->DefineSection(1, zpos, 0, kUpperSlidePinRmin);
9620   upSlidePinSh->DefineSection(2, zpos, 0, kUpperSlidePinRmax);
9621   zpos += kUpperSlidePinH2;
9622   upSlidePinSh->DefineSection(3, zpos, 0, kUpperSlidePinRmax);
9623   upSlidePinSh->DefineSection(4, zpos, 0, kUpperSlidePinRmin);
9624   zpos += kUpperSlidePinH1;
9625   upSlidePinSh->DefineSection(5, zpos, 0, kUpperSlidePinRmin);
9626
9627   // The Lower Wheel Slide (0872/C/W/00-01-02-03)
9628   // A mother volume of air (to avoid assembly) contains the Alluminum block
9629   // (a Composite Shape: a Xtru and a Pcon for the hole), the Alluminum nose
9630   // (a Xtru) and the Steel pin (a Pcon)
9631   // (The wheels are approximated as part of the block itself)
9632   // The Air mother volume
9633   TGeoXtru *lwSlideAirSh = new TGeoXtru(2);
9634   lwSlideAirSh->SetName("ITSlowerSlideAirShape");
9635
9636   xprof[0] = 0;
9637   yprof[0] = 0;
9638   xprof[1] = xprof[0] + kLowerSlideTotDepth/2 - kLowerSlideNoseBase/2;
9639   yprof[1] = yprof[0];
9640   xprof[2] = xprof[1];
9641   yprof[2] = yprof[1] - (kLowerSlideBlockHi + kLowerSlidePinH2);
9642   xprof[3] = xprof[2] - kLowerSlideTotDepth;
9643   yprof[3] = yprof[2];
9644   xprof[4] = xprof[3];
9645   yprof[4] = yprof[3] + kLowerSlidePinH2 + kLowerSlideTotHeight;
9646   xprof[5] = xprof[0];
9647   yprof[5] = yprof[4];
9648
9649   lwSlideAirSh->DefinePolygon(6, xprof, yprof);
9650   lwSlideAirSh->DefineSection(0,-kLowerSlideWidth/2);
9651   lwSlideAirSh->DefineSection(1, kLowerSlideWidth/2);
9652
9653   // The (filled) Aluminum block: a Xtru
9654   TGeoXtru *lwSlideAluSh = new TGeoXtru(2);
9655   lwSlideAluSh->SetName("ITSlowerSlideAluShape");
9656
9657   xprof[0] = lwSlideAirSh->GetX(0);
9658   yprof[0] = lwSlideAirSh->GetY(0);
9659   xprof[1] = lwSlideAirSh->GetX(1);
9660   yprof[1] = lwSlideAirSh->GetY(1);
9661   xprof[2] = xprof[1];
9662   yprof[2] = yprof[1] - kLowerSlideBlockHi;
9663   xprof[3] = lwSlideAirSh->GetX(3);
9664   yprof[3] = yprof[2];
9665   xprof[4] = xprof[3];
9666   yprof[4] = yprof[3] + kLowerSlideBlockHi;
9667   xprof[5] = xprof[4] + kLowerSlideTotDepth/2;
9668   yprof[5] = yprof[4];
9669   xprof[6] = xprof[5];
9670   yprof[6] = lwSlideAirSh->GetY(4);
9671   xprof[7] = xprof[0];
9672   yprof[7] = yprof[6];
9673
9674   lwSlideAluSh->DefinePolygon(8, xprof, yprof);
9675   lwSlideAluSh->DefineSection(0, lwSlideAirSh->GetZ(0));
9676   lwSlideAluSh->DefineSection(1, lwSlideAirSh->GetZ(1));
9677
9678   // The cylindrical hole in the block; a Pcon
9679   TGeoPcon *lwSlideHoleSh = new TGeoPcon(0, 360, 4);
9680   lwSlideHoleSh->SetName("ITSlowerSlideHoleShape");
9681
9682   zpos = lwSlideAluSh->GetY(2);
9683   lwSlideHoleSh->DefineSection(0, zpos-0.1, 0, kLowerSlideHoleRout);
9684   zpos += kLowerSlideHoleH1;
9685   lwSlideHoleSh->DefineSection(1, zpos, 0, kLowerSlideHoleRout);
9686   lwSlideHoleSh->DefineSection(2, zpos, 0, kLowerSlideHoleRint);
9687   zpos = lwSlideAluSh->GetY(4);
9688   lwSlideHoleSh->DefineSection(3, zpos, 0, kLowerSlideHoleRint);
9689
9690   TGeoCombiTrans *lwSlideHolePos = new TGeoCombiTrans(lwSlideAluSh->GetX(5),
9691                                                       0, 0,
9692                                    new TGeoRotation("",0,-90,0) );
9693   lwSlideHolePos->SetName("ITSlowerSlideHolePos");
9694   lwSlideHolePos->RegisterYourself();
9695
9696   // The actual block: a CompositeShape
9697   TGeoCompositeShape *lwSlideBlockSh = new TGeoCompositeShape("ITSlowerSlideAluShape-ITSlowerSlideHoleShape:ITSlowerSlideHolePos");
9698
9699   // The Aluminum nose: a Xtru
9700   TGeoXtru *lwSlideNoseSh = new TGeoXtru(2);
9701   lwSlideNoseSh->SetName("ITSlowerSlideNoseShape");
9702
9703   xprof[0] = lwSlideAluSh->GetX(5);
9704   yprof[0] = lwSlideAluSh->GetY(5);
9705   xprof[1] = xprof[0] - kLowerSlideNoseBase/2;
9706   yprof[1] = yprof[0];
9707   xprof[2] = xprof[1];
9708   yprof[2] = yprof[1] + kLowerSlideNoseBasHi;
9709   xprof[3] = lwSlideAluSh->GetX(0) - kLowerSlideNoseUpWid;
9710   yprof[3] = lwSlideAluSh->GetY(6);
9711   xprof[4] = xprof[0];
9712   yprof[4] = yprof[3];
9713
9714   lwSlideNoseSh->DefinePolygon(5, xprof, yprof);
9715   lwSlideNoseSh->DefineSection(0,-kLowerSlideNoseDepth/2);
9716   lwSlideNoseSh->DefineSection(1, kLowerSlideNoseDepth/2);
9717
9718   // The Steel pin in the block; a Pcon
9719   TGeoPcon *lwSlidePinSh = new TGeoPcon(0, 360, 4);
9720   lwSlidePinSh->SetName("ITSlowerSlidePinShape");
9721
9722   zpos = lwSlideAirSh->GetY(2);
9723   lwSlidePinSh->DefineSection(0, zpos, 0, kLowerSlidePinRmax);
9724   zpos += kLowerSlidePinH2;
9725   lwSlidePinSh->DefineSection(1, zpos, 0, kLowerSlidePinRmax);
9726   lwSlidePinSh->DefineSection(2, zpos, 0, kLowerSlidePinRmin);
9727   zpos += kLowerSlidePinH1;
9728   lwSlidePinSh->DefineSection(3, zpos, 0, kLowerSlidePinRmin);
9729
9730   // The Stirrup on the Muon side (0872/C/01-02): a really complex Xtru
9731   // to approximate arcs with polylines
9732   TGeoXtru *stirrupC1C2Sh = new TGeoXtru(2);
9733
9734   for (Int_t j=0; j<11; j++) { // The internal arc
9735     xprof[j] = kStirrC12R50*(1 - CosD(90*j/10));
9736     yprof[j] = kStirrC12R50*SinD(90*j/10);
9737   }
9738
9739   xprof[11] = xprof[10] + kStirrC12TailLen;
9740   yprof[11] = yprof[10];
9741   xprof[12] = xprof[11];
9742   yprof[12] = kStirrC12BodyHalfHi;
9743   xprof[13] = xprof[12] - kStirrC12BodyLen;
9744   yprof[13] = yprof[12];
9745
9746   xprof[17] = xprof[12] - kStirrC12TotLen + kStirrC12HeadLen;
9747   yprof[17] = kStirrC12HeadHalfHi;
9748   IntersectCircle(-TanD(kStirrC12HeadAng), xprof[17], yprof[17],
9749                   kStirrC12R100, xprof[13], yprof[13]+kStirrC12R100,
9750                   xprof[16], yprof[16], xdummy, ydummy);
9751   alpha = TMath::ASin((xprof[13]-xprof[16])/kStirrC12R100);
9752   xprof[14] = xprof[13] - kStirrC12R100*TMath::Sin(alpha/3);
9753   yprof[14] = yprof[13] + kStirrC12R100*(1 - TMath::Cos(alpha/3));
9754   xprof[15] = xprof[13] - kStirrC12R100*TMath::Sin(2*alpha/3);
9755   yprof[15] = yprof[13] + kStirrC12R100*(1 - TMath::Cos(2*alpha/3));
9756
9757   xprof[18] = xprof[17] - kStirrC12HeadLen;
9758   yprof[18] = yprof[17];
9759   xprof[19] = xprof[18];
9760   yprof[19] = kStirrC12HeadIntHi;
9761   xprof[20] = xprof[19] + kStirrC12HeadIntLen - kStirrC12R10;
9762   yprof[20] = yprof[19];
9763   for (Int_t j=1; j<4; j++) {
9764     xprof[20+j] = xprof[20] + kStirrC12R10*SinD(90*j/3);
9765     yprof[20+j] = yprof[20] - kStirrC12R10*(1 - CosD(90*j/3));
9766   }
9767
9768   // We did the up side, now reflex on the bottom side
9769   for (Int_t jp = 0; jp < kNumberOfStirrCPoints; jp++) {
9770     xprof[24+jp] =  xprof[23-jp];
9771     yprof[24+jp] = -yprof[23-jp];
9772   }
9773
9774   // Now the actual Xtru
9775   stirrupC1C2Sh->DefinePolygon(2*kNumberOfStirrCPoints+1, xprof, yprof);
9776   stirrupC1C2Sh->DefineSection(0,-kStirrC12Thick/2);
9777   stirrupC1C2Sh->DefineSection(1, kStirrC12Thick/2);
9778
9779   // The first element of the Stirrup on the Forward side (0872/C/05):
9780   // a really complex Xtru (equal to part of the Muon Stirrup)
9781   // (0872/C/06 and 0872/C/07 are dismounted after positioning the TPC to I.P.)
9782   TGeoXtru *stirrupC5Sh = new TGeoXtru(2);
9783
9784   for (Int_t j=0; j<13; j++) { // The internal arc and the tail
9785     xprof[j] = stirrupC1C2Sh->GetX(j);
9786     yprof[j] = stirrupC1C2Sh->GetY(j);
9787   }
9788
9789   xprof[13] = xprof[12] - kStirrC5BodyLen;
9790   yprof[13] = yprof[12];
9791
9792   // We did the up side, now reflex on the bottom side
9793   for (Int_t jp = 0; jp < 13; jp++) {
9794     xprof[14+jp] =  xprof[13-jp];
9795     yprof[14+jp] = -yprof[13-jp];
9796   }
9797
9798   // Now the actual Xtru
9799   stirrupC5Sh->DefinePolygon(27, xprof, yprof);
9800   stirrupC5Sh->DefineSection(0,-kStirrC12Thick/2);
9801   stirrupC5Sh->DefineSection(1, kStirrC12Thick/2);
9802
9803
9804   // We have all shapes: now create the real volumes
9805   TGeoMedium *medAlcoa   = mgr->GetMedium("ITS_ALUMINUM$"); // To code!!!!!!
9806   TGeoMedium *medHokotol = mgr->GetMedium("ITS_HOKOTOL$");
9807   TGeoMedium *medAnticor = mgr->GetMedium("ITS_ANTICORODAL$");
9808   TGeoMedium *medErgal   = mgr->GetMedium("ITS_ERGAL$");
9809   TGeoMedium *medAisi    = mgr->GetMedium("ITS_AISI304L$");
9810   TGeoMedium *medAir     = mgr->GetMedium("ITS_AIR$");
9811   TGeoMedium *medPlexy   = mgr->GetMedium("ITS_PLEXYGLAS$");
9812   TGeoMedium *medPVC     = mgr->GetMedium("ITS_PVC$");
9813
9814
9815   TGeoVolume *suppRingC2C3  = new TGeoVolume("ITSTPCsupportRingC2C3",
9816                                              ringC2C3, medAlcoa);
9817
9818   suppRingC2C3->SetVisibility(kTRUE);
9819   suppRingC2C3->SetLineColor(6); // Purple
9820   suppRingC2C3->SetLineWidth(1);
9821   suppRingC2C3->SetFillColor(suppRingC2C3->GetLineColor());
9822   suppRingC2C3->SetFillStyle(4000); // 0% transparent
9823
9824   TGeoVolume *forwUpHook  = new TGeoVolume("ITSTPCsupportForwUpHook",
9825                                            forwUpHookShape, medHokotol);
9826
9827   forwUpHook->SetVisibility(kTRUE);
9828   forwUpHook->SetLineColor(6); // Purple
9829   forwUpHook->SetLineWidth(1);
9830   forwUpHook->SetFillColor(forwUpHook->GetLineColor());
9831   forwUpHook->SetFillStyle(4000); // 0% transparent
9832
9833   TGeoVolume *forwLwHook  = new TGeoVolume("ITSTPCsupportForwLwHook",
9834                                            forwLwHookShape, medHokotol);
9835
9836   forwLwHook->SetVisibility(kTRUE);
9837   forwLwHook->SetLineColor(6); // Purple
9838   forwLwHook->SetLineWidth(1);
9839   forwLwHook->SetFillColor(forwLwHook->GetLineColor());
9840   forwLwHook->SetFillStyle(4000); // 0% transparent
9841
9842   TGeoVolume *rearUpHook  = new TGeoVolume("ITSTPCsupportRearUpHook",
9843                                            rearUpHookShape, medHokotol);
9844
9845   rearUpHook->SetVisibility(kTRUE);
9846   rearUpHook->SetLineColor(6); // Purple
9847   rearUpHook->SetLineWidth(1);
9848   rearUpHook->SetFillColor(rearUpHook->GetLineColor());
9849   rearUpHook->SetFillStyle(4000); // 0% transparent
9850
9851   TGeoVolume *rearLwHook  = new TGeoVolume("ITSTPCsupportRearLwHook",
9852                                            rearLwHookShape, medAnticor);
9853
9854   rearLwHook->SetVisibility(kTRUE);
9855   rearLwHook->SetLineColor(6); // Purple
9856   rearLwHook->SetLineWidth(1);
9857   rearLwHook->SetFillColor(rearLwHook->GetLineColor());
9858   rearLwHook->SetFillStyle(4000); // 0% transparent
9859
9860   TGeoVolume *rearLwBrack  = new TGeoVolume("ITSTPCsupportRearLwBracket",
9861                                             rearLwBrackShape, medAnticor);
9862
9863   rearLwBrack->SetVisibility(kTRUE);
9864   rearLwBrack->SetLineColor(6); // Purple
9865   rearLwBrack->SetLineWidth(1);
9866   rearLwBrack->SetFillColor(rearLwBrack->GetLineColor());
9867   rearLwBrack->SetFillStyle(4000); // 0% transparent
9868
9869   TGeoVolume *forwWebSStirrup  = new TGeoVolume("ITSTPCsupportForwWebSStirrup",
9870                                                 forwWebSStirrSh, medAnticor);
9871
9872   forwWebSStirrup->SetVisibility(kTRUE);
9873   forwWebSStirrup->SetLineColor(6); // Purple
9874   forwWebSStirrup->SetLineWidth(1);
9875   forwWebSStirrup->SetFillColor(forwWebSStirrup->GetLineColor());
9876   forwWebSStirrup->SetFillStyle(4000); // 0% transparent
9877
9878   TGeoVolume *forwWebTStirr3  = new TGeoVolume("ITSTPCsupportForwWebTStirrup3",
9879                                                forwWebTStirr3Sh, medAnticor);
9880
9881   forwWebTStirr3->SetVisibility(kTRUE);
9882   forwWebTStirr3->SetLineColor(6); // Purple
9883   forwWebTStirr3->SetLineWidth(1);
9884   forwWebTStirr3->SetFillColor(forwWebTStirr3->GetLineColor());
9885   forwWebTStirr3->SetFillStyle(4000); // 0% transparent
9886
9887   TGeoVolume *forwWebTStirr4  = new TGeoVolume("ITSTPCsupportForwWebTStirrup4",
9888                                                forwWebTStirr4Sh, medAnticor);
9889
9890   forwWebTStirr4->SetVisibility(kTRUE);
9891   forwWebTStirr4->SetLineColor(6); // Purple
9892   forwWebTStirr4->SetLineWidth(1);
9893   forwWebTStirr4->SetFillColor(forwWebTStirr4->GetLineColor());
9894   forwWebTStirr4->SetFillStyle(4000); // 0% transparent
9895
9896   TGeoVolume *frWebClamp  = new TGeoVolume("ITSTPCsupportForwRearWebClamp",
9897                                            frWebClampSh, medPlexy);
9898
9899   frWebClamp->SetVisibility(kTRUE);
9900   frWebClamp->SetLineColor(kAzure);
9901   frWebClamp->SetLineWidth(1);
9902   frWebClamp->SetFillColor(frWebClamp->GetLineColor());
9903   frWebClamp->SetFillStyle(4000); // 0% transparent
9904
9905   TGeoVolume *upWebStirrup  = new TGeoVolume("ITSTPCsupportUpperWebStirrup",
9906                                              upWebStirrSh, medAnticor);
9907
9908   upWebStirrup->SetVisibility(kTRUE);
9909   upWebStirrup->SetLineColor(6); // Purple
9910   upWebStirrup->SetLineWidth(1);
9911   upWebStirrup->SetFillColor(upWebStirrup->GetLineColor());
9912   upWebStirrup->SetFillStyle(4000); // 0% transparent
9913
9914   TGeoVolume *upRearWebBar  = new TGeoVolume("ITSTPCsupportUpperRearWebBar",
9915                                              upRearWebBarSh, medPlexy);
9916
9917   upRearWebBar->SetVisibility(kTRUE);
9918   upRearWebBar->SetLineColor(kAzure);
9919   upRearWebBar->SetLineWidth(1);
9920   upRearWebBar->SetFillColor(upRearWebBar->GetLineColor());
9921   upRearWebBar->SetFillStyle(4000); // 0% transparent
9922
9923   TGeoVolume *webCam  = new TGeoVolume("ITSTPCsupportWebcam",
9924                                        webcamShape, medPVC);
9925
9926   webCam->SetVisibility(kTRUE);
9927   webCam->SetLineColor(kBlack);
9928   webCam->SetLineWidth(1);
9929   webCam->SetFillColor(webCam->GetLineColor());
9930   webCam->SetFillStyle(4000); // 0% transparent
9931
9932   TGeoVolume *upSlideVol  = new TGeoVolume("ITSTPCsupportUpperSlide",
9933                                            upSlideAirSh, medAir);
9934
9935   upSlideVol->SetVisibility(kFALSE);
9936
9937   TGeoVolume *upSlideBlock  = new TGeoVolume("ITSTPCsupportUpperSlideBlock",
9938                                              upSlideBlockSh, medAnticor);
9939
9940   upSlideBlock->SetVisibility(kTRUE);
9941   upSlideBlock->SetLineColor(6); // Purple
9942   upSlideBlock->SetLineWidth(1);
9943   upSlideBlock->SetFillColor(upSlideBlock->GetLineColor());
9944   upSlideBlock->SetFillStyle(4000); // 0% transparent
9945
9946   TGeoVolume *upSlidePin  = new TGeoVolume("ITSTPCsupportUpperSlidePin",
9947                                            upSlidePinSh, medAisi);
9948
9949   upSlidePin->SetVisibility(kTRUE);
9950   upSlidePin->SetLineColor(kGray);
9951   upSlidePin->SetLineWidth(1);
9952   upSlidePin->SetFillColor(upSlidePin->GetLineColor());
9953   upSlidePin->SetFillStyle(4000); // 0% transparent
9954
9955   TGeoVolume *lwSlideVol  = new TGeoVolume("ITSTPCsupportLowerSlide",
9956                                            lwSlideAirSh, medAir);
9957
9958   lwSlideVol->SetVisibility(kFALSE);
9959
9960   TGeoVolume *lwSlideBlock  = new TGeoVolume("ITSTPCsupportLowerSlideBlock",
9961                                              lwSlideBlockSh, medAnticor);
9962
9963   lwSlideBlock->SetVisibility(kTRUE);
9964   lwSlideBlock->SetLineColor(6); // Purple
9965   lwSlideBlock->SetLineWidth(1);
9966   lwSlideBlock->SetFillColor(lwSlideBlock->GetLineColor());
9967   lwSlideBlock->SetFillStyle(4000); // 0% transparent
9968
9969   TGeoVolume *lwSlideNose  = new TGeoVolume("ITSTPCsupportLowerSlideNose",
9970                                             lwSlideNoseSh, medAnticor);
9971
9972   lwSlideNose->SetVisibility(kTRUE);
9973   lwSlideNose->SetLineColor(6); // Purple
9974   lwSlideNose->SetLineWidth(1);
9975   lwSlideNose->SetFillColor(lwSlideNose->GetLineColor());
9976   lwSlideNose->SetFillStyle(4000); // 0% transparent
9977
9978   TGeoVolume *lwSlidePin  = new TGeoVolume("ITSTPCsupportLowerSlidePin",
9979                                            lwSlidePinSh, medAisi);
9980
9981   lwSlidePin->SetVisibility(kTRUE);
9982   lwSlidePin->SetLineColor(kGray);
9983   lwSlidePin->SetLineWidth(1);
9984   lwSlidePin->SetFillColor(lwSlidePin->GetLineColor());
9985   lwSlidePin->SetFillStyle(4000); // 0% transparent
9986
9987   TGeoVolume *stirrC1C2  = new TGeoVolume("ITSTPCsupportStirrupC1C2",
9988                                           stirrupC1C2Sh, medErgal);
9989
9990   stirrC1C2->SetVisibility(kTRUE);
9991   stirrC1C2->SetLineColor(6); // Purple
9992   stirrC1C2->SetLineWidth(1);
9993   stirrC1C2->SetFillColor(stirrC1C2->GetLineColor());
9994   stirrC1C2->SetFillStyle(4000); // 0% transparent
9995
9996   TGeoVolume *stirrC5  = new TGeoVolume("ITSTPCsupportStirrupC5",
9997                                         stirrupC5Sh, medErgal);
9998
9999   stirrC5->SetVisibility(kTRUE);
10000   stirrC5->SetLineColor(6); // Purple
10001   stirrC5->SetLineWidth(1);
10002   stirrC5->SetFillColor(stirrC5->GetLineColor());
10003   stirrC5->SetFillStyle(4000); // 0% transparent
10004
10005
10006   // Build up the wheel slides
10007   upSlideVol->AddNode(upSlideBlock,1,0);
10008   upSlideVol->AddNode(upSlidePin,  1,
10009                       new TGeoCombiTrans(-kUpperSlideHoleXPos, 0, 0,
10010                                          new TGeoRotation("",0,-90,0) ) );
10011
10012   lwSlideVol->AddNode(lwSlideBlock,1,0);
10013   lwSlideVol->AddNode(lwSlideNose ,1,0);
10014   lwSlideVol->AddNode(lwSlidePin,  1,
10015                       new TGeoCombiTrans(lwSlideAluSh->GetX(5), 0, 0,
10016                                          new TGeoRotation("",0,-90,0) ) );
10017
10018
10019   // Finally put everything in the mother volume
10020   moth->AddNode(suppRingC2C3,1,
10021                 new TGeoTranslation(0, 0, kRingCZPos+kRingCZToTPC) );
10022   moth->AddNode(suppRingC2C3,2,
10023                 new TGeoCombiTrans( 0, 0,-kRingCZPos,
10024                                    new TGeoRotation("",0.,180.,0.) ) );
10025   moth->AddNode(suppRingC2C3,3,
10026                 new TGeoCombiTrans( 0, 0, kRingCZPos+kRingCZToTPC,
10027                                    new TGeoRotation("",0.,0.,180.) ) );
10028   moth->AddNode(suppRingC2C3,4,
10029                 new TGeoCombiTrans( 0, 0,-kRingCZPos,
10030                                    new TGeoRotation("",0.,180.,180.) ) );
10031
10032   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10033   moth->AddNode(forwUpHook,1,
10034                 new TGeoTranslation( 0, 0, zpos) );
10035
10036   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10037   moth->AddNode(forwLwHook,1,
10038                 new TGeoCombiTrans( 0, 0, zpos,
10039                                    new TGeoRotation("",0.,0.,180.) ) );
10040
10041   zpos = kRingCZPos + kRingCThick + kRearUpHookThick;
10042   moth->AddNode(rearUpHook,1,
10043                 new TGeoTranslation( 0, 0,-zpos) );
10044
10045   zpos = kRingCZPos + kRingCThick + kRearLwHookThick;
10046   moth->AddNode(rearLwHook,1,
10047                 new TGeoCombiTrans( 0, 0,-zpos,
10048                                    new TGeoRotation("",0.,0.,180.) ) );
10049
10050   xpos =  kRearLwHookWide/2 + kRearLwBracketThick/2;
10051   ypos = -kRingCHeight;
10052   moth->AddNode(rearLwBrack,1,
10053                 new TGeoCombiTrans( xpos, ypos,-zpos,
10054                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10055   moth->AddNode(rearLwBrack,2,
10056                 new TGeoCombiTrans(-xpos, ypos,-zpos,
10057                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10058
10059   xpos = kForwUpHookWide/2;
10060   ypos = (forwUpHookMainBody->GetY(8) + forwUpHookMainBody->GetY(9))/2;
10061   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10062   moth->AddNode(forwWebSStirrup,1,
10063                 new TGeoCombiTrans( xpos, ypos, zpos,
10064                                    new TGeoRotation("", 0., 90., 0.) ) );
10065   xpos = kForwLwHookWide/2;
10066   ypos = (forwLwHookMainBody->GetY(8) + forwLwHookMainBody->GetY(9))/2;
10067   moth->AddNode(forwWebSStirrup,2,
10068                 new TGeoCombiTrans( xpos,-ypos, zpos,
10069                                    new TGeoRotation("", 0., 90., 0.) ) );
10070
10071   xpos = kForwUpHookWide/2
10072         + (forwWebSStirrSh->GetX(4) + forwWebSStirrSh->GetX(5))/2;
10073   ypos = (forwUpHookMainBody->GetY(8) + forwUpHookMainBody->GetY(9))/2
10074         +  forwWebSStirrSh->GetZ(1) - forwWebTStirr3Sh->GetY(7);
10075   zpos += (forwWebSStirrSh->GetY(4) - forwWebSStirrSh->GetY(0));
10076   moth->AddNode(forwWebTStirr3,1,
10077                 new TGeoTranslation( xpos, ypos, zpos) );
10078
10079   ypos -= frWebClampSh->GetZ(1);
10080   moth->AddNode(frWebClamp,1,
10081                 new TGeoCombiTrans( xpos, ypos, zpos+forwWebTStirr3Sh->GetZ(1),
10082                                    new TGeoRotation("", 0., 90., 0.) ) );
10083
10084   ypos -= webcamShape->GetDY()/2;
10085   moth->AddNode(webCam,1,
10086                 new TGeoTranslation( xpos, ypos,
10087                      zpos+forwWebTStirr3Sh->GetZ(1)+webcamShape->GetDZ()) );
10088
10089   xpos = kForwLwHookWide/2
10090         + (forwWebSStirrSh->GetX(4) + forwWebSStirrSh->GetX(5))/2;
10091   ypos = (forwLwHookMainBody->GetY(8) + forwLwHookMainBody->GetY(9))/2
10092         +  forwWebSStirrSh->GetZ(1) - forwWebTStirr4Sh->GetY(7);
10093   moth->AddNode(forwWebTStirr4,1,
10094                 new TGeoCombiTrans( xpos,-ypos, zpos,
10095                                    new TGeoRotation("", 180., 0., 0.) ) );
10096
10097   ypos -= frWebClampSh->GetZ(1);
10098   moth->AddNode(frWebClamp,2,
10099                 new TGeoCombiTrans( xpos,-ypos, zpos+forwWebTStirr4Sh->GetZ(1),
10100                                    new TGeoRotation("", 0., 90., 0.) ) );
10101
10102   ypos -= webcamShape->GetDY()/2;
10103   moth->AddNode(webCam,2,
10104                 new TGeoTranslation( xpos,-ypos,
10105                      zpos+forwWebTStirr4Sh->GetZ(1)+webcamShape->GetDZ()) );
10106
10107   xpos = kRearUpHookWide/2 + kRearUpWebStirrDep/2;
10108   ypos = kRingCHeight;
10109   zpos = kRingCZPos + kRingCThick;
10110   moth->AddNode(upWebStirrup,1,
10111                 new TGeoCombiTrans( xpos, ypos,-zpos,
10112                                    new TGeoRotation("",-90.,-90., 90.) ) );
10113   moth->AddNode(upWebStirrup,2,
10114                 new TGeoCombiTrans(-xpos, ypos,-zpos,
10115                                    new TGeoRotation("",-90.,-90., 90.) ) );
10116
10117   ypos = kRingCHeight + upWebStirrSh->GetY(2) - upRearWebBarSh->GetDY();
10118   zpos = kRingCZPos + kRingCThick + upWebStirrSh->GetX(3)
10119        - upRearWebBarSh->GetDZ();
10120   moth->AddNode(upRearWebBar,1,
10121                 new TGeoTranslation( 0, ypos,-zpos) );
10122
10123   zpos -= upRearWebBarSh->GetDZ();
10124   moth->AddNode(frWebClamp,3,
10125                 new TGeoCombiTrans( 0, ypos,-zpos,
10126                                    new TGeoRotation("", 0., 90., 0.) ) );
10127
10128   ypos -= webcamShape->GetDY()/2;
10129   zpos -= webcamShape->GetDZ();
10130   moth->AddNode(webCam,3,
10131                 new TGeoTranslation( 0, ypos,-zpos) );
10132
10133   xpos = ringC2C3->GetX(14) + kUpperSlideWidth/2;
10134   ypos = ringC2C3->GetY(14);
10135   zpos = kRingCZPos + kRingCThick;
10136   moth->AddNode(upSlideVol,1,
10137                 new TGeoCombiTrans( xpos, ypos, zpos + kRingCZToTPC,
10138                                    new TGeoRotation("",-90.,-90., 90.) ) );
10139   moth->AddNode(upSlideVol,2,
10140                 new TGeoCombiTrans(-xpos, ypos, zpos + kRingCZToTPC,
10141                                    new TGeoRotation("",-90.,-90., 90.) ) );
10142   moth->AddNode(upSlideVol,3,
10143                 new TGeoCombiTrans( xpos, ypos, -zpos,
10144                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10145   moth->AddNode(upSlideVol,4,
10146                 new TGeoCombiTrans(-xpos, ypos, -zpos,
10147                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10148
10149   moth->AddNode(lwSlideVol,1,
10150                 new TGeoCombiTrans( xpos,-ypos, zpos + kRingCZToTPC,
10151                                    new TGeoRotation("", 90.,-90., 90.) ) );
10152   moth->AddNode(lwSlideVol,2,
10153                 new TGeoCombiTrans(-xpos,-ypos, zpos + kRingCZToTPC,
10154                                    new TGeoRotation("", 90.,-90., 90.) ) );
10155   moth->AddNode(lwSlideVol,3,
10156                 new TGeoCombiTrans( xpos,-ypos,-zpos,
10157                                    new TGeoRotation("",-90.,-90.,-90.) ) );
10158   moth->AddNode(lwSlideVol,4,
10159                 new TGeoCombiTrans(-xpos,-ypos,-zpos,
10160                                    new TGeoRotation("",-90.,-90.,-90.) ) );
10161
10162   xpos = kStirrCXPos;
10163   zpos = kRingCZPos + kStirrCZPos + stirrupC1C2Sh->GetZ(1) + kRingCZToTPC;
10164   moth->AddNode(stirrC1C2,1,
10165                 new TGeoTranslation( xpos, 0, zpos) );
10166   moth->AddNode(stirrC1C2,2,
10167                 new TGeoCombiTrans(-xpos, 0, zpos,
10168                                    new TGeoRotation("", 90.,-180.,-90.) ) );
10169
10170   xpos = kStirrCXPos + stirrupC1C2Sh->GetX(18) + kUpperSlideWidth/2;
10171   ypos = ringC2C3->GetY(14); // Slides are all at the same height
10172   zpos = kRingCZPos + kStirrCZPos + kStirrC12Thick + kRingCZToTPC;
10173   moth->AddNode(upSlideVol,5,
10174                 new TGeoCombiTrans( xpos, ypos, zpos,
10175                                    new TGeoRotation("",-90.,-90., 90.) ) );
10176   moth->AddNode(upSlideVol,6,
10177                 new TGeoCombiTrans(-xpos, ypos, zpos,
10178                                    new TGeoRotation("",-90.,-90., 90.) ) );
10179   moth->AddNode(lwSlideVol,5,
10180                 new TGeoCombiTrans( xpos,-ypos, zpos,
10181                                    new TGeoRotation("", 90.,-90., 90.) ) );
10182   moth->AddNode(lwSlideVol,6,
10183                 new TGeoCombiTrans(-xpos,-ypos, zpos,
10184                                    new TGeoRotation("", 90.,-90., 90.) ) );
10185
10186   xpos = kStirrCXPos;
10187   zpos = kRingCZPos + kStirrCZPos + stirrupC5Sh->GetZ(1);
10188   moth->AddNode(stirrC5,1,
10189                 new TGeoTranslation( xpos, 0,-zpos) );
10190   moth->AddNode(stirrC5,2,
10191                 new TGeoCombiTrans(-xpos, 0,-zpos,
10192                                    new TGeoRotation("", 90.,-180.,-90.) ) );
10193
10194
10195   return;
10196 }
10197