fixed the tainted variables
[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                    const Double_t *xin, const 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) const
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) const
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) const
730 {
731 //
732 // Given two points (x1,y1) and (x2,y2), determines the point (x,y)
733 // lying on the line parallel to the line passing by these points,
734 // at a distance d and passing by the point (x3,y3), which is symmetric to
735 // the third point with respect to the axis of the segment delimited by
736 // the two first points.
737 //
738 // Input:
739 //        x1, y1 : first point
740 //        x2, y2 : second point
741 //        x3, y3 : third point
742 //        d      : distance between the two lines
743 //
744 // Output:
745 //        x, y   : coordinate of the reflected point
746 //
747 // Created:      22 Feb 2009  Mario Sitta
748 //
749 //Begin_Html
750 /*
751 <img src="ITS/doc/ReflectPoint.gif">
752 */
753 //End_Html
754
755   // The slope of the line passing by the first two points
756   Double_t k = (y2 - y1)/(x2 - x1);
757
758   // The middle point of the segment 1-2
759   Double_t xK = (x1 + x2)/2.;
760   Double_t yK = (y1 + y2)/2.;
761
762   // The intercept between the axis of the segment 1-2 and the line
763   // passing by 3 and parallel to the line passing by 1-2
764   Double_t xH = (k*k*x3 + k*(yK - y3) + xK)/(k*k + 1);
765   Double_t yH = k*(xH - x3) + y3;
766
767   // The point symmetric to 3 with respect to H
768   x = 2*xH - x3;
769   y = 2*yH - y3;
770
771   // Done
772   return;
773 }
774
775 //______________________________________________________________________
776 void AliITSv11GeometrySupport::SDDCone(TGeoVolume *moth,TGeoManager *mgr)
777 {
778 //
779 // Creates the SDD support cone and cylinder geometry as a
780 // volume assembly and adds it to the mother volume
781 // (part of this code is taken or anyway inspired to SDDCone method
782 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
783 //
784 // Input:
785 //         moth : the TGeoVolume owing the volume structure
786 //         mgr  : the GeoManager (default gGeoManager)
787 // Output:
788 //
789 // Created:         ???       Bjorn S. Nilsen
790 // Updated:      18 Feb 2008  Mario Sitta
791 // Updated:      25 Jul 2008  Mario Sitta   SDDCarbonFiberCone simpler
792 // Updated:      10 Jun 2010  Mario Sitta   Cables across cone holes added
793 //
794 // Technical data are taken from:  "Supporto Generale Settore SDD"
795 // (technical drawings ALR-0816/1-B), "Supporto Globale Settore SDD"
796 // (technical drawings ALR-0816/2A, ALR-0816/2B, ALR-0816/2C, ALR-0816/2D), 
797 // private communication with B. Giraudo
798
799   // Dimensions of the Central cylinder and flanges
800   const Double_t kCylinderHalfLength = (790.0/2)*fgkmm;
801   const Double_t kCylinderInnerR     = (210.0/2)*fgkmm;
802   const Double_t kCylinderOuterR     = (231.0/2)*fgkmm;
803   const Double_t kFlangeHalfLength   = ( 15.0/2)*fgkmm;
804   const Double_t kFlangeInnerR       = (210.5/2)*fgkmm;
805   const Double_t kFlangeOuterR       = (230.5/2)*fgkmm;
806   const Double_t kInsertoHalfLength  =
807                                      kCylinderHalfLength - 2*kFlangeHalfLength;
808 //  const Double_t kCFThickness        = kFlangeInnerR - kCylinderInnerR;
809   const Double_t kBoltDiameter       =       6.0*fgkmm; // M6 screw
810   const Double_t kBoltDepth          =       6.0*fgkmm; // In the flange
811   const Double_t kBoltRadius         = (220.0/2)*fgkmm; // Radius in flange
812   const Double_t kThetaBolt          =      30.0*fgkDegree;
813   const Int_t    kNBolts             = (Int_t)(360.0/kThetaBolt);
814   // Dimensions of the Cone
815   const Double_t kConeROutMin        = (540.0/2)*fgkmm;
816   const Double_t kConeROutMax        = (560.0/2)*fgkmm;
817   const Double_t kConeRCurv          =      10.0*fgkmm; // Radius of curvature
818   const Double_t kConeRinMin         = (210.0/2)*fgkmm;
819 //  const Double_t kConeRinMax         = (216.0/2)*fgkmm;
820   const Double_t kConeRinCylinder    = (231.0/2)*fgkmm;
821   const Double_t kConeZCylinder      =     192.0*fgkmm;
822   const Double_t kConeZOuterMilled   =      23.0*fgkmm;
823   const Double_t kConeDZin           =      15.0*fgkmm; // ???
824   const Double_t kConeThickness      =      10.0*fgkmm; // Rohacell + Carb.Fib.
825   const Double_t kConeTheta          =      45.0*fgkDegree; // SDD cone angle
826   const Double_t kSinConeTheta       =
827                                      TMath::Sin(kConeTheta*TMath::DegToRad());
828   const Double_t kCosConeTheta       =
829                                      TMath::Cos(kConeTheta*TMath::DegToRad());
830   const Double_t kTanConeTheta       =
831                                      TMath::Tan(kConeTheta*TMath::DegToRad());
832   // Dimensions of the Cone Inserts
833   const Double_t kConeCFThickness    =       1.5*fgkmm;//Carbon fiber thickness
834   // Dimensions of the Cone Holes
835   const Double_t kHole1RMin          = (450.0/2)*fgkmm;
836   const Double_t kHole1RMax          = (530.0/2)*fgkmm;
837   const Double_t kHole2RMin          = (280.0/2)*fgkmm;
838   const Double_t kHole2RMax          = (375.0/2)*fgkmm;
839   const Double_t kHole1Phi           =      25.0*fgkDegree;
840   const Double_t kHole2Phi           =      50.0*fgkDegree;
841   const Double_t kHole3RMin          =     205.0*fgkmm;
842   const Double_t kHole3DeltaR        =        15*fgkmm;
843   const Double_t kHole3Width         =        30*fgkmm;
844   const Int_t    kNHole3             =         6      ;
845   const Double_t kHole4RMin          =     116.0*fgkmm;
846   const Double_t kHole4DeltaR        =        15*fgkmm;
847   const Double_t kHole4Width         =        30*fgkmm;
848   //  const Int_t    kNHole4             =         3      ;
849   // Fraction of materials in holes
850   const Double_t kHolePlasticFrac    =       0.55846;
851   const Double_t kHoleCuFrac         =       0.06319;
852   const Double_t kHoleGlassFrac      =       0.02652;
853
854   // Local variables
855   Double_t x, y, z, t, dza, rmin, rmax;
856
857
858   // Recover the needed materials
859   TGeoMedium *medSDDcf    = mgr->GetMedium("ITS_SDD C (M55J)$");
860   TGeoMedium *medSDDair   = mgr->GetMedium("ITS_SDD AIR$");
861   TGeoMedium *medSDDste   = mgr->GetMedium("ITS_G10FR4$"); // stesalite
862   TGeoMedium *medSDDroh   = mgr->GetMedium("ITS_ROHACELL$");
863   TGeoMedium *medSDDss    = mgr->GetMedium("ITS_INOX$");
864   TGeoMedium *medSDDplast = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
865   TGeoMedium *medSDDCu    = mgr->GetMedium("ITS_COPPER$");
866   TGeoMedium *medSDDglass = mgr->GetMedium("ITS_SDD OPTICFIB$");
867
868   // First define the geometrical shapes
869
870   // Central cylinder with its internal foam and the lateral flanges:
871   // a carbon fiber Tube which contains a rohacell Tube and two
872   // stesalite Tube's
873   TGeoTube *cylindershape = new TGeoTube(kCylinderInnerR,kCylinderOuterR,
874                                          kCylinderHalfLength);
875
876   TGeoTube *insertoshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
877                                         kInsertoHalfLength);
878
879   TGeoTube *flangeshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
880                                        kFlangeHalfLength);
881
882   // The flange bolt: it is a Tube
883   TGeoTube *boltshape = new TGeoTube(0.0, 0.5*kBoltDiameter, 0.5*kBoltDepth);
884
885   // Debug if requested
886   if (GetDebug(1)) {
887     cylindershape->InspectShape();
888     insertoshape->InspectShape();
889     flangeshape->InspectShape();
890     boltshape->InspectShape();
891   }
892
893
894   // We have the shapes: now create the real volumes
895
896   TGeoVolume *cfcylinder = new TGeoVolume("SDDCarbonFiberCylinder",
897                                           cylindershape,medSDDcf);
898   cfcylinder->SetVisibility(kTRUE);
899   cfcylinder->SetLineColor(4); // Blue
900   cfcylinder->SetLineWidth(1);
901   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
902   cfcylinder->SetFillStyle(4000); // 0% transparent
903
904   TGeoVolume *foamcylinder = new TGeoVolume("SDDFoamCylinder",
905                                             insertoshape,medSDDroh);
906   foamcylinder->SetVisibility(kTRUE);
907   foamcylinder->SetLineColor(3); // Green
908   foamcylinder->SetLineWidth(1);
909   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
910   foamcylinder->SetFillStyle(4050); // 50% transparent
911
912   TGeoVolume *flangecylinder = new TGeoVolume("SDDFlangeCylinder",
913                                               flangeshape,medSDDste);
914   flangecylinder->SetVisibility(kTRUE);
915   flangecylinder->SetLineColor(2); // Red
916   flangecylinder->SetLineWidth(1);
917   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
918   flangecylinder->SetFillStyle(4050); // 50% transparent
919
920   TGeoVolume *bolt = new TGeoVolume("SDDFlangeBolt",boltshape,medSDDss);
921   bolt->SetVisibility(kTRUE);
922   bolt->SetLineColor(1);  // Black
923   bolt->SetLineWidth(1);
924   bolt->SetFillColor(bolt->GetLineColor());
925   bolt->SetFillStyle(4050); // 50% transparent
926
927   // Mount up the cylinder
928   for(Int_t i=0; i<kNBolts; i++){
929     t = kThetaBolt*i;
930     x = kBoltRadius*CosD(t);
931     y = kBoltRadius*SinD(t);
932     z = kFlangeHalfLength-kBoltDepth;
933     flangecylinder->AddNode(bolt, i+1, new TGeoTranslation("",x,y,z));
934   }
935
936   cfcylinder->AddNode(foamcylinder,1,0);
937   cfcylinder->AddNode(flangecylinder,1,
938               new TGeoTranslation(0, 0, kInsertoHalfLength+kFlangeHalfLength));
939   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
940               0, 0, -kInsertoHalfLength-kFlangeHalfLength,
941               new TGeoRotation("",0,180,0)     ) );
942
943
944   // SDD Support Cone with its internal inserts: a carbon fiber Pcon
945   // with holes which contains a stesalite Pcon which on turn contains a
946   // rohacell Pcon
947
948   dza = kConeThickness/kSinConeTheta-(kConeROutMax-kConeROutMin)/kTanConeTheta;
949
950   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 10);
951
952   coneshape->Z(0)     = 0.0;
953   coneshape->Rmin(0)  = kConeROutMin;
954   coneshape->Rmax(0)  = kConeROutMax;
955
956   coneshape->Z(1)     = kConeZOuterMilled - dza;
957   coneshape->Rmin(1)  = coneshape->GetRmin(0);
958   coneshape->Rmax(1)  = coneshape->GetRmax(0);
959
960   coneshape->Z(2)     = kConeZOuterMilled;
961   coneshape->Rmax(2)  = coneshape->GetRmax(0);
962
963   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(1),
964                     coneshape->GetRmin(1),kConeTheta,z,rmin);
965   coneshape->Z(3)     = z;
966   coneshape->Rmin(3)  = rmin;
967
968   coneshape->Rmin(2)  = RminFrom2Points(coneshape,3,1,coneshape->GetZ(2));
969
970   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(2),
971                     coneshape->GetRmax(2),kConeTheta,z,rmax);
972   coneshape->Z(4)     = z;
973   coneshape->Rmax(4)  = rmax;
974   coneshape->Rmin(4)  = RminFromZpCone(coneshape,3,kConeTheta,
975                                        coneshape->GetZ(4),0.0);
976
977   coneshape->Rmax(3)  = RmaxFrom2Points(coneshape,4,2,coneshape->GetZ(3));
978
979   coneshape->Z(6)     = kConeZCylinder - kConeDZin;
980
981   RadiusOfCurvature(kConeRCurv,90.0,coneshape->GetZ(6),0.0,
982                     90.0-kConeTheta,z,rmin);
983   coneshape->Z(5)     = z;
984   coneshape->Rmin(5)  = RminFromZpCone(coneshape,3,kConeTheta,z);
985   coneshape->Rmax(5)  = RmaxFromZpCone(coneshape,4,kConeTheta,z);
986
987   RadiusOfCurvature(kConeRCurv,90.-kConeTheta,
988                     0.0,coneshape->Rmin(5),90.0,z,rmin);
989   coneshape->Rmin(6)  = rmin;
990   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,4,kConeTheta,
991                                        coneshape->GetZ(6));
992
993   coneshape->Z(7)     = coneshape->GetZ(6);
994   coneshape->Rmin(7)  = kConeRinMin;
995   coneshape->Rmax(7)  = coneshape->GetRmax(6);
996
997   coneshape->Rmin(8)  = kConeRinMin;
998
999   RadiusOfCurvature(kConeRCurv,90.0,kConeZCylinder,kConeRinCylinder,
1000                     90.0-kConeTheta,z,rmax);
1001   coneshape->Z(8)     = z;
1002   coneshape->Rmax(8)  = rmax;
1003
1004   coneshape->Z(9)     = kConeZCylinder;
1005   coneshape->Rmin(9)  = kConeRinMin;
1006   coneshape->Rmax(9)  = kConeRinCylinder;
1007
1008
1009   // SDD Cone Insert: another Pcon
1010   Double_t x0, y0, x1, y1, x2, y2;
1011   TGeoPcon *coneinsertshape = new TGeoPcon(0.0, 360.0, 9);
1012
1013   coneinsertshape->Z(0)    = coneshape->GetZ(0) + kConeCFThickness;
1014   coneinsertshape->Rmin(0) = coneshape->GetRmin(0) + kConeCFThickness;
1015   coneinsertshape->Rmax(0) = coneshape->GetRmax(0) - kConeCFThickness;
1016
1017   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1018   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1019   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1020   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1021   coneinsertshape->Z(1)    = z;
1022   coneinsertshape->Rmin(1) = rmin;
1023   coneinsertshape->Rmax(1) = coneinsertshape->GetRmax(0);
1024
1025   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmax(1);
1026   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmax(2);
1027   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmax(3);
1028   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1029   coneinsertshape->Z(2)    = z;
1030   coneinsertshape->Rmax(2) = rmax;
1031
1032   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1033   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1034   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1035   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1036   coneinsertshape->Z(3)    = z;
1037   coneinsertshape->Rmin(3) = rmin;
1038
1039   x0 = coneinsertshape->GetZ(1); y0 = coneinsertshape->GetRmin(1);
1040   x1 = coneinsertshape->GetZ(3); y1 = coneinsertshape->GetRmin(3);
1041   coneinsertshape->Rmin(2) = Yfrom2Points(x0, y0, x1, y1,
1042                                           coneinsertshape->Z(2));
1043
1044   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
1045   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
1046   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
1047   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1048   coneinsertshape->Z(4)    = z;
1049   coneinsertshape->Rmax(4) = rmax;
1050
1051   x0 = coneinsertshape->GetZ(2); y0 = coneinsertshape->GetRmax(2);
1052   x1 = coneinsertshape->GetZ(4); y1 = coneinsertshape->GetRmax(4);
1053   coneinsertshape->Rmax(3) = Yfrom2Points(x0, y0, x1, y1,
1054                                           coneinsertshape->Z(3));
1055
1056   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmin(4);
1057   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmin(5);
1058   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmin(6);
1059   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1060   coneinsertshape->Z(5)    = z;
1061   coneinsertshape->Rmin(5) = rmin;
1062   coneinsertshape->Rmax(5) = coneinsertshape->GetRmax(4) -
1063           kTanConeTheta*(coneinsertshape->GetZ(5) - coneinsertshape->GetZ(4));
1064
1065   x0 = coneinsertshape->GetZ(3); y0 = coneinsertshape->GetRmin(3);
1066   x1 = coneinsertshape->GetZ(5); y1 = coneinsertshape->GetRmin(5);
1067   coneinsertshape->Rmin(4) = Yfrom2Points(x0, y0, x1, y1,
1068                                           coneinsertshape->Z(4));
1069
1070   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmin(5);
1071   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmin(6);
1072   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmin(7);
1073   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1074   coneinsertshape->Z(6)    = z;
1075   coneinsertshape->Rmin(6) = rmin;
1076   coneinsertshape->Rmax(6) = coneinsertshape->GetRmax(4) -
1077           kTanConeTheta*(coneinsertshape->GetZ(6) - coneinsertshape->GetZ(4));
1078
1079   coneinsertshape->Z(7)    = coneinsertshape->GetZ(6);
1080   coneinsertshape->Rmin(7) = coneshape->GetRmin(7) + kConeCFThickness;
1081   coneinsertshape->Rmax(7) = coneinsertshape->GetRmax(6);
1082
1083   coneinsertshape->Z(8)    = coneshape->GetZ(9) - kConeCFThickness;
1084   coneinsertshape->Rmin(8) = coneinsertshape->GetRmin(7);
1085   coneinsertshape->Rmax(8) = coneinsertshape->GetRmax(4) -
1086           kTanConeTheta*(coneinsertshape->GetZ(8) - coneinsertshape->GetZ(4));
1087
1088   // SDD Cone Foam: another Pcon
1089   TGeoPcon *conefoamshape = new TGeoPcon(0.0, 360.0, 4);
1090
1091   RadiusOfCurvature(kConeRCurv+kConeCFThickness,0.0,coneinsertshape->GetZ(1),
1092                     coneinsertshape->GetRmin(1),kConeTheta,z,rmin);
1093
1094   conefoamshape->Z(0)    = z;
1095   conefoamshape->Rmin(0) = rmin;
1096   conefoamshape->Rmax(0) = conefoamshape->GetRmin(0);
1097
1098   conefoamshape->Z(1)    = conefoamshape->GetZ(0)+
1099                          (kConeThickness-2.0*kConeCFThickness)/kSinConeTheta;
1100   conefoamshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1101                                           conefoamshape->GetZ(1));
1102   conefoamshape->Rmax(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1103                                           conefoamshape->GetZ(1));
1104
1105   conefoamshape->Z(2)    = coneshape->GetZ(5)-kConeCFThickness;
1106   conefoamshape->Rmin(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1107                                           conefoamshape->GetZ(2));
1108   conefoamshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1109                                           conefoamshape->GetZ(2));
1110
1111   conefoamshape->Z(3)    = coneinsertshape->GetZ(5)+
1112                          (kConeThickness-2.0*kConeCFThickness)*kCosConeTheta;
1113   conefoamshape->Rmax(3) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1114                                           conefoamshape->GetZ(3));
1115   conefoamshape->Rmin(3) = conefoamshape->GetRmax(3);
1116
1117   // SDD Cone Holes: Pcon's
1118   // A single hole volume gives an overlap with coneinsert, so
1119   // three contiguous volumes are created: one to be put in the cone foam
1120   // and two in the cone carbon fiber envelope
1121   TGeoPcon *hole1shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1122
1123   hole1shape->Rmin(0) = kHole1RMax;
1124   hole1shape->Rmax(0) = hole1shape->GetRmin(0);
1125   hole1shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1126                                        hole1shape->GetRmin(0));
1127
1128   hole1shape->Rmax(1) = hole1shape->GetRmax(0);
1129   hole1shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1130                                        hole1shape->GetRmax(1));
1131   hole1shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1132                                        hole1shape->GetZ(1));
1133
1134   hole1shape->Rmin(2) = kHole1RMin;
1135   hole1shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1136                                        hole1shape->GetRmin(2));
1137   hole1shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1138                                        hole1shape->GetZ(2));
1139
1140   hole1shape->Rmin(3) = hole1shape->GetRmin(2);
1141   hole1shape->Rmax(3) = hole1shape->GetRmin(3);
1142   hole1shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1143                                        hole1shape->GetRmax(3));
1144
1145   TGeoPcon *hole11shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1146
1147   hole11shape->Rmin(0) = kHole1RMax;
1148   hole11shape->Rmax(0) = hole11shape->GetRmin(0);
1149   hole11shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1150                                         hole11shape->GetRmin(0));
1151
1152   hole11shape->Rmax(1) = hole11shape->GetRmax(0);
1153   hole11shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1154                                         hole11shape->GetRmax(1));
1155   hole11shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1156                                         hole11shape->GetZ(1));
1157
1158   hole11shape->Rmin(2) = kHole1RMin;
1159   hole11shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1160                                         hole11shape->GetRmin(2));
1161   hole11shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1162                                         hole11shape->GetZ(2));
1163
1164   hole11shape->Rmin(3) = hole11shape->GetRmin(2);
1165   hole11shape->Rmax(3) = hole11shape->GetRmin(3);
1166   hole11shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1167                                         hole11shape->GetRmax(3));
1168
1169   TGeoPcon *hole12shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1170
1171   hole12shape->Rmin(0) = kHole1RMax;
1172   hole12shape->Rmax(0) = hole12shape->GetRmin(0);
1173   hole12shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1174                                         hole12shape->GetRmin(0));
1175
1176   hole12shape->Rmax(1) = hole12shape->GetRmax(0);
1177   hole12shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1178                                         hole12shape->GetRmax(1));
1179   hole12shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1180                                         hole12shape->GetZ(1));
1181
1182   hole12shape->Rmin(2) = kHole1RMin;
1183   hole12shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1184                                         hole12shape->GetRmin(2));
1185   hole12shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1186                                         hole12shape->GetZ(2));
1187
1188   hole12shape->Rmin(3) = hole12shape->GetRmin(2);
1189   hole12shape->Rmax(3) = hole12shape->GetRmin(3);
1190   hole12shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1191                                         hole12shape->GetRmax(3));
1192
1193   //
1194   TGeoPcon *hole2shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1195
1196   hole2shape->Rmin(0) = kHole2RMax;
1197   hole2shape->Rmax(0) = hole2shape->GetRmin(0);
1198   hole2shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1199                                        hole2shape->GetRmin(0));
1200
1201   hole2shape->Rmax(1) = hole2shape->GetRmax(0);
1202   hole2shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1203                                        hole2shape->GetRmax(1));
1204   hole2shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1205                                        hole2shape->GetZ(1));
1206
1207   hole2shape->Rmin(2) = kHole2RMin;
1208   hole2shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1209                                        hole2shape->GetRmin(2));
1210   hole2shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1211                                        hole2shape->GetZ(2));
1212
1213   hole2shape->Rmin(3) = hole2shape->GetRmin(2);
1214   hole2shape->Rmax(3) = hole2shape->GetRmin(3);
1215   hole2shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1216                                        hole2shape->GetRmax(3));
1217
1218   TGeoPcon *hole21shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1219
1220   hole21shape->Rmin(0) = kHole2RMax;
1221   hole21shape->Rmax(0) = hole21shape->GetRmin(0);
1222   hole21shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1223                                         hole21shape->GetRmin(0));
1224
1225   hole21shape->Rmax(1) = hole21shape->GetRmax(0);
1226   hole21shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1227                                         hole21shape->GetRmax(1));
1228   hole21shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1229                                         hole21shape->GetZ(1));
1230
1231   hole21shape->Rmin(2) = kHole2RMin;
1232   hole21shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1233                                         hole21shape->GetRmin(2));
1234   hole21shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1235                                         hole21shape->GetZ(2));
1236
1237   hole21shape->Rmin(3) = hole21shape->GetRmin(2);
1238   hole21shape->Rmax(3) = hole21shape->GetRmin(3);
1239   hole21shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1240                                         hole21shape->GetRmax(3));
1241
1242   TGeoPcon *hole22shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1243
1244   hole22shape->Rmin(0) = kHole2RMax;
1245   hole22shape->Rmax(0) = hole22shape->GetRmin(0);
1246   hole22shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1247                                         hole22shape->GetRmin(0));
1248
1249   hole22shape->Rmax(1) = hole22shape->GetRmax(0);
1250   hole22shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1251                                         hole22shape->GetRmax(1));
1252   hole22shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1253                                         hole22shape->GetZ(1));
1254
1255   hole22shape->Rmin(2) = kHole2RMin;
1256   hole22shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1257                                         hole22shape->GetRmin(2));
1258   hole22shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1259                                         hole22shape->GetZ(2));
1260
1261   hole22shape->Rmin(3) = hole22shape->GetRmin(2);
1262   hole22shape->Rmax(3) = hole22shape->GetRmin(3);
1263   hole22shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1264                                         hole22shape->GetRmax(3));
1265
1266   //
1267   Double_t holePhi;
1268   holePhi = (kHole3Width/kHole3RMin)*TMath::RadToDeg();
1269
1270   TGeoPcon *hole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1271
1272   hole3shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1273   hole3shape->Rmax(0) = hole3shape->GetRmin(0);
1274   hole3shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1275                                        hole3shape->GetRmin(0));
1276
1277   hole3shape->Rmax(1) = hole3shape->GetRmax(0);
1278   hole3shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1279                                        hole3shape->GetRmax(1));
1280   hole3shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1281                                        hole3shape->GetZ(1));
1282
1283   hole3shape->Rmin(2) = kHole3RMin;
1284   hole3shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1285                                        hole3shape->GetRmin(2));
1286   hole3shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1287                                        hole3shape->GetZ(2));
1288
1289   hole3shape->Rmin(3) = hole3shape->GetRmin(2);
1290   hole3shape->Rmax(3) = hole3shape->GetRmin(3);
1291   hole3shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1292                                        hole3shape->GetRmax(3));
1293
1294   TGeoPcon *hole31shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1295
1296   hole31shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1297   hole31shape->Rmax(0) = hole31shape->GetRmin(0);
1298   hole31shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1299                                         hole31shape->GetRmin(0));
1300
1301   hole31shape->Rmax(1) = hole31shape->GetRmax(0);
1302   hole31shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1303                                         hole31shape->GetRmax(1));
1304   hole31shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1305                                         hole31shape->GetZ(1));
1306
1307   hole31shape->Rmin(2) = kHole3RMin;
1308   hole31shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1309                                         hole31shape->GetRmin(2));
1310   hole31shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1311                                         hole31shape->GetZ(2));
1312
1313   hole31shape->Rmin(3) = hole31shape->GetRmin(2);
1314   hole31shape->Rmax(3) = hole31shape->GetRmin(3);
1315   hole31shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1316                                         hole31shape->GetRmax(3));
1317
1318   TGeoPcon *hole32shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1319
1320   hole32shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1321   hole32shape->Rmax(0) = hole32shape->GetRmin(0);
1322   hole32shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1323                                         hole32shape->GetRmin(0));
1324
1325   hole32shape->Rmax(1) = hole32shape->GetRmax(0);
1326   hole32shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1327                                         hole32shape->GetRmax(1));
1328   hole32shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1329                                         hole32shape->GetZ(1));
1330
1331   hole32shape->Rmin(2) = kHole3RMin;
1332   hole32shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1333                                         hole32shape->GetRmin(2));
1334   hole32shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1335                                         hole32shape->GetZ(2));
1336
1337   hole32shape->Rmin(3) = hole32shape->GetRmin(2);
1338   hole32shape->Rmax(3) = hole32shape->GetRmin(3);
1339   hole32shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1340                                         hole32shape->GetRmax(3));
1341
1342   //
1343   holePhi = (kHole4Width/kHole4RMin)*TMath::RadToDeg();
1344
1345   TGeoPcon *hole4shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1346
1347   hole4shape->Rmin(0) = kHole4RMin + kHole4DeltaR;
1348   hole4shape->Rmax(0) = hole4shape->GetRmin(0);
1349   hole4shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1350                                        hole4shape->GetRmin(0));
1351
1352   hole4shape->Rmax(1) = hole4shape->GetRmax(0);
1353   hole4shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1354                                        hole4shape->GetRmax(1));
1355   hole4shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1356                                        hole4shape->GetZ(1));
1357
1358   hole4shape->Rmin(2) = kHole4RMin;
1359   hole4shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1360                                        hole4shape->GetRmin(2));
1361   hole4shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1362                                        hole4shape->GetZ(2));
1363
1364   hole4shape->Rmin(3) = hole4shape->GetRmin(2);
1365   hole4shape->Rmax(3) = hole4shape->GetRmin(3);
1366   hole4shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1367                                        hole4shape->GetRmax(3));
1368
1369   // Cables to be put inside the holes: Pcon's
1370   // (fractions are manually computed from AliITSv11GeometrySDD::SDDCables
1371   TGeoPcon *hole1plastshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1372
1373   hole1plastshape->Rmin(0) = hole1shape->GetRmin(0);
1374   hole1plastshape->Rmax(0) = hole1shape->GetRmax(0);
1375   hole1plastshape->Z(0)    = hole1shape->GetZ(0);
1376
1377   hole1plastshape->Rmin(1) = hole1shape->GetRmin(1);
1378   hole1plastshape->Rmax(1) = hole1shape->GetRmax(1);
1379   hole1plastshape->Z(1)    = hole1shape->GetZ(1);
1380
1381   dza = hole1plastshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHolePlasticFrac;
1382
1383   hole1plastshape->Rmin(2) = dza;
1384   hole1plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1385                                             hole1plastshape->GetRmin(2));
1386   hole1plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1387                                             hole1plastshape->GetZ(2));
1388
1389   hole1plastshape->Rmin(3) = hole1plastshape->GetRmin(2);
1390   hole1plastshape->Rmax(3) = hole1plastshape->GetRmin(3);
1391   hole1plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1392                                             hole1plastshape->GetRmax(3));
1393
1394   TGeoPcon *hole1Cushape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1395
1396   hole1Cushape->Rmin(0) = hole1plastshape->GetRmin(2);
1397   hole1Cushape->Rmax(0) = hole1Cushape->GetRmin(0);
1398   hole1Cushape->Z(0)    = hole1plastshape->GetZ(2);
1399
1400   dza = hole1Cushape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleCuFrac;
1401
1402   hole1Cushape->Rmin(1) = dza;
1403   hole1Cushape->Rmax(1) = hole1Cushape->GetRmax(0);
1404   hole1Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1405                                          hole1Cushape->GetRmin(1));
1406
1407   hole1Cushape->Rmax(2) = hole1Cushape->GetRmax(0);
1408   hole1Cushape->Rmin(2) = hole1Cushape->GetRmin(1);
1409   hole1Cushape->Z(2)    = hole1plastshape->GetZ(3);
1410
1411   hole1Cushape->Rmin(3) = hole1Cushape->GetRmin(1);
1412   hole1Cushape->Rmax(3) = hole1Cushape->GetRmin(3);
1413   hole1Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1414                                          hole1Cushape->GetRmax(3));
1415
1416   TGeoPcon *hole1glassshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1417
1418   hole1glassshape->Rmin(0) = hole1Cushape->GetRmin(1);
1419   hole1glassshape->Rmax(0) = hole1glassshape->GetRmin(0);
1420   hole1glassshape->Z(0)    = hole1Cushape->GetZ(1);
1421
1422   dza = hole1glassshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleGlassFrac;
1423
1424   hole1glassshape->Rmin(1) = dza;
1425   hole1glassshape->Rmax(1) = hole1glassshape->GetRmax(0);
1426   hole1glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1427                                             hole1glassshape->GetRmin(1));
1428
1429   hole1glassshape->Rmax(2) = hole1glassshape->GetRmax(0);
1430   hole1glassshape->Rmin(2) = hole1glassshape->GetRmin(1);
1431   hole1glassshape->Z(2)    = hole1Cushape->GetZ(3);
1432
1433   hole1glassshape->Rmin(3) = hole1glassshape->GetRmin(1);
1434   hole1glassshape->Rmax(3) = hole1glassshape->GetRmin(3);
1435   hole1glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1436                                             hole1glassshape->GetRmax(3));
1437   //
1438   TGeoPcon *hole2plastshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1439
1440   hole2plastshape->Rmin(0) = hole2shape->GetRmin(0);
1441   hole2plastshape->Rmax(0) = hole2shape->GetRmax(0);
1442   hole2plastshape->Z(0)    = hole2shape->GetZ(0);
1443
1444   hole2plastshape->Rmin(1) = hole2shape->GetRmin(1);
1445   hole2plastshape->Rmax(1) = hole2shape->GetRmax(1);
1446   hole2plastshape->Z(1)    = hole2shape->GetZ(1);
1447
1448   dza = hole2plastshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHolePlasticFrac;
1449
1450   hole2plastshape->Rmin(2) = dza;
1451   hole2plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1452                                             hole2plastshape->GetRmin(2));
1453   hole2plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1454                                             hole2plastshape->GetZ(2));
1455
1456   hole2plastshape->Rmin(3) = hole2plastshape->GetRmin(2);
1457   hole2plastshape->Rmax(3) = hole2plastshape->GetRmin(3);
1458   hole2plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1459                                             hole2plastshape->GetRmax(3));
1460
1461   TGeoPcon *hole2Cushape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1462
1463   hole2Cushape->Rmin(0) = hole2plastshape->GetRmin(2);
1464   hole2Cushape->Rmax(0) = hole2Cushape->GetRmin(0);
1465   hole2Cushape->Z(0)    = hole2plastshape->GetZ(2);
1466
1467   dza = hole2Cushape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleCuFrac;
1468
1469   hole2Cushape->Rmin(1) = dza;
1470   hole2Cushape->Rmax(1) = hole2Cushape->GetRmax(0);
1471   hole2Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1472                                          hole2Cushape->GetRmin(1));
1473
1474   hole2Cushape->Rmax(2) = hole2Cushape->GetRmax(0);
1475   hole2Cushape->Rmin(2) = hole2Cushape->GetRmin(1);
1476   hole2Cushape->Z(2)    = hole2plastshape->GetZ(3);
1477
1478   hole2Cushape->Rmin(3) = hole2Cushape->GetRmin(1);
1479   hole2Cushape->Rmax(3) = hole2Cushape->GetRmin(3);
1480   hole2Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1481                                          hole2Cushape->GetRmax(3));
1482
1483   TGeoPcon *hole2glassshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1484
1485   hole2glassshape->Rmin(0) = hole2Cushape->GetRmin(1);
1486   hole2glassshape->Rmax(0) = hole2glassshape->GetRmin(0);
1487   hole2glassshape->Z(0)    = hole2Cushape->GetZ(1);
1488
1489   dza = hole2glassshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleGlassFrac;
1490
1491   hole2glassshape->Rmin(1) = dza;
1492   hole2glassshape->Rmax(1) = hole2glassshape->GetRmax(0);
1493   hole2glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1494                                             hole2glassshape->GetRmin(1));
1495
1496   hole2glassshape->Rmax(2) = hole2glassshape->GetRmax(0);
1497   hole2glassshape->Rmin(2) = hole2glassshape->GetRmin(1);
1498   hole2glassshape->Z(2)    = hole2Cushape->GetZ(3);
1499
1500   hole2glassshape->Rmin(3) = hole2glassshape->GetRmin(1);
1501   hole2glassshape->Rmax(3) = hole2glassshape->GetRmin(3);
1502   hole2glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1503                                             hole2glassshape->GetRmax(3));
1504
1505
1506   // Debug if requested
1507   if (GetDebug(1)) {
1508     coneshape->InspectShape();
1509     coneinsertshape->InspectShape();
1510     conefoamshape->InspectShape();
1511     hole1shape->InspectShape();
1512     hole2shape->InspectShape();
1513     hole3shape->InspectShape();
1514     hole4shape->InspectShape();
1515   }
1516
1517
1518   // We have the shapes: now create the real volumes
1519
1520   TGeoVolume *cfcone = new TGeoVolume("SDDCarbonFiberCone",
1521                                       coneshape,medSDDcf);
1522   cfcone->SetVisibility(kTRUE);
1523   cfcone->SetLineColor(4); // Blue
1524   cfcone->SetLineWidth(1);
1525   cfcone->SetFillColor(cfcone->GetLineColor());
1526   cfcone->SetFillStyle(4000); // 0% transparent
1527
1528   TGeoVolume *cfconeinsert = new TGeoVolume("SDDCarbonFiberConeInsert",
1529                                             coneinsertshape,medSDDste);
1530   cfconeinsert->SetVisibility(kTRUE);
1531   cfconeinsert->SetLineColor(2); // Red
1532   cfconeinsert->SetLineWidth(1);
1533   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
1534   cfconeinsert->SetFillStyle(4050); // 50% transparent
1535
1536   TGeoVolume *cfconefoam = new TGeoVolume("SDDCarbonFiberConeFoam",
1537                                           conefoamshape,medSDDroh);
1538   cfconefoam->SetVisibility(kTRUE);
1539   cfconefoam->SetLineColor(7); // Light blue
1540   cfconefoam->SetLineWidth(1);
1541   cfconefoam->SetFillColor(cfconefoam->GetLineColor());
1542   cfconefoam->SetFillStyle(4050); // 50% transparent
1543
1544   TGeoVolume *hole1 = new TGeoVolume("SDDCableHole1",
1545                                      hole1shape,medSDDair);
1546   hole1->SetVisibility(kTRUE);
1547   hole1->SetLineColor(5); // Yellow
1548   hole1->SetLineWidth(1);
1549   hole1->SetFillColor(hole1->GetLineColor());
1550   hole1->SetFillStyle(4090); // 90% transparent
1551
1552   TGeoVolume *hole11 = new TGeoVolume("SDDCableHole11",
1553                                       hole11shape,medSDDair);
1554   hole11->SetVisibility(kTRUE);
1555   hole11->SetLineColor(5); // Yellow
1556   hole11->SetLineWidth(1);
1557   hole11->SetFillColor(hole11->GetLineColor());
1558   hole11->SetFillStyle(4090); // 90% transparent
1559
1560   TGeoVolume *hole12 = new TGeoVolume("SDDCableHole12",
1561                                       hole12shape,medSDDair);
1562   hole12->SetVisibility(kTRUE);
1563   hole12->SetLineColor(5); // Yellow
1564   hole12->SetLineWidth(1);
1565   hole12->SetFillColor(hole12->GetLineColor());
1566   hole12->SetFillStyle(4090); // 90% transparent
1567
1568   TGeoVolume *hole1plast = new TGeoVolume("SDDCableHole1Plast",
1569                                           hole1plastshape,medSDDplast);
1570   hole1plast->SetVisibility(kTRUE);
1571   hole1plast->SetLineColor(kBlue);
1572   hole1plast->SetLineWidth(1);
1573   hole1plast->SetFillColor(hole1plast->GetLineColor());
1574   hole1plast->SetFillStyle(4090); // 90% transparent
1575
1576   TGeoVolume *hole1Cu = new TGeoVolume("SDDCableHole1Cu",
1577                                        hole1Cushape,medSDDCu);
1578   hole1Cu->SetVisibility(kTRUE);
1579   hole1Cu->SetLineColor(kRed);
1580   hole1Cu->SetLineWidth(1);
1581   hole1Cu->SetFillColor(hole1Cu->GetLineColor());
1582   hole1Cu->SetFillStyle(4090); // 90% transparent
1583
1584   TGeoVolume *hole1glass = new TGeoVolume("SDDCableHole1glass",
1585                                           hole1glassshape,medSDDglass);
1586   hole1glass->SetVisibility(kTRUE);
1587   hole1glass->SetLineColor(kGreen);
1588   hole1glass->SetLineWidth(1);
1589   hole1glass->SetFillColor(hole1glass->GetLineColor());
1590   hole1glass->SetFillStyle(4090); // 90% transparent
1591
1592   TGeoVolume *hole2 = new TGeoVolume("SDDCableHole2",
1593                                      hole2shape,medSDDair);
1594   hole2->SetVisibility(kTRUE);
1595   hole2->SetLineColor(5); // Yellow
1596   hole2->SetLineWidth(1);
1597   hole2->SetFillColor(hole2->GetLineColor());
1598   hole2->SetFillStyle(4090); // 90% transparent
1599
1600   TGeoVolume *hole21 = new TGeoVolume("SDDCableHole21",
1601                                       hole21shape,medSDDair);
1602   hole21->SetVisibility(kTRUE);
1603   hole21->SetLineColor(5); // Yellow
1604   hole21->SetLineWidth(1);
1605   hole21->SetFillColor(hole21->GetLineColor());
1606   hole21->SetFillStyle(4090); // 90% transparent
1607
1608   TGeoVolume *hole22 = new TGeoVolume("SDDCableHole22",
1609                                       hole22shape,medSDDair);
1610   hole22->SetVisibility(kTRUE);
1611   hole22->SetLineColor(5); // Yellow
1612   hole22->SetLineWidth(1);
1613   hole22->SetFillColor(hole22->GetLineColor());
1614   hole22->SetFillStyle(4090); // 90% transparent
1615
1616   TGeoVolume *hole2plast = new TGeoVolume("SDDCableHole2Plast",
1617                                           hole2plastshape,medSDDplast);
1618   hole2plast->SetVisibility(kTRUE);
1619   hole2plast->SetLineColor(kBlue);
1620   hole2plast->SetLineWidth(1);
1621   hole2plast->SetFillColor(hole2plast->GetLineColor());
1622   hole2plast->SetFillStyle(4090); // 90% transparent
1623
1624   TGeoVolume *hole2Cu = new TGeoVolume("SDDCableHole2Cu",
1625                                        hole2Cushape,medSDDCu);
1626   hole2Cu->SetVisibility(kTRUE);
1627   hole2Cu->SetLineColor(kRed);
1628   hole2Cu->SetLineWidth(1);
1629   hole2Cu->SetFillColor(hole2Cu->GetLineColor());
1630   hole2Cu->SetFillStyle(4090); // 90% transparent
1631
1632   TGeoVolume *hole2glass = new TGeoVolume("SDDCableHole2glass",
1633                                           hole2glassshape,medSDDglass);
1634   hole2glass->SetVisibility(kTRUE);
1635   hole2glass->SetLineColor(kGreen);
1636   hole2glass->SetLineWidth(1);
1637   hole2glass->SetFillColor(hole2glass->GetLineColor());
1638   hole2glass->SetFillStyle(4090); // 90% transparent
1639
1640   TGeoVolume *hole3 = new TGeoVolume("SDDCableHole3",
1641                                      hole3shape,medSDDair);
1642   hole3->SetVisibility(kTRUE);
1643   hole3->SetLineColor(5); // Yellow
1644   hole3->SetLineWidth(1);
1645   hole3->SetFillColor(hole3->GetLineColor());
1646   hole3->SetFillStyle(4090); // 90% transparent
1647
1648   TGeoVolume *hole31 = new TGeoVolume("SDDCableHole31",
1649                                       hole31shape,medSDDair);
1650   hole31->SetVisibility(kTRUE);
1651   hole31->SetLineColor(5); // Yellow
1652   hole31->SetLineWidth(1);
1653   hole31->SetFillColor(hole31->GetLineColor());
1654   hole31->SetFillStyle(4090); // 90% transparent
1655
1656   TGeoVolume *hole32 = new TGeoVolume("SDDCableHole32",
1657                                       hole32shape,medSDDair);
1658   hole32->SetVisibility(kTRUE);
1659   hole32->SetLineColor(5); // Yellow
1660   hole32->SetLineWidth(1);
1661   hole32->SetFillColor(hole32->GetLineColor());
1662   hole32->SetFillStyle(4090); // 90% transparent
1663
1664   TGeoVolume *hole4 = new TGeoVolume("SDDCableHole4",
1665                                      hole4shape,medSDDair);
1666   hole4->SetVisibility(kTRUE);
1667   hole4->SetLineColor(5); // Yellow
1668   hole4->SetLineWidth(1);
1669   hole4->SetFillColor(hole4->GetLineColor());
1670   hole4->SetFillStyle(4090); // 90% transparent
1671
1672   // Mount up a cone
1673   cfconeinsert->AddNode(cfconefoam,1,0);
1674
1675   hole1->AddNode(hole1plast, 1, 0);
1676   hole1->AddNode(hole1Cu, 1, 0);
1677   hole1->AddNode(hole1glass, 1, 0);
1678
1679   hole2->AddNode(hole2plast, 1, 0);
1680   hole2->AddNode(hole2Cu, 1, 0);
1681   hole2->AddNode(hole2glass, 1, 0);
1682
1683   for (Int_t i=0; i<12; i++) {
1684     Double_t phiH = i*30.0;
1685     cfconefoam->AddNode(hole1 , i+1, new TGeoRotation("", 0, 0, phiH));
1686         cfcone->AddNode(hole11, i+1, new TGeoRotation("", 0, 0, phiH));
1687         cfcone->AddNode(hole12, i+1, new TGeoRotation("", 0, 0, phiH));
1688   }
1689
1690   for (Int_t i=0; i<6; i++) {
1691     Double_t phiH = i*60.0;
1692     cfconefoam->AddNode(hole2 , i+1, new TGeoRotation("", 0, 0, phiH));
1693         cfcone->AddNode(hole21, i+1, new TGeoRotation("", 0, 0, phiH));
1694         cfcone->AddNode(hole22, i+1, new TGeoRotation("", 0, 0, phiH));
1695   }
1696
1697   for (Int_t i=0; i<kNHole3; i++) {
1698     Double_t phiH0 = 360./(Double_t)kNHole3;
1699     Double_t phiH  = i*phiH0 + 0.5*phiH0;
1700     cfconefoam->AddNode(hole3 , i+1, new TGeoRotation("", phiH, 0, 0));
1701         cfcone->AddNode(hole31, i+1, new TGeoRotation("", phiH, 0, 0));
1702         cfcone->AddNode(hole32, i+1, new TGeoRotation("", phiH, 0, 0));
1703   }
1704
1705   cfcone->AddNode(cfconeinsert,1,0);
1706
1707 /*
1708   for (Int_t i=0; i<kNHole4; i++) {
1709     Double_t phiH0 = 360./(Double_t)kNHole4;
1710     Double_t phiH  = i*phiH0 + 0.25*phiH0;
1711     cfcone->AddNode(hole4, i+1, new TGeoRotation("", phiH, 0, 0));
1712   }
1713 */
1714   // Finally put everything in the mother volume
1715   moth->AddNode(cfcylinder,1,0);
1716
1717   z = coneshape->Z(9);
1718   moth->AddNode(cfcone,1,new TGeoTranslation(0, 0, -z - kCylinderHalfLength));
1719   moth->AddNode(cfcone,2,new TGeoCombiTrans (0, 0,  z + kCylinderHalfLength,
1720                          new TGeoRotation("", 0, 180, 0)                   ));
1721
1722
1723   return;
1724 }
1725
1726 //______________________________________________________________________
1727 void AliITSv11GeometrySupport::SSDCone(TGeoVolume *moth,TGeoManager *mgr)
1728 {
1729 //
1730 // Creates the SSD support cone and cylinder geometry. as a
1731 // volume assembly and adds it to the mother volume
1732 // (part of this code is taken or anyway inspired to SSDCone method
1733 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
1734 //
1735 // Input:
1736 //         moth : the TGeoVolume owing the volume structure
1737 //         mgr  : the GeoManager (default gGeoManager)
1738 // Output:
1739 //
1740 // Created:         ???       Bjorn S. Nilsen
1741 // Updated:      08 Mar 2008  Mario Sitta
1742 //
1743 // Technical data are taken from:  "ITS Supporto Generale" (technical
1744 // drawings ALR3-0743/1, ALR3-0743/1A and ALR3-0743/1B), "Supporto Generale
1745 // Settore SSD" (technical drawings ALR3-0743/2A and ALR3-0743/2E), private
1746 // communication with B. Giraudo
1747 //
1748 // Updated:      11 Apr 2008  Mario Sitta
1749 // Measures from drawings give overlaps with SPD thermal shield wings,
1750 // so the terminal part of the SSD cone was reduced
1751 //
1752 // Updated:      30 Mar 2010  Mario Sitta
1753 // Following M. van Leeuwen's suggestion on material budget, the thickness
1754 // of the carbon fiber cylinder was increased from 0.6 to 0.625mm
1755
1756   // Dimensions of the Central cylinder and flanges
1757   const Double_t kCylinderHalfLength   = (1144.0/2) *fgkmm;
1758   const Double_t kCylinderOuterRadius  = ( 595.0/2) *fgkmm;
1759   const Double_t kCylinderThickness    =       0.625*fgkmm;
1760   const Double_t kFoamHalfLength       = (1020.0/2) *fgkmm;
1761   const Double_t kFoamThickness        =        5.0 *fgkmm;
1762   const Double_t kFlangeHalfLength     =
1763                                       (kCylinderHalfLength-kFoamHalfLength)/2.;
1764   const Double_t kFlangeInnerRadius    = ( 563.0/2) *fgkmm;
1765   // Dimensions of the Cone
1766   const Double_t kConeROuterMin        = ( 957.0/2) *fgkmm;
1767   const Double_t kConeROuterMax        = ( 997.0/2) *fgkmm;
1768   const Double_t kConeRInnerMin        = ( 564.0/2) *fgkmm;
1769   const Double_t kConeRCurv1           =       10.0 *fgkmm;
1770   const Double_t kConeRCurv2           =       25.0 *fgkmm;
1771   const Double_t kConeCent1RCurv2      = ( 578.0/2) *fgkmm;
1772   const Double_t kConeCent2RCurv2      = ( 592.0/2) *fgkmm;
1773 //  const Double_t kConeZOuterRing       =       47.0 *fgkmm;
1774 //  const Double_t kConeZOuterRingInside =       30.25*fgkmm;
1775 //  const Double_t kConeZInnerRing       =      161.5 *fgkmm;
1776 //  const Double_t kConeZLength          =      176.5 *fgkmm;
1777   const Double_t kConeZOuterRing       =       38.5 *fgkmm;
1778   const Double_t kConeZOuterRingInside =       22.2 *fgkmm;
1779   const Double_t kConeZInnerRing       =      153.0 *fgkmm;
1780   const Double_t kConeZLength          =      168.0 *fgkmm;
1781   const Double_t kConeZPosition        = kConeZLength + kCylinderHalfLength;
1782   const Double_t kConeThickness        =       13.0 *fgkmm; // Cone thickness
1783   const Double_t kConeTheta            =       39.1 *fgkDegree; // Cone angle
1784   const Double_t kSinConeTheta         =
1785                                       TMath::Sin(kConeTheta*TMath::DegToRad());
1786   const Double_t kCosConeTheta         =
1787                                       TMath::Cos(kConeTheta*TMath::DegToRad());
1788   // Dimensions of the Foam cores
1789   const Double_t kConeFoam1Length      =      112.3 *fgkmm;
1790   const Double_t kConeFoam2Length      =       58.4 *fgkmm;
1791   // Dimensions of the Cone Holes
1792   const Double_t kCoolingHoleWidth     =       40.0 *fgkmm;
1793   const Double_t kCoolingHoleHight     =       30.0 *fgkmm;
1794   const Double_t kCoolingHoleRmin      =      350.0 *fgkmm;
1795   const Double_t kCoolingHolePhi       =       45.0 *fgkDegree;
1796   const Double_t kMountingHoleWidth    =       20.0 *fgkmm;
1797   const Double_t kMountingHoleHight    =       20.0 *fgkmm;
1798   const Double_t kMountingHoleRmin     =      317.5 *fgkmm;
1799   const Double_t kMountingHolePhi      =       60.0 *fgkDegree;
1800   const Double_t kCableHoleRin         = ( 800.0/2) *fgkmm;
1801   const Double_t kCableHoleRout        = ( 920.0/2) *fgkmm;
1802   const Double_t kCableHoleWidth       =      200.0 *fgkmm;
1803 //  const Double_t kCableHoleAngle       =       42.0 *fgkDegree;
1804   // Dimensions of the Cone Wings
1805   const Double_t kWingRmax             =      527.5 *fgkmm;
1806   const Double_t kWingWidth            =       70.0 *fgkmm;
1807   const Double_t kWingHalfThick        = (  10.0/2) *fgkmm;
1808   const Double_t kThetaWing            =       45.0 *fgkDegree;
1809   // Dimensions of the SSD-SDD Mounting Brackets
1810   const Double_t kBracketRmin          = ( 541.0/2) *fgkmm;// See SDD ROutMin
1811   const Double_t kBracketRmax          = ( 585.0/2) *fgkmm;
1812   const Double_t kBracketHalfLength    = (   4.0/2) *fgkmm;
1813   const Double_t kBracketPhi           = (70.*fgkmm/kBracketRmax)*fgkRadian;
1814   // Common data
1815   const Double_t kCFThickness          =        0.75*fgkmm; //Carb. fib. thick.
1816
1817
1818   // Local variables
1819   Double_t rmin1, rmin2, rmax, z;
1820
1821   //
1822   //Begin_Html
1823   /*
1824     <img src="picts/ITS/file_name.gif">
1825     <P>
1826     <FONT FACE'"TIMES">
1827     ITS SSD central support and thermal shield cylinder.
1828     </FONT>
1829     </P>
1830   */
1831   //End_Html
1832   //
1833
1834   // Central cylinder with its internal foam and the lateral flanges:
1835   // a carbon fiber Pcon which contains a rohacell Tube and two
1836   // stesalite Cone's
1837   TGeoPcon *externalcylshape = new TGeoPcon(0,360,4);
1838
1839   rmax  = kCylinderOuterRadius;
1840   rmin1 = kFlangeInnerRadius - kCylinderThickness;
1841   rmin2 = rmax - 2*kCylinderThickness - kFoamThickness;
1842   externalcylshape->DefineSection(0,-kCylinderHalfLength,rmin1,rmax);
1843   externalcylshape->DefineSection(1,-kFoamHalfLength    ,rmin2,rmax);
1844   externalcylshape->DefineSection(2, kFoamHalfLength    ,rmin2,rmax);
1845   externalcylshape->DefineSection(3, kCylinderHalfLength,rmin1,rmax);
1846
1847   rmax  = kCylinderOuterRadius - kCylinderThickness;
1848   rmin1 = rmax - kFoamThickness;
1849   TGeoTube *foamshape = new TGeoTube(rmin1,rmax,kFoamHalfLength);
1850
1851   rmax  = kCylinderOuterRadius - kCylinderThickness;
1852   rmin1 = rmax - kFoamThickness;
1853   rmin2 = kFlangeInnerRadius;
1854   TGeoCone *flangeshape = new TGeoCone(kFlangeHalfLength,
1855                                        rmin1,rmax,rmin2,rmax);
1856
1857
1858   // We have the shapes: now create the real volumes
1859
1860   TGeoMedium *medSSDcf  = mgr->GetMedium("ITS_SSD C (M55J)$");
1861   TGeoMedium *medSSDair = mgr->GetMedium("ITS_SSD AIR$");
1862   TGeoMedium *medSSDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
1863   TGeoMedium *medSSDroh = mgr->GetMedium("ITS_ROHACELL$");
1864   TGeoMedium *medSSDal  = mgr->GetMedium("ITS_ALUMINUM$");
1865
1866   TGeoVolume *cfcylinder = new TGeoVolume("SSDexternalcylinder",
1867                                            externalcylshape,medSSDcf);
1868   cfcylinder->SetVisibility(kTRUE);
1869   cfcylinder->SetLineColor(4); // blue
1870   cfcylinder->SetLineWidth(1);
1871   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
1872   cfcylinder->SetFillStyle(4000); // 0% transparent
1873
1874   TGeoVolume *foamcylinder = new TGeoVolume("SSDfoamcylinder",
1875                                             foamshape,medSSDroh);
1876   foamcylinder->SetVisibility(kTRUE);
1877   foamcylinder->SetLineColor(3); // green
1878   foamcylinder->SetLineWidth(1);
1879   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
1880   foamcylinder->SetFillStyle(4050); // 50% transparent
1881
1882   TGeoVolume *flangecylinder = new TGeoVolume("SSDflangecylinder",
1883                                               flangeshape,medSSDste);
1884   flangecylinder->SetVisibility(kTRUE);
1885   flangecylinder->SetLineColor(2); // red
1886   flangecylinder->SetLineWidth(1);
1887   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
1888   flangecylinder->SetFillStyle(4050); // 50% transparent
1889
1890   // Mount up the cylinder
1891   cfcylinder->AddNode(foamcylinder,1,0);
1892   cfcylinder->AddNode(flangecylinder,1,
1893               new TGeoTranslation(0, 0, kFoamHalfLength+kFlangeHalfLength));
1894   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
1895               0, 0, -kFoamHalfLength-kFlangeHalfLength,
1896               new TGeoRotation("",0,180,0)     ) );
1897
1898
1899   // The whole Cone as an assembly
1900   TGeoVolumeAssembly *vC = new TGeoVolumeAssembly("ITSssdCone");
1901
1902
1903   // SSD Support Cone with its internal inserts: a carbon fiber Pcon
1904   // with holes which contains a stesalite Pcon which on turn contains a
1905   // rohacell Pcon
1906   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 12);
1907
1908   coneshape->Z(0)     = 0.0;
1909   coneshape->Rmin(0)  = kConeROuterMin;
1910   coneshape->Rmax(0)  = kConeROuterMax;
1911
1912   coneshape->Z(1)     = kConeZOuterRingInside - kConeRCurv1;
1913   coneshape->Rmin(1)  = coneshape->GetRmin(0);
1914   coneshape->Rmax(1)  = coneshape->GetRmax(0);
1915
1916   coneshape->Z(2)     = kConeZOuterRingInside;
1917   coneshape->Rmin(2)  = coneshape->GetRmin(1) - kConeRCurv1;
1918   coneshape->Rmax(2)  = coneshape->GetRmax(0);
1919
1920   coneshape->Z(3)     = coneshape->GetZ(2);
1921   coneshape->Rmax(3)  = coneshape->GetRmax(0);
1922
1923   coneshape->Z(4)     = kConeZOuterRing - kConeRCurv1;
1924   coneshape->Rmax(4)  = coneshape->GetRmax(0);
1925
1926   coneshape->Z(5)     = kConeZOuterRing;
1927   coneshape->Rmax(5)  = coneshape->GetRmax(4) - kConeRCurv1;
1928
1929   coneshape->Z(6)     = coneshape->GetZ(5);
1930
1931   RadiusOfCurvature(kConeRCurv2,90.0,kConeZInnerRing,kConeCent1RCurv2,
1932                     90.0-kConeTheta,z,rmin1);
1933   coneshape->Z(7)     = z;
1934   coneshape->Rmin(7)  = rmin1;
1935
1936   coneshape->Rmin(3)  = RminFromZpCone(coneshape,7,90.-kConeTheta,
1937                                        coneshape->GetZ(3));
1938
1939   coneshape->Rmin(4)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(4));
1940
1941   coneshape->Rmin(5)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(5));
1942
1943   coneshape->Rmin(6) = coneshape->GetRmin(5);
1944
1945   coneshape->Z(8)     = kConeZInnerRing;
1946   coneshape->Rmin(8)  = kConeCent1RCurv2;
1947
1948   coneshape->Z(9)     = coneshape->GetZ(8);
1949   coneshape->Rmin(9)  = kConeRInnerMin;
1950
1951   RadiusOfCurvature(kConeRCurv2,90.0,kConeZLength,kConeCent2RCurv2,
1952                     90.0-kConeTheta,z,rmax);
1953
1954   coneshape->Z(10)    = z;
1955   coneshape->Rmin(10) = coneshape->GetRmin(9);
1956   coneshape->Rmax(10) = rmax;
1957
1958   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,10,90.-kConeTheta,
1959                                        coneshape->GetZ(6));
1960
1961   coneshape->Rmax(7)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(7));
1962
1963   coneshape->Rmax(8)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(8));
1964
1965   coneshape->Rmax(9)  = coneshape->GetRmax(8);
1966
1967   coneshape->Z(11)    = kConeZLength;
1968   coneshape->Rmin(11) = coneshape->GetRmin(10);
1969   coneshape->Rmax(11) = kConeCent2RCurv2;
1970
1971   // SSD Cone Insert: another Pcon
1972   Double_t x0, y0, x1, y1, x2, y2;
1973   TGeoPcon *coneinsertshape = new TGeoPcon(0.0,360.0,12);
1974
1975   coneinsertshape->Z(0)     = coneshape->GetZ(0) + kCFThickness;
1976   coneinsertshape->Rmin(0)  = coneshape->GetRmin(0) + kCFThickness;
1977   coneinsertshape->Rmax(0)  = coneshape->GetRmax(0) - kCFThickness;
1978
1979   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1980   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1981   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1982   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1983   coneinsertshape->Z(1)     = z;
1984   coneinsertshape->Rmin(1)  = rmin1;
1985   coneinsertshape->Rmax(1)  = coneinsertshape->GetRmax(0);
1986
1987   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmin(1);
1988   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmin(2);
1989   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmin(3);
1990   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1991   coneinsertshape->Z(2)     = z;
1992   coneinsertshape->Rmin(2)  = rmin1;
1993   coneinsertshape->Rmax(2)  = coneinsertshape->GetRmax(1);
1994
1995   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1996   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1997   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1998   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1999   coneinsertshape->Z(3)     = z;
2000   coneinsertshape->Rmin(3)  = rmin1;
2001   coneinsertshape->Rmax(3)  = coneinsertshape->GetRmax(2);
2002
2003   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
2004   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
2005   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
2006   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2007   coneinsertshape->Z(4)     = z;
2008   coneinsertshape->Rmax(4)  = rmax;
2009
2010   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmax(4);
2011   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmax(5);
2012   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmax(6);
2013   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2014   coneinsertshape->Z(5)     = z;
2015   coneinsertshape->Rmax(5)  = rmax;
2016
2017   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmax(5);
2018   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmax(6);
2019   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmax(7);
2020   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2021   coneinsertshape->Z(6)     = z;
2022   coneinsertshape->Rmax(6)  = rmax;
2023
2024   x0 = coneshape->GetZ(6); y0 = coneshape->GetRmin(6);
2025   x1 = coneshape->GetZ(7); y1 = coneshape->GetRmin(7);
2026   x2 = coneshape->GetZ(8); y2 = coneshape->GetRmin(8);
2027   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2028   coneinsertshape->Z(7)     = z;
2029   coneinsertshape->Rmin(7)  = rmin1;
2030
2031   coneinsertshape->Rmin(4)  = RminFrom2Points(coneinsertshape,3,7,
2032                                               coneinsertshape->GetZ(4));
2033
2034   coneinsertshape->Rmin(5)  = RminFrom2Points(coneinsertshape,3,7,
2035                                               coneinsertshape->GetZ(5));
2036
2037   coneinsertshape->Rmin(6)  = coneinsertshape->GetRmin(5);
2038
2039   x0 = coneshape->GetZ(7); y0 = coneshape->GetRmin(7);
2040   x1 = coneshape->GetZ(8); y1 = coneshape->GetRmin(8);
2041   x2 = coneshape->GetZ(9); y2 = coneshape->GetRmin(9);
2042   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2043   coneinsertshape->Z(8)     = z;
2044   coneinsertshape->Rmin(8)  = rmin1;
2045
2046   x0 = coneshape->GetZ( 8); y0 = coneshape->GetRmin( 8);
2047   x1 = coneshape->GetZ( 9); y1 = coneshape->GetRmin( 9);
2048   x2 = coneshape->GetZ(10); y2 = coneshape->GetRmin(10);
2049   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2050   coneinsertshape->Z(9)     = z;
2051   coneinsertshape->Rmin(9)  = rmin1;
2052
2053   x0 = coneshape->GetZ( 9); y0 = coneshape->GetRmax( 9);
2054   x1 = coneshape->GetZ(10); y1 = coneshape->GetRmax(10);
2055   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmax(11);
2056   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2057   coneinsertshape->Z(10)    = z;
2058   coneinsertshape->Rmax(10) = rmax;
2059   coneinsertshape->Rmin(10) = coneinsertshape->GetRmin(9);
2060
2061   coneinsertshape->Rmax(7)  = RmaxFrom2Points(coneinsertshape,6,10,
2062                                               coneinsertshape->GetZ(7));
2063
2064   coneinsertshape->Rmax(8)  = RmaxFrom2Points(coneinsertshape,6,10,
2065                                               coneinsertshape->GetZ(8));
2066
2067   coneinsertshape->Rmax(9)  = coneinsertshape->GetRmax(8);
2068
2069   x0 = coneshape->GetZ(10); y0 = coneshape->GetRmax(10);
2070   x1 = coneshape->GetZ(11); y1 = coneshape->GetRmax(11);
2071   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmin(11);
2072   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2073   coneinsertshape->Z(11)    = z;
2074   coneinsertshape->Rmax(11) = rmax;
2075   coneinsertshape->Rmin(11) = coneinsertshape->GetRmin(10);
2076
2077   // SSD Cone Foams: two other Pcon's
2078   TGeoPcon *conefoam1shape = new TGeoPcon(0.0, 360.0, 4);
2079
2080   conefoam1shape->Z(0)    = coneinsertshape->GetZ(3);
2081   conefoam1shape->Rmin(0) = coneinsertshape->GetRmin(3);
2082   conefoam1shape->Rmax(0) = conefoam1shape->GetRmin(0);
2083
2084   conefoam1shape->Rmax(1) = conefoam1shape->GetRmax(0);
2085   conefoam1shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2086                                            conefoam1shape->GetRmax(1));
2087   conefoam1shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2088                                            conefoam1shape->GetZ(1));
2089
2090   Double_t t = kConeThickness - 2*kCFThickness;
2091   conefoam1shape->Rmin(2) = conefoam1shape->GetRmax(0) -
2092                            (kConeFoam1Length*kCosConeTheta - t*kSinConeTheta);
2093   conefoam1shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2094                                            conefoam1shape->GetRmin(2));
2095   conefoam1shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2096                                            conefoam1shape->GetZ(2));
2097
2098   conefoam1shape->Rmin(3) = conefoam1shape->GetRmin(2);
2099   conefoam1shape->Rmax(3) = conefoam1shape->GetRmin(3);
2100   conefoam1shape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2101                                            conefoam1shape->GetRmax(3));
2102
2103   TGeoPcon *conefoam2shape = new TGeoPcon(0.0, 360.0, 4);
2104
2105   conefoam2shape->Z(3)    = coneinsertshape->GetZ(10);
2106   conefoam2shape->Rmin(3) = coneinsertshape->GetRmax(10);
2107   conefoam2shape->Rmax(3) = conefoam2shape->GetRmin(3);
2108
2109   conefoam2shape->Rmin(2) = conefoam2shape->GetRmin(3);
2110   conefoam2shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2111                                            conefoam2shape->GetRmin(2));
2112   conefoam2shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2113                                            conefoam2shape->GetZ(2));
2114
2115   conefoam2shape->Rmin(0) = conefoam2shape->GetRmax(2) +
2116                            (kConeFoam2Length*kCosConeTheta - t*kSinConeTheta);
2117   conefoam2shape->Rmax(0) = conefoam2shape->GetRmin(0);
2118   conefoam2shape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2119                                            conefoam2shape->GetRmin(0));
2120
2121   conefoam2shape->Rmax(1) = conefoam2shape->GetRmax(0);
2122   conefoam2shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2123                                            conefoam2shape->GetRmax(1));
2124   conefoam2shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2125                                            conefoam2shape->GetZ(1));
2126
2127   // SSD Cone Holes: Pcon's
2128   // A single hole volume gives an overlap with coneinsert, so
2129   // three contiguous volumes are created: one to be put in coneinsert
2130   // and two in the cone carbon fiber envelope
2131   Double_t holePhi;
2132   holePhi = (kCoolingHoleWidth/kCoolingHoleRmin)*TMath::RadToDeg();
2133
2134   TGeoPcon *coolingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2135
2136   coolingholeshape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2137   coolingholeshape->Rmax(0) = coolingholeshape->GetRmin(0);
2138   coolingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2139                                              coolingholeshape->GetRmin(0));
2140
2141   coolingholeshape->Rmax(1) = coolingholeshape->GetRmax(0);
2142   coolingholeshape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2143                                              coolingholeshape->GetRmax(1));
2144   coolingholeshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2145                                              coolingholeshape->GetZ(1));
2146
2147   coolingholeshape->Rmin(2) = kCoolingHoleRmin;
2148   coolingholeshape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2149                                              coolingholeshape->GetRmin(2));
2150   coolingholeshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2151                                              coolingholeshape->GetZ(2));
2152
2153   coolingholeshape->Rmin(3) = coolingholeshape->GetRmin(2);
2154   coolingholeshape->Rmax(3) = coolingholeshape->GetRmin(3);
2155   coolingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2156                                              coolingholeshape->GetRmax(3));
2157
2158   TGeoPcon *coolinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2159
2160   coolinghole2shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2161   coolinghole2shape->Rmax(0) = coolinghole2shape->GetRmin(0);
2162   coolinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2163                                               coolinghole2shape->GetRmin(0));
2164
2165   coolinghole2shape->Rmax(1) = coolinghole2shape->GetRmax(0);
2166   coolinghole2shape->Z(1)    = coolingholeshape->GetZ(0);
2167   coolinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2168                                               coolinghole2shape->GetZ(1));
2169
2170   coolinghole2shape->Rmin(2) = kCoolingHoleRmin;
2171   coolinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2172                                               coolinghole2shape->GetRmin(2));
2173   coolinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2174                                               coolinghole2shape->GetZ(2));
2175
2176   coolinghole2shape->Rmin(3) = coolinghole2shape->GetRmin(2);
2177   coolinghole2shape->Rmax(3) = coolinghole2shape->GetRmin(3);
2178   coolinghole2shape->Z(3)    = coolingholeshape->GetZ(2);
2179
2180   TGeoPcon *coolinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2181
2182   coolinghole3shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2183   coolinghole3shape->Rmax(0) = coolinghole3shape->GetRmin(0);
2184   coolinghole3shape->Z(0)    = coolingholeshape->GetZ(1);
2185
2186   coolinghole3shape->Rmax(1) = coolinghole3shape->GetRmax(0);
2187   coolinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2188                                               coolinghole3shape->GetRmax(1));
2189   coolinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2190                                               coolinghole3shape->GetZ(1));
2191
2192   coolinghole3shape->Rmin(2) = kCoolingHoleRmin;
2193   coolinghole3shape->Z(2)    = coolingholeshape->GetZ(3);
2194   coolinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2195                                               coolinghole3shape->GetZ(2));
2196
2197   coolinghole3shape->Rmin(3) = coolinghole3shape->GetRmin(2);
2198   coolinghole3shape->Rmax(3) = coolinghole3shape->GetRmin(3);
2199   coolinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2200                                               coolinghole3shape->GetRmax(3));
2201
2202   //
2203   holePhi = (kMountingHoleWidth/kMountingHoleRmin)*TMath::RadToDeg();
2204
2205   TGeoPcon *mountingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2206
2207   mountingholeshape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2208   mountingholeshape->Rmax(0) = mountingholeshape->GetRmin(0);
2209   mountingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2210                                               mountingholeshape->GetRmin(0));
2211
2212   mountingholeshape->Rmin(1) = kMountingHoleRmin;
2213   mountingholeshape->Rmax(1) = mountingholeshape->GetRmax(0);
2214   mountingholeshape->Z(1)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2215                                               mountingholeshape->GetRmin(1));
2216
2217   mountingholeshape->Rmin(2) = mountingholeshape->GetRmin(1);
2218   mountingholeshape->Rmax(2) = mountingholeshape->GetRmax(1);
2219   mountingholeshape->Z(2)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2220                                               mountingholeshape->GetRmax(2));
2221
2222   mountingholeshape->Rmin(3) = mountingholeshape->GetRmin(2);
2223   mountingholeshape->Rmax(3) = mountingholeshape->GetRmin(3);
2224   mountingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2225                                               mountingholeshape->GetRmax(3));
2226
2227   TGeoPcon *mountinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2228
2229   mountinghole2shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2230   mountinghole2shape->Rmax(0) = mountingholeshape->GetRmin(0);
2231   mountinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2232                                                mountinghole2shape->GetRmin(0));
2233
2234   mountinghole2shape->Rmax(1) = mountinghole2shape->GetRmax(0);
2235   mountinghole2shape->Z(1)    = mountingholeshape->Z(0);
2236   mountinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2237                                                mountinghole2shape->GetZ(1));
2238
2239   mountinghole2shape->Rmin(2) = kMountingHoleRmin;
2240   mountinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2241                                                mountinghole2shape->GetRmin(2));
2242   mountinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2243                                                mountinghole2shape->GetZ(2));
2244
2245   mountinghole2shape->Rmin(3) = mountinghole2shape->Rmin(2);
2246   mountinghole2shape->Rmax(3) = mountinghole2shape->Rmin(3);
2247   mountinghole2shape->Z(3)    = mountingholeshape->Z(1);
2248
2249   TGeoPcon *mountinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2250
2251   mountinghole3shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2252   mountinghole3shape->Rmax(0) = mountingholeshape->GetRmin(0);
2253   mountinghole3shape->Z(0)    = mountingholeshape->GetZ(2);
2254
2255   mountinghole3shape->Rmax(1) = mountinghole3shape->GetRmax(0);
2256   mountinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2257                                                mountinghole3shape->GetRmax(1));
2258   mountinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2259                                                mountinghole3shape->GetZ(1));
2260
2261   mountinghole3shape->Rmin(2) = kMountingHoleRmin;
2262   mountinghole3shape->Z(2)    = mountingholeshape->Z(3);
2263   mountinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2264                                                mountinghole3shape->GetZ(2));
2265
2266   mountinghole3shape->Rmin(3) = mountinghole3shape->Rmin(2);
2267   mountinghole3shape->Rmax(3) = mountinghole3shape->Rmin(3);
2268   mountinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2269                                                mountinghole3shape->GetRmax(3));
2270
2271   // The Cable Hole is even more complicated, a Composite Shape
2272   // is unavoidable here (gosh!)
2273   TGeoPcon *coneshapecopy = new TGeoPcon("conecopy",0.0, 360.0, 12);
2274
2275   for (Int_t i=0; i<12; i++) {
2276     coneshapecopy->Rmin(i) = coneshape->GetRmin(i);
2277     coneshapecopy->Rmax(i) = coneshape->GetRmax(i);
2278     coneshapecopy->Z(i)    = coneshape->GetZ(i);
2279   }
2280
2281   holePhi = (kCableHoleWidth/kCableHoleRout)*TMath::RadToDeg();
2282   TGeoConeSeg *chCS = new TGeoConeSeg("chCS", 0.5*kConeZLength,
2283                                       kCableHoleRin, kCableHoleRout,
2284                                       kCableHoleRin, kCableHoleRout,
2285                                       -0.5*holePhi, 0.5*holePhi);
2286
2287   TGeoCompositeShape *cableholeshape = new TGeoCompositeShape(
2288                                            "SSDCableHoleShape",
2289                                            "conecopy*chCS");
2290
2291   if(GetDebug(1)){
2292     chCS->InspectShape();
2293     cableholeshape->InspectShape();
2294   }
2295
2296   // SSD Cone Wings: Tube and TubeSeg shapes
2297   Double_t angleWideWing, angleWideWingThickness;
2298   angleWideWing = (kWingWidth/kWingRmax)*TMath::RadToDeg();
2299   angleWideWingThickness = (kCFThickness/kWingRmax)*TMath::RadToDeg();
2300
2301   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kConeROuterMax, kWingRmax,
2302                                            kWingHalfThick,
2303                                            0, angleWideWing);
2304
2305   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kConeROuterMax,
2306                                  kWingRmax-kCFThickness,
2307                                  kWingHalfThick-kCFThickness,
2308                                  angleWideWingThickness,
2309                                  angleWideWing-angleWideWingThickness);
2310
2311   // SDD support plate, SSD side (Mounting Bracket): a TubeSeg
2312   TGeoTubeSeg *bracketshape = new TGeoTubeSeg(kBracketRmin, kBracketRmax,
2313                             kBracketHalfLength, -kBracketPhi/2, kBracketPhi/2);
2314
2315
2316   // We have the shapes: now create the real volumes
2317
2318   TGeoVolume *cfcone = new TGeoVolume("SSDCarbonFiberCone",
2319                                       coneshape,medSSDcf);
2320   cfcone->SetVisibility(kTRUE);
2321   cfcone->SetLineColor(4); // Blue
2322   cfcone->SetLineWidth(1);
2323   cfcone->SetFillColor(cfcone->GetLineColor());
2324   cfcone->SetFillStyle(4000); // 0% transparent
2325
2326   TGeoVolume *cfconeinsert = new TGeoVolume("SSDCarbonFiberConeInsert",
2327                                             coneinsertshape,medSSDste);
2328   cfconeinsert->SetVisibility(kTRUE);
2329   cfconeinsert->SetLineColor(2); // Red
2330   cfconeinsert->SetLineWidth(1);
2331   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2332   cfconeinsert->SetFillStyle(4050); // 50% transparent
2333
2334   TGeoVolume *cfconefoam1 = new TGeoVolume("SSDCarbonFiberConeFoam1",
2335                                             conefoam1shape,medSSDroh);
2336   cfconefoam1->SetVisibility(kTRUE);
2337   cfconefoam1->SetLineColor(3); // Green
2338   cfconefoam1->SetLineWidth(1);
2339   cfconefoam1->SetFillColor(cfconefoam1->GetLineColor());
2340   cfconefoam1->SetFillStyle(4050); // 50% transparent
2341
2342   TGeoVolume *cfconefoam2 = new TGeoVolume("SSDCarbonFiberConeFoam2",
2343                                             conefoam2shape,medSSDroh);
2344   cfconefoam2->SetVisibility(kTRUE);
2345   cfconefoam2->SetLineColor(3); // Green
2346   cfconefoam2->SetLineWidth(1);
2347   cfconefoam2->SetFillColor(cfconefoam2->GetLineColor());
2348   cfconefoam2->SetFillStyle(4050); // 50% transparent
2349
2350   TGeoVolume *coolinghole = new TGeoVolume("SSDCoolingHole",
2351                                            coolingholeshape,medSSDair);
2352   coolinghole->SetVisibility(kTRUE);
2353   coolinghole->SetLineColor(5); // Yellow
2354   coolinghole->SetLineWidth(1);
2355   coolinghole->SetFillColor(coolinghole->GetLineColor());
2356   coolinghole->SetFillStyle(4090); // 90% transparent
2357
2358   TGeoVolume *coolinghole2 = new TGeoVolume("SSDCoolingHole2",
2359                                             coolinghole2shape,medSSDair);
2360   coolinghole2->SetVisibility(kTRUE);
2361   coolinghole2->SetLineColor(5); // Yellow
2362   coolinghole2->SetLineWidth(1);
2363   coolinghole2->SetFillColor(coolinghole2->GetLineColor());
2364   coolinghole2->SetFillStyle(4090); // 90% transparent
2365
2366   TGeoVolume *coolinghole3 = new TGeoVolume("SSDCoolingHole3",
2367                                             coolinghole3shape,medSSDair);
2368   coolinghole3->SetVisibility(kTRUE);
2369   coolinghole3->SetLineColor(5); // Yellow
2370   coolinghole3->SetLineWidth(1);
2371   coolinghole3->SetFillColor(coolinghole3->GetLineColor());
2372   coolinghole3->SetFillStyle(4090); // 90% transparent
2373
2374   TGeoVolume *mountinghole = new TGeoVolume("SSDMountingHole",
2375                                             mountingholeshape,medSSDair);
2376   mountinghole->SetVisibility(kTRUE);
2377   mountinghole->SetLineColor(5); // Yellow
2378   mountinghole->SetLineWidth(1);
2379   mountinghole->SetFillColor(mountinghole->GetLineColor());
2380   mountinghole->SetFillStyle(4090); // 90% transparent
2381
2382   TGeoVolume *mountinghole2 = new TGeoVolume("SSDMountingHole2",
2383                                              mountinghole2shape,medSSDair);
2384   mountinghole2->SetVisibility(kTRUE);
2385   mountinghole2->SetLineColor(5); // Yellow
2386   mountinghole2->SetLineWidth(1);
2387   mountinghole2->SetFillColor(mountinghole2->GetLineColor());
2388   mountinghole2->SetFillStyle(4090); // 90% transparent
2389
2390   TGeoVolume *mountinghole3 = new TGeoVolume("SSDMountingHole3",
2391                                              mountinghole3shape,medSSDair);
2392   mountinghole3->SetVisibility(kTRUE);
2393   mountinghole3->SetLineColor(5); // Yellow
2394   mountinghole3->SetLineWidth(1);
2395   mountinghole3->SetFillColor(mountinghole3->GetLineColor());
2396   mountinghole3->SetFillStyle(4090); // 90% transparent
2397
2398   TGeoVolume *wing = new TGeoVolume("SSDWing",wingshape,medSSDcf);
2399   wing->SetVisibility(kTRUE);
2400   wing->SetLineColor(4); // Blue
2401   wing->SetLineWidth(1);
2402   wing->SetFillColor(wing->GetLineColor());
2403   wing->SetFillStyle(4000); // 0% transparent
2404
2405   TGeoVolume *cablehole = new TGeoVolume("SSDCableHole",
2406                                          cableholeshape,medSSDair);
2407   cablehole->SetVisibility(kTRUE);
2408   cablehole->SetLineColor(5); // Yellow
2409   cablehole->SetLineWidth(1);
2410   cablehole->SetFillColor(cablehole->GetLineColor());
2411   cablehole->SetFillStyle(4090); // 90% transparent
2412
2413   TGeoVolume *winginsert = new TGeoVolume("SSDWingInsert",
2414                                           winginsertshape,medSSDste);
2415   winginsert->SetVisibility(kTRUE);
2416   winginsert->SetLineColor(2); // Red
2417   winginsert->SetLineWidth(1);
2418   winginsert->SetFillColor(winginsert->GetLineColor());
2419   winginsert->SetFillStyle(4050); // 50% transparent
2420
2421   TGeoVolume *bracket = new TGeoVolume("SSDMountingBracket",
2422                                        bracketshape,medSSDal);
2423   bracket->SetVisibility(kTRUE);
2424   bracket->SetLineColor(6); // Purple
2425   bracket->SetLineWidth(1);
2426   bracket->SetFillColor(bracket->GetLineColor());
2427   bracket->SetFillStyle(4000); // 0% transparent
2428
2429   // Mount up a cone
2430   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
2431     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
2432     cfconefoam2->AddNode(mountinghole,i+1, new TGeoRotation("", phiH, 0, 0));
2433   }
2434
2435   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
2436     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
2437     cfconeinsert->AddNodeOverlap(coolinghole,i+1, new TGeoRotation("", phiH, 0, 0));
2438   }
2439
2440   cfconeinsert->AddNode(cfconefoam1,1,0);
2441   cfconeinsert->AddNode(cfconefoam2,1,0);
2442
2443   cfcone->AddNode(cfconeinsert,1,0);
2444
2445   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
2446     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
2447     cfcone->AddNode(coolinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
2448     cfcone->AddNode(coolinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
2449     cfcone->AddNodeOverlap(cablehole,i+1, new TGeoRotation("", phiH, 0, 0));
2450   }
2451
2452   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
2453     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
2454     cfcone->AddNode(mountinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
2455     cfcone->AddNode(mountinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
2456   }
2457
2458   wing->AddNode(winginsert,1,0);
2459
2460   // Add all volumes in the Cone assembly
2461   vC->AddNode(cfcone,1,new TGeoTranslation(0,0,-kConeZPosition));
2462
2463   for (Int_t i=0; i<4; i++) {
2464     Double_t thetaW = kThetaWing + 90.*i + angleWideWing/2.;
2465     vC->AddNode(wing, i+1, new TGeoCombiTrans(0, 0, -kConeZPosition+kWingHalfThick,
2466                            new TGeoRotation("",thetaW,180,0)));
2467   }
2468
2469   Double_t zBracket = kConeZPosition - coneshape->GetZ(9) +
2470                       2*bracketshape->GetDz();
2471   for (Int_t i=0; i<3; i++) {
2472     Double_t thetaB = 60 + 120.*i;
2473     vC->AddNode(bracket, i+1, new TGeoCombiTrans(0, 0, -zBracket,
2474                               new TGeoRotation("",thetaB,0,0)));
2475   }
2476
2477   // Finally put everything in the mother volume
2478   moth->AddNode(cfcylinder,1,0);
2479
2480   moth->AddNode(vC, 1, 0 );
2481   moth->AddNode(vC, 2, new TGeoRotation("",180, 180, 0) );
2482
2483   // Some debugging if requested
2484   if(GetDebug(1)){
2485     vC->PrintNodes();
2486     vC->InspectShape();
2487   }
2488
2489   return;
2490 }
2491
2492 //______________________________________________________________________
2493 void AliITSv11GeometrySupport::ServicesCableSupport(TGeoVolume *moth,
2494                                                     TGeoManager *mgr){
2495 //
2496 // Creates the cable trays which are outside the ITS support cones
2497 // but still inside the TPC
2498 // This is now a stearing routine, the actual work is done by three
2499 // specialized methods to avoid a really huge unique method
2500 //
2501 // Input:
2502 //         moth : the TGeoVolume owing the volume structure
2503 //         mgr  : the GeoManager (default gGeoManager)
2504 // Output:
2505 //
2506 // Created:      15 Nov 2009  Mario Sitta
2507 //
2508
2509   TraySupportsSideA(moth, mgr);
2510
2511   ServicesCableSupportSPD(moth, mgr);
2512   ServicesCableSupportSDD(moth, mgr);
2513   ServicesCableSupportSSD(moth, mgr);
2514
2515   return;
2516 }
2517
2518 //______________________________________________________________________
2519 void AliITSv11GeometrySupport::TraySupportsSideA(TGeoVolume *moth,
2520                                                  TGeoManager *mgr){
2521 //
2522 // Creates the structure supporting the ITS cable trays on Side A
2523 //
2524 // Input:
2525 //         moth : the TGeoVolume owing the volume structure
2526 //         mgr  : the GeoManager (default gGeoManager)
2527 // Output:
2528 //
2529 // Created:      14 Dec 2009  Mario Sitta
2530 // Updated:      26 Feb 2010  Mario Sitta
2531 //
2532 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
2533 // drawings and other (oral) information given by F.Tosello
2534 //
2535
2536   // Dimensions and positions of the A-Side Cable Tray Support Ring
2537   // (0872/G/A/01)
2538   const Double_t kSuppRingYTrans      =  110.00 *fgkmm;
2539   const Double_t kSuppRingZTrans      =(1011.00+435.00) *fgkmm;
2540   const Double_t kSuppForwYTrans      =  185.00 *fgkmm;
2541
2542   const Double_t kExtSuppRingSpace1   =   33.00 *fgkmm;
2543   const Double_t kExtSuppRingSpace2   =   45.00 *fgkmm;
2544   const Double_t kExtSuppRingSpcAbov  =   30.00 *fgkmm;
2545   const Double_t kExtSuppRingBase     =  491.50 *fgkmm;
2546   const Double_t kExtSuppRingInward   =   35.00 *fgkmm;
2547   const Double_t kExtSuppRingRmax     =  540.00 *fgkmm;
2548   const Double_t kExtSuppRingRint1    =  465.00 *fgkmm;
2549   const Double_t kExtSuppRingRint2    =  467.00 *fgkmm;
2550   const Double_t kExtSuppRingInnerHi  =  450.00 *fgkmm;
2551   const Double_t kExtSuppRingInWide   =  100.00 *fgkmm;
2552   const Double_t kExtSuppRingR7       =    7.00 *fgkmm;
2553   const Double_t kExtSuppRingR5       =    5.00 *fgkmm;
2554   const Double_t kExtSuppRingThick    =   20.00 *fgkmm;
2555
2556   const Double_t kExtSuppRingSpcAng   =   10.50 *TMath::DegToRad();
2557   const Double_t kExtSuppRingPartPhi  =   15.00 *TMath::DegToRad();
2558   const Double_t kExtSuppRingIntAng   =    7.00 *TMath::DegToRad();
2559   const Double_t kExtSuppRingBaseAng  =   75.00 *TMath::DegToRad();
2560   const Double_t kExtSuppRingR7Ang    =  100.00 *TMath::DegToRad(); // Guessed
2561
2562   const Int_t    kExtSuppRingNPtsArc  =   10; // N.points to approximate arc
2563
2564   const Double_t kIntSuppRingThick1   =   15.00 *fgkmm;
2565   const Double_t kIntSuppRingThick2   =   13.00 *fgkmm;
2566   const Double_t kIntSuppRingInward   =   24.00 *fgkmm;
2567   const Double_t kIntSuppRingThick    =   20.00 *fgkmm;
2568
2569   const Double_t kSuppCylHeight       =  340.00 *fgkmm;
2570   const Double_t kSuppCylRint         =  475.00 *fgkmm;
2571   const Double_t kSuppCylRext         =  478.00 *fgkmm;
2572   const Double_t kSuppCylDispl        =  137.70 *fgkmm;
2573
2574   const Double_t kSuppSpacerHeight    =   30.00 *fgkmm;
2575   const Double_t kSuppSpacerThick     =   10.00 *fgkmm;
2576
2577   const Double_t kSuppSpacerAngle     =   15.00;  // Degrees
2578
2579   const Double_t kSuppForwRingRint1   =  500.00 *fgkmm;
2580   const Double_t kSuppForwRingRint2   =  540.00 *fgkmm;
2581   const Double_t kSuppForwRingRext    =  560.00 *fgkmm;
2582   const Double_t kSuppForwRingThikAll =   50.00 *fgkmm;
2583   const Double_t kSuppForwRingThikInt =   20.00 *fgkmm;
2584
2585   // (0872/G/B/01)
2586   const Double_t kSuppForwConeRmin    =  558.00 *fgkmm;
2587   const Double_t kSuppForwConeRmax    =  681.00 *fgkmm;
2588   const Double_t kSuppForwConeLen1    =  318.00 *fgkmm;
2589   const Double_t kSuppForwConeLen2    =  662.00 *fgkmm;
2590   const Double_t kSuppForwConeThick   =    3.00 *fgkmm;
2591
2592   const Double_t kSuppBackRingPlacTop =   90.00 *fgkmm;
2593   const Double_t kSuppBackRingPlacSid =   50.00 *fgkmm;
2594   const Double_t kSuppBackRingHeight  =  760.00 *fgkmm;
2595   const Double_t kSuppBackRingRext    =  760.00 *fgkmm;
2596   const Double_t kSuppBackRingRint    =  685.00 *fgkmm;
2597 //  const Double_t kSuppBackRingRint2   =  675.00 *fgkmm;
2598   const Double_t kSuppBackRingR10     =   10.00 *fgkmm;
2599   const Double_t kSuppBackRingBase    =  739.00 *fgkmm;
2600   const Double_t kSuppBackRingThikAll =   50.00 *fgkmm;
2601   const Double_t kSuppBackRingThick1  =   20.00 *fgkmm;
2602   const Double_t kSuppBackRingThick2  =   20.00 *fgkmm;
2603
2604 //  const Double_t kSuppBackRingPlacAng =   10.00 *TMath::DegToRad();
2605   const Double_t kSuppBackRingPlacAng =   10.25 *TMath::DegToRad();//Fix ovlp.
2606   const Double_t kSuppBackRing2ndAng1 =   78.40 *TMath::DegToRad();
2607   const Double_t kSuppBackRing2ndAng2 =   45.00 *TMath::DegToRad();
2608
2609   const Int_t    kSuppBackRingNPtsArc =   10; // N.points to approximate arc
2610
2611   // (0872/G/C/01)
2612   const Double_t kRearSuppZTransGlob  =(1011.00+9315.00-6040.00) *fgkmm;
2613   const Double_t kBackRodZTrans       = 2420.00 *fgkmm;
2614
2615   const Double_t kBackRodLength       = 1160.00 *fgkmm;
2616   const Double_t kBackRodThickLen     =   20.00 *fgkmm;
2617   const Double_t kBackRodDiameter     =   20.00 *fgkmm;
2618
2619   const Double_t kSuppRearRingRint    =  360.00 *fgkmm;
2620   const Double_t kSuppRearRingRext1   =  410.00 *fgkmm;
2621   const Double_t kSuppRearRingRext2   =  414.00 *fgkmm;
2622   const Double_t kSuppRearRingHeight  =  397.00 *fgkmm;
2623   const Double_t kSuppRearRingTopWide =  111.87 *fgkmm;
2624   const Double_t kSuppRearRingBase    =  451.50 *fgkmm;
2625   const Double_t kSuppRearRingBaseHi  =   58.00 *fgkmm;
2626   const Double_t kSuppRearRingSideHi  =   52.00 *fgkmm;
2627   const Double_t kSuppRearRingInside  =   40.00 *fgkmm;
2628   const Double_t kSuppRearRingInsideHi=   12.00 *fgkmm;
2629   const Double_t kSuppRearRingThick   =   20.00 *fgkmm;
2630   const Double_t kSuppRearRingXRodHole=  441.50 *fgkmm;
2631   const Double_t kSuppRearRingYRodHole=   42.00 *fgkmm;
2632
2633   const Double_t kSuppRearRing1stAng  =   22.00 *TMath::DegToRad();
2634   const Double_t kSuppRearRingStepAng =   15.00 *TMath::DegToRad();
2635
2636   const Int_t    kSuppRearRingNPtsArc =   10; // N.points to approximate arc
2637
2638
2639   // Local variables
2640   Double_t xprof[2*(15+kExtSuppRingNPtsArc)],yprof[2*(15+kExtSuppRingNPtsArc)];
2641   Double_t slp1, slp2, phi, xm, ym;
2642   Double_t xloc, yloc, zloc, rmin, rmax, deltaR;
2643   Int_t npoints;
2644
2645
2646   // The whole support as an assembly
2647   TGeoVolumeAssembly *trayASuppStruct = new TGeoVolumeAssembly("ITSsuppSideAStructure");
2648   
2649
2650   // First create all needed shapes
2651
2652   // The External Ring (part of 0872/G/A/01): a really complex Xtru
2653   TGeoXtru *extSuppRing = new TGeoXtru(2);
2654
2655   // First the upper notch...
2656   xprof[ 0] = kExtSuppRingSpace1;
2657   yprof[ 0] = kExtSuppRingInnerHi + kExtSuppRingSpcAbov;
2658
2659   slp1 = TMath::Tan(TMath::Pi()/2 - kExtSuppRingSpcAng);
2660   IntersectCircle(slp1, xprof[0], yprof[0], kExtSuppRingRmax, 0., 0.,
2661                   xprof[5], yprof[5], xm, ym); // Ignore dummy xm,ym
2662
2663   xprof[ 4] = xprof[5];
2664   yprof[ 4] = yprof[5] - kExtSuppRingR5/TMath::Tan(kExtSuppRingSpcAng);
2665   xprof[ 3] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/6));
2666   yprof[ 3] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/6));
2667   xprof[ 2] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/3));
2668   yprof[ 2] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/3));
2669   xprof[ 1] = xprof[4] - kExtSuppRingR5;
2670   yprof[ 1] = yprof[4] - kExtSuppRingR5;
2671
2672   Int_t indx = 5+kExtSuppRingNPtsArc;
2673   // ...then the external arc, approximated with segments,...
2674   xprof[indx] = kExtSuppRingBase;
2675   yprof[indx] = TMath::Sqrt(kExtSuppRingRmax*kExtSuppRingRmax -
2676                             kExtSuppRingBase*kExtSuppRingBase);
2677   Double_t alphamin = TMath::ASin(kExtSuppRingSpace2/kExtSuppRingRmax);
2678   Double_t alphamax = TMath::Pi()/2 -
2679                     TMath::ASin(yprof[5+kExtSuppRingNPtsArc]/kExtSuppRingRmax);
2680
2681   for (Int_t jp = 1; jp < kExtSuppRingNPtsArc; jp++) {
2682     Double_t alpha = jp*(alphamax-alphamin)/kExtSuppRingNPtsArc;
2683     xprof[5+jp] = kExtSuppRingRmax*TMath::Sin(alpha);
2684     yprof[5+jp] = kExtSuppRingRmax*TMath::Cos(alpha);
2685   }
2686   // ...and finally the interior profile
2687   xprof[indx+1] = kExtSuppRingBase;
2688   yprof[indx+1] = kSuppRingYTrans;
2689   xprof[indx+2] = xprof[indx+1] - kExtSuppRingInward;
2690   yprof[indx+2] = yprof[indx+1];
2691
2692   phi  = TMath::Pi()/2 - 4*kExtSuppRingPartPhi - kExtSuppRingIntAng;
2693   slp1 = TMath::Tan(TMath::Pi() - kExtSuppRingBaseAng);
2694   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2695   xm   = kExtSuppRingRint2*TMath::Cos(phi);
2696   ym   = kExtSuppRingRint2*TMath::Sin(phi);
2697   IntersectLines(slp1, xprof[indx+2], yprof[indx+2], slp2, xm, ym,
2698                  xprof[indx+3], yprof[indx+3]);
2699
2700   slp1 = slp2;
2701   phi += kExtSuppRingPartPhi;
2702   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2703   xm   = kExtSuppRingRint1*TMath::Cos(phi);
2704   ym   = kExtSuppRingRint1*TMath::Sin(phi);
2705   IntersectLines(slp1, xprof[indx+3], yprof[indx+3], slp2, xm, ym,
2706                  xprof[indx+4], yprof[indx+4]);
2707   
2708   slp1 = slp2;
2709   phi += kExtSuppRingPartPhi;
2710   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2711   xm   = kExtSuppRingRint2*TMath::Cos(phi);
2712   ym   = kExtSuppRingRint2*TMath::Sin(phi);
2713   IntersectLines(slp1, xprof[indx+4], yprof[indx+4], slp2, xm, ym,
2714                  xprof[indx+5], yprof[indx+5]);
2715   
2716   slp1 = slp2;
2717   phi += kExtSuppRingPartPhi;
2718   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2719   xm   = kExtSuppRingRint1*TMath::Cos(phi);
2720   ym   = kExtSuppRingRint1*TMath::Sin(phi);
2721   IntersectLines(slp1, xprof[indx+5], yprof[indx+5], slp2, xm, ym,
2722                  xprof[indx+6], yprof[indx+6]);
2723   
2724   xprof[indx+9] = kExtSuppRingInWide;
2725   yprof[indx+9] = kExtSuppRingInnerHi;
2726   xprof[indx+8] = xprof[indx+9] +
2727                   (1 - TMath::Cos(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
2728   yprof[indx+8] = yprof[indx+9] +
2729                   (    TMath::Sin(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
2730   xprof[indx+7] = xprof[indx+9] +
2731                   (1 + TMath::Cos(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
2732   yprof[indx+7] = yprof[indx+9] +
2733                   (    TMath::Sin(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
2734   // Gosh, we did the right side! now reflex on the left side
2735   npoints = (sizeof(xprof)/sizeof(Double_t))/2;
2736   for (Int_t jp = 0; jp < npoints; jp++) {
2737     xprof[npoints+jp] = -xprof[npoints-1-jp];
2738     yprof[npoints+jp] =  yprof[npoints-1-jp];
2739   }
2740   // wow! now the actual Xtru
2741   extSuppRing->DefinePolygon(2*npoints, xprof, yprof);
2742   extSuppRing->DefineSection(0,0);
2743   extSuppRing->DefineSection(1,kExtSuppRingThick);
2744
2745   // The Internal Ring (part of 0872/G/A/01): another complex Xtru
2746   TGeoXtru *intSuppRing = new TGeoXtru(2);
2747
2748   // First the external profile...
2749   npoints = 0;
2750
2751   slp1 = 0;
2752   phi  = TMath::Pi()/2 - kExtSuppRingPartPhi - kExtSuppRingIntAng;
2753   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2754   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
2755   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
2756   IntersectLines(slp1,  0, kExtSuppRingInnerHi+kExtSuppRingSpcAbov,
2757                  slp2, xm, ym,
2758                  xprof[npoints], yprof[npoints]);
2759   npoints++;
2760
2761   slp1 = slp2;
2762   phi -= kExtSuppRingPartPhi;
2763   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2764   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
2765   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
2766   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
2767                  slp2, xm, ym,
2768                  xprof[npoints], yprof[npoints]);
2769   npoints++;
2770
2771   slp1 = slp2;
2772   phi -= kExtSuppRingPartPhi;
2773   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2774   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
2775   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
2776   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
2777                  slp2, xm, ym,
2778                  xprof[npoints], yprof[npoints]);
2779   npoints++;
2780
2781   slp1 = slp2;
2782   phi -= kExtSuppRingPartPhi;
2783   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
2784   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
2785   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
2786   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
2787                  slp2, xm, ym,
2788                  xprof[npoints], yprof[npoints]);
2789   npoints++;
2790
2791   xprof[npoints] = kExtSuppRingBase-kIntSuppRingInward;
2792   yprof[npoints] = Yfrom2Points(xprof[npoints-1], yprof[npoints-1], xm, ym,
2793                                 xprof[npoints]);
2794   npoints++;
2795
2796   xprof[npoints] = xprof[npoints-1];
2797   yprof[npoints] = kSuppRingYTrans;
2798   npoints++;
2799   // ...and then the interior profile, which is identical to extSuppRing one
2800   for (Int_t jp=0; jp < 8; jp++) {
2801     xprof[npoints] = extSuppRing->GetX(17+jp);
2802     yprof[npoints] = extSuppRing->GetY(17+jp);
2803     npoints++;
2804   }
2805   // We did the right side! now reflex on the left side
2806   for (Int_t jp = 0; jp < npoints; jp++) {
2807     xprof[npoints+jp] = -xprof[npoints-1-jp];
2808     yprof[npoints+jp] =  yprof[npoints-1-jp];
2809   }
2810   // And now the actual Xtru
2811   intSuppRing->DefinePolygon(2*npoints, xprof, yprof);
2812   intSuppRing->DefineSection(0,0);
2813   intSuppRing->DefineSection(1,kIntSuppRingThick);
2814
2815   // The intermediate cylinder (0872/G/A/03): a TubeSeg
2816   alphamin = TMath::ASin(kSuppCylDispl/kSuppCylRint)*TMath::RadToDeg();
2817   alphamax = 180 - alphamin;
2818   TGeoTubeSeg *interCylind = new TGeoTubeSeg(kSuppCylRint, kSuppCylRext,
2819                                      kSuppCylHeight/2, alphamin, alphamax);
2820
2821   // The spacer (0872/G/A/03): a simple Xtru
2822   TGeoXtru *suppSpacer = new TGeoXtru(2);
2823
2824   xprof[0] = kSuppSpacerHeight;
2825   yprof[0] = kSuppSpacerThick;
2826   xprof[1] = xprof[0];
2827   yprof[1] = 0;
2828   xprof[2] = 0;
2829   yprof[2] = 0;
2830   xprof[3] = kSuppSpacerThick*SinD(kSuppSpacerAngle);
2831   yprof[3] = yprof[0];
2832
2833   suppSpacer->DefinePolygon(4, xprof, yprof);
2834   suppSpacer->DefineSection(0,-kSuppCylHeight/2);
2835   suppSpacer->DefineSection(1, kSuppCylHeight/2);
2836
2837   // The forward ring (0872/G/B/02): a Pcon (slight oversimplification)
2838   Double_t rmean = (kSuppForwRingRint1+kSuppForwRingRext)/2;
2839   alphamin = TMath::ASin(kSuppForwYTrans/rmean)*TMath::RadToDeg();
2840   alphamax = 180 - alphamin;
2841
2842   TGeoPcon *forwardRing = new TGeoPcon(alphamin,alphamax-alphamin,4);
2843
2844   forwardRing->DefineSection(0,0,
2845                              kSuppForwRingRint1,kSuppForwRingRext);
2846   forwardRing->DefineSection(1,kSuppForwRingThikInt,
2847                              kSuppForwRingRint1,kSuppForwRingRext);
2848   forwardRing->DefineSection(2,kSuppForwRingThikInt,
2849                              kSuppForwRingRint2,kSuppForwRingRext);
2850   forwardRing->DefineSection(3,kSuppForwRingThikAll,
2851                              kSuppForwRingRint2,kSuppForwRingRext);
2852
2853   // The forward cone (0872/G/B/03): a TGeoPcon
2854   TGeoPcon *forwardCone = new TGeoPcon(alphamin,alphamax-alphamin,3);
2855
2856   forwardCone->DefineSection(0,0,
2857                              kSuppForwConeRmin-kSuppForwConeThick,
2858                              kSuppForwConeRmin);
2859   forwardCone->DefineSection(1,kSuppForwConeLen1,
2860                              kSuppForwConeRmin-kSuppForwConeThick,
2861                              kSuppForwConeRmin);
2862   forwardCone->DefineSection(2,kSuppForwConeLen1+kSuppForwConeLen2,
2863                              kSuppForwConeRmax-kSuppForwConeThick,
2864                              kSuppForwConeRmax);
2865
2866   // The first part of the Back Ring (part of 0872/G/B/01): a complex Xtru
2867   TGeoXtru *firstSuppBackRing = new TGeoXtru(2);
2868
2869   // First the external profile... (the arc is approximated with segments)
2870   npoints = 0;
2871
2872   xprof[npoints] = kSuppBackRingPlacTop;
2873   yprof[npoints] = kSuppBackRingHeight;
2874   npoints++;
2875
2876   alphamax = TMath::Pi()/2 - TMath::ASin(kSuppBackRingPlacTop/kSuppBackRingRext);
2877   alphamin = TMath::ASin((kSuppForwYTrans+kSuppBackRingPlacSid)/kSuppBackRingRext);
2878
2879   xprof[npoints] = xprof[npoints-1];
2880   yprof[npoints] = kSuppBackRingRext*TMath::Sin(alphamax);
2881   npoints++;
2882
2883   for (Int_t jp = 1; jp <= kSuppBackRingNPtsArc; jp++) {
2884     Double_t alpha = alphamax - jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
2885     xprof[npoints] = kSuppBackRingRext*TMath::Cos(alpha);
2886     yprof[npoints] = kSuppBackRingRext*TMath::Sin(alpha);
2887     npoints++;
2888   }
2889
2890   xprof[npoints] = kSuppBackRingBase -
2891                    kSuppBackRingPlacSid*TMath::Tan(kSuppBackRingPlacAng);
2892   yprof[npoints] = yprof[npoints-1];
2893   npoints++;
2894
2895   xprof[npoints] = kSuppBackRingBase;
2896   yprof[npoints] = kSuppForwYTrans;
2897   npoints++;
2898   // ...then the internal profile (the arc is approximated with segments)
2899   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint);
2900   alphamax = TMath::Pi()/2;
2901
2902   for (Int_t jp = 0; jp < kSuppBackRingNPtsArc; jp++) {
2903     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
2904     xprof[npoints] = kSuppBackRingRint*TMath::Cos(alpha);
2905     yprof[npoints] = kSuppBackRingRint*TMath::Sin(alpha);
2906     npoints++;
2907   }
2908
2909   xprof[npoints] = 0;
2910   yprof[npoints] = kSuppBackRingRint;
2911   npoints++;
2912   // We did the right side! now reflex on the left side (except last point)
2913   for (Int_t jp = 0; jp < npoints-1; jp++) {
2914     xprof[npoints+jp] = -xprof[npoints-jp-2];
2915     yprof[npoints+jp] =  yprof[npoints-jp-2];
2916   }
2917   // And now the actual Xtru
2918   firstSuppBackRing->DefinePolygon(2*npoints-1, xprof, yprof);
2919   firstSuppBackRing->DefineSection(0,0);
2920   firstSuppBackRing->DefineSection(1,kSuppBackRingThick1);
2921
2922   // The second part of the Back Ring (part of 0872/G/B/01): a Pcon
2923   // (slight oversimplification)
2924   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint)*TMath::RadToDeg();
2925   alphamax = 180 - alphamin;
2926
2927   TGeoPcon *secondSuppBackRing = new TGeoPcon(alphamin,alphamax-alphamin,6);
2928
2929   deltaR = kSuppBackRingThick2/TMath::Sin(kSuppBackRing2ndAng1);
2930   rmin = kSuppBackRingRint - kSuppBackRingThick1/TMath::Tan(kSuppBackRing2ndAng1);
2931   rmax = rmin + deltaR + kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
2932   secondSuppBackRing->DefineSection(0, 0, rmin, rmax);
2933
2934   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1/3));
2935   rmax -= kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1/3);
2936   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2937   secondSuppBackRing->DefineSection(1, zloc, rmin, rmax);
2938
2939   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1*2/3));
2940   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1*2/3);
2941   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2942   secondSuppBackRing->DefineSection(2, zloc, rmin, rmax);
2943
2944   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1));
2945   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
2946   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2947   secondSuppBackRing->DefineSection(3, zloc, rmin, rmax);
2948
2949   slp1 = TMath::Tan(kSuppBackRing2ndAng2);
2950   slp2 = TMath::Tan(TMath::Pi()/2 + kSuppBackRing2ndAng1);
2951   IntersectLines(-slp1,kSuppBackRingThikAll,deltaR/2,
2952                   slp2,kSuppBackRingThikAll,deltaR,
2953                   xm, ym);
2954
2955   zloc = xm - kSuppBackRingThick1;
2956   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2957   rmax = rmin + deltaR;
2958   secondSuppBackRing->DefineSection(4, zloc, rmin, rmax);
2959
2960   zloc = kSuppBackRingThikAll - kSuppBackRingThick1;
2961   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
2962   rmax = rmin + deltaR/2;
2963   secondSuppBackRing->DefineSection(5, zloc, rmin, rmax);
2964
2965   // The supporting rod: a Tube
2966   TGeoTube *suppRod = new TGeoTube(0, kBackRodDiameter/2,
2967                                    (kBackRodLength - kBackRodThickLen)/2);
2968
2969   // The Back Ring (0872/G/C/01): another complex Xtru
2970   TGeoXtru *suppRearRing = new TGeoXtru(2);
2971
2972   // First the external profile...
2973   npoints = 0;
2974
2975   xprof[npoints] = kSuppRearRingTopWide;
2976   yprof[npoints] = kSuppRearRingHeight;
2977   npoints++;
2978
2979   phi = kSuppRearRing1stAng;
2980   slp1 = TMath::Tan(TMath::Pi() - phi);
2981   phi += kSuppRearRingStepAng;
2982   slp2 = TMath::Tan(TMath::Pi() - phi);
2983   xm = kSuppRearRingRext2*TMath::Sin(phi);
2984   ym = kSuppRearRingRext2*TMath::Cos(phi);
2985   IntersectLines(slp1, kSuppRearRingTopWide, kSuppRearRingHeight,
2986                  slp2, xm, ym,
2987                  xprof[npoints], yprof[npoints]);
2988   npoints++;
2989
2990   slp1 = slp2;
2991   phi += kSuppRearRingStepAng;
2992   slp2 = TMath::Tan(TMath::Pi() - phi);
2993   xm = kSuppRearRingRext1*TMath::Sin(phi);
2994   ym = kSuppRearRingRext1*TMath::Cos(phi);
2995   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
2996                  slp2, xm, ym,
2997                  xprof[npoints], yprof[npoints]);
2998   npoints++;
2999
3000   slp1 = slp2;
3001   phi += kSuppRearRingStepAng;
3002   slp2 = TMath::Tan(TMath::Pi() - phi);
3003   xm = kSuppRearRingRext2*TMath::Sin(phi);
3004   ym = kSuppRearRingRext2*TMath::Cos(phi);
3005   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3006                  slp2, xm, ym,
3007                  xprof[npoints], yprof[npoints]);
3008   npoints++;
3009
3010   slp1 = slp2;
3011   slp2 = 0;
3012   xm = kSuppRearRingBase;
3013   ym = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3014   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3015                  slp2, xm, ym,
3016                  xprof[npoints], yprof[npoints]);
3017   npoints++;
3018
3019   xprof[npoints] = kSuppRearRingBase;
3020   yprof[npoints] = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3021   npoints++;
3022   xprof[npoints] = xprof[npoints - 1];
3023   yprof[npoints] = kSuppRearRingBaseHi;
3024   npoints++;
3025   xprof[npoints] = xprof[npoints - 1] - kSuppRearRingInside;
3026   yprof[npoints] = yprof[npoints - 1];
3027   npoints++;
3028   xprof[npoints] = xprof[npoints - 1];
3029   yprof[npoints] = yprof[npoints - 1] + kSuppRearRingInsideHi;
3030   npoints++;
3031   // ...then the internal arc, approximated with segments,...
3032   xprof[npoints] = kSuppRearRingRint;
3033   yprof[npoints] = yprof[npoints - 1];
3034
3035   alphamin = TMath::ASin(kSuppRearRingBaseHi/kSuppRearRingRint);
3036   alphamax = TMath::Pi()/2;
3037
3038   for (Int_t jp = 1; jp < kSuppRearRingNPtsArc; jp++) {
3039     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppRearRingNPtsArc;
3040     xprof[npoints+jp] = kSuppRearRingRint*TMath::Cos(alpha);
3041     yprof[npoints+jp] = kSuppRearRingRint*TMath::Sin(alpha);
3042   }
3043
3044   xprof[npoints+kSuppRearRingNPtsArc] = 0;
3045   yprof[npoints+kSuppRearRingNPtsArc] = kSuppRearRingRint;
3046   // We did the right side! now reflex on the left side
3047   Int_t nTotalPoints = npoints+kSuppRearRingNPtsArc;
3048   for (Int_t jp = 0; jp < nTotalPoints; jp++) {
3049     xprof[nTotalPoints+1+jp] = -xprof[nTotalPoints-1-jp];
3050     yprof[nTotalPoints+1+jp] =  yprof[nTotalPoints-1-jp];
3051   }
3052
3053   // And now the actual Xtru
3054   suppRearRing->DefinePolygon(2*nTotalPoints+1, xprof, yprof);
3055   suppRearRing->DefineSection(0,0);
3056   suppRearRing->DefineSection(1,kSuppRearRingThick);
3057
3058
3059   // We have all shapes: now create the real volumes
3060   TGeoMedium *medAl = mgr->GetMedium("ITS_ANTICORODAL$");
3061
3062   TGeoVolume *sideAExtSuppRing = new TGeoVolume("ITSsuppSideAExtSuppRing",
3063                                                  extSuppRing, medAl);
3064
3065   sideAExtSuppRing->SetVisibility(kTRUE);
3066   sideAExtSuppRing->SetLineColor(kMagenta+1);
3067   sideAExtSuppRing->SetLineWidth(1);
3068   sideAExtSuppRing->SetFillColor(sideAExtSuppRing->GetLineColor());
3069   sideAExtSuppRing->SetFillStyle(4000); // 0% transparent
3070
3071   TGeoVolume *sideAIntSuppRing = new TGeoVolume("ITSsuppSideAIntSuppRing",
3072                                                  intSuppRing, medAl);
3073
3074   sideAIntSuppRing->SetVisibility(kTRUE);
3075   sideAIntSuppRing->SetLineColor(kMagenta+1);
3076   sideAIntSuppRing->SetLineWidth(1);
3077   sideAIntSuppRing->SetFillColor(sideAIntSuppRing->GetLineColor());
3078   sideAIntSuppRing->SetFillStyle(4000); // 0% transparent
3079
3080   TGeoVolume *sideASuppCyl = new TGeoVolume("ITSsuppSideASuppCyl",
3081                                             interCylind, medAl);
3082
3083   sideASuppCyl->SetVisibility(kTRUE);
3084   sideASuppCyl->SetLineColor(kMagenta+1);
3085   sideASuppCyl->SetLineWidth(1);
3086   sideASuppCyl->SetFillColor(sideASuppCyl->GetLineColor());
3087   sideASuppCyl->SetFillStyle(4000); // 0% transparent
3088
3089   TGeoVolume *sideASuppSpacer = new TGeoVolume("ITSsuppSideASuppSpacer",
3090                                                suppSpacer, medAl);
3091
3092   sideASuppSpacer->SetVisibility(kTRUE);
3093   sideASuppSpacer->SetLineColor(kMagenta+1);
3094   sideASuppSpacer->SetLineWidth(1);
3095   sideASuppSpacer->SetFillColor(sideASuppSpacer->GetLineColor());
3096   sideASuppSpacer->SetFillStyle(4000); // 0% transparent
3097
3098   TGeoVolume *sideASuppForwRing = new TGeoVolume("ITSsuppSideASuppForwRing",
3099                                                  forwardRing, medAl);
3100
3101   sideASuppForwRing->SetVisibility(kTRUE);
3102   sideASuppForwRing->SetLineColor(kMagenta+1);
3103   sideASuppForwRing->SetLineWidth(1);
3104   sideASuppForwRing->SetFillColor(sideASuppForwRing->GetLineColor());
3105   sideASuppForwRing->SetFillStyle(4000); // 0% transparent
3106
3107   TGeoVolume *sideASuppForwCone = new TGeoVolume("ITSsuppSideASuppForwCone",
3108                                                  forwardCone, medAl);
3109
3110   sideASuppForwCone->SetVisibility(kTRUE);
3111   sideASuppForwCone->SetLineColor(kMagenta+1);
3112   sideASuppForwCone->SetLineWidth(1);
3113   sideASuppForwCone->SetFillColor(sideASuppForwCone->GetLineColor());
3114   sideASuppForwCone->SetFillStyle(4000); // 0% transparent
3115
3116   TGeoVolume *sideAFirstSuppBackRing = new TGeoVolume("ITSsuppSideAFirstSuppBackRing",
3117                                                      firstSuppBackRing, medAl);
3118
3119   sideAFirstSuppBackRing->SetVisibility(kTRUE);
3120   sideAFirstSuppBackRing->SetLineColor(kMagenta+1);
3121   sideAFirstSuppBackRing->SetLineWidth(1);
3122   sideAFirstSuppBackRing->SetFillColor(sideAFirstSuppBackRing->GetLineColor());
3123   sideAFirstSuppBackRing->SetFillStyle(4000); // 0% transparent
3124
3125   TGeoVolume *sideASecondSuppBackRing = new TGeoVolume("ITSsuppSideASecondSuppBackRing",
3126                                                        secondSuppBackRing, medAl);
3127
3128   sideASecondSuppBackRing->SetVisibility(kTRUE);
3129   sideASecondSuppBackRing->SetLineColor(kMagenta+1);
3130   sideASecondSuppBackRing->SetLineWidth(1);
3131   sideASecondSuppBackRing->SetFillColor(sideASecondSuppBackRing->GetLineColor());
3132   sideASecondSuppBackRing->SetFillStyle(4000); // 0% transparent
3133
3134   TGeoVolume *sideASuppRod = new TGeoVolume("ITSsuppSideASuppRod",
3135                                             suppRod, medAl);
3136
3137   sideASuppRod->SetVisibility(kTRUE);
3138   sideASuppRod->SetLineColor(kMagenta+1);
3139   sideASuppRod->SetLineWidth(1);
3140   sideASuppRod->SetFillColor(sideASuppRod->GetLineColor());
3141   sideASuppRod->SetFillStyle(4000); // 0% transparent
3142
3143   TGeoVolume *sideASuppRearRing = new TGeoVolume("ITSsuppSideASuppRearRing",
3144                                                  suppRearRing, medAl);
3145
3146   sideASuppRearRing->SetVisibility(kTRUE);
3147   sideASuppRearRing->SetLineColor(kMagenta+1);
3148   sideASuppRearRing->SetLineWidth(1);
3149   sideASuppRearRing->SetFillColor(sideASuppRearRing->GetLineColor());
3150   sideASuppRearRing->SetFillStyle(4000); // 0% transparent
3151
3152
3153   // Now build up the support structure
3154   zloc = kSuppRingZTrans;
3155   trayASuppStruct->AddNode(sideAExtSuppRing, 1,
3156                            new TGeoTranslation(0, 0, zloc) );
3157   trayASuppStruct->AddNode(sideAExtSuppRing, 2,
3158                            new TGeoCombiTrans( 0, 0, zloc,
3159                                                new TGeoRotation("",180,0,0)));
3160
3161   zloc += kExtSuppRingThick;
3162   trayASuppStruct->AddNode(sideAIntSuppRing, 1,
3163                            new TGeoTranslation(0, 0, zloc) );
3164   trayASuppStruct->AddNode(sideAIntSuppRing, 2,
3165                            new TGeoCombiTrans( 0, 0, zloc,
3166                                                new TGeoRotation("",180,0,0)));
3167
3168   xloc = kExtSuppRingBase - kIntSuppRingInward;
3169   yloc = kSuppRingYTrans;
3170   zloc += (kIntSuppRingThick + kSuppCylHeight/2);
3171   trayASuppStruct->AddNode(sideASuppCyl, 1,
3172                            new TGeoTranslation(0, 0, zloc) );
3173   trayASuppStruct->AddNode(sideASuppCyl, 2,
3174                            new TGeoCombiTrans( 0, 0, zloc,
3175                                                new TGeoRotation("",180,0,0)));
3176   trayASuppStruct->AddNode(sideASuppSpacer, 1,
3177                            new TGeoCombiTrans( xloc, yloc, zloc,
3178                            new TGeoRotation("",90+kSuppSpacerAngle,0,0)));
3179   trayASuppStruct->AddNode(sideASuppSpacer, 2,
3180                            new TGeoCombiTrans(-xloc, yloc, zloc,
3181                            new TGeoRotation("",0,180,kSuppSpacerAngle-90)));
3182   trayASuppStruct->AddNode(sideASuppSpacer, 3,
3183                            new TGeoCombiTrans( xloc,-yloc, zloc,
3184                            new TGeoRotation("",180,180,kSuppSpacerAngle-90)));
3185   trayASuppStruct->AddNode(sideASuppSpacer, 4,
3186                            new TGeoCombiTrans(-xloc,-yloc, zloc,
3187                            new TGeoRotation("",270+kSuppSpacerAngle,0,0)));
3188
3189
3190   zloc += kSuppCylHeight/2;
3191   trayASuppStruct->AddNode(sideAIntSuppRing, 3,
3192                            new TGeoTranslation(0, 0, zloc) );
3193   trayASuppStruct->AddNode(sideAIntSuppRing, 4,
3194                            new TGeoCombiTrans( 0, 0, zloc,
3195                                                new TGeoRotation("",180,0,0)));
3196
3197   zloc += kIntSuppRingThick;
3198   trayASuppStruct->AddNode(sideAExtSuppRing, 3,
3199                            new TGeoTranslation(0, 0, zloc) );
3200   trayASuppStruct->AddNode(sideAExtSuppRing, 4,
3201                            new TGeoCombiTrans( 0, 0, zloc,
3202                                                new TGeoRotation("",180,0,0)));
3203
3204   zloc += kExtSuppRingThick;
3205   trayASuppStruct->AddNode(sideASuppForwRing, 1,
3206                            new TGeoTranslation(0, 0, zloc) );
3207   trayASuppStruct->AddNode(sideASuppForwRing, 2,
3208                            new TGeoCombiTrans( 0, 0, zloc,
3209                                                new TGeoRotation("",180,0,0)));
3210
3211   zloc += kSuppForwRingThikAll;
3212   trayASuppStruct->AddNode(sideASuppForwCone, 1,
3213                            new TGeoTranslation(0, 0, zloc) );
3214   trayASuppStruct->AddNode(sideASuppForwCone, 2,
3215                            new TGeoCombiTrans( 0, 0, zloc,
3216                                                new TGeoRotation("",180,0,0)));
3217
3218   zloc += (kSuppForwConeLen1+kSuppForwConeLen2);
3219   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 1,
3220                            new TGeoTranslation(0, 0, zloc) );
3221   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 2,
3222                            new TGeoCombiTrans( 0, 0, zloc,
3223                                                new TGeoRotation("",180,0,0)));
3224
3225   zloc += kSuppBackRingThick1;
3226   trayASuppStruct->AddNode(sideASecondSuppBackRing, 1,
3227                            new TGeoTranslation(0, 0, zloc) );
3228   trayASuppStruct->AddNode(sideASecondSuppBackRing, 2,
3229                            new TGeoCombiTrans( 0, 0, zloc,
3230                                                new TGeoRotation("",180,0,0)));
3231
3232   xloc = kSuppRearRingXRodHole;
3233   yloc = kSuppRearRingBaseHi + kSuppRearRingYRodHole;
3234   zloc = kRearSuppZTransGlob - kBackRodZTrans + suppRod->GetDz();
3235   trayASuppStruct->AddNode(sideASuppRod, 1,
3236                            new TGeoTranslation( xloc, yloc, zloc) );
3237   trayASuppStruct->AddNode(sideASuppRod, 2,
3238                            new TGeoTranslation(-xloc, yloc, zloc) );
3239   trayASuppStruct->AddNode(sideASuppRod, 3,
3240                            new TGeoTranslation( xloc,-yloc, zloc) );
3241   trayASuppStruct->AddNode(sideASuppRod, 4,
3242                            new TGeoTranslation(-xloc,-yloc, zloc) );
3243
3244   zloc += suppRod->GetDz();
3245   trayASuppStruct->AddNode(sideASuppRearRing, 1,
3246                            new TGeoTranslation( 0, 0, zloc) );
3247   trayASuppStruct->AddNode(sideASuppRearRing, 2,
3248                            new TGeoCombiTrans( 0, 0, zloc,
3249                                                new TGeoRotation("",180,0,0)));
3250
3251
3252   // Finally put everything in the mother volume
3253   moth->AddNode(trayASuppStruct,1,0);
3254
3255   return;
3256 }
3257
3258 //______________________________________________________________________
3259 void AliITSv11GeometrySupport::ServicesCableSupportSPD(TGeoVolume *moth,
3260                                                        TGeoManager *mgr){
3261 //
3262 // Creates the all SPD cable trays which are outside the ITS support cones
3263 // but still inside the TPC
3264 // In order to avoid a huge monolithic routine, this method actually
3265 // calls inner methods to create and assemble the various (macro)pieces
3266 //
3267 // Input:
3268 //         moth : the TGeoVolume owing the volume structure
3269 //         mgr  : the GeoManager (default gGeoManager)
3270 // Output:
3271 //
3272 // Created:         ???