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