]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySupport.cxx
Added protection, fixed dynamic cast
[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,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 //
62 // Technical data are taken from:  ALICE-Thermal Screen "Cone transition"
63 // (thermal-screen1_a3.ps), "Cylinder" (thermal-screen2_a3.ps), "Half
64 // assembly" (thermal-screen3_a3.ps), "Flange" (thermal-screen4_a3.ps)
65
66
67   // Dimensions of the Central shield
68   const Double_t kHalfLengthCentral  = 400.*fgkmm;
69   const Double_t kThicknessCentral   = 0.4*fgkmm;
70   const Double_t kInnerRadiusCentral = 8.1475*fgkcm;
71   const Double_t kOuterRadiusCentral = 9.9255*fgkcm;
72   const Double_t kInnerACentral = 3.1674*fgkcm;
73   const Double_t kInnerBCentral = 2.023 *fgkcm;
74   const Double_t kOuterACentral = 2.4374*fgkcm;
75   const Double_t kOuterBCentral = 3.8162*fgkcm;
76   // Dimensions of the EndCap shield
77   const Double_t kHalfLengthEndCap  = 25.*fgkmm;
78   const Double_t kThicknessEndCap   = 2.0*fgkmm;
79   const Double_t kInnerRadiusEndCap = 8.0775*fgkcm;
80   const Double_t kOuterRadiusEndCap = 9.9955*fgkcm;
81   const Double_t kInnerAEndCap = 3.1453*fgkcm;
82   const Double_t kInnerBEndCap = 2.0009*fgkcm;
83   const Double_t kOuterAEndCap = 2.4596*fgkcm;
84   const Double_t kOuterBEndCap = 3.8384*fgkcm;
85   // Dimensions of the Cone shield
86   const Double_t kHalfLengthCone  = 145.*fgkmm;
87   const Double_t kThicknessCone   = 0.3*fgkmm;
88   const Double_t kInnerRadialCone = 37.3*fgkcm;
89   const Double_t kOuterRadialCone = 39.0*fgkcm;
90   const Double_t kInnerACone = 14.2344*fgkcm;
91   //  const Double_t kInnerBCone =  9.0915*fgkcm;
92   const Double_t kOuterACone =  9.5058*fgkcm;
93   //  const Double_t kOuterBCone = 14.8831*fgkcm;
94   // Dimensions of the Flange's Ring and Wing
95   const Double_t kHalfLengthRing  = 7.5*fgkmm;
96   const Double_t kThicknessRing   = 0.3*fgkmm;
97   const Double_t kInnerRadiusRing = 37.3*fgkcm;
98   const Double_t kOuterRadiusRing = 42.0*fgkcm;
99   const Double_t kOuterRadiusWing = 49.25*fgkcm;
100   const Double_t kWideWing      = 6.0*fgkcm;
101   const Double_t kThetaWing     = 45.0;
102   // Common data
103   const Double_t kTheta = 36.0*TMath::DegToRad();
104   const Double_t kThicknessOmega = 0.3*fgkmm;
105
106   // Local variables
107   Double_t x, y;
108   Double_t xshld[24], yshld[24];
109   Double_t xair[24] , yair[24];
110   Double_t xomega[48], yomega[48];
111   //  Double_t *xyarb8;
112
113   // The entire shield is made up of two half central shields
114   // symmetric with respect to the XZ plane, four half end cap
115   // shields, again symmetric with respect to the XZ plane, and four
116   // half cones, symmetric with respect to the XZ plane too.
117
118   TGeoVolumeAssembly *vM = new TGeoVolumeAssembly("ITSspdThermalShield");
119
120   // The central half shield: a half tube of carbon fiber,
121   // a similar but proportionally smaller half tube of air inside it,
122   // and a Omega-shaped carbon fiber insert inside the air.
123   // They are all XTru shapes
124
125   TGeoXtru *centralshape = new TGeoXtru(2);
126
127   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
128                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
129                         kTheta,xshld,yshld);
130
131   centralshape->DefinePolygon(24,xshld,yshld);
132   centralshape->DefineSection(0,-kHalfLengthCentral);
133   centralshape->DefineSection(1, kHalfLengthCentral);
134
135   // Now rescale to get the air volume dimensions
136     InsidePoint(xshld[23], yshld[23],
137                 xshld[ 0], yshld[ 0],
138                 xshld[ 1], yshld[ 1], kThicknessCentral,
139                 xair[0], yair[0]);
140   for (Int_t i=1; i<23; i++) {
141     InsidePoint(xshld[i-1], yshld[i-1],
142                 xshld[ i ], yshld[ i ],
143                 xshld[i+1], yshld[i+1], kThicknessCentral,
144                 xair[i], yair[i]);
145   }
146     InsidePoint(xshld[22], yshld[22],
147                 xshld[23], yshld[23],
148                 xshld[ 0], yshld[ 0], kThicknessCentral,
149                 xair[23], yair[23]);
150
151   // Create the air shape
152   TGeoXtru *centralairshape = new TGeoXtru(2);
153
154   centralairshape->DefinePolygon(24,xair,yair);
155   centralairshape->DefineSection(0,-kHalfLengthCentral);
156   centralairshape->DefineSection(1, kHalfLengthCentral);
157
158   // Create the Omega insert
159   TGeoXtru *centralomegashape = new TGeoXtru(2);
160
161   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
162
163   centralomegashape->DefinePolygon(48,xomega,yomega);
164   centralomegashape->DefineSection(0,-kHalfLengthCentral);
165   centralomegashape->DefineSection(1, kHalfLengthCentral);
166
167   // The end cap half shield: a half tube of carbon fiber,
168   // a similar but proportionally smaller half tube of air inside it,
169   // and a Omega-shaped carbon fiber insert inside the air.
170   // They are all XTru shapes
171
172   TGeoXtru *endcapshape = new TGeoXtru(2);
173
174   CreateSPDThermalShape(kInnerAEndCap,kInnerBEndCap,kInnerRadiusEndCap,
175                         kOuterAEndCap,kOuterBEndCap,kOuterRadiusEndCap,
176                         kTheta,xshld,yshld);
177
178   endcapshape->DefinePolygon(24,xshld,yshld);
179   endcapshape->DefineSection(0,-kHalfLengthEndCap);
180   endcapshape->DefineSection(1, kHalfLengthEndCap);
181
182   // Now rescale to get the air volume dimensions
183     InsidePoint(xshld[23], yshld[23],
184                 xshld[ 0], yshld[ 0],
185                 xshld[ 1], yshld[ 1], kThicknessEndCap,
186                 xair[0], yair[0]);
187   for (Int_t i=1; i<23; i++) {
188     InsidePoint(xshld[i-1], yshld[i-1],
189                 xshld[ i ], yshld[ i ],
190                 xshld[i+1], yshld[i+1], kThicknessEndCap,
191                 xair[i], yair[i]);
192   }
193     InsidePoint(xshld[22], yshld[22],
194                 xshld[23], yshld[23],
195                 xshld[ 0], yshld[ 0], kThicknessEndCap,
196                 xair[23], yair[23]);
197
198   // Create the air shape
199   TGeoXtru *endcapairshape = new TGeoXtru(2);
200
201   endcapairshape->DefinePolygon(24,xair,yair);
202   endcapairshape->DefineSection(0,-kHalfLengthEndCap);
203   endcapairshape->DefineSection(1, kHalfLengthEndCap);
204
205   // Create the Omega insert
206   TGeoXtru *endcapomegashape = new TGeoXtru(2);
207
208   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
209
210   endcapomegashape->DefinePolygon(48,xomega,yomega);
211   endcapomegashape->DefineSection(0,-kHalfLengthEndCap);
212   endcapomegashape->DefineSection(1, kHalfLengthEndCap);
213
214   // The cone half shield is more complex since there is no basic
215   // TGeo shape to describe it correctly. So it is made of a series
216   // of TGeoArb8 shapes filled with air, which all together make up the
217   // the cone AND its internal insert. Part of the following code is
218   // adapted from SPDThermalSheald method.
219
220   // Filled portions
221   TGeoArb8 *sC1 = new TGeoArb8(kHalfLengthCone);
222   TGeoArb8 *sC2 = new TGeoArb8(kHalfLengthCone);
223
224   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
225                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
226                         kTheta,xshld,yshld);
227
228   sC1->SetVertex(0,xshld[12],yshld[12]);
229   sC1->SetVertex(1,xshld[11],yshld[11]);
230   sC1->SetVertex(2,xshld[ 0],yshld[ 0]);
231   sC1->SetVertex(3,xshld[23],yshld[23]);
232
233   sC2->SetVertex(0,xshld[11],yshld[11]);
234   sC2->SetVertex(1,xshld[10],yshld[10]);
235   sC2->SetVertex(2,xshld[ 1],yshld[ 1]);
236   sC2->SetVertex(3,xshld[ 0],yshld[ 0]);
237
238   // Drawings give only the radius, convert it to the apothegm
239   Double_t kInnerRadiusCone = TMath::Sqrt(kInnerRadialCone*kInnerRadialCone
240                                           - 0.25*kInnerACone*kInnerACone);
241   Double_t kOuterRadiusCone = TMath::Sqrt(kOuterRadialCone*kOuterRadialCone
242                                           - 0.25*kOuterACone*kOuterACone);
243
244   Double_t xco[4], yco[4], xci[4], yci[4];
245
246   for (Int_t i=0; i<2; i++) {
247     Double_t th = i*kTheta*TMath::RadToDeg();
248     xco[2*i  ] = kOuterRadiusCone*SinD(th) - 0.5*kOuterACone*CosD(th);
249     yco[2*i  ] = kOuterRadiusCone*CosD(th) + 0.5*kOuterACone*SinD(th);
250     xci[2*i  ] = kInnerRadiusCone*SinD(th) - 0.5*kInnerACone*CosD(th);
251     yci[2*i  ] = kInnerRadiusCone*CosD(th) + 0.5*kInnerACone*SinD(th);
252     xco[2*i+1] = kOuterRadiusCone*SinD(th) + 0.5*kOuterACone*CosD(th);
253     yco[2*i+1] = kOuterRadiusCone*CosD(th) - 0.5*kOuterACone*SinD(th);
254     xci[2*i+1] = kInnerRadiusCone*SinD(th) + 0.5*kInnerACone*CosD(th);
255     yci[2*i+1] = kInnerRadiusCone*CosD(th) - 0.5*kInnerACone*SinD(th);
256   }
257
258   sC1->SetVertex(4,xco[0],yco[0]);
259   sC1->SetVertex(5,xco[1],yco[1]);
260   sC1->SetVertex(6,xci[1],yci[1]);
261   sC1->SetVertex(7,xci[0],yci[0]);
262
263   sC2->SetVertex(4,xco[1],yco[1]);
264   sC2->SetVertex(5,xco[2],yco[2]);
265   sC2->SetVertex(6,xci[2],yci[2]);
266   sC2->SetVertex(7,xci[1],yci[1]);
267
268   // Air holes
269   TGeoArb8 *sCh1 = new TGeoArb8(kHalfLengthCone);
270   TGeoArb8 *sCh2 = new TGeoArb8(kHalfLengthCone);
271
272   for(Int_t i=0; i<4; i++){
273     InsidePoint(sC1->GetVertices()[((i+3)%4)*2+0],
274                 sC1->GetVertices()[((i+3)%4)*2+1],
275                 sC1->GetVertices()[i*2+0],
276                 sC1->GetVertices()[i*2+1],
277                 sC1->GetVertices()[((i+1)%4)*2+0],
278                 sC1->GetVertices()[((i+1)%4)*2+1],-kThicknessCone,x,y);
279     sCh1->SetVertex(i,x,y);
280
281     InsidePoint(sC1->GetVertices()[((i+3)%4 +4)*2+0],
282                 sC1->GetVertices()[((i+3)%4 +4)*2+1],
283                 sC1->GetVertices()[(i+4)*2+0],
284                 sC1->GetVertices()[(i+4)*2+1],
285                 sC1->GetVertices()[((i+1)%4 +4)*2+0],
286                 sC1->GetVertices()[((i+1)%4 +4)*2+1],-kThicknessCone,x,y);
287     sCh1->SetVertex(i+4,x,y);
288
289     InsidePoint(sC2->GetVertices()[((i+3)%4)*2+0],
290                 sC2->GetVertices()[((i+3)%4)*2+1],
291                 sC2->GetVertices()[i*2+0],
292                 sC2->GetVertices()[i*2+1],
293                 sC2->GetVertices()[((i+1)%4)*2+0],
294                 sC2->GetVertices()[((i+1)%4)*2+1],-kThicknessCone,x,y);
295     sCh2->SetVertex(i,x,y);
296
297     InsidePoint(sC2->GetVertices()[((i+3)%4 +4)*2+0],
298                 sC2->GetVertices()[((i+3)%4 +4)*2+1],
299                 sC2->GetVertices()[(i+4)*2+0],
300                 sC2->GetVertices()[(i+4)*2+1],
301                 sC2->GetVertices()[((i+1)%4 +4)*2+0],
302                 sC2->GetVertices()[((i+1)%4 +4)*2+1],-kThicknessCone,x,y);
303     sCh2->SetVertex(i+4,x,y);
304   }
305
306   // Finally the carbon fiber Ring with its Wings and their
307   // stesalite inserts. They are Tube and TubeSeg shapes
308
309   TGeoTube *ringshape = new TGeoTube(kInnerRadiusRing,kOuterRadiusRing,
310                                      kHalfLengthRing);
311
312   TGeoTube *ringinsertshape = new TGeoTube(kInnerRadiusRing+kThicknessRing,
313                                            kOuterRadiusRing-kThicknessRing,
314                                            kHalfLengthRing-kThicknessRing);
315
316   Double_t angleWideWing, angleWideWingThickness;
317   angleWideWing = (kWideWing/kOuterRadiusWing)*TMath::RadToDeg();
318   angleWideWingThickness = (kThicknessRing/kOuterRadiusWing)*TMath::RadToDeg();
319
320   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kOuterRadiusRing,kOuterRadiusWing,
321                                            kHalfLengthRing, 0, angleWideWing);
322
323   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kOuterRadiusRing,
324              kOuterRadiusWing-kThicknessRing, kHalfLengthRing-kThicknessRing,
325              angleWideWingThickness, angleWideWing-angleWideWingThickness);
326
327
328   // We have the shapes: now create the real volumes
329
330   TGeoMedium *medSPDcf  = mgr->GetMedium("ITS_SPD shield$");
331   TGeoMedium *medSPDair = mgr->GetMedium("ITS_SPD AIR$");
332   TGeoMedium *medSPDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
333
334   TGeoVolume *centralshield = new TGeoVolume("SPDcentralshield",
335                                              centralshape,medSPDcf);
336   centralshield->SetVisibility(kTRUE);
337   centralshield->SetLineColor(7);
338   centralshield->SetLineWidth(1);
339
340   TGeoVolume *centralairshield = new TGeoVolume("SPDcentralairshield",
341                                                 centralairshape,medSPDair);
342   centralairshield->SetVisibility(kTRUE);
343   centralairshield->SetLineColor(5); // Yellow
344   centralairshield->SetLineWidth(1);
345   centralairshield->SetFillColor(centralairshield->GetLineColor());
346   centralairshield->SetFillStyle(4090); // 90% transparent
347
348   TGeoVolume *centralomega = new TGeoVolume("SPDcentralomega",
349                                              centralomegashape,medSPDcf);
350   centralomega->SetVisibility(kTRUE);
351   centralomega->SetLineColor(7);
352   centralomega->SetLineWidth(1);
353
354   centralairshield->AddNode(centralomega,1,0);
355   centralshield->AddNode(centralairshield,1,0);
356
357   TGeoVolume *endcapshield = new TGeoVolume("SPDendcapshield",
358                                              endcapshape,medSPDcf);
359   endcapshield->SetVisibility(kTRUE);
360   endcapshield->SetLineColor(7);
361   endcapshield->SetLineWidth(1);
362
363   TGeoVolume *endcapairshield = new TGeoVolume("SPDendcapairshield",
364                                                 endcapairshape,medSPDair);
365   endcapairshield->SetVisibility(kTRUE);
366   endcapairshield->SetLineColor(5); // Yellow
367   endcapairshield->SetLineWidth(1);
368   endcapairshield->SetFillColor(endcapairshield->GetLineColor());
369   endcapairshield->SetFillStyle(4090); // 90% transparent
370
371   TGeoVolume *endcapomega = new TGeoVolume("SPDendcapomega",
372                                            endcapomegashape,medSPDcf);
373   endcapomega->SetVisibility(kTRUE);
374   endcapomega->SetLineColor(7);
375   endcapomega->SetLineWidth(1);
376
377   endcapairshield->AddNode(endcapomega,1,0);
378   endcapshield->AddNode(endcapairshield,1,0);
379
380   TGeoVolume *vC1 = new TGeoVolume("SPDconeshieldV1",sC1,medSPDcf);
381   vC1->SetVisibility(kTRUE);
382   vC1->SetLineColor(7);
383   vC1->SetLineWidth(1);
384
385   TGeoVolume *vCh1 = new TGeoVolume("SPDconeshieldH1",sCh1,medSPDair);
386
387   vCh1->SetVisibility(kTRUE);
388   vCh1->SetLineColor(5); // Yellow
389   vCh1->SetLineWidth(1);
390   vCh1->SetFillColor(vCh1->GetLineColor());
391   vCh1->SetFillStyle(4090); // 90% transparent
392
393   vC1->AddNode(vCh1,1,0);
394
395   TGeoVolume *vC2 = new TGeoVolume("SPDconeshieldV2",sC2,medSPDcf);
396
397   vC2->SetVisibility(kTRUE);
398   vC2->SetLineColor(7);
399   vC2->SetLineWidth(1);
400
401   TGeoVolume *vCh2 = new TGeoVolume("SPDconeshieldH2",sCh2,medSPDair);
402
403   vCh2->SetVisibility(kTRUE);
404   vCh2->SetLineColor(5); // Yellow
405   vCh2->SetLineWidth(1);
406   vCh2->SetFillColor(vCh2->GetLineColor());
407   vCh2->SetFillStyle(4090); // 90% transparent
408
409   vC2->AddNode(vCh2,1,0);
410
411   TGeoVolume *ring = new TGeoVolume("SPDshieldring",ringshape,medSPDcf);
412   ring->SetVisibility(kTRUE);
413   ring->SetLineColor(7);
414   ring->SetLineWidth(1);
415
416   TGeoVolume *ringinsert = new TGeoVolume("SPDshieldringinsert",
417                                           ringinsertshape,medSPDste);
418   ringinsert->SetVisibility(kTRUE);
419   ringinsert->SetLineColor(3); // Green
420 //  ringinsert->SetLineWidth(1);
421   ringinsert->SetFillColor(ringinsert->GetLineColor());
422   ringinsert->SetFillStyle(4010); // 10% transparent
423
424   ring->AddNode(ringinsert,1,0);
425
426   TGeoVolume *wing = new TGeoVolume("SPDshieldringwing",wingshape,medSPDcf);
427   wing->SetVisibility(kTRUE);
428   wing->SetLineColor(7);
429   wing->SetLineWidth(1);
430
431   TGeoVolume *winginsert = new TGeoVolume("SPDshieldringinsert",
432                                           winginsertshape,medSPDste);
433   winginsert->SetVisibility(kTRUE);
434   winginsert->SetLineColor(3); // Green
435 //  winginsert->SetLineWidth(1);
436   winginsert->SetFillColor(winginsert->GetLineColor());
437   winginsert->SetFillStyle(4010); // 10% transparent
438
439   wing->AddNode(winginsert,1,0);
440
441
442   // Add all volumes in the assembly
443   vM->AddNode(centralshield,1,0);
444   vM->AddNode(centralshield,2,new TGeoRotation("",180,0,0));
445
446   vM->AddNode(endcapshield,1,
447               new TGeoTranslation(0,0, kHalfLengthCentral+kHalfLengthEndCap));
448   vM->AddNode(endcapshield,2,
449               new TGeoTranslation(0,0,-kHalfLengthCentral-kHalfLengthEndCap));
450   vM->AddNode(endcapshield,3,new TGeoCombiTrans(
451               0, 0, kHalfLengthCentral+kHalfLengthEndCap,
452               new TGeoRotation("",180,0,0)     ) );
453   vM->AddNode(endcapshield,4,new TGeoCombiTrans(
454               0, 0,-kHalfLengthCentral-kHalfLengthEndCap,
455               new TGeoRotation("",180,0,0)     ) );
456
457   for (Int_t i=0; i<10; i++) {
458     Double_t thetaC12 = kTheta*TMath::RadToDeg();
459     vM->AddNode(vC1,2*i+1, new TGeoCombiTrans(
460                0, 0,  kHalfLengthCentral+2*kHalfLengthEndCap+kHalfLengthCone,
461                new TGeoRotation("",0,  0,i*thetaC12)   ) );
462     vM->AddNode(vC1,2*i+2, new TGeoCombiTrans(
463                0, 0, -kHalfLengthCentral-2*kHalfLengthEndCap-kHalfLengthCone,
464                new TGeoRotation("",0,180,i*thetaC12)   ) );
465     vM->AddNode(vC2,2*i+1, new TGeoCombiTrans(
466                0, 0,  kHalfLengthCentral+2*kHalfLengthEndCap+kHalfLengthCone,
467                new TGeoRotation("",0,  0,i*thetaC12)   ) );
468     vM->AddNode(vC2,2*i+2, new TGeoCombiTrans(
469                0, 0, -kHalfLengthCentral-2*kHalfLengthEndCap-kHalfLengthCone,
470                new TGeoRotation("",0,180,i*thetaC12)   ) );
471   }
472
473   vM->AddNode(ring,1,new TGeoTranslation(0, 0,
474               kHalfLengthCentral+2*kHalfLengthEndCap+2*kHalfLengthCone
475              +kHalfLengthRing));
476   vM->AddNode(ring,2,new TGeoTranslation(0, 0,
477              -kHalfLengthCentral-2*kHalfLengthEndCap-2*kHalfLengthCone
478              -kHalfLengthRing));
479
480   for (Int_t i=0; i<4; i++) {
481     Double_t thetaW = kThetaWing*(2*i+1) - angleWideWing/2.;
482     vM->AddNode(wing,2*i+1,new TGeoCombiTrans(0, 0,
483               kHalfLengthCentral+2*kHalfLengthEndCap+2*kHalfLengthCone
484              +kHalfLengthRing, new TGeoRotation("",thetaW,0,0)  ));
485     vM->AddNode(wing,2*i+2,new TGeoCombiTrans(0, 0,
486              -kHalfLengthCentral-2*kHalfLengthEndCap-2*kHalfLengthCone
487              -kHalfLengthRing, new TGeoRotation("",thetaW,0,0)  ));
488   }
489
490   // Some debugging if requested
491   if(GetDebug(1)){
492     vM->PrintNodes();
493     vM->InspectShape();
494   }
495
496   // Finally put the entire shield in the mother volume
497   moth->AddNode(vM,1,0);
498
499   return;
500 }
501
502 //______________________________________________________________________
503 void AliITSv11GeometrySupport::CreateSPDThermalShape(
504      Double_t ina, Double_t inb, Double_t inr,
505      Double_t oua, Double_t oub, Double_t our,
506      Double_t   t, Double_t *x , Double_t *y )
507 {
508 //
509 // Creates the proper sequence of X and Y coordinates to determine
510 // the base XTru polygon for the SPD thermal shapes
511 //
512 // Input:
513 //        ina, inb : inner shape sides
514 //        inr      : inner radius
515 //        oua, oub : outer shape sides
516 //        our      : outer radius
517 //        t        : theta angle
518 //
519 // Output:
520 //        x, y : coordinate vectors [24]
521 //
522 // Created:      14 Nov 2007  Mario Sitta
523 // Updated:      11 Dec 2007  Mario Sitta
524 //
525   Double_t xlocal[6],ylocal[6];
526
527   //Create the first inner quadrant (X > 0)
528   FillSPDXtruShape(ina,inb,inr,t,xlocal,ylocal);
529   for (Int_t i=0; i<6; i++) {
530     x[i] = xlocal[i];
531     y[i] = ylocal[i];
532   }
533
534   // Then reflex on the second quadrant (X < 0)
535   for (Int_t i=0; i<6; i++) {
536     x[23-i] = -x[i];
537     y[23-i] =  y[i];
538   }
539
540   // Now create the first outer quadrant (X > 0)
541   FillSPDXtruShape(oua,oub,our,t,xlocal,ylocal);
542   for (Int_t i=0; i<6; i++) {
543     x[11-i] = xlocal[i];
544     y[11-i] = ylocal[i];
545   }
546
547   // Finally reflex on the second quadrant (X < 0)
548   for (Int_t i=0; i<6; i++) {
549     x[12+i] = -x[11-i];
550     y[12+i] =  y[11-i];
551   }
552
553   return;
554 }
555
556 //______________________________________________________________________
557 void AliITSv11GeometrySupport::CreateSPDOmegaShape(
558                              Double_t *xin, Double_t *yin, Double_t  d,
559                              Double_t   *x, Double_t *y)
560 {
561 //
562 // Creates the proper sequence of X and Y coordinates to determine
563 // the SPD Omega XTru polygon
564 //
565 // Input:
566 //        xin, yin : coordinates of the air volume
567 //        d        : Omega shape thickness
568 //        t        : theta angle
569 //
570 // Output:
571 //        x, y     : coordinate vectors [48]
572 //
573 // Created:      17 Nov 2007  Mario Sitta
574 // Updated:      11 Dec 2007  Mario Sitta
575 // Updated:      20 Feb 2009  Mario Sitta       New algorithm (the old one
576 //                                              gives erroneous vertexes)
577 //
578
579   // This vector contains the index of those points which coincide
580   // with the corresponding points in the air shape
581   Int_t indexAir2Omega[12] = {1, 2, 5, 6, 9, 10, 11, 15, 16, 19, 20, 23};
582
583   // First fill those vertexes corresponding to
584   // the edges aligned to the air shape edges
585   for (Int_t j=0; j<12; j++) {
586     x[*(indexAir2Omega+j)] = xin[j];
587     y[*(indexAir2Omega+j)] = yin[j];
588   }
589
590   // Now get the coordinates of the first inner point
591   PointFromParallelLines(x[23],y[23],x[1],y[1],d,x[0],y[0]);
592
593   // Knowing this, the second internal point can be determined
594   InsidePoint(x[0],y[0],x[1],y[1],x[2],y[2],d,x[22],y[22]);
595
596   // The third point is now computable
597   ReflectPoint(x[1],y[1],x[2],y[2],x[22],y[22],x[21],y[21]);
598
599   // Repeat this logic
600   InsidePoint(x[21],y[21],x[20],y[20],x[19],y[19],-d,x[3],y[3]);
601
602   ReflectPoint(x[20],y[20],x[19],y[19],x[3],y[3],x[4],y[4]);
603
604   InsidePoint(x[4],y[4],x[5],y[5],x[6],y[6],d,x[18],y[18]);
605
606   ReflectPoint(x[5],y[5],x[6],y[6],x[18],y[18],x[17],y[17]);
607
608   InsidePoint(x[17],y[17],x[16],y[16],x[15],y[15],-d,x[7],y[7]);
609
610   ReflectPoint(x[16],y[16],x[15],y[15],x[7],y[7],x[8],y[8]);
611
612   InsidePoint(x[8],y[8],x[9],y[9],x[10],y[10],d,x[14],y[14]);
613
614   // These need to be fixed explicitly
615   x[12] = x[11];
616   y[12] = y[11] + d;
617   x[13] = x[10] + d;
618   y[13] = y[12];
619
620   // Finally reflect on the negative side
621   for (Int_t i=0; i<24; i++) {
622     x[24+i] = -x[23-i];
623     y[24+i] =  y[23-i];
624   }
625
626   // Wow ! We've finished
627   return;
628 }
629
630 //______________________________________________________________________
631 void AliITSv11GeometrySupport::FillSPDXtruShape(Double_t a, Double_t b,
632                                                 Double_t r, Double_t t,
633                                                 Double_t *x, Double_t *y)
634 {
635 //
636 // Creates the partial sequence of X and Y coordinates to determine
637 // the lateral part of the SPD thermal shield
638 //
639 // Input:
640 //        a, b : shape sides
641 //        r    : radius
642 //        t    : theta angle
643 //
644 // Output:
645 //        x, y : coordinate vectors [6]
646 //
647 // Created:      14 Nov 2007  Mario Sitta
648 //
649   x[0] = a/2;
650   y[0] = r;
651
652   x[1] = x[0] + b * TMath::Cos(t/2);
653   y[1] = y[0] - b * TMath::Sin(t/2);
654
655   x[2] = x[1] + a * TMath::Cos(t);
656   y[2] = y[1] - a * TMath::Sin(t);
657
658   x[3] = x[2] + b * TMath::Cos(3*t/2);
659   y[3] = y[2] - b * TMath::Sin(3*t/2);
660
661   x[4] = x[3] + a * TMath::Cos(2*t);
662   y[4] = y[3] - a * TMath::Sin(2*t);
663
664   x[5] = x[4];
665   y[5] = 0.;
666
667   return;
668 }
669
670 //______________________________________________________________________
671 void AliITSv11GeometrySupport::PointFromParallelLines(Double_t x1, Double_t y1,
672                               Double_t x2, Double_t y2, Double_t d,
673                               Double_t &x, Double_t &y)
674 {
675 //
676 // Determines the X and Y of the first internal point of the Omega shape
677 // (i.e. the coordinates of a point given two parallel lines passing by
678 // two points and placed at a known distance)
679 //
680 // Input:
681 //        x1, y1 : first point
682 //        x2, y2 : second point
683 //        d      : distance between the two lines
684 //
685 // Output:
686 //        x, y   : coordinate of the point
687 //
688 // Created:      22 Feb 2009  Mario Sitta
689 //
690 //Begin_Html
691 /*
692 <img src="ITS/doc/PointFromParallelLines.gif">
693 */
694 //End_Html
695
696   // The slope of the paralles lines at a distance d
697   Double_t m; 
698
699   // The parameters of the solving equation
700   // a x^2 - 2 b x + c = 0
701   Double_t a = (x1 - x2)*(x1 - x2) - d*d;
702   Double_t b = (x1 - x2)*(y1 - y2);
703   Double_t c = (y1 - y2)*(y1 - y2) - d*d;
704
705   // (Delta4 is Delta/4 because we use the reduced formula)
706   Double_t Delta4 = b*b - a*c;
707
708   // Compute the slope of the two parallel lines
709   // (one of the two possible slopes, the one with the smaller
710   // absolute value is needed)
711   if (Delta4 < 0) { // Should never happen with our data, but just to be sure
712     x = -1;         // x is expected positive, so this flags an error
713     return;
714   } else
715     m = (b + TMath::Sqrt(Delta4))/a;  // b is negative with our data
716
717   // Finally compute the coordinates of the point
718   x = x2 + (y1 - y2 - d)/m;
719   y = y1 - d;
720
721   // Done
722   return;
723 }
724
725 //______________________________________________________________________
726 void AliITSv11GeometrySupport::ReflectPoint(Double_t x1, Double_t y1,
727                                             Double_t x2, Double_t y2,
728                                             Double_t x3, Double_t y3,
729                                             Double_t &x, Double_t &y)
730 {
731 //
732 // Given two points (x1,y1) and (x2,y2), determines the point (x,y)
733 // lying on the line parallel to the line passing by these points,
734 // at a distance d and passing by the point (x3,y3), which is symmetric to
735 // the third point with respect to the axis of the segment delimited by
736 // the two first points.
737 //
738 // Input:
739 //        x1, y1 : first point
740 //        x2, y2 : second point
741 //        x3, y3 : third point
742 //        d      : distance between the two lines
743 //
744 // Output:
745 //        x, y   : coordinate of the reflected point
746 //
747 // Created:      22 Feb 2009  Mario Sitta
748 //
749 //Begin_Html
750 /*
751 <img src="ITS/doc/ReflectPoint.gif">
752 */
753 //End_Html
754
755   // The slope of the line passing by the first two points
756   Double_t k = (y2 - y1)/(x2 - x1);
757
758   // The middle point of the segment 1-2
759   Double_t xK = (x1 + x2)/2.;
760   Double_t yK = (y1 + y2)/2.;
761
762   // The intercept between the axis of the segment 1-2 and the line
763   // passing by 3 and parallel to the line passing by 1-2
764   Double_t xH = (k*k*x3 + k*(yK - y3) + xK)/(k*k + 1);
765   Double_t yH = k*(xH - x3) + y3;
766
767   // The point symmetric to 3 with respect to H
768   x = 2*xH - x3;
769   y = 2*yH - y3;
770
771   // Done
772   return;
773 }
774
775 //______________________________________________________________________
776 void AliITSv11GeometrySupport::SDDCone(TGeoVolume *moth,TGeoManager *mgr)
777 {
778 //
779 // Creates the SDD support cone and cylinder geometry as a
780 // volume assembly and adds it to the mother volume
781 // (part of this code is taken or anyway inspired to SDDCone method
782 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
783 //
784 // Input:
785 //         moth : the TGeoVolume owing the volume structure
786 //         mgr  : the GeoManager (default gGeoManager)
787 // Output:
788 //
789 // Created:         ???       Bjorn S. Nilsen
790 // Updated:      18 Feb 2008  Mario Sitta
791 // Updated:      25 Jul 2008  Mario Sitta   SDDCarbonFiberCone simpler
792 // Updated:      10 Jun 2010  Mario Sitta   Cables across cone holes added
793 //
794 // Technical data are taken from:  "Supporto Generale Settore SDD"
795 // (technical drawings ALR-0816/1-B), "Supporto Globale Settore SDD"
796 // (technical drawings ALR-0816/2A, ALR-0816/2B, ALR-0816/2C, ALR-0816/2D), 
797 // private communication with B. Giraudo
798
799   // Dimensions of the Central cylinder and flanges
800   const Double_t kCylinderHalfLength = (790.0/2)*fgkmm;
801   const Double_t kCylinderInnerR     = (210.0/2)*fgkmm;
802   const Double_t kCylinderOuterR     = (231.0/2)*fgkmm;
803   const Double_t kFlangeHalfLength   = ( 15.0/2)*fgkmm;
804   const Double_t kFlangeInnerR       = (210.5/2)*fgkmm;
805   const Double_t kFlangeOuterR       = (230.5/2)*fgkmm;
806   const Double_t kInsertoHalfLength  =
807                                      kCylinderHalfLength - 2*kFlangeHalfLength;
808 //  const Double_t kCFThickness        = kFlangeInnerR - kCylinderInnerR;
809   const Double_t kBoltDiameter       =       6.0*fgkmm; // M6 screw
810   const Double_t kBoltDepth          =       6.0*fgkmm; // In the flange
811   const Double_t kBoltRadius         = (220.0/2)*fgkmm; // Radius in flange
812   const Double_t kThetaBolt          =      30.0*fgkDegree;
813   const Int_t    kNBolts             = (Int_t)(360.0/kThetaBolt);
814   // Dimensions of the Cone
815   const Double_t kConeROutMin        = (540.0/2)*fgkmm;
816   const Double_t kConeROutMax        = (560.0/2)*fgkmm;
817   const Double_t kConeRCurv          =      10.0*fgkmm; // Radius of curvature
818   const Double_t kConeRinMin         = (210.0/2)*fgkmm;
819 //  const Double_t kConeRinMax         = (216.0/2)*fgkmm;
820   const Double_t kConeRinCylinder    = (231.0/2)*fgkmm;
821   const Double_t kConeZCylinder      =     192.0*fgkmm;
822   const Double_t kConeZOuterMilled   =      23.0*fgkmm;
823   const Double_t kConeDZin           =      15.0*fgkmm; // ???
824   const Double_t kConeThickness      =      10.0*fgkmm; // Rohacell + Carb.Fib.
825   const Double_t kConeTheta          =      45.0*fgkDegree; // SDD cone angle
826   const Double_t kSinConeTheta       =
827                                      TMath::Sin(kConeTheta*TMath::DegToRad());
828   const Double_t kCosConeTheta       =
829                                      TMath::Cos(kConeTheta*TMath::DegToRad());
830   const Double_t kTanConeTheta       =
831                                      TMath::Tan(kConeTheta*TMath::DegToRad());
832   // Dimensions of the Cone Inserts
833   const Double_t kConeCFThickness    =       1.5*fgkmm;//Carbon fiber thickness
834   // Dimensions of the Cone Holes
835   const Double_t kHole1RMin          = (450.0/2)*fgkmm;
836   const Double_t kHole1RMax          = (530.0/2)*fgkmm;
837   const Double_t kHole2RMin          = (280.0/2)*fgkmm;
838   const Double_t kHole2RMax          = (375.0/2)*fgkmm;
839   const Double_t kHole1Phi           =      25.0*fgkDegree;
840   const Double_t kHole2Phi           =      50.0*fgkDegree;
841   const Double_t kHole3RMin          =     205.0*fgkmm;
842   const Double_t kHole3DeltaR        =        15*fgkmm;
843   const Double_t kHole3Width         =        30*fgkmm;
844   const Int_t    kNHole3             =         6      ;
845   const Double_t kHole4RMin          =     116.0*fgkmm;
846   const Double_t kHole4DeltaR        =        15*fgkmm;
847   const Double_t kHole4Width         =        30*fgkmm;
848   //  const Int_t    kNHole4             =         3      ;
849   // Fraction of materials in holes
850   const Double_t kHolePlasticFrac    =       0.55846;
851   const Double_t kHoleCuFrac         =       0.06319;
852   const Double_t kHoleGlassFrac      =       0.02652;
853
854   // Local variables
855   Double_t x, y, z, t, dza, rmin, rmax;
856
857
858   // Recover the needed materials
859   TGeoMedium *medSDDcf    = mgr->GetMedium("ITS_SDD C (M55J)$");
860   TGeoMedium *medSDDair   = mgr->GetMedium("ITS_SDD AIR$");
861   TGeoMedium *medSDDste   = mgr->GetMedium("ITS_G10FR4$"); // stesalite
862   TGeoMedium *medSDDroh   = mgr->GetMedium("ITS_ROHACELL$");
863   TGeoMedium *medSDDss    = mgr->GetMedium("ITS_INOX$");
864   TGeoMedium *medSDDplast = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
865   TGeoMedium *medSDDCu    = mgr->GetMedium("ITS_COPPER$");
866   TGeoMedium *medSDDglass = mgr->GetMedium("ITS_SDD OPTICFIB$");
867
868   // First define the geometrical shapes
869
870   // Central cylinder with its internal foam and the lateral flanges:
871   // a carbon fiber Tube which contains a rohacell Tube and two
872   // stesalite Tube's
873   TGeoTube *cylindershape = new TGeoTube(kCylinderInnerR,kCylinderOuterR,
874                                          kCylinderHalfLength);
875
876   TGeoTube *insertoshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
877                                         kInsertoHalfLength);
878
879   TGeoTube *flangeshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
880                                        kFlangeHalfLength);
881
882   // The flange bolt: it is a Tube
883   TGeoTube *boltshape = new TGeoTube(0.0, 0.5*kBoltDiameter, 0.5*kBoltDepth);
884
885   // Debug if requested
886   if (GetDebug(1)) {
887     cylindershape->InspectShape();
888     insertoshape->InspectShape();
889     flangeshape->InspectShape();
890     boltshape->InspectShape();
891   }
892
893
894   // We have the shapes: now create the real volumes
895
896   TGeoVolume *cfcylinder = new TGeoVolume("SDDCarbonFiberCylinder",
897                                           cylindershape,medSDDcf);
898   cfcylinder->SetVisibility(kTRUE);
899   cfcylinder->SetLineColor(4); // Blue
900   cfcylinder->SetLineWidth(1);
901   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
902   cfcylinder->SetFillStyle(4000); // 0% transparent
903
904   TGeoVolume *foamcylinder = new TGeoVolume("SDDFoamCylinder",
905                                             insertoshape,medSDDroh);
906   foamcylinder->SetVisibility(kTRUE);
907   foamcylinder->SetLineColor(3); // Green
908   foamcylinder->SetLineWidth(1);
909   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
910   foamcylinder->SetFillStyle(4050); // 50% transparent
911
912   TGeoVolume *flangecylinder = new TGeoVolume("SDDFlangeCylinder",
913                                               flangeshape,medSDDste);
914   flangecylinder->SetVisibility(kTRUE);
915   flangecylinder->SetLineColor(2); // Red
916   flangecylinder->SetLineWidth(1);
917   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
918   flangecylinder->SetFillStyle(4050); // 50% transparent
919
920   TGeoVolume *bolt = new TGeoVolume("SDDFlangeBolt",boltshape,medSDDss);
921   bolt->SetVisibility(kTRUE);
922   bolt->SetLineColor(1);  // Black
923   bolt->SetLineWidth(1);
924   bolt->SetFillColor(bolt->GetLineColor());
925   bolt->SetFillStyle(4050); // 50% transparent
926
927   // Mount up the cylinder
928   for(Int_t i=0; i<kNBolts; i++){
929     t = kThetaBolt*i;
930     x = kBoltRadius*CosD(t);
931     y = kBoltRadius*SinD(t);
932     z = kFlangeHalfLength-kBoltDepth;
933     flangecylinder->AddNode(bolt, i+1, new TGeoTranslation("",x,y,z));
934   }
935
936   cfcylinder->AddNode(foamcylinder,1,0);
937   cfcylinder->AddNode(flangecylinder,1,
938               new TGeoTranslation(0, 0, kInsertoHalfLength+kFlangeHalfLength));
939   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
940               0, 0, -kInsertoHalfLength-kFlangeHalfLength,
941               new TGeoRotation("",0,180,0)     ) );
942
943
944   // SDD Support Cone with its internal inserts: a carbon fiber Pcon
945   // with holes which contains a stesalite Pcon which on turn contains a
946   // rohacell Pcon
947
948   dza = kConeThickness/kSinConeTheta-(kConeROutMax-kConeROutMin)/kTanConeTheta;
949
950   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 10);
951
952   coneshape->Z(0)     = 0.0;
953   coneshape->Rmin(0)  = kConeROutMin;
954   coneshape->Rmax(0)  = kConeROutMax;
955
956   coneshape->Z(1)     = kConeZOuterMilled - dza;
957   coneshape->Rmin(1)  = coneshape->GetRmin(0);
958   coneshape->Rmax(1)  = coneshape->GetRmax(0);
959
960   coneshape->Z(2)     = kConeZOuterMilled;
961   coneshape->Rmax(2)  = coneshape->GetRmax(0);
962
963   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(1),
964                     coneshape->GetRmin(1),kConeTheta,z,rmin);
965   coneshape->Z(3)     = z;
966   coneshape->Rmin(3)  = rmin;
967
968   coneshape->Rmin(2)  = RminFrom2Points(coneshape,3,1,coneshape->GetZ(2));
969
970   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(2),
971                     coneshape->GetRmax(2),kConeTheta,z,rmax);
972   coneshape->Z(4)     = z;
973   coneshape->Rmax(4)  = rmax;
974   coneshape->Rmin(4)  = RminFromZpCone(coneshape,3,kConeTheta,
975                                        coneshape->GetZ(4),0.0);
976
977   coneshape->Rmax(3)  = RmaxFrom2Points(coneshape,4,2,coneshape->GetZ(3));
978
979   coneshape->Z(6)     = kConeZCylinder - kConeDZin;
980
981   RadiusOfCurvature(kConeRCurv,90.0,coneshape->GetZ(6),0.0,
982                     90.0-kConeTheta,z,rmin);
983   coneshape->Z(5)     = z;
984   coneshape->Rmin(5)  = RminFromZpCone(coneshape,3,kConeTheta,z);
985   coneshape->Rmax(5)  = RmaxFromZpCone(coneshape,4,kConeTheta,z);
986
987   RadiusOfCurvature(kConeRCurv,90.-kConeTheta,
988                     0.0,coneshape->Rmin(5),90.0,z,rmin);
989   coneshape->Rmin(6)  = rmin;
990   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,4,kConeTheta,
991                                        coneshape->GetZ(6));
992
993   coneshape->Z(7)     = coneshape->GetZ(6);
994   coneshape->Rmin(7)  = kConeRinMin;
995   coneshape->Rmax(7)  = coneshape->GetRmax(6);
996
997   coneshape->Rmin(8)  = kConeRinMin;
998
999   RadiusOfCurvature(kConeRCurv,90.0,kConeZCylinder,kConeRinCylinder,
1000                     90.0-kConeTheta,z,rmax);
1001   coneshape->Z(8)     = z;
1002   coneshape->Rmax(8)  = rmax;
1003
1004   coneshape->Z(9)     = kConeZCylinder;
1005   coneshape->Rmin(9)  = kConeRinMin;
1006   coneshape->Rmax(9)  = kConeRinCylinder;
1007
1008
1009   // SDD Cone Insert: another Pcon
1010   Double_t x0, y0, x1, y1, x2, y2;
1011   TGeoPcon *coneinsertshape = new TGeoPcon(0.0, 360.0, 9);
1012
1013   coneinsertshape->Z(0)    = coneshape->GetZ(0) + kConeCFThickness;
1014   coneinsertshape->Rmin(0) = coneshape->GetRmin(0) + kConeCFThickness;
1015   coneinsertshape->Rmax(0) = coneshape->GetRmax(0) - kConeCFThickness;
1016
1017   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1018   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1019   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1020   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1021   coneinsertshape->Z(1)    = z;
1022   coneinsertshape->Rmin(1) = rmin;
1023   coneinsertshape->Rmax(1) = coneinsertshape->GetRmax(0);
1024
1025   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmax(1);
1026   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmax(2);
1027   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmax(3);
1028   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1029   coneinsertshape->Z(2)    = z;
1030   coneinsertshape->Rmax(2) = rmax;
1031
1032   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1033   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1034   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1035   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1036   coneinsertshape->Z(3)    = z;
1037   coneinsertshape->Rmin(3) = rmin;
1038
1039   x0 = coneinsertshape->GetZ(1); y0 = coneinsertshape->GetRmin(1);
1040   x1 = coneinsertshape->GetZ(3); y1 = coneinsertshape->GetRmin(3);
1041   coneinsertshape->Rmin(2) = Yfrom2Points(x0, y0, x1, y1,
1042                                           coneinsertshape->Z(2));
1043
1044   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
1045   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
1046   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
1047   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1048   coneinsertshape->Z(4)    = z;
1049   coneinsertshape->Rmax(4) = rmax;
1050
1051   x0 = coneinsertshape->GetZ(2); y0 = coneinsertshape->GetRmax(2);
1052   x1 = coneinsertshape->GetZ(4); y1 = coneinsertshape->GetRmax(4);
1053   coneinsertshape->Rmax(3) = Yfrom2Points(x0, y0, x1, y1,
1054                                           coneinsertshape->Z(3));
1055
1056   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmin(4);
1057   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmin(5);
1058   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmin(6);
1059   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1060   coneinsertshape->Z(5)    = z;
1061   coneinsertshape->Rmin(5) = rmin;
1062   coneinsertshape->Rmax(5) = coneinsertshape->GetRmax(4) -
1063           kTanConeTheta*(coneinsertshape->GetZ(5) - coneinsertshape->GetZ(4));
1064
1065   x0 = coneinsertshape->GetZ(3); y0 = coneinsertshape->GetRmin(3);
1066   x1 = coneinsertshape->GetZ(5); y1 = coneinsertshape->GetRmin(5);
1067   coneinsertshape->Rmin(4) = Yfrom2Points(x0, y0, x1, y1,
1068                                           coneinsertshape->Z(4));
1069
1070   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmin(5);
1071   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmin(6);
1072   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmin(7);
1073   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1074   coneinsertshape->Z(6)    = z;
1075   coneinsertshape->Rmin(6) = rmin;
1076   coneinsertshape->Rmax(6) = coneinsertshape->GetRmax(4) -
1077           kTanConeTheta*(coneinsertshape->GetZ(6) - coneinsertshape->GetZ(4));
1078
1079   coneinsertshape->Z(7)    = coneinsertshape->GetZ(6);
1080   coneinsertshape->Rmin(7) = coneshape->GetRmin(7) + kConeCFThickness;
1081   coneinsertshape->Rmax(7) = coneinsertshape->GetRmax(6);
1082
1083   coneinsertshape->Z(8)    = coneshape->GetZ(9) - kConeCFThickness;
1084   coneinsertshape->Rmin(8) = coneinsertshape->GetRmin(7);
1085   coneinsertshape->Rmax(8) = coneinsertshape->GetRmax(4) -
1086           kTanConeTheta*(coneinsertshape->GetZ(8) - coneinsertshape->GetZ(4));
1087
1088   // SDD Cone Foam: another Pcon
1089   TGeoPcon *conefoamshape = new TGeoPcon(0.0, 360.0, 4);
1090
1091   RadiusOfCurvature(kConeRCurv+kConeCFThickness,0.0,coneinsertshape->GetZ(1),
1092                     coneinsertshape->GetRmin(1),kConeTheta,z,rmin);
1093
1094   conefoamshape->Z(0)    = z;
1095   conefoamshape->Rmin(0) = rmin;
1096   conefoamshape->Rmax(0) = conefoamshape->GetRmin(0);
1097
1098   conefoamshape->Z(1)    = conefoamshape->GetZ(0)+
1099                          (kConeThickness-2.0*kConeCFThickness)/kSinConeTheta;
1100   conefoamshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1101                                           conefoamshape->GetZ(1));
1102   conefoamshape->Rmax(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1103                                           conefoamshape->GetZ(1));
1104
1105   conefoamshape->Z(2)    = coneshape->GetZ(5)-kConeCFThickness;
1106   conefoamshape->Rmin(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1107                                           conefoamshape->GetZ(2));
1108   conefoamshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1109                                           conefoamshape->GetZ(2));
1110
1111   conefoamshape->Z(3)    = coneinsertshape->GetZ(5)+
1112                          (kConeThickness-2.0*kConeCFThickness)*kCosConeTheta;
1113   conefoamshape->Rmax(3) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1114                                           conefoamshape->GetZ(3));
1115   conefoamshape->Rmin(3) = conefoamshape->GetRmax(3);
1116
1117   // SDD Cone Holes: Pcon's
1118   // A single hole volume gives an overlap with coneinsert, so
1119   // three contiguous volumes are created: one to be put in the cone foam
1120   // and two in the cone carbon fiber envelope
1121   TGeoPcon *hole1shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1122
1123   hole1shape->Rmin(0) = kHole1RMax;
1124   hole1shape->Rmax(0) = hole1shape->GetRmin(0);
1125   hole1shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1126                                        hole1shape->GetRmin(0));
1127
1128   hole1shape->Rmax(1) = hole1shape->GetRmax(0);
1129   hole1shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1130                                        hole1shape->GetRmax(1));
1131   hole1shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1132                                        hole1shape->GetZ(1));
1133
1134   hole1shape->Rmin(2) = kHole1RMin;
1135   hole1shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1136                                        hole1shape->GetRmin(2));
1137   hole1shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1138                                        hole1shape->GetZ(2));
1139
1140   hole1shape->Rmin(3) = hole1shape->GetRmin(2);
1141   hole1shape->Rmax(3) = hole1shape->GetRmin(3);
1142   hole1shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1143                                        hole1shape->GetRmax(3));
1144
1145   TGeoPcon *hole11shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1146
1147   hole11shape->Rmin(0) = kHole1RMax;
1148   hole11shape->Rmax(0) = hole11shape->GetRmin(0);
1149   hole11shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1150                                         hole11shape->GetRmin(0));
1151
1152   hole11shape->Rmax(1) = hole11shape->GetRmax(0);
1153   hole11shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1154                                         hole11shape->GetRmax(1));
1155   hole11shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1156                                         hole11shape->GetZ(1));
1157
1158   hole11shape->Rmin(2) = kHole1RMin;
1159   hole11shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1160                                         hole11shape->GetRmin(2));
1161   hole11shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1162                                         hole11shape->GetZ(2));
1163
1164   hole11shape->Rmin(3) = hole11shape->GetRmin(2);
1165   hole11shape->Rmax(3) = hole11shape->GetRmin(3);
1166   hole11shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1167                                         hole11shape->GetRmax(3));
1168
1169   TGeoPcon *hole12shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1170
1171   hole12shape->Rmin(0) = kHole1RMax;
1172   hole12shape->Rmax(0) = hole12shape->GetRmin(0);
1173   hole12shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1174                                         hole12shape->GetRmin(0));
1175
1176   hole12shape->Rmax(1) = hole12shape->GetRmax(0);
1177   hole12shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1178                                         hole12shape->GetRmax(1));
1179   hole12shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1180                                         hole12shape->GetZ(1));
1181
1182   hole12shape->Rmin(2) = kHole1RMin;
1183   hole12shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1184                                         hole12shape->GetRmin(2));
1185   hole12shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1186                                         hole12shape->GetZ(2));
1187
1188   hole12shape->Rmin(3) = hole12shape->GetRmin(2);
1189   hole12shape->Rmax(3) = hole12shape->GetRmin(3);
1190   hole12shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1191                                         hole12shape->GetRmax(3));
1192
1193   //
1194   TGeoPcon *hole2shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1195
1196   hole2shape->Rmin(0) = kHole2RMax;
1197   hole2shape->Rmax(0) = hole2shape->GetRmin(0);
1198   hole2shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1199                                        hole2shape->GetRmin(0));
1200
1201   hole2shape->Rmax(1) = hole2shape->GetRmax(0);
1202   hole2shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1203                                        hole2shape->GetRmax(1));
1204   hole2shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1205                                        hole2shape->GetZ(1));
1206
1207   hole2shape->Rmin(2) = kHole2RMin;
1208   hole2shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1209                                        hole2shape->GetRmin(2));
1210   hole2shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1211                                        hole2shape->GetZ(2));
1212
1213   hole2shape->Rmin(3) = hole2shape->GetRmin(2);
1214   hole2shape->Rmax(3) = hole2shape->GetRmin(3);
1215   hole2shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1216                                        hole2shape->GetRmax(3));
1217
1218   TGeoPcon *hole21shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1219
1220   hole21shape->Rmin(0) = kHole2RMax;
1221   hole21shape->Rmax(0) = hole21shape->GetRmin(0);
1222   hole21shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1223                                         hole21shape->GetRmin(0));
1224
1225   hole21shape->Rmax(1) = hole21shape->GetRmax(0);
1226   hole21shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1227                                         hole21shape->GetRmax(1));
1228   hole21shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1229                                         hole21shape->GetZ(1));
1230
1231   hole21shape->Rmin(2) = kHole2RMin;
1232   hole21shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1233                                         hole21shape->GetRmin(2));
1234   hole21shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1235                                         hole21shape->GetZ(2));
1236
1237   hole21shape->Rmin(3) = hole21shape->GetRmin(2);
1238   hole21shape->Rmax(3) = hole21shape->GetRmin(3);
1239   hole21shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1240                                         hole21shape->GetRmax(3));
1241
1242   TGeoPcon *hole22shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1243
1244   hole22shape->Rmin(0) = kHole2RMax;
1245   hole22shape->Rmax(0) = hole22shape->GetRmin(0);
1246   hole22shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1247                                         hole22shape->GetRmin(0));
1248
1249   hole22shape->Rmax(1) = hole22shape->GetRmax(0);
1250   hole22shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1251                                         hole22shape->GetRmax(1));
1252   hole22shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1253                                         hole22shape->GetZ(1));
1254
1255   hole22shape->Rmin(2) = kHole2RMin;
1256   hole22shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1257                                         hole22shape->GetRmin(2));
1258   hole22shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1259                                         hole22shape->GetZ(2));
1260
1261   hole22shape->Rmin(3) = hole22shape->GetRmin(2);
1262   hole22shape->Rmax(3) = hole22shape->GetRmin(3);
1263   hole22shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1264                                         hole22shape->GetRmax(3));
1265
1266   //
1267   Double_t holePhi;
1268   holePhi = (kHole3Width/kHole3RMin)*TMath::RadToDeg();
1269
1270   TGeoPcon *hole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1271
1272   hole3shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1273   hole3shape->Rmax(0) = hole3shape->GetRmin(0);
1274   hole3shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1275                                        hole3shape->GetRmin(0));
1276
1277   hole3shape->Rmax(1) = hole3shape->GetRmax(0);
1278   hole3shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1279                                        hole3shape->GetRmax(1));
1280   hole3shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1281                                        hole3shape->GetZ(1));
1282
1283   hole3shape->Rmin(2) = kHole3RMin;
1284   hole3shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1285                                        hole3shape->GetRmin(2));
1286   hole3shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1287                                        hole3shape->GetZ(2));
1288
1289   hole3shape->Rmin(3) = hole3shape->GetRmin(2);
1290   hole3shape->Rmax(3) = hole3shape->GetRmin(3);
1291   hole3shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1292                                        hole3shape->GetRmax(3));
1293
1294   TGeoPcon *hole31shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1295
1296   hole31shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1297   hole31shape->Rmax(0) = hole31shape->GetRmin(0);
1298   hole31shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1299                                         hole31shape->GetRmin(0));
1300
1301   hole31shape->Rmax(1) = hole31shape->GetRmax(0);
1302   hole31shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1303                                         hole31shape->GetRmax(1));
1304   hole31shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1305                                         hole31shape->GetZ(1));
1306
1307   hole31shape->Rmin(2) = kHole3RMin;
1308   hole31shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1309                                         hole31shape->GetRmin(2));
1310   hole31shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1311                                         hole31shape->GetZ(2));
1312
1313   hole31shape->Rmin(3) = hole31shape->GetRmin(2);
1314   hole31shape->Rmax(3) = hole31shape->GetRmin(3);
1315   hole31shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1316                                         hole31shape->GetRmax(3));
1317
1318   TGeoPcon *hole32shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1319
1320   hole32shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1321   hole32shape->Rmax(0) = hole32shape->GetRmin(0);
1322   hole32shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1323                                         hole32shape->GetRmin(0));
1324
1325   hole32shape->Rmax(1) = hole32shape->GetRmax(0);
1326   hole32shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1327                                         hole32shape->GetRmax(1));
1328   hole32shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1329                                         hole32shape->GetZ(1));
1330
1331   hole32shape->Rmin(2) = kHole3RMin;
1332   hole32shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1333                                         hole32shape->GetRmin(2));
1334   hole32shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1335                                         hole32shape->GetZ(2));
1336
1337   hole32shape->Rmin(3) = hole32shape->GetRmin(2);
1338   hole32shape->Rmax(3) = hole32shape->GetRmin(3);
1339   hole32shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1340                                         hole32shape->GetRmax(3));
1341
1342   //
1343   holePhi = (kHole4Width/kHole4RMin)*TMath::RadToDeg();
1344
1345   TGeoPcon *hole4shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1346
1347   hole4shape->Rmin(0) = kHole4RMin + kHole4DeltaR;
1348   hole4shape->Rmax(0) = hole4shape->GetRmin(0);
1349   hole4shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1350                                        hole4shape->GetRmin(0));
1351
1352   hole4shape->Rmax(1) = hole4shape->GetRmax(0);
1353   hole4shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1354                                        hole4shape->GetRmax(1));
1355   hole4shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1356                                        hole4shape->GetZ(1));
1357
1358   hole4shape->Rmin(2) = kHole4RMin;
1359   hole4shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1360                                        hole4shape->GetRmin(2));
1361   hole4shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1362                                        hole4shape->GetZ(2));
1363
1364   hole4shape->Rmin(3) = hole4shape->GetRmin(2);
1365   hole4shape->Rmax(3) = hole4shape->GetRmin(3);
1366   hole4shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1367                                        hole4shape->GetRmax(3));
1368
1369   // Cables to be put inside the holes: Pcon's
1370   // (fractions are manually computed from AliITSv11GeometrySDD::SDDCables
1371   TGeoPcon *hole1plastshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1372
1373   hole1plastshape->Rmin(0) = hole1shape->GetRmin(0);
1374   hole1plastshape->Rmax(0) = hole1shape->GetRmax(0);
1375   hole1plastshape->Z(0)    = hole1shape->GetZ(0);
1376
1377   hole1plastshape->Rmin(1) = hole1shape->GetRmin(1);
1378   hole1plastshape->Rmax(1) = hole1shape->GetRmax(1);
1379   hole1plastshape->Z(1)    = hole1shape->GetZ(1);
1380
1381   dza = hole1plastshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHolePlasticFrac;
1382
1383   hole1plastshape->Rmin(2) = dza;
1384   hole1plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1385                                             hole1plastshape->GetRmin(2));
1386   hole1plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1387                                             hole1plastshape->GetZ(2));
1388
1389   hole1plastshape->Rmin(3) = hole1plastshape->GetRmin(2);
1390   hole1plastshape->Rmax(3) = hole1plastshape->GetRmin(3);
1391   hole1plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1392                                             hole1plastshape->GetRmax(3));
1393
1394   TGeoPcon *hole1Cushape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1395
1396   hole1Cushape->Rmin(0) = hole1plastshape->GetRmin(2);
1397   hole1Cushape->Rmax(0) = hole1Cushape->GetRmin(0);
1398   hole1Cushape->Z(0)    = hole1plastshape->GetZ(2);
1399
1400   dza = hole1Cushape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleCuFrac;
1401
1402   hole1Cushape->Rmin(1) = dza;
1403   hole1Cushape->Rmax(1) = hole1Cushape->GetRmax(0);
1404   hole1Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1405                                          hole1Cushape->GetRmin(1));
1406
1407   hole1Cushape->Rmax(2) = hole1Cushape->GetRmax(0);
1408   hole1Cushape->Rmin(2) = hole1Cushape->GetRmin(1);
1409   hole1Cushape->Z(2)    = hole1plastshape->GetZ(3);
1410
1411   hole1Cushape->Rmin(3) = hole1Cushape->GetRmin(1);
1412   hole1Cushape->Rmax(3) = hole1Cushape->GetRmin(3);
1413   hole1Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1414                                          hole1Cushape->GetRmax(3));
1415
1416   TGeoPcon *hole1glassshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1417
1418   hole1glassshape->Rmin(0) = hole1Cushape->GetRmin(1);
1419   hole1glassshape->Rmax(0) = hole1glassshape->GetRmin(0);
1420   hole1glassshape->Z(0)    = hole1Cushape->GetZ(1);
1421
1422   dza = hole1glassshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleGlassFrac;
1423
1424   hole1glassshape->Rmin(1) = dza;
1425   hole1glassshape->Rmax(1) = hole1glassshape->GetRmax(0);
1426   hole1glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1427                                             hole1glassshape->GetRmin(1));
1428
1429   hole1glassshape->Rmax(2) = hole1glassshape->GetRmax(0);
1430   hole1glassshape->Rmin(2) = hole1glassshape->GetRmin(1);
1431   hole1glassshape->Z(2)    = hole1Cushape->GetZ(3);
1432
1433   hole1glassshape->Rmin(3) = hole1glassshape->GetRmin(1);
1434   hole1glassshape->Rmax(3) = hole1glassshape->GetRmin(3);
1435   hole1glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1436                                             hole1glassshape->GetRmax(3));
1437   //
1438   TGeoPcon *hole2plastshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1439
1440   hole2plastshape->Rmin(0) = hole2shape->GetRmin(0);
1441   hole2plastshape->Rmax(0) = hole2shape->GetRmax(0);
1442   hole2plastshape->Z(0)    = hole2shape->GetZ(0);
1443
1444   hole2plastshape->Rmin(1) = hole2shape->GetRmin(1);
1445   hole2plastshape->Rmax(1) = hole2shape->GetRmax(1);
1446   hole2plastshape->Z(1)    = hole2shape->GetZ(1);
1447
1448   dza = hole2plastshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHolePlasticFrac;
1449
1450   hole2plastshape->Rmin(2) = dza;
1451   hole2plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1452                                             hole2plastshape->GetRmin(2));
1453   hole2plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1454                                             hole2plastshape->GetZ(2));
1455
1456   hole2plastshape->Rmin(3) = hole2plastshape->GetRmin(2);
1457   hole2plastshape->Rmax(3) = hole2plastshape->GetRmin(3);
1458   hole2plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1459                                             hole2plastshape->GetRmax(3));
1460
1461   TGeoPcon *hole2Cushape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1462
1463   hole2Cushape->Rmin(0) = hole2plastshape->GetRmin(2);
1464   hole2Cushape->Rmax(0) = hole2Cushape->GetRmin(0);
1465   hole2Cushape->Z(0)    = hole2plastshape->GetZ(2);
1466
1467   dza = hole2Cushape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleCuFrac;
1468
1469   hole2Cushape->Rmin(1) = dza;
1470   hole2Cushape->Rmax(1) = hole2Cushape->GetRmax(0);
1471   hole2Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1472                                          hole2Cushape->GetRmin(1));
1473
1474   hole2Cushape->Rmax(2) = hole2Cushape->GetRmax(0);
1475   hole2Cushape->Rmin(2) = hole2Cushape->GetRmin(1);
1476   hole2Cushape->Z(2)    = hole2plastshape->GetZ(3);
1477
1478   hole2Cushape->Rmin(3) = hole2Cushape->GetRmin(1);
1479   hole2Cushape->Rmax(3) = hole2Cushape->GetRmin(3);
1480   hole2Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1481                                          hole2Cushape->GetRmax(3));
1482
1483   TGeoPcon *hole2glassshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1484
1485   hole2glassshape->Rmin(0) = hole2Cushape->GetRmin(1);
1486   hole2glassshape->Rmax(0) = hole2glassshape->GetRmin(0);
1487   hole2glassshape->Z(0)    = hole2Cushape->GetZ(1);
1488
1489   dza = hole2glassshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleGlassFrac;
1490
1491   hole2glassshape->Rmin(1) = dza;
1492   hole2glassshape->Rmax(1) = hole2glassshape->GetRmax(0);
1493   hole2glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1494                                             hole2glassshape->GetRmin(1));
1495
1496   hole2glassshape->Rmax(2) = hole2glassshape->GetRmax(0);
1497   hole2glassshape->Rmin(2) = hole2glassshape->GetRmin(1);
1498   hole2glassshape->Z(2)    = hole2Cushape->GetZ(3);
1499
1500   hole2glassshape->Rmin(3) = hole2glassshape->GetRmin(1);
1501   hole2glassshape->Rmax(3) = hole2glassshape->GetRmin(3);
1502   hole2glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1503                                             hole2glassshape->GetRmax(3));
1504
1505
1506   // Debug if requested
1507   if (GetDebug(1)) {
1508     coneshape->InspectShape();
1509     coneinsertshape->InspectShape();
1510     conefoamshape->InspectShape();
1511     hole1shape->InspectShape();
1512     hole2shape->InspectShape();
1513     hole3shape->InspectShape();
1514     hole4shape->InspectShape();
1515   }
1516
1517
1518   // We have the shapes: now create the real volumes
1519
1520   TGeoVolume *cfcone = new TGeoVolume("SDDCarbonFiberCone",
1521                                       coneshape,medSDDcf);
1522   cfcone->SetVisibility(kTRUE);
1523   cfcone->SetLineColor(4); // Blue
1524   cfcone->SetLineWidth(1);
1525   cfcone->SetFillColor(cfcone->GetLineColor());
1526   cfcone->SetFillStyle(4000); // 0% transparent
1527
1528   TGeoVolume *cfconeinsert = new TGeoVolume("SDDCarbonFiberConeInsert",
1529                                             coneinsertshape,medSDDste);
1530   cfconeinsert->SetVisibility(kTRUE);
1531   cfconeinsert->SetLineColor(2); // Red
1532   cfconeinsert->SetLineWidth(1);
1533   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
1534   cfconeinsert->SetFillStyle(4050); // 50% transparent
1535
1536   TGeoVolume *cfconefoam = new TGeoVolume("SDDCarbonFiberConeFoam",
1537                                           conefoamshape,medSDDroh);
1538   cfconefoam->SetVisibility(kTRUE);
1539   cfconefoam->SetLineColor(7); // Light blue
1540   cfconefoam->SetLineWidth(1);
1541   cfconefoam->SetFillColor(cfconefoam->GetLineColor());
1542   cfconefoam->SetFillStyle(4050); // 50% transparent
1543
1544   TGeoVolume *hole1 = new TGeoVolume("SDDCableHole1",
1545                                      hole1shape,medSDDair);
1546   hole1->SetVisibility(kTRUE);
1547   hole1->SetLineColor(5); // Yellow
1548   hole1->SetLineWidth(1);
1549   hole1->SetFillColor(hole1->GetLineColor());
1550   hole1->SetFillStyle(4090); // 90% transparent
1551
1552   TGeoVolume *hole11 = new TGeoVolume("SDDCableHole11",
1553                                       hole11shape,medSDDair);
1554   hole11->SetVisibility(kTRUE);
1555   hole11->SetLineColor(5); // Yellow
1556   hole11->SetLineWidth(1);
1557   hole11->SetFillColor(hole11->GetLineColor());
1558   hole11->SetFillStyle(4090); // 90% transparent
1559
1560   TGeoVolume *hole12 = new TGeoVolume("SDDCableHole12",
1561                                       hole12shape,medSDDair);
1562   hole12->SetVisibility(kTRUE);
1563   hole12->SetLineColor(5); // Yellow
1564   hole12->SetLineWidth(1);
1565   hole12->SetFillColor(hole12->GetLineColor());
1566   hole12->SetFillStyle(4090); // 90% transparent
1567
1568   TGeoVolume *hole1plast = new TGeoVolume("SDDCableHole1Plast",
1569                                           hole1plastshape,medSDDplast);
1570   hole1plast->SetVisibility(kTRUE);
1571   hole1plast->SetLineColor(kBlue);
1572   hole1plast->SetLineWidth(1);
1573   hole1plast->SetFillColor(hole1plast->GetLineColor());
1574   hole1plast->SetFillStyle(4090); // 90% transparent
1575
1576   TGeoVolume *hole1Cu = new TGeoVolume("SDDCableHole1Cu",
1577                                        hole1Cushape,medSDDCu);
1578   hole1Cu->SetVisibility(kTRUE);
1579   hole1Cu->SetLineColor(kRed);
1580   hole1Cu->SetLineWidth(1);
1581   hole1Cu->SetFillColor(hole1Cu->GetLineColor());
1582   hole1Cu->SetFillStyle(4090); // 90% transparent
1583
1584   TGeoVolume *hole1glass = new TGeoVolume("SDDCableHole1glass",
1585                                           hole1glassshape,medSDDglass);
1586   hole1glass->SetVisibility(kTRUE);
1587   hole1glass->SetLineColor(kGreen);
1588   hole1glass->SetLineWidth(1);
1589   hole1glass->SetFillColor(hole1glass->GetLineColor());
1590   hole1glass->SetFillStyle(4090); // 90% transparent
1591
1592   TGeoVolume *hole2 = new TGeoVolume("SDDCableHole2",
1593                                      hole2shape,medSDDair);
1594   hole2->SetVisibility(kTRUE);
1595   hole2->SetLineColor(5); // Yellow
1596   hole2->SetLineWidth(1);
1597   hole2->SetFillColor(hole2->GetLineColor());
1598   hole2->SetFillStyle(4090); // 90% transparent
1599
1600   TGeoVolume *hole21 = new TGeoVolume("SDDCableHole21",
1601                                       hole21shape,medSDDair);
1602   hole21->SetVisibility(kTRUE);
1603   hole21->SetLineColor(5); // Yellow
1604   hole21->SetLineWidth(1);
1605   hole21->SetFillColor(hole21->GetLineColor());
1606   hole21->SetFillStyle(4090); // 90% transparent
1607
1608   TGeoVolume *hole22 = new TGeoVolume("SDDCableHole22",
1609                                       hole22shape,medSDDair);
1610   hole22->SetVisibility(kTRUE);
1611   hole22->SetLineColor(5); // Yellow
1612   hole22->SetLineWidth(1);
1613   hole22->SetFillColor(hole22->GetLineColor());
1614   hole22->SetFillStyle(4090); // 90% transparent
1615
1616   TGeoVolume *hole2plast = new TGeoVolume("SDDCableHole2Plast",
1617                                           hole2plastshape,medSDDplast);
1618   hole2plast->SetVisibility(kTRUE);
1619   hole2plast->SetLineColor(kBlue);
1620   hole2plast->SetLineWidth(1);
1621   hole2plast->SetFillColor(hole2plast->GetLineColor());
1622   hole2plast->SetFillStyle(4090); // 90% transparent
1623
1624   TGeoVolume *hole2Cu = new TGeoVolume("SDDCableHole2Cu",
1625                                        hole2Cushape,medSDDCu);
1626   hole2Cu->SetVisibility(kTRUE);
1627   hole2Cu->SetLineColor(kRed);
1628   hole2Cu->SetLineWidth(1);
1629   hole2Cu->SetFillColor(hole2Cu->GetLineColor());
1630   hole2Cu->SetFillStyle(4090); // 90% transparent
1631
1632   TGeoVolume *hole2glass = new TGeoVolume("SDDCableHole2glass",
1633                                           hole2glassshape,medSDDglass);
1634   hole2glass->SetVisibility(kTRUE);
1635   hole2glass->SetLineColor(kGreen);
1636   hole2glass->SetLineWidth(1);
1637   hole2glass->SetFillColor(hole2glass->GetLineColor());
1638   hole2glass->SetFillStyle(4090); // 90% transparent
1639
1640   TGeoVolume *hole3 = new TGeoVolume("SDDCableHole3",
1641                                      hole3shape,medSDDair);
1642   hole3->SetVisibility(kTRUE);
1643   hole3->SetLineColor(5); // Yellow
1644   hole3->SetLineWidth(1);
1645   hole3->SetFillColor(hole3->GetLineColor());
1646   hole3->SetFillStyle(4090); // 90% transparent
1647
1648   TGeoVolume *hole31 = new TGeoVolume("SDDCableHole31",
1649                                       hole31shape,medSDDair);
1650   hole31->SetVisibility(kTRUE);
1651   hole31->SetLineColor(5); // Yellow
1652   hole31->SetLineWidth(1);
1653   hole31->SetFillColor(hole31->GetLineColor());
1654   hole31->SetFillStyle(4090); // 90% transparent
1655
1656   TGeoVolume *hole32 = new TGeoVolume("SDDCableHole32",
1657                                       hole32shape,medSDDair);
1658   hole32->SetVisibility(kTRUE);
1659   hole32->SetLineColor(5); // Yellow
1660   hole32->SetLineWidth(1);
1661   hole32->SetFillColor(hole32->GetLineColor());
1662   hole32->SetFillStyle(4090); // 90% transparent
1663
1664   TGeoVolume *hole4 = new TGeoVolume("SDDCableHole4",
1665                                      hole4shape,medSDDair);
1666   hole4->SetVisibility(kTRUE);
1667   hole4->SetLineColor(5); // Yellow
1668   hole4->SetLineWidth(1);
1669   hole4->SetFillColor(hole4->GetLineColor());
1670   hole4->SetFillStyle(4090); // 90% transparent
1671
1672   // Mount up a cone
1673   cfconeinsert->AddNode(cfconefoam,1,0);
1674
1675   hole1->AddNode(hole1plast, 1, 0);
1676   hole1->AddNode(hole1Cu, 1, 0);
1677   hole1->AddNode(hole1glass, 1, 0);
1678
1679   hole2->AddNode(hole2plast, 1, 0);
1680   hole2->AddNode(hole2Cu, 1, 0);
1681   hole2->AddNode(hole2glass, 1, 0);
1682
1683   for (Int_t i=0; i<12; i++) {
1684     Double_t phiH = i*30.0;
1685     cfconefoam->AddNode(hole1 , i+1, new TGeoRotation("", 0, 0, phiH));
1686         cfcone->AddNode(hole11, i+1, new TGeoRotation("", 0, 0, phiH));
1687         cfcone->AddNode(hole12, i+1, new TGeoRotation("", 0, 0, phiH));
1688   }
1689
1690   for (Int_t i=0; i<6; i++) {
1691     Double_t phiH = i*60.0;
1692     cfconefoam->AddNode(hole2 , i+1, new TGeoRotation("", 0, 0, phiH));
1693         cfcone->AddNode(hole21, i+1, new TGeoRotation("", 0, 0, phiH));
1694         cfcone->AddNode(hole22, i+1, new TGeoRotation("", 0, 0, phiH));
1695   }
1696
1697   for (Int_t i=0; i<kNHole3; i++) {
1698     Double_t phiH0 = 360./(Double_t)kNHole3;
1699     Double_t phiH  = i*phiH0 + 0.5*phiH0;
1700     cfconefoam->AddNode(hole3 , i+1, new TGeoRotation("", phiH, 0, 0));
1701         cfcone->AddNode(hole31, i+1, new TGeoRotation("", phiH, 0, 0));
1702         cfcone->AddNode(hole32, i+1, new TGeoRotation("", phiH, 0, 0));
1703   }
1704
1705   cfcone->AddNode(cfconeinsert,1,0);
1706
1707 /*
1708   for (Int_t i=0; i<kNHole4; i++) {
1709     Double_t phiH0 = 360./(Double_t)kNHole4;
1710     Double_t phiH  = i*phiH0 + 0.25*phiH0;
1711     cfcone->AddNode(hole4, i+1, new TGeoRotation("", phiH, 0, 0));
1712   }
1713 */
1714   // Finally put everything in the mother volume
1715   moth->AddNode(cfcylinder,1,0);
1716
1717   z = coneshape->Z(9);
1718   moth->AddNode(cfcone,1,new TGeoTranslation(0, 0, -z - kCylinderHalfLength));
1719   moth->AddNode(cfcone,2,new TGeoCombiTrans (0, 0,  z + kCylinderHalfLength,
1720                          new TGeoRotation("", 0, 180, 0)                   ));
1721
1722
1723   return;
1724 }
1725
1726 //______________________________________________________________________
1727 void AliITSv11GeometrySupport::SSDCone(TGeoVolume *moth,TGeoManager *mgr)
1728 {
1729 //
1730 // Creates the SSD support cone and cylinder geometry. as a
1731 // volume assembly and adds it to the mother volume
1732 // (part of this code is taken or anyway inspired to SSDCone method
1733 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
1734 //
1735 // Input:
1736 //         moth : the TGeoVolume owing the volume structure
1737 //         mgr  : the GeoManager (default gGeoManager)
1738 // Output:
1739 //
1740 // Created:         ???       Bjorn S. Nilsen
1741 // Updated:      08 Mar 2008  Mario Sitta
1742 //
1743 // Technical data are taken from:  "ITS Supporto Generale" (technical
1744 // drawings ALR3-0743/1, ALR3-0743/1A and ALR3-0743/1B), "Supporto Generale
1745 // Settore SSD" (technical drawings ALR3-0743/2A and ALR3-0743/2E), private
1746 // communication with B. Giraudo
1747 //
1748 // Updated:      11 Apr 2008  Mario Sitta
1749 // Measures from drawings give overlaps with SPD thermal shield wings,
1750 // so the terminal part of the SSD cone was reduced
1751 //
1752 // Updated:      30 Mar 2010  Mario Sitta
1753 // Following M. van Leeuwen's suggestion on material budget, the thickness
1754 // of the carbon fiber cylinder was increased from 0.6 to 0.625mm
1755
1756   // Dimensions of the Central cylinder and flanges
1757   const Double_t kCylinderHalfLength   = (1144.0/2) *fgkmm;
1758   const Double_t kCylinderOuterRadius  = ( 595.0/2) *fgkmm;
1759   const Double_t kCylinderThickness    =       0.625*fgkmm;
1760   const Double_t kFoamHalfLength       = (1020.0/2) *fgkmm;
1761   const Double_t kFoamThickness        =        5.0 *fgkmm;
1762   const Double_t kFlangeHalfLength     =
1763                                       (kCylinderHalfLength-kFoamHalfLength)/2.;
1764   const Double_t kFlangeInnerRadius    = ( 563.0/2) *fgkmm;
1765   // Dimensions of the Cone
1766   const Double_t kConeROuterMin        = ( 957.0/2) *fgkmm;
1767   const Double_t kConeROuterMax        = ( 997.0/2) *fgkmm;
1768   const Double_t kConeRInnerMin        = ( 564.0/2) *fgkmm;
1769   const Double_t kConeRCurv1           =       10.0 *fgkmm;
1770   const Double_t kConeRCurv2           =       25.0 *fgkmm;
1771   const Double_t kConeCent1RCurv2      = ( 578.0/2) *fgkmm;
1772   const Double_t kConeCent2RCurv2      = ( 592.0/2) *fgkmm;
1773 //  const Double_t kConeZOuterRing       =       47.0 *fgkmm;
1774 //  const Double_t kConeZOuterRingInside =       30.25*fgkmm;
1775 //  const Double_t kConeZInnerRing       =      161.5 *fgkmm;
1776 //  const Double_t kConeZLength          =      176.5 *fgkmm;
1777   const Double_t kConeZOuterRing       =       38.5 *fgkmm;
1778   const Double_t kConeZOuterRingInside =       22.2 *fgkmm;
1779   const Double_t kConeZInnerRing       =      153.0 *fgkmm;
1780   const Double_t kConeZLength          =      168.0 *fgkmm;
1781   const Double_t kConeZPosition        = kConeZLength + kCylinderHalfLength;
1782   const Double_t kConeThickness        =       13.0 *fgkmm; // Cone thickness
1783   const Double_t kConeTheta            =       39.1 *fgkDegree; // Cone angle
1784   const Double_t kSinConeTheta         =
1785                                       TMath::Sin(kConeTheta*TMath::DegToRad());
1786   const Double_t kCosConeTheta         =
1787                                       TMath::Cos(kConeTheta*TMath::DegToRad());
1788   // Dimensions of the Foam cores
1789   const Double_t kConeFoam1Length      =      112.3 *fgkmm;
1790   const Double_t kConeFoam2Length      =       58.4 *fgkmm;
1791   // Dimensions of the Cone Holes
1792   const Double_t kCoolingHoleWidth     =       40.0 *fgkmm;
1793   const Double_t kCoolingHoleHight     =       30.0 *fgkmm;
1794   const Double_t kCoolingHoleRmin      =      350.0 *fgkmm;
1795   const Double_t kCoolingHolePhi       =       45.0 *fgkDegree;
1796   const Double_t kMountingHoleWidth    =       20.0 *fgkmm;
1797   const Double_t kMountingHoleHight    =       20.0 *fgkmm;
1798   const Double_t kMountingHoleRmin     =      317.5 *fgkmm;
1799   const Double_t kMountingHolePhi      =       60.0 *fgkDegree;
1800   const Double_t kCableHoleRin         = ( 800.0/2) *fgkmm;
1801   const Double_t kCableHoleRout        = ( 920.0/2) *fgkmm;
1802   const Double_t kCableHoleWidth       =      200.0 *fgkmm;
1803 //  const Double_t kCableHoleAngle       =       42.0 *fgkDegree;
1804   // Dimensions of the Cone Wings
1805   const Double_t kWingRmax             =      527.5 *fgkmm;
1806   const Double_t kWingWidth            =       70.0 *fgkmm;
1807   const Double_t kWingHalfThick        = (  10.0/2) *fgkmm;
1808   const Double_t kThetaWing            =       45.0 *fgkDegree;
1809   // Dimensions of the SSD-SDD Mounting Brackets
1810   const Double_t kBracketRmin          = ( 541.0/2) *fgkmm;// See SDD ROutMin
1811   const Double_t kBracketRmax          = ( 585.0/2) *fgkmm;
1812   const Double_t kBracketHalfLength    = (   4.0/2) *fgkmm;
1813   const Double_t kBracketPhi           = (70.*fgkmm/kBracketRmax)*fgkRadian;
1814   // Common data
1815   const Double_t kCFThickness          =        0.75*fgkmm; //Carb. fib. thick.
1816
1817
1818   // Local variables
1819   Double_t rmin1, rmin2, rmax, z;
1820
1821   //
1822   //Begin_Html
1823   /*
1824     <img src="picts/ITS/file_name.gif">
1825     <P>
1826     <FONT FACE'"TIMES">
1827     ITS SSD central support and thermal shield cylinder.
1828     </FONT>
1829     </P>
1830   */
1831   //End_Html
1832   //
1833
1834   // Central cylinder with its internal foam and the lateral flanges:
1835   // a carbon fiber Pcon which contains a rohacell Tube and two
1836   // stesalite Cone's
1837   TGeoPcon *externalcylshape = new TGeoPcon(0,360,4);
1838
1839   rmax  = kCylinderOuterRadius;
1840   rmin1 = kFlangeInnerRadius - kCylinderThickness;
1841   rmin2 = rmax - 2*kCylinderThickness - kFoamThickness;
1842   externalcylshape->DefineSection(0,-kCylinderHalfLength,rmin1,rmax);
1843   externalcylshape->DefineSection(1,-kFoamHalfLength    ,rmin2,rmax);
1844   externalcylshape->DefineSection(2, kFoamHalfLength    ,rmin2,rmax);
1845   externalcylshape->DefineSection(3, kCylinderHalfLength,rmin1,rmax);
1846
1847   rmax  = kCylinderOuterRadius - kCylinderThickness;
1848   rmin1 = rmax - kFoamThickness;
1849   TGeoTube *foamshape = new TGeoTube(rmin1,rmax,kFoamHalfLength);
1850
1851   rmax  = kCylinderOuterRadius - kCylinderThickness;
1852   rmin1 = rmax - kFoamThickness;
1853   rmin2 = kFlangeInnerRadius;
1854   TGeoCone *flangeshape = new TGeoCone(kFlangeHalfLength,
1855                                        rmin1,rmax,rmin2,rmax);
1856
1857
1858   // We have the shapes: now create the real volumes
1859
1860   TGeoMedium *medSSDcf  = mgr->GetMedium("ITS_SSD C (M55J)$");
1861   TGeoMedium *medSSDair = mgr->GetMedium("ITS_SSD AIR$");
1862   TGeoMedium *medSSDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
1863   TGeoMedium *medSSDroh = mgr->GetMedium("ITS_ROHACELL$");
1864   TGeoMedium *medSSDal  = mgr->GetMedium("ITS_ALUMINUM$");
1865
1866   TGeoVolume *cfcylinder = new TGeoVolume("SSDexternalcylinder",
1867                                            externalcylshape,medSSDcf);
1868   cfcylinder->SetVisibility(kTRUE);
1869   cfcylinder->SetLineColor(4); // blue
1870   cfcylinder->SetLineWidth(1);
1871   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
1872   cfcylinder->SetFillStyle(4000); // 0% transparent
1873
1874   TGeoVolume *foamcylinder = new TGeoVolume("SSDfoamcylinder",
1875                                             foamshape,medSSDroh);
1876   foamcylinder->SetVisibility(kTRUE);
1877   foamcylinder->SetLineColor(3); // green
1878   foamcylinder->SetLineWidth(1);
1879   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
1880   foamcylinder->SetFillStyle(4050); // 50% transparent
1881
1882   TGeoVolume *flangecylinder = new TGeoVolume("SSDflangecylinder",
1883                                               flangeshape,medSSDste);
1884   flangecylinder->SetVisibility(kTRUE);
1885   flangecylinder->SetLineColor(2); // red
1886   flangecylinder->SetLineWidth(1);
1887   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
1888   flangecylinder->SetFillStyle(4050); // 50% transparent
1889
1890   // Mount up the cylinder
1891   cfcylinder->AddNode(foamcylinder,1,0);
1892   cfcylinder->AddNode(flangecylinder,1,
1893               new TGeoTranslation(0, 0, kFoamHalfLength+kFlangeHalfLength));
1894   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
1895               0, 0, -kFoamHalfLength-kFlangeHalfLength,
1896               new TGeoRotation("",0,180,0)     ) );
1897
1898
1899   // The whole Cone as an assembly
1900   TGeoVolumeAssembly *vC = new TGeoVolumeAssembly("ITSssdCone");
1901
1902
1903   // SSD Support Cone with its internal inserts: a carbon fiber Pcon
1904   // with holes which contains a stesalite Pcon which on turn contains a
1905   // rohacell Pcon
1906   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 12);
1907
1908   coneshape->Z(0)     = 0.0;
1909   coneshape->Rmin(0)  = kConeROuterMin;
1910   coneshape->Rmax(0)  = kConeROuterMax;
1911
1912   coneshape->Z(1)     = kConeZOuterRingInside - kConeRCurv1;
1913   coneshape->Rmin(1)  = coneshape->GetRmin(0);
1914   coneshape->Rmax(1)  = coneshape->GetRmax(0);
1915
1916   coneshape->Z(2)     = kConeZOuterRingInside;
1917   coneshape->Rmin(2)  = coneshape->GetRmin(1) - kConeRCurv1;
1918   coneshape->Rmax(2)  = coneshape->GetRmax(0);
1919
1920   coneshape->Z(3)     = coneshape->GetZ(2);
1921   coneshape->Rmax(3)  = coneshape->GetRmax(0);
1922
1923   coneshape->Z(4)     = kConeZOuterRing - kConeRCurv1;
1924   coneshape->Rmax(4)  = coneshape->GetRmax(0);
1925
1926   coneshape->Z(5)     = kConeZOuterRing;
1927   coneshape->Rmax(5)  = coneshape->GetRmax(4) - kConeRCurv1;
1928
1929   coneshape->Z(6)     = coneshape->GetZ(5);
1930
1931   RadiusOfCurvature(kConeRCurv2,90.0,kConeZInnerRing,kConeCent1RCurv2,
1932                     90.0-kConeTheta,z,rmin1);
1933   coneshape->Z(7)     = z;
1934   coneshape->Rmin(7)  = rmin1;
1935
1936   coneshape->Rmin(3)  = RminFromZpCone(coneshape,7,90.-kConeTheta,
1937                                        coneshape->GetZ(3));
1938
1939   coneshape->Rmin(4)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(4));
1940
1941   coneshape->Rmin(5)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(5));
1942
1943   coneshape->Rmin(6) = coneshape->GetRmin(5);
1944
1945   coneshape->Z(8)     = kConeZInnerRing;
1946   coneshape->Rmin(8)  = kConeCent1RCurv2;
1947
1948   coneshape->Z(9)     = coneshape->GetZ(8);
1949   coneshape->Rmin(9)  = kConeRInnerMin;
1950
1951   RadiusOfCurvature(kConeRCurv2,90.0,kConeZLength,kConeCent2RCurv2,
1952                     90.0-kConeTheta,z,rmax);
1953
1954   coneshape->Z(10)    = z;
1955   coneshape->Rmin(10) = coneshape->GetRmin(9);
1956   coneshape->Rmax(10) = rmax;
1957
1958   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,10,90.-kConeTheta,
1959                                        coneshape->GetZ(6));
1960
1961   coneshape->Rmax(7)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(7));
1962
1963   coneshape->Rmax(8)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(8));
1964
1965   coneshape->Rmax(9)  = coneshape->GetRmax(8);
1966
1967   coneshape->Z(11)    = kConeZLength;
1968   coneshape->Rmin(11) = coneshape->GetRmin(10);
1969   coneshape->Rmax(11) = kConeCent2RCurv2;
1970
1971   // SSD Cone Insert: another Pcon
1972   Double_t x0, y0, x1, y1, x2, y2;
1973   TGeoPcon *coneinsertshape = new TGeoPcon(0.0,360.0,12);
1974
1975   coneinsertshape->Z(0)     = coneshape->GetZ(0) + kCFThickness;
1976   coneinsertshape->Rmin(0)  = coneshape->GetRmin(0) + kCFThickness;
1977   coneinsertshape->Rmax(0)  = coneshape->GetRmax(0) - kCFThickness;
1978
1979   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1980   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1981   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1982   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1983   coneinsertshape->Z(1)     = z;
1984   coneinsertshape->Rmin(1)  = rmin1;
1985   coneinsertshape->Rmax(1)  = coneinsertshape->GetRmax(0);
1986
1987   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmin(1);
1988   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmin(2);
1989   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmin(3);
1990   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1991   coneinsertshape->Z(2)     = z;
1992   coneinsertshape->Rmin(2)  = rmin1;
1993   coneinsertshape->Rmax(2)  = coneinsertshape->GetRmax(1);
1994
1995   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1996   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1997   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1998   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1999   coneinsertshape->Z(3)     = z;
2000   coneinsertshape->Rmin(3)  = rmin1;
2001   coneinsertshape->Rmax(3)  = coneinsertshape->GetRmax(2);
2002
2003   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
2004   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
2005   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
2006   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2007   coneinsertshape->Z(4)     = z;
2008   coneinsertshape->Rmax(4)  = rmax;
2009
2010   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmax(4);
2011   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmax(5);
2012   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmax(6);
2013   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2014   coneinsertshape->Z(5)     = z;
2015   coneinsertshape->Rmax(5)  = rmax;
2016
2017   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmax(5);
2018   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmax(6);
2019   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmax(7);
2020   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2021   coneinsertshape->Z(6)     = z;
2022   coneinsertshape->Rmax(6)  = rmax;
2023
2024   x0 = coneshape->GetZ(6); y0 = coneshape->GetRmin(6);
2025   x1 = coneshape->GetZ(7); y1 = coneshape->GetRmin(7);
2026   x2 = coneshape->GetZ(8); y2 = coneshape->GetRmin(8);
2027   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2028   coneinsertshape->Z(7)     = z;
2029   coneinsertshape->Rmin(7)  = rmin1;
2030
2031   coneinsertshape->Rmin(4)  = RminFrom2Points(coneinsertshape,3,7,
2032                                               coneinsertshape->GetZ(4));
2033
2034   coneinsertshape->Rmin(5)  = RminFrom2Points(coneinsertshape,3,7,
2035                                               coneinsertshape->GetZ(5));
2036
2037   coneinsertshape->Rmin(6)  = coneinsertshape->GetRmin(5);
2038
2039   x0 = coneshape->GetZ(7); y0 = coneshape->GetRmin(7);
2040   x1 = coneshape->GetZ(8); y1 = coneshape->GetRmin(8);
2041   x2 = coneshape->GetZ(9); y2 = coneshape->GetRmin(9);
2042   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2043   coneinsertshape->Z(8)     = z;
2044   coneinsertshape->Rmin(8)  = rmin1;
2045
2046   x0 = coneshape->GetZ( 8); y0 = coneshape->GetRmin( 8);
2047   x1 = coneshape->GetZ( 9); y1 = coneshape->GetRmin( 9);
2048   x2 = coneshape->GetZ(10); y2 = coneshape->GetRmin(10);
2049   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2050   coneinsertshape->Z(9)     = z;
2051   coneinsertshape->Rmin(9)  = rmin1;
2052
2053   x0 = coneshape->GetZ( 9); y0 = coneshape->GetRmax( 9);
2054   x1 = coneshape->GetZ(10); y1 = coneshape->GetRmax(10);
2055   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmax(11);
2056   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2057   coneinsertshape->Z(10)    = z;
2058   coneinsertshape->Rmax(10) = rmax;
2059   coneinsertshape->Rmin(10) = coneinsertshape->GetRmin(9);
2060
2061   coneinsertshape->Rmax(7)  = RmaxFrom2Points(coneinsertshape,6,10,
2062                                               coneinsertshape->GetZ(7));
2063
2064   coneinsertshape->Rmax(8)  = RmaxFrom2Points(coneinsertshape,6,10,
2065                                               coneinsertshape->GetZ(8));
2066
2067   coneinsertshape->Rmax(9)  = coneinsertshape->GetRmax(8);
2068
2069   x0 = coneshape->GetZ(10); y0 = coneshape->GetRmax(10);
2070   x1 = coneshape->GetZ(11); y1 = coneshape->GetRmax(11);
2071   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmin(11);
2072   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2073   coneinsertshape->Z(11)    = z;
2074   coneinsertshape->Rmax(11) = rmax;
2075   coneinsertshape->Rmin(11) = coneinsertshape->GetRmin(10);
2076
2077   // SSD Cone Foams: two other Pcon's
2078   TGeoPcon *conefoam1shape = new TGeoPcon(0.0, 360.0, 4);
2079
2080   conefoam1shape->Z(0)    = coneinsertshape->GetZ(3);
2081   conefoam1shape->Rmin(0) = coneinsertshape->GetRmin(3);
2082   conefoam1shape->Rmax(0) = conefoam1shape->GetRmin(0);
2083
2084   conefoam1shape->Rmax(1) = conefoam1shape->GetRmax(0);
2085   conefoam1shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2086                                            conefoam1shape->GetRmax(1));
2087   conefoam1shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2088                                            conefoam1shape->GetZ(1));
2089
2090   Double_t t = kConeThickness - 2*kCFThickness;
2091   conefoam1shape->Rmin(2) = conefoam1shape->GetRmax(0) -
2092                            (kConeFoam1Length*kCosConeTheta - t*kSinConeTheta);
2093   conefoam1shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2094                                            conefoam1shape->GetRmin(2));
2095   conefoam1shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2096                                            conefoam1shape->GetZ(2));
2097
2098   conefoam1shape->Rmin(3) = conefoam1shape->GetRmin(2);
2099   conefoam1shape->Rmax(3) = conefoam1shape->GetRmin(3);
2100   conefoam1shape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2101                                            conefoam1shape->GetRmax(3));
2102
2103   TGeoPcon *conefoam2shape = new TGeoPcon(0.0, 360.0, 4);
2104
2105   conefoam2shape->Z(3)    = coneinsertshape->GetZ(10);
2106   conefoam2shape->Rmin(3) = coneinsertshape->GetRmax(10);
2107   conefoam2shape->Rmax(3) = conefoam2shape->GetRmin(3);
2108
2109   conefoam2shape->Rmin(2) = conefoam2shape->GetRmin(3);
2110   conefoam2shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2111                                            conefoam2shape->GetRmin(2));
2112   conefoam2shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2113                                            conefoam2shape->GetZ(2));
2114
2115   conefoam2shape->Rmin(0) = conefoam2shape->GetRmax(2) +
2116                            (kConeFoam2Length*kCosConeTheta - t*kSinConeTheta);
2117   conefoam2shape->Rmax(0) = conefoam2shape->GetRmin(0);
2118   conefoam2shape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2119                                            conefoam2shape->GetRmin(0));
2120
2121   conefoam2shape->Rmax(1) = conefoam2shape->GetRmax(0);
2122   conefoam2shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2123                                            conefoam2shape->GetRmax(1));
2124   conefoam2shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2125                                            conefoam2shape->GetZ(1));
2126
2127   // SSD Cone Holes: Pcon's
2128   // A single hole volume gives an overlap with coneinsert, so
2129   // three contiguous volumes are created: one to be put in coneinsert
2130   // and two in the cone carbon fiber envelope
2131   Double_t holePhi;
2132   holePhi = (kCoolingHoleWidth/kCoolingHoleRmin)*TMath::RadToDeg();
2133
2134   TGeoPcon *coolingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2135
2136   coolingholeshape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2137   coolingholeshape->Rmax(0) = coolingholeshape->GetRmin(0);
2138   coolingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2139                                              coolingholeshape->GetRmin(0));
2140
2141   coolingholeshape->Rmax(1) = coolingholeshape->GetRmax(0);
2142   coolingholeshape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2143                                              coolingholeshape->GetRmax(1));
2144   coolingholeshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2145                                              coolingholeshape->GetZ(1));
2146
2147   coolingholeshape->Rmin(2) = kCoolingHoleRmin;
2148   coolingholeshape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2149                                              coolingholeshape->GetRmin(2));
2150   coolingholeshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2151                                              coolingholeshape->GetZ(2));
2152
2153   coolingholeshape->Rmin(3) = coolingholeshape->GetRmin(2);
2154   coolingholeshape->Rmax(3) = coolingholeshape->GetRmin(3);
2155   coolingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2156                                              coolingholeshape->GetRmax(3));
2157
2158   TGeoPcon *coolinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2159
2160   coolinghole2shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2161   coolinghole2shape->Rmax(0) = coolinghole2shape->GetRmin(0);
2162   coolinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2163                                               coolinghole2shape->GetRmin(0));
2164
2165   coolinghole2shape->Rmax(1) = coolinghole2shape->GetRmax(0);
2166   coolinghole2shape->Z(1)    = coolingholeshape->GetZ(0);
2167   coolinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2168                                               coolinghole2shape->GetZ(1));
2169
2170   coolinghole2shape->Rmin(2) = kCoolingHoleRmin;
2171   coolinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2172                                               coolinghole2shape->GetRmin(2));
2173   coolinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2174                                               coolinghole2shape->GetZ(2));
2175
2176   coolinghole2shape->Rmin(3) = coolinghole2shape->GetRmin(2);
2177   coolinghole2shape->Rmax(3) = coolinghole2shape->GetRmin(3);
2178   coolinghole2shape->Z(3)    = coolingholeshape->GetZ(2);
2179
2180   TGeoPcon *coolinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2181
2182   coolinghole3shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2183   coolinghole3shape->Rmax(0) = coolinghole3shape->GetRmin(0);
2184   coolinghole3shape->Z(0)    = coolingholeshape->GetZ(1);
2185
2186   coolinghole3shape->Rmax(1) = coolinghole3shape->GetRmax(0);
2187   coolinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2188                                               coolinghole3shape->GetRmax(1));
2189   coolinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2190                                               coolinghole3shape->GetZ(1));
2191
2192   coolinghole3shape->Rmin(2) = kCoolingHoleRmin;
2193   coolinghole3shape->Z(2)    = coolingholeshape->GetZ(3);
2194   coolinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2195                                               coolinghole3shape->GetZ(2));
2196
2197   coolinghole3shape->Rmin(3) = coolinghole3shape->GetRmin(2);
2198   coolinghole3shape->Rmax(3) = coolinghole3shape->GetRmin(3);
2199   coolinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2200                                               coolinghole3shape->GetRmax(3));
2201
2202   //
2203   holePhi = (kMountingHoleWidth/kMountingHoleRmin)*TMath::RadToDeg();
2204
2205   TGeoPcon *mountingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2206
2207   mountingholeshape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2208   mountingholeshape->Rmax(0) = mountingholeshape->GetRmin(0);
2209   mountingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2210                                               mountingholeshape->GetRmin(0));
2211
2212   mountingholeshape->Rmin(1) = kMountingHoleRmin;
2213   mountingholeshape->Rmax(1) = mountingholeshape->GetRmax(0);
2214   mountingholeshape->Z(1)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2215                                               mountingholeshape->GetRmin(1));
2216
2217   mountingholeshape->Rmin(2) = mountingholeshape->GetRmin(1);
2218   mountingholeshape->Rmax(2) = mountingholeshape->GetRmax(1);
2219   mountingholeshape->Z(2)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2220                                               mountingholeshape->GetRmax(2));
2221
2222   mountingholeshape->Rmin(3) = mountingholeshape->GetRmin(2);
2223   mountingholeshape->Rmax(3) = mountingholeshape->GetRmin(3);
2224   mountingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2225                                               mountingholeshape->GetRmax(3));
2226
2227   TGeoPcon *mountinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2228
2229   mountinghole2shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2230   mountinghole2shape->Rmax(0) = mountingholeshape->GetRmin(0);
2231   mountinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2232                                                mountinghole2shape->GetRmin(0));
2233
2234   mountinghole2shape->Rmax(1) = mountinghole2shape->GetRmax(0);
2235   mountinghole2shape->Z(1)    = mountingholeshape->Z(0);
2236   mountinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2237                                                mountinghole2shape->GetZ(1));
2238
2239   mountinghole2shape->Rmin(2) = kMountingHoleRmin;
2240   mountinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2241                                                mountinghole2shape->GetRmin(2));
2242   mountinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2243                                                mountinghole2shape->GetZ(2));
2244
2245   mountinghole2shape->Rmin(3) = mountinghole2shape->Rmin(2);
2246   mountinghole2shape->Rmax(3) = mountinghole2shape->Rmin(3);
2247   mountinghole2shape->Z(3)    = mountingholeshape->Z(1);
2248
2249   TGeoPcon *mountinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2250
2251   mountinghole3shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2252   mountinghole3shape->Rmax(0) = mountingholeshape->GetRmin(0);
2253   mountinghole3shape->Z(0)    = mountingholeshape->GetZ(2);
2254
2255   mountinghole3shape->Rmax(1) = mountinghole3shape->GetRmax(0);
2256   mountinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2257                                                mountinghole3shape->GetRmax(1));
2258   mountinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2259                                                mountinghole3shape->GetZ(1));
2260
2261   mountinghole3shape->Rmin(2) = kMountingHoleRmin;
2262   mountinghole3shape->Z(2)    = mountingholeshape->Z(3);
2263   mountinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2264                                                mountinghole3shape->GetZ(2));
2265
2266   mountinghole3shape->Rmin(3) = mountinghole3shape->Rmin(2);
2267   mountinghole3shape->Rmax(3) = mountinghole3shape->Rmin(3);
2268   mountinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2269                                                mountinghole3shape->GetRmax(3));
2270
2271   // The Cable Hole is even more complicated, a Composite Shape
2272   // is unavoidable here (gosh!)
2273   TGeoPcon *coneshapecopy = new TGeoPcon("conecopy",0.0, 360.0, 12);
2274
2275   for (Int_t i=0; i<12; i++) {
2276     coneshapecopy->Rmin(i) = coneshape->GetRmin(i);
2277     coneshapecopy->Rmax(i) = coneshape->GetRmax(i);
2278     coneshapecopy->Z(i)    = coneshape->GetZ(i);
2279   }
2280
2281   holePhi = (kCableHoleWidth/kCableHoleRout)*TMath::RadToDeg();
2282   TGeoConeSeg *chCS = new TGeoConeSeg("chCS", 0.5*kConeZLength,
2283                                       kCableHoleRin, kCableHoleRout,
2284                                       kCableHoleRin, kCableHoleRout,
2285                                       -0.5*holePhi, 0.5*holePhi);
2286
2287   TGeoCompositeShape *cableholeshape = new TGeoCompositeShape(
2288                                            "SSDCableHoleShape",
2289                                            "conecopy*chCS");
2290
2291   if(GetDebug(1)){
2292     chCS->InspectShape();
2293     cableholeshape->InspectShape();
2294   }
2295
2296   // SSD Cone Wings: Tube and TubeSeg shapes
2297   Double_t angleWideWing, angleWideWingThickness;
2298   angleWideWing = (kWingWidth/kWingRmax)*TMath::RadToDeg();
2299   angleWideWingThickness = (kCFThickness/kWingRmax)*TMath::RadToDeg();
2300
2301   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kConeROuterMax, kWingRmax,
2302                                            kWingHalfThick,
2303                                            0, angleWideWing);
2304
2305   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kConeROuterMax,
2306                                  kWingRmax-kCFThickness,
2307                                  kWingHalfThick-kCFThickness,
2308                                  angleWideWingThickness,
2309                                  angleWideWing-angleWideWingThickness);
2310
2311   // SDD support plate, SSD side (Mounting Bracket): a TubeSeg
2312   TGeoTubeSeg *bracketshape = new TGeoTubeSeg(kBracketRmin, kBracketRmax,
2313                             kBracketHalfLength, -kBracketPhi/2, kBracketPhi/2);
2314
2315
2316   // We have the shapes: now create the real volumes
2317
2318   TGeoVolume *cfcone = new TGeoVolume("SSDCarbonFiberCone",
2319                                       coneshape,medSSDcf);
2320   cfcone->SetVisibility(kTRUE);
2321   cfcone->SetLineColor(4); // Blue
2322   cfcone->SetLineWidth(1);
2323   cfcone->SetFillColor(cfcone->GetLineColor());
2324   cfcone->SetFillStyle(4000); // 0% transparent
2325
2326   TGeoVolume *cfconeinsert = new TGeoVolume("SSDCarbonFiberConeInsert",
2327                                             coneinsertshape,medSSDste);
2328   cfconeinsert->SetVisibility(kTRUE);
2329   cfconeinsert->SetLineColor(2); // Red
2330   cfconeinsert->SetLineWidth(1);
2331   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2332   cfconeinsert->SetFillStyle(4050); // 50% transparent
2333
2334   TGeoVolume *cfconefoam1 = new TGeoVolume("SSDCarbonFiberConeFoam1",
2335                                             conefoam1shape,medSSDroh);
2336   cfconefoam1->SetVisibility(kTRUE);
2337   cfconefoam1->SetLineColor(3); // Green
2338   cfconefoam1->SetLineWidth(1);
2339   cfconefoam1->SetFillColor(cfconefoam1->GetLineColor());
2340   cfconefoam1->SetFillStyle(4050); // 50% transparent
2341
2342   TGeoVolume *cfconefoam2 = new TGeoVolume("SSDCarbonFiberConeFoam2",
2343                                             conefoam2shape,medSSDroh);
2344   cfconefoam2->SetVisibility(kTRUE);
2345   cfconefoam2->SetLineColor(3); // Green
2346   cfconefoam2->SetLineWidth(1);
2347   cfconefoam2->SetFillColor(cfconefoam2->GetLineColor());
2348   cfconefoam2->SetFillStyle(4050); // 50% transparent
2349
2350   TGeoVolume *coolinghole = new TGeoVolume("SSDCoolingHole",
2351                                            coolingholeshape,medSSDair);
2352   coolinghole->SetVisibility(kTRUE);
2353   coolinghole->SetLineColor(5); // Yellow
2354   coolinghole->SetLineWidth(1);
2355   coolinghole->SetFillColor(coolinghole->GetLineColor());
2356   coolinghole->SetFillStyle(4090); // 90% transparent
2357
2358   TGeoVolume *coolinghole2 = new TGeoVolume("SSDCoolingHole2",
2359                                             coolinghole2shape,medSSDair);
2360   coolinghole2->SetVisibility(kTRUE);
2361   coolinghole2->SetLineColor(5); // Yellow
2362   coolinghole2->SetLineWidth(1);
2363   coolinghole2->SetFillColor(coolinghole2->GetLineColor());
2364   coolinghole2->SetFillStyle(4090); // 90% transparent
2365
2366   TGeoVolume *coolinghole3 = new TGeoVolume("SSDCoolingHole3",
2367                                             coolinghole3shape,medSSDair);
2368   coolinghole3->SetVisibility(kTRUE);
2369   coolinghole3->SetLineColor(5); // Yellow
2370   coolinghole3->SetLineWidth(1);
2371   coolinghole3->SetFillColor(coolinghole3->GetLineColor());
2372   coolinghole3->SetFillStyle(4090); // 90% transparent
2373
2374   TGeoVolume *mountinghole = new TGeoVolume("SSDMountingHole",
2375                                             mountingholeshape,medSSDair);
2376   mountinghole->SetVisibility(kTRUE);
2377   mountinghole->SetLineColor(5); // Yellow
2378   mountinghole->SetLineWidth(1);
2379   mountinghole->SetFillColor(mountinghole->GetLineColor());
2380   mountinghole->SetFillStyle(4090); // 90% transparent
2381
2382   TGeoVolume *mountinghole2 = new TGeoVolume("SSDMountingHole2",
2383                                              mountinghole2shape,medSSDair);
2384   mountinghole2->SetVisibility(kTRUE);
2385   mountinghole2->SetLineColor(5); // Yellow
2386   mountinghole2->SetLineWidth(1);
2387   mountinghole2->SetFillColor(mountinghole2->GetLineColor());
2388   mountinghole2->SetFillStyle(4090); // 90% transparent
2389
2390   TGeoVolume *mountinghole3 = new TGeoVolume("SSDMountingHole3",
2391                                              mountinghole3shape,medSSDair);
2392   mountinghole3->SetVisibility(kTRUE);
2393   mountinghole3->SetLineColor(5); // Yellow
2394   mountinghole3->SetLineWidth(1);
2395   mountinghole3->SetFillColor(mountinghole3->GetLineColor());
2396   mountinghole3->SetFillStyle(4090); // 90% transparent
2397
2398   TGeoVolume *wing = new TGeoVolume("SSDWing",wingshape,medSSDcf);
2399   wing->SetVisibility(kTRUE);
2400   wing->SetLineColor(4); // Blue
2401   wing->SetLineWidth(1);
2402   wing->SetFillColor(wing->GetLineColor());
2403   wing->SetFillStyle(4000); // 0% transparent
2404
2405   TGeoVolume *cablehole = new TGeoVolume("SSDCableHole",
2406                                          cableholeshape,medSSDair);
2407   cablehole->SetVisibility(kTRUE);
2408   cablehole->SetLineColor(5); // Yellow
2409   cablehole->SetLineWidth(1);
2410   cablehole->SetFillColor(cablehole->GetLineColor());
2411   cablehole->SetFillStyle(4090); // 90% transparent
2412
2413   TGeoVolume *winginsert = new TGeoVolume("SSDWingInsert",
2414                                           winginsertshape,medSSDste);
2415   winginsert->SetVisibility(kTRUE);
2416   winginsert->SetLineColor(2); // Red
2417   winginsert->SetLineWidth(1);
2418   winginsert->SetFillColor(winginsert->GetLineColor());
2419   winginsert->SetFillStyle(4050); // 50% transparent
2420
2421   TGeoVolume *bracket = new TGeoVolume("SSDMountingBracket",
2422                                        bracketshape,medSSDal);
2423   bracket->SetVisibility(kTRUE);
2424   bracket->SetLineColor(6); // Purple
2425   bracket->SetLineWidth(1);
2426   bracket->SetFillColor(bracket->GetLineColor());
2427   bracket->SetFillStyle(4000); // 0% transparent
2428
2429   // Mount up a cone
2430   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
2431     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
2432     cfconefoam2->AddNode(mountinghole,i+1, new TGeoRotation("", phiH, 0, 0));
2433   }
2434
2435   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
2436     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
2437     cfconeinsert->AddNodeOverlap(coolinghole,i+1, new TGeoRotation("", phiH, 0, 0));
2438   }
2439
2440   cfconeinsert->AddNode(cfconefoam1,1,0);
2441   cfconeinsert->AddNode(cfconefoam2,1,0);
2442
2443   cfcone->AddNode(cfconeinsert,1,0);
2444
2445   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
2446     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
2447     cfcone->AddNode(coolinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
2448     cfcone->AddNode(coolinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
2449     cfcone->AddNodeOverlap(cablehole,i+1, new TGeoRotation("", phiH, 0, 0));
2450   }
2451
2452   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
2453     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
2454     cfcone->AddNode(mountinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
2455     cfcone->AddNode(mountinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
2456   }
2457
2458   wing->AddNode(winginsert,1,0);
2459
2460   // Add all volumes in the Cone assembly
2461   vC->AddNode(cfcone,1,new TGeoTranslation(0,0,-kConeZPosition));
2462
2463   for (Int_t i=0; i<4; i++) {
2464     Double_t thetaW = kThetaWing + 90.*i + angleWideWing/2.;
2465     vC->AddNode(wing, i+1, new TGeoCombiTrans(0, 0, -kConeZPosition+kWingHalfThick,
2466                            new TGeoRotation("",thetaW,180,0)));
2467   }
2468
2469   Double_t zBracket = kConeZPosition - coneshape->GetZ(9) +
2470                       2*bracketshape->GetDz();
2471   for (Int_t i=0; i<3; i++) {
2472     Double_t thetaB = 60 + 120.*i;
2473     vC->AddNode(bracket, i+1, new TGeoCombiTrans(0, 0, -zBracket,
2474                               new TGeoRotation("",thetaB,0,0)));
2475   }
2476
2477   // Finally put everything in the mother volume
2478   moth->AddNode(cfcylinder,1,0);
2479
2480   moth->AddNode(vC, 1, 0 );
2481   moth->AddNode(vC, 2, new TGeoRotation("",180, 180, 0) );
2482
2483   // Some debugging if requested
2484   if(GetDebug(1)){
2485     vC->PrintNodes();
2486     vC->InspectShape();
2487   }
2488
2489   return;
2490 }
2491
2492 //______________________________________________________________________
2493 void AliITSv11GeometrySupport::ServicesCableSupport(TGeoVolume *moth,
2494                                                     TGeoManager *mgr){
2495 //
2496 // Creates the cable trays which are outside the ITS support cones
2497 // but still inside the TPC
2498 // This is now a stearing routine, the actual work is done by three
2499 // specialized methods to avoid a really huge unique method
2500 //
2501 // Input:
2502 //         moth : the TGeoVolume owing the volume structure
2503 //         mgr  : the GeoManager (default gGeoManager)
2504 // Output:
2505 //
2506 // Created:      15 Nov 2009  Mario Sitta
2507 //
2508
2509   TraySupportsSideA(moth, mgr);
2510
2511   ServicesCableSupportSPD(moth, mgr);
2512   ServicesCableSupportSDD(moth, mgr);
2513   ServicesCableSupportSSD(moth, mgr);
2514
2515   return;
2516 }
2517
2518 //______________________________________________________________________
2519 void AliITSv11GeometrySupport::TraySupportsSideA(TGeoVolume *moth,
2520                                                  TGeoManager *mgr){
2521 //
2522 // Creates the structure supporting the ITS cable trays on Side A
2523 //
2524 // Input:
2525 //         moth : the TGeoVolume owing the volume structure
2526 //         mgr  : the GeoManager (default gGeoManager)
2527 // Output:
2528 //
2529 // Created:      14 Dec 2009  Mario Sitta
2530 // Updated:      26 Feb 2010  Mario Sitta
2531 //
2532 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
2533 // drawings and other (oral) information given by F.Tosello
2534 //
2535
2536   // Dimensions and positions of the A-Side Cable Tray Support Ring
2537   // (0872/G/A/01)
2538   const Double_t kSuppRingYTrans      =  110.00 *fgkmm;
2539   const Double_t kSuppRingZTrans      =(1011.00+435.00) *fgkmm;
2540   const Double_t kSuppForwYTrans      =  185.00 *fgkmm;
2541
2542   const Double_t kExtSuppRingSpace1   =   33.00 *fgkmm;
2543   const Double_t kExtSuppRingSpace2   =   45.00 *fgkmm;
2544   const Double_t kExtSuppRingSpcAbov  =   30.00 *fgkmm;
2545   const Double_t kExtSuppRingBase     =  491.50 *fgkmm;
2546   const Double_t kExtSuppRingInward   =   35.00 *fgkmm;
2547   const Double_t kExtSuppRingRmax     =  540.00 *fgkmm;
2548   const Double_t kExtSuppRingRint1    =  465.00 *fgkmm;
2549   const Double_t kExtSuppRingRint2    =  467.00 *fgkmm;
2550   const Double_t kExtSuppRingInnerHi  =  450.00 *fgkmm;
2551   const Double_t kExtSuppRingInWide   =  100.00 *fgkmm;
2552   const Double_t kExtSuppRingR7       =    7.00 *fgkmm;
2553   const Double_t kExtSuppRingR5       =    5.00 *fgkmm;
2554   const Double_t kExtSuppRingThick    =   20.00 *fgkmm;
2555
2556   const Double_t kExtSuppRingSpcAng   =   10.50 *TMath::DegToRad();
2557   const Double_t kExtSuppRingPartPhi  =   15.00 *TMath::DegToRad();
2558   const Double_t kExtSuppRingIntAng   =    7.00 *TMath::DegToRad();
2559   const Double_t kExtSuppRingBaseAng  =   75.00 *TMath::DegToRad();
2560   const Double_t kExtSuppRingR7Ang    =  100.00 *TMath::DegToRad(); // Guessed
2561
2562   const Int_t    kExtSuppRingNPtsArc  =   10; // N.points to approximate arc
2563
2564   const Double_t kIntSuppRingThick1   =   15.00 *fgkmm;
2565   const Double_t kIntSuppRingThick2   =   13.00 *fgkmm;
2566   const Double_t kIntSuppRingInward   =   24.00 *fgkmm;
2567   const Double_t kIntSuppRingThick    =   20.00 *fgkmm;
2568
2569   const Double_t kSuppCylHeight       =  340.00 *fgkmm;
2570   const Double_t kSuppCylRint         =  475.00 *fgkmm;
2571   const Double_t kSuppCylRext         =  478.00 *fgkmm;
2572   const Double_t kSuppCylDispl        =  137.70 *fgkmm;
2573
2574   const Double_t kSuppSpacerHeight    =   30.00 *fgkmm;
2575   const Double_t kSuppSpacerThick     =   10.00 *fgkmm;
2576
2577   const Double_t kSuppSpacerAngle     =   15.00;  // Degrees
2578
2579   const Double_t kSuppForwRingRint1   =  500.00 *fgkmm;
2580   const Double_t kSuppForwRingRint2   =  540.00 *fgkmm;
2581   const Double_t kSuppForwRingRext    =  560.00 *fgkmm;
2582   const Double_t kSuppForwRingThikAll =   50.00 *fgkmm;
2583   const Double_t kSuppForwRingThikInt =   20.00 *fgkmm;
2584
2585   // (0872/G/B/01)
2586   const Double_t kSuppForwConeRmin    =  558.00 *fgkmm;
2587   const Double_t kSuppForwConeRmax    =  681.00 *fgkmm;
2588   const Double_t kSuppForwConeLen1    =  318.00 *fgkmm;
2589   const Double_t kSuppForwConeLen2    =  662.00 *fgkmm;
2590   const Double_t kSuppForwConeThick   =    3.00 *fgkmm;
2591
2592   const Double_t kSuppBackRingPlacTop =   90.00 *fgkmm;
2593   const Double_t kSuppBackRingPlacSid =   50.00 *fgkmm;
2594   const Double_t kSuppBackRingHeight  =  760.00 *fgkmm;
2595   const Double_t kSuppBackRingRext    =  760.00 *fgkmm;
2596   const Double_t kSuppBackRingRint    =  685.00 *fgkmm;
2597 //  const Double_t kSuppBackRingRint2   =  675.00 *fgkmm;
2598   const Double_t kSuppBackRingR10     =   10.00 *fgkmm;
2599   const Double_t kSuppBackRingBase    =  739.00 *fgkmm;
2600   const Double_t kSuppBackRingThikAll =   50.00 *fgkmm;
2601   const Double_t kSuppBackRingThick1  =   20.00 *fgkmm;
2602   const Double_t kSuppBackRingThick2  =   20.00 *fgkmm;
2603
2604 //  const Double_t kSuppBackRingPlacAng =   10.00 *TMath::DegToRad();
2605   const Double_t kSuppBackRingPlacAng =   10.25 *TMath::DegToRad();//Fix ovlp.
2606   const Double_t kSuppBackRing2ndAng1 =   78.40 *TMath::DegToRad();
2607   const Double_t kSuppBackRing2ndAng2 =   45.00 *TMath::DegToRad();
2608
2609   const Int_t    kSuppBackRingNPtsArc =   10; // N.points to approximate arc
2610
2611   // (0872/G/C/01)
2612   const Double_t kRearSuppZTransGlob  =(1011.00+9315.00-6040.00) *fgkmm;
2613   const Double_t kBackRodZTrans       = 2420.00 *fgkmm;
2614
2615   const Double_t kBackRodLength       = 1160.00 *fgkmm;
2616   const Double_t kBackRodThickLen     =   20.00 *fgkmm;
2617   const Double_t kBackRodDiameter     =   20.00 *fgkmm;
2618
2619   const Double_t kSuppRearRingRint    =  360.00 *fgkmm;
2620   const Double_t kSuppRearRingRext1   =  410.00 *fgkmm;
2621   const Double_t kSuppRearRingRext2   =  414.00 *fgkmm;
2622   const Double_t kSuppRearRingHeight  =  397.00 *fgkmm;
2623   const Double_t kSuppRearRingTopWide =  111.87 *fgkmm;
2624   const Double_t kSuppRearRingBase    =  451.50 *fgkmm;
2625   const Double_t kSuppRearRingBaseHi  =   58.00 *fgkmm;
2626   const Double_t kSuppRearRingSideHi  =   52.00 *fgkmm;
2627   const Double_t kSuppRearRingInside  =   40.00 *fgkmm;
2628   const Double_t kSuppRearRingInsideHi=   12.00 *fgkmm;
2629   const Double_t kSuppRearRingThick   =   20.00 *fgkmm;
2630   const Double_t kSuppRearRingXRodHole=  441.50 *fgkmm;
2631   const Double_t kSuppRearRingYRodHole=   42.00 *fgkmm;
2632
2633   const Double_t kSuppRearRing1stAng  =   22.00 *TMath::DegToRad();
2634   const Double_t kSuppRearRingStepAng =   15.00 *TMath::DegToRad();
2635
2636   const Int_t    kSuppRearRingNPtsArc =   10; // N.points to approximate arc
2637
2638
2639   // Local variables
2640   Double_t xprof[2*(15+kExtSuppRingNPtsArc)],yprof[2*(15+kExtSuppRingNPtsArc)];
2641   Double_t slp1, slp2, phi, xm, ym;
2642   Double_t xloc, yloc, zloc, rmin, rmax, deltaR;
2643   Int_t npoints;
2644
2645
2646   // The whole support as an assembly
2647   TGeoVolumeAssembly *trayASuppStruct = new TGeoVolumeAssembly("ITSsuppSideAStructure");
2648   
2649
2650   // First create all needed shapes
2651
2652   // The External Ring (part of 0872/G/A/01): a really complex Xtru
2653   TGeoXtru *extSuppRing = new TGeoXtru(2);
2654
2655   // First the upper notch...
2656   xprof[ 0] = kExtSuppRingSpace1;
2657   yprof[ 0] = kExtSuppRingInnerHi + kExtSuppRingSpcAbov;
2658
2659   slp1 = TMath::Tan(TMath::Pi()/2 - kExtSuppRingSpcAng);
2660   IntersectCircle(slp1, xprof[0], yprof[0], kExtSuppRingRmax, 0., 0.,
2661                   xprof[5], yprof[5], xm, ym); // Ignore dummy xm,ym
2662
2663   xprof[ 4] = xprof[5];
2664   yprof[ 4] = yprof[5] - kExtSuppRingR5/TMath::Tan(kExtSuppRingSpcAng);
2665   xprof[ 3] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/6));
2666   yprof[ 3] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/6));
2667   xprof[ 2] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/3));
2668   yprof[ 2] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/3));
2669   xprof[ 1] = xprof[4] - kExtSuppRingR5;
2670   yprof[ 1] = yprof[4] - kExtSuppRingR5;
2671
2672   Int_t indx = 5+kExtSuppRingNPtsArc;
2673   // ...then the external arc, approximated with segments,...
2674   xprof[indx] = kExtSuppRingBase;
2675   yprof[indx] = TMath::Sqrt(kExtSuppRingRmax*kExtSuppRingRmax -
2676                             kExtSuppRingBase*kExtSuppRingBase);
2677   Double_t alphamin = TMath::ASin(kExtSuppRingSpace2/kExtSuppRingRmax);
2678   Double_t alphamax = TMath::Pi()/2 -
2679                     TMath::ASin(yprof[5+kExtSuppRingNPtsArc]/kExtSuppRingRmax);
2680
2681   for (Int_t jp = 1; jp < kExtSuppRingNPtsArc; jp++) {
2682     Double_t alpha = jp*(alphamax-alphamin)/kExtSuppRingNPtsArc;
2683     xprof[5+jp] = kExtSuppRingRmax*TMath::Sin(alpha);
2684     yprof[5+jp] = kExtSuppRingRmax*TMath::Cos(alpha);
2685   }
2686   // ...and finally the interior profile
2687   xprof[indx+1] = kExtSuppRingBase;
2688   yprof[indx+1] = kSuppRingYTrans;
2689   xprof[indx+2] = xprof[indx+1] - kExtSuppRingInward;
2690   yprof[indx+2] = yprof[indx+1];
2691
2692   phi  = TMath::Pi()/2 - 4*kExtSuppRingPartPhi - kExtSuppRingIntAng;
2693   slp1 = TMath::Tan(TMath::Pi() - kExtSuppRingBaseAng);
2694   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2695   xm   = kExtSuppRingRint2*TMath::Cos(phi);
2696   ym   = kExtSuppRingRint2*TMath::Sin(phi);
2697   IntersectLines(slp1, xprof[indx+2], yprof[indx+2], slp2, xm, ym,
2698                  xprof[indx+3], yprof[indx+3]);
2699
2700   slp1 = slp2;
2701   phi += kExtSuppRingPartPhi;
2702   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2703   xm   = kExtSuppRingRint1*TMath::Cos(phi);
2704   ym   = kExtSuppRingRint1*TMath::Sin(phi);
2705   IntersectLines(slp1, xprof[indx+3], yprof[indx+3], slp2, xm, ym,
2706                  xprof[indx+4], yprof[indx+4]);
2707   
2708   slp1 = slp2;
2709   phi += kExtSuppRingPartPhi;
2710   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2711   xm   = kExtSuppRingRint2*TMath::Cos(phi);
2712   ym   = kExtSuppRingRint2*TMath::Sin(phi);
2713   IntersectLines(slp1, xprof[indx+4], yprof[indx+4], slp2, xm, ym,
2714                  xprof[indx+5], yprof[indx+5]);
2715   
2716   slp1 = slp2;
2717   phi += kExtSuppRingPartPhi;
2718   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2719   xm   = kExtSuppRingRint1*TMath::Cos(phi);
2720   ym   = kExtSuppRingRint1*TMath::Sin(phi);
2721   IntersectLines(slp1, xprof[indx+5], yprof[indx+5], slp2, xm, ym,
2722                  xprof[indx+6], yprof[indx+6]);
2723   
2724   xprof[indx+9] = kExtSuppRingInWide;
2725   yprof[indx+9] = kExtSuppRingInnerHi;
2726   xprof[indx+8] = xprof[indx+9] +
2727                   (1 - TMath::Cos(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
2728   yprof[indx+8] = yprof[indx+9] +
2729                   (    TMath::Sin(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
2730   xprof[indx+7] = xprof[indx+9] +
2731                   (1 + TMath::Cos(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
2732   yprof[indx+7] = yprof[indx+9] +
2733                   (    TMath::Sin(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
2734   // Gosh, we did the right side! now reflex on the left side
2735   npoints = (sizeof(xprof)/sizeof(Double_t))/2;
2736   for (Int_t jp = 0; jp < npoints; jp++) {
2737     xprof[npoints+jp] = -xprof[npoints-1-jp];
2738     yprof[npoints+jp] =  yprof[npoints-1-jp];
2739   }
2740   // wow! now the actual Xtru
2741   extSuppRing->DefinePolygon(2*npoints, xprof, yprof);
2742   extSuppRing->DefineSection(0,0);
2743   extSuppRing->DefineSection(1,kExtSuppRingThick);
2744
2745   // The Internal Ring (part of 0872/G/A/01): another complex Xtru
2746   TGeoXtru *intSuppRing = new TGeoXtru(2);
2747
2748   // First the external profile...
2749   npoints = 0;
2750
2751   slp1 = 0;
2752   phi  = TMath::Pi()/2 - kExtSuppRingPartPhi - kExtSuppRingIntAng;
2753   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2754   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
2755   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
2756   IntersectLines(slp1,  0, kExtSuppRingInnerHi+kExtSuppRingSpcAbov,
2757                  slp2, xm, ym,
2758                  xprof[npoints], yprof[npoints]);
2759   npoints++;
2760
2761   slp1 = slp2;
2762   phi -= kExtSuppRingPartPhi;
2763   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2764   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
2765   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
2766   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
2767                  slp2, xm, ym,
2768                  xprof[npoints], yprof[npoints]);
2769   npoints++;
2770
2771   slp1 = slp2;
2772   phi -= kExtSuppRingPartPhi;
2773   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2774   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
2775   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
2776   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
2777                  slp2, xm, ym,
2778                  xprof[npoints], yprof[npoints]);
2779   npoints++;
2780
2781   slp1 = slp2;
2782   phi -= kExtSuppRingPartPhi;
2783   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2784   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
2785   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
2786   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
2787                  slp2, xm, ym,
2788                  xprof[npoints], yprof[npoints]);
2789   npoints++;
2790
2791   xprof[npoints] = kExtSuppRingBase-kIntSuppRingInward;
2792   yprof[npoints] = Yfrom2Points(xprof[npoints-1], yprof[npoints-1], xm, ym,
2793                                 xprof[npoints]);
2794   npoints++;
2795
2796   xprof[npoints] = xprof[npoints-1];
2797   yprof[npoints] = kSuppRingYTrans;
2798   npoints++;
2799   // ...and then the interior profile, which is identical to extSuppRing one
2800   for (Int_t jp=0; jp < 8; jp++) {
2801     xprof[npoints] = extSuppRing->GetX(17+jp);
2802     yprof[npoints] = extSuppRing->GetY(17+jp);
2803     npoints++;
2804   }
2805   // We did the right side! now reflex on the left side
2806   for (Int_t jp = 0; jp < npoints; jp++) {
2807     xprof[npoints+jp] = -xprof[npoints-1-jp];
2808     yprof[npoints+jp] =  yprof[npoints-1-jp];
2809   }
2810   // And now the actual Xtru
2811   intSuppRing->DefinePolygon(2*npoints, xprof, yprof);
2812   intSuppRing->DefineSection(0,0);
2813   intSuppRing->DefineSection(1,kIntSuppRingThick);
2814
2815   // The intermediate cylinder (0872/G/A/03): a TubeSeg
2816   alphamin = TMath::ASin(kSuppCylDispl/kSuppCylRint)*TMath::RadToDeg();
2817   alphamax = 180 - alphamin;
2818   TGeoTubeSeg *interCylind = new TGeoTubeSeg(kSuppCylRint, kSuppCylRext,
2819                                      kSuppCylHeight/2, alphamin, alphamax);
2820
2821   // The spacer (0872/G/A/03): a simple Xtru
2822   TGeoXtru *suppSpacer = new TGeoXtru(2);
2823
2824   xprof[0] = kSuppSpacerHeight;
2825   yprof[0] = kSuppSpacerThick;
2826   xprof[1] = xprof[0];
2827   yprof[1] = 0;
2828   xprof[2] = 0;
2829   yprof[2] = 0;
2830   xprof[3] = kSuppSpacerThick*SinD(kSuppSpacerAngle);
2831   yprof[3] = yprof[0];
2832
2833   suppSpacer->DefinePolygon(4, xprof, yprof);
2834   suppSpacer->DefineSection(0,-kSuppCylHeight/2);
2835   suppSpacer->DefineSection(1, kSuppCylHeight/2);
2836
2837   // The forward ring (0872/G/B/02): a Pcon (slight oversimplification)
2838   Double_t rmean = (kSuppForwRingRint1+kSuppForwRingRext)/2;
2839   alphamin = TMath::ASin(kSuppForwYTrans/rmean)*TMath::RadToDeg();
2840   alphamax = 180 - alphamin;
2841
2842   TGeoPcon *forwardRing = new TGeoPcon(alphamin,alphamax-alphamin,4);
2843
2844   forwardRing->DefineSection(0,0,
2845                              kSuppForwRingRint1,kSuppForwRingRext);
2846   forwardRing->DefineSection(1,kSuppForwRingThikInt,
2847                              kSuppForwRingRint1,kSuppForwRingRext);
2848   forwardRing->DefineSection(2,kSuppForwRingThikInt,
2849                              kSuppForwRingRint2,kSuppForwRingRext);
2850   forwardRing->DefineSection(3,kSuppForwRingThikAll,
2851                              kSuppForwRingRint2,kSuppForwRingRext);
2852
2853   // The forward cone (0872/G/B/03): a TGeoPcon
2854   TGeoPcon *forwardCone = new TGeoPcon(alphamin,alphamax-alphamin,3);
2855
2856   forwardCone->DefineSection(0,0,
2857                              kSuppForwConeRmin-kSuppForwConeThick,
2858                              kSuppForwConeRmin);
2859   forwardCone->DefineSection(1,kSuppForwConeLen1,
2860                              kSuppForwConeRmin-kSuppForwConeThick,
2861                              kSuppForwConeRmin);
2862   forwardCone->DefineSection(2,kSuppForwConeLen1+kSuppForwConeLen2,
2863                              kSuppForwConeRmax-kSuppForwConeThick,
2864                              kSuppForwConeRmax);
2865
2866   // The first part of the Back Ring (part of 0872/G/B/01): a complex Xtru
2867   TGeoXtru *firstSuppBackRing = new TGeoXtru(2);
2868
2869   // First the external profile... (the arc is approximated with segments)
2870   npoints = 0;
2871
2872   xprof[npoints] = kSuppBackRingPlacTop;
2873   yprof[npoints] = kSuppBackRingHeight;
2874   npoints++;
2875
2876   alphamax = TMath::Pi()/2 - TMath::ASin(kSuppBackRingPlacTop/kSuppBackRingRext);
2877   alphamin = TMath::ASin((kSuppForwYTrans+kSuppBackRingPlacSid)/kSuppBackRingRext);
2878
2879   xprof[npoints] = xprof[npoints-1];
2880   yprof[npoints] = kSuppBackRingRext*TMath::Sin(alphamax);
2881   npoints++;
2882
2883   for (Int_t jp = 1; jp <= kSuppBackRingNPtsArc; jp++) {
2884     Double_t alpha = alphamax - jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
2885     xprof[npoints] = kSuppBackRingRext*TMath::Cos(alpha);
2886     yprof[npoints] = kSuppBackRingRext*TMath::Sin(alpha);
2887     npoints++;
2888   }
2889
2890   xprof[npoints] = kSuppBackRingBase -
2891                    kSuppBackRingPlacSid*TMath::Tan(kSuppBackRingPlacAng);
2892   yprof[npoints] = yprof[npoints-1];
2893   npoints++;
2894
2895   xprof[npoints] = kSuppBackRingBase;
2896   yprof[npoints] = kSuppForwYTrans;
2897   npoints++;
2898   // ...then the internal profile (the arc is approximated with segments)
2899   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint);
2900   alphamax = TMath::Pi()/2;
2901
2902   for (Int_t jp = 0; jp < kSuppBackRingNPtsArc; jp++) {
2903     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
2904     xprof[npoints] = kSuppBackRingRint*TMath::Cos(alpha);
2905     yprof[npoints] = kSuppBackRingRint*TMath::Sin(alpha);
2906     npoints++;
2907   }
2908
2909   xprof[npoints] = 0;
2910   yprof[npoints] = kSuppBackRingRint;
2911   npoints++;
2912   // We did the right side! now reflex on the left side (except last point)
2913   for (Int_t jp = 0; jp < npoints-1; jp++) {
2914     xprof[npoints+jp] = -xprof[npoints-jp-2];
2915     yprof[npoints+jp] =  yprof[npoints-jp-2];
2916   }
2917   // And now the actual Xtru
2918   firstSuppBackRing->DefinePolygon(2*npoints-1, xprof, yprof);
2919   firstSuppBackRing->DefineSection(0,0);
2920   firstSuppBackRing->DefineSection(1,kSuppBackRingThick1);
2921
2922   // The second part of the Back Ring (part of 0872/G/B/01): a Pcon
2923   // (slight oversimplification)
2924   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint)*TMath::RadToDeg();
2925   alphamax = 180 - alphamin;
2926
2927   TGeoPcon *secondSuppBackRing = new TGeoPcon(alphamin,alphamax-alphamin,6);
2928
2929   deltaR = kSuppBackRingThick2/TMath::Sin(kSuppBackRing2ndAng1);
2930   rmin = kSuppBackRingRint - kSuppBackRingThick1/TMath::Tan(kSuppBackRing2ndAng1);
2931   rmax = rmin + deltaR + kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
2932   secondSuppBackRing->DefineSection(0, 0, rmin, rmax);
2933
2934   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1/3));
2935   rmax -= kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1/3);
2936   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2937   secondSuppBackRing->DefineSection(1, zloc, rmin, rmax);
2938
2939   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1*2/3));
2940   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1*2/3);
2941   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2942   secondSuppBackRing->DefineSection(2, zloc, rmin, rmax);
2943
2944   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1));
2945   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
2946   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2947   secondSuppBackRing->DefineSection(3, zloc, rmin, rmax);
2948
2949   slp1 = TMath::Tan(kSuppBackRing2ndAng2);
2950   slp2 = TMath::Tan(TMath::Pi()/2 + kSuppBackRing2ndAng1);
2951   IntersectLines(-slp1,kSuppBackRingThikAll,deltaR/2,
2952                   slp2,kSuppBackRingThikAll,deltaR,
2953                   xm, ym);
2954
2955   zloc = xm - kSuppBackRingThick1;
2956   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2957   rmax = rmin + deltaR;
2958   secondSuppBackRing->DefineSection(4, zloc, rmin, rmax);
2959
2960   zloc = kSuppBackRingThikAll - kSuppBackRingThick1;
2961   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2962   rmax = rmin + deltaR/2;
2963   secondSuppBackRing->DefineSection(5, zloc, rmin, rmax);
2964
2965   // The supporting rod: a Tube
2966   TGeoTube *suppRod = new TGeoTube(0, kBackRodDiameter/2,
2967                                    (kBackRodLength - kBackRodThickLen)/2);
2968
2969   // The Back Ring (0872/G/C/01): another complex Xtru
2970   TGeoXtru *suppRearRing = new TGeoXtru(2);
2971
2972   // First the external profile...
2973   npoints = 0;
2974
2975   xprof[npoints] = kSuppRearRingTopWide;
2976   yprof[npoints] = kSuppRearRingHeight;
2977   npoints++;
2978
2979   phi = kSuppRearRing1stAng;
2980   slp1 = TMath::Tan(TMath::Pi() - phi);
2981   phi += kSuppRearRingStepAng;
2982   slp2 = TMath::Tan(TMath::Pi() - phi);
2983   xm = kSuppRearRingRext2*TMath::Sin(phi);
2984   ym = kSuppRearRingRext2*TMath::Cos(phi);
2985   IntersectLines(slp1, kSuppRearRingTopWide, kSuppRearRingHeight,
2986                  slp2, xm, ym,
2987                  xprof[npoints], yprof[npoints]);
2988   npoints++;
2989
2990   slp1 = slp2;
2991   phi += kSuppRearRingStepAng;
2992   slp2 = TMath::Tan(TMath::Pi() - phi);
2993   xm = kSuppRearRingRext1*TMath::Sin(phi);
2994   ym = kSuppRearRingRext1*TMath::Cos(phi);
2995   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
2996                  slp2, xm, ym,
2997                  xprof[npoints], yprof[npoints]);
2998   npoints++;
2999
3000   slp1 = slp2;
3001   phi += kSuppRearRingStepAng;
3002   slp2 = TMath::Tan(TMath::Pi() - phi);
3003   xm = kSuppRearRingRext2*TMath::Sin(phi);
3004   ym = kSuppRearRingRext2*TMath::Cos(phi);
3005   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3006                  slp2, xm, ym,
3007                  xprof[npoints], yprof[npoints]);
3008   npoints++;
3009
3010   slp1 = slp2;
3011   slp2 = 0;
3012   xm = kSuppRearRingBase;
3013   ym = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3014   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3015                  slp2, xm, ym,
3016                  xprof[npoints], yprof[npoints]);
3017   npoints++;
3018
3019   xprof[npoints] = kSuppRearRingBase;
3020   yprof[npoints] = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3021   npoints++;
3022   xprof[npoints] = xprof[npoints - 1];
3023   yprof[npoints] = kSuppRearRingBaseHi;
3024   npoints++;
3025   xprof[npoints] = xprof[npoints - 1] - kSuppRearRingInside;
3026   yprof[npoints] = yprof[npoints - 1];
3027   npoints++;
3028   xprof[npoints] = xprof[npoints - 1];
3029   yprof[npoints] = yprof[npoints - 1] + kSuppRearRingInsideHi;
3030   npoints++;
3031   // ...then the internal arc, approximated with segments,...
3032   xprof[npoints] = kSuppRearRingRint;
3033   yprof[npoints] = yprof[npoints - 1];
3034
3035   alphamin = TMath::ASin(kSuppRearRingBaseHi/kSuppRearRingRint);
3036   alphamax = TMath::Pi()/2;
3037
3038   for (Int_t jp = 1; jp < kSuppRearRingNPtsArc; jp++) {
3039     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppRearRingNPtsArc;
3040     xprof[npoints+jp] = kSuppRearRingRint*TMath::Cos(alpha);
3041     yprof[npoints+jp] = kSuppRearRingRint*TMath::Sin(alpha);
3042   }
3043
3044   xprof[npoints+kSuppRearRingNPtsArc] = 0;
3045   yprof[npoints+kSuppRearRingNPtsArc] = kSuppRearRingRint;
3046   // We did the right side! now reflex on the left side
3047   Int_t nTotalPoints = npoints+kSuppRearRingNPtsArc;
3048   for (Int_t jp = 0; jp < nTotalPoints; jp++) {
3049     xprof[nTotalPoints+1+jp] = -xprof[nTotalPoints-1-jp];
3050     yprof[nTotalPoints+1+jp] =  yprof[nTotalPoints-1-jp];
3051   }
3052
3053   // And now the actual Xtru
3054   suppRearRing->DefinePolygon(2*nTotalPoints+1, xprof, yprof);
3055   suppRearRing->DefineSection(0,0);
3056   suppRearRing->DefineSection(1,kSuppRearRingThick);
3057
3058
3059   // We have all shapes: now create the real volumes
3060   TGeoMedium *medAl = mgr->GetMedium("ITS_ANTICORODAL$");
3061
3062   TGeoVolume *sideAExtSuppRing = new TGeoVolume("ITSsuppSideAExtSuppRing",
3063                                                  extSuppRing, medAl);
3064
3065   sideAExtSuppRing->SetVisibility(kTRUE);
3066   sideAExtSuppRing->SetLineColor(kMagenta+1);
3067   sideAExtSuppRing->SetLineWidth(1);
3068   sideAExtSuppRing->SetFillColor(sideAExtSuppRing->GetLineColor());
3069   sideAExtSuppRing->SetFillStyle(4000); // 0% transparent
3070
3071   TGeoVolume *sideAIntSuppRing = new TGeoVolume("ITSsuppSideAIntSuppRing",
3072                                                  intSuppRing, medAl);
3073
3074   sideAIntSuppRing->SetVisibility(kTRUE);
3075   sideAIntSuppRing->SetLineColor(kMagenta+1);
3076   sideAIntSuppRing->SetLineWidth(1);
3077   sideAIntSuppRing->SetFillColor(sideAIntSuppRing->GetLineColor());
3078   sideAIntSuppRing->SetFillStyle(4000); // 0% transparent
3079
3080   TGeoVolume *sideASuppCyl = new TGeoVolume("ITSsuppSideASuppCyl",
3081                                             interCylind, medAl);
3082
3083   sideASuppCyl->SetVisibility(kTRUE);
3084   sideASuppCyl->SetLineColor(kMagenta+1);
3085   sideASuppCyl->SetLineWidth(1);
3086   sideASuppCyl->SetFillColor(sideASuppCyl->GetLineColor());
3087   sideASuppCyl->SetFillStyle(4000); // 0% transparent
3088
3089   TGeoVolume *sideASuppSpacer = new TGeoVolume("ITSsuppSideASuppSpacer",
3090                                                suppSpacer, medAl);
3091
3092   sideASuppSpacer->SetVisibility(kTRUE);
3093   sideASuppSpacer->SetLineColor(kMagenta+1);
3094   sideASuppSpacer->SetLineWidth(1);
3095   sideASuppSpacer->SetFillColor(sideASuppSpacer->GetLineColor());
3096   sideASuppSpacer->SetFillStyle(4000); // 0% transparent
3097
3098   TGeoVolume *sideASuppForwRing = new TGeoVolume("ITSsuppSideASuppForwRing",
3099                                                  forwardRing, medAl);
3100
3101   sideASuppForwRing->SetVisibility(kTRUE);
3102   sideASuppForwRing->SetLineColor(kMagenta+1);
3103   sideASuppForwRing->SetLineWidth(1);
3104   sideASuppForwRing->SetFillColor(sideASuppForwRing->GetLineColor());
3105   sideASuppForwRing->SetFillStyle(4000); // 0% transparent
3106
3107   TGeoVolume *sideASuppForwCone = new TGeoVolume("ITSsuppSideASuppForwCone",
3108                                                  forwardCone, medAl);
3109
3110   sideASuppForwCone->SetVisibility(kTRUE);
3111   sideASuppForwCone->SetLineColor(kMagenta+1);
3112   sideASuppForwCone->SetLineWidth(1);
3113   sideASuppForwCone->SetFillColor(sideASuppForwCone->GetLineColor());
3114   sideASuppForwCone->SetFillStyle(4000); // 0% transparent
3115
3116   TGeoVolume *sideAFirstSuppBackRing = new TGeoVolume("ITSsuppSideAFirstSuppBackRing",
3117                                                      firstSuppBackRing, medAl);
3118
3119   sideAFirstSuppBackRing->SetVisibility(kTRUE);
3120   sideAFirstSuppBackRing->SetLineColor(kMagenta+1);
3121   sideAFirstSuppBackRing->SetLineWidth(1);
3122   sideAFirstSuppBackRing->SetFillColor(sideAFirstSuppBackRing->GetLineColor());
3123   sideAFirstSuppBackRing->SetFillStyle(4000); // 0% transparent
3124
3125   TGeoVolume *sideASecondSuppBackRing = new TGeoVolume("ITSsuppSideASecondSuppBackRing",
3126                                                        secondSuppBackRing, medAl);
3127
3128   sideASecondSuppBackRing->SetVisibility(kTRUE);
3129   sideASecondSuppBackRing->SetLineColor(kMagenta+1);
3130   sideASecondSuppBackRing->SetLineWidth(1);
3131   sideASecondSuppBackRing->SetFillColor(sideASecondSuppBackRing->GetLineColor());
3132   sideASecondSuppBackRing->SetFillStyle(4000); // 0% transparent
3133
3134   TGeoVolume *sideASuppRod = new TGeoVolume("ITSsuppSideASuppRod",
3135                                             suppRod, medAl);
3136
3137   sideASuppRod->SetVisibility(kTRUE);
3138   sideASuppRod->SetLineColor(kMagenta+1);
3139   sideASuppRod->SetLineWidth(1);
3140   sideASuppRod->SetFillColor(sideASuppRod->GetLineColor());
3141   sideASuppRod->SetFillStyle(4000); // 0% transparent
3142
3143   TGeoVolume *sideASuppRearRing = new TGeoVolume("ITSsuppSideASuppRearRing",
3144                                                  suppRearRing, medAl);
3145
3146   sideASuppRearRing->SetVisibility(kTRUE);
3147   sideASuppRearRing->SetLineColor(kMagenta+1);
3148   sideASuppRearRing->SetLineWidth(1);
3149   sideASuppRearRing->SetFillColor(sideASuppRearRing->GetLineColor());
3150   sideASuppRearRing->SetFillStyle(4000); // 0% transparent
3151
3152
3153   // Now build up the support structure
3154   zloc = kSuppRingZTrans;
3155   trayASuppStruct->AddNode(sideAExtSuppRing, 1,
3156                            new TGeoTranslation(0, 0, zloc) );
3157   trayASuppStruct->AddNode(sideAExtSuppRing, 2,
3158                            new TGeoCombiTrans( 0, 0, zloc,
3159                                                new TGeoRotation("",180,0,0)));
3160
3161   zloc += kExtSuppRingThick;
3162   trayASuppStruct->AddNode(sideAIntSuppRing, 1,
3163                            new TGeoTranslation(0, 0, zloc) );
3164   trayASuppStruct->AddNode(sideAIntSuppRing, 2,
3165                            new TGeoCombiTrans( 0, 0, zloc,
3166                                                new TGeoRotation("",180,0,0)));
3167
3168   xloc = kExtSuppRingBase - kIntSuppRingInward;
3169   yloc = kSuppRingYTrans;
3170   zloc += (kIntSuppRingThick + kSuppCylHeight/2);
3171   trayASuppStruct->AddNode(sideASuppCyl, 1,
3172                            new TGeoTranslation(0, 0, zloc) );
3173   trayASuppStruct->AddNode(sideASuppCyl, 2,
3174                            new TGeoCombiTrans( 0, 0, zloc,
3175                                                new TGeoRotation("",180,0,0)));
3176   trayASuppStruct->AddNode(sideASuppSpacer, 1,
3177                            new TGeoCombiTrans( xloc, yloc, zloc,
3178                            new TGeoRotation("",90+kSuppSpacerAngle,0,0)));
3179   trayASuppStruct->AddNode(sideASuppSpacer, 2,
3180                            new TGeoCombiTrans(-xloc, yloc, zloc,
3181                            new TGeoRotation("",0,180,kSuppSpacerAngle-90)));
3182   trayASuppStruct->AddNode(sideASuppSpacer, 3,
3183                            new TGeoCombiTrans( xloc,-yloc, zloc,
3184                            new TGeoRotation("",180,180,kSuppSpacerAngle-90)));
3185   trayASuppStruct->AddNode(sideASuppSpacer, 4,
3186                            new TGeoCombiTrans(-xloc,-yloc, zloc,
3187                            new TGeoRotation("",270+kSuppSpacerAngle,0,0)));
3188
3189
3190   zloc += kSuppCylHeight/2;
3191   trayASuppStruct->AddNode(sideAIntSuppRing, 3,
3192                            new TGeoTranslation(0, 0, zloc) );
3193   trayASuppStruct->AddNode(sideAIntSuppRing, 4,
3194                            new TGeoCombiTrans( 0, 0, zloc,
3195                                                new TGeoRotation("",180,0,0)));
3196
3197   zloc += kIntSuppRingThick;
3198   trayASuppStruct->AddNode(sideAExtSuppRing, 3,
3199                            new TGeoTranslation(0, 0, zloc) );
3200   trayASuppStruct->AddNode(sideAExtSuppRing, 4,
3201                            new TGeoCombiTrans( 0, 0, zloc,
3202                                                new TGeoRotation("",180,0,0)));
3203
3204   zloc += kExtSuppRingThick;
3205   trayASuppStruct->AddNode(sideASuppForwRing, 1,
3206                            new TGeoTranslation(0, 0, zloc) );
3207   trayASuppStruct->AddNode(sideASuppForwRing, 2,
3208                            new TGeoCombiTrans( 0, 0, zloc,
3209                                                new TGeoRotation("",180,0,0)));
3210
3211   zloc += kSuppForwRingThikAll;
3212   trayASuppStruct->AddNode(sideASuppForwCone, 1,
3213                            new TGeoTranslation(0, 0, zloc) );
3214   trayASuppStruct->AddNode(sideASuppForwCone, 2,
3215                            new TGeoCombiTrans( 0, 0, zloc,
3216                                                new TGeoRotation("",180,0,0)));
3217
3218   zloc += (kSuppForwConeLen1+kSuppForwConeLen2);
3219   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 1,
3220                            new TGeoTranslation(0, 0, zloc) );
3221   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 2,
3222                            new TGeoCombiTrans( 0, 0, zloc,
3223                                                new TGeoRotation("",180,0,0)));
3224
3225   zloc += kSuppBackRingThick1;
3226   trayASuppStruct->AddNode(sideASecondSuppBackRing, 1,
3227                            new TGeoTranslation(0, 0, zloc) );
3228   trayASuppStruct->AddNode(sideASecondSuppBackRing, 2,
3229                            new TGeoCombiTrans( 0, 0, zloc,
3230                                                new TGeoRotation("",180,0,0)));
3231
3232   xloc = kSuppRearRingXRodHole;
3233   yloc = kSuppRearRingBaseHi + kSuppRearRingYRodHole;
3234   zloc = kRearSuppZTransGlob - kBackRodZTrans + suppRod->GetDz();
3235   trayASuppStruct->AddNode(sideASuppRod, 1,
3236                            new TGeoTranslation( xloc, yloc, zloc) );
3237   trayASuppStruct->AddNode(sideASuppRod, 2,
3238                            new TGeoTranslation(-xloc, yloc, zloc) );
3239   trayASuppStruct->AddNode(sideASuppRod, 3,
3240                            new TGeoTranslation( xloc,-yloc, zloc) );
3241   trayASuppStruct->AddNode(sideASuppRod, 4,
3242                            new TGeoTranslation(-xloc,-yloc, zloc) );
3243
3244   zloc += suppRod->GetDz();
3245   trayASuppStruct->AddNode(sideASuppRearRing, 1,
3246                            new TGeoTranslation( 0, 0, zloc) );
3247   trayASuppStruct->AddNode(sideASuppRearRing, 2,
3248                            new TGeoCombiTrans( 0, 0, zloc,
3249                                                new TGeoRotation("",180,0,0)));
3250
3251
3252   // Finally put everything in the mother volume
3253   moth->AddNode(trayASuppStruct,1,0);
3254
3255   return;
3256 }
3257
3258 //______________________________________________________________________
3259 void AliITSv11GeometrySupport::ServicesCableSupportSPD(TGeoVolume *moth,
3260                                                        TGeoManager *mgr){
3261 //
3262 // Creates the all SPD cable trays which are outside the ITS support cones
3263 // but still inside the TPC
3264 // In order to avoid a huge monolithic routine, this method actually
3265 // calls inner methods to create and assemble the various (macro)pieces
3266 //
3267 // Input:
3268 //         moth : the TGeoVolume owing the volume structure
3269 //         mgr  : the GeoManager (default gGeoManager)
3270 // Output:
3271 //
3272 // Created:         ???       Bjorn S. Nilsen
3273 // Updated:      15 Nov 2009  Mario Sitta
3274 //
3275 // Technical data are taken from AutoCAD drawings and other (oral)
3276 // information given by F.Tosello
3277 //
3278
3279   SPDCableTraysSideA(moth, mgr);
3280   SPDCableTraysSideC(moth, mgr);
3281
3282 }
3283
3284 //______________________________________________________________________
3285 void AliITSv11GeometrySupport::ServicesCableSupportSDD(TGeoVolume *moth,
3286                                                        TGeoManager *mgr){
3287 //
3288 // Creates the all SDD cable trays which are outside the ITS support cones
3289 // but still inside the TPC
3290 // In order to avoid a huge monolithic routine, this method actually
3291 // calls inner methods to create and assemble the various (macro)pieces
3292 //
3293 // Input:
3294 //         moth : the TGeoVolume owing the volume structure
3295 //         mgr  : the GeoManager (default gGeoManager)
3296 // Output:
3297 //
3298 // Created:      14 Dec 2009  Mario Sitta
3299 //
3300
3301   SDDCableTraysSideA(moth, mgr);
3302   SDDCableTraysSideC(moth, mgr);
3303
3304   return;
3305 }
3306
3307 //______________________________________________________________________
3308 void AliITSv11GeometrySupport::ServicesCableSupportSSD(TGeoVolume *moth,
3309                                                        TGeoManager *mgr){
3310 //
3311 // Creates the SSD cable trays which are outside the ITS support cones
3312 // but still inside the TPC
3313 // In order to avoid a huge monolithic routine, this method actually
3314 // calls inner methods to create and assemble the various (macro)pieces
3315 //
3316 // Input:
3317 //         moth : the TGeoVolume owing the volume structure
3318 //         mgr  : the GeoManager (default gGeoManager)
3319 // Output:
3320 //
3321 // Created:      15 Nov 2009  Mario Sitta
3322 //
3323
3324   SSDCableTraysSideA(moth, mgr);
3325   SSDCableTraysSideC(moth, mgr);
3326
3327   return;
3328 }
3329
3330 //______________________________________________________________________
3331 void AliITSv11GeometrySupport::SPDCableTraysSideA(TGeoVolume *moth,
3332                                                   TGeoManager *mgr){
3333 //
3334 // Creates the SPD cable trays which are outside the ITS support cones
3335 // but still inside the TPC on Side A
3336 // (part of this code is taken or anyway inspired to ServicesCableSupport
3337 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
3338 //
3339 // Input:
3340 //         moth : the TGeoVolume owing the volume structure
3341 //         mgr  : the GeoManager (default gGeoManager)
3342 // Output:
3343 //
3344 // Created:      15 Feb 2010  Mario Sitta
3345 // Updated:      10 Jun 2010  Mario Sitta  Freon inside cooling pipes
3346 //
3347 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
3348 // drawings and other (oral) information given by F.Tosello and D.Elia
3349 // (small differences with blueprints - e.g. -0.07mm in R1Trans and
3350 // R2Trans - fix small overlaps; they are then compensated in positioning
3351 // the Rear Tray to avoid its own overlaps with the rear supporting ring)
3352 // Optical cables and low voltage cables are approximated with mean
3353 // materials and square cross sections, but preserving the total material
3354 // budget.
3355 //
3356
3357   // Overall position and rotation of the A-Side Cable Trays
3358   // (parts of 0872/G/D)
3359   const Double_t kTrayAR1Trans           =  396.93 *fgkmm;
3360   const Double_t kTrayAR2Trans           =  413.93 *fgkmm;
3361   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
3362   const Double_t kTrayAZRot              = (180-169.5);// Degrees
3363   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
3364   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
3365
3366   const Double_t kForwardTrayWide        =   94.00 *fgkmm;//!!!TO BE CHECKED!!!
3367   const Double_t kForwardTrayFirstHigh   =   83.00 *fgkmm;//!!!TO BE CHECKED!!!
3368   const Double_t kForwardTraySecondHigh  =   52.70 *fgkmm;//!!!TO BE CHECKED!!!
3369   const Double_t kForwardTrayTotalLen    =  853.00 *fgkmm;
3370   const Double_t kForwardTrayFirstLen    =  435.00 *fgkmm;
3371   const Double_t kForwardTrayWingWide    =   16.00 *fgkmm;//!!!TO BE CHECKED!!!
3372   const Double_t kForwardTrayInterSpace  =   18.00 *fgkmm;//!!!TO BE CHECKED!!!
3373   const Double_t kForwardTrayThick       =    2.00 *fgkmm;
3374
3375   const Int_t kForwardSideNpoints        =    6;
3376
3377   const Double_t kExternalTrayLen        = 1200.00 *fgkmm;
3378   const Double_t kExternalTrayWide       = kForwardTrayWide;
3379   const Double_t kExternalTrayHigh       = kForwardTraySecondHigh;
3380   const Double_t kExternalTrayThick      = kForwardTrayThick;
3381
3382   const Double_t kCoolingTubeRmin        =    5.00 *fgkmm;
3383   const Double_t kCoolingTubeRmax        =    6.00 *fgkmm;
3384
3385   const Double_t kOpticalFibersSect      =    8.696*fgkmm;//!!!ESTIMATED!!!
3386   const Double_t kLowVoltageCableSect    =    3.412*fgkmm;//!!!ESTIMATED!!!
3387   const Double_t kHiVoltageCableSect     =    1.873*fgkmm;//!!!ESTIMATED!!!
3388
3389
3390   // Local variables
3391   Double_t xprof[kForwardSideNpoints], yprof[kForwardSideNpoints];
3392   Double_t xloc, yloc, zloc, alpharot;
3393
3394
3395   // The two tray components as assemblies
3396   TGeoVolumeAssembly *cableTrayAForw =
3397     new TGeoVolumeAssembly("ITSsupportSPDTrayAForwRear");
3398   TGeoVolumeAssembly *cableTrayAExt =
3399     new TGeoVolumeAssembly("ITSsupportSPDTrayAExt");
3400   
3401
3402   // First create all needed shapes
3403
3404   // The lower face of the forward tray: a BBox
3405   TGeoBBox *forwTrayLowerFace = new TGeoBBox(kForwardTrayWide/2,
3406                                              kForwardTrayThick/2,
3407                                              kForwardTrayTotalLen/2);
3408
3409   // The side face of the forward tray: a Xtru
3410   TGeoXtru *forwTraySideFace = new TGeoXtru(2);
3411   forwTraySideFace->SetName("ITSsuppSPDForwTraySide");
3412
3413   xprof[0] = 0;
3414   yprof[0] = kForwardTrayThick;
3415   xprof[1] = kForwardTrayTotalLen;
3416   yprof[1] = yprof[0];
3417   xprof[2] = xprof[1];
3418   yprof[2] = kForwardTraySecondHigh - kForwardTrayThick;
3419   xprof[3] = kForwardTrayFirstLen;
3420   yprof[3] = yprof[2];
3421   xprof[4] = xprof[3];
3422   yprof[4] = kForwardTrayFirstHigh - kForwardTrayThick;
3423   xprof[5] = xprof[0];
3424   yprof[5] = yprof[4];
3425
3426   forwTraySideFace->DefinePolygon(6, xprof, yprof);
3427   forwTraySideFace->DefineSection(0, 0);
3428   forwTraySideFace->DefineSection(1, kForwardTrayThick);
3429
3430   // The covers of the forward tray: two BBox's
3431   TGeoBBox *forwTrayShortCover = new TGeoBBox(kForwardTrayWide/2,
3432                                               kForwardTrayThick/2,
3433                                               kForwardTrayFirstLen/2);
3434
3435   TGeoBBox *forwTrayLongCover = new TGeoBBox(kForwardTrayWide/2,
3436                                              kForwardTrayThick/2,
3437                              (kForwardTrayTotalLen - kForwardTrayFirstLen)/2);
3438
3439   // Each small wing of the forward tray: a BBox
3440   TGeoBBox *forwTrayWing = new TGeoBBox(kForwardTrayWingWide/2,
3441                              (kForwardTrayFirstHigh-kForwardTraySecondHigh)/2,
3442                                         kForwardTrayThick/2);
3443
3444   // The internal plane of the forward tray: a BBox
3445   TGeoBBox *forwTrayPlane = new TGeoBBox(kForwardTrayWide/2-kForwardTrayThick,
3446                                          kForwardTrayThick/2,
3447                                          kForwardTrayTotalLen/2);
3448
3449   // The internal wall of the forward tray: a BBox
3450   TGeoBBox *forwTrayWall = new TGeoBBox(kForwardTrayThick/2,
3451                                  (kForwardTrayInterSpace-kForwardTrayThick)/2,
3452                                         kForwardTrayTotalLen/2);
3453
3454   // Each horizontal face of the external tray: a BBox
3455   TGeoBBox *extTrayHorFace = new TGeoBBox(kExternalTrayWide/2-kExternalTrayThick,
3456                                           kExternalTrayThick/2,
3457                                           kExternalTrayLen/2);
3458
3459   // Each vertical face of the external tray: a BBox
3460   TGeoBBox *extTrayVerFace = new TGeoBBox(kExternalTrayThick/2,
3461                                           kExternalTrayHigh/2,
3462                                           kExternalTrayLen/2);
3463
3464   // The internal wall of the external tray: a BBox
3465   TGeoBBox *extTrayWall = new TGeoBBox(kExternalTrayThick/2,
3466                                  (kForwardTrayInterSpace-kExternalTrayThick)/2,
3467                                        kExternalTrayLen/2);
3468
3469   // The cooling tube inside the forward tray: a Tube
3470   Double_t zelong = (kForwardTraySecondHigh - 2*kForwardTrayThick
3471                 - 2*forwTrayWall->GetDY() - kCoolingTubeRmax)*SinD(kTrayAZRot);
3472   Double_t zlen = (zelong + kForwardTrayTotalLen)/2;
3473   TGeoTube *coolTubeForw = new TGeoTube(0, kCoolingTubeRmax, zlen);
3474
3475   // The freon inside the forward tray tubes: a Tube
3476   TGeoTube *freonTubeForw = new TGeoTube(0, kCoolingTubeRmin, zlen);
3477
3478   // The cooling tube inside the external tray: a Ctub
3479   TGeoCtub *coolTubeExt = new TGeoCtub(0, kCoolingTubeRmax,
3480                                        kExternalTrayLen/2, 0, 360,
3481                                        0, SinD(kTrayAZRot),-CosD(kTrayAZRot),
3482                                        0,                0,               1);
3483
3484   // The freon inside the forward tray tubes: a Tube
3485   TGeoCtub *freonTubeExt = new TGeoCtub(0, kCoolingTubeRmin,
3486                                         kExternalTrayLen/2, 0, 360,
3487                                         0, SinD(kTrayAZRot),-CosD(kTrayAZRot),
3488                                         0,                0,               1);
3489
3490   // The optical fibers inside the forward tray: a BBox
3491   TGeoBBox *optFibsForw = new TGeoBBox(kOpticalFibersSect/2,
3492                                        kOpticalFibersSect/2,
3493                                        kForwardTrayTotalLen/2);
3494
3495   // The optical fibers inside the external tray: a Xtru
3496   TGeoXtru *optFibsExt = new TGeoXtru(2);
3497   optFibsExt->SetName("ITSsuppSPDExtTrayOptFibs");
3498
3499   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
3500            + 2*forwTrayWall->GetDY();
3501   xprof[0] = yprof[0]*TanD(kTrayAZRot);
3502   xprof[1] = kExternalTrayLen;
3503   yprof[1] = yprof[0];
3504   xprof[2] = xprof[1];
3505   yprof[2] = yprof[1] + kOpticalFibersSect;
3506   yprof[3] = yprof[2];
3507   xprof[3] = yprof[2]*TanD(kTrayAZRot);
3508
3509   optFibsExt->DefinePolygon(4, xprof, yprof);
3510   optFibsExt->DefineSection(0, 0);
3511   optFibsExt->DefineSection(1, kOpticalFibersSect);
3512
3513   // The Low Voltage cables inside the forward tray: a BBox
3514   TGeoBBox *lowCablesForw = new TGeoBBox(kLowVoltageCableSect/2,
3515                                          kLowVoltageCableSect/2,
3516                                          kForwardTrayTotalLen/2);
3517
3518   // The Low Voltage inside the external tray: a Xtru
3519   TGeoXtru *lowCablesExt = new TGeoXtru(2);
3520   lowCablesExt->SetName("ITSsuppSPDExtTrayLowVoltage");
3521
3522   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
3523            + 2*forwTrayWall->GetDY();
3524   xprof[0] = yprof[0]*TanD(kTrayAZRot);
3525   xprof[1] = kExternalTrayLen;
3526   yprof[1] = yprof[0];
3527   xprof[2] = xprof[1];
3528   yprof[2] = yprof[1] + kLowVoltageCableSect;
3529   yprof[3] = yprof[2];
3530   xprof[3] = yprof[2]*TanD(kTrayAZRot);
3531
3532   lowCablesExt->DefinePolygon(4, xprof, yprof);
3533   lowCablesExt->DefineSection(0, 0);
3534   lowCablesExt->DefineSection(1, kLowVoltageCableSect);
3535
3536   // The High Voltage cables inside the forward tray: a BBox
3537   TGeoBBox *hiCablesForw = new TGeoBBox(kHiVoltageCableSect/2,
3538                                         kHiVoltageCableSect/2,
3539                                         kForwardTrayTotalLen/2);
3540
3541   // The High Voltage inside the external tray: a Xtru
3542   TGeoXtru *hiCablesExt = new TGeoXtru(2);
3543   hiCablesExt->SetName("ITSsuppSPDExtTrayHiVoltage");
3544
3545   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
3546            + 2*forwTrayWall->GetDY();
3547   xprof[0] = yprof[0]*TanD(kTrayAZRot);
3548   xprof[1] = kExternalTrayLen;
3549   yprof[1] = yprof[0];
3550   xprof[2] = xprof[1];
3551   yprof[2] = yprof[1] + kHiVoltageCableSect;
3552   yprof[3] = yprof[2];
3553   xprof[3] = yprof[2]*TanD(kTrayAZRot);
3554
3555   hiCablesExt->DefinePolygon(4, xprof, yprof);
3556   hiCablesExt->DefineSection(0, 0);
3557   hiCablesExt->DefineSection(1, kHiVoltageCableSect);
3558
3559
3560   // We have all shapes: now create the real volumes
3561   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
3562   TGeoMedium *medIn    = mgr->GetMedium("ITS_INOX$");
3563   TGeoMedium *medFreon = mgr->GetMedium("ITS_GASEOUS FREON$");
3564   TGeoMedium *medFibs  = mgr->GetMedium("ITS_SDD OPTICFIB$");//!TO BE CHECKED!
3565   TGeoMedium *medLVC   = mgr->GetMedium("ITS_SPD_LOWCABLES$");
3566   TGeoMedium *medHVC   = mgr->GetMedium("ITS_SPD_HICABLES$");
3567
3568   TGeoVolume *forwTrayABase = new TGeoVolume("ITSsuppSPDSideAForwTrayABase",
3569                                             forwTrayLowerFace, medAl);
3570
3571   forwTrayABase->SetVisibility(kTRUE);
3572   forwTrayABase->SetLineColor(6); // Purple
3573   forwTrayABase->SetLineWidth(1);
3574   forwTrayABase->SetFillColor(forwTrayABase->GetLineColor());
3575   forwTrayABase->SetFillStyle(4000); // 0% transparent
3576
3577   TGeoVolume *forwTrayASide = new TGeoVolume("ITSsuppSPDSideAForwTrayASide",
3578                                             forwTraySideFace, medAl);
3579
3580   forwTrayASide->SetVisibility(kTRUE);
3581   forwTrayASide->SetLineColor(6); // Purple
3582   forwTrayASide->SetLineWidth(1);
3583   forwTrayASide->SetFillColor(forwTrayASide->GetLineColor());
3584   forwTrayASide->SetFillStyle(4000); // 0% transparent
3585
3586   TGeoVolume *forwTrayACoverShort = new TGeoVolume("ITSsuppSPDSideAForwTrayASC",
3587                                                   forwTrayShortCover, medAl);
3588
3589   forwTrayACoverShort->SetVisibility(kTRUE);
3590   forwTrayACoverShort->SetLineColor(6); // Purple
3591   forwTrayACoverShort->SetLineWidth(1);
3592   forwTrayACoverShort->SetFillColor(forwTrayACoverShort->GetLineColor());
3593   forwTrayACoverShort->SetFillStyle(4000); // 0% transparent
3594
3595   TGeoVolume *forwTrayACoverLong = new TGeoVolume("ITSsuppSPDSideAForwTrayALC",
3596                                                  forwTrayLongCover, medAl);
3597
3598   forwTrayACoverLong->SetVisibility(kTRUE);
3599   forwTrayACoverLong->SetLineColor(6); // Purple
3600   forwTrayACoverLong->SetLineWidth(1);
3601   forwTrayACoverLong->SetFillColor(forwTrayACoverLong->GetLineColor());
3602   forwTrayACoverLong->SetFillStyle(4000); // 0% transparent
3603
3604   TGeoVolume *forwTrayAWing = new TGeoVolume("ITSsuppSPDSideAForwTrayAWing",
3605                                              forwTrayWing, medAl);
3606
3607   forwTrayAWing->SetVisibility(kTRUE);
3608   forwTrayAWing->SetLineColor(6); // Purple
3609   forwTrayAWing->SetLineWidth(1);
3610   forwTrayAWing->SetFillColor(forwTrayAWing->GetLineColor());
3611   forwTrayAWing->SetFillStyle(4000); // 0% transparent
3612
3613   TGeoVolume *forwTrayAPlane = new TGeoVolume("ITSsuppSPDSideAForwTrayAPlane",
3614                                               forwTrayPlane, medAl);
3615
3616   forwTrayAPlane->SetVisibility(kTRUE);
3617   forwTrayAPlane->SetLineColor(6); // Purple
3618   forwTrayAPlane->SetLineWidth(1);
3619   forwTrayAPlane->SetFillColor(forwTrayAPlane->GetLineColor());
3620   forwTrayAPlane->SetFillStyle(4000); // 0% transparent
3621
3622   TGeoVolume *forwTrayAWall = new TGeoVolume("ITSsuppSPDSideAForwTrayAWall",
3623                                              forwTrayWall, medAl);
3624
3625   forwTrayAWall->SetVisibility(kTRUE);
3626   forwTrayAWall->SetLineColor(6); // Purple
3627   forwTrayAWall->SetLineWidth(1);
3628   forwTrayAWall->SetFillColor(forwTrayAWall->GetLineColor());
3629   forwTrayAWall->SetFillStyle(4000); // 0% transparent
3630
3631   TGeoVolume *extTrayAHorFace = new TGeoVolume("ITSsuppSPDSideAExtTrayHorFace",
3632                                                extTrayHorFace, medAl);
3633
3634   extTrayAHorFace->SetVisibility(kTRUE);
3635   extTrayAHorFace->SetLineColor(6); // Purple
3636   extTrayAHorFace->SetLineWidth(1);
3637   extTrayAHorFace->SetFillColor(extTrayAHorFace->GetLineColor());
3638   extTrayAHorFace->SetFillStyle(4000); // 0% transparent
3639
3640   TGeoVolume *extTrayAVerFace = new TGeoVolume("ITSsuppSPDSideAExtTrayVerFace",
3641                                                extTrayVerFace, medAl);
3642
3643   extTrayAVerFace->SetVisibility(kTRUE);
3644   extTrayAVerFace->SetLineColor(6); // Purple
3645   extTrayAVerFace->SetLineWidth(1);
3646   extTrayAVerFace->SetFillColor(extTrayAVerFace->GetLineColor());
3647   extTrayAVerFace->SetFillStyle(4000); // 0% transparent
3648
3649   TGeoVolume *extTrayAWall = new TGeoVolume("ITSsuppSPDSideAExtTrayWall",
3650                                             extTrayWall, medAl);
3651
3652   extTrayAWall->SetVisibility(kTRUE);
3653   extTrayAWall->SetLineColor(6); // Purple
3654   extTrayAWall->SetLineWidth(1);
3655   extTrayAWall->SetFillColor(extTrayAWall->GetLineColor());
3656   extTrayAWall->SetFillStyle(4000); // 0% transparent
3657
3658   TGeoVolume *forwCoolTube = new TGeoVolume("ITSsuppSPDSideAForwTrayCoolTube",
3659                                             coolTubeForw, medIn);
3660
3661   forwCoolTube->SetVisibility(kTRUE);
3662   forwCoolTube->SetLineColor(kGray); // as in GeometrySPD
3663   forwCoolTube->SetLineWidth(1);
3664   forwCoolTube->SetFillColor(forwCoolTube->GetLineColor());
3665   forwCoolTube->SetFillStyle(4000); // 0% transparent
3666
3667   TGeoVolume *forwCoolFreon = new TGeoVolume("ITSsuppSPDSideAForwTrayFreon",
3668                                              freonTubeForw, medFreon);
3669
3670   forwCoolFreon->SetVisibility(kTRUE);
3671   forwCoolFreon->SetLineColor(kBlue); // Blue
3672   forwCoolFreon->SetLineWidth(1);
3673   forwCoolFreon->SetFillColor(forwCoolFreon->GetLineColor());
3674   forwCoolFreon->SetFillStyle(4000); // 0% transparent
3675
3676   TGeoVolume *extCoolTube = new TGeoVolume("ITSsuppSPDSideAExtTrayCoolTube",
3677                                            coolTubeExt, medIn);
3678
3679   extCoolTube->SetVisibility(kTRUE);
3680   extCoolTube->SetLineColor(kGray); // as in GeometrySPD
3681   extCoolTube->SetLineWidth(1);
3682   extCoolTube->SetFillColor(extCoolTube->GetLineColor());
3683   extCoolTube->SetFillStyle(4000); // 0% transparent
3684
3685   TGeoVolume *extCoolFreon = new TGeoVolume("ITSsuppSPDSideAExtTrayFreon",
3686                                             freonTubeExt, medFreon);
3687
3688   extCoolFreon->SetVisibility(kTRUE);
3689   extCoolFreon->SetLineColor(kBlue); // Blue
3690   extCoolFreon->SetLineWidth(1);
3691   extCoolFreon->SetFillColor(extCoolFreon->GetLineColor());
3692   extCoolFreon->SetFillStyle(4000); // 0% transparent
3693
3694   TGeoVolume *forwOptFibs = new TGeoVolume("ITSsuppSPDSideAForwTrayOptFibs",
3695                                            optFibsForw, medFibs);
3696
3697   forwOptFibs->SetVisibility(kTRUE);
3698   forwOptFibs->SetLineColor(kOrange); // Orange
3699   forwOptFibs->SetLineWidth(1);
3700   forwOptFibs->SetFillColor(forwOptFibs->GetLineColor());
3701   forwOptFibs->SetFillStyle(4000); // 0% transparent
3702
3703   TGeoVolume *extOptFibs = new TGeoVolume("ITSsuppSPDSideAExtTrayOptFibs",
3704                                           optFibsExt, medFibs);
3705
3706   extOptFibs->SetVisibility(kTRUE);
3707   extOptFibs->SetLineColor(kOrange); // Orange
3708   extOptFibs->SetLineWidth(1);
3709   extOptFibs->SetFillColor(extOptFibs->GetLineColor());
3710   extOptFibs->SetFillStyle(4000); // 0% transparent
3711
3712   TGeoVolume *forwLowCabs = new TGeoVolume("ITSsuppSPDSideAForwTrayLowCabs",
3713                                            lowCablesForw, medLVC);
3714
3715   forwLowCabs->SetVisibility(kTRUE);
3716   forwLowCabs->SetLineColor(kRed); // Red
3717   forwLowCabs->SetLineWidth(1);
3718   forwLowCabs->SetFillColor(forwLowCabs->GetLineColor());
3719   forwLowCabs->SetFillStyle(4000); // 0% transparent
3720
3721   TGeoVolume *extLowCabs = new TGeoVolume("ITSsuppSPDSideAExtTrayLowCabs",
3722                                           lowCablesExt, medLVC);
3723
3724   extLowCabs->SetVisibility(kTRUE);
3725   extLowCabs->SetLineColor(kRed); // Red
3726   extLowCabs->SetLineWidth(1);
3727   extLowCabs->SetFillColor(extLowCabs->GetLineColor());
3728   extLowCabs->SetFillStyle(4000); // 0% transparent
3729
3730   TGeoVolume *forwHiCabs = new TGeoVolume("ITSsuppSPDSideAForwTrayHiCabs",
3731                                           hiCablesForw, medHVC);
3732
3733   forwHiCabs->SetVisibility(kTRUE);
3734   forwHiCabs->SetLineColor(kRed); // Red
3735   forwHiCabs->SetLineWidth(1);
3736   forwHiCabs->SetFillColor(forwHiCabs->GetLineColor());
3737   forwHiCabs->SetFillStyle(4000); // 0% transparent
3738
3739   TGeoVolume *extHiCabs = new TGeoVolume("ITSsuppSPDSideAExtTrayHiCabs",
3740                                          hiCablesExt, medHVC);
3741
3742   extHiCabs->SetVisibility(kTRUE);
3743   extHiCabs->SetLineColor(kRed); // Red
3744   extHiCabs->SetLineWidth(1);
3745   extHiCabs->SetFillColor(extHiCabs->GetLineColor());
3746   extHiCabs->SetFillStyle(4000); // 0% transparent
3747
3748
3749   // Now build up the trays
3750   yloc = forwTrayLowerFace->GetDY();
3751   zloc = forwTrayLowerFace->GetDZ();
3752   cableTrayAForw->AddNode(forwTrayABase, 1,
3753                       new TGeoTranslation(0, yloc, zloc));
3754
3755   xloc = kForwardTrayWide/2;
3756   cableTrayAForw->AddNode(forwTrayASide, 1,
3757                       new TGeoCombiTrans( xloc, 0, 0,
3758                                          new TGeoRotation("",90,-90,-90)));
3759   cableTrayAForw->AddNode(forwTrayASide, 2,
3760                       new TGeoCombiTrans(-xloc+kForwardTrayThick, 0, 0,
3761                                          new TGeoRotation("",90,-90,-90)));
3762
3763   yloc = kForwardTrayFirstHigh - forwTrayShortCover->GetDY();
3764   zloc = forwTrayShortCover->GetDZ();
3765   cableTrayAForw->AddNode(forwTrayACoverShort, 1,
3766                       new TGeoTranslation(0, yloc, zloc));
3767
3768   yloc = kForwardTraySecondHigh - forwTrayLongCover->GetDY();
3769   zloc = kForwardTrayFirstLen + forwTrayLongCover->GetDZ();
3770   cableTrayAForw->AddNode(forwTrayACoverLong, 1,
3771                       new TGeoTranslation(0, yloc, zloc));
3772
3773   xloc = kForwardTrayWide/2 - kForwardTrayThick - forwTrayWing->GetDX();
3774   yloc = kForwardTrayFirstHigh - kForwardTrayThick - forwTrayWing->GetDY();
3775   zloc = kForwardTrayFirstLen - forwTrayWing->GetDZ();
3776   cableTrayAForw->AddNode(forwTrayAWing, 1,
3777                       new TGeoTranslation( xloc, yloc, zloc));
3778   cableTrayAForw->AddNode(forwTrayAWing, 2,
3779                       new TGeoTranslation(-xloc, yloc, zloc));
3780
3781   yloc = kForwardTrayThick + kForwardTrayInterSpace - forwTrayPlane->GetDY();
3782   zloc = forwTrayPlane->GetDZ();
3783   cableTrayAForw->AddNode(forwTrayAPlane, 1,
3784                       new TGeoTranslation(0, yloc, zloc));
3785
3786   yloc = kForwardTrayThick + forwTrayWall->GetDY();
3787   zloc = forwTrayWall->GetDZ();
3788   cableTrayAForw->AddNode(forwTrayAWall, 1,
3789                       new TGeoTranslation(0, yloc, zloc));
3790
3791   forwCoolTube->AddNode(forwCoolFreon, 1, 0);
3792
3793   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY()
3794        + coolTubeForw->GetRmax();
3795   zloc = coolTubeForw->GetDz();
3796   cableTrayAForw->AddNode(forwCoolTube, 1,
3797                       new TGeoTranslation(0, yloc, zloc));
3798
3799   xloc = optFibsForw->GetDX() + coolTubeForw->GetRmax();
3800   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY() + optFibsForw->GetDY();
3801   zloc = optFibsForw->GetDZ();
3802   cableTrayAForw->AddNode(forwOptFibs, 1,
3803                       new TGeoTranslation(xloc, yloc, zloc));
3804
3805   xloc = lowCablesForw->GetDX() + coolTubeForw->GetRmax();
3806   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY() +lowCablesForw->GetDY();
3807   zloc = lowCablesForw->GetDZ();
3808   cableTrayAForw->AddNode(forwLowCabs, 1,
3809                       new TGeoTranslation(-xloc, yloc, zloc));
3810
3811   xloc = hiCablesForw->GetDX() + 2*lowCablesForw->GetDX()
3812        + coolTubeForw->GetRmax();
3813   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY() + hiCablesForw->GetDY();
3814   zloc = hiCablesForw->GetDZ();
3815   cableTrayAForw->AddNode(forwHiCabs, 1,
3816                       new TGeoTranslation(-xloc, yloc, zloc));
3817
3818   // To simplify following placement in MARS, origin is on top
3819   yloc = -kExternalTrayHigh + kExternalTrayThick/2;
3820   zloc = kExternalTrayLen/2;
3821   cableTrayAExt->AddNode(extTrayAHorFace, 1,
3822                       new TGeoTranslation( 0, yloc, zloc));
3823
3824   xloc = kExternalTrayWide/2 - kExternalTrayThick/2;
3825   yloc = -kExternalTrayHigh/2;
3826   cableTrayAExt->AddNode(extTrayAVerFace, 1,
3827                       new TGeoTranslation( xloc, yloc, zloc));
3828   cableTrayAExt->AddNode(extTrayAVerFace, 2,
3829                       new TGeoTranslation(-xloc, yloc, zloc));
3830
3831   yloc = -kExternalTrayThick/2;
3832   cableTrayAExt->AddNode(extTrayAHorFace, 2,
3833                       new TGeoTranslation( 0, yloc, zloc));
3834
3835   yloc = -kExternalTrayHigh
3836        + kExternalTrayThick + kForwardTrayInterSpace - kExternalTrayThick/2;
3837   cableTrayAExt->AddNode(extTrayAHorFace, 3,
3838                       new TGeoTranslation( 0, yloc, zloc));
3839
3840   yloc = -kExternalTrayHigh + kExternalTrayThick + extTrayWall->GetDY();
3841   cableTrayAExt->AddNode(extTrayAWall, 1,
3842                       new TGeoTranslation( 0, yloc, zloc));
3843
3844   extCoolTube->AddNode(extCoolFreon, 1, 0);
3845
3846   yloc = -kExternalTrayHigh + 2*kExternalTrayThick + 2*extTrayWall->GetDY()
3847        + coolTubeExt->GetRmax();
3848   zloc = coolTubeExt->GetDz();
3849   cableTrayAExt->AddNode(extCoolTube, 1,
3850                       new TGeoTranslation(0, yloc, zloc));
3851
3852   xloc = kOpticalFibersSect + coolTubeExt->GetRmax();
3853   cableTrayAExt->AddNode(extOptFibs, 1,
3854                       new TGeoCombiTrans( xloc, 0, 0,
3855                                          new TGeoRotation("",90,-90,-90)));
3856
3857   xloc = kLowVoltageCableSect + coolTubeExt->GetRmax();
3858   cableTrayAExt->AddNode(extLowCabs, 1,
3859                       new TGeoCombiTrans(-xloc, 0, 0,
3860                                          new TGeoRotation("",90,-90,-90)));
3861
3862   xloc = 2*kHiVoltageCableSect + kLowVoltageCableSect + coolTubeExt->GetRmax();
3863   cableTrayAExt->AddNode(extHiCabs, 1,
3864                       new TGeoCombiTrans(-xloc, 0, 0,
3865                                          new TGeoRotation("",90,-90,-90)));
3866
3867
3868   // Finally put everything in the mother volume
3869   Double_t rExtTray = kTrayAR2Trans + kExternalTrayHigh;
3870
3871   moth->AddNode(cableTrayAForw,1,
3872                 new TGeoTranslation( 0, kTrayAR1Trans, kTrayAZTrans));
3873   moth->AddNode(cableTrayAForw,2,
3874                 new TGeoCombiTrans(  0,-kTrayAR1Trans, kTrayAZTrans,
3875                                     new TGeoRotation("",180, 0, 0)));
3876
3877   yloc = kTrayAR1Trans + kExternalTrayHigh;
3878   zloc = kTrayAZTrans + kForwardTrayTotalLen;
3879   moth->AddNode(cableTrayAExt,1,
3880                 new TGeoCombiTrans( 0, yloc, zloc,
3881                                     new TGeoRotation("",  0,-kTrayAZRot, 0)));
3882   moth->AddNode(cableTrayAExt,2,
3883                 new TGeoCombiTrans( 0,-yloc, zloc,
3884                                     new TGeoRotation("",180,-kTrayAZRot, 0)));
3885
3886   alpharot = kTrayAFirstRotAng + kTrayASecondRotAng;
3887   xloc = kTrayAR2Trans*SinD(alpharot);
3888   yloc = kTrayAR2Trans*CosD(alpharot);
3889   moth->AddNode(cableTrayAForw,3,
3890                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
3891                             new TGeoRotation("",-alpharot,0,0)   )   );
3892   xloc = rExtTray*SinD(alpharot);
3893   yloc = rExtTray*CosD(alpharot);
3894   moth->AddNode(cableTrayAExt,3,
3895                             new TGeoCombiTrans( xloc, yloc, zloc,
3896                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
3897
3898   alpharot += 180;
3899   xloc = kTrayAR2Trans*SinD(alpharot);
3900   yloc = kTrayAR2Trans*CosD(alpharot);
3901   moth->AddNode(cableTrayAForw,4,
3902                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
3903                             new TGeoRotation("",-alpharot,0,0)   )   );
3904   xloc = rExtTray*SinD(alpharot);
3905   yloc = rExtTray*CosD(alpharot);
3906   moth->AddNode(cableTrayAExt,4,
3907                             new TGeoCombiTrans( xloc, yloc, zloc,
3908                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
3909
3910   alpharot = - kTrayAFirstRotAng - kTrayASecondRotAng;
3911   xloc = kTrayAR2Trans*SinD(alpharot);
3912   yloc = kTrayAR2Trans*CosD(alpharot);
3913   moth->AddNode(cableTrayAForw,5,
3914                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
3915                             new TGeoRotation("",-alpharot,0,0)   )   );
3916   xloc = rExtTray*SinD(alpharot);
3917   yloc = rExtTray*CosD(alpharot);
3918   moth->AddNode(cableTrayAExt,5,
3919                             new TGeoCombiTrans( xloc, yloc, zloc,
3920                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
3921
3922   alpharot += 180;
3923   xloc = kTrayAR2Trans*SinD(alpharot);
3924   yloc = kTrayAR2Trans*CosD(alpharot);
3925   moth->AddNode(cableTrayAForw,6,
3926                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
3927                             new TGeoRotation("",-alpharot,0,0)   )   );
3928   xloc = rExtTray*SinD(alpharot);
3929   yloc = rExtTray*CosD(alpharot);
3930   moth->AddNode(cableTrayAExt,6,
3931                             new TGeoCombiTrans( xloc, yloc, zloc,
3932                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
3933
3934   alpharot = kTrayAFirstRotAng + 3*kTrayASecondRotAng;
3935   xloc = kTrayAR2Trans*SinD(alpharot);
3936   yloc = kTrayAR2Trans*CosD(alpharot);
3937   moth->AddNode(cableTrayAForw,7,
3938                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
3939                             new TGeoRotation("",-alpharot,0,0)   )   );
3940   xloc = rExtTray*SinD(alpharot);
3941   yloc = rExtTray*CosD(alpharot);
3942   moth->AddNode(cableTrayAExt,7,
3943                             new TGeoCombiTrans( xloc, yloc, zloc,
3944                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
3945
3946   alpharot += 180;
3947   xloc = kTrayAR2Trans*SinD(alpharot);
3948   yloc = kTrayAR2Trans*CosD(alpharot);
3949   moth->AddNode(cableTrayAForw,8,
3950                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
3951                             new TGeoRotation("",-alpharot,0,0)   )   );
3952   xloc = rExtTray*SinD(alpharot);
3953   yloc = rExtTray*CosD(alpharot);
3954   moth->AddNode(cableTrayAExt,8,
3955                             new TGeoCombiTrans( xloc, yloc, zloc,
3956                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
3957
3958   alpharot = - kTrayAFirstRotAng - 3*kTrayASecondRotAng;
3959   xloc = kTrayAR2Trans*SinD(alpharot);
3960   yloc = kTrayAR2Trans*CosD(alpharot);
3961   moth->AddNode(cableTrayAForw,9,
3962                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
3963                             new TGeoRotation("",-alpharot,0,0)   )   );
3964   xloc = rExtTray*SinD(alpharot);
3965   yloc = rExtTray*CosD(alpharot);
3966   moth->AddNode(cableTrayAExt,9,
3967                             new TGeoCombiTrans( xloc, yloc, zloc,
3968                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
3969
3970   alpharot += 180;
3971   xloc = kTrayAR2Trans*SinD(alpharot);
3972   yloc = kTrayAR2Trans*CosD(alpharot);
3973   moth->AddNode(cableTrayAForw,10,
3974                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
3975                             new TGeoRotation("",-alpharot,0,0)   )   );
3976   xloc = rExtTray*SinD(alpharot);
3977   yloc = rExtTray*CosD(alpharot);
3978   moth->AddNode(cableTrayAExt,10,
3979                             new TGeoCombiTrans( xloc, yloc, zloc,
3980                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
3981
3982
3983   return;
3984 }
3985
3986 //______________________________________________________________________
3987 void AliITSv11GeometrySupport::SPDCableTraysSideC(TGeoVolume *moth,
3988                                                   TGeoManager *mgr){
3989 //
3990 // Creates the SPD cable trays which are outside the ITS support cones
3991 // but still inside the TPC on Side C
3992 // (part of this code is taken or anyway inspired to ServicesCableSupport
3993 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
3994 //
3995 // Input:
3996 //         moth : the TGeoVolume owing the volume structure
3997 //         mgr  : the GeoManager (default gGeoManager)
3998 // Output:
3999 //
4000 // Return:
4001 //
4002 // Created:         ???       Bjorn S. Nilsen
4003 // Updated:      22 Apr 2010  Mario Sitta
4004 // Updated:      10 Jun 2010  Mario Sitta  Freon inside cooling pipes
4005 //
4006 // Technical data are taken from AutoCAD drawings and other (oral)
4007 // information given by D.Elia
4008 //
4009
4010   // Dimensions and positions of the C-Side Cable Tray elements
4011   const Int_t    kNumTraysSideC       =   10;
4012
4013   const Double_t kTrayCHalfWide       =    6.350 *fgkcm;
4014   const Double_t kTrayCLength1        =  172.800 *fgkcm;
4015   const Double_t kTrayCLength2        =  189.300 *fgkcm;
4016   const Double_t kTrayCFirstLen       =  435.000 *fgkmm;
4017   const Double_t kTrayCFirstHigh      =   83.000 *fgkmm;//!!!TO BE CHECKED!!!
4018   const Double_t kTrayCSecondHigh     =   52.700 *fgkmm;//!!!TO BE CHECKED!!!
4019   const Double_t kTrayCThick          =    0.200 *fgkcm;
4020   const Double_t kTrayCInterSpace     =   18.000 *fgkmm;//!!!TO BE CHECKED!!!
4021   const Double_t kTrayCFoldAngle      =    5.000 *fgkDegree;
4022
4023   const Double_t kCoolingTubeRmin     =    5.000 *fgkmm;
4024   const Double_t kCoolingTubeRmax     =    6.000 *fgkmm;
4025   const Double_t kOpticalFibersSect   =    8.696 *fgkmm;//!!!ESTIMATED!!!
4026   const Double_t kLowVoltageCableSect =    3.412 *fgkmm;//!!!ESTIMATED!!!
4027   const Double_t kHiVoltageCableSect  =    1.873 *fgkmm;//!!!ESTIMATED!!!
4028
4029   // Overall position and rotation of the C-Side Cable Trays
4030   const Double_t kTraySideCRPos       =   45.300 *fgkcm;
4031   const Double_t kTraySideCZPos       = -102.400 *fgkcm;
4032   const Double_t kTraySideCAlphaRot[kNumTraysSideC/2]  =
4033     {    0.0,      41.0,     -41.0,      76.0,      -76.0};
4034   // From position of the other trays
4035
4036
4037   // Local variables
4038   Double_t xprof[8], yprof[8];
4039   Double_t xloc, yloc, zloc, delta, alpharot;
4040
4041
4042   // The single C-Side Cable tray as an assembly
4043   TGeoVolumeAssembly *cableTrayC = new TGeoVolumeAssembly("ITSsupportSPDTrayC");
4044
4045   // First create all needed shapes
4046
4047   // The Cable Tray lower face: a Xtru
4048   TGeoXtru *sideCHorFace = new TGeoXtru(2);
4049
4050   xprof[0] = 0.;
4051   yprof[0] = 0.;
4052   xprof[1] = kTrayCLength1;
4053   yprof[1] = 0.;
4054   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4055   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4056   xprof[3] = xprof[2] - kTrayCThick*SinD(kTrayCFoldAngle);
4057   yprof[3] = yprof[2] + kTrayCThick*CosD(kTrayCFoldAngle);
4058   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4059               kTrayCThick , xprof[4], yprof[4]);
4060   xprof[5] = 0.;
4061   yprof[5] = kTrayCThick;
4062
4063   delta = kTrayCHalfWide - kTrayCThick;
4064
4065   sideCHorFace->DefinePolygon(6, xprof, yprof);
4066   sideCHorFace->DefineSection(0,-delta);
4067   sideCHorFace->DefineSection(1, delta);
4068
4069   // The Cable Tray middle face: a Xtru
4070   // (somehow duplicate of HorFace, but in this way avoid an overlap with Wall)
4071   TGeoXtru *sideCMidFace = new TGeoXtru(2);
4072
4073   xprof[0] = 0.;
4074   yprof[0] = kTrayCInterSpace + kTrayCThick;
4075   xprof[1] = kTrayCLength1;
4076   yprof[1] = yprof[0];
4077   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4078   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4079   xprof[3] = xprof[2] - kTrayCThick*SinD(kTrayCFoldAngle);
4080   yprof[3] = yprof[2] + kTrayCThick*CosD(kTrayCFoldAngle);
4081   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4082               kTrayCThick , xprof[4], yprof[4]);
4083   xprof[5] = 0.;
4084   yprof[5] = yprof[0] + kTrayCThick;
4085
4086   delta = kTrayCHalfWide - kTrayCThick;
4087
4088   sideCMidFace->DefinePolygon(6, xprof, yprof);
4089   sideCMidFace->DefineSection(0,-delta);
4090   sideCMidFace->DefineSection(1, delta);
4091
4092   // The Cable Tray lower face: a Xtru
4093   TGeoXtru *sideCSideFace = new TGeoXtru(2);
4094
4095   xprof[0] = 0.;
4096   yprof[0] = 0.;
4097   xprof[1] = kTrayCLength1;
4098   yprof[1] = 0.;
4099   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
4100   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
4101   xprof[3] = xprof[2] - kTrayCSecondHigh*SinD(kTrayCFoldAngle);
4102   yprof[3] = yprof[2] + kTrayCSecondHigh*CosD(kTrayCFoldAngle);
4103   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4104               kTrayCSecondHigh , xprof[4], yprof[4]);
4105   xprof[5] = kTrayCFirstLen;
4106   yprof[5] = kTrayCSecondHigh;
4107   xprof[6] = xprof[5];
4108   yprof[6] = kTrayCFirstHigh;
4109   xprof[7] = xprof[0];
4110   yprof[7] = yprof[6];
4111
4112   sideCSideFace->DefinePolygon(8, xprof, yprof);
4113   sideCSideFace->DefineSection(0, 0);
4114   sideCSideFace->DefineSection(1, kTrayCThick);
4115
4116   // The short cover: a BBox
4117   TGeoBBox *sideCShortCover = new TGeoBBox(kTrayCFirstLen/2,
4118                                            kTrayCThick/2,
4119                                            kTrayCHalfWide-kTrayCThick);
4120
4121   // The long cover: a Xtru
4122   TGeoXtru *sideCLongCover = new TGeoXtru(2);
4123
4124   xprof[5] = sideCSideFace->GetX(5);
4125   yprof[5] = sideCSideFace->GetY(5);
4126   xprof[4] = sideCSideFace->GetX(4);
4127   yprof[4] = sideCSideFace->GetY(4);
4128   xprof[3] = sideCSideFace->GetX(3);
4129   yprof[3] = sideCSideFace->GetY(3);
4130   xprof[2] = xprof[3] + kTrayCThick*SinD(kTrayCFoldAngle);
4131   yprof[2] = yprof[3] - kTrayCThick*CosD(kTrayCFoldAngle);
4132   InsidePoint(xprof[5], yprof[5], xprof[4], yprof[4], xprof[3], yprof[3],
4133              -kTrayCThick , xprof[1], yprof[1]);
4134   xprof[0] = xprof[5];
4135   yprof[0] = yprof[5] - kTrayCThick;
4136
4137   delta = kTrayCHalfWide - kTrayCThick;
4138
4139   sideCLongCover->DefinePolygon(6, xprof, yprof);
4140   sideCLongCover->DefineSection(0,-delta);
4141   sideCLongCover->DefineSection(1, delta);
4142
4143   // The internal wall: a Xtru
4144   TGeoXtru *intWall = new TGeoXtru(2);
4145
4146   xprof[0] = sideCHorFace->GetX(5);
4147   yprof[0] = sideCHorFace->GetY(5);
4148   xprof[1] = sideCHorFace->GetX(4);
4149   yprof[1] = sideCHorFace->GetY(4);
4150   xprof[2] = sideCHorFace->GetX(3);
4151   yprof[2] = sideCHorFace->GetY(3);
4152   xprof[3] = sideCMidFace->GetX(2);
4153   yprof[3] = sideCMidFace->GetY(2);
4154   xprof[4] = sideCMidFace->GetX(1);
4155   yprof[4] = sideCMidFace->GetY(1);
4156   xprof[5] = sideCMidFace->GetX(0);
4157   yprof[5] = sideCMidFace->GetY(0);
4158
4159   intWall->DefinePolygon(6, xprof, yprof);
4160   intWall->DefineSection(0,-kTrayCThick/2);
4161   intWall->DefineSection(1, kTrayCThick/2);
4162
4163   // The horizontal part of the cooling tube inside the tray: a Tube
4164   delta = sideCMidFace->GetX(4) - sideCMidFace->GetX(5);
4165   TGeoTube *horTube = new TGeoTube(0, kCoolingTubeRmax, delta/2);
4166
4167   // The freon inside the horizontal part of the cooling tube: a Tube
4168   TGeoTube *horFreon = new TGeoTube(0, kCoolingTubeRmin, delta/2);
4169
4170   // The inclined part of the cooling tube inside the tray: a Ctub
4171   Double_t x3, y3, x4, y4;
4172   x3 = sideCMidFace->GetX(3);
4173   y3 = sideCMidFace->GetY(3);
4174   x4 = sideCMidFace->GetX(4);
4175   y4 = sideCMidFace->GetY(4);
4176   delta = TMath::Sqrt( (x4 - x3 + kCoolingTubeRmax*SinD(kTrayCFoldAngle))*
4177                        (x4 - x3 + kCoolingTubeRmax*SinD(kTrayCFoldAngle))    +
4178        (y4 + kCoolingTubeRmax - y3 - kCoolingTubeRmax*SinD(kTrayCFoldAngle))*
4179        (y4 + kCoolingTubeRmax - y3 - kCoolingTubeRmax*SinD(kTrayCFoldAngle)) );
4180
4181   TGeoCtub *incTube = new TGeoCtub(0, kCoolingTubeRmax, delta/2, 0, 360,
4182                                0, SinD(kTrayCFoldAngle),-CosD(kTrayCFoldAngle),
4183                                0,                     0,                    1);
4184
4185   // The freon inside the inclined part of the cooling tube: a Ctub
4186   TGeoCtub *incFreon = new TGeoCtub(0, kCoolingTubeRmin, delta/2, 0, 360,
4187                                0, SinD(kTrayCFoldAngle),-CosD(kTrayCFoldAngle),
4188                                0,                     0,                    1);
4189
4190   // The optical fibers inside the tray: a Xtru
4191   TGeoXtru *optFibs = new TGeoXtru(2);
4192
4193   xprof[0] = sideCMidFace->GetX(5);
4194   yprof[0] = sideCMidFace->GetY(5);
4195   xprof[1] = sideCMidFace->GetX(4);
4196   yprof[1] = sideCMidFace->GetY(4);
4197   xprof[2] = sideCMidFace->GetX(3);
4198   yprof[2] = sideCMidFace->GetY(3);
4199   xprof[3] = xprof[2] - kOpticalFibersSect*SinD(kTrayCFoldAngle);
4200   yprof[3] = yprof[2] + kOpticalFibersSect*CosD(kTrayCFoldAngle);
4201   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4202               kOpticalFibersSect , xprof[4], yprof[4]);
4203   xprof[5] = 0.;
4204   yprof[5] = yprof[0] + kOpticalFibersSect;
4205
4206   optFibs->DefinePolygon(6, xprof, yprof);
4207   optFibs->DefineSection(0, 0);
4208   optFibs->DefineSection(1, kOpticalFibersSect);
4209
4210   // The low voltage cables inside the tray: a Xtru
4211   TGeoXtru *lowCables = new TGeoXtru(2);
4212
4213   xprof[0] = sideCMidFace->GetX(5);
4214   yprof[0] = sideCMidFace->GetY(5);
4215   xprof[1] = sideCMidFace->GetX(4);
4216   yprof[1] = sideCMidFace->GetY(4);
4217   xprof[2] = sideCMidFace->GetX(3);
4218   yprof[2] = sideCMidFace->GetY(3);
4219   xprof[3] = xprof[2] - kLowVoltageCableSect*SinD(kTrayCFoldAngle);
4220   yprof[3] = yprof[2] + kLowVoltageCableSect*CosD(kTrayCFoldAngle);
4221   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4222               kLowVoltageCableSect , xprof[4], yprof[4]);
4223   xprof[5] = 0.;
4224   yprof[5] = yprof[0] + kLowVoltageCableSect;
4225
4226   lowCables->DefinePolygon(6, xprof, yprof);
4227   lowCables->DefineSection(0, 0);
4228   lowCables->DefineSection(1, kLowVoltageCableSect);
4229
4230   // The high voltage cables inside the tray: a Xtru
4231   TGeoXtru *hiCables = new TGeoXtru(2);
4232
4233   xprof[0] = sideCMidFace->GetX(5);
4234   yprof[0] = sideCMidFace->GetY(5);
4235   xprof[1] = sideCMidFace->GetX(4);
4236   yprof[1] = sideCMidFace->GetY(4);
4237   xprof[2] = sideCMidFace->GetX(3);
4238   yprof[2] = sideCMidFace->GetY(3);
4239   xprof[3] = xprof[2] - kHiVoltageCableSect*SinD(kTrayCFoldAngle);
4240   yprof[3] = yprof[2] + kHiVoltageCableSect*CosD(kTrayCFoldAngle);
4241   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
4242               kHiVoltageCableSect , xprof[4], yprof[4]);
4243   xprof[5] = 0.;
4244   yprof[5] = yprof[0] + kHiVoltageCableSect;
4245
4246   hiCables->DefinePolygon(6, xprof, yprof);
4247   hiCables->DefineSection(0, 0);
4248   hiCables->DefineSection(1, kHiVoltageCableSect);
4249
4250
4251   // We have all shapes: now create the real volumes
4252   TGeoMedium *medAl   = mgr->GetMedium("ITS_ALUMINUM$");
4253   TGeoMedium *medIn   = mgr->GetMedium("ITS_INOX$");
4254   TGeoMedium *medFr   = mgr->GetMedium("ITS_Freon$");
4255   TGeoMedium *medFibs = mgr->GetMedium("ITS_SDD OPTICFIB$");//!!TO BE CHECKED!!
4256   TGeoMedium *medLVC  = mgr->GetMedium("ITS_SPD_LOWCABLES$");
4257   TGeoMedium *medHVC  = mgr->GetMedium("ITS_SPD_HICABLES$");
4258
4259   TGeoVolume *traySideCHorFace  = new TGeoVolume("ITSsuppSPDTraySideCHor",
4260                                                  sideCHorFace, medAl);
4261
4262   traySideCHorFace->SetVisibility(kTRUE);
4263   traySideCHorFace->SetLineColor(6); // Purple
4264   traySideCHorFace->SetLineWidth(1);
4265   traySideCHorFace->SetFillColor(traySideCHorFace->GetLineColor());
4266   traySideCHorFace->SetFillStyle(4000); // 0% transparent
4267
4268   TGeoVolume *traySideCMidFace  = new TGeoVolume("ITSsuppSPDTraySideCMid",
4269                                                  sideCMidFace, medAl);
4270
4271   traySideCMidFace->SetVisibility(kTRUE);
4272   traySideCMidFace->SetLineColor(6); // Purple
4273   traySideCMidFace->SetLineWidth(1);
4274   traySideCMidFace->SetFillColor(traySideCMidFace->GetLineColor());
4275   traySideCMidFace->SetFillStyle(4000); // 0% transparent
4276
4277   TGeoVolume *traySideCSideFace  = new TGeoVolume("ITSsuppSPDTraySideCSide",
4278                                                   sideCSideFace, medAl);
4279
4280   traySideCSideFace->SetVisibility(kTRUE);
4281   traySideCSideFace->SetLineColor(6); // Purple
4282   traySideCSideFace->SetLineWidth(1);
4283   traySideCSideFace->SetFillColor(traySideCSideFace->GetLineColor());
4284   traySideCSideFace->SetFillStyle(4000); // 0% transparent
4285
4286   TGeoVolume *traySideCShortCover  = new TGeoVolume("ITSsuppSPDTraySideCShCov",
4287                                                     sideCShortCover, medAl);
4288
4289   traySideCShortCover->SetVisibility(kTRUE);
4290   traySideCShortCover->SetLineColor(6); // Purple
4291   traySideCShortCover->SetLineWidth(1);
4292   traySideCShortCover->SetFillColor(traySideCShortCover->GetLineColor());
4293   traySideCShortCover->SetFillStyle(4000); // 0% transparent
4294
4295   TGeoVolume *traySideCLongCover  = new TGeoVolume("ITSsuppSPDTraySideCLnCov",
4296                                                    sideCLongCover, medAl);
4297
4298   traySideCLongCover->SetVisibility(kTRUE);
4299   traySideCLongCover->SetLineColor(6); // Purple
4300   traySideCLongCover->SetLineWidth(1);
4301   traySideCLongCover->SetFillColor(traySideCLongCover->GetLineColor());
4302   traySideCLongCover->SetFillStyle(4000); // 0% transparent
4303
4304   TGeoVolume *traySideCIntWall  = new TGeoVolume("ITSsuppSPDTraySideCWall",
4305                                                  intWall, medAl);
4306
4307   traySideCIntWall->SetVisibility(kTRUE);
4308   traySideCIntWall->SetLineColor(6); // Purple
4309   traySideCIntWall->SetLineWidth(1);
4310   traySideCIntWall->SetFillColor(traySideCIntWall->GetLineColor());
4311   traySideCIntWall->SetFillStyle(4000); // 0% transparent
4312
4313   TGeoVolume *traySideCHorTube = new TGeoVolume("ITSsuppSPDTraySideCHorTube",
4314                                                 horTube, medIn);
4315
4316   traySideCHorTube->SetVisibility(kTRUE);
4317   traySideCHorTube->SetLineColor(kGray); // as in GeometrySPD
4318   traySideCHorTube->SetLineWidth(1);
4319   traySideCHorTube->SetFillColor(traySideCHorTube->GetLineColor());
4320   traySideCHorTube->SetFillStyle(4000); // 0% transparent
4321
4322   TGeoVolume *traySideCHorFreon = new TGeoVolume("ITSsuppSPDTraySideCHorFreon",
4323                                                  horFreon, medFr);
4324
4325   traySideCHorFreon->SetVisibility(kTRUE);
4326   traySideCHorFreon->SetLineColor(kBlue); // Blue
4327   traySideCHorFreon->SetLineWidth(1);
4328   traySideCHorFreon->SetFillColor(traySideCHorFreon->GetLineColor());
4329   traySideCHorFreon->SetFillStyle(4000); // 0% transparent
4330
4331   TGeoVolume *traySideCIncTube = new TGeoVolume("ITSsuppSPDTraySideCIncTube",
4332                                                 incTube, medIn);
4333
4334   traySideCIncTube->SetVisibility(kTRUE);
4335   traySideCIncTube->SetLineColor(kGray); // as in GeometrySPD
4336   traySideCIncTube->SetLineWidth(1);
4337   traySideCIncTube->SetFillColor(traySideCIncTube->GetLineColor());
4338   traySideCIncTube->SetFillStyle(4000); // 0% transparent
4339
4340   TGeoVolume *traySideCIncFreon = new TGeoVolume("ITSsuppSPDTraySideCIncFreon",
4341                                                  incFreon, medFr);
4342
4343   traySideCIncFreon->SetVisibility(kTRUE);
4344   traySideCIncFreon->SetLineColor(kBlue); // Blue
4345   traySideCIncFreon->SetLineWidth(1);
4346   traySideCIncFreon->SetFillColor(traySideCIncFreon->GetLineColor());
4347   traySideCIncFreon->SetFillStyle(4000); // 0% transparent
4348
4349   TGeoVolume *traySideCOptFibs = new TGeoVolume("ITSsuppSPDTraySideCOptFibs",
4350                                                 optFibs, medFibs);
4351
4352   traySideCOptFibs->SetVisibility(kTRUE);
4353   traySideCOptFibs->SetLineColor(kOrange); // Orange
4354   traySideCOptFibs->SetLineWidth(1);
4355   traySideCOptFibs->SetFillColor(traySideCOptFibs->GetLineColor());
4356   traySideCOptFibs->SetFillStyle(4000); // 0% transparent
4357
4358   TGeoVolume *traySideCLowCabs = new TGeoVolume("ITSsuppSPDTraySideCLowCabs",
4359                                                 lowCables, medLVC);
4360
4361   traySideCLowCabs->SetVisibility(kTRUE);
4362   traySideCLowCabs->SetLineColor(kRed); // Red
4363   traySideCLowCabs->SetLineWidth(1);
4364   traySideCLowCabs->SetFillColor(traySideCLowCabs->GetLineColor());
4365   traySideCLowCabs->SetFillStyle(4000); // 0% transparent
4366
4367   TGeoVolume *traySideCHiCabs = new TGeoVolume("ITSsuppSPDTraySideCHiCabs",
4368                                                hiCables, medHVC);
4369
4370   traySideCHiCabs->SetVisibility(kTRUE);
4371   traySideCHiCabs->SetLineColor(kRed); // Red
4372   traySideCHiCabs->SetLineWidth(1);
4373   traySideCHiCabs->SetFillColor(traySideCHiCabs->GetLineColor());
4374   traySideCHiCabs->SetFillStyle(4000); // 0% transparent
4375
4376
4377   // Now build up the trays
4378   cableTrayC->AddNode(traySideCHorFace,1,0);
4379
4380   cableTrayC->AddNode(traySideCMidFace,1,0);
4381
4382   zloc = kTrayCHalfWide - kTrayCThick;
4383   cableTrayC->AddNode(traySideCSideFace, 1,
4384                       new TGeoTranslation( 0, 0, zloc));
4385   zloc = -kTrayCHalfWide;
4386   cableTrayC->AddNode(traySideCSideFace, 2,
4387                       new TGeoTranslation( 0, 0, zloc));
4388
4389   xloc = sideCShortCover->GetDX();
4390   yloc = kTrayCFirstHigh - sideCShortCover->GetDY();
4391   cableTrayC->AddNode(traySideCShortCover, 1,
4392                       new TGeoTranslation( xloc, yloc, 0));
4393
4394   cableTrayC->AddNode(traySideCLongCover,1,0);
4395
4396   cableTrayC->AddNode(traySideCIntWall,1,0);
4397
4398   traySideCHorTube->AddNode(traySideCHorFreon, 1, 0);
4399   traySideCIncTube->AddNode(traySideCIncFreon, 1, 0);
4400
4401   xloc = horTube->GetDz();
4402   yloc = sideCMidFace->GetY(5) + horTube->GetRmax();
4403   cableTrayC->AddNode(traySideCHorTube, 1,
4404                       new TGeoCombiTrans( xloc, yloc, 0,
4405                       new TGeoRotation("",-90.,-90.,90.)));
4406
4407   xloc = sideCMidFace->GetX(4) + (incTube->GetDz())*CosD(kTrayCFoldAngle);
4408   yloc = sideCMidFace->GetY(4) +  incTube->GetRmax() +
4409             (incTube->GetDz())*SinD(kTrayCFoldAngle)+0.005;//Avoid small ovrlp
4410   cableTrayC->AddNode(traySideCIncTube, 1,
4411                       new TGeoCombiTrans( xloc, yloc, 0,
4412                       new TGeoRotation("",-90.+kTrayCFoldAngle,-90.,90.)));
4413
4414   zloc = horTube->GetRmax();
4415   cableTrayC->AddNode(traySideCOptFibs, 1,
4416                       new TGeoTranslation( 0, 0, zloc));
4417
4418   zloc = kLowVoltageCableSect + horTube->GetRmax();
4419   cableTrayC->AddNode(traySideCLowCabs, 1,
4420                       new TGeoTranslation( 0, 0,-zloc));
4421
4422   zloc = kHiVoltageCableSect + kLowVoltageCableSect + horTube->GetRmax();
4423   cableTrayC->AddNode(traySideCHiCabs, 1,
4424                       new TGeoTranslation( 0, 0,-zloc));
4425
4426
4427   // Finally put everything in the mother volume
4428   for (Int_t jt = 0; jt < kNumTraysSideC/2; jt++) {
4429     alpharot = kTraySideCAlphaRot[jt];
4430
4431     xloc = kTraySideCRPos*SinD(alpharot);
4432     yloc = kTraySideCRPos*CosD(alpharot);
4433     moth->AddNode(cableTrayC,2*jt+1,
4434                 new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
4435                 new TGeoRotation("",-90.+alpharot,-90.,90.+kTrayCFoldAngle)));
4436     alpharot += 180;
4437     xloc = kTraySideCRPos*SinD(alpharot);
4438     yloc = kTraySideCRPos*CosD(alpharot);
4439     moth->AddNode(cableTrayC,2*jt+2,
4440                 new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
4441                 new TGeoRotation("",-90.+alpharot,-90.,90.+kTrayCFoldAngle)));
4442   }
4443
4444
4445   return;
4446 }
4447
4448 //______________________________________________________________________
4449 void AliITSv11GeometrySupport::SDDCableTraysSideA(TGeoVolume *moth,
4450                                                   TGeoManager *mgr){
4451 //
4452 // Creates the SDD cable trays which are outside the ITS support cones
4453 // but still inside the TPC on Side A
4454 // (part of this code is taken or anyway inspired to ServicesCableSupport
4455 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
4456 //
4457 // Input:
4458 //         moth : the TGeoVolume owing the volume structure
4459 //         mgr  : the GeoManager (default gGeoManager)
4460 // Output:
4461 //
4462 // Created:         ???       Bjorn S. Nilsen
4463 // Updated:       5 Jan 2010  Mario Sitta
4464 // Updated:      26 Feb 2010  Mario Sitta
4465 //
4466 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
4467 // drawings and other (oral) information given by F.Tosello
4468 //
4469
4470   // Overall position and rotation of the A-Side Cable Trays
4471   // (parts of 0872/G/D)
4472   const Double_t kTrayARTrans            =  408.35 *fgkmm;
4473   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
4474   const Double_t kTrayAZToSupportRing    =  435.00 *fgkmm;
4475   const Double_t kExternTrayZTrans       =  853.00 *fgkmm;
4476   const Double_t kExternCoverYTrans      =    2.00 *fgkmm;
4477   const Double_t kTrayAZRot              = (180-169.5);// Degrees
4478   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
4479   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
4480
4481   const Double_t kForwardTrayTailHeight  =  100.00 *fgkmm; // Computed
4482   const Double_t kForwardTrayTotalHeight =  170.00 *fgkmm; // Computed
4483   const Double_t kForwardTrayUpperLength =  405.00 *fgkmm; // Computed
4484   const Double_t kForwardCoverLength     =  380.00 *fgkmm;
4485   const Double_t kForwardCoverWide       =  133.00 *fgkmm;
4486   const Double_t kForwardCoverHeight     =   10.00 *fgkmm;
4487   const Double_t kForwardCoverThick      =    1.00 *fgkmm;
4488
4489   const Double_t kExternTrayTotalLen     = 1200.00 *fgkmm;
4490   const Double_t kExternTrayTotalHeight  =   52.00 *fgkmm;
4491   const Double_t kExternCoverLen         = kExternTrayTotalLen;
4492   const Double_t kExternCoverThick       =    5.00 *fgkmm;
4493   const Double_t kExternCoverSideThick   =    3.00 *fgkmm;
4494
4495   const Int_t    kForwardTrayNpoints     =    8;
4496
4497
4498   // Local variables
4499   Double_t xprof[kForwardTrayNpoints], yprof[kForwardTrayNpoints];
4500   Double_t xloc, yloc, zloc, alpharot;
4501
4502
4503   // The whole tray as an assembly
4504   TGeoVolumeAssembly *cableTrayA = new TGeoVolumeAssembly("ITSsupportSDDTrayA");
4505   
4506
4507   // First create all needed shapes
4508
4509   // The forward tray is very complex and deserves a dedicated method
4510   TGeoVolumeAssembly *forwardTray = CreateSDDForwardTraySideA(mgr);
4511
4512   // The forward cover: a Xtru
4513   TGeoXtru *forwardCover = new TGeoXtru(2);
4514   forwardCover->SetName("ITSsuppSDDForwCover");
4515
4516   xprof[0] = kForwardCoverWide/2;
4517   yprof[0] = kForwardCoverHeight;
4518   xprof[1] = xprof[0];
4519   yprof[1] = 0;
4520   xprof[2] = xprof[1] - kForwardCoverThick;
4521   yprof[2] = yprof[1];
4522   xprof[3] = xprof[2];
4523   yprof[3] = yprof[0] - kForwardCoverThick;
4524
4525   // We did the right side, now reflex on the left side
4526   for (Int_t jp = 0; jp < 4; jp++) {
4527     xprof[4+jp] = -xprof[3-jp];
4528     yprof[4+jp] =  yprof[3-jp];
4529   }
4530
4531   forwardCover->DefinePolygon(8, xprof, yprof);
4532   forwardCover->DefineSection(0, 0);
4533   forwardCover->DefineSection(1, kForwardCoverLength);
4534
4535   // The external tray (as 0872/G/D/03): a Xtru
4536   TGeoXtru *externalTray = CreateSDDSSDTraysSideA(kExternTrayTotalLen,
4537                                                   kExternTrayTotalHeight);
4538
4539   // The external covers: a Composite Shape
4540   TGeoCompositeShape *externCover = CreateTrayAExternalCover(kExternCoverLen);
4541
4542
4543   // We have all shapes: now create the real volumes
4544   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
4545   TGeoMedium *medAntic = mgr->GetMedium("ITS_ANTICORODAL$");
4546
4547   TGeoVolume *forwardTrayCover = new TGeoVolume("ITSsuppSDDSideAForwTrayCover",
4548                                                 forwardCover, medAl);
4549
4550   forwardTrayCover->SetVisibility(kTRUE);
4551   forwardTrayCover->SetLineColor(kMagenta+1); // Purple
4552   forwardTrayCover->SetLineWidth(1);
4553   forwardTrayCover->SetFillColor(forwardTrayCover->GetLineColor());
4554   forwardTrayCover->SetFillStyle(4000); // 0% transparent
4555
4556   TGeoVolume *externalTraySDD = new TGeoVolume("ITSsuppSDDSideAExternalTray",
4557                                                externalTray, medAl);
4558
4559   externalTraySDD->SetVisibility(kTRUE);
4560   externalTraySDD->SetLineColor(6); // Purple
4561   externalTraySDD->SetLineWidth(1);
4562   externalTraySDD->SetFillColor(externalTraySDD->GetLineColor());
4563   externalTraySDD->SetFillStyle(4000); // 0% transparent
4564
4565   TGeoVolume *externTrayCover = new TGeoVolume("ITSsuppSDDSideAExtTrayCover",
4566                                                externCover, medAntic);
4567
4568   externTrayCover->SetVisibility(kTRUE);
4569   externTrayCover->SetLineColor(kMagenta+1); // Purple
4570   externTrayCover->SetLineWidth(1);
4571   externTrayCover->SetFillColor(externTrayCover->GetLineColor());
4572   externTrayCover->SetFillStyle(4000); // 0% transparent
4573
4574
4575   // Now build up the tray
4576   yloc = kForwardTrayTotalHeight - forwardCover->GetY(3) +
4577          kExternTrayTotalHeight +
4578          kExternCoverSideThick - kForwardTrayTailHeight;
4579   zloc = kTrayAZToSupportRing - kForwardCoverLength;
4580   cableTrayA->AddNode(forwardTrayCover, 1,
4581                       new TGeoTranslation( 0, yloc, zloc) );
4582
4583   Double_t totalhi = kExternTrayTotalHeight + kExternCoverThick
4584                    - kExternCoverYTrans;
4585
4586   yloc = totalhi*(1 - CosD(kTrayAZRot));
4587   zloc = kExternTrayZTrans + totalhi*SinD(kTrayAZRot);
4588   cableTrayA->AddNode(externalTraySDD, 1,
4589                       new TGeoCombiTrans( 0, yloc, zloc,
4590                       new TGeoRotation("", 0,-kTrayAZRot, 0)        ) );
4591
4592   yloc = kExternTrayTotalHeight - kExternCoverYTrans;
4593   zloc = kExternTrayZTrans - yloc*SinD(kTrayAZRot);
4594   yloc *= CosD(kTrayAZRot);
4595   zloc += totalhi*SinD(kTrayAZRot);
4596   yloc += totalhi*(1 - CosD(kTrayAZRot));
4597   cableTrayA->AddNode(externTrayCover,1,
4598                       new TGeoCombiTrans( 0, yloc, zloc,
4599                       new TGeoRotation("", 0,-kTrayAZRot, 0)        ) );
4600
4601
4602   // Finally put everything in the mother volume
4603   alpharot = -kTrayAFirstRotAng;
4604   xloc = kTrayARTrans*SinD(alpharot);
4605   yloc = kTrayARTrans*CosD(alpharot);
4606   zloc = kTrayAZTrans;
4607   moth->AddNode(cableTrayA,1,
4608                             new TGeoCombiTrans( xloc, yloc, zloc,
4609                             new TGeoRotation("",-alpharot,0,0)   )   );
4610
4611   alpharot += 180;
4612   xloc = kTrayARTrans*SinD(alpharot);
4613   yloc = kTrayARTrans*CosD(alpharot);
4614   moth->AddNode(cableTrayA,2,
4615                             new TGeoCombiTrans( xloc, yloc, zloc,
4616                             new TGeoRotation("",-alpharot,0,0)   )   );
4617
4618   alpharot = kTrayAFirstRotAng + 2*kTrayASecondRotAng;
4619   xloc = kTrayARTrans*SinD(alpharot);
4620   yloc = kTrayARTrans*CosD(alpharot);
4621   moth->AddNode(cableTrayA,3,
4622                             new TGeoCombiTrans( xloc, yloc, zloc,
4623                             new TGeoRotation("",-alpharot,0,0)   )   );
4624
4625   alpharot += 180;
4626   xloc = kTrayARTrans*SinD(alpharot);
4627   yloc = kTrayARTrans*CosD(alpharot);
4628   moth->AddNode(cableTrayA,4,
4629                             new TGeoCombiTrans( xloc, yloc, zloc,
4630                             new TGeoRotation("",-alpharot,0,0)   )   );
4631
4632   // To avoid putting an assembly inside another assembly,
4633   // the forwardTray is put directly in the mother volume
4634   Double_t rforw = kTrayARTrans + kExternTrayTotalHeight +
4635                    kExternCoverSideThick -
4636                    kForwardTrayTailHeight;
4637
4638   alpharot = -kTrayAFirstRotAng;
4639   xloc = rforw*SinD(alpharot);
4640   yloc = rforw*CosD(alpharot);
4641   zloc = kTrayAZTrans + kTrayAZToSupportRing - kForwardTrayUpperLength;
4642
4643   moth->AddNode(forwardTray,1,
4644                             new TGeoCombiTrans( xloc, yloc, zloc,
4645                             new TGeoRotation("",-alpharot,0,0)   )   );
4646
4647   alpharot += 180;
4648   xloc = rforw*SinD(alpharot);
4649   yloc = rforw*CosD(alpharot);
4650   moth->AddNode(forwardTray,2,
4651                             new TGeoCombiTrans( xloc, yloc, zloc,
4652                             new TGeoRotation("",-alpharot,0,0)   )   );
4653
4654   alpharot = kTrayAFirstRotAng + 2*kTrayASecondRotAng;
4655   xloc = rforw*SinD(alpharot);
4656   yloc = rforw*CosD(alpharot);
4657   moth->AddNode(forwardTray,3,
4658                             new TGeoCombiTrans( xloc, yloc, zloc,
4659                             new TGeoRotation("",-alpharot,0,0)   )   );
4660
4661   alpharot += 180;
4662   xloc = rforw*SinD(alpharot);
4663   yloc = rforw*CosD(alpharot);
4664   moth->AddNode(forwardTray,4,
4665                             new TGeoCombiTrans( xloc, yloc, zloc,
4666                             new TGeoRotation("",-alpharot,0,0)   )   );
4667
4668
4669   return;
4670 }
4671
4672 //______________________________________________________________________
4673 void AliITSv11GeometrySupport::SDDCableTraysSideC(TGeoVolume *moth,
4674                                                   TGeoManager *mgr){
4675 //
4676 // Creates the SDD cable trays which are outside the ITS support cones
4677 // but still inside the TPC on Side C
4678 // (part of this code is taken or anyway inspired to ServicesCableSupport
4679 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
4680 //
4681 // Input:
4682 //         moth : the TGeoVolume owing the volume structure
4683 //         mgr  : the GeoManager (default gGeoManager)
4684 // Output:
4685 //
4686 // Created:         ???       Bjorn S. Nilsen
4687 // Updated:      17 Apr 2010  Mario Sitta
4688 //
4689 // Technical data are taken from AutoCAD drawings and other (oral)
4690 // information given by F.Tosello
4691 //
4692
4693   // Dimensions and positions of the C-Side Cable Tray elements
4694   const Int_t    kNumTraySideC           =    4;
4695
4696   const Double_t kSideCFoldAngle         =    5.00 *fgkDegree;
4697
4698   // Overall position and rotation of the C-Side Cable Trays
4699   const Double_t kTraySideCRPos          =   45.30    *fgkcm;
4700   const Double_t kTraySideCZPos          = -102.40    *fgkcm;
4701   const Double_t kTraySideCAlphaRot[kNumTraySideC]  = {    -23.0,      59.0,
4702     /* from SSD tray position */                       180.-23.0, 180.+59.0};
4703
4704
4705   // Local variables
4706 //  Double_t xprof[12], yprof[12];
4707   Double_t xloc, yloc, alpharot, alphafold;
4708
4709
4710   // The assembly holding the metallic structure
4711   // We need four of them because the content is different
4712   TGeoVolumeAssembly *trayStructure[kNumTraySideC];
4713   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
4714     char name[20];
4715     sprintf(name,"ITSsupportSDDTrayC%d",jt);
4716     trayStructure[jt] = CreateSDDSSDTraysSideC(name);
4717   }
4718
4719
4720   // We have all shapes: now create the real volumes
4721   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
4722   if (0==1) medAl->Print();
4723
4724   // Finally put everything in the mother volume
4725   alphafold = kSideCFoldAngle;
4726
4727   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
4728     alpharot = kTraySideCAlphaRot[jt];
4729     xloc = kTraySideCRPos*SinD(alpharot);
4730     yloc = kTraySideCRPos*CosD(alpharot);
4731     moth->AddNode(trayStructure[jt],1,
4732                        new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
4733                        new TGeoRotation("",-90.+alpharot,-90.,90.+alphafold)));
4734   }
4735
4736
4737   return;
4738 }
4739
4740
4741 //______________________________________________________________________
4742 void AliITSv11GeometrySupport::SSDCableTraysSideA(TGeoVolume *moth,
4743                                                   TGeoManager *mgr){
4744 //
4745 // Creates the SSD cable trays which are outside the ITS support cones
4746 // but still inside the TPC on Side A
4747 // (part of this code is taken or anyway inspired to ServicesCableSupport
4748 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
4749 //
4750 // Input:
4751 //         moth : the TGeoVolume owing the volume structure
4752 //         mgr  : the GeoManager (default gGeoManager)
4753 // Output:
4754 //
4755 // Created:         ???       Bjorn S. Nilsen
4756 // Updated:      30 Dec 2009  Mario Sitta
4757 //
4758 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
4759 // drawings and other (oral) information given by F.Tosello and
4760 // Ton van den Brink
4761 // Cables and cooling tubes are approximated with proper materials and
4762 // rectangular cross sections, always preserving the total material budget.
4763 //
4764
4765   // Dimensions and positions of the A-Side Cable Trays
4766   // (parts of 0872/G/D)
4767   const Double_t kTrayARTrans            =  408.35 *fgkmm;
4768   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
4769   const Double_t kForwardSideYTrans      =   12.00 *fgkmm;//!!!TO BE CHECKED!!!
4770   const Double_t kCoversYTrans           =    2.00 *fgkmm;
4771   const Double_t kTrayAZRot              = (180-169.5);// Degrees
4772   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
4773   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
4774
4775   const Double_t kTrayTotalHeight        =   52.00 *fgkmm;
4776   const Double_t kTrayHeighToBend        =   32.00 *fgkmm;
4777   const Double_t kTrayWidth              =  130.00 *fgkmm;
4778   const Double_t kTrayThick              =    2.00 *fgkmm;
4779
4780   const Double_t kTrayBendAngle          =   22.00 *TMath::DegToRad();
4781
4782   const Double_t kForwardTrayTotalLen    =  853.00 *fgkmm;
4783   const Double_t kForwardTrayFirstLen    =  350.00 *fgkmm;
4784   const Double_t kForwardTrayFirstHeight =   47.00 *fgkmm;
4785   const Double_t kForwardCoverLen        =  420.00 *fgkmm;
4786
4787   const Double_t kForwardSideLength      = kForwardTrayFirstLen;//!!!TO BE CHECKED!!!
4788   const Double_t kForwardSideHeight      =   90.00 *fgkmm;//!!!TO BE CHECKED!!!
4789   const Double_t kForwardSideThick       =    1.00 *fgkmm;//!!!TO BE CHECKED!!!
4790   const Double_t kForwardCoverHeight     =   10.00 *fgkmm;//!!!TO BE CHECKED!!!
4791
4792   const Double_t kExternalTrayTotalLen   = 1200.00 *fgkmm;
4793   const Double_t kExternalCoverLen       = kExternalTrayTotalLen;
4794   const Double_t kExternalCoverThick     =    5.00 *fgkmm;
4795
4796   const Int_t    kForwardTrayNpoints     =   16;
4797
4798   const Double_t kServicesWidth          =  100.00 *fgkmm;
4799   const Double_t kCopperHeight           =   11.20 *fgkmm;// 1120 mm^2
4800   const Double_t kCablePlasticHeight     =   11.50 *fgkmm;// 1150 mm^2
4801   const Double_t kCoolingWaterHeight     =    2.65 *fgkmm;//  265 mm^2
4802   const Double_t kPoliUrethaneHeight     =    4.62 *fgkmm;//  462 mm^2
4803
4804
4805   // Local variables
4806   Double_t xprof[kForwardTrayNpoints], yprof[kForwardTrayNpoints];
4807   Double_t xloc, yloc, zloc, alpharot, totalhi;
4808
4809
4810   // The two tray components as assemblies
4811   TGeoVolumeAssembly *cableTrayAForw =
4812     new TGeoVolumeAssembly("ITSsupportSSDTrayAForw");
4813   TGeoVolumeAssembly *cableTrayAExt =
4814     new TGeoVolumeAssembly("ITSsupportSSDTrayAExt");
4815   
4816
4817   // First create all needed shapes
4818
4819   // The first part of the forward tray (part of 0872/G/D/07): a Xtru
4820   TGeoXtru *forwTrayPart1 = new TGeoXtru(2);
4821
4822   xprof[3] = kTrayWidth/2;
4823   yprof[3] = kForwardTrayFirstHeight;
4824   xprof[2] = xprof[3] - kTrayThick;
4825   yprof[2] = yprof[3];
4826   xprof[4] = xprof[3];
4827   yprof[4] = kTrayTotalHeight - kTrayHeighToBend;
4828   xprof[5] = xprof[4] - yprof[4]*TMath::Tan(kTrayBendAngle);
4829   yprof[5] = 0;
4830
4831   InsidePoint( xprof[3], yprof[3], xprof[4], yprof[4], xprof[5], yprof[5],
4832               -kTrayThick, xprof[1], yprof[1]);
4833
4834   xprof[6] = -xprof[5];
4835   yprof[6] =  yprof[5];
4836
4837   InsidePoint( xprof[4], yprof[4], xprof[5], yprof[5], xprof[6], yprof[6],
4838               -kTrayThick, xprof[0], yprof[0]);
4839
4840   // We did the right side, now reflex on the left side
4841   for (Int_t jp = 0; jp < 6; jp++) {
4842     xprof[6+jp] = -xprof[5-jp];
4843     yprof[6+jp] =  yprof[5-jp];
4844   }
4845
4846   // And now the actual Xtru
4847   forwTrayPart1->DefinePolygon(12, xprof, yprof);
4848   forwTrayPart1->DefineSection(0, 0);
4849   forwTrayPart1->DefineSection(1, kForwardTrayFirstLen);
4850
4851   // The second part of the forward tray (part of 0872/G/D/07): a Xtru
4852   TGeoXtru *forwTrayPart2 =
4853     CreateSDDSSDTraysSideA(kForwardTrayTotalLen - kForwardTrayFirstLen,
4854                            kTrayTotalHeight);
4855
4856   // The external tray (as 0872/G/D/03): a Xtru with same profile
4857   TGeoXtru *externalTray = CreateSDDSSDTraysSideA(kExternalTrayTotalLen,
4858                                                   kTrayTotalHeight);
4859
4860   // The side wall of the forward tray: a BBox
4861   TGeoBBox *forwSide = new TGeoBBox(kForwardSideThick/2,
4862                                     kForwardSideHeight/2,
4863                                     kForwardSideLength/2);
4864
4865   // The side cover over the walls: a Xtru
4866   TGeoXtru *forwSideCover = new TGeoXtru(2);
4867   forwSideCover->SetName("ITSsuppSSDForwCover");
4868
4869   xprof[0] = kTrayWidth/2 + 2*kForwardSideThick;
4870   yprof[0] = kForwardCoverHeight;
4871   xprof[1] = xprof[0];
4872   yprof[1] = 0;
4873   xprof[2] = xprof[1] - kForwardSideThick;
4874   yprof[2] = yprof[1];
4875   xprof[3] = xprof[2];
4876   yprof[3] = yprof[0] - kForwardSideThick;
4877
4878   // We did the right side, now reflex on the left side
4879   for (Int_t jp = 0; jp < 4; jp++) {
4880     xprof[4+jp] = -xprof[3-jp];
4881     yprof[4+jp] =  yprof[3-jp];
4882   }
4883
4884   forwSideCover->DefinePolygon(8, xprof, yprof);
4885   forwSideCover->DefineSection(0, 0);
4886   forwSideCover->DefineSection(1, kForwardSideLength);
4887
4888   // The forward and external covers: two Composite Shape's
4889   TGeoCompositeShape *forwardCover = CreateTrayAForwardCover(kForwardCoverLen);
4890
4891   TGeoCompositeShape *externCover = CreateTrayAExternalCover(kExternalCoverLen);
4892
4893   // The cable copper inside the forward tray: a BBox
4894   TGeoBBox *forwCopper = new TGeoBBox(kServicesWidth/2,
4895                                       kCopperHeight/2,
4896                                       kForwardTrayTotalLen/2);
4897
4898   // The cable copper inside the forward tray: a Xtru
4899   TGeoXtru *extCopper = new TGeoXtru(2);
4900   extCopper->SetName("ITSsuppSSDExtTrayCopper");
4901
4902   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
4903           - kTrayThick;
4904
4905   xprof[0] = -totalhi*TanD(kTrayAZRot);
4906   yprof[0] = kTrayThick;
4907   xprof[1] = kExternalTrayTotalLen;
4908   yprof[1] = yprof[0];
4909   xprof[2] = xprof[1];
4910   yprof[2] = yprof[1] + kCopperHeight;
4911   totalhi -= kCopperHeight;
4912   xprof[3] = -totalhi*TanD(kTrayAZRot);
4913   yprof[3] = yprof[2];
4914
4915   extCopper->DefinePolygon(4, xprof, yprof);
4916   extCopper->DefineSection(0, 0);
4917   extCopper->DefineSection(1, kServicesWidth);
4918
4919   // The cable plastic inside the forward tray: a BBox
4920   TGeoBBox *forwPlastic = new TGeoBBox(kServicesWidth/2,
4921                                        kCablePlasticHeight/2,
4922                                        kForwardTrayTotalLen/2);
4923
4924   // The cable plastic inside the forward tray: a Xtru
4925   TGeoXtru *extPlastic = new TGeoXtru(2);
4926   extPlastic->SetName("ITSsuppSSDExtTrayPlastic");
4927
4928   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
4929           - kTrayThick - kCopperHeight;
4930
4931   xprof[0] = -totalhi*TanD(kTrayAZRot);
4932   yprof[0] = kTrayThick;
4933   xprof[1] = kExternalTrayTotalLen;
4934   yprof[1] = yprof[0];
4935   xprof[2] = xprof[1];
4936   yprof[2] = yprof[1] + kCablePlasticHeight;
4937   totalhi -= kCablePlasticHeight;
4938   xprof[3] = -totalhi*TanD(kTrayAZRot);
4939   yprof[3] = yprof[2];
4940
4941   extPlastic->DefinePolygon(4, xprof, yprof);
4942   extPlastic->DefineSection(0, 0);
4943   extPlastic->DefineSection(1, kServicesWidth);
4944
4945   // The cooling water inside the forward tray: a BBox
4946   TGeoBBox *forwWater = new TGeoBBox(kServicesWidth/2,
4947                                      kCoolingWaterHeight/2,
4948                                      kForwardTrayTotalLen/2);
4949
4950   // The cooling water inside the forward tray: a Xtru
4951   TGeoXtru *extWater = new TGeoXtru(2);
4952   extWater->SetName("ITSsuppSSDExtTrayWater");
4953
4954   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
4955           - kTrayThick - kCopperHeight - kCablePlasticHeight;
4956
4957   xprof[0] = -totalhi*TanD(kTrayAZRot);
4958   yprof[0] = kTrayThick;
4959   xprof[1] = kExternalTrayTotalLen;
4960   yprof[1] = yprof[0];
4961   xprof[2] = xprof[1];
4962   yprof[2] = yprof[1] + kCoolingWaterHeight;
4963   totalhi -= kCoolingWaterHeight;
4964   xprof[3] = -totalhi*TanD(kTrayAZRot);
4965   yprof[3] = yprof[2];
4966
4967   extWater->DefinePolygon(4, xprof, yprof);
4968   extWater->DefineSection(0, 0);
4969   extWater->DefineSection(1, kServicesWidth);
4970
4971   // The polyurethane inside the forward tray: a BBox
4972   TGeoBBox *forwPUR = new TGeoBBox(kServicesWidth/2,
4973                                    kPoliUrethaneHeight/2,
4974                                    kForwardTrayTotalLen/2);
4975
4976   // The poliurethane inside the forward tray: a Xtru
4977   TGeoXtru *extPUR = new TGeoXtru(2);
4978   extPUR->SetName("ITSsuppSSDExtTrayPUR");
4979
4980   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
4981           - kTrayThick - kCopperHeight - kCablePlasticHeight
4982           - kCoolingWaterHeight;
4983
4984   xprof[0] = -totalhi*TanD(kTrayAZRot);
4985   yprof[0] = kTrayThick;
4986   xprof[1] = kExternalTrayTotalLen;
4987   yprof[1] = yprof[0];
4988   xprof[2] = xprof[1];
4989   yprof[2] = yprof[1] + kPoliUrethaneHeight;
4990   totalhi -= kPoliUrethaneHeight;
4991   xprof[3] = -totalhi*TanD(kTrayAZRot);
4992   yprof[3] = yprof[2];
4993
4994   extPUR->DefinePolygon(4, xprof, yprof);
4995   extPUR->DefineSection(0, 0);
4996   extPUR->DefineSection(1, kServicesWidth);
4997
4998
4999   // We have all shapes: now create the real volumes
5000   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
5001   TGeoMedium *medAntic = mgr->GetMedium("ITS_ANTICORODAL$");
5002   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
5003   TGeoMedium *medFEP   = mgr->GetMedium("ITS_SSD FEP$");
5004   TGeoMedium *medH2O   = mgr->GetMedium("ITS_WATER$");
5005   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
5006
5007   TGeoVolume *forwTrayFirst = new TGeoVolume("ITSsuppSSDSideAForwTrayFirst",
5008                                              forwTrayPart1, medAl);
5009
5010   forwTrayFirst->SetVisibility(kTRUE);
5011   forwTrayFirst->SetLineColor(6); // Purple
5012   forwTrayFirst->SetLineWidth(1);
5013   forwTrayFirst->SetFillColor(forwTrayFirst->GetLineColor());
5014   forwTrayFirst->SetFillStyle(4000); // 0% transparent
5015
5016   TGeoVolume *forwTraySecond = new TGeoVolume("ITSsuppSSDSideAForwTraySecond",
5017                                               forwTrayPart2, medAl);
5018
5019   forwTraySecond->SetVisibility(kTRUE);
5020   forwTraySecond->SetLineColor(6); // Purple
5021   forwTraySecond->SetLineWidth(1);
5022   forwTraySecond->SetFillColor(forwTraySecond->GetLineColor());
5023   forwTraySecond->SetFillStyle(4000); // 0% transparent
5024
5025   TGeoVolume *forwTraySide = new TGeoVolume("ITSsuppSSDSideAForwTraySide",
5026                                             forwSide, medAl);
5027
5028   forwTraySide->SetVisibility(kTRUE);
5029   forwTraySide->SetLineColor(6); // Purple
5030   forwTraySide->SetLineWidth(1);
5031   forwTraySide->SetFillColor(forwTraySide->GetLineColor());
5032   forwTraySide->SetFillStyle(4000); // 0% transparent
5033
5034   TGeoVolume *forwTraySideCover = new TGeoVolume("ITSsuppSSDSideAForwTraySideCover",
5035                                             forwSideCover, medAl);
5036
5037   forwTraySideCover->SetVisibility(kTRUE);
5038   forwTraySideCover->SetLineColor(6); // Purple
5039   forwTraySideCover->SetLineWidth(1);
5040   forwTraySideCover->SetFillColor(forwTraySideCover->GetLineColor());
5041   forwTraySideCover->SetFillStyle(4000); // 0% transparent
5042
5043   TGeoVolume *externalTraySSD = new TGeoVolume("ITSsuppSSDSideAExternalTray",
5044                                                externalTray, medAl);
5045
5046   externalTraySSD->SetVisibility(kTRUE);
5047   externalTraySSD->SetLineColor(6); // Purple
5048   externalTraySSD->SetLineWidth(1);
5049   externalTraySSD->SetFillColor(externalTraySSD->GetLineColor());
5050   externalTraySSD->SetFillStyle(4000); // 0% transparent
5051
5052   TGeoVolume *forwardTrayCover = new TGeoVolume("ITSsuppSSDSideAForwTrayCover",
5053                                                 forwardCover, medAntic);
5054
5055   forwardTrayCover->SetVisibility(kTRUE);
5056   forwardTrayCover->SetLineColor(kMagenta+1); // Purple
5057   forwardTrayCover->SetLineWidth(1);
5058   forwardTrayCover->SetFillColor(forwardTrayCover->GetLineColor());
5059   forwardTrayCover->SetFillStyle(4000); // 0% transparent
5060
5061   TGeoVolume *externTrayCover = new TGeoVolume("ITSsuppSSDSideAExtTrayCover",
5062                                                externCover, medAntic);
5063
5064   externTrayCover->SetVisibility(kTRUE);
5065   externTrayCover->SetLineColor(kMagenta+1); // Purple
5066   externTrayCover->SetLineWidth(1);
5067   externTrayCover->SetFillColor(externTrayCover->GetLineColor());
5068   externTrayCover->SetFillStyle(4000); // 0% transparent
5069
5070   TGeoVolume *forwCableCu = new TGeoVolume("ITSsuppSSDSideAForwCableCu",
5071                                            forwCopper, medCu);
5072
5073   forwCableCu->SetVisibility(kTRUE);
5074   forwCableCu->SetLineColor(kRed); // Red
5075   forwCableCu->SetLineWidth(1);
5076   forwCableCu->SetFillColor(forwCableCu->GetLineColor());
5077   forwCableCu->SetFillStyle(4000); // 0% transparent
5078
5079   TGeoVolume *extCableCu = new TGeoVolume("ITSsuppSSDSideAExtCableCu",
5080                                           extCopper, medCu);
5081
5082   extCableCu->SetVisibility(kTRUE);
5083   extCableCu->SetLineColor(kRed); // Red
5084   extCableCu->SetLineWidth(1);
5085   extCableCu->SetFillColor(extCableCu->GetLineColor());
5086   extCableCu->SetFillStyle(4000); // 0% transparent
5087
5088   TGeoVolume *forwCableFEP = new TGeoVolume("ITSsuppSSDSideAForwCableFEP",
5089                                             forwPlastic, medFEP);
5090
5091   forwCableFEP->SetVisibility(kTRUE);
5092   forwCableFEP->SetLineColor(kYellow); // Yellow
5093   forwCableFEP->SetLineWidth(1);
5094   forwCableFEP->SetFillColor(forwCableFEP->GetLineColor());
5095   forwCableFEP->SetFillStyle(4000); // 0% transparent
5096
5097   TGeoVolume *extCableFEP = new TGeoVolume("ITSsuppSSDSideAExtCableFEP",
5098                                            extPlastic, medFEP);
5099
5100   extCableFEP->SetVisibility(kTRUE);
5101   extCableFEP->SetLineColor(kYellow); // Yellow
5102   extCableFEP->SetLineWidth(1);
5103   extCableFEP->SetFillColor(extCableFEP->GetLineColor());
5104   extCableFEP->SetFillStyle(4000); // 0% transparent
5105
5106   TGeoVolume *forwTrayWater = new TGeoVolume("ITSsuppSSDSideAForwTrayWater",
5107                                              forwWater, medH2O);
5108
5109   forwTrayWater->SetVisibility(kTRUE);
5110   forwTrayWater->SetLineColor(kBlue); // Blue
5111   forwTrayWater->SetLineWidth(1);
5112   forwTrayWater->SetFillColor(forwTrayWater->GetLineColor());
5113   forwTrayWater->SetFillStyle(4000); // 0% transparent
5114
5115   TGeoVolume *extTrayWater = new TGeoVolume("ITSsuppSSDSideAExtTrayWater",
5116                                             extWater, medH2O);
5117
5118   extTrayWater->SetVisibility(kTRUE);
5119   extTrayWater->SetLineColor(kBlue); // Blue
5120   extTrayWater->SetLineWidth(1);
5121   extTrayWater->SetFillColor(extTrayWater->GetLineColor());
5122   extTrayWater->SetFillStyle(4000); // 0% transparent
5123
5124   TGeoVolume *forwPolyUr = new TGeoVolume("ITSsuppSSDSideAForwPolyUr",
5125                                           forwPUR, medPUR);
5126
5127   forwPolyUr->SetVisibility(kTRUE);
5128   forwPolyUr->SetLineColor(kGray); // Gray
5129   forwPolyUr->SetLineWidth(1);
5130   forwPolyUr->SetFillColor(forwPolyUr->GetLineColor());
5131   forwPolyUr->SetFillStyle(4000); // 0% transparent
5132
5133   TGeoVolume *extPolyUr = new TGeoVolume("ITSsuppSSDSideAExtPolyUr",
5134                                          extPUR, medPUR);
5135
5136   extPolyUr->SetVisibility(kTRUE);
5137   extPolyUr->SetLineColor(kGray); // Gray
5138   extPolyUr->SetLineWidth(1);
5139   extPolyUr->SetFillColor(extPolyUr->GetLineColor());
5140   extPolyUr->SetFillStyle(4000); // 0% transparent
5141
5142
5143   // Now build up the tray
5144   cableTrayAForw->AddNode(forwTrayFirst, 1, 0);
5145
5146   cableTrayAForw->AddNode(forwTraySecond, 1,
5147                         new TGeoTranslation(0, 0, kForwardTrayFirstLen) );
5148
5149   xloc = kTrayWidth/2 + kForwardSideThick/2;
5150   yloc = kForwardTrayFirstHeight + kForwardSideHeight/2 - kForwardSideYTrans;
5151   zloc = kForwardSideLength/2;
5152   cableTrayAForw->AddNode(forwTraySide,1,
5153                         new TGeoTranslation( xloc, yloc, zloc) );
5154   cableTrayAForw->AddNode(forwTraySide,2,
5155                         new TGeoTranslation(-xloc, yloc, zloc) );
5156
5157   yloc = kForwardTrayFirstHeight + kForwardSideHeight - kForwardSideYTrans
5158        - kForwardCoverHeight;
5159   cableTrayAForw->AddNode(forwTraySideCover,1,
5160                         new TGeoTranslation(0, yloc, 0) );
5161
5162   yloc = kTrayTotalHeight - kCoversYTrans;
5163   zloc = kForwardTrayTotalLen - kForwardCoverLen;
5164   cableTrayAForw->AddNode(forwardTrayCover,1,
5165                         new TGeoTranslation(0, yloc, zloc) );
5166
5167   yloc = kTrayThick + forwCopper->GetDY();
5168   zloc = forwCopper->GetDZ();
5169   cableTrayAForw->AddNode(forwCableCu, 1,
5170                         new TGeoTranslation(0, yloc, zloc) );
5171
5172   yloc = kTrayThick + kCopperHeight + forwPlastic->GetDY();
5173   zloc = forwPlastic->GetDZ();
5174   cableTrayAForw->AddNode(forwCableFEP, 1,
5175                         new TGeoTranslation(0, yloc, zloc) );
5176
5177   yloc = kTrayThick + kCopperHeight + kCablePlasticHeight + forwWater->GetDY();
5178   zloc = forwWater->GetDZ();
5179   cableTrayAForw->AddNode(forwTrayWater, 1,
5180                         new TGeoTranslation(0, yloc, zloc) );
5181
5182   yloc = kTrayThick + kCopperHeight + kCablePlasticHeight
5183        + kCoolingWaterHeight + forwPUR->GetDY();
5184   zloc = forwPUR->GetDZ();
5185   cableTrayAForw->AddNode(forwPolyUr, 1,
5186                         new TGeoTranslation(0, yloc, zloc) );
5187
5188   // To simplify following placement in MARS, origin is on top
5189   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans;
5190
5191   yloc = -totalhi;
5192   cableTrayAExt->AddNode(externalTraySSD, 1,
5193                         new TGeoTranslation(0, yloc, 0) );
5194
5195   yloc = -totalhi + kTrayTotalHeight - kCoversYTrans;
5196   cableTrayAExt->AddNode(externTrayCover,1,
5197                         new TGeoTranslation(0, yloc, 0) );
5198
5199   xloc = extCopper->GetDZ();
5200   yloc = -totalhi;
5201   cableTrayAExt->AddNode(extCableCu,1,
5202                         new TGeoCombiTrans( xloc, yloc, 0,
5203                         new TGeoRotation("",-90, 90, 90)        ) );
5204
5205   xloc = extPlastic->GetDZ();
5206   yloc = -totalhi + kCopperHeight;
5207   cableTrayAExt->AddNode(extCableFEP,1,
5208                         new TGeoCombiTrans( xloc, yloc, 0,
5209                         new TGeoRotation("",-90, 90, 90)        ) );
5210
5211   xloc = extWater->GetDZ();
5212   yloc = -totalhi + kCopperHeight + kCablePlasticHeight;
5213   cableTrayAExt->AddNode(extTrayWater,1,
5214                         new TGeoCombiTrans( xloc, yloc, 0,
5215                         new TGeoRotation("",-90, 90, 90)        ) );
5216
5217   xloc = extPUR->GetDZ();
5218   yloc = -totalhi + kCopperHeight + kCablePlasticHeight + kCoolingWaterHeight;
5219   cableTrayAExt->AddNode(extPolyUr,1,
5220                         new TGeoCombiTrans( xloc, yloc, 0,
5221                         new TGeoRotation("",-90, 90, 90)        ) );
5222
5223
5224   // Finally put everything in the mother volume
5225   zloc = kTrayAZTrans;
5226   Double_t zlocext = zloc + kForwardTrayTotalLen;
5227   Double_t rExtTray = kTrayARTrans + kTrayTotalHeight;
5228
5229   alpharot = kTrayAFirstRotAng;
5230   xloc = kTrayARTrans*SinD(alpharot);
5231   yloc = kTrayARTrans*CosD(alpharot);
5232   moth->AddNode(cableTrayAForw,1,
5233                             new TGeoCombiTrans( xloc, yloc, zloc,
5234                             new TGeoRotation("",-alpharot,0,0)   )   );
5235   xloc = rExtTray*SinD(alpharot);
5236   yloc = rExtTray*CosD(alpharot);
5237   moth->AddNode(cableTrayAExt,1,
5238                             new TGeoCombiTrans( xloc, yloc, zlocext,
5239                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
5240
5241   alpharot += 180;
5242   xloc = kTrayARTrans*SinD(alpharot);
5243   yloc = kTrayARTrans*CosD(alpharot);
5244   moth->AddNode(cableTrayAForw,2,
5245                             new TGeoCombiTrans( xloc, yloc, zloc,
5246                             new TGeoRotation("",-alpharot,0,0)   )   );
5247   xloc = rExtTray*SinD(alpharot);
5248   yloc = rExtTray*CosD(alpharot);
5249   moth->AddNode(cableTrayAExt,2,
5250                             new TGeoCombiTrans( xloc, yloc, zlocext,
5251                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
5252
5253   alpharot = -kTrayAFirstRotAng - 2*kTrayASecondRotAng;
5254   xloc = kTrayARTrans*SinD(alpharot);
5255   yloc = kTrayARTrans*CosD(alpharot);
5256   moth->AddNode(cableTrayAForw,3,
5257                             new TGeoCombiTrans( xloc, yloc, zloc,
5258                             new TGeoRotation("",-alpharot,0,0)   )   );
5259   xloc = rExtTray*SinD(alpharot);
5260   yloc = rExtTray*CosD(alpharot);
5261   moth->AddNode(cableTrayAExt,3,
5262                             new TGeoCombiTrans( xloc, yloc, zlocext,
5263                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
5264
5265   alpharot += 180;
5266   xloc = kTrayARTrans*SinD(alpharot);
5267   yloc = kTrayARTrans*CosD(alpharot);
5268   moth->AddNode(cableTrayAForw,4,
5269                             new TGeoCombiTrans( xloc, yloc, zloc,
5270                             new TGeoRotation("",-alpharot,0,0)   )   );
5271   xloc = rExtTray*SinD(alpharot);
5272   yloc = rExtTray*CosD(alpharot);
5273   moth->AddNode(cableTrayAExt,4,
5274                             new TGeoCombiTrans( xloc, yloc, zlocext,
5275                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
5276
5277
5278   return;
5279 }
5280
5281 //______________________________________________________________________
5282 void AliITSv11GeometrySupport::SSDCableTraysSideC(TGeoVolume *moth,
5283                                                   TGeoManager *mgr){
5284 //
5285 // Creates the SSD cable trays which are outside the ITS support cones
5286 // but still inside the TPC on Side C
5287 // (part of this code is taken or anyway inspired to ServicesCableSupport
5288 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
5289 //
5290 // Input:
5291 //         moth : the TGeoVolume owing the volume structure
5292 //         mgr  : the GeoManager (default gGeoManager)
5293 // Output:
5294 //
5295 // Created:         ???       Bjorn S. Nilsen
5296 // Updated:      15 Apr 2010  Mario Sitta
5297 //
5298 // Technical data are taken from AutoCAD drawings and other (oral)
5299 // information given by F.Tosello
5300 //
5301
5302   // Dimensions and positions of the C-Side Cable Tray elements
5303   const Int_t    kNumTraySideC           =    4;
5304
5305   const Double_t kSideCFoldAngle         =    5.00 *fgkDegree;
5306
5307   const Double_t kServicesWidth          =  100.00 *fgkmm;
5308   const Double_t kCopperHeight           =   11.20 *fgkmm;// 1120 mm^2
5309   const Double_t kCablePlasticHeight     =   11.50 *fgkmm;// 1150 mm^2
5310   const Double_t kCoolingWaterHeight     =    2.65 *fgkmm;//  265 mm^2
5311   const Double_t kPoliUrethaneHeight     =    4.62 *fgkmm;//  462 mm^2
5312
5313   // Overall position and rotation of the C-Side Cable Trays
5314   const Double_t kTraySideCRPos          =   45.30    *fgkcm;
5315   const Double_t kTraySideCZPos          = -102.40    *fgkcm;
5316   const Double_t kTraySideCAlphaRot[kNumTraySideC]  = {     23.0,     -59.0,
5317     /* from Patch panel position */                    180.+23.0, 180.-59.0};
5318
5319
5320   // Local variables
5321   Double_t xprof[6], yprof[6];
5322   Double_t xloc, yloc, alpharot, alphafold;
5323
5324
5325   // The assembly holding the metallic structure
5326   TGeoVolumeAssembly *trayStructure =
5327                                 CreateSDDSSDTraysSideC("ITSsupportSSDTrayC");
5328
5329   // The cable copper inside the tray: a Xtru
5330   TGeoXtru *copper = new TGeoXtru(2);
5331   copper->SetName("ITSsuppSSDTrayCCopper");
5332
5333   // Copper lies on the lower plate: get position of its points
5334   TGeoXtru *lowerplate = (TGeoXtru*)(mgr->GetVolume("ITSsuppTraySideCLower")->GetShape());
5335   xprof[0] = lowerplate->GetX(5);
5336   yprof[0] = lowerplate->GetY(5);
5337   xprof[1] = lowerplate->GetX(4);
5338   yprof[1] = lowerplate->GetY(4);
5339   xprof[2] = lowerplate->GetX(3);
5340   yprof[2] = lowerplate->GetY(3);
5341   xprof[3] = xprof[2] - kCopperHeight*SinD(kSideCFoldAngle);
5342   yprof[3] = yprof[2] + kCopperHeight*CosD(kSideCFoldAngle);
5343   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5344               kCopperHeight , xprof[4], yprof[4]);
5345   xprof[5] = xprof[0];
5346   yprof[5] = yprof[0] + kCopperHeight;
5347
5348   copper->DefinePolygon(6, xprof, yprof);
5349   copper->DefineSection(0, -kServicesWidth/2);
5350   copper->DefineSection(1,  kServicesWidth/2);
5351
5352   // The cable plastic inside the tray: a Xtru
5353   TGeoXtru *plastic = new TGeoXtru(2);
5354   plastic->SetName("ITSsuppSSDTrayCPlastic");
5355
5356   xprof[0] = copper->GetX(5);
5357   yprof[0] = copper->GetY(5);
5358   xprof[1] = copper->GetX(4);
5359   yprof[1] = copper->GetY(4);
5360   xprof[2] = copper->GetX(3);
5361   yprof[2] = copper->GetY(3);
5362   xprof[3] = xprof[2] - kCablePlasticHeight*SinD(kSideCFoldAngle);
5363   yprof[3] = yprof[2] + kCablePlasticHeight*CosD(kSideCFoldAngle);
5364   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5365               kCablePlasticHeight , xprof[4], yprof[4]);
5366   xprof[5] = xprof[0];
5367   yprof[5] = yprof[0] + kCablePlasticHeight;
5368
5369   plastic->DefinePolygon(6, xprof, yprof);
5370   plastic->DefineSection(0, -kServicesWidth/2);
5371   plastic->DefineSection(1,  kServicesWidth/2);
5372
5373   // The cooling water inside the tray: a Xtru
5374   TGeoXtru *water = new TGeoXtru(2);
5375   water->SetName("ITSsuppSSDTrayCWater");
5376
5377   xprof[0] = plastic->GetX(5);
5378   yprof[0] = plastic->GetY(5);
5379   xprof[1] = plastic->GetX(4);
5380   yprof[1] = plastic->GetY(4);
5381   xprof[2] = plastic->GetX(3);
5382   yprof[2] = plastic->GetY(3);
5383   xprof[3] = xprof[2] - kCoolingWaterHeight*SinD(kSideCFoldAngle);
5384   yprof[3] = yprof[2] + kCoolingWaterHeight*CosD(kSideCFoldAngle);
5385   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5386               kCoolingWaterHeight , xprof[4], yprof[4]);
5387   xprof[5] = xprof[0];
5388   yprof[5] = yprof[0] + kCoolingWaterHeight;
5389
5390   water->DefinePolygon(6, xprof, yprof);
5391   water->DefineSection(0, -kServicesWidth/2);
5392   water->DefineSection(1,  kServicesWidth/2);
5393
5394   // The poliurethane inside the tray: a Xtru
5395   TGeoXtru *PUR = new TGeoXtru(2);
5396   PUR->SetName("ITSsuppSSDTrayCPUR");
5397
5398   xprof[0] = water->GetX(5);
5399   yprof[0] = water->GetY(5);
5400   xprof[1] = water->GetX(4);
5401   yprof[1] = water->GetY(4);
5402   xprof[2] = water->GetX(3);
5403   yprof[2] = water->GetY(3);
5404   xprof[3] = xprof[2] - kPoliUrethaneHeight*SinD(kSideCFoldAngle);
5405   yprof[3] = yprof[2] + kPoliUrethaneHeight*CosD(kSideCFoldAngle);
5406   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5407               kPoliUrethaneHeight , xprof[4], yprof[4]);
5408   xprof[5] = xprof[0];
5409   yprof[5] = yprof[0] + kPoliUrethaneHeight;
5410
5411   PUR->DefinePolygon(6, xprof, yprof);
5412   PUR->DefineSection(0, -kServicesWidth/2);
5413   PUR->DefineSection(1,  kServicesWidth/2);
5414
5415
5416   // We have all shapes: now create the real volumes
5417   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
5418   TGeoMedium *medFEP   = mgr->GetMedium("ITS_SSD FEP$");
5419   TGeoMedium *medH2O   = mgr->GetMedium("ITS_WATER$");
5420   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
5421
5422   TGeoVolume *copperCable = new TGeoVolume("ITSsuppSSDSideCCableCu",
5423                                            copper, medCu);
5424
5425   copperCable->SetVisibility(kTRUE);
5426   copperCable->SetLineColor(kRed); // Red
5427   copperCable->SetLineWidth(1);
5428   copperCable->SetFillColor(copperCable->GetLineColor());
5429   copperCable->SetFillStyle(4000); // 0% transparent
5430
5431   TGeoVolume *cableFEP = new TGeoVolume("ITSsuppSSDSideCCableFEP",
5432                                         plastic, medFEP);
5433
5434   cableFEP->SetVisibility(kTRUE);
5435   cableFEP->SetLineColor(kYellow); // Yellow
5436   cableFEP->SetLineWidth(1);
5437   cableFEP->SetFillColor(cableFEP->GetLineColor());
5438   cableFEP->SetFillStyle(4000); // 0% transparent
5439
5440   TGeoVolume *trayWater = new TGeoVolume("ITSsuppSSDSideCTrayWater",
5441                                          water, medH2O);
5442
5443   trayWater->SetVisibility(kTRUE);
5444   trayWater->SetLineColor(kBlue); // Blue
5445   trayWater->SetLineWidth(1);
5446   trayWater->SetFillColor(trayWater->GetLineColor());
5447   trayWater->SetFillStyle(4000); // 0% transparent
5448
5449   TGeoVolume *trayPolyUr = new TGeoVolume("ITSsuppSSDSideCPolyUr",
5450                                           PUR, medPUR);
5451
5452   trayPolyUr->SetVisibility(kTRUE);
5453   trayPolyUr->SetLineColor(kGray); // Gray
5454   trayPolyUr->SetLineWidth(1);
5455   trayPolyUr->SetFillColor(trayPolyUr->GetLineColor());
5456   trayPolyUr->SetFillStyle(4000); // 0% transparent
5457
5458
5459   // Now fill in the tray
5460   trayStructure->AddNode(copperCable,1,0);
5461   trayStructure->AddNode(cableFEP,1,0);
5462   trayStructure->AddNode(trayWater,1,0);
5463   trayStructure->AddNode(trayPolyUr,1,0);
5464
5465
5466   // Finally put everything in the mother volume
5467   alphafold = kSideCFoldAngle;
5468
5469   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
5470     alpharot = kTraySideCAlphaRot[jt];
5471     xloc = kTraySideCRPos*SinD(alpharot);
5472     yloc = kTraySideCRPos*CosD(alpharot);
5473     moth->AddNode(trayStructure,jt+1,
5474                        new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
5475                        new TGeoRotation("",-90.+alpharot,-90.,90.+alphafold)));
5476   }
5477
5478
5479   return;
5480 }
5481
5482 //______________________________________________________________________
5483 TGeoVolumeAssembly* AliITSv11GeometrySupport::CreateSDDForwardTraySideA(TGeoManager *mgr){
5484 //
5485 // Creates the forward SDD tray on Side A (0872/G/D/01)
5486 //
5487 // Input:
5488 //         mgr  : the GeoManager (used only to get the proper material)
5489 //
5490 // Output:
5491 //
5492 // Return:     a TGeoVolumeAssembly for the tray
5493 //
5494 // Created:      08 Jan 2010  Mario Sitta
5495 //
5496 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
5497 // drawings and other (oral) information given by F.Tosello
5498 //
5499
5500   // Dimensions of the A-Side Forward Cable Tray (0872/G/D/01)
5501   const Double_t kForwardTrayThick        =    2.00 *fgkmm;
5502   const Double_t kForwardTraySideLength   =  823.00 *fgkmm;
5503   const Double_t kForwardTrayTailLength   =  212.00 *fgkmm;
5504   const Double_t kForwardTrayBaseHalfWide =   55.00 *fgkmm;
5505   const Double_t kForwardTrayNotchLength  =   47.20 *fgkmm;
5506   const Double_t kForwardTrayNotchHeight  =   25.00 *fgkmm;
5507   const Double_t kForwardTrayNotchDown    =   10.00 *fgkmm;
5508   const Double_t kForwardTraySide1Height  =   39.00 *fgkmm;
5509   const Double_t kForwardTraySide2Height  =   26.00 *fgkmm;
5510   const Double_t kForwardTraySide2Expand  =   10.50 *fgkmm;
5511   const Double_t kForwardTraySide3TailLen =  418.00 *fgkmm;
5512   const Double_t kForwardTraySide3TailHi  =   31.00 *fgkmm;
5513   const Double_t kForwardTraySide3HeadLen =  425.00 *fgkmm;
5514   const Double_t kForwardTraySide3HeadHi  =   72.00 *fgkmm;
5515   const Double_t kForwardTrayHorWingWide  =   10.50 *fgkmm;
5516   const Double_t kForwardTrayVertWingWide =   15.00 *fgkmm;
5517
5518   const Int_t    kForwardTraySideNpoints  =    9;
5519
5520
5521   // Local variables
5522   Double_t xprof[kForwardTraySideNpoints], yprof[kForwardTraySideNpoints];
5523   Double_t ylen, zlen;
5524   Double_t xloc, yloc, zloc;
5525
5526
5527   // The tray has a very complex shape, so it is made by assembling
5528   // different elements (with some small simplifications): the result
5529   // is a TGeoAssembly returned to the caller
5530   TGeoVolumeAssembly *forwardTray = new TGeoVolumeAssembly("ITSsuppSDDForwardTray");
5531
5532   // The tray base: a BBox
5533   zlen = (kForwardTraySideLength-kForwardTrayTailLength)/2;
5534   TGeoBBox *trayBase = new TGeoBBox(kForwardTrayBaseHalfWide,
5535                                     kForwardTrayThick/2, zlen);
5536
5537   // The first part of the side wall: a Xtru
5538   TGeoXtru *traySide1 = new TGeoXtru(2);
5539
5540   xprof[0] = 0;
5541   yprof[0] = kForwardTrayThick;
5542   xprof[1] = kForwardTraySideLength-kForwardTrayTailLength;
5543   yprof[1] = yprof[0];
5544   xprof[2] = kForwardTraySideLength;
5545   yprof[2] = kForwardTraySide1Height + kForwardTrayThick;
5546   xprof[3] = 0;
5547   yprof[3] = yprof[2];
5548
5549   traySide1->DefinePolygon(4, xprof, yprof);
5550   traySide1->DefineSection(0, 0);
5551   traySide1->DefineSection(1, kForwardTrayThick);
5552
5553   // The second part of the side wall: a Xtru
5554   TGeoXtru *traySide2 = new TGeoXtru(2);
5555
5556   xprof[0] = kForwardTrayBaseHalfWide - kForwardTrayThick;
5557   yprof[0] = traySide1->GetY(2);
5558   xprof[1] = kForwardTrayBaseHalfWide;
5559   yprof[1] = yprof[0];
5560   xprof[2] = xprof[1] + kForwardTraySide2Expand;
5561   yprof[2] = yprof[1] + kForwardTraySide2Height;
5562   xprof[3] = xprof[2] - kForwardTrayThick;
5563   yprof[3] = yprof[2];
5564
5565   traySide2->DefinePolygon(4, xprof, yprof);
5566   traySide2->DefineSection(0, 0);
5567   traySide2->DefineSection(1, kForwardTraySideLength);
5568
5569   // The third part of the side wall: a Xtru
5570   TGeoXtru *traySide3 = new TGeoXtru(2);
5571
5572   xprof[0] = 0;
5573   yprof[0] = traySide2->GetY(2);
5574   xprof[1] = kForwardTraySideLength;
5575   yprof[1] = yprof[0];
5576   xprof[2] = xprof[1];
5577   yprof[2] = yprof[1] + kForwardTraySide3TailHi - kForwardTrayThick;
5578   xprof[3] = xprof[2] - kForwardTraySide3TailLen - kForwardTrayThick;
5579   yprof[3] = yprof[2];
5580   xprof[4] = xprof[3];
5581   yprof[4] = yprof[3] + kForwardTraySide3HeadHi + kForwardTrayThick;
5582   xprof[5] = xprof[4] - kForwardTraySide3HeadLen;
5583   yprof[5] = yprof[4];
5584   xprof[6] = xprof[5];
5585   yprof[6] = yprof[5] - kForwardTrayNotchHeight;
5586   xprof[7] = xprof[6] + kForwardTrayNotchLength;
5587   yprof[7] = yprof[6];
5588   xprof[8] = xprof[7];
5589   yprof[8] = yprof[7] - kForwardTrayNotchDown;
5590
5591   traySide3->DefinePolygon(9, xprof, yprof);
5592   traySide3->DefineSection(0, 0);
5593   traySide3->DefineSection(1, kForwardTrayThick);
5594
5595   // The horizontal wing: a BBox
5596   TGeoBBox *trayHorWing = new TGeoBBox(kForwardTrayHorWingWide/2,
5597                                        kForwardTrayThick/2,
5598                                        kForwardTraySide3TailLen/2);
5599
5600   // The vertical wing: a BBox
5601   ylen = (traySide3->GetY(4) - traySide3->GetY(3))/2;
5602   TGeoBBox *trayVertWing = new TGeoBBox(kForwardTrayVertWingWide/2,
5603                                         ylen, kForwardTrayThick/2);
5604
5605
5606   // We have all shapes: now create the real volumes
5607   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
5608
5609   TGeoVolume *forwTrayBase = new TGeoVolume("ITSsuppSDDSideAForwTrayBase",
5610                                             trayBase, medAl);
5611
5612   forwTrayBase->SetVisibility(kTRUE);
5613   forwTrayBase->SetLineColor(6); // Purple
5614   forwTrayBase->SetLineWidth(1);
5615   forwTrayBase->SetFillColor(forwTrayBase->GetLineColor());
5616   forwTrayBase->SetFillStyle(4000); // 0% transparent
5617
5618   TGeoVolume *forwTraySide1 = new TGeoVolume("ITSsuppSDDSideAForwTraySide1",
5619                                             traySide1, medAl);
5620
5621   forwTraySide1->SetVisibility(kTRUE);
5622   forwTraySide1->SetLineColor(6); // Purple
5623   forwTraySide1->SetLineWidth(1);
5624   forwTraySide1->SetFillColor(forwTraySide1->GetLineColor());
5625   forwTraySide1->SetFillStyle(4000); // 0% transparent
5626
5627   TGeoVolume *forwTraySide2 = new TGeoVolume("ITSsuppSDDSideAForwTraySide2",
5628                                             traySide2, medAl);
5629
5630   forwTraySide2->SetVisibility(kTRUE);
5631   forwTraySide2->SetLineColor(6); // Purple
5632   forwTraySide2->SetLineWidth(1);
5633   forwTraySide2->SetFillColor(forwTraySide2->GetLineColor());
5634   forwTraySide2->SetFillStyle(4000); // 0% transparent
5635
5636   TGeoVolume *forwTraySide3 = new TGeoVolume("ITSsuppSDDSideAForwTraySide3",
5637                                             traySide3, medAl);
5638
5639   forwTraySide3->SetVisibility(kTRUE);
5640   forwTraySide3->SetLineColor(6); // Purple
5641   forwTraySide3->SetLineWidth(1);
5642   forwTraySide3->SetFillColor(forwTraySide3->GetLineColor());
5643   forwTraySide3->SetFillStyle(4000); // 0% transparent
5644
5645   TGeoVolume *forwTrayHWing = new TGeoVolume("ITSsuppSDDSideAForwTrayHorWing",
5646                                             trayHorWing, medAl);
5647
5648   forwTrayHWing->SetVisibility(kTRUE);
5649   forwTrayHWing->SetLineColor(6); // Purple
5650   forwTrayHWing->SetLineWidth(1);
5651   forwTrayHWing->SetFillColor(forwTrayHWing->GetLineColor());
5652   forwTrayHWing->SetFillStyle(4000); // 0% transparent
5653
5654   TGeoVolume *forwTrayVWing = new TGeoVolume("ITSsuppSDDSideAForwTrayVertWing",
5655                                             trayVertWing, medAl);
5656
5657   forwTrayVWing->SetVisibility(kTRUE);
5658   forwTrayVWing->SetLineColor(6); // Purple
5659   forwTrayVWing->SetLineWidth(1);
5660   forwTrayVWing->SetFillColor(forwTrayVWing->GetLineColor());
5661   forwTrayVWing->SetFillStyle(4000); // 0% transparent
5662
5663
5664   // Now build up the tray
5665   yloc = kForwardTrayThick/2;
5666   zloc = zlen;
5667   forwardTray->AddNode(forwTrayBase, 1,
5668                        new TGeoTranslation(0, yloc, zloc) );
5669
5670   xloc = kForwardTrayBaseHalfWide;
5671   forwardTray->AddNode(forwTraySide1, 1,
5672                        new TGeoCombiTrans(xloc, 0, 0,
5673                                    new TGeoRotation("",90,-90,-90)));
5674   xloc = -xloc + kForwardTrayThick;
5675   forwardTray->AddNode(forwTraySide1, 2,
5676                        new TGeoCombiTrans(xloc, 0, 0,
5677                                    new TGeoRotation("",90,-90,-90)));
5678
5679   forwardTray->AddNode(forwTraySide2, 1, 0);
5680   zloc = kForwardTraySideLength;
5681   forwardTray->AddNode(forwTraySide2, 2,
5682                        new TGeoCombiTrans(0, 0, zloc,
5683                                    new TGeoRotation("",90,-180,-90)));
5684
5685   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand;
5686   forwardTray->AddNode(forwTraySide3, 1,
5687                        new TGeoCombiTrans(xloc, 0, 0,
5688                                    new TGeoRotation("",90,-90,-90)));
5689   xloc = -xloc + kForwardTrayThick;
5690   forwardTray->AddNode(forwTraySide3, 2,
5691                        new TGeoCombiTrans(xloc, 0, 0,
5692                                    new TGeoRotation("",90,-90,-90)));
5693
5694   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand
5695        - kForwardTrayHorWingWide/2;
5696   yloc = traySide3->GetY(2) + kForwardTrayThick/2;
5697   zloc = kForwardTraySideLength - trayHorWing->GetDZ();
5698   forwardTray->AddNode(forwTrayHWing, 1,
5699                        new TGeoTranslation( xloc, yloc, zloc) );
5700   forwardTray->AddNode(forwTrayHWing, 2,
5701                        new TGeoTranslation(-xloc, yloc, zloc) );
5702
5703   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand
5704        - kForwardTrayVertWingWide/2;
5705   yloc = traySide3->GetY(2) + trayVertWing->GetDY();
5706   zloc = traySide3->GetX(3) + kForwardTrayThick/2;
5707   forwardTray->AddNode(forwTrayVWing, 1,
5708                        new TGeoTranslation( xloc, yloc, zloc) );
5709   forwardTray->AddNode(forwTrayVWing, 2,
5710                        new TGeoTranslation(-xloc, yloc, zloc) );
5711
5712
5713   return forwardTray;
5714 }
5715
5716 //______________________________________________________________________
5717 TGeoCompositeShape* AliITSv11GeometrySupport::CreateTrayAForwardCover(const Double_t coverLen){
5718 //
5719 // Creates the forward cover of the SDD and SSD cable trays on Side A
5720 // (0872/G/D/02)
5721 //
5722 // Input:
5723 //             coverLen: the total length of the cover
5724 //
5725 // Output:
5726 //
5727 // Return:     a TGeoCompositeShape for the cover
5728 //
5729 // Created:      03 Jan 2010  Mario Sitta
5730 //
5731 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
5732 // drawings and other (oral) information given by F.Tosello
5733 //
5734
5735   // Dimensions and positions of the A-Side Cable Tray Forward Cover
5736   // (0872/G/D/02)
5737   const Double_t kForwardCoverWide        =  130.00 *fgkmm;
5738   const Double_t kForwardCoverSideWide    =   10.00 *fgkmm;
5739   const Double_t kForwardCoverHoleLen     =  160.00 *fgkmm;
5740   const Double_t kForwardCoverHoleWide    =   90.00 *fgkmm;
5741   const Double_t kForwardCoverHoleR10     =   10.00 *fgkmm;
5742   const Double_t kForwardCoverTotalThick  =    5.00 *fgkmm;
5743   const Double_t kForwardCoverSideThick   =    3.00 *fgkmm;
5744   const Double_t kForwardCoverInternThick =    2.00 *fgkmm;
5745
5746   const Double_t kForwardCoverHoleZTrans  =   40.00 *fgkmm;
5747
5748
5749   // Local variables
5750   Double_t xprof[16], yprof[16];
5751   Double_t yloc, zloc;
5752
5753
5754   // The main shape: a Xtru
5755   TGeoXtru *forwCoverMain = new TGeoXtru(2);
5756   forwCoverMain->SetName("ITSsuppForwCoverMain");
5757
5758   xprof[0] = kForwardCoverWide/2;
5759   yprof[0] = kForwardCoverTotalThick;
5760   xprof[1] = xprof[0];
5761   yprof[1] = yprof[0] - kForwardCoverSideThick;
5762   xprof[2] = xprof[1] - kForwardCoverSideWide;
5763   yprof[2] = yprof[1];
5764   xprof[3] = xprof[2];
5765   yprof[3] = 0;
5766
5767   // We did the right side, now reflex on the left side
5768   for (Int_t jp = 0; jp < 4; jp++) {
5769     xprof[4+jp] = -xprof[3-jp];
5770     yprof[4+jp] =  yprof[3-jp];
5771   }
5772
5773   // And now the actual Xtru
5774   forwCoverMain->DefinePolygon(8, xprof, yprof);
5775   forwCoverMain->DefineSection(0, 0);
5776   forwCoverMain->DefineSection(1, coverLen);
5777
5778   // The hole: another Xtru (rounded corners approximated with segments)
5779   TGeoXtru *forwCoverHole = new TGeoXtru(2);
5780   forwCoverHole->SetName("ITSsuppForwCoverHole");
5781
5782   CreateTrayACoverHolesShape(kForwardCoverHoleWide, kForwardCoverHoleLen,
5783                              kForwardCoverHoleR10 , xprof, yprof);
5784
5785   // And now the actual Xtru
5786   forwCoverHole->DefinePolygon(16, xprof, yprof);
5787   forwCoverHole->DefineSection(0, 0);
5788   forwCoverHole->DefineSection(1, kForwardCoverTotalThick-kForwardCoverInternThick);
5789
5790   // Now the proper rototranslation matrices for the two holes
5791   yloc = kForwardCoverTotalThick-kForwardCoverInternThick-0.01;//Precision fix
5792   zloc = kForwardCoverHoleZTrans;
5793   TGeoCombiTrans *mf1 = new TGeoCombiTrans(0, yloc, zloc,
5794                                            new TGeoRotation("", 0, 90, 0) );
5795   mf1->SetName("mf1");
5796   mf1->RegisterYourself();
5797
5798   zloc = coverLen - kForwardCoverHoleZTrans - kForwardCoverHoleLen;
5799   TGeoCombiTrans *mf2 = new TGeoCombiTrans(0, yloc, zloc,
5800                                            new TGeoRotation("", 0, 90, 0) );
5801   mf2->SetName("mf2");
5802   mf2->RegisterYourself();
5803
5804   // Finally the actual cover shape
5805   TGeoCompositeShape *cover = new TGeoCompositeShape("ITSsuppForwardCoverMain",
5806     "ITSsuppForwCoverMain-ITSsuppForwCoverHole:mf1-ITSsuppForwCoverHole:mf2");
5807
5808   return cover;
5809 }
5810
5811 //______________________________________________________________________
5812 TGeoCompositeShape* AliITSv11GeometrySupport::CreateTrayAExternalCover(const Double_t coverLen){
5813 //
5814 // Creates the external cover of the SDD and SSD cable trays on Side A
5815 // (0872/G/D/04)
5816 //
5817 // Input:
5818 //             coverLen: the total length of the cover
5819 //
5820 // Output:
5821 //
5822 // Return:     a TGeoCompositeShape for the cover
5823 //
5824 // Created:      03 Jan 2010  Mario Sitta
5825 //
5826 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
5827 // drawings and other (oral) information given by F.Tosello
5828 //
5829
5830   // Dimensions and positions of the A-Side Cable Tray External Cover
5831   // (0872/G/D/04)
5832   const Double_t kExternalCoverWide        =  130.00 *fgkmm;
5833   const Double_t kExternalCoverSideWide    =   10.00 *fgkmm;
5834   const Double_t kExternalCoverHoleLen1    =  262.00 *fgkmm;
5835   const Double_t kExternalCoverHoleLen2    =  280.00 *fgkmm;
5836   const Double_t kExternalCoverHoleLen3    =  205.00 *fgkmm;
5837   const Double_t kExternalCoverHoleLen4    =   55.00 *fgkmm;
5838   const Double_t kExternalCoverHoleWide    =   90.00 *fgkmm;
5839   const Double_t kExternalCoverHoleR10     =   10.00 *fgkmm;
5840   const Double_t kExternalCoverTotalThick  =    5.00 *fgkmm;
5841   const Double_t kExternalCoverSideThick   =    3.00 *fgkmm;
5842   const Double_t kExternalCoverInternThick =    2.00 *fgkmm;
5843
5844   const Double_t kExternalCoverHole1ZTrans =   28.00 *fgkmm;
5845   const Double_t kExternalCoverHolesZTrans =   20.00 *fgkmm;
5846
5847
5848   // Local variables
5849   Double_t xprof[16], yprof[16];
5850   Double_t yloc, zloc;
5851
5852
5853   // The main shape: a Xtru
5854   TGeoXtru *externCoverMain = new TGeoXtru(2);
5855   externCoverMain->SetName("ITSsuppExternCoverMain");
5856
5857   xprof[0] = kExternalCoverWide/2;
5858   yprof[0] = kExternalCoverTotalThick;
5859   xprof[1] = xprof[0];
5860   yprof[1] = yprof[0] - kExternalCoverSideThick;
5861   xprof[2] = xprof[1] - kExternalCoverSideWide;
5862   yprof[2] = yprof[1];
5863   xprof[3] = xprof[2];
5864   yprof[3] = 0;
5865
5866   // We did the right side, now reflex on the left side
5867   for (Int_t jp = 0; jp < 4; jp++) {
5868     xprof[4+jp] = -xprof[3-jp];
5869     yprof[4+jp] =  yprof[3-jp];
5870   }
5871
5872   // And now the actual Xtru
5873   externCoverMain->DefinePolygon(8, xprof, yprof);
5874   externCoverMain->DefineSection(0, 0);
5875   externCoverMain->DefineSection(1, coverLen);
5876
5877   // The first hole: a Xtru (rounded corners approximated with segments)
5878   Double_t holethick = kExternalCoverTotalThick-kExternalCoverInternThick;
5879
5880   TGeoXtru *extCoverHole1 = new TGeoXtru(2);
5881   extCoverHole1->SetName("ITSsuppExtCoverHole1");
5882
5883   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen1,
5884                              kExternalCoverHoleR10 , xprof, yprof);
5885
5886   extCoverHole1->DefinePolygon(16, xprof, yprof);
5887   extCoverHole1->DefineSection(0, 0);
5888   extCoverHole1->DefineSection(1, holethick);
5889
5890   // The second (and third) hole: another Xtru
5891   TGeoXtru *extCoverHole2 = new TGeoXtru(2);
5892   extCoverHole2->SetName("ITSsuppExtCoverHole2");
5893
5894   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen2,
5895                              kExternalCoverHoleR10 , xprof, yprof);
5896
5897   extCoverHole2->DefinePolygon(16, xprof, yprof);
5898   extCoverHole2->DefineSection(0, 0);
5899   extCoverHole2->DefineSection(1, holethick);
5900
5901   // The fourth hole: another Xtru
5902   TGeoXtru *extCoverHole3 = new TGeoXtru(2);
5903   extCoverHole3->SetName("ITSsuppExtCoverHole3");
5904
5905   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen3,
5906                              kExternalCoverHoleR10 , xprof, yprof);
5907
5908   extCoverHole3->DefinePolygon(16, xprof, yprof);
5909   extCoverHole3->DefineSection(0, 0);
5910   extCoverHole3->DefineSection(1, holethick);
5911
5912   // The fifth and last hole: another Xtru
5913   TGeoXtru *extCoverHole4 = new TGeoXtru(2);
5914   extCoverHole4->SetName("ITSsuppExtCoverHole4");
5915
5916   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen4,
5917                              kExternalCoverHoleR10 , xprof, yprof);
5918
5919   extCoverHole4->DefinePolygon(16, xprof, yprof);
5920   extCoverHole4->DefineSection(0, 0);
5921   extCoverHole4->DefineSection(1, holethick);
5922
5923   // Now the proper rototranslation matrices for the holes
5924   yloc = kExternalCoverTotalThick - kExternalCoverInternThick-0.01;
5925   zloc = kExternalCoverHole1ZTrans;
5926   TGeoCombiTrans *me1 = new TGeoCombiTrans(0, yloc, zloc,
5927                                            new TGeoRotation("", 0, 90, 0) );
5928   me1->SetName("me1");
5929   me1->RegisterYourself();
5930
5931   zloc += (kExternalCoverHoleLen1 + kExternalCoverHolesZTrans);
5932   TGeoCombiTrans *me2 = new TGeoCombiTrans(0, yloc, zloc,
5933                                            new TGeoRotation("", 0, 90, 0) );
5934   me2->SetName("me2");
5935   me2->RegisterYourself();
5936
5937   zloc += (kExternalCoverHoleLen2 + kExternalCoverHolesZTrans);
5938   TGeoCombiTrans *me3 = new TGeoCombiTrans(0, yloc, zloc,
5939                                            new TGeoRotation("", 0, 90, 0) );
5940   me3->SetName("me3");
5941   me3->RegisterYourself();
5942
5943   zloc += (kExternalCoverHoleLen2 + kExternalCoverHolesZTrans);
5944   TGeoCombiTrans *me4 = new TGeoCombiTrans(0, yloc, zloc,
5945                                            new TGeoRotation("", 0, 90, 0) );
5946   me4->SetName("me4");
5947   me4->RegisterYourself();
5948
5949   zloc += (kExternalCoverHoleLen3 + kExternalCoverHolesZTrans);
5950   TGeoCombiTrans *me5 = new TGeoCombiTrans(0, yloc, zloc,
5951                                            new TGeoRotation("", 0, 90, 0) );
5952   me5->SetName("me5");
5953   me5->RegisterYourself();
5954
5955   // Finally the actual cover shape
5956   TGeoCompositeShape *cover = new TGeoCompositeShape("ITSsuppExternCoverMain",
5957     "ITSsuppExternCoverMain-ITSsuppExtCoverHole1:me1-ITSsuppExtCoverHole2:me2-ITSsuppExtCoverHole2:me3-ITSsuppExtCoverHole3:me4-ITSsuppExtCoverHole4:me5");
5958
5959   return cover;
5960 }
5961
5962 //______________________________________________________________________
5963 void AliITSv11GeometrySupport::CreateTrayACoverHolesShape(const Double_t wide,
5964                                const Double_t length, const Double_t r10,
5965                                Double_t *x, Double_t *y){
5966 //
5967 // Creates the proper sequence of X and Y coordinates to determine
5968 // the base XTru polygon for the holes in the SDD and SSD tray covers
5969 // (here the rounded corners are approximated with segments)
5970 //
5971 // Input:
5972 //        wide   : the hole wide
5973 //        length : the hole length
5974 //        r10    : the radius of the rounded corners
5975 //
5976 // Output:
5977 //        x, y : coordinate vectors [16]
5978 //
5979 // Created:      03 Jan 2010  Mario Sitta
5980 //
5981 // Caller must guarantee that x and y have the correct dimensions
5982 // (but being this a private method it's easy to tell)
5983 //
5984
5985   x[0] = wide/2 - r10;
5986   y[0] = length;
5987   x[1] = x[0] + r10*SinD(30);
5988   y[1] = y[0] - r10*(1 - CosD(30));
5989   x[2] = x[0] + r10*SinD(60);
5990   y[2] = y[0] - r10*(1 - CosD(60));
5991   x[3] = x[0] + r10;
5992   y[3] = y[0] - r10;
5993   x[4] = x[3];
5994   y[4] = r10;
5995   x[5] = x[4] - r10*(1 - CosD(30));
5996   y[5] = y[4] - r10*SinD(30);
5997   x[6] = x[4] - r10*(1 - CosD(60));
5998   y[6] = y[4] - r10*SinD(60);
5999   x[7] = x[4] - r10;
6000   y[7] = 0;
6001
6002   // We did the right side, now reflex on the left side
6003   for (Int_t jp = 0; jp < 8; jp++) {
6004     x[8+jp] = -x[7-jp];
6005     y[8+jp] =  y[7-jp];
6006   }
6007
6008   return;
6009 }
6010
6011 //______________________________________________________________________
6012 TGeoXtru* AliITSv11GeometrySupport::CreateSDDSSDTraysSideA(
6013                                               const Double_t trayLen,
6014                                               const Double_t trayHi){
6015 //
6016 // Creates parts of the SDD and SSD Trays on Side A which are identical
6017 // (0872/G/D/03, part of 0872/G/D/07, 0872/G/C/11)
6018 //
6019 // Input:
6020 //         trayLen : the length of the tray part
6021 //         trayHi  : the height of the tray part
6022 //
6023 // Output:
6024 //
6025 // Return:     a TGeoXtru
6026 //
6027 // Created:      26 Feb 2010  Mario Sitta
6028 //
6029 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
6030 // drawings and other (oral) information given by F.Tosello
6031 //
6032
6033   // Dimensions and positions of the A-Side Cable Trays
6034   // (parts of 0872/G/C)
6035   const Double_t kTrayWidth              =  130.00 *fgkmm;
6036   const Double_t kTrayWingWidth          =   10.00 *fgkmm;
6037   const Double_t kTrayHeightToBend       =   20.00 *fgkmm;
6038   const Double_t kTrayThick              =    2.00 *fgkmm;
6039
6040   const Double_t kTrayBendAngle          =   22.00 *TMath::DegToRad();
6041
6042   const Int_t    kTrayNpoints            =   16;
6043
6044   // Local variables
6045   Double_t xprof[kTrayNpoints], yprof[kTrayNpoints];
6046
6047
6048   // The tray shape: a Xtru
6049   TGeoXtru *trayPart = new TGeoXtru(2);
6050
6051   xprof[2] = kTrayWidth/2 - kTrayThick;
6052   yprof[2] = trayHi - kTrayThick;
6053   xprof[3] = kTrayWidth/2 - kTrayWingWidth;
6054   yprof[3] = yprof[2];
6055   xprof[4] = xprof[3];
6056   yprof[4] = trayHi;
6057   xprof[5] = kTrayWidth/2;
6058   yprof[5] = yprof[4];
6059   xprof[6] = xprof[5];
6060   yprof[6] = kTrayHeightToBend;
6061   xprof[7] = xprof[6] - yprof[6]*TMath::Tan(kTrayBendAngle);
6062   yprof[7] = 0;
6063
6064   InsidePoint( xprof[5], yprof[5], xprof[6], yprof[6], xprof[7], yprof[7],
6065               -kTrayThick, xprof[1], yprof[1]);
6066
6067   xprof[8] = -xprof[7];
6068   yprof[8] =  yprof[7];
6069
6070   InsidePoint( xprof[6], yprof[6], xprof[7], yprof[7], xprof[8], yprof[8],
6071               -kTrayThick, xprof[0], yprof[0]);
6072
6073   // We did the right side, now reflex on the left side
6074   for (Int_t jp = 0; jp < 8; jp++) {
6075     xprof[8+jp] = -xprof[7-jp];
6076     yprof[8+jp] =  yprof[7-jp];
6077   }
6078
6079   // And now the actual Xtru
6080   trayPart->DefinePolygon(kTrayNpoints, xprof, yprof);
6081   trayPart->DefineSection(0, 0);
6082   trayPart->DefineSection(1, trayLen);
6083
6084
6085   return trayPart;
6086 }
6087
6088 //______________________________________________________________________
6089 TGeoVolumeAssembly* AliITSv11GeometrySupport::CreateSDDSSDTraysSideC(
6090                                                         const char *trayName,
6091                                                         TGeoManager *mgr){
6092
6093 //
6094 // Creates the SDD and SSD Trays on Side C which are supposedly identical
6095 //
6096 // Input:
6097 //         trayName : the assembly name
6098 //
6099 // Output:
6100 //
6101 // Return:     a TGeoVolumeAssembly
6102 //
6103 // Created:      16 Apr 2010  Mario Sitta
6104 //
6105 // Technical data are taken from AutoCAD drawings and other (oral)
6106 // information given by F.Tosello
6107 //
6108
6109   const Double_t kSideCHalfThick      =    0.100   *fgkcm;
6110   const Double_t kSideCFoldAngle      =    5.000   *TMath::DegToRad();
6111
6112   const Double_t kSideCLength1        =  172.800   *fgkcm;
6113   const Double_t kSideCLength2        =  189.300   *fgkcm;
6114   const Double_t kSideCHalfWide       =    6.350   *fgkcm;
6115   const Double_t kSideCHeight1        =   11.800   *fgkcm;
6116   const Double_t kSideCHeight2        =    4.300   *fgkcm;
6117   const Double_t kSideCSideLength1    =   10.800   *fgkcm;
6118   const Double_t kSideCSideLength2    =   63.800   *fgkcm;
6119   const Double_t kSideCSideHeight     =    8.800   *fgkcm;
6120   const Int_t    kNPointsLowerFace    =    6;
6121   const Int_t    kNPointsLateralFace  =    9;
6122
6123   const Double_t kSideCWingAHalfLen   =    5.000   *fgkcm;
6124   const Double_t kSideCWingBHalfLen   =   30.500   *fgkcm;
6125   const Double_t kSideCWingCHalfLen   =    2.000   *fgkcm;
6126   const Double_t kSideCWingDHalfLen   =   48.500   *fgkcm;
6127   const Double_t kSideCWingEHalfLen   =   83.000   *fgkcm;
6128   const Double_t kSideCWingsHalfWide  =    0.450   *fgkcm;
6129
6130   const Int_t    kNPointsCoverFace    =   12;
6131
6132   const Double_t kPlateHalfLen        =    6.000   *fgkcm;
6133   const Double_t kPlateThick          =    0.600   *fgkcm;
6134   const Double_t kPlateHeight         =    4.200   *fgkcm;
6135   const Int_t    kNPointsPlate        =    6;
6136
6137   const Double_t kBarCoolRmax         =    0.4     *fgkcm;
6138   const Int_t    kNumBarCool          =    2;
6139   const Double_t kXShiftBarCool[kNumBarCool] = { 8.7, 13.0 };
6140   const Double_t kYShiftBarCool[kNumBarCool] = { 8.5,  5.0 };
6141
6142
6143   // Local variables
6144   Double_t xprof[12], yprof[12];
6145   Double_t xloc, yloc, zloc, delta, alpharot;
6146
6147   // The single C-Side Cable tray as an assembly
6148   TGeoVolumeAssembly *cableTrayC = new TGeoVolumeAssembly(trayName);
6149
6150   // First create all needed shapes
6151
6152   // The Cable Tray lower face: a Xtru
6153   TGeoXtru *sideCLowerFace = new TGeoXtru(2);
6154
6155   xprof[0] = 0.;
6156   yprof[0] = 0.;
6157   xprof[1] = kSideCLength1;
6158   yprof[1] = 0.;
6159   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(kSideCFoldAngle);
6160   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(kSideCFoldAngle);
6161   xprof[3] = xprof[2] - 2*kSideCHalfThick*TMath::Sin(kSideCFoldAngle);
6162   yprof[3] = yprof[2] + 2*kSideCHalfThick*TMath::Cos(kSideCFoldAngle);
6163   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6164               2*kSideCHalfThick , xprof[4], yprof[4]);
6165   xprof[5] = 0.;
6166   yprof[5] = 2*kSideCHalfThick;
6167
6168   sideCLowerFace->DefinePolygon(kNPointsLowerFace, xprof, yprof);
6169   sideCLowerFace->DefineSection(0,-kSideCHalfWide);
6170   sideCLowerFace->DefineSection(1, kSideCHalfWide);
6171
6172   // The Cable Tray lateral face: a Xtru
6173   TGeoXtru *sideCLateralFace = new TGeoXtru(2);
6174
6175   xprof[0] = 0.;
6176   yprof[0] = 0.;
6177   xprof[1] = kSideCLength1;
6178   yprof[1] = 0.;
6179   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(kSideCFoldAngle);
6180   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(kSideCFoldAngle);
6181   xprof[3] = xprof[2] - kSideCHeight2*TMath::Sin(kSideCFoldAngle);
6182   yprof[3] = yprof[2] + kSideCHeight2*TMath::Cos(kSideCFoldAngle);
6183   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6184               kSideCHeight2, xprof[4], yprof[4]);
6185   xprof[5] = kSideCSideLength1 + kSideCSideLength2;
6186   yprof[5] = kSideCHeight2;
6187   xprof[6] = xprof[5];
6188   yprof[6] = kSideCSideHeight;
6189   xprof[7] = kSideCSideLength1;
6190   yprof[7] = kSideCHeight1;
6191   xprof[8] = 0;
6192   yprof[8] = yprof[7];
6193
6194   sideCLateralFace->DefinePolygon(kNPointsLateralFace, xprof, yprof);
6195   sideCLateralFace->DefineSection(0,-kSideCHalfThick);
6196   sideCLateralFace->DefineSection(1, kSideCHalfThick);
6197
6198   // The lateral wings: four BBox's
6199   TGeoBBox *sideCLateralWingA = new TGeoBBox(kSideCWingAHalfLen,
6200                                              kSideCHalfThick,
6201                                              kSideCWingsHalfWide);
6202
6203   TGeoBBox *sideCLateralWingB = new TGeoBBox(kSideCWingBHalfLen,
6204                                              kSideCHalfThick,
6205                                              kSideCWingsHalfWide);
6206
6207   TGeoBBox *sideCLateralWingC = new TGeoBBox(kSideCHalfThick,    // With these
6208                                              kSideCWingCHalfLen, // X,Y avoid
6209                                              kSideCWingsHalfWide);//rotations
6210
6211   TGeoBBox *sideCLateralWingD = new TGeoBBox(kSideCWingDHalfLen,
6212                                              kSideCHalfThick,
6213                                              kSideCWingsHalfWide);
6214
6215   TGeoBBox *sideCLateralWingE = new TGeoBBox(kSideCWingEHalfLen,
6216                                              kSideCHalfThick,
6217                                              kSideCWingsHalfWide);
6218
6219   // The connecting lower plate: a Xtru
6220   TGeoXtru *sideCLowerPlate =  new TGeoXtru(2);
6221
6222   xprof[0] = 0.;
6223   yprof[0] = 0.;
6224   xprof[1] = kPlateHalfLen;
6225   yprof[1] = 0.;
6226   xprof[2] = xprof[1] + kPlateHalfLen*TMath::Cos(kSideCFoldAngle);
6227   yprof[2] = kPlateHalfLen*TMath::Sin(kSideCFoldAngle);
6228   xprof[3] = xprof[2] - kPlateThick*TMath::Sin(kSideCFoldAngle);
6229   yprof[3] = yprof[2] + kPlateThick*TMath::Cos(kSideCFoldAngle);
6230   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6231               kPlateThick, xprof[4], yprof[4]);
6232   xprof[5] = 0.;
6233   yprof[5] = kPlateThick;
6234
6235   sideCLowerPlate->DefinePolygon(kNPointsPlate, xprof, yprof);
6236   Double_t zwide = kSideCHalfWide + 2*kSideCHalfThick;
6237   sideCLowerPlate->DefineSection(0,-zwide);
6238   sideCLowerPlate->DefineSection(1, zwide);
6239
6240   // The connecting side plate: a Xtru
6241   TGeoXtru *sideCLateralPlate = new TGeoXtru(2);
6242
6243   xprof[0] = 0.;
6244   yprof[0] = 0.;
6245   xprof[1] = kPlateHalfLen;
6246   yprof[1] = 0.;
6247   xprof[2] = xprof[1] + kPlateHalfLen*TMath::Cos(kSideCFoldAngle);
6248   yprof[2] = kPlateHalfLen*TMath::Sin(kSideCFoldAngle);
6249   xprof[3] = xprof[2] - kPlateHeight*TMath::Sin(kSideCFoldAngle);
6250   yprof[3] = yprof[2] + kPlateHeight*TMath::Cos(kSideCFoldAngle);
6251   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6252               kPlateHeight, xprof[4], yprof[4]); // Avoid small overlap
6253   xprof[5] = 0.;
6254   yprof[5] = kPlateHeight;
6255
6256   sideCLateralPlate->DefinePolygon(kNPointsPlate, xprof, yprof);
6257   sideCLateralPlate->DefineSection(0,-kPlateThick/2);
6258   sideCLateralPlate->DefineSection(1, kPlateThick/2);
6259
6260   // The bar fixing the cooling tubes: a Tube
6261   TGeoTube *coolBar = new TGeoTube(0., kBarCoolRmax, kSideCHalfWide);
6262
6263   // The Cable Tray cover: a (complex) Xtru
6264   TGeoXtru *sideCCoverFace = new TGeoXtru(2);
6265
6266   xprof[ 0] = sideCLateralFace->GetX(8);
6267   yprof[ 0] = sideCLateralFace->GetY(8);
6268   xprof[ 1] = sideCLateralFace->GetX(7);
6269   yprof[ 1] = sideCLateralFace->GetY(7);
6270   xprof[ 2] = sideCLateralFace->GetX(6);
6271   yprof[ 2] = sideCLateralFace->GetY(6);
6272   xprof[ 3] = sideCLateralFace->GetX(5);
6273   yprof[ 3] = sideCLateralFace->GetY(5);
6274   xprof[ 4] = sideCLateralFace->GetX(4);
6275   yprof[ 4] = sideCLateralFace->GetY(4);
6276
6277   xloc = (kSideCLength1 + (kSideCSideLength1+kSideCSideLength2))/2;
6278   delta  = kSideCLength1 - (xloc + kSideCWingDHalfLen);
6279   xprof[ 5] = xprof[4]
6280             + (delta + 2*kSideCWingEHalfLen)*TMath::Cos(kSideCFoldAngle);
6281   yprof[ 5] = yprof[4]
6282             + (delta + 2*kSideCWingEHalfLen)*TMath::Sin(kSideCFoldAngle);
6283
6284   xprof[ 6] = xprof[5] - 2*kSideCHalfThick*TMath::Sin(kSideCFoldAngle);
6285   yprof[ 6] = yprof[5] + 2*kSideCHalfThick*TMath::Cos(kSideCFoldAngle);
6286   InsidePoint(xprof[3], yprof[3], xprof[4], yprof[4], xprof[5], yprof[5],
6287               2*kSideCHalfThick, xprof[7], yprof[7]);
6288   InsidePoint(xprof[2], yprof[2], xprof[3], yprof[3], xprof[4], yprof[4],
6289               2*kSideCHalfThick, xprof[8], yprof[8]);
6290   xprof[ 9] = xprof[2] + 2*kSideCHalfThick;
6291   yprof[ 9] = yprof[2] + 2*kSideCHalfThick;
6292   xprof[10] = xprof[1];
6293   yprof[10] = yprof[1] + 2*kSideCHalfThick;
6294   xprof[11] = xprof[0];
6295   yprof[11] = yprof[0] + 2*kSideCHalfThick;
6296
6297   sideCCoverFace->DefinePolygon(kNPointsCoverFace, xprof, yprof);
6298   zloc = kSideCHalfWide + 2*kSideCHalfThick + 2*kSideCWingsHalfWide;
6299   sideCCoverFace->DefineSection(0,-zloc);
6300   sideCCoverFace->DefineSection(1, zloc);
6301
6302
6303   // We have all shapes: now create the real volumes
6304   TGeoMedium *medAl      = mgr->GetMedium("ITS_ALUMINUM$");
6305
6306   TGeoVolume *traySideCLowerFace  = new TGeoVolume("ITSsuppTraySideCLower",
6307                                                    sideCLowerFace, medAl);
6308
6309   traySideCLowerFace->SetVisibility(kTRUE);
6310   traySideCLowerFace->SetLineColor(6); // Purple
6311   traySideCLowerFace->SetLineWidth(1);
6312   traySideCLowerFace->SetFillColor(traySideCLowerFace->GetLineColor());
6313   traySideCLowerFace->SetFillStyle(4000); // 0% transparent
6314
6315   TGeoVolume *traySideCLateralFace  = new TGeoVolume("ITSsuppTraySideCLateral",
6316                                                      sideCLateralFace, medAl);
6317
6318   traySideCLateralFace->SetVisibility(kTRUE);
6319   traySideCLateralFace->SetLineColor(6); // Purple
6320   traySideCLateralFace->SetLineWidth(1);
6321   traySideCLateralFace->SetFillColor(traySideCLateralFace->GetLineColor());
6322   traySideCLateralFace->SetFillStyle(4000); // 0% transparent
6323
6324   TGeoVolume *traySideCLateralWingA =
6325     new TGeoVolume("ITSsuppTraySideCLateralWingA", sideCLateralWingA,  medAl);
6326
6327   traySideCLateralWingA->SetVisibility(kTRUE);
6328   traySideCLateralWingA->SetLineColor(6); // Purple
6329   traySideCLateralWingA->SetLineWidth(1);
6330   traySideCLateralWingA->SetFillColor(traySideCLateralWingA->GetLineColor());
6331   traySideCLateralWingA->SetFillStyle(4000); // 0% transparent
6332
6333   TGeoVolume *traySideCLateralWingB =
6334     new TGeoVolume("ITSsuppTraySideCLateralWingB", sideCLateralWingB,  medAl);
6335
6336   traySideCLateralWingB->SetVisibility(kTRUE);
6337   traySideCLateralWingB->SetLineColor(6); // Purple
6338   traySideCLateralWingB->SetLineWidth(1);
6339   traySideCLateralWingB->SetFillColor(traySideCLateralWingB->GetLineColor());
6340   traySideCLateralWingB->SetFillStyle(4000); // 0% transparent
6341
6342   TGeoVolume *traySideCLateralWingC =
6343     new TGeoVolume("ITSsuppTraySideCLateralWingC", sideCLateralWingC,  medAl);
6344
6345   traySideCLateralWingC->SetVisibility(kTRUE);
6346   traySideCLateralWingC->SetLineColor(6); // Purple
6347   traySideCLateralWingC->SetLineWidth(1);
6348   traySideCLateralWingC->SetFillColor(traySideCLateralWingC->GetLineColor());
6349   traySideCLateralWingC->SetFillStyle(4000); // 0% transparent
6350
6351   TGeoVolume *traySideCLateralWingD =
6352     new TGeoVolume("ITSsuppTraySideCLateralWingD", sideCLateralWingD,  medAl);
6353
6354   traySideCLateralWingD->SetVisibility(kTRUE);
6355   traySideCLateralWingD->SetLineColor(6); // Purple
6356   traySideCLateralWingD->SetLineWidth(1);
6357   traySideCLateralWingD->SetFillColor(traySideCLateralWingD->GetLineColor());
6358   traySideCLateralWingD->SetFillStyle(4000); // 0% transparent
6359
6360   TGeoVolume *traySideCLateralWingE =
6361     new TGeoVolume("ITSsuppTraySideCLateralWingE", sideCLateralWingE,  medAl);
6362
6363   traySideCLateralWingE->SetVisibility(kTRUE);
6364   traySideCLateralWingE->SetLineColor(6); // Purple
6365   traySideCLateralWingE->SetLineWidth(1);
6366   traySideCLateralWingE->SetFillColor(traySideCLateralWingE->GetLineColor());
6367   traySideCLateralWingE->SetFillStyle(4000); // 0% transparent
6368
6369   TGeoVolume *traySideCLowerPlate =
6370     new TGeoVolume("ITSsuppTraySideCLowerPlate", sideCLowerPlate,  medAl);
6371
6372   traySideCLowerPlate->SetVisibility(kTRUE);
6373   traySideCLowerPlate->SetLineColor(6); // Purple
6374   traySideCLowerPlate->SetLineWidth(1);
6375   traySideCLowerPlate->SetFillColor(traySideCLowerPlate->GetLineColor());
6376   traySideCLowerPlate->SetFillStyle(4000); // 0% transparent
6377
6378   TGeoVolume *traySideCLateralPlate =
6379     new TGeoVolume("ITSsuppTraySideCLateralPlate", sideCLateralPlate,  medAl);
6380
6381   traySideCLateralPlate->SetVisibility(kTRUE);
6382   traySideCLateralPlate->SetLineColor(6); // Purple
6383   traySideCLateralPlate->SetLineWidth(1);
6384   traySideCLateralPlate->SetFillColor(traySideCLateralPlate->GetLineColor());
6385   traySideCLateralPlate->SetFillStyle(4000); // 0% transparent
6386
6387   TGeoVolume *traySideCCoverFace =
6388     new TGeoVolume("ITSsuppTraySideCCoverFace", sideCCoverFace,  medAl);
6389
6390   traySideCCoverFace->SetVisibility(kTRUE);
6391   traySideCCoverFace->SetLineColor(6); // Purple
6392   traySideCCoverFace->SetLineWidth(1);
6393   traySideCCoverFace->SetFillColor(traySideCCoverFace->GetLineColor());
6394   traySideCCoverFace->SetFillStyle(4000); // 0% transparent
6395
6396   TGeoVolume *coolingTubeBar = new TGeoVolume("ITSsuppTraySideCCoolBar",
6397                                               coolBar, medAl);
6398
6399   coolingTubeBar->SetVisibility(kTRUE);
6400   coolingTubeBar->SetLineColor(6); // Purple
6401   coolingTubeBar->SetLineWidth(1);
6402   coolingTubeBar->SetFillColor(coolingTubeBar->GetLineColor());
6403   coolingTubeBar->SetFillStyle(4000); // 0% transparent
6404
6405
6406   // Now build up the tray
6407   cableTrayC->AddNode(traySideCLowerFace,1,0);
6408
6409   zloc = kSideCHalfWide + kSideCHalfThick;
6410   cableTrayC->AddNode(traySideCLateralFace,1,
6411                             new TGeoTranslation(0., 0., zloc) );
6412   cableTrayC->AddNode(traySideCLateralFace,2,
6413                             new TGeoTranslation(0., 0.,-zloc) );
6414
6415   xloc = kSideCWingAHalfLen;
6416   yloc = kSideCHeight1 - kSideCHalfThick;
6417   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
6418   cableTrayC->AddNode(traySideCLateralWingA,1,
6419                             new TGeoTranslation(xloc, yloc, zloc) );
6420   cableTrayC->AddNode(traySideCLateralWingA,2,
6421                             new TGeoTranslation(xloc, yloc,-zloc) );
6422
6423   xloc = kSideCSideLength1 + kSideCSideLength2/2;
6424   yloc = Yfrom2Points(kSideCSideLength1,kSideCHeight1,
6425                       kSideCSideLength1+kSideCSideLength2,kSideCSideHeight,
6426                       xloc) - kSideCHalfThick -0.0012; // Avoid small overlap
6427   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
6428   alpharot = (-(kSideCHeight1 - kSideCSideHeight)/kSideCSideLength2 )*
6429                 TMath::RadToDeg();
6430   cableTrayC->AddNode(traySideCLateralWingB,1,
6431                             new TGeoCombiTrans(xloc, yloc, zloc,
6432                                         new TGeoRotation("",alpharot,0,0) ) );
6433   cableTrayC->AddNode(traySideCLateralWingB,2,
6434                             new TGeoCombiTrans(xloc, yloc,-zloc,
6435                                         new TGeoRotation("",alpharot,0,0) ) );
6436
6437   xloc = kSideCSideLength1 + kSideCSideLength2 - kSideCHalfThick;
6438   yloc = kSideCSideHeight - kSideCWingCHalfLen;
6439   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
6440   cableTrayC->AddNode(traySideCLateralWingC,1,
6441                             new TGeoTranslation(xloc, yloc, zloc) );
6442   cableTrayC->AddNode(traySideCLateralWingC,2,
6443                             new TGeoTranslation(xloc, yloc,-zloc) );
6444
6445   xloc = (kSideCLength1 + (kSideCSideLength1+kSideCSideLength2))/2;
6446   yloc = kSideCHeight2 - kSideCHalfThick;
6447   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
6448   cableTrayC->AddNode(traySideCLateralWingD,1,
6449                             new TGeoTranslation(xloc, yloc, zloc) );
6450   cableTrayC->AddNode(traySideCLateralWingD,2,
6451                             new TGeoTranslation(xloc, yloc,-zloc) );
6452
6453   delta = kSideCLength1 - (xloc + kSideCWingDHalfLen);
6454   xloc = kSideCLength1 + delta + kSideCWingEHalfLen;
6455   yloc = (xloc - kSideCLength1)*TMath::Tan(kSideCFoldAngle) +
6456           kSideCHeight2*TMath::Cos(kSideCFoldAngle) - kSideCHalfThick;
6457   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
6458   alpharot = kSideCFoldAngle*TMath::RadToDeg();
6459   cableTrayC->AddNode(traySideCLateralWingE,1,
6460                             new TGeoCombiTrans(xloc, yloc, zloc,
6461                                         new TGeoRotation("",alpharot,0,0) ) );
6462   cableTrayC->AddNode(traySideCLateralWingE,2,
6463                             new TGeoCombiTrans(xloc, yloc,-zloc,
6464                                         new TGeoRotation("",alpharot,0,0) ) );
6465
6466   xloc = kSideCLength1 - kPlateHalfLen;
6467   yloc = -kPlateThick -0.0025; // Avoid small overlap
6468   cableTrayC->AddNode(traySideCLowerPlate,1,
6469                             new TGeoTranslation(xloc, yloc, 0.) );
6470
6471   xloc = kSideCLength1 - kPlateHalfLen;
6472   yloc = -kPlateThick;
6473   zloc = kSideCHalfWide + 2*kSideCHalfThick + kPlateThick/2;
6474   cableTrayC->AddNode(traySideCLateralPlate,1,
6475                             new TGeoTranslation(xloc, yloc, zloc) );
6476   cableTrayC->AddNode(traySideCLateralPlate,2,
6477                             new TGeoTranslation(xloc, yloc,-zloc) );
6478
6479   for (Int_t jc = 0; jc <kNumBarCool; jc++) {
6480     xloc = kXShiftBarCool[jc];
6481     yloc = kYShiftBarCool[jc];
6482     cableTrayC->AddNode(coolingTubeBar,jc+1,
6483                               new TGeoTranslation(xloc, yloc, 0.) );
6484   }
6485
6486   cableTrayC->AddNode(traySideCCoverFace,1,0);
6487
6488
6489   // Finally return what we made up
6490
6491   return cableTrayC;
6492 }
6493