update for the NUA
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySupport.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // This class Defines the Geometry for the ITS services and support cones
17 // outside of the ceneteral volume (except for the Ceneteral support 
18 // cylinders. Other classes define the rest of the ITS. Specificaly the ITS
19 // The SSD support cone,SSD Support centeral cylinder, SDD support cone,
20 // The SDD cupport centeral cylinder, the SPD Thermal Sheald, The supports
21 // and cable trays on both the RB26 (muon dump) and RB24 sides, and all of
22 // the cabling from the ladders/stave ends out past the TPC. 
23
24 /* $Id$ */
25 // General Root includes
26 #include <TMath.h>
27 // Root Geometry includes
28 //#include <AliLog.h>
29 #include <TGeoManager.h>
30 #include <TGeoVolume.h>
31 #include <TGeoPcon.h>
32 #include <TGeoCone.h>
33 #include <TGeoTube.h> // contaings TGeoTubeSeg
34 #include <TGeoArb8.h>
35 #include <TGeoXtru.h>
36 #include <TGeoCompositeShape.h>
37 #include <TGeoMatrix.h>
38 #include "AliITSv11GeometrySupport.h"
39
40 ClassImp(AliITSv11GeometrySupport)
41
42 #define SQ(A) (A)*(A)
43
44 //______________________________________________________________________
45 void AliITSv11GeometrySupport::SPDCone(TGeoVolume *moth,const TGeoManager *mgr)
46 {
47 //
48 // Creates the SPD thermal shield as a volume assembly
49 // and adds it to the mother volume
50 // (this is actually a merge of the previous SPDThermalSheald method
51 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06 and the
52 // CreateSPDThermalShield method of AliITSv11Hybrid)
53 //
54 // Input:
55 //         moth : the TGeoVolume owing the volume structure
56 //         mgr  : the GeoManager (default gGeoManager)
57 // Output:
58 //
59 // Created:         ???          ???
60 // Updated:      11 Dec 2007  Mario Sitta
61 // Updated:      20 Mar 2012  Mario Sitta  Reimplemented with simpler shapes
62 // Updated:      20 Jul 2012  Mario Sitta  Reimplemented with Composite Shape
63 // Updated:      12 Oct 2012  Mario Sitta  Composite Shape also for EndCap
64 //
65 // Technical data are taken from:  ALICE-Thermal Screen "Cone transition"
66 // (thermal-screen1_a3.ps), "Cylinder" (thermal-screen2_a3.ps), "Half
67 // assembly" (thermal-screen3_a3.ps), "Flange" (thermal-screen4_a3.ps)
68
69
70   // Dimensions of the Central shield
71   const Double_t kHalfLengthCentral  = 399.9*fgkmm;
72   const Double_t kThicknessCentral   = 0.4*fgkmm;
73   const Double_t kInnerRadiusCentral = 8.1475*fgkcm;
74   const Double_t kOuterRadiusCentral = 9.9255*fgkcm;
75   const Double_t kInnerACentral = 3.1674*fgkcm;
76   const Double_t kInnerBCentral = 2.023 *fgkcm;
77   const Double_t kOuterACentral = 2.4374*fgkcm;
78   const Double_t kOuterBCentral = 3.8162*fgkcm;
79   const Double_t kCoolManifHoleWid  = 24.0*fgkmm; // TO BE CHECKED!
80   const Double_t kCoolManifHoleLen  = 57.5*fgkmm; // 54.2 + 1.5*2 + 0.3 toll.
81   const Double_t kCoolManifHoleZPos = 36.47*fgkcm;// MUST match SPD class
82   const Double_t kCoolSuppHoleWid  = 15.0*fgkmm;
83   const Double_t kCoolSuppHoleLen  = 38.4*fgkmm; // 35.1 + 1.5*2 + 0.3 toll.// TO BE CHECKED!
84   const Double_t kCoolSuppHoleZPos = 26.5*fgkcm;
85   // Dimensions of the EndCap shield
86   const Double_t kHalfLengthEndCap  = 25.*fgkmm;
87   const Double_t kThicknessEndCap   = 2.0*fgkmm;
88   const Double_t kInnerRadiusEndCap = 8.0775*fgkcm;
89   const Double_t kOuterRadiusEndCap = 9.9955*fgkcm;
90   const Double_t kInnerAEndCap = 3.1453*fgkcm;
91   const Double_t kInnerBEndCap = 2.0009*fgkcm;
92   const Double_t kOuterAEndCap = 2.4596*fgkcm;
93   const Double_t kOuterBEndCap = 3.8384*fgkcm;
94   // Dimensions of the Cone shield
95   const Double_t kHalfLengthCone  = 145.*fgkmm;
96   const Double_t kThicknessCone   = 0.3*fgkmm;
97   const Double_t kInnerRadialCone = 37.3*fgkcm;
98   const Double_t kOuterRadialCone = 39.0*fgkcm;
99   const Double_t kInnerACone = 14.2344*fgkcm;
100   const Double_t kInnerBCone =  9.0915*fgkcm;
101   const Double_t kOuterACone =  9.5058*fgkcm;
102   const Double_t kOuterBCone = 14.8831*fgkcm;
103   // Dimensions of the filler blocks and bars
104   const Double_t kFillerBlockLength = 20.0*fgkmm;
105   const Double_t kFillerBlockHoleR  = 2.4*fgkmm;
106   const Double_t kFillerBlockZTrans = 1.5*fgkmm;
107   const Double_t kFillerBarLength = 220.0*fgkmm;
108   const Double_t kFillerBarThick  =   1.0*fgkmm;
109   // Dimensions of the Flange's Ring and Wing
110   const Double_t kHalfLengthRing  = 7.5*fgkmm;
111   const Double_t kThicknessRing   = 0.3*fgkmm;
112   const Double_t kInnerRadiusRing = 37.3*fgkcm;
113   const Double_t kOuterRadiusRing = 42.0*fgkcm;
114   const Double_t kOuterRadiusWing = 49.25*fgkcm;
115   const Double_t kWideWing      = 6.0*fgkcm;
116   const Double_t kThetaWing     = 45.0;
117   // Common data
118   const Double_t kThetaDeg = 36.0;
119   const Double_t kTheta = kThetaDeg*TMath::DegToRad();
120   const Double_t kThicknessOmega = 0.3*fgkmm;
121
122   // Local variables
123   Double_t xpos, ypos, zpos;
124   Double_t xXtru[24], yXtru[24];
125   Double_t xshld[24], yshld[24]; // Coord. of external thermal shape
126   Double_t xair[24] , yair[24];  // Coord. of whole air shape
127   Double_t xomega[48], yomega[48];
128
129
130   // The entire shield is made up of two half central shields
131   // symmetric with respect to the XZ plane, four half end cap
132   // shields, again symmetric with respect to the XZ plane, and four
133   // half cones, symmetric with respect to the XZ plane too.
134
135   TGeoVolumeAssembly *vM = new TGeoVolumeAssembly("ITSspdThermalShield");
136
137   // The central half shield: a Composite Shape of carbon fiber.
138   // We need Composite Shapes because we have holes in which the SPD
139   // cooling manifolds and their supports will be placed.
140   // All Composite elements are XTru shapes
141
142   // First determine the external shape points
143   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
144                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
145                         kTheta,xshld,yshld);
146
147   // Now rescale to get the air volume dimensions
148     InsidePoint(xshld[23], yshld[23],
149                 xshld[ 0], yshld[ 0],
150                 xshld[ 1], yshld[ 1], kThicknessCentral,
151                 xair[0], yair[0]);
152   for (Int_t i=1; i<23; i++) {
153     InsidePoint(xshld[i-1], yshld[i-1],
154                 xshld[ i ], yshld[ i ],
155                 xshld[i+1], yshld[i+1], kThicknessCentral,
156                 xair[i], yair[i]);
157   }
158     InsidePoint(xshld[22], yshld[22],
159                 xshld[23], yshld[23],
160                 xshld[ 0], yshld[ 0], kThicknessCentral,
161                 xair[23], yair[23]);
162
163   // Then use them to determine the Omega shape points
164   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
165
166   // Finally create the single Xtru volumes
167   TGeoXtru *uppershape = new TGeoXtru(2);
168   uppershape->SetName("upTS");
169
170   for (Int_t j=0; j<6; j++) {
171     xXtru[j  ] = xair[11-j];
172     yXtru[j  ] = yair[11-j];
173     xXtru[j+6] = xshld[j+6];
174     yXtru[j+6] = yshld[j+6];
175   }
176   yXtru[5] = yXtru[6];  // Air is not at same Y as thermal shield
177   for (Int_t j=0; j<12; j++) {
178     xXtru[23-j] = -xXtru[j];
179     yXtru[23-j] =  yXtru[j];
180   }
181
182   uppershape->DefinePolygon(24,xXtru,yXtru);
183   uppershape->DefineSection(0,-kHalfLengthCentral);
184   uppershape->DefineSection(1, kHalfLengthCentral);
185
186   TGeoXtru *lowershape = new TGeoXtru(2);
187   lowershape->SetName("lwTS");
188
189   for (Int_t j=0; j<6; j++) {
190     xXtru[j  ] = xshld[j];
191     yXtru[j  ] = yshld[j];
192     xXtru[j+6] = xair[5-j];
193     yXtru[j+6] = yair[5-j];
194   }
195   yXtru[6] = yXtru[5];  // Air is not at same Y as thermal shield
196   for (Int_t j=0; j<12; j++) {
197     xXtru[23-j] = -xXtru[j];
198     yXtru[23-j] =  yXtru[j];
199   }
200
201   lowershape->DefinePolygon(24,xXtru,yXtru);
202   lowershape->DefineSection(0,-kHalfLengthCentral);
203   lowershape->DefineSection(1, kHalfLengthCentral);
204
205   yomega[10] = yshld[6];   // Add also base thickness
206   yomega[11] = yomega[10];
207   yomega[36] = yshld[17];
208   yomega[37] = yomega[36];
209
210   TGeoXtru *omegashape = new TGeoXtru(2);
211   omegashape->SetName("omTS");
212
213   omegashape->DefinePolygon(48,xomega,yomega);
214   omegashape->DefineSection(0,-kHalfLengthCentral);
215   omegashape->DefineSection(1, kHalfLengthCentral);
216
217   // And now the holes and their position matrices
218   Double_t radius = 0.5*(uppershape->GetY(11)+lowershape->GetY(0));
219
220   TGeoBBox *manifhole = new TGeoBBox(kCoolManifHoleWid/2,
221           0.55*(uppershape->GetY(11)-lowershape->GetY(0)),
222                                      kCoolManifHoleLen/2);
223   manifhole->SetName("mhTS");
224
225   zpos = kCoolManifHoleZPos;
226
227   TGeoTranslation *m1p = new TGeoTranslation("m1p",0,radius, zpos);
228   TGeoTranslation *m1n = new TGeoTranslation("m1n",0,radius,-zpos);
229   m1p->RegisterYourself();
230   m1n->RegisterYourself();
231
232   TGeoCombiTrans *m2p = new TGeoCombiTrans("m2p",radius*SinD(kThetaDeg),
233                                                  radius*CosD(kThetaDeg),
234                                            zpos,
235                                         new TGeoRotation("",-kThetaDeg,0,0));
236   TGeoCombiTrans *m2n = new TGeoCombiTrans("m2n",radius*SinD(kThetaDeg),
237                                                  radius*CosD(kThetaDeg),
238                                           -zpos,
239                                         new TGeoRotation("",-kThetaDeg,0,0));
240   m2p->RegisterYourself();
241   m2n->RegisterYourself();
242
243   TGeoCombiTrans *m3p = new TGeoCombiTrans("m3p",radius*SinD(-kThetaDeg),
244                                                  radius*CosD(-kThetaDeg),
245                                            zpos,
246                                         new TGeoRotation("",kThetaDeg,0,0));
247   TGeoCombiTrans *m3n = new TGeoCombiTrans("m3n",radius*SinD(-kThetaDeg),
248                                                  radius*CosD(-kThetaDeg),
249                                           -zpos,
250                                         new TGeoRotation("",kThetaDeg,0,0));
251   m3p->RegisterYourself();
252   m3n->RegisterYourself();
253
254   TGeoCombiTrans *m4p = new TGeoCombiTrans("m4p",radius*SinD(2*kThetaDeg),
255                                                  radius*CosD(2*kThetaDeg),
256                                            zpos,
257                                         new TGeoRotation("",-2*kThetaDeg,0,0));
258   TGeoCombiTrans *m4n = new TGeoCombiTrans("m4n",radius*SinD(2*kThetaDeg),
259                                                  radius*CosD(2*kThetaDeg),
260                                           -zpos,
261                                         new TGeoRotation("",-2*kThetaDeg,0,0));
262   m4p->RegisterYourself();
263   m4n->RegisterYourself();
264
265   TGeoCombiTrans *m5p = new TGeoCombiTrans("m5p",radius*SinD(-2*kThetaDeg),
266                                                  radius*CosD(-2*kThetaDeg),
267                                            zpos,
268                                         new TGeoRotation("",2*kThetaDeg,0,0));
269   TGeoCombiTrans *m5n = new TGeoCombiTrans("m5n",radius*SinD(-2*kThetaDeg),
270                                                  radius*CosD(-2*kThetaDeg),
271                                           -zpos,
272                                         new TGeoRotation("",2*kThetaDeg,0,0));
273   m5p->RegisterYourself();
274   m5n->RegisterYourself();
275
276   TGeoBBox *supphole = new TGeoBBox(kCoolSuppHoleWid/2,
277          0.55*(uppershape->GetY(11)-lowershape->GetY(0)),
278                                     kCoolSuppHoleLen/2);
279   supphole->SetName("shTS");
280
281   zpos = kCoolSuppHoleZPos;
282
283   TGeoTranslation *s1p = new TGeoTranslation("s1p",0,radius, zpos);
284   TGeoTranslation *s1n = new TGeoTranslation("s1n",0,radius,-zpos);
285   s1p->RegisterYourself();
286   s1n->RegisterYourself();
287
288   TGeoCombiTrans *s2p = new TGeoCombiTrans("s2p",radius*SinD(kThetaDeg),
289                                                  radius*CosD(kThetaDeg),
290                                            zpos,
291                                         new TGeoRotation("",-kThetaDeg,0,0));
292   TGeoCombiTrans *s2n = new TGeoCombiTrans("s2n",radius*SinD(kThetaDeg),
293                                                  radius*CosD(kThetaDeg),
294                                           -zpos,
295                                         new TGeoRotation("",-kThetaDeg,0,0));
296   s2p->RegisterYourself();
297   s2n->RegisterYourself();
298
299   TGeoCombiTrans *s3p = new TGeoCombiTrans("s3p",radius*SinD(-kThetaDeg),
300                                                  radius*CosD(-kThetaDeg),
301                                            zpos,
302                                         new TGeoRotation("",kThetaDeg,0,0));
303   TGeoCombiTrans *s3n = new TGeoCombiTrans("s3n",radius*SinD(-kThetaDeg),
304                                                  radius*CosD(-kThetaDeg),
305                                           -zpos,
306                                         new TGeoRotation("",kThetaDeg,0,0));
307   s3p->RegisterYourself();
308   s3n->RegisterYourself();
309
310   TGeoCombiTrans *s4p = new TGeoCombiTrans("s4p",radius*SinD(2*kThetaDeg),
311                                                  radius*CosD(2*kThetaDeg),
312                                            zpos,
313                                         new TGeoRotation("",-2*kThetaDeg,0,0));
314   TGeoCombiTrans *s4n = new TGeoCombiTrans("s4n",radius*SinD(2*kThetaDeg),
315                                                  radius*CosD(2*kThetaDeg),
316                                           -zpos,
317                                         new TGeoRotation("",-2*kThetaDeg,0,0));
318   s4p->RegisterYourself();
319   s4n->RegisterYourself();
320
321   TGeoCombiTrans *s5p = new TGeoCombiTrans("s5p",radius*SinD(-2*kThetaDeg),
322                                                  radius*CosD(-2*kThetaDeg),
323                                            zpos,
324                                         new TGeoRotation("",2*kThetaDeg,0,0));
325   TGeoCombiTrans *s5n = new TGeoCombiTrans("s5n",radius*SinD(-2*kThetaDeg),
326                                                  radius*CosD(-2*kThetaDeg),
327                                           -zpos,
328                                         new TGeoRotation("",2*kThetaDeg,0,0));
329   s5p->RegisterYourself();
330   s5n->RegisterYourself();
331
332   // Finally the actual shape
333   TGeoCompositeShape *centralshape = new TGeoCompositeShape("centralTS",
334     "upTS+lwTS+omTS-mhTS:m1p-mhTS:m1n-mhTS:m2p-mhTS:m2n-mhTS:m3p-mhTS:m3n-mhTS:m4p-mhTS:m4n-mhTS:m5p-mhTS:m5n-shTS:s1p-shTS:s1n-shTS:s2p-shTS:s2n-shTS:s3p-shTS:s3n-shTS:s4p-shTS:s4n-shTS:s5p-shTS:s5n");
335
336   // The end cap half shield: a Composite Shape of carbon fiber.
337   // We need Composite Shapes because we have elements partially
338   // entering the empty spaces, and this would create overlaps or
339   // extrusions.
340   // All Composite elements are XTru shapes
341
342   // First determine the external shape points
343   CreateSPDThermalShape(kInnerAEndCap,kInnerBEndCap,kInnerRadiusEndCap,
344                         kOuterAEndCap,kOuterBEndCap,kOuterRadiusEndCap,
345                         kTheta,xshld,yshld);
346
347   // Now rescale to get the air volume dimensions
348     InsidePoint(xshld[23], yshld[23],
349                 xshld[ 0], yshld[ 0],
350                 xshld[ 1], yshld[ 1], kThicknessEndCap,
351                 xair[0], yair[0]);
352   for (Int_t i=1; i<23; i++) {
353     InsidePoint(xshld[i-1], yshld[i-1],
354                 xshld[ i ], yshld[ i ],
355                 xshld[i+1], yshld[i+1], kThicknessEndCap,
356                 xair[i], yair[i]);
357   }
358     InsidePoint(xshld[22], yshld[22],
359                 xshld[23], yshld[23],
360                 xshld[ 0], yshld[ 0], kThicknessEndCap,
361                 xair[23], yair[23]);
362
363   // Then use them to determine the Omega shape points
364   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
365
366   // Finally create the single Xtru volumes
367   TGeoXtru *upendcapshape = new TGeoXtru(2);
368   upendcapshape->SetName("upEC");
369
370   for (Int_t j=0; j<6; j++) {
371     xXtru[j  ] = xair[11-j];
372     yXtru[j  ] = yair[11-j];
373     xXtru[j+6] = xshld[j+6];
374     yXtru[j+6] = yshld[j+6];
375   }
376   yXtru[5] = yXtru[6];  // Air is not at same Y as thermal shield
377   for (Int_t j=0; j<12; j++) {
378     xXtru[23-j] = -xXtru[j];
379     yXtru[23-j] =  yXtru[j];
380   }
381
382   upendcapshape->DefinePolygon(24,xXtru,yXtru);
383   upendcapshape->DefineSection(0,-kHalfLengthEndCap);
384   upendcapshape->DefineSection(1, kHalfLengthEndCap);
385
386   TGeoXtru *lowendcapshape = new TGeoXtru(2);
387   lowendcapshape->SetName("lwEC");
388
389   for (Int_t j=0; j<6; j++) {
390     xXtru[j  ] = xshld[j];
391     yXtru[j  ] = yshld[j];
392     xXtru[j+6] = xair[5-j];
393     yXtru[j+6] = yair[5-j];
394   }
395   yXtru[6] = yXtru[5];  // Air is not at same Y as thermal shield
396   for (Int_t j=0; j<12; j++) {
397     xXtru[23-j] = -xXtru[j];
398     yXtru[23-j] =  yXtru[j];
399   }
400
401   lowendcapshape->DefinePolygon(24,xXtru,yXtru);
402   lowendcapshape->DefineSection(0,-kHalfLengthEndCap);
403   lowendcapshape->DefineSection(1, kHalfLengthEndCap);
404
405   yomega[10] = yshld[6];   // Add also base thickness
406   yomega[11] = yomega[10];
407   yomega[36] = yshld[17];
408   yomega[37] = yomega[36];
409
410   TGeoXtru *omgendcapshape = new TGeoXtru(2);
411   omgendcapshape->SetName("omEC");
412
413   omgendcapshape->DefinePolygon(48,xomega,yomega);
414   omgendcapshape->DefineSection(0,-kHalfLengthEndCap);
415   omgendcapshape->DefineSection(1, kHalfLengthEndCap);
416
417   // Finally the actual shape
418   TGeoCompositeShape *endcapshape = new TGeoCompositeShape("endcapTS",
419                                                            "upEC+lwEC+omEC");
420
421   // The filler block: a Xtru
422   TGeoXtru *fillershape = new TGeoXtru(2);
423
424   xXtru[0] = omgendcapshape->GetX(1) + 0.0002; // Avoid thiny extrusion
425   yXtru[0] = omgendcapshape->GetY(1);
426   xXtru[1] = omgendcapshape->GetX(0) + 0.0002;
427   yXtru[1] = omgendcapshape->GetY(0);
428   xXtru[2] = omgendcapshape->GetX(47) - 0.0002;
429   yXtru[2] = omgendcapshape->GetY(47);
430   xXtru[3] = omgendcapshape->GetX(46);
431   yXtru[3] = omgendcapshape->GetY(46);
432
433   fillershape->DefinePolygon(4,xXtru,yXtru);
434   fillershape->DefineSection(0,-kFillerBlockLength/2);
435   fillershape->DefineSection(1, kFillerBlockLength/2);
436
437   // The hole in the filler: a Tube (made of air)
438   TGeoTube *fillerholeshape = new TGeoTube(0, kFillerBlockHoleR,
439                                            kFillerBlockLength/2);
440
441   // The filler bar: a BBox
442   Double_t fside = omgendcapshape->GetY(14) - omgendcapshape->GetY(13);
443   TGeoBBox *fillbarshape = new TGeoBBox(fside/2, fside/2, kFillerBarLength/2);
444
445   // The hole in the bar filler: a smaller BBox (made of air)
446   fside -= 2*kFillerBarThick;
447   TGeoBBox *fillbarholeshape = new TGeoBBox(fside/2, fside/2,
448                                             kFillerBarLength/2);
449
450   // The cone half shield is more complex since there is no basic
451   // TGeo shape to describe it correctly. So it is a Composite Shape
452   // of a series of TGeoArb8 shapes, in which TGeoArb8 shapes filled
453   // with air are placed, which all together make up the cone AND
454   // its internal insert. Part of the following code is adapted from
455   // old SPDThermalSheald method.
456
457   // sCn : Filled portions, sChn : Air holes
458   TGeoArb8 *sC1  = new TGeoArb8(kHalfLengthCone);
459   TGeoArb8 *sC2  = new TGeoArb8(kHalfLengthCone);
460   TGeoArb8 *sC3  = new TGeoArb8(kHalfLengthCone);
461   TGeoArb8 *sC4  = new TGeoArb8(kHalfLengthCone);
462   TGeoArb8 *sC5  = new TGeoArb8(kHalfLengthCone);
463   TGeoArb8 *sC6  = new TGeoArb8(kHalfLengthCone);
464   TGeoArb8 *sC7  = new TGeoArb8(kHalfLengthCone);
465   TGeoArb8 *sC8  = new TGeoArb8(kHalfLengthCone);
466   TGeoArb8 *sC9  = new TGeoArb8(kHalfLengthCone);
467   TGeoArb8 *sC10 = new TGeoArb8(kHalfLengthCone);
468   TGeoArb8 *sC11 = new TGeoArb8(kHalfLengthCone);
469
470   sC1->SetName("sC1");
471   sC2->SetName("sC2");
472   sC3->SetName("sC3");
473   sC4->SetName("sC4");
474   sC5->SetName("sC5");
475   sC6->SetName("sC6");
476   sC7->SetName("sC7");
477   sC8->SetName("sC8");
478   sC9->SetName("sC9");
479   sC10->SetName("sC10");
480   sC11->SetName("sC11");
481
482   TGeoArb8 *sCh1  = new TGeoArb8(kHalfLengthCone);
483   TGeoArb8 *sCh2  = new TGeoArb8(kHalfLengthCone);
484   TGeoArb8 *sCh3  = new TGeoArb8(kHalfLengthCone);
485   TGeoArb8 *sCh4  = new TGeoArb8(kHalfLengthCone);
486   TGeoArb8 *sCh5  = new TGeoArb8(kHalfLengthCone);
487   TGeoArb8 *sCh6  = new TGeoArb8(kHalfLengthCone);
488   TGeoArb8 *sCh7  = new TGeoArb8(kHalfLengthCone);
489   TGeoArb8 *sCh8  = new TGeoArb8(kHalfLengthCone);
490   TGeoArb8 *sCh9  = new TGeoArb8(kHalfLengthCone);
491   TGeoArb8 *sCh10 = new TGeoArb8(kHalfLengthCone);
492   TGeoArb8 *sCh11 = new TGeoArb8(kHalfLengthCone);
493
494   sCh1->SetName("sCh1");
495   sCh2->SetName("sCh2");
496   sCh3->SetName("sCh3");
497   sCh4->SetName("sCh4");
498   sCh5->SetName("sCh5");
499   sCh6->SetName("sCh6");
500   sCh7->SetName("sCh7");
501   sCh8->SetName("sCh8");
502   sCh9->SetName("sCh9");
503   sCh10->SetName("sCh10");
504   sCh11->SetName("sCh11");
505
506   // Smaller end: determine the coordinates of the points of carbon fiber
507   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
508                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
509                         kTheta,xshld,yshld);
510
511   sC1->SetVertex(0, xshld[12], yshld[12]);
512   sC1->SetVertex(1, xshld[11], yshld[11]);
513   sC1->SetVertex(2, xshld[ 0], yshld[ 0]);
514   sC1->SetVertex(3, xshld[23], yshld[23]);
515
516   sC2->SetVertex(0, xshld[11], yshld[11]);
517   sC2->SetVertex(1, xshld[10], yshld[10]);
518   sC2->SetVertex(2, xshld[ 1], yshld[ 1]);
519   sC2->SetVertex(3, xshld[ 0], yshld[ 0]);
520
521   sC3->SetVertex(0, xshld[10], yshld[10]);
522   sC3->SetVertex(1, xshld[ 9], yshld[ 9]);
523   sC3->SetVertex(2, xshld[ 2], yshld[ 2]);
524   sC3->SetVertex(3, xshld[ 1], yshld[ 1]);
525
526   sC4->SetVertex(0, xshld[ 9], yshld[ 9]);
527   sC4->SetVertex(1, xshld[ 8], yshld[ 8]);
528   sC4->SetVertex(2, xshld[ 3], yshld[ 3]);
529   sC4->SetVertex(3, xshld[ 2], yshld[ 2]);
530
531   sC5->SetVertex(0, xshld[ 8], yshld[ 8]);
532   sC5->SetVertex(1, xshld[ 7], yshld[ 7]);
533   sC5->SetVertex(2, xshld[ 4], yshld[ 4]);
534   sC5->SetVertex(3, xshld[ 3], yshld[ 3]);
535
536   sC6->SetVertex(0, xshld[ 7], yshld[ 7]);
537   sC6->SetVertex(1, xshld[ 6], yshld[ 6]);
538   sC6->SetVertex(2, xshld[ 5], yshld[ 5]);
539   sC6->SetVertex(3, xshld[ 4], yshld[ 4]);
540
541   sC7->SetVertex(0,-xshld[10], yshld[10]);
542   sC7->SetVertex(1,-xshld[11], yshld[11]);
543   sC7->SetVertex(2,-xshld[ 0], yshld[ 0]);
544   sC7->SetVertex(3,-xshld[ 1], yshld[ 1]);
545
546   sC8->SetVertex(0,-xshld[ 9], yshld[ 9]);
547   sC8->SetVertex(1,-xshld[10], yshld[10]);
548   sC8->SetVertex(2,-xshld[ 1], yshld[ 1]);
549   sC8->SetVertex(3,-xshld[ 2], yshld[ 2]);
550
551   sC9->SetVertex(0,-xshld[ 8], yshld[ 8]);
552   sC9->SetVertex(1,-xshld[ 9], yshld[ 9]);
553   sC9->SetVertex(2,-xshld[ 2], yshld[ 2]);
554   sC9->SetVertex(3,-xshld[ 3], yshld[ 3]);
555
556   sC10->SetVertex(0,-xshld[ 7], yshld[ 7]);
557   sC10->SetVertex(1,-xshld[ 8], yshld[ 8]);
558   sC10->SetVertex(2,-xshld[ 3], yshld[ 3]);
559   sC10->SetVertex(3,-xshld[ 4], yshld[ 4]);
560
561   sC11->SetVertex(0,-xshld[ 6], yshld[ 6]);
562   sC11->SetVertex(1,-xshld[ 7], yshld[ 7]);
563   sC11->SetVertex(2,-xshld[ 4], yshld[ 4]);
564   sC11->SetVertex(3,-xshld[ 5], yshld[ 5]);
565
566   // Then rescale to get the air volume dimensions
567     InsidePoint(xshld[23], yshld[23],
568                 xshld[ 0], yshld[ 0],
569                 xshld[ 1], yshld[ 1], kThicknessCone,
570                 xair[0], yair[0]);
571   for (Int_t i=1; i<23; i++) {
572     InsidePoint(xshld[i-1], yshld[i-1],
573                 xshld[ i ], yshld[ i ],
574                 xshld[i+1], yshld[i+1], kThicknessCone,
575                 xair[i], yair[i]);
576   }
577     InsidePoint(xshld[22], yshld[22],
578                 xshld[23], yshld[23],
579                 xshld[ 0], yshld[ 0], kThicknessCone,
580                 xair[23], yair[23]);
581
582   // Then use them to determine the Omega shape points
583   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
584
585   // Finally fill the small end coordinates of the air shapes
586   sCh1->SetVertex(0, xomega[ 0], yomega[ 0]);
587   sCh1->SetVertex(1, xomega[ 1], yomega[ 1]);
588   sCh1->SetVertex(2,-xomega[ 1], yomega[ 1]);
589   sCh1->SetVertex(3,-xomega[ 0], yomega[ 0]);
590
591   sCh2->SetVertex(0, xomega[20], yomega[20]);
592   sCh2->SetVertex(1, xomega[21], yomega[21]);
593   sCh2->SetVertex(2, xomega[22], yomega[22]);
594   sCh2->SetVertex(3, xomega[23], yomega[23]);
595
596   sCh3->SetVertex(0, xomega[ 2], yomega[ 2]);
597   sCh3->SetVertex(1, xomega[ 3], yomega[ 3]);
598   sCh3->SetVertex(2, xomega[ 4], yomega[ 4]);
599   sCh3->SetVertex(3, xomega[ 5], yomega[ 5]);
600
601   sCh4->SetVertex(0, xomega[16], yomega[16]);
602   sCh4->SetVertex(1, xomega[17], yomega[17]);
603   sCh4->SetVertex(2, xomega[18], yomega[18]);
604   sCh4->SetVertex(3, xomega[19], yomega[19]);
605
606   sCh5->SetVertex(0, xomega[ 6], yomega[ 6]);
607   sCh5->SetVertex(1, xomega[ 7], yomega[ 7]);
608   sCh5->SetVertex(2, xomega[ 8], yomega[ 8]);
609   sCh5->SetVertex(3, xomega[ 9], yomega[ 9]);
610
611   sCh6->SetVertex(0, xomega[12], yomega[12]);
612   sCh6->SetVertex(1, xomega[13], yomega[13]);
613   sCh6->SetVertex(2, xomega[14], yomega[14]);
614   sCh6->SetVertex(3, xomega[15], yomega[15]);
615
616   sCh7->SetVertex(0,-xomega[21], yomega[21]);
617   sCh7->SetVertex(1,-xomega[20], yomega[20]);
618   sCh7->SetVertex(2,-xomega[23], yomega[23]);
619   sCh7->SetVertex(3,-xomega[22], yomega[22]);
620
621   sCh8->SetVertex(0,-xomega[ 3], yomega[ 3]);
622   sCh8->SetVertex(1,-xomega[ 2], yomega[ 2]);
623   sCh8->SetVertex(2,-xomega[ 5], yomega[ 5]);
624   sCh8->SetVertex(3,-xomega[ 4], yomega[ 4]);
625
626   sCh9->SetVertex(0,-xomega[17], yomega[17]);
627   sCh9->SetVertex(1,-xomega[16], yomega[16]);
628   sCh9->SetVertex(2,-xomega[19], yomega[19]);
629   sCh9->SetVertex(3,-xomega[18], yomega[18]);
630
631   sCh10->SetVertex(0,-xomega[ 7], yomega[ 7]);
632   sCh10->SetVertex(1,-xomega[ 6], yomega[ 6]);
633   sCh10->SetVertex(2,-xomega[ 9], yomega[ 9]);
634   sCh10->SetVertex(3,-xomega[ 8], yomega[ 8]);
635
636   sCh11->SetVertex(0,-xomega[13], yomega[13]);
637   sCh11->SetVertex(1,-xomega[12], yomega[12]);
638   sCh11->SetVertex(2,-xomega[15], yomega[15]);
639   sCh11->SetVertex(3,-xomega[14], yomega[14]);
640
641   // Bigger end: determine the coordinates of the points of carbon fiber
642
643   // Drawings give only the radius, convert it to the apothegm
644   Double_t kInnerRadiusCone = TMath::Sqrt(kInnerRadialCone*kInnerRadialCone
645                                           - 0.25*kInnerACone*kInnerACone);
646   Double_t kOuterRadiusCone = TMath::Sqrt(kOuterRadialCone*kOuterRadialCone
647                                           - 0.25*kOuterACone*kOuterACone);
648
649   CreateSPDThermalShape(kInnerACone,kInnerBCone,kInnerRadiusCone,
650                         kOuterACone,kOuterBCone,kOuterRadiusCone,
651                         kTheta,xshld,yshld);
652
653   sC1->SetVertex(4, xshld[12], yshld[12]);
654   sC1->SetVertex(5, xshld[11], yshld[11]);
655   sC1->SetVertex(6, xshld[ 0], yshld[ 0]);
656   sC1->SetVertex(7, xshld[23], yshld[23]);
657
658   sC2->SetVertex(4, xshld[11], yshld[11]);
659   sC2->SetVertex(5, xshld[10], yshld[10]);
660   sC2->SetVertex(6, xshld[ 1], yshld[ 1]);
661   sC2->SetVertex(7, xshld[ 0], yshld[ 0]);
662
663   sC3->SetVertex(4, xshld[10], yshld[10]);
664   sC3->SetVertex(5, xshld[ 9], yshld[ 9]);
665   sC3->SetVertex(6, xshld[ 2], yshld[ 2]);
666   sC3->SetVertex(7, xshld[ 1], yshld[ 1]);
667
668   sC4->SetVertex(4, xshld[ 9], yshld[ 9]);
669   sC4->SetVertex(5, xshld[ 8], yshld[ 8]);
670   sC4->SetVertex(6, xshld[ 3], yshld[ 3]);
671   sC4->SetVertex(7, xshld[ 2], yshld[ 2]);
672
673   sC5->SetVertex(4, xshld[ 8], yshld[ 8]);
674   sC5->SetVertex(5, xshld[ 7], yshld[ 7]);
675   sC5->SetVertex(6, xshld[ 4], yshld[ 4]);
676   sC5->SetVertex(7, xshld[ 3], yshld[ 3]);
677
678   sC6->SetVertex(4, xshld[ 7], yshld[ 7]);
679   sC6->SetVertex(5, xshld[ 6], yshld[ 6]);
680   sC6->SetVertex(6, xshld[ 5], yshld[ 5]);
681   sC6->SetVertex(7, xshld[ 4], yshld[ 4]);
682
683   sC7->SetVertex(4,-xshld[10], yshld[10]);
684   sC7->SetVertex(5,-xshld[11], yshld[11]);
685   sC7->SetVertex(6,-xshld[ 0], yshld[ 0]);
686   sC7->SetVertex(7,-xshld[ 1], yshld[ 1]);
687
688   sC8->SetVertex(4,-xshld[ 9], yshld[ 9]);
689   sC8->SetVertex(5,-xshld[10], yshld[10]);
690   sC8->SetVertex(6,-xshld[ 1], yshld[ 1]);
691   sC8->SetVertex(7,-xshld[ 2], yshld[ 2]);
692
693   sC9->SetVertex(4,-xshld[ 8], yshld[ 8]);
694   sC9->SetVertex(5,-xshld[ 9], yshld[ 9]);
695   sC9->SetVertex(6,-xshld[ 2], yshld[ 2]);
696   sC9->SetVertex(7,-xshld[ 3], yshld[ 3]);
697
698   sC10->SetVertex(4,-xshld[ 7], yshld[ 7]);
699   sC10->SetVertex(5,-xshld[ 8], yshld[ 8]);
700   sC10->SetVertex(6,-xshld[ 3], yshld[ 3]);
701   sC10->SetVertex(7,-xshld[ 4], yshld[ 4]);
702
703   sC11->SetVertex(4,-xshld[ 6], yshld[ 6]);
704   sC11->SetVertex(5,-xshld[ 7], yshld[ 7]);
705   sC11->SetVertex(6,-xshld[ 4], yshld[ 4]);
706   sC11->SetVertex(7,-xshld[ 5], yshld[ 5]);
707
708   // Then rescale to get the air volume dimensions
709     InsidePoint(xshld[23], yshld[23],
710                 xshld[ 0], yshld[ 0],
711                 xshld[ 1], yshld[ 1], kThicknessCone,
712                 xair[0], yair[0]);
713   for (Int_t i=1; i<23; i++) {
714     InsidePoint(xshld[i-1], yshld[i-1],
715                 xshld[ i ], yshld[ i ],
716                 xshld[i+1], yshld[i+1], kThicknessCone,
717                 xair[i], yair[i]);
718   }
719     InsidePoint(xshld[22], yshld[22],
720                 xshld[23], yshld[23],
721                 xshld[ 0], yshld[ 0], kThicknessCone,
722                 xair[23], yair[23]);
723
724   // Then use them to determine the Omega shape points
725   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
726
727   // Finally fill the big end coordinates of the air shapes
728   sCh1->SetVertex(4, xomega[ 0], yomega[ 0]);
729   sCh1->SetVertex(5, xomega[ 1], yomega[ 1]);
730   sCh1->SetVertex(6,-xomega[ 1], yomega[ 1]);
731   sCh1->SetVertex(7,-xomega[ 0], yomega[ 0]);
732
733   sCh2->SetVertex(4, xomega[20], yomega[20]);
734   sCh2->SetVertex(5, xomega[21], yomega[21]);
735   sCh2->SetVertex(6, xomega[22], yomega[22]);
736   sCh2->SetVertex(7, xomega[23], yomega[23]);
737
738   sCh3->SetVertex(4, xomega[ 2], yomega[ 2]);
739   sCh3->SetVertex(5, xomega[ 3], yomega[ 3]);
740   sCh3->SetVertex(6, xomega[ 4], yomega[ 4]);
741   sCh3->SetVertex(7, xomega[ 5], yomega[ 5]);
742
743   sCh4->SetVertex(4, xomega[16], yomega[16]);
744   sCh4->SetVertex(5, xomega[17], yomega[17]);
745   sCh4->SetVertex(6, xomega[18], yomega[18]);
746   sCh4->SetVertex(7, xomega[19], yomega[19]);
747
748   sCh5->SetVertex(4, xomega[ 6], yomega[ 6]);
749   sCh5->SetVertex(5, xomega[ 7], yomega[ 7]);
750   sCh5->SetVertex(6, xomega[ 8], yomega[ 8]);
751   sCh5->SetVertex(7, xomega[ 9], yomega[ 9]);
752
753   sCh6->SetVertex(4, xomega[12], yomega[12]);
754   sCh6->SetVertex(5, xomega[13], yomega[13]);
755   sCh6->SetVertex(6, xomega[14], yomega[14]);
756   sCh6->SetVertex(7, xomega[15], yomega[15]);
757
758   sCh7->SetVertex(4,-xomega[21], yomega[21]);
759   sCh7->SetVertex(5,-xomega[20], yomega[20]);
760   sCh7->SetVertex(6,-xomega[23], yomega[23]);
761   sCh7->SetVertex(7,-xomega[22], yomega[22]);
762
763   sCh8->SetVertex(4,-xomega[ 3], yomega[ 3]);
764   sCh8->SetVertex(5,-xomega[ 2], yomega[ 2]);
765   sCh8->SetVertex(6,-xomega[ 5], yomega[ 5]);
766   sCh8->SetVertex(7,-xomega[ 4], yomega[ 4]);
767
768   sCh9->SetVertex(4,-xomega[17], yomega[17]);
769   sCh9->SetVertex(5,-xomega[16], yomega[16]);
770   sCh9->SetVertex(6,-xomega[19], yomega[19]);
771   sCh9->SetVertex(7,-xomega[18], yomega[18]);
772
773   sCh10->SetVertex(4,-xomega[ 7], yomega[ 7]);
774   sCh10->SetVertex(5,-xomega[ 6], yomega[ 6]);
775   sCh10->SetVertex(6,-xomega[ 9], yomega[ 9]);
776   sCh10->SetVertex(7,-xomega[ 8], yomega[ 8]);
777
778   sCh11->SetVertex(4,-xomega[13], yomega[13]);
779   sCh11->SetVertex(5,-xomega[12], yomega[12]);
780   sCh11->SetVertex(6,-xomega[15], yomega[15]);
781   sCh11->SetVertex(7,-xomega[14], yomega[14]);
782
783   // Now the actual carbon fiber cone: a CompositeShape
784   TGeoCompositeShape *sCone = new TGeoCompositeShape("sCone",
785                             "sC1+sC2+sC3+sC4+sC5+sC6+sC7+sC8+sC9+sC10+sC11");
786
787   // Finally the carbon fiber Ring with its Wings and their
788   // stesalite inserts. They are Tube and TubeSeg shapes
789
790   TGeoTube *ringshape = new TGeoTube(kInnerRadiusRing,kOuterRadiusRing,
791                                      kHalfLengthRing);
792
793   TGeoTube *ringinsertshape = new TGeoTube(kInnerRadiusRing+kThicknessRing,
794                                            kOuterRadiusRing-kThicknessRing,
795                                            kHalfLengthRing-kThicknessRing);
796
797   Double_t angleWideWing, angleWideWingThickness;
798   angleWideWing = (kWideWing/kOuterRadiusWing)*TMath::RadToDeg();
799   angleWideWingThickness = (kThicknessRing/kOuterRadiusWing)*TMath::RadToDeg();
800
801   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kOuterRadiusRing,kOuterRadiusWing,
802                                            kHalfLengthRing, 0, angleWideWing);
803
804   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kOuterRadiusRing,
805              kOuterRadiusWing-kThicknessRing, kHalfLengthRing-kThicknessRing,
806              angleWideWingThickness, angleWideWing-angleWideWingThickness);
807
808
809   // We have the shapes: now create the real volumes
810
811   TGeoMedium *medSPDcf  = mgr->GetMedium("ITS_SPD shield$");
812   TGeoMedium *medSPDair = mgr->GetMedium("ITS_SPD AIR$");
813   TGeoMedium *medSPDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
814
815   TGeoVolume *centralshield = new TGeoVolume("SPDcentralshield",
816                                              centralshape,medSPDcf);
817   centralshield->SetVisibility(kTRUE);
818   centralshield->SetLineColor(7);
819   centralshield->SetLineWidth(1);
820   centralshield->SetFillColor(centralshield->GetLineColor());
821   centralshield->SetFillStyle(4090); // 90% transparent
822
823   TGeoVolume *endcapshield = new TGeoVolume("SPDendcapshield",
824                                              endcapshape,medSPDcf);
825   endcapshield->SetVisibility(kTRUE);
826   endcapshield->SetLineColor(7);
827   endcapshield->SetLineWidth(1);
828   endcapshield->SetFillColor(endcapshield->GetLineColor());
829   endcapshield->SetFillStyle(4090); // 90% transparent
830
831   TGeoVolume *fillerblock = new TGeoVolume("SPDfillerblock",
832                                            fillershape,medSPDcf);
833   fillerblock->SetVisibility(kTRUE);
834   fillerblock->SetLineColor(7);
835   fillerblock->SetLineWidth(1);
836   fillerblock->SetFillColor(fillerblock->GetLineColor());
837   fillerblock->SetFillStyle(4090); // 90% transparent
838
839   TGeoVolume *fillerhole = new TGeoVolume("SPDfillerhole",
840                                           fillerholeshape,medSPDair);
841   fillerhole->SetVisibility(kTRUE);
842   fillerhole->SetLineColor(5); // Yellow
843   fillerhole->SetLineWidth(1);
844   fillerhole->SetFillColor(fillerhole->GetLineColor());
845   fillerhole->SetFillStyle(4090); // 90% transparent
846
847   ypos = (fillershape->GetY(0)+fillershape->GetY(1))/2;
848   fillerblock->AddNode(fillerhole, 1, new TGeoTranslation(0, ypos, 0));
849
850   zpos = omgendcapshape->GetZ(1) - fillershape->GetZ(1) - kFillerBlockZTrans;
851   endcapshield->AddNode(fillerblock, 1, new TGeoTranslation(0, 0, zpos));
852   endcapshield->AddNode(fillerblock, 2, new TGeoCombiTrans(0, 0, zpos,
853                                        new TGeoRotation("", kThetaDeg,0,0)));
854   endcapshield->AddNode(fillerblock, 3, new TGeoCombiTrans(0, 0, zpos,
855                                        new TGeoRotation("",-kThetaDeg,0,0)));
856   endcapshield->AddNode(fillerblock, 4, new TGeoCombiTrans(0, 0, zpos,
857                                        new TGeoRotation("", 2*kThetaDeg,0,0)));
858   endcapshield->AddNode(fillerblock, 5, new TGeoCombiTrans(0, 0, zpos,
859                                        new TGeoRotation("",-2*kThetaDeg,0,0)));
860
861   TGeoVolume *fillerbar = new TGeoVolume("SPDfillerbar",
862                                          fillbarshape,medSPDcf);
863   fillerbar->SetVisibility(kTRUE);
864   fillerbar->SetLineColor(7);
865   fillerbar->SetLineWidth(1);
866   fillerbar->SetFillColor(fillerbar->GetLineColor());
867   fillerbar->SetFillStyle(4090); // 90% transparent
868
869   TGeoVolume *fillbarhole = new TGeoVolume("SPDfillerbarhole",
870                                              fillbarholeshape,medSPDair);
871   fillbarhole->SetVisibility(kTRUE);
872   fillbarhole->SetLineColor(5); // Yellow
873   fillbarhole->SetLineWidth(1);
874   fillbarhole->SetFillColor(fillbarhole->GetLineColor());
875   fillbarhole->SetFillStyle(4090); // 90% transparent
876
877   fillerbar->AddNode(fillbarhole, 1, 0);
878
879   TGeoVolume *vCone = new TGeoVolume("SPDconeshield",sCone,medSPDcf);
880   vCone->SetVisibility(kTRUE);
881   vCone->SetLineColor(7);
882   vCone->SetLineWidth(1);
883   vCone->SetFillColor(vCone->GetLineColor());
884   vCone->SetFillStyle(4090); // 90% transparent
885
886   TGeoVolume *vCh1 = new TGeoVolume("SPDconeshieldH1",sCh1,medSPDair);
887   vCh1->SetVisibility(kTRUE);
888   vCh1->SetLineColor(5); // Yellow
889   vCh1->SetLineWidth(1);
890   vCh1->SetFillColor(vCh1->GetLineColor());
891   vCh1->SetFillStyle(4090); // 90% transparent
892
893   TGeoVolume *vCh2 = new TGeoVolume("SPDconeshieldH2",sCh2,medSPDair);
894   vCh2->SetVisibility(kTRUE);
895   vCh2->SetLineColor(5); // Yellow
896   vCh2->SetLineWidth(1);
897   vCh2->SetFillColor(vCh2->GetLineColor());
898   vCh2->SetFillStyle(4090); // 90% transparent
899
900   TGeoVolume *vCh3 = new TGeoVolume("SPDconeshieldH3",sCh3,medSPDair);
901   vCh3->SetVisibility(kTRUE);
902   vCh3->SetLineColor(5); // Yellow
903   vCh3->SetLineWidth(1);
904   vCh3->SetFillColor(vCh3->GetLineColor());
905   vCh3->SetFillStyle(4090); // 90% transparent
906
907   TGeoVolume *vCh4 = new TGeoVolume("SPDconeshieldH4",sCh4,medSPDair);
908   vCh4->SetVisibility(kTRUE);
909   vCh4->SetLineColor(5); // Yellow
910   vCh4->SetLineWidth(1);
911   vCh4->SetFillColor(vCh4->GetLineColor());
912   vCh4->SetFillStyle(4090); // 90% transparent
913
914   TGeoVolume *vCh5 = new TGeoVolume("SPDconeshieldH5",sCh5,medSPDair);
915   vCh5->SetVisibility(kTRUE);
916   vCh5->SetLineColor(5); // Yellow
917   vCh5->SetLineWidth(1);
918   vCh5->SetFillColor(vCh5->GetLineColor());
919   vCh5->SetFillStyle(4090); // 90% transparent
920
921   TGeoVolume *vCh6 = new TGeoVolume("SPDconeshieldH6",sCh6,medSPDair);
922   vCh6->SetVisibility(kTRUE);
923   vCh6->SetLineColor(5); // Yellow
924   vCh6->SetLineWidth(1);
925   vCh6->SetFillColor(vCh6->GetLineColor());
926   vCh6->SetFillStyle(4090); // 90% transparent
927
928   TGeoVolume *vCh7 = new TGeoVolume("SPDconeshieldH7",sCh7,medSPDair);
929   vCh7->SetVisibility(kTRUE);
930   vCh7->SetLineColor(5); // Yellow
931   vCh7->SetLineWidth(1);
932   vCh7->SetFillColor(vCh7->GetLineColor());
933   vCh7->SetFillStyle(4090); // 90% transparent
934
935   TGeoVolume *vCh8 = new TGeoVolume("SPDconeshieldH8",sCh8,medSPDair);
936   vCh8->SetVisibility(kTRUE);
937   vCh8->SetLineColor(5); // Yellow
938   vCh8->SetLineWidth(1);
939   vCh8->SetFillColor(vCh8->GetLineColor());
940   vCh8->SetFillStyle(4090); // 90% transparent
941
942   TGeoVolume *vCh9 = new TGeoVolume("SPDconeshieldH9",sCh9,medSPDair);
943   vCh9->SetVisibility(kTRUE);
944   vCh9->SetLineColor(5); // Yellow
945   vCh9->SetLineWidth(1);
946   vCh9->SetFillColor(vCh9->GetLineColor());
947   vCh9->SetFillStyle(4090); // 90% transparent
948
949   TGeoVolume *vCh10 = new TGeoVolume("SPDconeshieldH10",sCh10,medSPDair);
950   vCh10->SetVisibility(kTRUE);
951   vCh10->SetLineColor(5); // Yellow
952   vCh10->SetLineWidth(1);
953   vCh10->SetFillColor(vCh10->GetLineColor());
954   vCh10->SetFillStyle(4090); // 90% transparent
955
956   TGeoVolume *vCh11 = new TGeoVolume("SPDconeshieldH11",sCh11,medSPDair);
957   vCh11->SetVisibility(kTRUE);
958   vCh11->SetLineColor(5); // Yellow
959   vCh11->SetLineWidth(1);
960   vCh11->SetFillColor(vCh11->GetLineColor());
961   vCh11->SetFillStyle(4090); // 90% transparent
962
963   vCone->AddNode(vCh1 ,1,0);
964   vCone->AddNode(vCh2 ,1,0);
965   vCone->AddNode(vCh3 ,1,0);
966   vCone->AddNode(vCh4 ,1,0);
967   vCone->AddNode(vCh5 ,1,0);
968   vCone->AddNode(vCh6 ,1,0);
969   vCone->AddNode(vCh7 ,1,0);
970   vCone->AddNode(vCh8 ,1,0);
971   vCone->AddNode(vCh9 ,1,0);
972   vCone->AddNode(vCh10,1,0);
973   vCone->AddNode(vCh11,1,0);
974
975   TGeoVolume *ring = new TGeoVolume("SPDshieldring",ringshape,medSPDcf);
976   ring->SetVisibility(kTRUE);
977   ring->SetLineColor(7);
978   ring->SetLineWidth(1);
979
980   TGeoVolume *ringinsert = new TGeoVolume("SPDshieldringinsert",
981                                           ringinsertshape,medSPDste);
982   ringinsert->SetVisibility(kTRUE);
983   ringinsert->SetLineColor(3); // Green
984 //  ringinsert->SetLineWidth(1);
985   ringinsert->SetFillColor(ringinsert->GetLineColor());
986   ringinsert->SetFillStyle(4010); // 10% transparent
987
988   ring->AddNode(ringinsert,1,0);
989
990   TGeoVolume *wing = new TGeoVolume("SPDshieldringwing",wingshape,medSPDcf);
991   wing->SetVisibility(kTRUE);
992   wing->SetLineColor(7);
993   wing->SetLineWidth(1);
994
995   TGeoVolume *winginsert = new TGeoVolume("SPDshieldwinginsert",
996                                           winginsertshape,medSPDste);
997   winginsert->SetVisibility(kTRUE);
998   winginsert->SetLineColor(3); // Green
999 //  winginsert->SetLineWidth(1);
1000   winginsert->SetFillColor(winginsert->GetLineColor());
1001   winginsert->SetFillStyle(4010); // 10% transparent
1002
1003   wing->AddNode(winginsert,1,0);
1004
1005
1006   // Add all volumes in the assembly
1007   const Double_t kLittleZTrans = 0.1*fgkmm;
1008   vM->AddNode(centralshield,1,new TGeoTranslation(0,0,-kLittleZTrans));
1009   vM->AddNode(centralshield,2,new TGeoCombiTrans( 0,0,-kLittleZTrans,
1010                                   new TGeoRotation("",180,0,0)));
1011
1012   zpos = kHalfLengthCentral+kHalfLengthEndCap;
1013   vM->AddNode(endcapshield,1,
1014               new TGeoTranslation(0,0, zpos-kLittleZTrans));
1015   vM->AddNode(endcapshield,2,new TGeoCombiTrans(
1016               0, 0,-zpos-kLittleZTrans, new TGeoRotation("",  0,180,0) ) );
1017   vM->AddNode(endcapshield,3,new TGeoCombiTrans(
1018               0, 0, zpos-kLittleZTrans, new TGeoRotation("",180,  0,0) ) );
1019   vM->AddNode(endcapshield,4,new TGeoCombiTrans(
1020               0, 0,-zpos-kLittleZTrans, new TGeoRotation("",180,180,0) ) );
1021
1022   xpos = omgendcapshape->GetX(13) + fillbarshape->GetDX();
1023   ypos = omgendcapshape->GetY(13) + fillbarshape->GetDY();
1024   zpos -= fillbarshape->GetDZ();
1025   vM->AddNode(fillerbar, 1, new TGeoTranslation( xpos, ypos, zpos));
1026   vM->AddNode(fillerbar, 2, new TGeoTranslation(-xpos, ypos, zpos));
1027   vM->AddNode(fillerbar, 3, new TGeoTranslation( xpos,-ypos, zpos));
1028   vM->AddNode(fillerbar, 4, new TGeoTranslation(-xpos,-ypos, zpos));
1029   vM->AddNode(fillerbar, 5, new TGeoTranslation( xpos, ypos,-zpos));
1030   vM->AddNode(fillerbar, 6, new TGeoTranslation(-xpos, ypos,-zpos));
1031   vM->AddNode(fillerbar, 7, new TGeoTranslation( xpos,-ypos,-zpos));
1032   vM->AddNode(fillerbar, 8, new TGeoTranslation(-xpos,-ypos,-zpos));
1033
1034   zpos = kHalfLengthCentral+2*kHalfLengthEndCap+kHalfLengthCone;
1035   vM->AddNode(vCone ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1036
1037   vM->AddNode(vCone ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1038                                 new TGeoRotation("", 0, 0, 180)   ));
1039
1040   vM->AddNode(vCone ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1041                                 new TGeoRotation("", 0, 180, 0)   ));
1042
1043   vM->AddNode(vCone ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1044                                 new TGeoRotation("", 0, 180, 180)   ));
1045
1046   zpos = kHalfLengthCentral+2*kHalfLengthEndCap+2*kHalfLengthCone
1047        + kHalfLengthRing;
1048   vM->AddNode(ring,1,new TGeoTranslation(0, 0, zpos-kLittleZTrans));
1049   vM->AddNode(ring,2,new TGeoTranslation(0, 0,-zpos-kLittleZTrans));
1050
1051   for (Int_t i=0; i<4; i++) {
1052     Double_t thetaW = kThetaWing*(2*i+1) - angleWideWing/2.;
1053     vM->AddNode(wing,2*i+1,new TGeoCombiTrans(0, 0, zpos-kLittleZTrans,
1054                                new TGeoRotation("",thetaW,0,0) ) );
1055     vM->AddNode(wing,2*i+2,new TGeoCombiTrans(0, 0,-zpos-kLittleZTrans,
1056                                new TGeoRotation("",thetaW,0,0) ) );
1057   }
1058
1059   // Some debugging if requested
1060   if(GetDebug(1)){
1061     vM->PrintNodes();
1062     vM->InspectShape();
1063   }
1064
1065   // Finally put the entire shield in the mother volume
1066   moth->AddNode(vM,1,0);
1067
1068   return;
1069 }
1070
1071 //______________________________________________________________________
1072 void AliITSv11GeometrySupport::CreateSPDThermalShape(
1073      Double_t ina, Double_t inb, Double_t inr,
1074      Double_t oua, Double_t oub, Double_t our,
1075      Double_t   t, Double_t *x , Double_t *y ) const
1076 {
1077 //
1078 // Creates the proper sequence of X and Y coordinates to determine
1079 // the base XTru polygon for the SPD thermal shapes
1080 //
1081 // Input:
1082 //        ina, inb : inner shape sides
1083 //        inr      : inner radius
1084 //        oua, oub : outer shape sides
1085 //        our      : outer radius
1086 //        t        : theta angle
1087 //
1088 // Output:
1089 //        x, y : coordinate vectors [24]
1090 //
1091 // Created:      14 Nov 2007  Mario Sitta
1092 // Updated:      11 Dec 2007  Mario Sitta
1093 //
1094   Double_t xlocal[6],ylocal[6];
1095
1096   //Create the first inner quadrant (X > 0)
1097   FillSPDXtruShape(ina,inb,inr,t,xlocal,ylocal);
1098   for (Int_t i=0; i<6; i++) {
1099     x[i] = xlocal[i];
1100     y[i] = ylocal[i];
1101   }
1102
1103   // Then reflex on the second quadrant (X < 0)
1104   for (Int_t i=0; i<6; i++) {
1105     x[23-i] = -x[i];
1106     y[23-i] =  y[i];
1107   }
1108
1109   // Now create the first outer quadrant (X > 0)
1110   FillSPDXtruShape(oua,oub,our,t,xlocal,ylocal);
1111   for (Int_t i=0; i<6; i++) {
1112     x[11-i] = xlocal[i];
1113     y[11-i] = ylocal[i];
1114   }
1115
1116   // Finally reflex on the second quadrant (X < 0)
1117   for (Int_t i=0; i<6; i++) {
1118     x[12+i] = -x[11-i];
1119     y[12+i] =  y[11-i];
1120   }
1121
1122   return;
1123 }
1124
1125 //______________________________________________________________________
1126 void AliITSv11GeometrySupport::CreateSPDOmegaShape(
1127                    const Double_t *xin, const Double_t *yin, Double_t  d,
1128                    Double_t   *x, Double_t *y)
1129 {
1130 //
1131 // Creates the proper sequence of X and Y coordinates to determine
1132 // the SPD Omega XTru polygon
1133 //
1134 // Input:
1135 //        xin, yin : coordinates of the air volume
1136 //        d        : Omega shape thickness
1137 //        t        : theta angle
1138 //
1139 // Output:
1140 //        x, y     : coordinate vectors [48]
1141 //
1142 // Created:      17 Nov 2007  Mario Sitta
1143 // Updated:      11 Dec 2007  Mario Sitta
1144 // Updated:      20 Feb 2009  Mario Sitta       New algorithm (the old one
1145 //                                              gives erroneous vertexes)
1146 //
1147
1148   // This vector contains the index of those points which coincide
1149   // with the corresponding points in the air shape
1150   Int_t indexAir2Omega[12] = {1, 2, 5, 6, 9, 10, 11, 15, 16, 19, 20, 23};
1151
1152   // First fill those vertexes corresponding to
1153   // the edges aligned to the air shape edges
1154   for (Int_t j=0; j<12; j++) {
1155     x[*(indexAir2Omega+j)] = xin[j];
1156     y[*(indexAir2Omega+j)] = yin[j];
1157   }
1158
1159   // Now get the coordinates of the first inner point
1160   PointFromParallelLines(x[23],y[23],x[1],y[1],d,x[0],y[0]);
1161
1162   // Knowing this, the second internal point can be determined
1163   InsidePoint(x[0],y[0],x[1],y[1],x[2],y[2],d,x[22],y[22]);
1164
1165   // The third point is now computable
1166   ReflectPoint(x[1],y[1],x[2],y[2],x[22],y[22],x[21],y[21]);
1167
1168   // Repeat this logic
1169   InsidePoint(x[21],y[21],x[20],y[20],x[19],y[19],-d,x[3],y[3]);
1170
1171   ReflectPoint(x[20],y[20],x[19],y[19],x[3],y[3],x[4],y[4]);
1172
1173   InsidePoint(x[4],y[4],x[5],y[5],x[6],y[6],d,x[18],y[18]);
1174
1175   ReflectPoint(x[5],y[5],x[6],y[6],x[18],y[18],x[17],y[17]);
1176
1177   InsidePoint(x[17],y[17],x[16],y[16],x[15],y[15],-d,x[7],y[7]);
1178
1179   ReflectPoint(x[16],y[16],x[15],y[15],x[7],y[7],x[8],y[8]);
1180
1181   InsidePoint(x[8],y[8],x[9],y[9],x[10],y[10],d,x[14],y[14]);
1182
1183   // These need to be fixed explicitly
1184   x[12] = x[11];
1185   y[12] = y[11] + d;
1186   x[13] = x[10] + d;
1187   y[13] = y[12];
1188
1189   // Finally reflect on the negative side
1190   for (Int_t i=0; i<24; i++) {
1191     x[24+i] = -x[23-i];
1192     y[24+i] =  y[23-i];
1193   }
1194
1195   // Wow ! We've finished
1196   return;
1197 }
1198
1199 //______________________________________________________________________
1200 void AliITSv11GeometrySupport::FillSPDXtruShape(Double_t a, Double_t b,
1201                                                 Double_t r, Double_t t,
1202                                                 Double_t *x, Double_t *y) const
1203 {
1204 //
1205 // Creates the partial sequence of X and Y coordinates to determine
1206 // the lateral part of the SPD thermal shield
1207 //
1208 // Input:
1209 //        a, b : shape sides
1210 //        r    : radius
1211 //        t    : theta angle
1212 //
1213 // Output:
1214 //        x, y : coordinate vectors [6]
1215 //
1216 // Created:      14 Nov 2007  Mario Sitta
1217 //
1218   x[0] = a/2;
1219   y[0] = r;
1220
1221   x[1] = x[0] + b * TMath::Cos(t/2);
1222   y[1] = y[0] - b * TMath::Sin(t/2);
1223
1224   x[2] = x[1] + a * TMath::Cos(t);
1225   y[2] = y[1] - a * TMath::Sin(t);
1226
1227   x[3] = x[2] + b * TMath::Cos(3*t/2);
1228   y[3] = y[2] - b * TMath::Sin(3*t/2);
1229
1230   x[4] = x[3] + a * TMath::Cos(2*t);
1231   y[4] = y[3] - a * TMath::Sin(2*t);
1232
1233   x[5] = x[4];
1234   y[5] = 0.;
1235
1236   return;
1237 }
1238
1239 //______________________________________________________________________
1240 void AliITSv11GeometrySupport::PointFromParallelLines(Double_t x1, Double_t y1,
1241                               Double_t x2, Double_t y2, Double_t d,
1242                               Double_t &x, Double_t &y) const
1243 {
1244 //
1245 // Determines the X and Y of the first internal point of the Omega shape
1246 // (i.e. the coordinates of a point given two parallel lines passing by
1247 // two points and placed at a known distance)
1248 //
1249 // Input:
1250 //        x1, y1 : first point
1251 //        x2, y2 : second point
1252 //        d      : distance between the two lines
1253 //
1254 // Output:
1255 //        x, y   : coordinate of the point
1256 //
1257 // Created:      22 Feb 2009  Mario Sitta
1258 //
1259 //Begin_Html
1260 /*
1261 <img src="ITS/doc/PointFromParallelLines.gif">
1262 */
1263 //End_Html
1264
1265   // The slope of the paralles lines at a distance d
1266   Double_t m; 
1267
1268   // The parameters of the solving equation
1269   // a x^2 - 2 b x + c = 0
1270   Double_t a = (x1 - x2)*(x1 - x2) - d*d;
1271   Double_t b = (x1 - x2)*(y1 - y2);
1272   Double_t c = (y1 - y2)*(y1 - y2) - d*d;
1273
1274   // (delta4 is Delta/4 because we use the reduced formula)
1275   Double_t delta4 = b*b - a*c;
1276
1277   // Compute the slope of the two parallel lines
1278   // (one of the two possible slopes, the one with the smaller
1279   // absolute value is needed)
1280   if (delta4 < 0) { // Should never happen with our data, but just to be sure
1281     x = -1;         // x is expected positive, so this flags an error
1282     return;
1283   } else
1284     m = (b + TMath::Sqrt(delta4))/a;  // b is negative with our data
1285
1286   // Finally compute the coordinates of the point
1287   x = x2 + (y1 - y2 - d)/m;
1288   y = y1 - d;
1289
1290   // Done
1291   return;
1292 }
1293
1294 //______________________________________________________________________
1295 void AliITSv11GeometrySupport::ReflectPoint(Double_t x1, Double_t y1,
1296                                             Double_t x2, Double_t y2,
1297                                             Double_t x3, Double_t y3,
1298                                             Double_t &x, Double_t &y) const
1299 {
1300 //
1301 // Given two points (x1,y1) and (x2,y2), determines the point (x,y)
1302 // lying on the line parallel to the line passing by these points,
1303 // at a distance d and passing by the point (x3,y3), which is symmetric to
1304 // the third point with respect to the axis of the segment delimited by
1305 // the two first points.
1306 //
1307 // Input:
1308 //        x1, y1 : first point
1309 //        x2, y2 : second point
1310 //        x3, y3 : third point
1311 //        d      : distance between the two lines
1312 //
1313 // Output:
1314 //        x, y   : coordinate of the reflected point
1315 //
1316 // Created:      22 Feb 2009  Mario Sitta
1317 //
1318 //Begin_Html
1319 /*
1320 <img src="ITS/doc/ReflectPoint.gif">
1321 */
1322 //End_Html
1323
1324   // The slope of the line passing by the first two points
1325   Double_t k = (y2 - y1)/(x2 - x1);
1326
1327   // The middle point of the segment 1-2
1328   Double_t xK = (x1 + x2)/2.;
1329   Double_t yK = (y1 + y2)/2.;
1330
1331   // The intercept between the axis of the segment 1-2 and the line
1332   // passing by 3 and parallel to the line passing by 1-2
1333   Double_t xH = (k*k*x3 + k*(yK - y3) + xK)/(k*k + 1);
1334   Double_t yH = k*(xH - x3) + y3;
1335
1336   // The point symmetric to 3 with respect to H
1337   x = 2*xH - x3;
1338   y = 2*yH - y3;
1339
1340   // Done
1341   return;
1342 }
1343
1344 //______________________________________________________________________
1345 void AliITSv11GeometrySupport::SDDCone(TGeoVolume *moth,const TGeoManager *mgr)
1346 {
1347 //
1348 // Creates the SDD support cone and cylinder geometry as a
1349 // volume assembly and adds it to the mother volume
1350 // (part of this code is taken or anyway inspired to SDDCone method
1351 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
1352 //
1353 // Input:
1354 //         moth : the TGeoVolume owing the volume structure
1355 //         mgr  : the GeoManager (default gGeoManager)
1356 // Output:
1357 //
1358 // Created:         ???       Bjorn S. Nilsen
1359 // Updated:      18 Feb 2008  Mario Sitta
1360 // Updated:      25 Jul 2008  Mario Sitta   SDDCarbonFiberCone simpler
1361 // Updated:      10 Jun 2010  Mario Sitta   Cables across cone holes added
1362 //
1363 // Technical data are taken from:  "Supporto Generale Settore SDD"
1364 // (technical drawings ALR-0816/1-B), "Supporto Globale Settore SDD"
1365 // (technical drawings ALR-0816/2A, ALR-0816/2B, ALR-0816/2C, ALR-0816/2D), 
1366 // private communication with B. Giraudo
1367
1368   // Dimensions of the Central cylinder and flanges
1369   const Double_t kCylinderHalfLength = (790.0/2)*fgkmm;
1370   const Double_t kCylinderInnerR     = (210.0/2)*fgkmm;
1371   const Double_t kCylinderOuterR     = (231.0/2)*fgkmm;
1372   const Double_t kFlangeHalfLength   = ( 15.0/2)*fgkmm;
1373   const Double_t kFlangeInnerR       = (210.5/2)*fgkmm;
1374   const Double_t kFlangeOuterR       = (230.5/2)*fgkmm;
1375   const Double_t kInsertoHalfLength  =
1376                                      kCylinderHalfLength - 2*kFlangeHalfLength;
1377 //  const Double_t kCFThickness        = kFlangeInnerR - kCylinderInnerR;
1378   const Double_t kBoltDiameter       =       6.0*fgkmm; // M6 screw
1379   const Double_t kBoltDepth          =       6.0*fgkmm; // In the flange
1380   const Double_t kBoltRadius         = (220.0/2)*fgkmm; // Radius in flange
1381   const Double_t kThetaBolt          =      30.0*fgkDegree;
1382   const Int_t    kNBolts             = (Int_t)(360.0/kThetaBolt);
1383   // Dimensions of the Cone
1384   const Double_t kConeROutMin        = (540.0/2)*fgkmm;
1385   const Double_t kConeROutMax        = (560.0/2)*fgkmm;
1386   const Double_t kConeRCurv          =      10.0*fgkmm; // Radius of curvature
1387   const Double_t kConeRinMin         = (210.0/2)*fgkmm;
1388 //  const Double_t kConeRinMax         = (216.0/2)*fgkmm;
1389   const Double_t kConeRinCylinder    = (231.0/2)*fgkmm;
1390   const Double_t kConeZCylinder      =     192.0*fgkmm;
1391   const Double_t kConeZOuterMilled   =      23.0*fgkmm;
1392   const Double_t kConeDZin           =      15.0*fgkmm; // ???
1393   const Double_t kConeThickness      =      10.0*fgkmm; // Rohacell + Carb.Fib.
1394   const Double_t kConeTheta          =      45.0*fgkDegree; // SDD cone angle
1395   const Double_t kSinConeTheta       =
1396                                      TMath::Sin(kConeTheta*TMath::DegToRad());
1397   const Double_t kCosConeTheta       =
1398                                      TMath::Cos(kConeTheta*TMath::DegToRad());
1399   const Double_t kTanConeTheta       =
1400                                      TMath::Tan(kConeTheta*TMath::DegToRad());
1401   // Dimensions of the Cone Inserts
1402   const Double_t kConeCFThickness    =       1.5*fgkmm;//Carbon fiber thickness
1403   // Dimensions of the Cone Holes
1404   const Double_t kHole1RMin          = (450.0/2)*fgkmm;
1405   const Double_t kHole1RMax          = (530.0/2)*fgkmm;
1406   const Double_t kHole2RMin          = (280.0/2)*fgkmm;
1407   const Double_t kHole2RMax          = (375.0/2)*fgkmm;
1408   const Double_t kHole1Phi           =      25.0*fgkDegree;
1409   const Double_t kHole2Phi           =      50.0*fgkDegree;
1410   const Double_t kHole3RMin          =     205.0*fgkmm;
1411   const Double_t kHole3DeltaR        =        15*fgkmm;
1412   const Double_t kHole3Width         =        30*fgkmm;
1413   const Int_t    kNHole3             =         6      ;
1414   const Double_t kHole4RMin          =     116.0*fgkmm;
1415   const Double_t kHole4DeltaR        =        15*fgkmm;
1416   const Double_t kHole4Width         =        30*fgkmm;
1417   //  const Int_t    kNHole4             =         3      ;
1418   // Fraction of materials in holes
1419   const Double_t kHolePlasticFrac    =       0.55846;
1420   const Double_t kHoleCuFrac         =       0.06319;
1421   const Double_t kHoleGlassFrac      =       0.02652;
1422
1423   // Local variables
1424   Double_t x, y, z, t, dza, rmin, rmax;
1425
1426
1427   // Recover the needed materials
1428   TGeoMedium *medSDDcf    = mgr->GetMedium("ITS_SDD C (M55J)$");
1429   TGeoMedium *medSDDair   = mgr->GetMedium("ITS_SDD AIR$");
1430   TGeoMedium *medSDDste   = mgr->GetMedium("ITS_G10FR4$"); // stesalite
1431   TGeoMedium *medSDDroh   = mgr->GetMedium("ITS_ROHACELL$");
1432   TGeoMedium *medSDDss    = mgr->GetMedium("ITS_INOX$");
1433   TGeoMedium *medSDDplast = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
1434   TGeoMedium *medSDDCu    = mgr->GetMedium("ITS_COPPER$");
1435   TGeoMedium *medSDDglass = mgr->GetMedium("ITS_SDD OPTICFIB$");
1436
1437   // First define the geometrical shapes
1438
1439   // Central cylinder with its internal foam and the lateral flanges:
1440   // a carbon fiber Tube which contains a rohacell Tube and two
1441   // stesalite Tube's
1442   TGeoTube *cylindershape = new TGeoTube(kCylinderInnerR,kCylinderOuterR,
1443                                          kCylinderHalfLength);
1444
1445   TGeoTube *insertoshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
1446                                         kInsertoHalfLength);
1447
1448   TGeoTube *flangeshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
1449                                        kFlangeHalfLength);
1450
1451   // The flange bolt: it is a Tube
1452   TGeoTube *boltshape = new TGeoTube(0.0, 0.5*kBoltDiameter, 0.5*kBoltDepth);
1453
1454   // Debug if requested
1455   if (GetDebug(1)) {
1456     cylindershape->InspectShape();
1457     insertoshape->InspectShape();
1458     flangeshape->InspectShape();
1459     boltshape->InspectShape();
1460   }
1461
1462
1463   // We have the shapes: now create the real volumes
1464
1465   TGeoVolume *cfcylinder = new TGeoVolume("SDDCarbonFiberCylinder",
1466                                           cylindershape,medSDDcf);
1467   cfcylinder->SetVisibility(kTRUE);
1468   cfcylinder->SetLineColor(4); // Blue
1469   cfcylinder->SetLineWidth(1);
1470   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
1471   cfcylinder->SetFillStyle(4000); // 0% transparent
1472
1473   TGeoVolume *foamcylinder = new TGeoVolume("SDDFoamCylinder",
1474                                             insertoshape,medSDDroh);
1475   foamcylinder->SetVisibility(kTRUE);
1476   foamcylinder->SetLineColor(3); // Green
1477   foamcylinder->SetLineWidth(1);
1478   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
1479   foamcylinder->SetFillStyle(4050); // 50% transparent
1480
1481   TGeoVolume *flangecylinder = new TGeoVolume("SDDFlangeCylinder",
1482                                               flangeshape,medSDDste);
1483   flangecylinder->SetVisibility(kTRUE);
1484   flangecylinder->SetLineColor(2); // Red
1485   flangecylinder->SetLineWidth(1);
1486   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
1487   flangecylinder->SetFillStyle(4050); // 50% transparent
1488
1489   TGeoVolume *bolt = new TGeoVolume("SDDFlangeBolt",boltshape,medSDDss);
1490   bolt->SetVisibility(kTRUE);
1491   bolt->SetLineColor(1);  // Black
1492   bolt->SetLineWidth(1);
1493   bolt->SetFillColor(bolt->GetLineColor());
1494   bolt->SetFillStyle(4050); // 50% transparent
1495
1496   // Mount up the cylinder
1497   for(Int_t i=0; i<kNBolts; i++){
1498     t = kThetaBolt*i;
1499     x = kBoltRadius*CosD(t);
1500     y = kBoltRadius*SinD(t);
1501     z = kFlangeHalfLength-kBoltDepth;
1502     flangecylinder->AddNode(bolt, i+1, new TGeoTranslation("",x,y,z));
1503   }
1504
1505   cfcylinder->AddNode(foamcylinder,1,0);
1506   cfcylinder->AddNode(flangecylinder,1,
1507               new TGeoTranslation(0, 0, kInsertoHalfLength+kFlangeHalfLength));
1508   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
1509               0, 0, -kInsertoHalfLength-kFlangeHalfLength,
1510               new TGeoRotation("",0,180,0)     ) );
1511
1512
1513   // SDD Support Cone with its internal inserts: a carbon fiber Pcon
1514   // with holes which contains a stesalite Pcon which on turn contains a
1515   // rohacell Pcon
1516
1517   dza = kConeThickness/kSinConeTheta-(kConeROutMax-kConeROutMin)/kTanConeTheta;
1518
1519   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 10);
1520
1521   coneshape->Z(0)     = 0.0;
1522   coneshape->Rmin(0)  = kConeROutMin;
1523   coneshape->Rmax(0)  = kConeROutMax;
1524
1525   coneshape->Z(1)     = kConeZOuterMilled - dza;
1526   coneshape->Rmin(1)  = coneshape->GetRmin(0);
1527   coneshape->Rmax(1)  = coneshape->GetRmax(0);
1528
1529   coneshape->Z(2)     = kConeZOuterMilled;
1530   coneshape->Rmax(2)  = coneshape->GetRmax(0);
1531
1532   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(1),
1533                     coneshape->GetRmin(1),kConeTheta,z,rmin);
1534   coneshape->Z(3)     = z;
1535   coneshape->Rmin(3)  = rmin;
1536
1537   coneshape->Rmin(2)  = RminFrom2Points(coneshape,3,1,coneshape->GetZ(2));
1538
1539   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(2),
1540                     coneshape->GetRmax(2),kConeTheta,z,rmax);
1541   coneshape->Z(4)     = z;
1542   coneshape->Rmax(4)  = rmax;
1543   coneshape->Rmin(4)  = RminFromZpCone(coneshape,3,kConeTheta,
1544                                        coneshape->GetZ(4),0.0);
1545
1546   coneshape->Rmax(3)  = RmaxFrom2Points(coneshape,4,2,coneshape->GetZ(3));
1547
1548   coneshape->Z(6)     = kConeZCylinder - kConeDZin;
1549
1550   RadiusOfCurvature(kConeRCurv,90.0,coneshape->GetZ(6),0.0,
1551                     90.0-kConeTheta,z,rmin);
1552   coneshape->Z(5)     = z;
1553   coneshape->Rmin(5)  = RminFromZpCone(coneshape,3,kConeTheta,z);
1554   coneshape->Rmax(5)  = RmaxFromZpCone(coneshape,4,kConeTheta,z);
1555
1556   RadiusOfCurvature(kConeRCurv,90.-kConeTheta,
1557                     0.0,coneshape->Rmin(5),90.0,z,rmin);
1558   coneshape->Rmin(6)  = rmin;
1559   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,4,kConeTheta,
1560                                        coneshape->GetZ(6));
1561
1562   coneshape->Z(7)     = coneshape->GetZ(6);
1563   coneshape->Rmin(7)  = kConeRinMin;
1564   coneshape->Rmax(7)  = coneshape->GetRmax(6);
1565
1566   coneshape->Rmin(8)  = kConeRinMin;
1567
1568   RadiusOfCurvature(kConeRCurv,90.0,kConeZCylinder,kConeRinCylinder,
1569                     90.0-kConeTheta,z,rmax);
1570   coneshape->Z(8)     = z;
1571   coneshape->Rmax(8)  = rmax;
1572
1573   coneshape->Z(9)     = kConeZCylinder;
1574   coneshape->Rmin(9)  = kConeRinMin;
1575   coneshape->Rmax(9)  = kConeRinCylinder;
1576
1577
1578   // SDD Cone Insert: another Pcon
1579   Double_t x0, y0, x1, y1, x2, y2;
1580   TGeoPcon *coneinsertshape = new TGeoPcon(0.0, 360.0, 9);
1581
1582   coneinsertshape->Z(0)    = coneshape->GetZ(0) + kConeCFThickness;
1583   coneinsertshape->Rmin(0) = coneshape->GetRmin(0) + kConeCFThickness;
1584   coneinsertshape->Rmax(0) = coneshape->GetRmax(0) - kConeCFThickness;
1585
1586   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1587   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1588   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1589   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1590   coneinsertshape->Z(1)    = z;
1591   coneinsertshape->Rmin(1) = rmin;
1592   coneinsertshape->Rmax(1) = coneinsertshape->GetRmax(0);
1593
1594   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmax(1);
1595   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmax(2);
1596   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmax(3);
1597   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1598   coneinsertshape->Z(2)    = z;
1599   coneinsertshape->Rmax(2) = rmax;
1600
1601   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1602   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1603   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1604   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1605   coneinsertshape->Z(3)    = z;
1606   coneinsertshape->Rmin(3) = rmin;
1607
1608   x0 = coneinsertshape->GetZ(1); y0 = coneinsertshape->GetRmin(1);
1609   x1 = coneinsertshape->GetZ(3); y1 = coneinsertshape->GetRmin(3);
1610   coneinsertshape->Rmin(2) = Yfrom2Points(x0, y0, x1, y1,
1611                                           coneinsertshape->Z(2));
1612
1613   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
1614   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
1615   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
1616   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1617   coneinsertshape->Z(4)    = z;
1618   coneinsertshape->Rmax(4) = rmax;
1619
1620   x0 = coneinsertshape->GetZ(2); y0 = coneinsertshape->GetRmax(2);
1621   x1 = coneinsertshape->GetZ(4); y1 = coneinsertshape->GetRmax(4);
1622   coneinsertshape->Rmax(3) = Yfrom2Points(x0, y0, x1, y1,
1623                                           coneinsertshape->Z(3));
1624
1625   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmin(4);
1626   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmin(5);
1627   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmin(6);
1628   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1629   coneinsertshape->Z(5)    = z;
1630   coneinsertshape->Rmin(5) = rmin;
1631   coneinsertshape->Rmax(5) = coneinsertshape->GetRmax(4) -
1632           kTanConeTheta*(coneinsertshape->GetZ(5) - coneinsertshape->GetZ(4));
1633
1634   x0 = coneinsertshape->GetZ(3); y0 = coneinsertshape->GetRmin(3);
1635   x1 = coneinsertshape->GetZ(5); y1 = coneinsertshape->GetRmin(5);
1636   coneinsertshape->Rmin(4) = Yfrom2Points(x0, y0, x1, y1,
1637                                           coneinsertshape->Z(4));
1638
1639   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmin(5);
1640   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmin(6);
1641   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmin(7);
1642   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1643   coneinsertshape->Z(6)    = z;
1644   coneinsertshape->Rmin(6) = rmin;
1645   coneinsertshape->Rmax(6) = coneinsertshape->GetRmax(4) -
1646           kTanConeTheta*(coneinsertshape->GetZ(6) - coneinsertshape->GetZ(4));
1647
1648   coneinsertshape->Z(7)    = coneinsertshape->GetZ(6);
1649   coneinsertshape->Rmin(7) = coneshape->GetRmin(7) + kConeCFThickness;
1650   coneinsertshape->Rmax(7) = coneinsertshape->GetRmax(6);
1651
1652   coneinsertshape->Z(8)    = coneshape->GetZ(9) - kConeCFThickness;
1653   coneinsertshape->Rmin(8) = coneinsertshape->GetRmin(7);
1654   coneinsertshape->Rmax(8) = coneinsertshape->GetRmax(4) -
1655           kTanConeTheta*(coneinsertshape->GetZ(8) - coneinsertshape->GetZ(4));
1656
1657   // SDD Cone Foam: another Pcon
1658   TGeoPcon *conefoamshape = new TGeoPcon(0.0, 360.0, 4);
1659
1660   RadiusOfCurvature(kConeRCurv+kConeCFThickness,0.0,coneinsertshape->GetZ(1),
1661                     coneinsertshape->GetRmin(1),kConeTheta,z,rmin);
1662
1663   conefoamshape->Z(0)    = z;
1664   conefoamshape->Rmin(0) = rmin;
1665   conefoamshape->Rmax(0) = conefoamshape->GetRmin(0);
1666
1667   conefoamshape->Z(1)    = conefoamshape->GetZ(0)+
1668                          (kConeThickness-2.0*kConeCFThickness)/kSinConeTheta;
1669   conefoamshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1670                                           conefoamshape->GetZ(1));
1671   conefoamshape->Rmax(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1672                                           conefoamshape->GetZ(1));
1673
1674   conefoamshape->Z(2)    = coneshape->GetZ(5)-kConeCFThickness;
1675   conefoamshape->Rmin(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1676                                           conefoamshape->GetZ(2));
1677   conefoamshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1678                                           conefoamshape->GetZ(2));
1679
1680   conefoamshape->Z(3)    = coneinsertshape->GetZ(5)+
1681                          (kConeThickness-2.0*kConeCFThickness)*kCosConeTheta;
1682   conefoamshape->Rmax(3) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1683                                           conefoamshape->GetZ(3));
1684   conefoamshape->Rmin(3) = conefoamshape->GetRmax(3);
1685
1686   // SDD Cone Holes: Pcon's
1687   // A single hole volume gives an overlap with coneinsert, so
1688   // three contiguous volumes are created: one to be put in the cone foam
1689   // and two in the cone carbon fiber envelope
1690   TGeoPcon *hole1shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1691
1692   hole1shape->Rmin(0) = kHole1RMax;
1693   hole1shape->Rmax(0) = hole1shape->GetRmin(0);
1694   hole1shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1695                                        hole1shape->GetRmin(0));
1696
1697   hole1shape->Rmax(1) = hole1shape->GetRmax(0);
1698   hole1shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1699                                        hole1shape->GetRmax(1));
1700   hole1shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1701                                        hole1shape->GetZ(1));
1702
1703   hole1shape->Rmin(2) = kHole1RMin;
1704   hole1shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1705                                        hole1shape->GetRmin(2));
1706   hole1shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1707                                        hole1shape->GetZ(2));
1708
1709   hole1shape->Rmin(3) = hole1shape->GetRmin(2);
1710   hole1shape->Rmax(3) = hole1shape->GetRmin(3);
1711   hole1shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1712                                        hole1shape->GetRmax(3));
1713
1714   TGeoPcon *hole11shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1715
1716   hole11shape->Rmin(0) = kHole1RMax;
1717   hole11shape->Rmax(0) = hole11shape->GetRmin(0);
1718   hole11shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1719                                         hole11shape->GetRmin(0));
1720
1721   hole11shape->Rmax(1) = hole11shape->GetRmax(0);
1722   hole11shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1723                                         hole11shape->GetRmax(1));
1724   hole11shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1725                                         hole11shape->GetZ(1));
1726
1727   hole11shape->Rmin(2) = kHole1RMin;
1728   hole11shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1729                                         hole11shape->GetRmin(2));
1730   hole11shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1731                                         hole11shape->GetZ(2));
1732
1733   hole11shape->Rmin(3) = hole11shape->GetRmin(2);
1734   hole11shape->Rmax(3) = hole11shape->GetRmin(3);
1735   hole11shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1736                                         hole11shape->GetRmax(3));
1737
1738   TGeoPcon *hole12shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1739
1740   hole12shape->Rmin(0) = kHole1RMax;
1741   hole12shape->Rmax(0) = hole12shape->GetRmin(0);
1742   hole12shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1743                                         hole12shape->GetRmin(0));
1744
1745   hole12shape->Rmax(1) = hole12shape->GetRmax(0);
1746   hole12shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1747                                         hole12shape->GetRmax(1));
1748   hole12shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1749                                         hole12shape->GetZ(1));
1750
1751   hole12shape->Rmin(2) = kHole1RMin;
1752   hole12shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1753                                         hole12shape->GetRmin(2));
1754   hole12shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1755                                         hole12shape->GetZ(2));
1756
1757   hole12shape->Rmin(3) = hole12shape->GetRmin(2);
1758   hole12shape->Rmax(3) = hole12shape->GetRmin(3);
1759   hole12shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1760                                         hole12shape->GetRmax(3));
1761
1762   //
1763   TGeoPcon *hole2shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1764
1765   hole2shape->Rmin(0) = kHole2RMax;
1766   hole2shape->Rmax(0) = hole2shape->GetRmin(0);
1767   hole2shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1768                                        hole2shape->GetRmin(0));
1769
1770   hole2shape->Rmax(1) = hole2shape->GetRmax(0);
1771   hole2shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1772                                        hole2shape->GetRmax(1));
1773   hole2shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1774                                        hole2shape->GetZ(1));
1775
1776   hole2shape->Rmin(2) = kHole2RMin;
1777   hole2shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1778                                        hole2shape->GetRmin(2));
1779   hole2shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1780                                        hole2shape->GetZ(2));
1781
1782   hole2shape->Rmin(3) = hole2shape->GetRmin(2);
1783   hole2shape->Rmax(3) = hole2shape->GetRmin(3);
1784   hole2shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1785                                        hole2shape->GetRmax(3));
1786
1787   TGeoPcon *hole21shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1788
1789   hole21shape->Rmin(0) = kHole2RMax;
1790   hole21shape->Rmax(0) = hole21shape->GetRmin(0);
1791   hole21shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1792                                         hole21shape->GetRmin(0));
1793
1794   hole21shape->Rmax(1) = hole21shape->GetRmax(0);
1795   hole21shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1796                                         hole21shape->GetRmax(1));
1797   hole21shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1798                                         hole21shape->GetZ(1));
1799
1800   hole21shape->Rmin(2) = kHole2RMin;
1801   hole21shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1802                                         hole21shape->GetRmin(2));
1803   hole21shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1804                                         hole21shape->GetZ(2));
1805
1806   hole21shape->Rmin(3) = hole21shape->GetRmin(2);
1807   hole21shape->Rmax(3) = hole21shape->GetRmin(3);
1808   hole21shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1809                                         hole21shape->GetRmax(3));
1810
1811   TGeoPcon *hole22shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1812
1813   hole22shape->Rmin(0) = kHole2RMax;
1814   hole22shape->Rmax(0) = hole22shape->GetRmin(0);
1815   hole22shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1816                                         hole22shape->GetRmin(0));
1817
1818   hole22shape->Rmax(1) = hole22shape->GetRmax(0);
1819   hole22shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1820                                         hole22shape->GetRmax(1));
1821   hole22shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1822                                         hole22shape->GetZ(1));
1823
1824   hole22shape->Rmin(2) = kHole2RMin;
1825   hole22shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1826                                         hole22shape->GetRmin(2));
1827   hole22shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1828                                         hole22shape->GetZ(2));
1829
1830   hole22shape->Rmin(3) = hole22shape->GetRmin(2);
1831   hole22shape->Rmax(3) = hole22shape->GetRmin(3);
1832   hole22shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1833                                         hole22shape->GetRmax(3));
1834
1835   //
1836   Double_t holePhi;
1837   holePhi = (kHole3Width/kHole3RMin)*TMath::RadToDeg();
1838
1839   TGeoPcon *hole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1840
1841   hole3shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1842   hole3shape->Rmax(0) = hole3shape->GetRmin(0);
1843   hole3shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1844                                        hole3shape->GetRmin(0));
1845
1846   hole3shape->Rmax(1) = hole3shape->GetRmax(0);
1847   hole3shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1848                                        hole3shape->GetRmax(1));
1849   hole3shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1850                                        hole3shape->GetZ(1));
1851
1852   hole3shape->Rmin(2) = kHole3RMin;
1853   hole3shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1854                                        hole3shape->GetRmin(2));
1855   hole3shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1856                                        hole3shape->GetZ(2));
1857
1858   hole3shape->Rmin(3) = hole3shape->GetRmin(2);
1859   hole3shape->Rmax(3) = hole3shape->GetRmin(3);
1860   hole3shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1861                                        hole3shape->GetRmax(3));
1862
1863   TGeoPcon *hole31shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1864
1865   hole31shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1866   hole31shape->Rmax(0) = hole31shape->GetRmin(0);
1867   hole31shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1868                                         hole31shape->GetRmin(0));
1869
1870   hole31shape->Rmax(1) = hole31shape->GetRmax(0);
1871   hole31shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1872                                         hole31shape->GetRmax(1));
1873   hole31shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1874                                         hole31shape->GetZ(1));
1875
1876   hole31shape->Rmin(2) = kHole3RMin;
1877   hole31shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1878                                         hole31shape->GetRmin(2));
1879   hole31shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1880                                         hole31shape->GetZ(2));
1881
1882   hole31shape->Rmin(3) = hole31shape->GetRmin(2);
1883   hole31shape->Rmax(3) = hole31shape->GetRmin(3);
1884   hole31shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1885                                         hole31shape->GetRmax(3));
1886
1887   TGeoPcon *hole32shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1888
1889   hole32shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1890   hole32shape->Rmax(0) = hole32shape->GetRmin(0);
1891   hole32shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1892                                         hole32shape->GetRmin(0));
1893
1894   hole32shape->Rmax(1) = hole32shape->GetRmax(0);
1895   hole32shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1896                                         hole32shape->GetRmax(1));
1897   hole32shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1898                                         hole32shape->GetZ(1));
1899
1900   hole32shape->Rmin(2) = kHole3RMin;
1901   hole32shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1902                                         hole32shape->GetRmin(2));
1903   hole32shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1904                                         hole32shape->GetZ(2));
1905
1906   hole32shape->Rmin(3) = hole32shape->GetRmin(2);
1907   hole32shape->Rmax(3) = hole32shape->GetRmin(3);
1908   hole32shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1909                                         hole32shape->GetRmax(3));
1910
1911   //
1912   holePhi = (kHole4Width/kHole4RMin)*TMath::RadToDeg();
1913
1914   TGeoPcon *hole4shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1915
1916   hole4shape->Rmin(0) = kHole4RMin + kHole4DeltaR;
1917   hole4shape->Rmax(0) = hole4shape->GetRmin(0);
1918   hole4shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1919                                        hole4shape->GetRmin(0));
1920
1921   hole4shape->Rmax(1) = hole4shape->GetRmax(0);
1922   hole4shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1923                                        hole4shape->GetRmax(1));
1924   hole4shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1925                                        hole4shape->GetZ(1));
1926
1927   hole4shape->Rmin(2) = kHole4RMin;
1928   hole4shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1929                                        hole4shape->GetRmin(2));
1930   hole4shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1931                                        hole4shape->GetZ(2));
1932
1933   hole4shape->Rmin(3) = hole4shape->GetRmin(2);
1934   hole4shape->Rmax(3) = hole4shape->GetRmin(3);
1935   hole4shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1936                                        hole4shape->GetRmax(3));
1937
1938   // Cables to be put inside the holes: Pcon's
1939   // (fractions are manually computed from AliITSv11GeometrySDD::SDDCables
1940   TGeoPcon *hole1plastshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1941
1942   hole1plastshape->Rmin(0) = hole1shape->GetRmin(0);
1943   hole1plastshape->Rmax(0) = hole1shape->GetRmax(0);
1944   hole1plastshape->Z(0)    = hole1shape->GetZ(0);
1945
1946   hole1plastshape->Rmin(1) = hole1shape->GetRmin(1);
1947   hole1plastshape->Rmax(1) = hole1shape->GetRmax(1);
1948   hole1plastshape->Z(1)    = hole1shape->GetZ(1);
1949
1950   dza = hole1plastshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHolePlasticFrac;
1951
1952   hole1plastshape->Rmin(2) = dza;
1953   hole1plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1954                                             hole1plastshape->GetRmin(2));
1955   hole1plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1956                                             hole1plastshape->GetZ(2));
1957
1958   hole1plastshape->Rmin(3) = hole1plastshape->GetRmin(2);
1959   hole1plastshape->Rmax(3) = hole1plastshape->GetRmin(3);
1960   hole1plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1961                                             hole1plastshape->GetRmax(3));
1962
1963   TGeoPcon *hole1Cushape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1964
1965   hole1Cushape->Rmin(0) = hole1plastshape->GetRmin(2);
1966   hole1Cushape->Rmax(0) = hole1Cushape->GetRmin(0);
1967   hole1Cushape->Z(0)    = hole1plastshape->GetZ(2);
1968
1969   dza = hole1Cushape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleCuFrac;
1970
1971   hole1Cushape->Rmin(1) = dza;
1972   hole1Cushape->Rmax(1) = hole1Cushape->GetRmax(0);
1973   hole1Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1974                                          hole1Cushape->GetRmin(1));
1975
1976   hole1Cushape->Rmax(2) = hole1Cushape->GetRmax(0);
1977   hole1Cushape->Rmin(2) = hole1Cushape->GetRmin(1);
1978   hole1Cushape->Z(2)    = hole1plastshape->GetZ(3);
1979
1980   hole1Cushape->Rmin(3) = hole1Cushape->GetRmin(1);
1981   hole1Cushape->Rmax(3) = hole1Cushape->GetRmin(3);
1982   hole1Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1983                                          hole1Cushape->GetRmax(3));
1984
1985   TGeoPcon *hole1glassshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1986
1987   hole1glassshape->Rmin(0) = hole1Cushape->GetRmin(1);
1988   hole1glassshape->Rmax(0) = hole1glassshape->GetRmin(0);
1989   hole1glassshape->Z(0)    = hole1Cushape->GetZ(1);
1990
1991   dza = hole1glassshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleGlassFrac;
1992
1993   hole1glassshape->Rmin(1) = dza;
1994   hole1glassshape->Rmax(1) = hole1glassshape->GetRmax(0);
1995   hole1glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1996                                             hole1glassshape->GetRmin(1));
1997
1998   hole1glassshape->Rmax(2) = hole1glassshape->GetRmax(0);
1999   hole1glassshape->Rmin(2) = hole1glassshape->GetRmin(1);
2000   hole1glassshape->Z(2)    = hole1Cushape->GetZ(3);
2001
2002   hole1glassshape->Rmin(3) = hole1glassshape->GetRmin(1);
2003   hole1glassshape->Rmax(3) = hole1glassshape->GetRmin(3);
2004   hole1glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2005                                             hole1glassshape->GetRmax(3));
2006   //
2007   TGeoPcon *hole2plastshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2008
2009   hole2plastshape->Rmin(0) = hole2shape->GetRmin(0);
2010   hole2plastshape->Rmax(0) = hole2shape->GetRmax(0);
2011   hole2plastshape->Z(0)    = hole2shape->GetZ(0);
2012
2013   hole2plastshape->Rmin(1) = hole2shape->GetRmin(1);
2014   hole2plastshape->Rmax(1) = hole2shape->GetRmax(1);
2015   hole2plastshape->Z(1)    = hole2shape->GetZ(1);
2016
2017   dza = hole2plastshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHolePlasticFrac;
2018
2019   hole2plastshape->Rmin(2) = dza;
2020   hole2plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2021                                             hole2plastshape->GetRmin(2));
2022   hole2plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
2023                                             hole2plastshape->GetZ(2));
2024
2025   hole2plastshape->Rmin(3) = hole2plastshape->GetRmin(2);
2026   hole2plastshape->Rmax(3) = hole2plastshape->GetRmin(3);
2027   hole2plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2028                                             hole2plastshape->GetRmax(3));
2029
2030   TGeoPcon *hole2Cushape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2031
2032   hole2Cushape->Rmin(0) = hole2plastshape->GetRmin(2);
2033   hole2Cushape->Rmax(0) = hole2Cushape->GetRmin(0);
2034   hole2Cushape->Z(0)    = hole2plastshape->GetZ(2);
2035
2036   dza = hole2Cushape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleCuFrac;
2037
2038   hole2Cushape->Rmin(1) = dza;
2039   hole2Cushape->Rmax(1) = hole2Cushape->GetRmax(0);
2040   hole2Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2041                                          hole2Cushape->GetRmin(1));
2042
2043   hole2Cushape->Rmax(2) = hole2Cushape->GetRmax(0);
2044   hole2Cushape->Rmin(2) = hole2Cushape->GetRmin(1);
2045   hole2Cushape->Z(2)    = hole2plastshape->GetZ(3);
2046
2047   hole2Cushape->Rmin(3) = hole2Cushape->GetRmin(1);
2048   hole2Cushape->Rmax(3) = hole2Cushape->GetRmin(3);
2049   hole2Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2050                                          hole2Cushape->GetRmax(3));
2051
2052   TGeoPcon *hole2glassshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2053
2054   hole2glassshape->Rmin(0) = hole2Cushape->GetRmin(1);
2055   hole2glassshape->Rmax(0) = hole2glassshape->GetRmin(0);
2056   hole2glassshape->Z(0)    = hole2Cushape->GetZ(1);
2057
2058   dza = hole2glassshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleGlassFrac;
2059
2060   hole2glassshape->Rmin(1) = dza;
2061   hole2glassshape->Rmax(1) = hole2glassshape->GetRmax(0);
2062   hole2glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2063                                             hole2glassshape->GetRmin(1));
2064
2065   hole2glassshape->Rmax(2) = hole2glassshape->GetRmax(0);
2066   hole2glassshape->Rmin(2) = hole2glassshape->GetRmin(1);
2067   hole2glassshape->Z(2)    = hole2Cushape->GetZ(3);
2068
2069   hole2glassshape->Rmin(3) = hole2glassshape->GetRmin(1);
2070   hole2glassshape->Rmax(3) = hole2glassshape->GetRmin(3);
2071   hole2glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2072                                             hole2glassshape->GetRmax(3));
2073
2074
2075   // Debug if requested
2076   if (GetDebug(1)) {
2077     coneshape->InspectShape();
2078     coneinsertshape->InspectShape();
2079     conefoamshape->InspectShape();
2080     hole1shape->InspectShape();
2081     hole2shape->InspectShape();
2082     hole3shape->InspectShape();
2083     hole4shape->InspectShape();
2084   }
2085
2086
2087   // We have the shapes: now create the real volumes
2088
2089   TGeoVolume *cfcone = new TGeoVolume("SDDCarbonFiberCone",
2090                                       coneshape,medSDDcf);
2091   cfcone->SetVisibility(kTRUE);
2092   cfcone->SetLineColor(4); // Blue
2093   cfcone->SetLineWidth(1);
2094   cfcone->SetFillColor(cfcone->GetLineColor());
2095   cfcone->SetFillStyle(4000); // 0% transparent
2096
2097   TGeoVolume *cfconeinsert = new TGeoVolume("SDDCarbonFiberConeInsert",
2098                                             coneinsertshape,medSDDste);
2099   cfconeinsert->SetVisibility(kTRUE);
2100   cfconeinsert->SetLineColor(2); // Red
2101   cfconeinsert->SetLineWidth(1);
2102   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2103   cfconeinsert->SetFillStyle(4050); // 50% transparent
2104
2105   TGeoVolume *cfconefoam = new TGeoVolume("SDDCarbonFiberConeFoam",
2106                                           conefoamshape,medSDDroh);
2107   cfconefoam->SetVisibility(kTRUE);
2108   cfconefoam->SetLineColor(7); // Light blue
2109   cfconefoam->SetLineWidth(1);
2110   cfconefoam->SetFillColor(cfconefoam->GetLineColor());
2111   cfconefoam->SetFillStyle(4050); // 50% transparent
2112
2113   TGeoVolume *hole1 = new TGeoVolume("SDDCableHole1",
2114                                      hole1shape,medSDDair);
2115   hole1->SetVisibility(kTRUE);
2116   hole1->SetLineColor(5); // Yellow
2117   hole1->SetLineWidth(1);
2118   hole1->SetFillColor(hole1->GetLineColor());
2119   hole1->SetFillStyle(4090); // 90% transparent
2120
2121   TGeoVolume *hole11 = new TGeoVolume("SDDCableHole11",
2122                                       hole11shape,medSDDair);
2123   hole11->SetVisibility(kTRUE);
2124   hole11->SetLineColor(5); // Yellow
2125   hole11->SetLineWidth(1);
2126   hole11->SetFillColor(hole11->GetLineColor());
2127   hole11->SetFillStyle(4090); // 90% transparent
2128
2129   TGeoVolume *hole12 = new TGeoVolume("SDDCableHole12",
2130                                       hole12shape,medSDDair);
2131   hole12->SetVisibility(kTRUE);
2132   hole12->SetLineColor(5); // Yellow
2133   hole12->SetLineWidth(1);
2134   hole12->SetFillColor(hole12->GetLineColor());
2135   hole12->SetFillStyle(4090); // 90% transparent
2136
2137   TGeoVolume *hole1plast = new TGeoVolume("SDDCableHole1Plast",
2138                                           hole1plastshape,medSDDplast);
2139   hole1plast->SetVisibility(kTRUE);
2140   hole1plast->SetLineColor(kBlue);
2141   hole1plast->SetLineWidth(1);
2142   hole1plast->SetFillColor(hole1plast->GetLineColor());
2143   hole1plast->SetFillStyle(4090); // 90% transparent
2144
2145   TGeoVolume *hole1Cu = new TGeoVolume("SDDCableHole1Cu",
2146                                        hole1Cushape,medSDDCu);
2147   hole1Cu->SetVisibility(kTRUE);
2148   hole1Cu->SetLineColor(kRed);
2149   hole1Cu->SetLineWidth(1);
2150   hole1Cu->SetFillColor(hole1Cu->GetLineColor());
2151   hole1Cu->SetFillStyle(4090); // 90% transparent
2152
2153   TGeoVolume *hole1glass = new TGeoVolume("SDDCableHole1glass",
2154                                           hole1glassshape,medSDDglass);
2155   hole1glass->SetVisibility(kTRUE);
2156   hole1glass->SetLineColor(kGreen);
2157   hole1glass->SetLineWidth(1);
2158   hole1glass->SetFillColor(hole1glass->GetLineColor());
2159   hole1glass->SetFillStyle(4090); // 90% transparent
2160
2161   TGeoVolume *hole2 = new TGeoVolume("SDDCableHole2",
2162                                      hole2shape,medSDDair);
2163   hole2->SetVisibility(kTRUE);
2164   hole2->SetLineColor(5); // Yellow
2165   hole2->SetLineWidth(1);
2166   hole2->SetFillColor(hole2->GetLineColor());
2167   hole2->SetFillStyle(4090); // 90% transparent
2168
2169   TGeoVolume *hole21 = new TGeoVolume("SDDCableHole21",
2170                                       hole21shape,medSDDair);
2171   hole21->SetVisibility(kTRUE);
2172   hole21->SetLineColor(5); // Yellow
2173   hole21->SetLineWidth(1);
2174   hole21->SetFillColor(hole21->GetLineColor());
2175   hole21->SetFillStyle(4090); // 90% transparent
2176
2177   TGeoVolume *hole22 = new TGeoVolume("SDDCableHole22",
2178                                       hole22shape,medSDDair);
2179   hole22->SetVisibility(kTRUE);
2180   hole22->SetLineColor(5); // Yellow
2181   hole22->SetLineWidth(1);
2182   hole22->SetFillColor(hole22->GetLineColor());
2183   hole22->SetFillStyle(4090); // 90% transparent
2184
2185   TGeoVolume *hole2plast = new TGeoVolume("SDDCableHole2Plast",
2186                                           hole2plastshape,medSDDplast);
2187   hole2plast->SetVisibility(kTRUE);
2188   hole2plast->SetLineColor(kBlue);
2189   hole2plast->SetLineWidth(1);
2190   hole2plast->SetFillColor(hole2plast->GetLineColor());
2191   hole2plast->SetFillStyle(4090); // 90% transparent
2192
2193   TGeoVolume *hole2Cu = new TGeoVolume("SDDCableHole2Cu",
2194                                        hole2Cushape,medSDDCu);
2195   hole2Cu->SetVisibility(kTRUE);
2196   hole2Cu->SetLineColor(kRed);
2197   hole2Cu->SetLineWidth(1);
2198   hole2Cu->SetFillColor(hole2Cu->GetLineColor());
2199   hole2Cu->SetFillStyle(4090); // 90% transparent
2200
2201   TGeoVolume *hole2glass = new TGeoVolume("SDDCableHole2glass",
2202                                           hole2glassshape,medSDDglass);
2203   hole2glass->SetVisibility(kTRUE);
2204   hole2glass->SetLineColor(kGreen);
2205   hole2glass->SetLineWidth(1);
2206   hole2glass->SetFillColor(hole2glass->GetLineColor());
2207   hole2glass->SetFillStyle(4090); // 90% transparent
2208
2209   TGeoVolume *hole3 = new TGeoVolume("SDDCableHole3",
2210                                      hole3shape,medSDDair);
2211   hole3->SetVisibility(kTRUE);
2212   hole3->SetLineColor(5); // Yellow
2213   hole3->SetLineWidth(1);
2214   hole3->SetFillColor(hole3->GetLineColor());
2215   hole3->SetFillStyle(4090); // 90% transparent
2216
2217   TGeoVolume *hole31 = new TGeoVolume("SDDCableHole31",
2218                                       hole31shape,medSDDair);
2219   hole31->SetVisibility(kTRUE);
2220   hole31->SetLineColor(5); // Yellow
2221   hole31->SetLineWidth(1);
2222   hole31->SetFillColor(hole31->GetLineColor());
2223   hole31->SetFillStyle(4090); // 90% transparent
2224
2225   TGeoVolume *hole32 = new TGeoVolume("SDDCableHole32",
2226                                       hole32shape,medSDDair);
2227   hole32->SetVisibility(kTRUE);
2228   hole32->SetLineColor(5); // Yellow
2229   hole32->SetLineWidth(1);
2230   hole32->SetFillColor(hole32->GetLineColor());
2231   hole32->SetFillStyle(4090); // 90% transparent
2232
2233   TGeoVolume *hole4 = new TGeoVolume("SDDCableHole4",
2234                                      hole4shape,medSDDair);
2235   hole4->SetVisibility(kTRUE);
2236   hole4->SetLineColor(5); // Yellow
2237   hole4->SetLineWidth(1);
2238   hole4->SetFillColor(hole4->GetLineColor());
2239   hole4->SetFillStyle(4090); // 90% transparent
2240
2241   // Mount up a cone
2242   cfconeinsert->AddNode(cfconefoam,1,0);
2243
2244   hole1->AddNode(hole1plast, 1, 0);
2245   hole1->AddNode(hole1Cu, 1, 0);
2246   hole1->AddNode(hole1glass, 1, 0);
2247
2248   hole2->AddNode(hole2plast, 1, 0);
2249   hole2->AddNode(hole2Cu, 1, 0);
2250   hole2->AddNode(hole2glass, 1, 0);
2251
2252   for (Int_t i=0; i<12; i++) {
2253     Double_t phiH = i*30.0;
2254     cfconefoam->AddNode(hole1 , i+1, new TGeoRotation("", 0, 0, phiH));
2255         cfcone->AddNode(hole11, i+1, new TGeoRotation("", 0, 0, phiH));
2256         cfcone->AddNode(hole12, i+1, new TGeoRotation("", 0, 0, phiH));
2257   }
2258
2259   for (Int_t i=0; i<6; i++) {
2260     Double_t phiH = i*60.0;
2261     cfconefoam->AddNode(hole2 , i+1, new TGeoRotation("", 0, 0, phiH));
2262         cfcone->AddNode(hole21, i+1, new TGeoRotation("", 0, 0, phiH));
2263         cfcone->AddNode(hole22, i+1, new TGeoRotation("", 0, 0, phiH));
2264   }
2265
2266   for (Int_t i=0; i<kNHole3; i++) {
2267     Double_t phiH0 = 360./(Double_t)kNHole3;
2268     Double_t phiH  = i*phiH0 + 0.5*phiH0;
2269     cfconefoam->AddNode(hole3 , i+1, new TGeoRotation("", phiH, 0, 0));
2270         cfcone->AddNode(hole31, i+1, new TGeoRotation("", phiH, 0, 0));
2271         cfcone->AddNode(hole32, i+1, new TGeoRotation("", phiH, 0, 0));
2272   }
2273
2274   cfcone->AddNode(cfconeinsert,1,0);
2275
2276 /*
2277   for (Int_t i=0; i<kNHole4; i++) {
2278     Double_t phiH0 = 360./(Double_t)kNHole4;
2279     Double_t phiH  = i*phiH0 + 0.25*phiH0;
2280     cfcone->AddNode(hole4, i+1, new TGeoRotation("", phiH, 0, 0));
2281   }
2282 */
2283   // Finally put everything in the mother volume
2284   moth->AddNode(cfcylinder,1,0);
2285
2286   z = coneshape->Z(9);
2287   moth->AddNode(cfcone,1,new TGeoTranslation(0, 0, -z - kCylinderHalfLength));
2288   moth->AddNode(cfcone,2,new TGeoCombiTrans (0, 0,  z + kCylinderHalfLength,
2289                          new TGeoRotation("", 0, 180, 0)                   ));
2290
2291
2292   return;
2293 }
2294
2295 //______________________________________________________________________
2296 void AliITSv11GeometrySupport::SSDCone(TGeoVolume *moth,const TGeoManager *mgr)
2297 {
2298 //
2299 // Creates the SSD support cone and cylinder geometry. as a
2300 // volume assembly and adds it to the mother volume
2301 // (part of this code is taken or anyway inspired to SSDCone method
2302 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
2303 //
2304 // Input:
2305 //         moth : the TGeoVolume owing the volume structure
2306 //         mgr  : the GeoManager (default gGeoManager)
2307 // Output:
2308 //
2309 // Created:         ???       Bjorn S. Nilsen
2310 // Updated:      08 Mar 2008  Mario Sitta
2311 //
2312 // Technical data are taken from:  "ITS Supporto Generale" (technical
2313 // drawings ALR3-0743/1, ALR3-0743/1A and ALR3-0743/1B), "Supporto Generale
2314 // Settore SSD" (technical drawings ALR3-0743/2A and ALR3-0743/2E), private
2315 // communication with B. Giraudo
2316 //
2317 // Updated:      11 Apr 2008  Mario Sitta
2318 // Measures from drawings give overlaps with SPD thermal shield wings,
2319 // so the terminal part of the SSD cone was reduced
2320 //
2321 // Updated:      30 Mar 2010  Mario Sitta
2322 // Following M. van Leeuwen's suggestion on material budget, the thickness
2323 // of the carbon fiber cylinder was increased from 0.6 to 0.625mm
2324
2325   // Dimensions of the Central cylinder and flanges
2326   const Double_t kCylinderHalfLength   = (1143.6/2) *fgkmm;
2327   const Double_t kCylinderOuterRadius  = ( 595.0/2) *fgkmm;
2328   const Double_t kCylinderThickness    =       0.625*fgkmm;
2329   const Double_t kFoamHalfLength       = (1020.0/2) *fgkmm;
2330   const Double_t kFoamThickness        =        5.0 *fgkmm;
2331   const Double_t kFlangeHalfLength     =
2332                                       (kCylinderHalfLength-kFoamHalfLength)/2.;
2333   const Double_t kFlangeInnerRadius    = ( 563.0/2) *fgkmm;
2334   // Dimensions of the Cone
2335   const Double_t kConeROuterMin        = ( 957.0/2) *fgkmm;
2336   const Double_t kConeROuterMax        = ( 997.0/2) *fgkmm;
2337   const Double_t kConeRInnerMin        = ( 564.0/2) *fgkmm;
2338   const Double_t kConeRCurv1           =       10.0 *fgkmm;
2339   const Double_t kConeRCurv2           =       25.0 *fgkmm;
2340   const Double_t kConeCent1RCurv2      = ( 578.0/2) *fgkmm;
2341   const Double_t kConeCent2RCurv2      = ( 592.0/2) *fgkmm;
2342 //  const Double_t kConeZOuterRing       =       47.0 *fgkmm;
2343 //  const Double_t kConeZOuterRingInside =       30.25*fgkmm;
2344 //  const Double_t kConeZInnerRing       =      161.5 *fgkmm;
2345 //  const Double_t kConeZLength          =      176.5 *fgkmm;
2346   const Double_t kConeZOuterRing       =       38.5 *fgkmm;
2347   const Double_t kConeZOuterRingInside =       22.2 *fgkmm;
2348   const Double_t kConeZInnerRing       =      153.0 *fgkmm;
2349   const Double_t kConeZLength          =      168.0 *fgkmm;
2350   const Double_t kConeZPosition        = kConeZLength + kCylinderHalfLength;
2351   const Double_t kConeThickness        =       13.0 *fgkmm; // Cone thickness
2352   const Double_t kConeTheta            =       39.1 *fgkDegree; // Cone angle
2353   const Double_t kSinConeTheta         =
2354                                       TMath::Sin(kConeTheta*TMath::DegToRad());
2355   const Double_t kCosConeTheta         =
2356                                       TMath::Cos(kConeTheta*TMath::DegToRad());
2357   // Dimensions of the Foam cores
2358   const Double_t kConeFoam1Length      =      112.3 *fgkmm;
2359   const Double_t kConeFoam2Length      =       58.4 *fgkmm;
2360   // Dimensions of the Cone Holes
2361   const Double_t kCoolingHoleWidth     =       40.0 *fgkmm;
2362   const Double_t kCoolingHoleHight     =       30.0 *fgkmm;
2363   const Double_t kCoolingHoleRmin      =      350.0 *fgkmm;
2364   const Double_t kCoolingHolePhi       =       45.0 *fgkDegree;
2365   const Double_t kMountingHoleWidth    =       20.0 *fgkmm;
2366   const Double_t kMountingHoleHight    =       20.0 *fgkmm;
2367   const Double_t kMountingHoleRmin     =      317.5 *fgkmm;
2368   const Double_t kMountingHolePhi      =       60.0 *fgkDegree;
2369   const Double_t kCableHoleRin         = ( 800.0/2) *fgkmm;
2370   const Double_t kCableHoleRout        = ( 920.0/2) *fgkmm;
2371   const Double_t kCableHoleWidth       =      200.0 *fgkmm;
2372 //  const Double_t kCableHoleAngle       =       42.0 *fgkDegree;
2373   // Dimensions of the Cone Wings
2374   const Double_t kWingRmax             =      527.5 *fgkmm;
2375   const Double_t kWingWidth            =       70.0 *fgkmm;
2376   const Double_t kWingHalfThick        = (  10.0/2) *fgkmm;
2377   const Double_t kThetaWing            =       45.0 *fgkDegree;
2378   // Dimensions of the SSD-SDD Mounting Brackets
2379   const Double_t kBracketRmin          = ( 541.0/2) *fgkmm;// See SDD ROutMin
2380   const Double_t kBracketRmax          = ( 585.0/2) *fgkmm;
2381   const Double_t kBracketHalfLength    = (   4.0/2) *fgkmm;
2382   const Double_t kBracketPhi           = (70.*fgkmm/kBracketRmax)*fgkRadian;
2383   // Common data
2384   const Double_t kCFThickness          =        0.75*fgkmm; //Carb. fib. thick.
2385
2386
2387   // Local variables
2388   Double_t rmin1, rmin2, rmax, z;
2389
2390   //
2391   //Begin_Html
2392   /*
2393     <img src="picts/ITS/file_name.gif">
2394     <P>
2395     <FONT FACE'"TIMES">
2396     ITS SSD central support and thermal shield cylinder.
2397     </FONT>
2398     </P>
2399   */
2400   //End_Html
2401   //
2402
2403   // Central cylinder with its internal foam and the lateral flanges:
2404   // a carbon fiber Pcon which contains a rohacell Tube and two
2405   // stesalite Cone's
2406   TGeoPcon *externalcylshape = new TGeoPcon(0,360,4);
2407
2408   rmax  = kCylinderOuterRadius;
2409   rmin1 = kFlangeInnerRadius - kCylinderThickness;
2410   rmin2 = rmax - 2*kCylinderThickness - kFoamThickness;
2411   externalcylshape->DefineSection(0,-kCylinderHalfLength,rmin1,rmax);
2412   externalcylshape->DefineSection(1,-kFoamHalfLength    ,rmin2,rmax);
2413   externalcylshape->DefineSection(2, kFoamHalfLength    ,rmin2,rmax);
2414   externalcylshape->DefineSection(3, kCylinderHalfLength,rmin1,rmax);
2415
2416   rmax  = kCylinderOuterRadius - kCylinderThickness;
2417   rmin1 = rmax - kFoamThickness;
2418   TGeoTube *foamshape = new TGeoTube(rmin1,rmax,kFoamHalfLength);
2419
2420   rmax  = kCylinderOuterRadius - kCylinderThickness;
2421   rmin1 = rmax - kFoamThickness;
2422   rmin2 = kFlangeInnerRadius;
2423   TGeoCone *flangeshape = new TGeoCone(kFlangeHalfLength,
2424                                        rmin1,rmax,rmin2,rmax);
2425
2426
2427   // We have the shapes: now create the real volumes
2428
2429   TGeoMedium *medSSDcf  = mgr->GetMedium("ITS_SSD C (M55J)$");
2430   TGeoMedium *medSSDair = mgr->GetMedium("ITS_SSD AIR$");
2431   TGeoMedium *medSSDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
2432   TGeoMedium *medSSDroh = mgr->GetMedium("ITS_ROHACELL$");
2433   TGeoMedium *medSSDal  = mgr->GetMedium("ITS_ALUMINUM$");
2434
2435   TGeoVolume *cfcylinder = new TGeoVolume("SSDexternalcylinder",
2436                                            externalcylshape,medSSDcf);
2437   cfcylinder->SetVisibility(kTRUE);
2438   cfcylinder->SetLineColor(4); // blue
2439   cfcylinder->SetLineWidth(1);
2440   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
2441   cfcylinder->SetFillStyle(4000); // 0% transparent
2442
2443   TGeoVolume *foamcylinder = new TGeoVolume("SSDfoamcylinder",
2444                                             foamshape,medSSDroh);
2445   foamcylinder->SetVisibility(kTRUE);
2446   foamcylinder->SetLineColor(3); // green
2447   foamcylinder->SetLineWidth(1);
2448   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
2449   foamcylinder->SetFillStyle(4050); // 50% transparent
2450
2451   TGeoVolume *flangecylinder = new TGeoVolume("SSDflangecylinder",
2452                                               flangeshape,medSSDste);
2453   flangecylinder->SetVisibility(kTRUE);
2454   flangecylinder->SetLineColor(2); // red
2455   flangecylinder->SetLineWidth(1);
2456   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
2457   flangecylinder->SetFillStyle(4050); // 50% transparent
2458
2459   // Mount up the cylinder
2460   cfcylinder->AddNode(foamcylinder,1,0);
2461   cfcylinder->AddNode(flangecylinder,1,
2462               new TGeoTranslation(0, 0, kFoamHalfLength+kFlangeHalfLength));
2463   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
2464               0, 0, -kFoamHalfLength-kFlangeHalfLength,
2465               new TGeoRotation("",0,180,0)     ) );
2466
2467
2468   // The whole Cone as an assembly
2469   TGeoVolumeAssembly *vC = new TGeoVolumeAssembly("ITSssdCone");
2470
2471
2472   // SSD Support Cone with its internal inserts: a carbon fiber Pcon
2473   // with holes which contains a stesalite Pcon which on turn contains a
2474   // rohacell Pcon
2475   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 12);
2476
2477   coneshape->Z(0)     = 0.0;
2478   coneshape->Rmin(0)  = kConeROuterMin;
2479   coneshape->Rmax(0)  = kConeROuterMax;
2480
2481   coneshape->Z(1)     = kConeZOuterRingInside - kConeRCurv1;
2482   coneshape->Rmin(1)  = coneshape->GetRmin(0);
2483   coneshape->Rmax(1)  = coneshape->GetRmax(0);
2484
2485   coneshape->Z(2)     = kConeZOuterRingInside;
2486   coneshape->Rmin(2)  = coneshape->GetRmin(1) - kConeRCurv1;
2487   coneshape->Rmax(2)  = coneshape->GetRmax(0);
2488
2489   coneshape->Z(3)     = coneshape->GetZ(2);
2490   coneshape->Rmax(3)  = coneshape->GetRmax(0);
2491
2492   coneshape->Z(4)     = kConeZOuterRing - kConeRCurv1;
2493   coneshape->Rmax(4)  = coneshape->GetRmax(0);
2494
2495   coneshape->Z(5)     = kConeZOuterRing;
2496   coneshape->Rmax(5)  = coneshape->GetRmax(4) - kConeRCurv1;
2497
2498   coneshape->Z(6)     = coneshape->GetZ(5);
2499
2500   RadiusOfCurvature(kConeRCurv2,90.0,kConeZInnerRing,kConeCent1RCurv2,
2501                     90.0-kConeTheta,z,rmin1);
2502   coneshape->Z(7)     = z;
2503   coneshape->Rmin(7)  = rmin1;
2504
2505   coneshape->Rmin(3)  = RminFromZpCone(coneshape,7,90.-kConeTheta,
2506                                        coneshape->GetZ(3));
2507
2508   coneshape->Rmin(4)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(4));
2509
2510   coneshape->Rmin(5)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(5));
2511
2512   coneshape->Rmin(6) = coneshape->GetRmin(5);
2513
2514   coneshape->Z(8)     = kConeZInnerRing;
2515   coneshape->Rmin(8)  = kConeCent1RCurv2;
2516
2517   coneshape->Z(9)     = coneshape->GetZ(8);
2518   coneshape->Rmin(9)  = kConeRInnerMin;
2519
2520   RadiusOfCurvature(kConeRCurv2,90.0,kConeZLength,kConeCent2RCurv2,
2521                     90.0-kConeTheta,z,rmax);
2522
2523   coneshape->Z(10)    = z;
2524   coneshape->Rmin(10) = coneshape->GetRmin(9);
2525   coneshape->Rmax(10) = rmax;
2526
2527   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,10,90.-kConeTheta,
2528                                        coneshape->GetZ(6));
2529
2530   coneshape->Rmax(7)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(7));
2531
2532   coneshape->Rmax(8)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(8));
2533
2534   coneshape->Rmax(9)  = coneshape->GetRmax(8);
2535
2536   coneshape->Z(11)    = kConeZLength;
2537   coneshape->Rmin(11) = coneshape->GetRmin(10);
2538   coneshape->Rmax(11) = kConeCent2RCurv2;
2539
2540   // SSD Cone Insert: another Pcon
2541   Double_t x0, y0, x1, y1, x2, y2;
2542   TGeoPcon *coneinsertshape = new TGeoPcon(0.0,360.0,12);
2543
2544   coneinsertshape->Z(0)     = coneshape->GetZ(0) + kCFThickness;
2545   coneinsertshape->Rmin(0)  = coneshape->GetRmin(0) + kCFThickness;
2546   coneinsertshape->Rmax(0)  = coneshape->GetRmax(0) - kCFThickness;
2547
2548   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
2549   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
2550   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
2551   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2552   coneinsertshape->Z(1)     = z;
2553   coneinsertshape->Rmin(1)  = rmin1;
2554   coneinsertshape->Rmax(1)  = coneinsertshape->GetRmax(0);
2555
2556   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmin(1);
2557   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmin(2);
2558   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmin(3);
2559   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2560   coneinsertshape->Z(2)     = z;
2561   coneinsertshape->Rmin(2)  = rmin1;
2562   coneinsertshape->Rmax(2)  = coneinsertshape->GetRmax(1);
2563
2564   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
2565   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
2566   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
2567   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2568   coneinsertshape->Z(3)     = z;
2569   coneinsertshape->Rmin(3)  = rmin1;
2570   coneinsertshape->Rmax(3)  = coneinsertshape->GetRmax(2);
2571
2572   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
2573   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
2574   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
2575   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2576   coneinsertshape->Z(4)     = z;
2577   coneinsertshape->Rmax(4)  = rmax;
2578
2579   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmax(4);
2580   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmax(5);
2581   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmax(6);
2582   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2583   coneinsertshape->Z(5)     = z;
2584   coneinsertshape->Rmax(5)  = rmax;
2585
2586   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmax(5);
2587   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmax(6);
2588   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmax(7);
2589   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2590   coneinsertshape->Z(6)     = z;
2591   coneinsertshape->Rmax(6)  = rmax;
2592
2593   x0 = coneshape->GetZ(6); y0 = coneshape->GetRmin(6);
2594   x1 = coneshape->GetZ(7); y1 = coneshape->GetRmin(7);
2595   x2 = coneshape->GetZ(8); y2 = coneshape->GetRmin(8);
2596   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2597   coneinsertshape->Z(7)     = z;
2598   coneinsertshape->Rmin(7)  = rmin1;
2599
2600   coneinsertshape->Rmin(4)  = RminFrom2Points(coneinsertshape,3,7,
2601                                               coneinsertshape->GetZ(4));
2602
2603   coneinsertshape->Rmin(5)  = RminFrom2Points(coneinsertshape,3,7,
2604                                               coneinsertshape->GetZ(5));
2605
2606   coneinsertshape->Rmin(6)  = coneinsertshape->GetRmin(5);
2607
2608   x0 = coneshape->GetZ(7); y0 = coneshape->GetRmin(7);
2609   x1 = coneshape->GetZ(8); y1 = coneshape->GetRmin(8);
2610   x2 = coneshape->GetZ(9); y2 = coneshape->GetRmin(9);
2611   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2612   coneinsertshape->Z(8)     = z;
2613   coneinsertshape->Rmin(8)  = rmin1;
2614
2615   x0 = coneshape->GetZ( 8); y0 = coneshape->GetRmin( 8);
2616   x1 = coneshape->GetZ( 9); y1 = coneshape->GetRmin( 9);
2617   x2 = coneshape->GetZ(10); y2 = coneshape->GetRmin(10);
2618   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2619   coneinsertshape->Z(9)     = z;
2620   coneinsertshape->Rmin(9)  = rmin1;
2621
2622   x0 = coneshape->GetZ( 9); y0 = coneshape->GetRmax( 9);
2623   x1 = coneshape->GetZ(10); y1 = coneshape->GetRmax(10);
2624   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmax(11);
2625   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2626   coneinsertshape->Z(10)    = z;
2627   coneinsertshape->Rmax(10) = rmax;
2628   coneinsertshape->Rmin(10) = coneinsertshape->GetRmin(9);
2629
2630   coneinsertshape->Rmax(7)  = RmaxFrom2Points(coneinsertshape,6,10,
2631                                               coneinsertshape->GetZ(7));
2632
2633   coneinsertshape->Rmax(8)  = RmaxFrom2Points(coneinsertshape,6,10,
2634                                               coneinsertshape->GetZ(8));
2635
2636   coneinsertshape->Rmax(9)  = coneinsertshape->GetRmax(8);
2637
2638   x0 = coneshape->GetZ(10); y0 = coneshape->GetRmax(10);
2639   x1 = coneshape->GetZ(11); y1 = coneshape->GetRmax(11);
2640   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmin(11);
2641   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2642   coneinsertshape->Z(11)    = z;
2643   coneinsertshape->Rmax(11) = rmax;
2644   coneinsertshape->Rmin(11) = coneinsertshape->GetRmin(10);
2645
2646   // SSD Cone Foams: two other Pcon's
2647   TGeoPcon *conefoam1shape = new TGeoPcon(0.0, 360.0, 4);
2648
2649   conefoam1shape->Z(0)    = coneinsertshape->GetZ(3);
2650   conefoam1shape->Rmin(0) = coneinsertshape->GetRmin(3);
2651   conefoam1shape->Rmax(0) = conefoam1shape->GetRmin(0);
2652
2653   conefoam1shape->Rmax(1) = conefoam1shape->GetRmax(0);
2654   conefoam1shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2655                                            conefoam1shape->GetRmax(1));
2656   conefoam1shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2657                                            conefoam1shape->GetZ(1));
2658
2659   Double_t t = kConeThickness - 2*kCFThickness;
2660   conefoam1shape->Rmin(2) = conefoam1shape->GetRmax(0) -
2661                            (kConeFoam1Length*kCosConeTheta - t*kSinConeTheta);
2662   conefoam1shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2663                                            conefoam1shape->GetRmin(2));
2664   conefoam1shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2665                                            conefoam1shape->GetZ(2));
2666
2667   conefoam1shape->Rmin(3) = conefoam1shape->GetRmin(2);
2668   conefoam1shape->Rmax(3) = conefoam1shape->GetRmin(3);
2669   conefoam1shape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2670                                            conefoam1shape->GetRmax(3));
2671
2672   TGeoPcon *conefoam2shape = new TGeoPcon(0.0, 360.0, 4);
2673
2674   conefoam2shape->Z(3)    = coneinsertshape->GetZ(10);
2675   conefoam2shape->Rmin(3) = coneinsertshape->GetRmax(10);
2676   conefoam2shape->Rmax(3) = conefoam2shape->GetRmin(3);
2677
2678   conefoam2shape->Rmin(2) = conefoam2shape->GetRmin(3);
2679   conefoam2shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2680                                            conefoam2shape->GetRmin(2));
2681   conefoam2shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2682                                            conefoam2shape->GetZ(2));
2683
2684   conefoam2shape->Rmin(0) = conefoam2shape->GetRmax(2) +
2685                            (kConeFoam2Length*kCosConeTheta - t*kSinConeTheta);
2686   conefoam2shape->Rmax(0) = conefoam2shape->GetRmin(0);
2687   conefoam2shape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2688                                            conefoam2shape->GetRmin(0));
2689
2690   conefoam2shape->Rmax(1) = conefoam2shape->GetRmax(0);
2691   conefoam2shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2692                                            conefoam2shape->GetRmax(1));
2693   conefoam2shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2694                                            conefoam2shape->GetZ(1));
2695
2696   // SSD Cone Holes: Pcon's
2697   // A single hole volume gives an overlap with coneinsert, so
2698   // three contiguous volumes are created: one to be put in coneinsert
2699   // and two in the cone carbon fiber envelope
2700   Double_t holePhi;
2701   holePhi = (kCoolingHoleWidth/kCoolingHoleRmin)*TMath::RadToDeg();
2702
2703   TGeoPcon *coolingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2704
2705   coolingholeshape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2706   coolingholeshape->Rmax(0) = coolingholeshape->GetRmin(0);
2707   coolingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2708                                              coolingholeshape->GetRmin(0));
2709
2710   coolingholeshape->Rmax(1) = coolingholeshape->GetRmax(0);
2711   coolingholeshape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2712                                              coolingholeshape->GetRmax(1));
2713   coolingholeshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2714                                              coolingholeshape->GetZ(1));
2715
2716   coolingholeshape->Rmin(2) = kCoolingHoleRmin;
2717   coolingholeshape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2718                                              coolingholeshape->GetRmin(2));
2719   coolingholeshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2720                                              coolingholeshape->GetZ(2));
2721
2722   coolingholeshape->Rmin(3) = coolingholeshape->GetRmin(2);
2723   coolingholeshape->Rmax(3) = coolingholeshape->GetRmin(3);
2724   coolingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2725                                              coolingholeshape->GetRmax(3));
2726
2727   TGeoPcon *coolinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2728
2729   coolinghole2shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2730   coolinghole2shape->Rmax(0) = coolinghole2shape->GetRmin(0);
2731   coolinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2732                                               coolinghole2shape->GetRmin(0));
2733
2734   coolinghole2shape->Rmax(1) = coolinghole2shape->GetRmax(0);
2735   coolinghole2shape->Z(1)    = coolingholeshape->GetZ(0);
2736   coolinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2737                                               coolinghole2shape->GetZ(1));
2738
2739   coolinghole2shape->Rmin(2) = kCoolingHoleRmin;
2740   coolinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2741                                               coolinghole2shape->GetRmin(2));
2742   coolinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2743                                               coolinghole2shape->GetZ(2));
2744
2745   coolinghole2shape->Rmin(3) = coolinghole2shape->GetRmin(2);
2746   coolinghole2shape->Rmax(3) = coolinghole2shape->GetRmin(3);
2747   coolinghole2shape->Z(3)    = coolingholeshape->GetZ(2);
2748
2749   TGeoPcon *coolinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2750
2751   coolinghole3shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2752   coolinghole3shape->Rmax(0) = coolinghole3shape->GetRmin(0);
2753   coolinghole3shape->Z(0)    = coolingholeshape->GetZ(1);
2754
2755   coolinghole3shape->Rmax(1) = coolinghole3shape->GetRmax(0);
2756   coolinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2757                                               coolinghole3shape->GetRmax(1));
2758   coolinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2759                                               coolinghole3shape->GetZ(1));
2760
2761   coolinghole3shape->Rmin(2) = kCoolingHoleRmin;
2762   coolinghole3shape->Z(2)    = coolingholeshape->GetZ(3);
2763   coolinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2764                                               coolinghole3shape->GetZ(2));
2765
2766   coolinghole3shape->Rmin(3) = coolinghole3shape->GetRmin(2);
2767   coolinghole3shape->Rmax(3) = coolinghole3shape->GetRmin(3);
2768   coolinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2769                                               coolinghole3shape->GetRmax(3));
2770
2771   //
2772   holePhi = (kMountingHoleWidth/kMountingHoleRmin)*TMath::RadToDeg();
2773
2774   TGeoPcon *mountingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2775
2776   mountingholeshape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2777   mountingholeshape->Rmax(0) = mountingholeshape->GetRmin(0);
2778   mountingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2779                                               mountingholeshape->GetRmin(0));
2780
2781   mountingholeshape->Rmin(1) = kMountingHoleRmin;
2782   mountingholeshape->Rmax(1) = mountingholeshape->GetRmax(0);
2783   mountingholeshape->Z(1)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2784                                               mountingholeshape->GetRmin(1));
2785
2786   mountingholeshape->Rmin(2) = mountingholeshape->GetRmin(1);
2787   mountingholeshape->Rmax(2) = mountingholeshape->GetRmax(1);
2788   mountingholeshape->Z(2)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2789                                               mountingholeshape->GetRmax(2));
2790
2791   mountingholeshape->Rmin(3) = mountingholeshape->GetRmin(2);
2792   mountingholeshape->Rmax(3) = mountingholeshape->GetRmin(3);
2793   mountingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2794                                               mountingholeshape->GetRmax(3));
2795
2796   TGeoPcon *mountinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2797
2798   mountinghole2shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2799   mountinghole2shape->Rmax(0) = mountingholeshape->GetRmin(0);
2800   mountinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2801                                                mountinghole2shape->GetRmin(0));
2802
2803   mountinghole2shape->Rmax(1) = mountinghole2shape->GetRmax(0);
2804   mountinghole2shape->Z(1)    = mountingholeshape->Z(0);
2805   mountinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2806                                                mountinghole2shape->GetZ(1));
2807
2808   mountinghole2shape->Rmin(2) = kMountingHoleRmin;
2809   mountinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2810                                                mountinghole2shape->GetRmin(2));
2811   mountinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2812                                                mountinghole2shape->GetZ(2));
2813
2814   mountinghole2shape->Rmin(3) = mountinghole2shape->Rmin(2);
2815   mountinghole2shape->Rmax(3) = mountinghole2shape->Rmin(3);
2816   mountinghole2shape->Z(3)    = mountingholeshape->Z(1);
2817
2818   TGeoPcon *mountinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2819
2820   mountinghole3shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2821   mountinghole3shape->Rmax(0) = mountingholeshape->GetRmin(0);
2822   mountinghole3shape->Z(0)    = mountingholeshape->GetZ(2);
2823
2824   mountinghole3shape->Rmax(1) = mountinghole3shape->GetRmax(0);
2825   mountinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2826                                                mountinghole3shape->GetRmax(1));
2827   mountinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2828                                                mountinghole3shape->GetZ(1));
2829
2830   mountinghole3shape->Rmin(2) = kMountingHoleRmin;
2831   mountinghole3shape->Z(2)    = mountingholeshape->Z(3);
2832   mountinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2833                                                mountinghole3shape->GetZ(2));
2834
2835   mountinghole3shape->Rmin(3) = mountinghole3shape->Rmin(2);
2836   mountinghole3shape->Rmax(3) = mountinghole3shape->Rmin(3);
2837   mountinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2838                                                mountinghole3shape->GetRmax(3));
2839
2840   // The Cable Hole is even more complicated, a Composite Shape
2841   // is unavoidable here (gosh!)
2842   TGeoPcon *coneshapecopy = new TGeoPcon("conecopy",0.0, 360.0, 12);
2843
2844   for (Int_t i=0; i<12; i++) {
2845     coneshapecopy->Rmin(i) = coneshape->GetRmin(i);
2846     coneshapecopy->Rmax(i) = coneshape->GetRmax(i);
2847     coneshapecopy->Z(i)    = coneshape->GetZ(i);
2848   }
2849
2850   holePhi = (kCableHoleWidth/kCableHoleRout)*TMath::RadToDeg();
2851   TGeoConeSeg *chCS = new TGeoConeSeg("chCS", 0.5*kConeZLength,
2852                                       kCableHoleRin, kCableHoleRout,
2853                                       kCableHoleRin, kCableHoleRout,
2854                                       -0.5*holePhi, 0.5*holePhi);
2855
2856   TGeoCompositeShape *cableholeshape = new TGeoCompositeShape(
2857                                            "SSDCableHoleShape",
2858                                            "conecopy*chCS");
2859
2860   if(GetDebug(1)){
2861     chCS->InspectShape();
2862     cableholeshape->InspectShape();
2863   }
2864
2865   // SSD Cone Wings: Tube and TubeSeg shapes
2866   Double_t angleWideWing, angleWideWingThickness;
2867   angleWideWing = (kWingWidth/kWingRmax)*TMath::RadToDeg();
2868   angleWideWingThickness = (kCFThickness/kWingRmax)*TMath::RadToDeg();
2869
2870   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kConeROuterMax, kWingRmax,
2871                                            kWingHalfThick,
2872                                            0, angleWideWing);
2873
2874   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kConeROuterMax,
2875                                  kWingRmax-kCFThickness,
2876                                  kWingHalfThick-kCFThickness,
2877                                  angleWideWingThickness,
2878                                  angleWideWing-angleWideWingThickness);
2879
2880   // SDD support plate, SSD side (Mounting Bracket): a TubeSeg
2881   TGeoTubeSeg *bracketshape = new TGeoTubeSeg(kBracketRmin, kBracketRmax,
2882                             kBracketHalfLength, -kBracketPhi/2, kBracketPhi/2);
2883
2884
2885   // We have the shapes: now create the real volumes
2886
2887   TGeoVolume *cfcone = new TGeoVolume("SSDCarbonFiberCone",
2888                                       coneshape,medSSDcf);
2889   cfcone->SetVisibility(kTRUE);
2890   cfcone->SetLineColor(4); // Blue
2891   cfcone->SetLineWidth(1);
2892   cfcone->SetFillColor(cfcone->GetLineColor());
2893   cfcone->SetFillStyle(4000); // 0% transparent
2894
2895   TGeoVolume *cfconeinsert = new TGeoVolume("SSDCarbonFiberConeInsert",
2896                                             coneinsertshape,medSSDste);
2897   cfconeinsert->SetVisibility(kTRUE);
2898   cfconeinsert->SetLineColor(2); // Red
2899   cfconeinsert->SetLineWidth(1);
2900   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2901   cfconeinsert->SetFillStyle(4050); // 50% transparent
2902
2903   TGeoVolume *cfconefoam1 = new TGeoVolume("SSDCarbonFiberConeFoam1",
2904                                             conefoam1shape,medSSDroh);
2905   cfconefoam1->SetVisibility(kTRUE);
2906   cfconefoam1->SetLineColor(3); // Green
2907   cfconefoam1->SetLineWidth(1);
2908   cfconefoam1->SetFillColor(cfconefoam1->GetLineColor());
2909   cfconefoam1->SetFillStyle(4050); // 50% transparent
2910
2911   TGeoVolume *cfconefoam2 = new TGeoVolume("SSDCarbonFiberConeFoam2",
2912                                             conefoam2shape,medSSDroh);
2913   cfconefoam2->SetVisibility(kTRUE);
2914   cfconefoam2->SetLineColor(3); // Green
2915   cfconefoam2->SetLineWidth(1);
2916   cfconefoam2->SetFillColor(cfconefoam2->GetLineColor());
2917   cfconefoam2->SetFillStyle(4050); // 50% transparent
2918
2919   TGeoVolume *coolinghole = new TGeoVolume("SSDCoolingHole",
2920                                            coolingholeshape,medSSDair);
2921   coolinghole->SetVisibility(kTRUE);
2922   coolinghole->SetLineColor(5); // Yellow
2923   coolinghole->SetLineWidth(1);
2924   coolinghole->SetFillColor(coolinghole->GetLineColor());
2925   coolinghole->SetFillStyle(4090); // 90% transparent
2926
2927   TGeoVolume *coolinghole2 = new TGeoVolume("SSDCoolingHole2",
2928                                             coolinghole2shape,medSSDair);
2929   coolinghole2->SetVisibility(kTRUE);
2930   coolinghole2->SetLineColor(5); // Yellow
2931   coolinghole2->SetLineWidth(1);
2932   coolinghole2->SetFillColor(coolinghole2->GetLineColor());
2933   coolinghole2->SetFillStyle(4090); // 90% transparent
2934
2935   TGeoVolume *coolinghole3 = new TGeoVolume("SSDCoolingHole3",
2936                                             coolinghole3shape,medSSDair);
2937   coolinghole3->SetVisibility(kTRUE);
2938   coolinghole3->SetLineColor(5); // Yellow
2939   coolinghole3->SetLineWidth(1);
2940   coolinghole3->SetFillColor(coolinghole3->GetLineColor());
2941   coolinghole3->SetFillStyle(4090); // 90% transparent
2942
2943   TGeoVolume *mountinghole = new TGeoVolume("SSDMountingHole",
2944                                             mountingholeshape,medSSDair);
2945   mountinghole->SetVisibility(kTRUE);
2946   mountinghole->SetLineColor(5); // Yellow
2947   mountinghole->SetLineWidth(1);
2948   mountinghole->SetFillColor(mountinghole->GetLineColor());
2949   mountinghole->SetFillStyle(4090); // 90% transparent
2950
2951   TGeoVolume *mountinghole2 = new TGeoVolume("SSDMountingHole2",
2952                                              mountinghole2shape,medSSDair);
2953   mountinghole2->SetVisibility(kTRUE);
2954   mountinghole2->SetLineColor(5); // Yellow
2955   mountinghole2->SetLineWidth(1);
2956   mountinghole2->SetFillColor(mountinghole2->GetLineColor());
2957   mountinghole2->SetFillStyle(4090); // 90% transparent
2958
2959   TGeoVolume *mountinghole3 = new TGeoVolume("SSDMountingHole3",
2960                                              mountinghole3shape,medSSDair);
2961   mountinghole3->SetVisibility(kTRUE);
2962   mountinghole3->SetLineColor(5); // Yellow
2963   mountinghole3->SetLineWidth(1);
2964   mountinghole3->SetFillColor(mountinghole3->GetLineColor());
2965   mountinghole3->SetFillStyle(4090); // 90% transparent
2966
2967   TGeoVolume *wing = new TGeoVolume("SSDWing",wingshape,medSSDcf);
2968   wing->SetVisibility(kTRUE);
2969   wing->SetLineColor(4); // Blue
2970   wing->SetLineWidth(1);
2971   wing->SetFillColor(wing->GetLineColor());
2972   wing->SetFillStyle(4000); // 0% transparent
2973
2974   TGeoVolume *cablehole = new TGeoVolume("SSDCableHole",
2975                                          cableholeshape,medSSDair);
2976   cablehole->SetVisibility(kTRUE);
2977   cablehole->SetLineColor(5); // Yellow
2978   cablehole->SetLineWidth(1);
2979   cablehole->SetFillColor(cablehole->GetLineColor());
2980   cablehole->SetFillStyle(4090); // 90% transparent
2981
2982   TGeoVolume *winginsert = new TGeoVolume("SSDWingInsert",
2983                                           winginsertshape,medSSDste);
2984   winginsert->SetVisibility(kTRUE);
2985   winginsert->SetLineColor(2); // Red
2986   winginsert->SetLineWidth(1);
2987   winginsert->SetFillColor(winginsert->GetLineColor());
2988   winginsert->SetFillStyle(4050); // 50% transparent
2989
2990   TGeoVolume *bracket = new TGeoVolume("SSDMountingBracket",
2991                                        bracketshape,medSSDal);
2992   bracket->SetVisibility(kTRUE);
2993   bracket->SetLineColor(6); // Purple
2994   bracket->SetLineWidth(1);
2995   bracket->SetFillColor(bracket->GetLineColor());
2996   bracket->SetFillStyle(4000); // 0% transparent
2997
2998   // Mount up a cone
2999   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
3000     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
3001     cfconefoam2->AddNode(mountinghole,i+1, new TGeoRotation("", phiH, 0, 0));
3002   }
3003
3004   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
3005     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
3006     cfconeinsert->AddNodeOverlap(coolinghole,i+1, new TGeoRotation("", phiH, 0, 0));
3007   }
3008
3009   cfconeinsert->AddNode(cfconefoam1,1,0);
3010   cfconeinsert->AddNode(cfconefoam2,1,0);
3011
3012   cfcone->AddNode(cfconeinsert,1,0);
3013
3014   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
3015     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
3016     cfcone->AddNode(coolinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
3017     cfcone->AddNode(coolinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
3018     cfcone->AddNodeOverlap(cablehole,i+1, new TGeoRotation("", phiH, 0, 0));
3019   }
3020
3021   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
3022     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
3023     cfcone->AddNode(mountinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
3024     cfcone->AddNode(mountinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
3025   }
3026
3027   wing->AddNode(winginsert,1,0);
3028
3029   // Add all volumes in the Cone assembly
3030   vC->AddNode(cfcone,1,new TGeoTranslation(0,0,-kConeZPosition));
3031
3032   for (Int_t i=0; i<4; i++) {
3033     Double_t thetaW = kThetaWing + 90.*i + angleWideWing/2.;
3034     vC->AddNode(wing, i+1, new TGeoCombiTrans(0, 0, -kConeZPosition+kWingHalfThick,
3035                            new TGeoRotation("",thetaW,180,0)));
3036   }
3037
3038   Double_t zBracket = kConeZPosition - coneshape->GetZ(9) +
3039                       2*bracketshape->GetDz();
3040   for (Int_t i=0; i<3; i++) {
3041     Double_t thetaB = 60 + 120.*i;
3042     vC->AddNode(bracket, i+1, new TGeoCombiTrans(0, 0, -zBracket,
3043                               new TGeoRotation("",thetaB,0,0)));
3044   }
3045
3046   // Finally put everything in the mother volume
3047   moth->AddNode(cfcylinder,1,0);
3048
3049   moth->AddNode(vC, 1, 0 );
3050   moth->AddNode(vC, 2, new TGeoRotation("",180, 180, 0) );
3051
3052   // Some debugging if requested
3053   if(GetDebug(1)){
3054     vC->PrintNodes();
3055     vC->InspectShape();
3056   }
3057
3058   return;
3059 }
3060
3061 //______________________________________________________________________
3062 void AliITSv11GeometrySupport::ServicesCableSupport(TGeoVolume *moth,
3063                                                     TGeoManager *mgr){
3064 //
3065 // Creates the cable trays which are outside the ITS support cones
3066 // but still inside the TPC
3067 // This is now a stearing routine, the actual work is done by three
3068 // specialized methods to avoid a really huge unique method
3069 //
3070 // Input:
3071 //         moth : the TGeoVolume owing the volume structure
3072 //         mgr  : the GeoManager (default gGeoManager)
3073 // Output:
3074 //
3075 // Created:      15 Nov 2009  Mario Sitta
3076 //
3077
3078   TraySupportsSideA(moth, mgr);
3079
3080   ServicesCableSupportSPD(moth, mgr);
3081   ServicesCableSupportSDD(moth, mgr);
3082   ServicesCableSupportSSD(moth, mgr);
3083
3084   return;
3085 }
3086
3087 //______________________________________________________________________
3088 void AliITSv11GeometrySupport::TraySupportsSideA(TGeoVolume *moth,
3089                                            const TGeoManager *mgr){
3090 //
3091 // Creates the structure supporting the ITS cable trays on Side A
3092 //
3093 // Input:
3094 //         moth : the TGeoVolume owing the volume structure
3095 //         mgr  : the GeoManager (default gGeoManager)
3096 // Output:
3097 //
3098 // Created:      14 Dec 2009  Mario Sitta
3099 // Updated:      26 Feb 2010  Mario Sitta
3100 //
3101 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
3102 // drawings and other (oral) information given by F.Tosello
3103 //
3104
3105   // Dimensions and positions of the A-Side Cable Tray Support Ring
3106   // (0872/G/A/01)
3107   const Double_t kSuppRingYTrans      =  110.00 *fgkmm;
3108   const Double_t kSuppRingZTrans      =(1011.00+435.00) *fgkmm;
3109   const Double_t kSuppForwYTrans      =  185.00 *fgkmm;
3110
3111   const Double_t kExtSuppRingSpace1   =   33.00 *fgkmm;
3112   const Double_t kExtSuppRingSpace2   =   45.00 *fgkmm;
3113   const Double_t kExtSuppRingSpcAbov  =   30.00 *fgkmm;
3114   const Double_t kExtSuppRingBase     =  491.50 *fgkmm;
3115   const Double_t kExtSuppRingInward   =   35.00 *fgkmm;
3116   const Double_t kExtSuppRingRmax     =  540.00 *fgkmm;
3117   const Double_t kExtSuppRingRint1    =  465.00 *fgkmm;
3118   const Double_t kExtSuppRingRint2    =  467.00 *fgkmm;
3119   const Double_t kExtSuppRingInnerHi  =  450.00 *fgkmm;
3120   const Double_t kExtSuppRingInWide   =  100.00 *fgkmm;
3121   const Double_t kExtSuppRingR7       =    7.00 *fgkmm;
3122   const Double_t kExtSuppRingR5       =    5.00 *fgkmm;
3123   const Double_t kExtSuppRingThick    =   20.00 *fgkmm;
3124
3125   const Double_t kExtSuppRingSpcAng   =   10.50 *TMath::DegToRad();
3126   const Double_t kExtSuppRingPartPhi  =   15.00 *TMath::DegToRad();
3127   const Double_t kExtSuppRingIntAng   =    7.00 *TMath::DegToRad();
3128   const Double_t kExtSuppRingBaseAng  =   75.00 *TMath::DegToRad();
3129   const Double_t kExtSuppRingR7Ang    =  100.00 *TMath::DegToRad(); // Guessed
3130
3131   const Int_t    kExtSuppRingNPtsArc  =   10; // N.points to approximate arc
3132
3133   const Double_t kIntSuppRingThick1   =   15.00 *fgkmm;
3134   const Double_t kIntSuppRingThick2   =   13.00 *fgkmm;
3135   const Double_t kIntSuppRingInward   =   24.00 *fgkmm;
3136   const Double_t kIntSuppRingThick    =   20.00 *fgkmm;
3137
3138   const Double_t kSuppCylHeight       =  340.00 *fgkmm;
3139   const Double_t kSuppCylRint         =  475.00 *fgkmm;
3140   const Double_t kSuppCylRext         =  478.00 *fgkmm;
3141   const Double_t kSuppCylDispl        =  137.70 *fgkmm;
3142
3143   const Double_t kSuppSpacerHeight    =   30.00 *fgkmm;
3144   const Double_t kSuppSpacerThick     =   10.00 *fgkmm;
3145
3146   const Double_t kSuppSpacerAngle     =   15.00;  // Degrees
3147
3148   const Double_t kSuppForwRingRint1   =  500.00 *fgkmm;
3149   const Double_t kSuppForwRingRint2   =  540.00 *fgkmm;
3150   const Double_t kSuppForwRingRext    =  560.00 *fgkmm;
3151   const Double_t kSuppForwRingThikAll =   50.00 *fgkmm;
3152   const Double_t kSuppForwRingThikInt =   20.00 *fgkmm;
3153
3154   // (0872/G/B/01)
3155   const Double_t kSuppForwConeRmin    =  558.00 *fgkmm;
3156   const Double_t kSuppForwConeRmax    =  681.00 *fgkmm;
3157   const Double_t kSuppForwConeLen1    =  318.00 *fgkmm;
3158   const Double_t kSuppForwConeLen2    =  662.00 *fgkmm;
3159   const Double_t kSuppForwConeThick   =    3.00 *fgkmm;
3160
3161   const Double_t kSuppBackRingPlacTop =   90.00 *fgkmm;
3162   const Double_t kSuppBackRingPlacSid =   50.00 *fgkmm;
3163   const Double_t kSuppBackRingHeight  =  760.00 *fgkmm;
3164   const Double_t kSuppBackRingRext    =  760.00 *fgkmm;
3165   const Double_t kSuppBackRingRint    =  685.00 *fgkmm;
3166 //  const Double_t kSuppBackRingRint2   =  675.00 *fgkmm;
3167   const Double_t kSuppBackRingR10     =   10.00 *fgkmm;
3168   const Double_t kSuppBackRingBase    =  739.00 *fgkmm;
3169   const Double_t kSuppBackRingThikAll =   50.00 *fgkmm;
3170   const Double_t kSuppBackRingThick1  =   20.00 *fgkmm;
3171   const Double_t kSuppBackRingThick2  =   20.00 *fgkmm;
3172
3173 //  const Double_t kSuppBackRingPlacAng =   10.00 *TMath::DegToRad();
3174   const Double_t kSuppBackRingPlacAng =   10.25 *TMath::DegToRad();//Fix ovlp.
3175   const Double_t kSuppBackRing2ndAng1 =   78.40 *TMath::DegToRad();
3176   const Double_t kSuppBackRing2ndAng2 =   45.00 *TMath::DegToRad();
3177
3178   const Int_t    kSuppBackRingNPtsArc =   10; // N.points to approximate arc
3179
3180   // (0872/G/C/01)
3181   const Double_t kRearSuppZTransGlob  =(1011.00+9315.00-6040.00) *fgkmm;
3182   const Double_t kBackRodZTrans       = 2420.00 *fgkmm;
3183
3184   const Double_t kBackRodLength       = 1160.00 *fgkmm;
3185   const Double_t kBackRodThickLen     =   20.00 *fgkmm;
3186   const Double_t kBackRodDiameter     =   20.00 *fgkmm;
3187
3188   const Double_t kSuppRearRingRint    =  360.00 *fgkmm;
3189   const Double_t kSuppRearRingRext1   =  410.00 *fgkmm;
3190   const Double_t kSuppRearRingRext2   =  414.00 *fgkmm;
3191   const Double_t kSuppRearRingHeight  =  397.00 *fgkmm;
3192   const Double_t kSuppRearRingTopWide =  111.87 *fgkmm;
3193   const Double_t kSuppRearRingBase    =  451.50 *fgkmm;
3194   const Double_t kSuppRearRingBaseHi  =   58.00 *fgkmm;
3195   const Double_t kSuppRearRingSideHi  =   52.00 *fgkmm;
3196   const Double_t kSuppRearRingInside  =   40.00 *fgkmm;
3197   const Double_t kSuppRearRingInsideHi=   12.00 *fgkmm;
3198   const Double_t kSuppRearRingThick   =   20.00 *fgkmm;
3199   const Double_t kSuppRearRingXRodHole=  441.50 *fgkmm;
3200   const Double_t kSuppRearRingYRodHole=   42.00 *fgkmm;
3201
3202   const Double_t kSuppRearRing1stAng  =   22.00 *TMath::DegToRad();
3203   const Double_t kSuppRearRingStepAng =   15.00 *TMath::DegToRad();
3204
3205   const Int_t    kSuppRearRingNPtsArc =   10; // N.points to approximate arc
3206
3207
3208   // Local variables
3209   Double_t xprof[2*(15+kExtSuppRingNPtsArc)],yprof[2*(15+kExtSuppRingNPtsArc)];
3210   Double_t slp1, slp2, phi, xm, ym;
3211   Double_t xloc, yloc, zloc, rmin, rmax, deltaR;
3212   Int_t npoints;
3213
3214
3215   // The whole support as an assembly
3216   TGeoVolumeAssembly *trayASuppStruct = new TGeoVolumeAssembly("ITSsuppSideAStructure");
3217   
3218
3219   // First create all needed shapes
3220
3221   // The External Ring (part of 0872/G/A/01): a really complex Xtru
3222   TGeoXtru *extSuppRing = new TGeoXtru(2);
3223
3224   // First the upper notch...
3225   xprof[ 0] = kExtSuppRingSpace1;
3226   yprof[ 0] = kExtSuppRingInnerHi + kExtSuppRingSpcAbov;
3227
3228   slp1 = TMath::Tan(TMath::Pi()/2 - kExtSuppRingSpcAng);
3229   IntersectCircle(slp1, xprof[0], yprof[0], kExtSuppRingRmax, 0., 0.,
3230                   xprof[5], yprof[5], xm, ym); // Ignore dummy xm,ym
3231
3232   xprof[ 4] = xprof[5];
3233   yprof[ 4] = yprof[5] - kExtSuppRingR5/TMath::Tan(kExtSuppRingSpcAng);
3234   xprof[ 3] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/6));
3235   yprof[ 3] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/6));
3236   xprof[ 2] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/3));
3237   yprof[ 2] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/3));
3238   xprof[ 1] = xprof[4] - kExtSuppRingR5;
3239   yprof[ 1] = yprof[4] - kExtSuppRingR5;
3240
3241   Int_t indx = 5+kExtSuppRingNPtsArc;
3242   // ...then the external arc, approximated with segments,...
3243   xprof[indx] = kExtSuppRingBase;
3244   yprof[indx] = TMath::Sqrt(kExtSuppRingRmax*kExtSuppRingRmax -
3245                             kExtSuppRingBase*kExtSuppRingBase);
3246   Double_t alphamin = TMath::ASin(kExtSuppRingSpace2/kExtSuppRingRmax);
3247   Double_t alphamax = TMath::Pi()/2 -
3248                     TMath::ASin(yprof[5+kExtSuppRingNPtsArc]/kExtSuppRingRmax);
3249
3250   for (Int_t jp = 1; jp < kExtSuppRingNPtsArc; jp++) {
3251     Double_t alpha = jp*(alphamax-alphamin)/kExtSuppRingNPtsArc;
3252     xprof[5+jp] = kExtSuppRingRmax*TMath::Sin(alpha);
3253     yprof[5+jp] = kExtSuppRingRmax*TMath::Cos(alpha);
3254   }
3255   // ...and finally the interior profile
3256   xprof[indx+1] = kExtSuppRingBase;
3257   yprof[indx+1] = kSuppRingYTrans;
3258   xprof[indx+2] = xprof[indx+1] - kExtSuppRingInward;
3259   yprof[indx+2] = yprof[indx+1];
3260
3261   phi  = TMath::Pi()/2 - 4*kExtSuppRingPartPhi - kExtSuppRingIntAng;
3262   slp1 = TMath::Tan(TMath::Pi() - kExtSuppRingBaseAng);
3263   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3264   xm   = kExtSuppRingRint2*TMath::Cos(phi);
3265   ym   = kExtSuppRingRint2*TMath::Sin(phi);
3266   IntersectLines(slp1, xprof[indx+2], yprof[indx+2], slp2, xm, ym,
3267                  xprof[indx+3], yprof[indx+3]);