Four overlaps fixed (M. Sitta)
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySupport.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // This class Defines the Geometry for the ITS services and support cones
17 // outside of the ceneteral volume (except for the Ceneteral support 
18 // cylinders. Other classes define the rest of the ITS. Specificaly the ITS
19 // The SSD support cone,SSD Support centeral cylinder, SDD support cone,
20 // The SDD cupport centeral cylinder, the SPD Thermal Sheald, The supports
21 // and cable trays on both the RB26 (muon dump) and RB24 sides, and all of
22 // the cabling from the ladders/stave ends out past the TPC. 
23
24 /* $Id$ */
25 // General Root includes
26 #include <TMath.h>
27 // Root Geometry includes
28 //#include <AliLog.h>
29 #include <TGeoManager.h>
30 #include <TGeoVolume.h>
31 #include <TGeoPcon.h>
32 #include <TGeoCone.h>
33 #include <TGeoTube.h> // contaings TGeoTubeSeg
34 #include <TGeoArb8.h>
35 #include <TGeoXtru.h>
36 #include <TGeoCompositeShape.h>
37 #include <TGeoMatrix.h>
38 #include "AliITSv11GeometrySupport.h"
39
40 ClassImp(AliITSv11GeometrySupport)
41
42 #define SQ(A) (A)*(A)
43
44 //______________________________________________________________________
45 void AliITSv11GeometrySupport::SPDCone(TGeoVolume *moth,TGeoManager *mgr)
46 {
47 //
48 // Creates the SPD thermal shield as a volume assembly
49 // and adds it to the mother volume
50 // (this is actually a merge of the previous SPDThermalSheald method
51 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06 and the
52 // CreateSPDThermalShield method of AliITSv11Hybrid)
53 //
54 // Input:
55 //         moth : the TGeoVolume owing the volume structure
56 //         mgr  : the GeoManager (default gGeoManager)
57 // Output:
58 //
59 // Created:         ???          ???
60 // Updated:      11 Dec 2007  Mario Sitta
61 //
62 // Technical data are taken from:  ALICE-Thermal Screen "Cone transition"
63 // (thermal-screen1_a3.ps), "Cylinder" (thermal-screen2_a3.ps), "Half
64 // assembly" (thermal-screen3_a3.ps), "Flange" (thermal-screen4_a3.ps)
65
66
67   // Dimensions of the Central shield
68   const Double_t kHalfLengthCentral  = 405.*fgkmm;
69   const Double_t kThicknessCentral   = 0.4*fgkmm;
70   const Double_t kInnerRadiusCentral = 8.1475*fgkcm;
71   const Double_t kOuterRadiusCentral = 9.9255*fgkcm;
72   const Double_t kInnerACentral = 3.1674*fgkcm;
73   const Double_t kInnerBCentral = 2.023 *fgkcm;
74   const Double_t kOuterACentral = 2.4374*fgkcm;
75   const Double_t kOuterBCentral = 3.8162*fgkcm;
76   // Dimensions of the EndCap shield
77   const Double_t kHalfLengthEndCap  = 25.*fgkmm;
78   const Double_t kThicknessEndCap   = 2.0*fgkmm;
79   const Double_t kInnerRadiusEndCap = 8.0775*fgkcm;
80   const Double_t kOuterRadiusEndCap = 9.9955*fgkcm;
81   const Double_t kInnerAEndCap = 3.1453*fgkcm;
82   const Double_t kInnerBEndCap = 2.0009*fgkcm;
83   const Double_t kOuterAEndCap = 2.4596*fgkcm;
84   const Double_t kOuterBEndCap = 3.8384*fgkcm;
85   // Dimensions of the Cone shield
86   const Double_t kHalfLengthCone  = 145.*fgkmm;
87   const Double_t kThicknessCone   = 0.3*fgkmm;
88   const Double_t kInnerRadialCone = 37.3*fgkcm;
89   const Double_t kOuterRadialCone = 39.0*fgkcm;
90   const Double_t kInnerACone = 14.2344*fgkcm;
91   //  const Double_t kInnerBCone =  9.0915*fgkcm;
92   const Double_t kOuterACone =  9.5058*fgkcm;
93   //  const Double_t kOuterBCone = 14.8831*fgkcm;
94   // Dimensions of the Flange's Ring and Wing
95   const Double_t kHalfLengthRing  = 7.5*fgkmm;
96   const Double_t kThicknessRing   = 0.3*fgkmm;
97   const Double_t kInnerRadiusRing = 37.3*fgkcm;
98   const Double_t kOuterRadiusRing = 42.0*fgkcm;
99   const Double_t kOuterRadiusWing = 49.25*fgkcm;
100   const Double_t kWideWing  = 6.0*fgkcm;
101   const Double_t kThetaWing = 45.0;
102   // Common data
103   const Double_t kTheta = 36.0*TMath::DegToRad();
104   const Double_t kThicknessOmega = 0.3*fgkmm;
105
106   // Local variables
107   Double_t x, y;
108   Double_t xshld[24], yshld[24];
109   Double_t xair[24] , yair[24];
110   Double_t xomega[48], yomega[48];
111   //  Double_t *xyarb8;
112
113   // The entire shield is made up of two half central shields
114   // symmetric with respect to the XZ plane, four half end cap
115   // shields, again symmetric with respect to the XZ plane, and four
116   // half cones, symmetric with respect to the XZ plane too.
117
118   TGeoVolumeAssembly *vM = new TGeoVolumeAssembly("ITSspdThermalShield");
119
120   // The central half shield: a half tube of carbon fiber,
121   // a similar but proportionally smaller half tube of air inside it,
122   // and a Omega-shaped carbon fiber insert inside the air.
123   // They are all XTru shapes
124
125   TGeoXtru *centralshape = new TGeoXtru(2);
126
127   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
128                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
129                         kTheta,xshld,yshld);
130
131   centralshape->DefinePolygon(24,xshld,yshld);
132   centralshape->DefineSection(0,-kHalfLengthCentral);
133   centralshape->DefineSection(1, kHalfLengthCentral);
134
135   // Now rescale to get the air volume dimensions
136     InsidePoint(xshld[23], yshld[23],
137                 xshld[ 0], yshld[ 0],
138                 xshld[ 1], yshld[ 1], kThicknessCentral,
139                 xair[0], yair[0]);
140   for (Int_t i=1; i<23; i++) {
141     InsidePoint(xshld[i-1], yshld[i-1],
142                 xshld[ i ], yshld[ i ],
143                 xshld[i+1], yshld[i+1], kThicknessCentral,
144                 xair[i], yair[i]);
145   }
146     InsidePoint(xshld[22], yshld[22],
147                 xshld[23], yshld[23],
148                 xshld[ 0], yshld[ 0], kThicknessCentral,
149                 xair[23], yair[23]);
150
151   // Create the air shape
152   TGeoXtru *centralairshape = new TGeoXtru(2);
153
154   centralairshape->DefinePolygon(24,xair,yair);
155   centralairshape->DefineSection(0,-kHalfLengthCentral);
156   centralairshape->DefineSection(1, kHalfLengthCentral);
157
158   // Create the Omega insert
159   TGeoXtru *centralomegashape = new TGeoXtru(2);
160
161   CreateSPDOmegaShape(xair,yair,kTheta,kThicknessOmega,xomega,yomega);
162
163   centralomegashape->DefinePolygon(48,xomega,yomega);
164   centralomegashape->DefineSection(0,-kHalfLengthCentral);
165   centralomegashape->DefineSection(1, kHalfLengthCentral);
166
167   // The end cap half shield: a half tube of carbon fiber,
168   // a similar but proportionally smaller half tube of air inside it,
169   // and a Omega-shaped carbon fiber insert inside the air.
170   // They are all XTru shapes
171
172   TGeoXtru *endcapshape = new TGeoXtru(2);
173
174   CreateSPDThermalShape(kInnerAEndCap,kInnerBEndCap,kInnerRadiusEndCap,
175                         kOuterAEndCap,kOuterBEndCap,kOuterRadiusEndCap,
176                         kTheta,xshld,yshld);
177
178   endcapshape->DefinePolygon(24,xshld,yshld);
179   endcapshape->DefineSection(0,-kHalfLengthEndCap);
180   endcapshape->DefineSection(1, kHalfLengthEndCap);
181
182   // Now rescale to get the air volume dimensions
183     InsidePoint(xshld[23], yshld[23],
184                 xshld[ 0], yshld[ 0],
185                 xshld[ 1], yshld[ 1], kThicknessEndCap,
186                 xair[0], yair[0]);
187   for (Int_t i=1; i<23; i++) {
188     InsidePoint(xshld[i-1], yshld[i-1],
189                 xshld[ i ], yshld[ i ],
190                 xshld[i+1], yshld[i+1], kThicknessEndCap,
191                 xair[i], yair[i]);
192   }
193     InsidePoint(xshld[22], yshld[22],
194                 xshld[23], yshld[23],
195                 xshld[ 0], yshld[ 0], kThicknessEndCap,
196                 xair[23], yair[23]);
197
198   // Create the air shape
199   TGeoXtru *endcapairshape = new TGeoXtru(2);
200
201   endcapairshape->DefinePolygon(24,xair,yair);
202   endcapairshape->DefineSection(0,-kHalfLengthEndCap);
203   endcapairshape->DefineSection(1, kHalfLengthEndCap);
204
205   // Create the Omega insert
206   TGeoXtru *endcapomegashape = new TGeoXtru(2);
207
208   CreateSPDOmegaShape(xair,yair,kTheta,kThicknessOmega,xomega,yomega);
209
210   endcapomegashape->DefinePolygon(48,xomega,yomega);
211   endcapomegashape->DefineSection(0,-kHalfLengthEndCap);
212   endcapomegashape->DefineSection(1, kHalfLengthEndCap);
213
214   // The cone half shield is more complex since there is no basic
215   // TGeo shape to describe it correctly. So it is made of a series
216   // of TGeoArb8 shapes filled with air, which all together make up the
217   // the cone AND its internal insert. Part of the following code is
218   // adapted from SPDThermalSheald method.
219
220   // Filled portions
221   TGeoArb8 *sC1 = new TGeoArb8(kHalfLengthCone);
222   TGeoArb8 *sC2 = new TGeoArb8(kHalfLengthCone);
223
224   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
225                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
226                         kTheta,xshld,yshld);
227
228   sC1->SetVertex(0,xshld[12],yshld[12]);
229   sC1->SetVertex(1,xshld[11],yshld[11]);
230   sC1->SetVertex(2,xshld[ 0],yshld[ 0]);
231   sC1->SetVertex(3,xshld[23],yshld[23]);
232
233   sC2->SetVertex(0,xshld[11],yshld[11]);
234   sC2->SetVertex(1,xshld[10],yshld[10]);
235   sC2->SetVertex(2,xshld[ 1],yshld[ 1]);
236   sC2->SetVertex(3,xshld[ 0],yshld[ 0]);
237
238   // Drawings give only the radius, convert it to the apothegm
239   Double_t kInnerRadiusCone = TMath::Sqrt(kInnerRadialCone*kInnerRadialCone
240                                           - 0.25*kInnerACone*kInnerACone);
241   Double_t kOuterRadiusCone = TMath::Sqrt(kOuterRadialCone*kOuterRadialCone
242                                           - 0.25*kOuterACone*kOuterACone);
243
244   Double_t xco[4], yco[4], xci[4], yci[4];
245
246   for (Int_t i=0; i<2; i++) {
247     Double_t th = i*kTheta*TMath::RadToDeg();
248     xco[2*i  ] = kOuterRadiusCone*SinD(th) - 0.5*kOuterACone*CosD(th);
249     yco[2*i  ] = kOuterRadiusCone*CosD(th) + 0.5*kOuterACone*SinD(th);
250     xci[2*i  ] = kInnerRadiusCone*SinD(th) - 0.5*kInnerACone*CosD(th);
251     yci[2*i  ] = kInnerRadiusCone*CosD(th) + 0.5*kInnerACone*SinD(th);
252     xco[2*i+1] = kOuterRadiusCone*SinD(th) + 0.5*kOuterACone*CosD(th);
253     yco[2*i+1] = kOuterRadiusCone*CosD(th) - 0.5*kOuterACone*SinD(th);
254     xci[2*i+1] = kInnerRadiusCone*SinD(th) + 0.5*kInnerACone*CosD(th);
255     yci[2*i+1] = kInnerRadiusCone*CosD(th) - 0.5*kInnerACone*SinD(th);
256   }
257
258   sC1->SetVertex(4,xco[0],yco[0]);
259   sC1->SetVertex(5,xco[1],yco[1]);
260   sC1->SetVertex(6,xci[1],yci[1]);
261   sC1->SetVertex(7,xci[0],yci[0]);
262
263   sC2->SetVertex(4,xco[1],yco[1]);
264   sC2->SetVertex(5,xco[2],yco[2]);
265   sC2->SetVertex(6,xci[2],yci[2]);
266   sC2->SetVertex(7,xci[1],yci[1]);
267
268   // Air holes
269   TGeoArb8 *sCh1 = new TGeoArb8(kHalfLengthCone);
270   TGeoArb8 *sCh2 = new TGeoArb8(kHalfLengthCone);
271
272   for(Int_t i=0; i<4; i++){
273     InsidePoint(sC1->GetVertices()[((i+3)%4)*2+0],
274                 sC1->GetVertices()[((i+3)%4)*2+1],
275                 sC1->GetVertices()[i*2+0],
276                 sC1->GetVertices()[i*2+1],
277                 sC1->GetVertices()[((i+1)%4)*2+0],
278                 sC1->GetVertices()[((i+1)%4)*2+1],-kThicknessCone,x,y);
279     sCh1->SetVertex(i,x,y);
280
281     InsidePoint(sC1->GetVertices()[((i+3)%4 +4)*2+0],
282                 sC1->GetVertices()[((i+3)%4 +4)*2+1],
283                 sC1->GetVertices()[(i+4)*2+0],
284                 sC1->GetVertices()[(i+4)*2+1],
285                 sC1->GetVertices()[((i+1)%4 +4)*2+0],
286                 sC1->GetVertices()[((i+1)%4 +4)*2+1],-kThicknessCone,x,y);
287     sCh1->SetVertex(i+4,x,y);
288
289     InsidePoint(sC2->GetVertices()[((i+3)%4)*2+0],
290                 sC2->GetVertices()[((i+3)%4)*2+1],
291                 sC2->GetVertices()[i*2+0],
292                 sC2->GetVertices()[i*2+1],
293                 sC2->GetVertices()[((i+1)%4)*2+0],
294                 sC2->GetVertices()[((i+1)%4)*2+1],-kThicknessCone,x,y);
295     sCh2->SetVertex(i,x,y);
296
297     InsidePoint(sC2->GetVertices()[((i+3)%4 +4)*2+0],
298                 sC2->GetVertices()[((i+3)%4 +4)*2+1],
299                 sC2->GetVertices()[(i+4)*2+0],
300                 sC2->GetVertices()[(i+4)*2+1],
301                 sC2->GetVertices()[((i+1)%4 +4)*2+0],
302                 sC2->GetVertices()[((i+1)%4 +4)*2+1],-kThicknessCone,x,y);
303     sCh2->SetVertex(i+4,x,y);
304   }
305
306   // Finally the carbon fiber Ring with its Wings and their
307   // stesalite inserts. They are Tube and TubeSeg shapes
308
309   TGeoTube *ringshape = new TGeoTube(kInnerRadiusRing,kOuterRadiusRing,
310                                      kHalfLengthRing);
311
312   TGeoTube *ringinsertshape = new TGeoTube(kInnerRadiusRing+kThicknessRing,
313                                            kOuterRadiusRing-kThicknessRing,
314                                            kHalfLengthRing-kThicknessRing);
315
316   Double_t angleWideWing, angleWideWingThickness;
317   angleWideWing = (kWideWing/kOuterRadiusWing)*TMath::RadToDeg();
318   angleWideWingThickness = (kThicknessRing/kOuterRadiusWing)*TMath::RadToDeg();
319
320   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kOuterRadiusRing,kOuterRadiusWing,
321                                            kHalfLengthRing, 0, angleWideWing);
322
323   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kOuterRadiusRing,
324              kOuterRadiusWing-kThicknessRing, kHalfLengthRing-kThicknessRing,
325              angleWideWingThickness, angleWideWing-angleWideWingThickness);
326
327
328   // We have the shapes: now create the real volumes
329
330   TGeoMedium *medSPDcf  = mgr->GetMedium("ITS_SPD shield$");
331   TGeoMedium *medSPDair = mgr->GetMedium("ITS_SPD AIR$");
332   TGeoMedium *medSPDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
333
334   TGeoVolume *centralshield = new TGeoVolume("SPDcentralshield",
335                                              centralshape,medSPDcf);
336   centralshield->SetVisibility(kTRUE);
337   centralshield->SetLineColor(7);
338   centralshield->SetLineWidth(1);
339
340   TGeoVolume *centralairshield = new TGeoVolume("SPDcentralairshield",
341                                                 centralairshape,medSPDair);
342   centralairshield->SetVisibility(kTRUE);
343   centralairshield->SetLineColor(5); // Yellow
344   centralairshield->SetLineWidth(1);
345   centralairshield->SetFillColor(centralairshield->GetLineColor());
346   centralairshield->SetFillStyle(4090); // 90% transparent
347
348   TGeoVolume *centralomega = new TGeoVolume("SPDcentralomega",
349                                              centralomegashape,medSPDcf);
350   centralomega->SetVisibility(kTRUE);
351   centralomega->SetLineColor(7);
352   centralomega->SetLineWidth(1);
353
354   centralairshield->AddNode(centralomega,1,0);
355   centralshield->AddNode(centralairshield,1,0);
356
357   TGeoVolume *endcapshield = new TGeoVolume("SPDendcapshield",
358                                              endcapshape,medSPDcf);
359   endcapshield->SetVisibility(kTRUE);
360   endcapshield->SetLineColor(7);
361   endcapshield->SetLineWidth(1);
362
363   TGeoVolume *endcapairshield = new TGeoVolume("SPDendcapairshield",
364                                                 endcapairshape,medSPDair);
365   endcapairshield->SetVisibility(kTRUE);
366   endcapairshield->SetLineColor(5); // Yellow
367   endcapairshield->SetLineWidth(1);
368   endcapairshield->SetFillColor(endcapairshield->GetLineColor());
369   endcapairshield->SetFillStyle(4090); // 90% transparent
370
371   TGeoVolume *endcapomega = new TGeoVolume("SPDendcapomega",
372                                            endcapomegashape,medSPDcf);
373   endcapomega->SetVisibility(kTRUE);
374   endcapomega->SetLineColor(7);
375   endcapomega->SetLineWidth(1);
376
377   endcapairshield->AddNode(endcapomega,1,0);
378   endcapshield->AddNode(endcapairshield,1,0);
379
380   TGeoVolume *vC1 = new TGeoVolume("SPDconeshieldV1",sC1,medSPDcf);
381   vC1->SetVisibility(kTRUE);
382   vC1->SetLineColor(7);
383   vC1->SetLineWidth(1);
384
385   TGeoVolume *vCh1 = new TGeoVolume("SPDconeshieldH1",sCh1,medSPDair);
386
387   vCh1->SetVisibility(kTRUE);
388   vCh1->SetLineColor(5); // Yellow
389   vCh1->SetLineWidth(1);
390   vCh1->SetFillColor(vCh1->GetLineColor());
391   vCh1->SetFillStyle(4090); // 90% transparent
392
393   vC1->AddNode(vCh1,1,0);
394
395   TGeoVolume *vC2 = new TGeoVolume("SPDconeshieldV2",sC2,medSPDcf);
396
397   vC2->SetVisibility(kTRUE);
398   vC2->SetLineColor(7);
399   vC2->SetLineWidth(1);
400
401   TGeoVolume *vCh2 = new TGeoVolume("SPDconeshieldH2",sCh2,medSPDair);
402
403   vCh2->SetVisibility(kTRUE);
404   vCh2->SetLineColor(5); // Yellow
405   vCh2->SetLineWidth(1);
406   vCh2->SetFillColor(vCh2->GetLineColor());
407   vCh2->SetFillStyle(4090); // 90% transparent
408
409   vC2->AddNode(vCh2,1,0);
410
411   TGeoVolume *ring = new TGeoVolume("SPDshieldring",ringshape,medSPDcf);
412   ring->SetVisibility(kTRUE);
413   ring->SetLineColor(7);
414   ring->SetLineWidth(1);
415
416   TGeoVolume *ringinsert = new TGeoVolume("SPDshieldringinsert",
417                                           ringinsertshape,medSPDste);
418   ringinsert->SetVisibility(kTRUE);
419   ringinsert->SetLineColor(3); // Green
420 //  ringinsert->SetLineWidth(1);
421   ringinsert->SetFillColor(ringinsert->GetLineColor());
422   ringinsert->SetFillStyle(4010); // 10% transparent
423
424   ring->AddNode(ringinsert,1,0);
425
426   TGeoVolume *wing = new TGeoVolume("SPDshieldringwing",wingshape,medSPDcf);
427   wing->SetVisibility(kTRUE);
428   wing->SetLineColor(7);
429   wing->SetLineWidth(1);
430
431   TGeoVolume *winginsert = new TGeoVolume("SPDshieldringinsert",
432                                           winginsertshape,medSPDste);
433   winginsert->SetVisibility(kTRUE);
434   winginsert->SetLineColor(3); // Green
435 //  winginsert->SetLineWidth(1);
436   winginsert->SetFillColor(winginsert->GetLineColor());
437   winginsert->SetFillStyle(4010); // 10% transparent
438
439   wing->AddNode(winginsert,1,0);
440
441
442   // Add all volumes in the assembly
443   vM->AddNode(centralshield,1,0);
444   vM->AddNode(centralshield,2,new TGeoRotation("",180,0,0));
445
446   vM->AddNode(endcapshield,1,
447               new TGeoTranslation(0,0, kHalfLengthCentral+kHalfLengthEndCap));
448   vM->AddNode(endcapshield,2,
449               new TGeoTranslation(0,0,-kHalfLengthCentral-kHalfLengthEndCap));
450   vM->AddNode(endcapshield,3,new TGeoCombiTrans(
451               0, 0, kHalfLengthCentral+kHalfLengthEndCap,
452               new TGeoRotation("",180,0,0)     ) );
453   vM->AddNode(endcapshield,4,new TGeoCombiTrans(
454               0, 0,-kHalfLengthCentral-kHalfLengthEndCap,
455               new TGeoRotation("",180,0,0)     ) );
456
457   for (Int_t i=0; i<10; i++) {
458     Double_t thetaC12 = kTheta*TMath::RadToDeg();
459     vM->AddNode(vC1,2*i+1, new TGeoCombiTrans(
460                0, 0,  kHalfLengthCentral+2*kHalfLengthEndCap+kHalfLengthCone,
461                new TGeoRotation("",0,  0,i*thetaC12)   ) );
462     vM->AddNode(vC1,2*i+2, new TGeoCombiTrans(
463                0, 0, -kHalfLengthCentral-2*kHalfLengthEndCap-kHalfLengthCone,
464                new TGeoRotation("",0,180,i*thetaC12)   ) );
465     vM->AddNode(vC2,2*i+1, new TGeoCombiTrans(
466                0, 0,  kHalfLengthCentral+2*kHalfLengthEndCap+kHalfLengthCone,
467                new TGeoRotation("",0,  0,i*thetaC12)   ) );
468     vM->AddNode(vC2,2*i+2, new TGeoCombiTrans(
469                0, 0, -kHalfLengthCentral-2*kHalfLengthEndCap-kHalfLengthCone,
470                new TGeoRotation("",0,180,i*thetaC12)   ) );
471   }
472
473   vM->AddNode(ring,1,new TGeoTranslation(0, 0,
474               kHalfLengthCentral+2*kHalfLengthEndCap+2*kHalfLengthCone
475              +kHalfLengthRing));
476   vM->AddNode(ring,2,new TGeoTranslation(0, 0,
477              -kHalfLengthCentral-2*kHalfLengthEndCap-2*kHalfLengthCone
478              -kHalfLengthRing));
479
480   for (Int_t i=0; i<4; i++) {
481     Double_t thetaW = kThetaWing*(2*i+1);
482     vM->AddNode(wing,2*i+1,new TGeoCombiTrans(0, 0,
483               kHalfLengthCentral+2*kHalfLengthEndCap+2*kHalfLengthCone
484              +kHalfLengthRing, new TGeoRotation("",thetaW,0,0)  ));
485     vM->AddNode(wing,2*i+2,new TGeoCombiTrans(0, 0,
486              -kHalfLengthCentral-2*kHalfLengthEndCap-2*kHalfLengthCone
487              -kHalfLengthRing, new TGeoRotation("",thetaW,0,0)  ));
488   }
489
490   // Some debugging if requested
491   if(GetDebug(1)){
492     vM->PrintNodes();
493     vM->InspectShape();
494   }
495
496   // Finally put the entire shield in the mother volume
497   moth->AddNode(vM,1,0);
498
499   return;
500 }
501
502 //______________________________________________________________________
503 void AliITSv11GeometrySupport::CreateSPDThermalShape(
504      Double_t ina, Double_t inb, Double_t inr,
505      Double_t oua, Double_t oub, Double_t our,
506      Double_t   t, Double_t *x , Double_t *y )
507 {
508 //
509 // Creates the proper sequence of X and Y coordinates to determine
510 // the base XTru polygon for the SPD thermal shapes
511 //
512 // Input:
513 //        ina, inb : inner shape sides
514 //        inr      : inner radius
515 //        oua, oub : outer shape sides
516 //        our      : outer radius
517 //        t        : theta angle
518 //
519 // Output:
520 //        x, y : coordinate vectors [24]
521 //
522 // Created:      14 Nov 2007  Mario Sitta
523 // Updated:      11 Dec 2007  Mario Sitta
524 //
525   Double_t xlocal[6],ylocal[6];
526
527   //Create the first inner quadrant (X > 0)
528   FillSPDXtruShape(ina,inb,inr,t,xlocal,ylocal);
529   for (Int_t i=0; i<6; i++) {
530     x[i] = xlocal[i];
531     y[i] = ylocal[i];
532   }
533
534   // Then reflex on the second quadrant (X < 0)
535   for (Int_t i=0; i<6; i++) {
536     x[23-i] = -x[i];
537     y[23-i] =  y[i];
538   }
539
540   // Now create the first outer quadrant (X > 0)
541   FillSPDXtruShape(oua,oub,our,t,xlocal,ylocal);
542   for (Int_t i=0; i<6; i++) {
543     x[11-i] = xlocal[i];
544     y[11-i] = ylocal[i];
545   }
546
547   // Finally reflex on the second quadrant (X < 0)
548   for (Int_t i=0; i<6; i++) {
549     x[12+i] = -x[11-i];
550     y[12+i] =  y[11-i];
551   }
552
553   return;
554 }
555
556 //______________________________________________________________________
557 void AliITSv11GeometrySupport::CreateSPDOmegaShape(
558                              Double_t *xin, Double_t *yin, Double_t  t,
559                              Double_t    d, Double_t   *x, Double_t *y)
560 {
561 //
562 // Creates the proper sequence of X and Y coordinates to determine
563 // the SPD Omega XTru polygon
564 //
565 // Input:
566 //        xin, yin : coordinates of the air volume
567 //        d        : Omega shape thickness
568 //        t        : theta angle
569 //
570 // Output:
571 //        x, y     : coordinate vectors [48]
572 //
573 // Created:      17 Nov 2007  Mario Sitta
574 // Updated:      11 Dec 2007  Mario Sitta
575 //
576   Double_t xlocal[6],ylocal[6];
577
578   // First determine various parameters
579   Double_t ina = TMath::Sqrt( (xin[23]-xin[0])*(xin[23]-xin[0]) +
580                               (yin[23]-yin[0])*(yin[23]-yin[0]) );
581   Double_t inb = TMath::Sqrt( (xin[ 1]-xin[0])*(xin[ 1]-xin[0]) +
582                               (yin[ 1]-yin[0])*(yin[ 1]-yin[0]) );
583   Double_t inr = yin[0];
584   Double_t oua = TMath::Sqrt( (xin[12]-xin[11])*(xin[12]-xin[11]) +
585                               (yin[12]-yin[11])*(yin[12]-yin[11]) );
586   Double_t oub = TMath::Sqrt( (xin[10]-xin[11])*(xin[10]-xin[11]) +
587                               (yin[10]-yin[11])*(yin[10]-yin[11]) );
588   Double_t our = yin[11];
589
590   //Create the first inner pseudo-quadrant
591   FillSPDXtruShape(ina,inb,inr,t,xlocal,ylocal);
592   x[ 1] = xlocal[0];
593   y[ 1] = ylocal[0];
594
595   x[ 2] = xlocal[1];
596   y[ 2] = ylocal[1];
597
598   x[ 5] = xlocal[2];
599   y[ 5] = ylocal[2];
600
601   x[ 6] = xlocal[3];
602   y[ 6] = ylocal[3];
603
604   x[ 9] = xlocal[4];
605   y[ 9] = ylocal[4];
606
607   x[10] = xlocal[5];
608   y[10] = ylocal[5];
609
610   //Create the first outer pseudo-quadrant
611   FillSPDXtruShape(oua,oub,our,t,xlocal,ylocal);
612   x[23] = xlocal[0];
613   y[23] = ylocal[0];
614
615   x[20] = xlocal[1];
616   y[20] = ylocal[1];
617
618   x[19] = xlocal[2];
619   y[19] = ylocal[2];
620
621   x[16] = xlocal[3];
622   y[16] = ylocal[3];
623
624   x[15] = xlocal[4];
625   y[15] = ylocal[4];
626
627   x[11] = xlocal[5];
628   y[11] = ylocal[5];
629
630   //Create the second inner pseudo-quadrant
631   FillSPDXtruShape(ina+2*d,inb-2*d,inr+d,t,xlocal,ylocal);
632   x[22] = xlocal[0];
633   y[22] = ylocal[0];
634
635   x[21] = xlocal[1];
636   y[21] = ylocal[1];
637
638   x[18] = xlocal[2];
639   y[18] = ylocal[2];
640
641   x[17] = xlocal[3];
642   y[17] = ylocal[3];
643
644   x[14] = xlocal[4];
645   y[14] = ylocal[4];
646
647   x[13] = xlocal[5];
648   y[13] = ylocal[5];
649
650   //Create the second outer pseudo-quadrant
651   FillSPDXtruShape(oua-2*d,oub+2*d,our-d,t,xlocal,ylocal);
652   x[ 0] = xlocal[0];
653   y[ 0] = ylocal[0];
654
655   x[ 3] = xlocal[1];
656   y[ 3] = ylocal[1];
657
658   x[ 4] = xlocal[2];
659   y[ 4] = ylocal[2];
660
661   x[ 7] = xlocal[3];
662   y[ 7] = ylocal[3];
663
664   x[ 8] = xlocal[4];
665   y[ 8] = ylocal[4];
666
667   x[12] = xlocal[5];
668   y[12] = ylocal[5];
669
670   // These need to be fixed explicitly
671   y[10] = yin[5];
672   y[11] = yin[6];
673   x[12] = x[11];
674   y[12] = y[11] + d;
675   x[13] = x[10] + d;
676   y[13] = y[12];
677
678   // Finally reflex on the negative side
679   for (Int_t i=0; i<24; i++) {
680     x[24+i] = -x[23-i];
681     y[24+i] =  y[23-i];
682   }
683
684   // Wow ! We've finished
685   return;
686 }
687
688 //______________________________________________________________________
689 void AliITSv11GeometrySupport::FillSPDXtruShape(Double_t a, Double_t b,
690                                                 Double_t r, Double_t t,
691                                                 Double_t *x, Double_t *y)
692 {
693 //
694 // Creates the partial sequence of X and Y coordinates to determine
695 // the lateral part of the SPD thermal shield
696 //
697 // Input:
698 //        a, b : shape sides
699 //        r    : radius
700 //        t    : theta angle
701 //
702 // Output:
703 //        x, y : coordinate vectors [6]
704 //
705 // Created:      14 Nov 2007  Mario Sitta
706 //
707   x[0] = a/2;
708   y[0] = r;
709
710   x[1] = x[0] + b * TMath::Cos(t/2);
711   y[1] = y[0] - b * TMath::Sin(t/2);
712
713   x[2] = x[1] + a * TMath::Cos(t);
714   y[2] = y[1] - a * TMath::Sin(t);
715
716   x[3] = x[2] + b * TMath::Cos(3*t/2);
717   y[3] = y[2] - b * TMath::Sin(3*t/2);
718
719   x[4] = x[3] + a * TMath::Cos(2*t);
720   y[4] = y[3] - a * TMath::Sin(2*t);
721
722   x[5] = x[4];
723   y[5] = 0.;
724
725   return;
726 }
727
728 //______________________________________________________________________
729 void AliITSv11GeometrySupport::SDDCone(TGeoVolume *moth,TGeoManager *mgr)
730 {
731 //
732 // Creates the SDD support cone and cylinder geometry as a
733 // volume assembly and adds it to the mother volume
734 // (part of this code is taken or anyway inspired to SDDCone method
735 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
736 //
737 // Input:
738 //         moth : the TGeoVolume owing the volume structure
739 //         mgr  : the GeoManager (default gGeoManager)
740 // Output:
741 //
742 // Created:         ???       Bjorn S. Nilsen
743 // Updated:      18 Feb 2008  Mario Sitta
744 //
745 // Technical data are taken from:  "Supporto Generale Settore SDD"
746 // (technical drawings ALR-0816/1-B), "Supporto Globale Settore SDD"
747 // (technical drawings ALR-0816/2A, ALR-0816/2B, ALR-0816/2C, ALR-0816/2D), 
748 // private communication with B. Giraudo
749
750   // Dimensions of the Central cylinder and flanges
751   const Double_t kCylinderHalfLength = (790.0/2)*fgkmm;
752   const Double_t kCylinderInnerR     = (210.0/2)*fgkmm;
753   const Double_t kCylinderOuterR     = (231.0/2)*fgkmm;
754   const Double_t kFlangeHalfLength   = ( 15.0/2)*fgkmm;
755   const Double_t kFlangeInnerR       = (210.5/2)*fgkmm;
756   const Double_t kFlangeOuterR       = (230.5/2)*fgkmm;
757   const Double_t kInsertoHalfLength  =
758                                      kCylinderHalfLength - 2*kFlangeHalfLength;
759 //  const Double_t kCFThickness        = kFlangeInnerR - kCylinderInnerR;
760   const Double_t kBoltDiameter       =       6.0*fgkmm; // M6 screw
761   const Double_t kBoltDepth          =       6.0*fgkmm; // In the flange
762   const Double_t kBoltRadius         = (220.0/2)*fgkmm; // Radius in flange
763   const Double_t kThetaBolt          =      30.0*fgkDegree;
764   const Int_t    kNBolts             = (Int_t)(360.0/kThetaBolt);
765   // Dimensions of the Cone
766   const Double_t kConeROutMin        = (540.0/2)*fgkmm;
767   const Double_t kConeROutMax        = (560.0/2)*fgkmm;
768   const Double_t kConeRCurv          =      10.0*fgkmm; // Radius of curvature
769   const Double_t kConeRinMin         = (210.0/2)*fgkmm;
770   const Double_t kConeRinMax         = (216.0/2)*fgkmm;
771   const Double_t kConeRinCylinder    = (231.0/2)*fgkmm;
772   const Double_t kConeZCylinder      =     192.0*fgkmm;
773   const Double_t kConeZOuterMilled   =      23.0*fgkmm;
774   const Double_t kConeDZin           =      15.0*fgkmm; // ???
775   const Double_t kConeThickness      =      10.0*fgkmm; // Rohacell + Carb.Fib.
776   const Double_t kConeTheta          =      45.0*fgkDegree; // SDD cone angle
777   const Double_t kSinConeTheta       =
778                                      TMath::Sin(kConeTheta*TMath::DegToRad());
779   const Double_t kCosConeTheta       =
780                                      TMath::Cos(kConeTheta*TMath::DegToRad());
781   const Double_t kTanConeTheta       =
782                                      TMath::Tan(kConeTheta*TMath::DegToRad());
783   // Dimensions of the Cone Inserts
784   const Double_t kConeCFThickness       = 1.5*fgkmm; // Carbon fiber thickness
785   // Dimensions of the Cone Holes
786   const Double_t kHole1RMin          = (450.0/2)*fgkmm;
787   const Double_t kHole1RMax          = (530.0/2)*fgkmm;
788   const Double_t kHole2RMin          = (280.0/2)*fgkmm;
789   const Double_t kHole2RMax          = (375.0/2)*fgkmm;
790   const Double_t kHole1Phi           =      25.0*fgkDegree;
791   const Double_t kHole2Phi           =      50.0*fgkDegree;
792   const Double_t kHole3RMin          =     205.0*fgkmm;
793   const Double_t kHole3DeltaR        =        15*fgkmm;
794   const Double_t kHole3Width         =        30*fgkmm;
795   const Int_t    kNHole3             =         6      ;
796   const Double_t kHole4RMin          =     116.0*fgkmm;
797   const Double_t kHole4DeltaR        =        15*fgkmm;
798   const Double_t kHole4Width         =        30*fgkmm;
799   //  const Int_t    kNHole4             =         3      ;
800
801   // Local variables
802   Double_t x, y, z, t, dza, rmin, rmax;
803
804
805   // Recover the needed materials
806   TGeoMedium *medSDDcf  = mgr->GetMedium("ITS_SDD C (M55J)$");
807   TGeoMedium *medSDDair = mgr->GetMedium("ITS_SDD AIR$");
808   TGeoMedium *medSDDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
809   TGeoMedium *medSDDroh = mgr->GetMedium("ITS_ROHACELL$");
810   TGeoMedium *medSDDss  = mgr->GetMedium("ITS_INOX$");
811
812   // First define the geometrical shapes
813
814   // Central cylinder with its internal foam and the lateral flanges:
815   // a carbon fiber Tube which contains a rohacell Tube and two
816   // stesalite Tube's
817   TGeoTube *cylindershape = new TGeoTube(kCylinderInnerR,kCylinderOuterR,
818                                          kCylinderHalfLength);
819
820   TGeoTube *insertoshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
821                                         kInsertoHalfLength);
822
823   TGeoTube *flangeshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
824                                        kFlangeHalfLength);
825
826   // The flange bolt: it is a Tube
827   TGeoTube *boltshape = new TGeoTube(0.0, 0.5*kBoltDiameter, 0.5*kBoltDepth);
828
829   // Debug if requested
830   if (GetDebug(1)) {
831     cylindershape->InspectShape();
832     insertoshape->InspectShape();
833     flangeshape->InspectShape();
834     boltshape->InspectShape();
835   }
836
837
838   // We have the shapes: now create the real volumes
839
840   TGeoVolume *cfcylinder = new TGeoVolume("SDDCarbonFiberCylinder",
841                                           cylindershape,medSDDcf);
842   cfcylinder->SetVisibility(kTRUE);
843   cfcylinder->SetLineColor(4); // Blue
844   cfcylinder->SetLineWidth(1);
845   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
846   cfcylinder->SetFillStyle(4000); // 0% transparent
847
848   TGeoVolume *foamcylinder = new TGeoVolume("SDDFoamCylinder",
849                                             insertoshape,medSDDroh);
850   foamcylinder->SetVisibility(kTRUE);
851   foamcylinder->SetLineColor(3); // Green
852   foamcylinder->SetLineWidth(1);
853   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
854   foamcylinder->SetFillStyle(4050); // 50% transparent
855
856   TGeoVolume *flangecylinder = new TGeoVolume("SDDFlangeCylinder",
857                                               flangeshape,medSDDste);
858   flangecylinder->SetVisibility(kTRUE);
859   flangecylinder->SetLineColor(2); // Red
860   flangecylinder->SetLineWidth(1);
861   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
862   flangecylinder->SetFillStyle(4050); // 50% transparent
863
864   TGeoVolume *bolt = new TGeoVolume("SDDFlangeBolt",boltshape,medSDDss);
865   bolt->SetVisibility(kTRUE);
866   bolt->SetLineColor(1);  // Black
867   bolt->SetLineWidth(1);
868   bolt->SetFillColor(bolt->GetLineColor());
869   bolt->SetFillStyle(4050); // 50% transparent
870
871   // Mount up the cylinder
872   for(Int_t i=0; i<kNBolts; i++){
873     t = kThetaBolt*i;
874     x = kBoltRadius*TMath::Cos(t);
875     y = kBoltRadius*TMath::Sin(t);
876     z = kFlangeHalfLength-kBoltDepth;
877     flangecylinder->AddNode(bolt, i+1, new TGeoTranslation("",x,y,z));
878   }
879
880   cfcylinder->AddNode(foamcylinder,1,0);
881   cfcylinder->AddNode(flangecylinder,1,
882               new TGeoTranslation(0, 0, kInsertoHalfLength+kFlangeHalfLength));
883   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
884               0, 0, -kInsertoHalfLength-kFlangeHalfLength,
885               new TGeoRotation("",0,180,0)     ) );
886
887
888   // SDD Support Cone with its internal inserts: a carbon fiber Pcon
889   // with holes which contains a stesalite Pcon which on turn contains a
890   // rohacell Pcon
891
892   dza = kConeThickness/kSinConeTheta-(kConeROutMax-kConeROutMin)/kTanConeTheta;
893
894   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 12);
895
896   coneshape->Z(0)     = 0.0;
897   coneshape->Rmin(0)  = kConeROutMin;
898   coneshape->Rmax(0)  = kConeROutMax;
899
900   coneshape->Z(1)     = kConeZOuterMilled - dza;
901   coneshape->Rmin(1)  = coneshape->GetRmin(0);
902   coneshape->Rmax(1)  = coneshape->GetRmax(0);
903
904   coneshape->Z(2)     = kConeZOuterMilled;
905   coneshape->Rmax(2)  = coneshape->GetRmax(0);
906
907   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(1),
908                     coneshape->GetRmin(1),kConeTheta,z,rmin);
909   coneshape->Z(3)     = z;
910   coneshape->Rmin(3)  = rmin;
911
912   coneshape->Rmin(2)  = RminFrom2Points(coneshape,3,1,coneshape->GetZ(2));
913
914   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(2),
915                     coneshape->GetRmax(2),kConeTheta,z,rmax);
916   coneshape->Z(4)     = z;
917   coneshape->Rmax(4)  = rmax;
918   coneshape->Rmin(4)  = RminFromZpCone(coneshape,3,kConeTheta,
919                                        coneshape->GetZ(4),0.0);
920
921   coneshape->Rmax(3)  = RmaxFrom2Points(coneshape,4,2,coneshape->GetZ(3));
922
923   coneshape->Rmin(7)  = kConeRinMin;
924
925   coneshape->Rmin(8)  = kConeRinMin;
926
927   RadiusOfCurvature(kConeRCurv,90.0,0.0,kConeRinMax,90.0-kConeTheta,z,rmax);
928   coneshape->Rmax(8)  = rmax;
929   coneshape->Z(8)     = ZFromRmaxpCone(coneshape,4,kConeTheta,
930                                        coneshape->GetRmax(8));
931
932   coneshape->Z(9)     = kConeZCylinder;
933   coneshape->Rmin(9)  = kConeRinMin;
934
935   coneshape->Z(10)    = coneshape->GetZ(9);
936   coneshape->Rmin(10) = kConeRinCylinder;
937
938   coneshape->Rmin(11) = kConeRinCylinder;
939   coneshape->Rmax(11) = coneshape->GetRmin(11);
940
941   rmin                = coneshape->GetRmin(8);
942   RadiusOfCurvature(kConeRCurv,90.0-kConeTheta,
943                     coneshape->GetZ(8),coneshape->GetRmax(8),90.0,z,rmax);
944   rmax                = kConeRinMax;
945   coneshape->Z(11)    = z + (coneshape->GetZ(8)-z)*
946                    (coneshape->GetRmax(11)-rmax)/(coneshape->GetRmax(8)-rmax);
947
948   coneshape->Rmax(9)  = RmaxFrom2Points(coneshape,11,8,coneshape->GetZ(9));
949
950   coneshape->Rmax(10) = coneshape->GetRmax(9);
951
952   coneshape->Z(6)     = z - kConeDZin;
953   coneshape->Z(7)     = coneshape->GetZ(6);
954
955   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,4,kConeTheta,
956                                        coneshape->GetZ(6));
957
958   coneshape->Rmax(7)  = coneshape->GetRmax(6);
959
960   RadiusOfCurvature(kConeRCurv,90.,
961                     coneshape->GetZ(6),0.0,90.0-kConeTheta,z,rmin);
962   coneshape->Z(5)     = z;
963   coneshape->Rmin(5)  = RminFromZpCone(coneshape,3,kConeTheta,z);
964   coneshape->Rmax(5)  = RmaxFromZpCone(coneshape,4,kConeTheta,z);
965
966   RadiusOfCurvature(kConeRCurv,90.-kConeTheta,
967                     0.0,coneshape->Rmin(5),90.0,z,rmin);
968   coneshape->Rmin(6)  = rmin;
969
970   // SDD Cone Insert: another Pcon
971   Double_t x0, y0, x1, y1, x2, y2;
972   TGeoPcon *coneinsertshape = new TGeoPcon(0.0, 360.0, 9);
973
974   coneinsertshape->Z(0)    = coneshape->GetZ(0) + kConeCFThickness;
975   coneinsertshape->Rmin(0) = coneshape->GetRmin(0) + kConeCFThickness;
976   coneinsertshape->Rmax(0) = coneshape->GetRmax(0) - kConeCFThickness;
977
978   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
979   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
980   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
981   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
982   coneinsertshape->Z(1)    = z;
983   coneinsertshape->Rmin(1) = rmin;
984   coneinsertshape->Rmax(1) = coneinsertshape->GetRmax(0);
985
986   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmax(1);
987   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmax(2);
988   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmax(3);
989   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
990   coneinsertshape->Z(2)    = z;
991   coneinsertshape->Rmax(2) = rmax;
992
993   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
994   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
995   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
996   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
997   coneinsertshape->Z(3)    = z;
998   coneinsertshape->Rmin(3) = rmin;
999
1000   x0 = coneinsertshape->GetZ(1); y0 = coneinsertshape->GetRmin(1);
1001   x1 = coneinsertshape->GetZ(3); y1 = coneinsertshape->GetRmin(3);
1002   coneinsertshape->Rmin(2) = Yfrom2Points(x0, y0, x1, y1,
1003                                           coneinsertshape->Z(2));
1004
1005   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
1006   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
1007   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
1008   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1009   coneinsertshape->Z(4)    = z;
1010   coneinsertshape->Rmax(4) = rmax;
1011
1012   x0 = coneinsertshape->GetZ(2); y0 = coneinsertshape->GetRmax(2);
1013   x1 = coneinsertshape->GetZ(4); y1 = coneinsertshape->GetRmax(4);
1014   coneinsertshape->Rmax(3) = Yfrom2Points(x0, y0, x1, y1,
1015                                           coneinsertshape->Z(3));
1016
1017   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmin(4);
1018   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmin(5);
1019   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmin(6);
1020   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1021   coneinsertshape->Z(5)    = z;
1022   coneinsertshape->Rmin(5) = rmin;
1023   coneinsertshape->Rmax(5) = coneinsertshape->GetRmax(4) -
1024           kTanConeTheta*(coneinsertshape->GetZ(5) - coneinsertshape->GetZ(4));
1025
1026   x0 = coneinsertshape->GetZ(3); y0 = coneinsertshape->GetRmin(3);
1027   x1 = coneinsertshape->GetZ(5); y1 = coneinsertshape->GetRmin(5);
1028   coneinsertshape->Rmin(4) = Yfrom2Points(x0, y0, x1, y1,
1029                                           coneinsertshape->Z(4));
1030
1031   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmin(5);
1032   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmin(6);
1033   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmin(7);
1034   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1035   coneinsertshape->Z(6)    = z;
1036   coneinsertshape->Rmin(6) = rmin;
1037   coneinsertshape->Rmax(6) = coneinsertshape->GetRmax(4) -
1038           kTanConeTheta*(coneinsertshape->GetZ(6) - coneinsertshape->GetZ(4));
1039
1040   coneinsertshape->Z(7)    = coneinsertshape->GetZ(6);
1041   coneinsertshape->Rmin(7) = coneshape->GetRmin(7) + kConeCFThickness;
1042   coneinsertshape->Rmax(7) = coneinsertshape->GetRmax(6);
1043
1044   coneinsertshape->Z(8)    = coneshape->GetZ(9) - kConeCFThickness;
1045   coneinsertshape->Rmin(8) = coneinsertshape->GetRmin(7);
1046   coneinsertshape->Rmax(8) = coneinsertshape->GetRmax(4) -
1047           kTanConeTheta*(coneinsertshape->GetZ(8) - coneinsertshape->GetZ(4));
1048
1049   // SDD Cone Foam: another Pcon
1050   TGeoPcon *conefoamshape = new TGeoPcon(0.0, 360.0, 4);
1051
1052   RadiusOfCurvature(kConeRCurv+kConeCFThickness,0.0,coneinsertshape->GetZ(1),
1053                     coneinsertshape->GetRmin(1),kConeTheta,z,rmin);
1054
1055   conefoamshape->Z(0)    = z;
1056   conefoamshape->Rmin(0) = rmin;
1057   conefoamshape->Rmax(0) = conefoamshape->GetRmin(0);
1058
1059   conefoamshape->Z(1)    = conefoamshape->GetZ(0)+
1060                          (kConeThickness-2.0*kConeCFThickness)/kSinConeTheta;
1061   conefoamshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1062                                           conefoamshape->GetZ(1));
1063   conefoamshape->Rmax(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1064                                           conefoamshape->GetZ(1));
1065
1066   conefoamshape->Z(2)    = coneshape->GetZ(5)-kConeCFThickness;
1067   conefoamshape->Rmin(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1068                                           conefoamshape->GetZ(2));
1069   conefoamshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1070                                           conefoamshape->GetZ(2));
1071
1072   conefoamshape->Z(3)    = coneinsertshape->GetZ(5)+
1073                          (kConeThickness-2.0*kConeCFThickness)*kCosConeTheta;
1074   conefoamshape->Rmax(3) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1075                                           conefoamshape->GetZ(3));
1076   conefoamshape->Rmin(3) = conefoamshape->GetRmax(3);
1077
1078   // SDD Cone Holes: Pcon's
1079   // A single hole volume gives an overlap with coneinsert, so
1080   // three contiguous volumes are created: one to be put in the cone foam
1081   // and two in the cone carbon fiber envelope
1082   TGeoPcon *hole1shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1083
1084   hole1shape->Rmin(0) = kHole1RMax;
1085   hole1shape->Rmax(0) = hole1shape->GetRmin(0);
1086   hole1shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1087                                        hole1shape->GetRmin(0));
1088
1089   hole1shape->Rmax(1) = hole1shape->GetRmax(0);
1090   hole1shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1091                                        hole1shape->GetRmax(1));
1092   hole1shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1093                                        hole1shape->GetZ(1));
1094
1095   hole1shape->Rmin(2) = kHole1RMin;
1096   hole1shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1097                                        hole1shape->GetRmin(2));
1098   hole1shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1099                                        hole1shape->GetZ(2));
1100
1101   hole1shape->Rmin(3) = hole1shape->GetRmin(2);
1102   hole1shape->Rmax(3) = hole1shape->GetRmin(3);
1103   hole1shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1104                                        hole1shape->GetRmax(3));
1105
1106   TGeoPcon *hole11shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1107
1108   hole11shape->Rmin(0) = kHole1RMax;
1109   hole11shape->Rmax(0) = hole11shape->GetRmin(0);
1110   hole11shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1111                                         hole11shape->GetRmin(0));
1112
1113   hole11shape->Rmax(1) = hole11shape->GetRmax(0);
1114   hole11shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1115                                         hole11shape->GetRmax(1));
1116   hole11shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1117                                         hole11shape->GetZ(1));
1118
1119   hole11shape->Rmin(2) = kHole1RMin;
1120   hole11shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1121                                         hole11shape->GetRmin(2));
1122   hole11shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1123                                         hole11shape->GetZ(2));
1124
1125   hole11shape->Rmin(3) = hole11shape->GetRmin(2);
1126   hole11shape->Rmax(3) = hole11shape->GetRmin(3);
1127   hole11shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1128                                         hole11shape->GetRmax(3));
1129
1130   TGeoPcon *hole12shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1131
1132   hole12shape->Rmin(0) = kHole1RMax;
1133   hole12shape->Rmax(0) = hole12shape->GetRmin(0);
1134   hole12shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1135                                         hole12shape->GetRmin(0));
1136
1137   hole12shape->Rmax(1) = hole12shape->GetRmax(0);
1138   hole12shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1139                                         hole12shape->GetRmax(1));
1140   hole12shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1141                                         hole12shape->GetZ(1));
1142
1143   hole12shape->Rmin(2) = kHole1RMin;
1144   hole12shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1145                                         hole12shape->GetRmin(2));
1146   hole12shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1147                                         hole12shape->GetZ(2));
1148
1149   hole12shape->Rmin(3) = hole12shape->GetRmin(2);
1150   hole12shape->Rmax(3) = hole12shape->GetRmin(3);
1151   hole12shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1152                                         hole12shape->GetRmax(3));
1153
1154   //
1155   TGeoPcon *hole2shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1156
1157   hole2shape->Rmin(0) = kHole2RMax;
1158   hole2shape->Rmax(0) = hole2shape->GetRmin(0);
1159   hole2shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1160                                        hole2shape->GetRmin(0));
1161
1162   hole2shape->Rmax(1) = hole2shape->GetRmax(0);
1163   hole2shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1164                                        hole2shape->GetRmax(1));
1165   hole2shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1166                                        hole2shape->GetZ(1));
1167
1168   hole2shape->Rmin(2) = kHole2RMin;
1169   hole2shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1170                                        hole2shape->GetRmin(2));
1171   hole2shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1172                                        hole2shape->GetZ(2));
1173
1174   hole2shape->Rmin(3) = hole2shape->GetRmin(2);
1175   hole2shape->Rmax(3) = hole2shape->GetRmin(3);
1176   hole2shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1177                                        hole2shape->GetRmax(3));
1178
1179   TGeoPcon *hole21shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1180
1181   hole21shape->Rmin(0) = kHole2RMax;
1182   hole21shape->Rmax(0) = hole21shape->GetRmin(0);
1183   hole21shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1184                                         hole21shape->GetRmin(0));
1185
1186   hole21shape->Rmax(1) = hole21shape->GetRmax(0);
1187   hole21shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1188                                         hole21shape->GetRmax(1));
1189   hole21shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1190                                         hole21shape->GetZ(1));
1191
1192   hole21shape->Rmin(2) = kHole2RMin;
1193   hole21shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1194                                         hole21shape->GetRmin(2));
1195   hole21shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1196                                         hole21shape->GetZ(2));
1197
1198   hole21shape->Rmin(3) = hole21shape->GetRmin(2);
1199   hole21shape->Rmax(3) = hole21shape->GetRmin(3);
1200   hole21shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1201                                         hole21shape->GetRmax(3));
1202
1203   TGeoPcon *hole22shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1204
1205   hole22shape->Rmin(0) = kHole2RMax;
1206   hole22shape->Rmax(0) = hole22shape->GetRmin(0);
1207   hole22shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1208                                         hole22shape->GetRmin(0));
1209
1210   hole22shape->Rmax(1) = hole22shape->GetRmax(0);
1211   hole22shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1212                                         hole22shape->GetRmax(1));
1213   hole22shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1214                                         hole22shape->GetZ(1));
1215
1216   hole22shape->Rmin(2) = kHole2RMin;
1217   hole22shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1218                                         hole22shape->GetRmin(2));
1219   hole22shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1220                                         hole22shape->GetZ(2));
1221
1222   hole22shape->Rmin(3) = hole22shape->GetRmin(2);
1223   hole22shape->Rmax(3) = hole22shape->GetRmin(3);
1224   hole22shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1225                                         hole22shape->GetRmax(3));
1226
1227   //
1228   Double_t holePhi;
1229   holePhi = (kHole3Width/kHole3RMin)*TMath::RadToDeg();
1230
1231   TGeoPcon *hole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1232
1233   hole3shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1234   hole3shape->Rmax(0) = hole3shape->GetRmin(0);
1235   hole3shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1236                                        hole3shape->GetRmin(0));
1237
1238   hole3shape->Rmax(1) = hole3shape->GetRmax(0);
1239   hole3shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1240                                        hole3shape->GetRmax(1));
1241   hole3shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1242                                        hole3shape->GetZ(1));
1243
1244   hole3shape->Rmin(2) = kHole3RMin;
1245   hole3shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1246                                        hole3shape->GetRmin(2));
1247   hole3shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1248                                        hole3shape->GetZ(2));
1249
1250   hole3shape->Rmin(3) = hole3shape->GetRmin(2);
1251   hole3shape->Rmax(3) = hole3shape->GetRmin(3);
1252   hole3shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1253                                        hole3shape->GetRmax(3));
1254
1255   TGeoPcon *hole31shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1256
1257   hole31shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1258   hole31shape->Rmax(0) = hole31shape->GetRmin(0);
1259   hole31shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1260                                         hole31shape->GetRmin(0));
1261
1262   hole31shape->Rmax(1) = hole31shape->GetRmax(0);
1263   hole31shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1264                                         hole31shape->GetRmax(1));
1265   hole31shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1266                                         hole31shape->GetZ(1));
1267
1268   hole31shape->Rmin(2) = kHole3RMin;
1269   hole31shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1270                                         hole31shape->GetRmin(2));
1271   hole31shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1272                                         hole31shape->GetZ(2));
1273
1274   hole31shape->Rmin(3) = hole31shape->GetRmin(2);
1275   hole31shape->Rmax(3) = hole31shape->GetRmin(3);
1276   hole31shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1277                                         hole31shape->GetRmax(3));
1278
1279   TGeoPcon *hole32shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1280
1281   hole32shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
1282   hole32shape->Rmax(0) = hole32shape->GetRmin(0);
1283   hole32shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1284                                         hole32shape->GetRmin(0));
1285
1286   hole32shape->Rmax(1) = hole32shape->GetRmax(0);
1287   hole32shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1288                                         hole32shape->GetRmax(1));
1289   hole32shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1290                                         hole32shape->GetZ(1));
1291
1292   hole32shape->Rmin(2) = kHole3RMin;
1293   hole32shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1294                                         hole32shape->GetRmin(2));
1295   hole32shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1296                                         hole32shape->GetZ(2));
1297
1298   hole32shape->Rmin(3) = hole32shape->GetRmin(2);
1299   hole32shape->Rmax(3) = hole32shape->GetRmin(3);
1300   hole32shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1301                                         hole32shape->GetRmax(3));
1302
1303   //
1304   holePhi = (kHole4Width/kHole4RMin)*TMath::RadToDeg();
1305
1306   TGeoPcon *hole4shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1307
1308   hole4shape->Rmin(0) = kHole4RMin + kHole4DeltaR;
1309   hole4shape->Rmax(0) = hole4shape->GetRmin(0);
1310   hole4shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1311                                        hole4shape->GetRmin(0));
1312
1313   hole4shape->Rmax(1) = hole4shape->GetRmax(0);
1314   hole4shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1315                                        hole4shape->GetRmax(1));
1316   hole4shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1317                                        hole4shape->GetZ(1));
1318
1319   hole4shape->Rmin(2) = kHole4RMin;
1320   hole4shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1321                                        hole4shape->GetRmin(2));
1322   hole4shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1323                                        hole4shape->GetZ(2));
1324
1325   hole4shape->Rmin(3) = hole4shape->GetRmin(2);
1326   hole4shape->Rmax(3) = hole4shape->GetRmin(3);
1327   hole4shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1328                                        hole4shape->GetRmax(3));
1329
1330   // Debug if requested
1331   if (GetDebug(1)) {
1332     coneshape->InspectShape();
1333     coneinsertshape->InspectShape();
1334     conefoamshape->InspectShape();
1335     hole1shape->InspectShape();
1336     hole2shape->InspectShape();
1337     hole3shape->InspectShape();
1338     hole4shape->InspectShape();
1339   }
1340
1341
1342   // We have the shapes: now create the real volumes
1343
1344   TGeoVolume *cfcone = new TGeoVolume("SDDCarbonFiberCone",
1345                                       coneshape,medSDDcf);
1346   cfcone->SetVisibility(kTRUE);
1347   cfcone->SetLineColor(4); // Blue
1348   cfcone->SetLineWidth(1);
1349   cfcone->SetFillColor(cfcone->GetLineColor());
1350   cfcone->SetFillStyle(4000); // 0% transparent
1351
1352   TGeoVolume *cfconeinsert = new TGeoVolume("SDDCarbonFiberConeInsert",
1353                                             coneinsertshape,medSDDste);
1354   cfconeinsert->SetVisibility(kTRUE);
1355   cfconeinsert->SetLineColor(2); // Red
1356   cfconeinsert->SetLineWidth(1);
1357   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
1358   cfconeinsert->SetFillStyle(4050); // 50% transparent
1359
1360   TGeoVolume *cfconefoam = new TGeoVolume("SDDCarbonFiberConeFoam",
1361                                           conefoamshape,medSDDroh);
1362   cfconefoam->SetVisibility(kTRUE);
1363   cfconefoam->SetLineColor(7); // Light blue
1364   cfconefoam->SetLineWidth(1);
1365   cfconefoam->SetFillColor(cfconefoam->GetLineColor());
1366   cfconefoam->SetFillStyle(4050); // 50% transparent
1367
1368   TGeoVolume *hole1 = new TGeoVolume("SDDCableHole1",
1369                                      hole1shape,medSDDair);
1370   hole1->SetVisibility(kTRUE);
1371   hole1->SetLineColor(5); // Yellow
1372   hole1->SetLineWidth(1);
1373   hole1->SetFillColor(hole1->GetLineColor());
1374   hole1->SetFillStyle(4090); // 90% transparent
1375
1376   TGeoVolume *hole11 = new TGeoVolume("SDDCableHole11",
1377                                       hole11shape,medSDDair);
1378   hole11->SetVisibility(kTRUE);
1379   hole11->SetLineColor(5); // Yellow
1380   hole11->SetLineWidth(1);
1381   hole11->SetFillColor(hole11->GetLineColor());
1382   hole11->SetFillStyle(4090); // 90% transparent
1383
1384   TGeoVolume *hole12 = new TGeoVolume("SDDCableHole12",
1385                                       hole12shape,medSDDair);
1386   hole12->SetVisibility(kTRUE);
1387   hole12->SetLineColor(5); // Yellow
1388   hole12->SetLineWidth(1);
1389   hole12->SetFillColor(hole12->GetLineColor());
1390   hole12->SetFillStyle(4090); // 90% transparent
1391
1392   TGeoVolume *hole2 = new TGeoVolume("SDDCableHole2",
1393                                      hole2shape,medSDDair);
1394   hole2->SetVisibility(kTRUE);
1395   hole2->SetLineColor(5); // Yellow
1396   hole2->SetLineWidth(1);
1397   hole2->SetFillColor(hole2->GetLineColor());
1398   hole2->SetFillStyle(4090); // 90% transparent
1399
1400   TGeoVolume *hole21 = new TGeoVolume("SDDCableHole21",
1401                                       hole21shape,medSDDair);
1402   hole21->SetVisibility(kTRUE);
1403   hole21->SetLineColor(5); // Yellow
1404   hole21->SetLineWidth(1);
1405   hole21->SetFillColor(hole21->GetLineColor());
1406   hole21->SetFillStyle(4090); // 90% transparent
1407
1408   TGeoVolume *hole22 = new TGeoVolume("SDDCableHole22",
1409                                       hole22shape,medSDDair);
1410   hole22->SetVisibility(kTRUE);
1411   hole22->SetLineColor(5); // Yellow
1412   hole22->SetLineWidth(1);
1413   hole22->SetFillColor(hole22->GetLineColor());
1414   hole22->SetFillStyle(4090); // 90% transparent
1415
1416   TGeoVolume *hole3 = new TGeoVolume("SDDCableHole3",
1417                                      hole3shape,medSDDair);
1418   hole3->SetVisibility(kTRUE);
1419   hole3->SetLineColor(5); // Yellow
1420   hole3->SetLineWidth(1);
1421   hole3->SetFillColor(hole3->GetLineColor());
1422   hole3->SetFillStyle(4090); // 90% transparent
1423
1424   TGeoVolume *hole31 = new TGeoVolume("SDDCableHole31",
1425                                       hole31shape,medSDDair);
1426   hole31->SetVisibility(kTRUE);
1427   hole31->SetLineColor(5); // Yellow
1428   hole31->SetLineWidth(1);
1429   hole31->SetFillColor(hole31->GetLineColor());
1430   hole31->SetFillStyle(4090); // 90% transparent
1431
1432   TGeoVolume *hole32 = new TGeoVolume("SDDCableHole32",
1433                                       hole32shape,medSDDair);
1434   hole32->SetVisibility(kTRUE);
1435   hole32->SetLineColor(5); // Yellow
1436   hole32->SetLineWidth(1);
1437   hole32->SetFillColor(hole32->GetLineColor());
1438   hole32->SetFillStyle(4090); // 90% transparent
1439
1440   TGeoVolume *hole4 = new TGeoVolume("SDDCableHole4",
1441                                      hole4shape,medSDDair);
1442   hole4->SetVisibility(kTRUE);
1443   hole4->SetLineColor(5); // Yellow
1444   hole4->SetLineWidth(1);
1445   hole4->SetFillColor(hole4->GetLineColor());
1446   hole4->SetFillStyle(4090); // 90% transparent
1447
1448   // Mount up a cone
1449   cfconeinsert->AddNode(cfconefoam,1,0);
1450
1451   for (Int_t i=0; i<12; i++) {
1452     Double_t phiH = i*30.0;
1453     cfconefoam->AddNode(hole1 , i+1, new TGeoRotation("", 0, 0, phiH));
1454         cfcone->AddNode(hole11, i+1, new TGeoRotation("", 0, 0, phiH));
1455         cfcone->AddNode(hole12, i+1, new TGeoRotation("", 0, 0, phiH));
1456   }
1457
1458   for (Int_t i=0; i<6; i++) {
1459     Double_t phiH = i*60.0;
1460     cfconefoam->AddNode(hole2 , i+1, new TGeoRotation("", 0, 0, phiH));
1461         cfcone->AddNode(hole21, i+1, new TGeoRotation("", 0, 0, phiH));
1462         cfcone->AddNode(hole22, i+1, new TGeoRotation("", 0, 0, phiH));
1463   }
1464
1465   for (Int_t i=0; i<kNHole3; i++) {
1466     Double_t phiH0 = 360./(Double_t)kNHole3;
1467     Double_t phiH  = i*phiH0 + 0.5*phiH0;
1468     cfconefoam->AddNode(hole3 , i+1, new TGeoRotation("", phiH, 0, 0));
1469         cfcone->AddNode(hole31, i+1, new TGeoRotation("", phiH, 0, 0));
1470         cfcone->AddNode(hole32, i+1, new TGeoRotation("", phiH, 0, 0));
1471   }
1472
1473   cfcone->AddNode(cfconeinsert,1,0);
1474
1475 /*
1476   for (Int_t i=0; i<kNHole4; i++) {
1477     Double_t phiH0 = 360./(Double_t)kNHole4;
1478     Double_t phiH  = i*phiH0 + 0.25*phiH0;
1479     cfcone->AddNode(hole4, i+1, new TGeoRotation("", phiH, 0, 0));
1480   }
1481 */
1482   // Finally put everything in the mother volume
1483   moth->AddNode(cfcylinder,1,0);
1484
1485   z = coneshape->Z(9);
1486   moth->AddNode(cfcone,1,new TGeoTranslation(0, 0, -z - kCylinderHalfLength));
1487   moth->AddNode(cfcone,2,new TGeoCombiTrans (0, 0,  z + kCylinderHalfLength,
1488                          new TGeoRotation("", 0, 180, 0)                   ));
1489
1490
1491   return;
1492 }
1493
1494 //______________________________________________________________________
1495 void AliITSv11GeometrySupport::SSDCone(TGeoVolume *moth,TGeoManager *mgr)
1496 {
1497 //
1498 // Creates the SSD support cone and cylinder geometry. as a
1499 // volume assembly and adds it to the mother volume
1500 // (part of this code is taken or anyway inspired to SSDCone method
1501 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
1502 //
1503 // Input:
1504 //         moth : the TGeoVolume owing the volume structure
1505 //         mgr  : the GeoManager (default gGeoManager)
1506 // Output:
1507 //
1508 // Created:         ???       Bjorn S. Nilsen
1509 // Updated:      08 Mar 2008  Mario Sitta
1510 //
1511 // Technical data are taken from:  "ITS Supporto Generale" (technical
1512 // drawings ALR3-0743/1, ALR3-0743/1A and ALR3-0743/1B), "Supporto Generale
1513 // Settore SSD" (technical drawings ALR3-0743/2A and ALR3-0743/2E), private
1514 // communication with B. Giraudo
1515 //
1516 // Updated:      11 Apr 2008  Mario Sitta
1517 // Measures from drawings give overlaps with SPD thermal shield wings,
1518 // so the terminal part of the SSD cone was reduced
1519
1520   // Dimensions of the Central cylinder and flanges
1521   const Double_t kCylinderHalfLength   = (1144.0/2) *fgkmm;
1522   const Double_t kCylinderOuterRadius  = ( 595.0/2) *fgkmm;
1523   const Double_t kCylinderThickness    =        0.6 *fgkmm;
1524   const Double_t kFoamHalfLength       = (1020.0/2) *fgkmm;
1525   const Double_t kFoamThickness        =        5.0 *fgkmm;
1526   const Double_t kFlangeHalfLength     =
1527                                       (kCylinderHalfLength-kFoamHalfLength)/2.;
1528   const Double_t kFlangeInnerRadius    = ( 563.0/2) *fgkmm;
1529   // Dimensions of the Cone
1530   const Double_t kConeROuterMin        = ( 957.0/2) *fgkmm;
1531   const Double_t kConeROuterMax        = ( 997.0/2) *fgkmm;
1532   const Double_t kConeRInnerMin        = ( 564.0/2) *fgkmm;
1533   const Double_t kConeRCurv1           =       10.0 *fgkmm;
1534   const Double_t kConeRCurv2           =       25.0 *fgkmm;
1535   const Double_t kConeCent1RCurv2      = ( 578.0/2) *fgkmm;
1536   const Double_t kConeCent2RCurv2      = ( 593.0/2) *fgkmm;
1537 //  const Double_t kConeZOuterRing       =       47.0 *fgkmm;
1538 //  const Double_t kConeZOuterRingInside =       30.25*fgkmm;
1539 //  const Double_t kConeZInnerRing       =      161.5 *fgkmm;
1540 //  const Double_t kConeZLength          =      176.5 *fgkmm;
1541   const Double_t kConeZOuterRing       =       38.5 *fgkmm;
1542   const Double_t kConeZOuterRingInside =       22.2 *fgkmm;
1543   const Double_t kConeZInnerRing       =      153.0 *fgkmm;
1544   const Double_t kConeZLength          =      168.0 *fgkmm;
1545   const Double_t kConeZPosition        = kConeZLength + kCylinderHalfLength;
1546   const Double_t kConeThickness        =       13.0 *fgkmm; // Cone thickness
1547   const Double_t kConeTheta            =       39.0 *fgkDegree; // Cone angle
1548   const Double_t kSinConeTheta         =
1549                                       TMath::Sin(kConeTheta*TMath::DegToRad());
1550   const Double_t kCosConeTheta         =
1551                                       TMath::Cos(kConeTheta*TMath::DegToRad());
1552   // Dimensions of the Foam cores
1553   const Double_t kConeFoam1Length      =      112.3 *fgkmm;
1554   const Double_t kConeFoam2Length      =       58.4 *fgkmm;
1555   // Dimensions of the Cone Holes
1556   const Double_t kCoolingHoleWidth     =       40.0 *fgkmm;
1557   const Double_t kCoolingHoleHight     =       30.0 *fgkmm;
1558   const Double_t kCoolingHoleRmin      =      350.0 *fgkmm;
1559   const Double_t kCoolingHolePhi       =       45.0 *fgkDegree;
1560   const Double_t kMountingHoleWidth    =       20.0 *fgkmm;
1561   const Double_t kMountingHoleHight    =       20.0 *fgkmm;
1562   const Double_t kMountingHoleRmin     =      317.5 *fgkmm;
1563   const Double_t kMountingHolePhi      =       60.0 *fgkDegree;
1564   const Double_t kCableHoleRin         = ( 800.0/2) *fgkmm;
1565   const Double_t kCableHoleRout        = ( 920.0/2) *fgkmm;
1566   const Double_t kCableHoleWidth       =      200.0 *fgkmm;
1567 //  const Double_t kCableHoleAngle       =       42.0 *fgkDegree;
1568   // Dimensions of the Cone Wings
1569   const Double_t kWingRmax             =      527.5 *fgkmm;
1570   const Double_t kWingWidth            =       70.0 *fgkmm;
1571   const Double_t kWingHalfThick        = (  10.0/2) *fgkmm;
1572   const Double_t kThetaWing            =       45.0 *fgkDegree;
1573   // Dimensions of the SSD-SDD Mounting Brackets
1574   const Double_t kBracketRmin          = ( 541.0/2) *fgkmm;// See SDD ROutMin
1575   const Double_t kBracketRmax          = ( 585.0/2) *fgkmm;
1576   const Double_t kBracketHalfLength    = (   4.0/2) *fgkmm;
1577   const Double_t kBracketPhi           = (70.*fgkmm/kBracketRmax)*fgkRadian;
1578   // Common data
1579   const Double_t kCFThickness          =        0.75*fgkmm; //Carb. fib. thick.
1580
1581
1582   // Local variables
1583   Double_t rmin1, rmin2, rmax, z;
1584
1585   //
1586   //Begin_Html
1587   /*
1588     <img src="picts/ITS/file_name.gif">
1589     <P>
1590     <FONT FACE'"TIMES">
1591     ITS SSD central support and thermal shield cylinder.
1592     </FONT>
1593     </P>
1594   */
1595   //End_Html
1596   //
1597
1598   // Central cylinder with its internal foam and the lateral flanges:
1599   // a carbon fiber Pcon which contains a rohacell Tube and two
1600   // stesalite Cone's
1601   TGeoPcon *externalcylshape = new TGeoPcon(0,360,4);
1602
1603   rmax  = kCylinderOuterRadius;
1604   rmin1 = kFlangeInnerRadius - kCylinderThickness;
1605   rmin2 = rmax - 2*kCylinderThickness - kFoamThickness;
1606   externalcylshape->DefineSection(0,-kCylinderHalfLength,rmin1,rmax);
1607   externalcylshape->DefineSection(1,-kFoamHalfLength    ,rmin2,rmax);
1608   externalcylshape->DefineSection(2, kFoamHalfLength    ,rmin2,rmax);
1609   externalcylshape->DefineSection(3, kCylinderHalfLength,rmin1,rmax);
1610
1611   rmax  = kCylinderOuterRadius - kCylinderThickness;
1612   rmin1 = rmax - kFoamThickness;
1613   TGeoTube *foamshape = new TGeoTube(rmin1,rmax,kFoamHalfLength);
1614
1615   rmax  = kCylinderOuterRadius - kCylinderThickness;
1616   rmin1 = rmax - kFoamThickness;
1617   rmin2 = kFlangeInnerRadius;
1618   TGeoCone *flangeshape = new TGeoCone(kFlangeHalfLength,
1619                                        rmin1,rmax,rmin2,rmax);
1620
1621
1622   // We have the shapes: now create the real volumes
1623
1624   TGeoMedium *medSSDcf  = mgr->GetMedium("ITS_SSD C (M55J)$");
1625   TGeoMedium *medSSDair = mgr->GetMedium("ITS_SSD AIR$");
1626   TGeoMedium *medSSDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
1627   TGeoMedium *medSSDroh = mgr->GetMedium("ITS_ROHACELL$");
1628   TGeoMedium *medSSDal  = mgr->GetMedium("ITS_ALUMINUM$");
1629
1630   TGeoVolume *cfcylinder = new TGeoVolume("SSDexternalcylinder",
1631                                            externalcylshape,medSSDcf);
1632   cfcylinder->SetVisibility(kTRUE);
1633   cfcylinder->SetLineColor(4); // blue
1634   cfcylinder->SetLineWidth(1);
1635   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
1636   cfcylinder->SetFillStyle(4000); // 0% transparent
1637
1638   TGeoVolume *foamcylinder = new TGeoVolume("SSDfoamcylinder",
1639                                             foamshape,medSSDroh);
1640   foamcylinder->SetVisibility(kTRUE);
1641   foamcylinder->SetLineColor(3); // green
1642   foamcylinder->SetLineWidth(1);
1643   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
1644   foamcylinder->SetFillStyle(4050); // 50% transparent
1645
1646   TGeoVolume *flangecylinder = new TGeoVolume("SSDflangecylinder",
1647                                               flangeshape,medSSDste);
1648   flangecylinder->SetVisibility(kTRUE);
1649   flangecylinder->SetLineColor(2); // red
1650   flangecylinder->SetLineWidth(1);
1651   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
1652   flangecylinder->SetFillStyle(4050); // 50% transparent
1653
1654   // Mount up the cylinder
1655   cfcylinder->AddNode(foamcylinder,1,0);
1656   cfcylinder->AddNode(flangecylinder,1,
1657               new TGeoTranslation(0, 0, kFoamHalfLength+kFlangeHalfLength));
1658   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
1659               0, 0, -kFoamHalfLength-kFlangeHalfLength,
1660               new TGeoRotation("",0,180,0)     ) );
1661
1662
1663   // The whole Cone as an assembly
1664   TGeoVolumeAssembly *vC = new TGeoVolumeAssembly("ITSssdCone");
1665
1666
1667   // SSD Support Cone with its internal inserts: a carbon fiber Pcon
1668   // with holes which contains a stesalite Pcon which on turn contains a
1669   // rohacell Pcon
1670   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 12);
1671
1672   coneshape->Z(0)     = 0.0;
1673   coneshape->Rmin(0)  = kConeROuterMin;
1674   coneshape->Rmax(0)  = kConeROuterMax;
1675
1676   coneshape->Z(1)     = kConeZOuterRingInside - kConeRCurv1;
1677   coneshape->Rmin(1)  = coneshape->GetRmin(0);
1678   coneshape->Rmax(1)  = coneshape->GetRmax(0);
1679
1680   coneshape->Z(2)     = kConeZOuterRingInside;
1681   coneshape->Rmin(2)  = coneshape->GetRmin(1) - kConeRCurv1;
1682   coneshape->Rmax(2)  = coneshape->GetRmax(0);
1683
1684   coneshape->Z(3)     = coneshape->GetZ(2);
1685   coneshape->Rmax(3)  = coneshape->GetRmax(0);
1686
1687   coneshape->Z(4)     = kConeZOuterRing - kConeRCurv1;
1688   coneshape->Rmax(4)  = coneshape->GetRmax(0);
1689
1690   coneshape->Z(5)     = kConeZOuterRing;
1691   coneshape->Rmax(5)  = coneshape->GetRmax(4) - kConeRCurv1;
1692
1693   coneshape->Z(6)     = coneshape->GetZ(5);
1694
1695   RadiusOfCurvature(kConeRCurv2,90.0,kConeZInnerRing,kConeCent1RCurv2,
1696                     90.0-kConeTheta,z,rmin1);
1697   coneshape->Z(7)     = z;
1698   coneshape->Rmin(7)  = rmin1;
1699
1700   coneshape->Rmin(3)  = RminFromZpCone(coneshape,7,90.-kConeTheta,
1701                                        coneshape->GetZ(3));
1702
1703   coneshape->Rmin(4)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(4));
1704
1705   coneshape->Rmin(5)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(5));
1706
1707   coneshape->Rmin(6) = coneshape->GetRmin(5);
1708
1709   coneshape->Z(8)     = kConeZInnerRing;
1710   coneshape->Rmin(8)  = kConeCent1RCurv2;
1711
1712   coneshape->Z(9)     = coneshape->GetZ(8);
1713   coneshape->Rmin(9)  = kConeRInnerMin;
1714
1715   RadiusOfCurvature(kConeRCurv2,90.0,kConeZLength,kConeCent2RCurv2,
1716                     90.0-kConeTheta,z,rmax);
1717
1718   coneshape->Z(10)    = z;
1719   coneshape->Rmin(10) = coneshape->GetRmin(9);
1720   coneshape->Rmax(10) = rmax;
1721
1722   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,10,90.-kConeTheta,
1723                                        coneshape->GetZ(6));
1724
1725   coneshape->Rmax(7)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(7));
1726
1727   coneshape->Rmax(8)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(8));
1728
1729   coneshape->Rmax(9)  = coneshape->GetRmax(8);
1730
1731   coneshape->Z(11)    = kConeZLength;
1732   coneshape->Rmin(11) = coneshape->GetRmin(10);
1733   coneshape->Rmax(11) = kConeCent2RCurv2;
1734
1735   // SSD Cone Insert: another Pcon
1736   Double_t x0, y0, x1, y1, x2, y2;
1737   TGeoPcon *coneinsertshape = new TGeoPcon(0.0,360.0,12);
1738
1739   coneinsertshape->Z(0)     = coneshape->GetZ(0) + kCFThickness;
1740   coneinsertshape->Rmin(0)  = coneshape->GetRmin(0) + kCFThickness;
1741   coneinsertshape->Rmax(0)  = coneshape->GetRmax(0) - kCFThickness;
1742
1743   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1744   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1745   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1746   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1747   coneinsertshape->Z(1)     = z;
1748   coneinsertshape->Rmin(1)  = rmin1;
1749   coneinsertshape->Rmax(1)  = coneinsertshape->GetRmax(0);
1750
1751   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmin(1);
1752   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmin(2);
1753   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmin(3);
1754   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1755   coneinsertshape->Z(2)     = z;
1756   coneinsertshape->Rmin(2)  = rmin1;
1757   coneinsertshape->Rmax(2)  = coneinsertshape->GetRmax(1);
1758
1759   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1760   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1761   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1762   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1763   coneinsertshape->Z(3)     = z;
1764   coneinsertshape->Rmin(3)  = rmin1;
1765   coneinsertshape->Rmax(3)  = coneinsertshape->GetRmax(2);
1766
1767   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
1768   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
1769   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
1770   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
1771   coneinsertshape->Z(4)     = z;
1772   coneinsertshape->Rmax(4)  = rmax;
1773
1774   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmax(4);
1775   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmax(5);
1776   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmax(6);
1777   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
1778   coneinsertshape->Z(5)     = z;
1779   coneinsertshape->Rmax(5)  = rmax;
1780
1781   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmax(5);
1782   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmax(6);
1783   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmax(7);
1784   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
1785   coneinsertshape->Z(6)     = z;
1786   coneinsertshape->Rmax(6)  = rmax;
1787
1788   x0 = coneshape->GetZ(6); y0 = coneshape->GetRmin(6);
1789   x1 = coneshape->GetZ(7); y1 = coneshape->GetRmin(7);
1790   x2 = coneshape->GetZ(8); y2 = coneshape->GetRmin(8);
1791   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1792   coneinsertshape->Z(7)     = z;
1793   coneinsertshape->Rmin(7)  = rmin1;
1794
1795   coneinsertshape->Rmin(4)  = RminFrom2Points(coneinsertshape,3,7,
1796                                               coneinsertshape->GetZ(4));
1797
1798   coneinsertshape->Rmin(5)  = RminFrom2Points(coneinsertshape,3,7,
1799                                               coneinsertshape->GetZ(5));
1800
1801   coneinsertshape->Rmin(6)  = coneinsertshape->GetRmin(5);
1802
1803   x0 = coneshape->GetZ(7); y0 = coneshape->GetRmin(7);
1804   x1 = coneshape->GetZ(8); y1 = coneshape->GetRmin(8);
1805   x2 = coneshape->GetZ(9); y2 = coneshape->GetRmin(9);
1806   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1807   coneinsertshape->Z(8)     = z;
1808   coneinsertshape->Rmin(8)  = rmin1;
1809
1810   x0 = coneshape->GetZ( 8); y0 = coneshape->GetRmin( 8);
1811   x1 = coneshape->GetZ( 9); y1 = coneshape->GetRmin( 9);
1812   x2 = coneshape->GetZ(10); y2 = coneshape->GetRmin(10);
1813   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
1814   coneinsertshape->Z(9)     = z;
1815   coneinsertshape->Rmin(9)  = rmin1;
1816
1817   x0 = coneshape->GetZ( 9); y0 = coneshape->GetRmax( 9);
1818   x1 = coneshape->GetZ(10); y1 = coneshape->GetRmax(10);
1819   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmax(11);
1820   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
1821   coneinsertshape->Z(10)    = z;
1822   coneinsertshape->Rmax(10) = rmax;
1823   coneinsertshape->Rmin(10) = coneinsertshape->GetRmin(9);
1824
1825   coneinsertshape->Rmax(7)  = RmaxFrom2Points(coneinsertshape,6,10,
1826                                               coneinsertshape->GetZ(7));
1827
1828   coneinsertshape->Rmax(8)  = RmaxFrom2Points(coneinsertshape,6,10,
1829                                               coneinsertshape->GetZ(8));
1830
1831   coneinsertshape->Rmax(9)  = coneinsertshape->GetRmax(8);
1832
1833   x0 = coneshape->GetZ(10); y0 = coneshape->GetRmax(10);
1834   x1 = coneshape->GetZ(11); y1 = coneshape->GetRmax(11);
1835   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmin(11);
1836   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
1837   coneinsertshape->Z(11)    = z;
1838   coneinsertshape->Rmax(11) = rmax;
1839   coneinsertshape->Rmin(11) = coneinsertshape->GetRmin(10);
1840
1841   // SSD Cone Foams: two other Pcon's
1842   TGeoPcon *conefoam1shape = new TGeoPcon(0.0, 360.0, 4);
1843
1844   conefoam1shape->Z(0)    = coneinsertshape->GetZ(3);
1845   conefoam1shape->Rmin(0) = coneinsertshape->GetRmin(3);
1846   conefoam1shape->Rmax(0) = conefoam1shape->GetRmin(0);
1847
1848   conefoam1shape->Rmax(1) = conefoam1shape->GetRmax(0);
1849   conefoam1shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
1850                                            conefoam1shape->GetRmax(1));
1851   conefoam1shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
1852                                            conefoam1shape->GetZ(1));
1853
1854   Double_t t = kConeThickness - 2*kCFThickness;
1855   conefoam1shape->Rmin(2) = conefoam1shape->GetRmax(0) -
1856                            (kConeFoam1Length*kCosConeTheta - t*kSinConeTheta);
1857   conefoam1shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
1858                                            conefoam1shape->GetRmin(2));
1859   conefoam1shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
1860                                            conefoam1shape->GetZ(2));
1861
1862   conefoam1shape->Rmin(3) = conefoam1shape->GetRmin(2);
1863   conefoam1shape->Rmax(3) = conefoam1shape->GetRmin(3);
1864   conefoam1shape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
1865                                            conefoam1shape->GetRmax(3));
1866
1867   TGeoPcon *conefoam2shape = new TGeoPcon(0.0, 360.0, 4);
1868
1869   conefoam2shape->Z(3)    = coneinsertshape->GetZ(10);
1870   conefoam2shape->Rmin(3) = coneinsertshape->GetRmax(10);
1871   conefoam2shape->Rmax(3) = conefoam2shape->GetRmin(3);
1872
1873   conefoam2shape->Rmin(2) = conefoam2shape->GetRmin(3);
1874   conefoam2shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
1875                                            conefoam2shape->GetRmin(2));
1876   conefoam2shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
1877                                            conefoam2shape->GetZ(2));
1878
1879   conefoam2shape->Rmin(0) = conefoam2shape->GetRmax(2) +
1880                            (kConeFoam2Length*kCosConeTheta - t*kSinConeTheta);
1881   conefoam2shape->Rmax(0) = conefoam2shape->GetRmin(0);
1882   conefoam2shape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
1883                                            conefoam2shape->GetRmin(0));
1884
1885   conefoam2shape->Rmax(1) = conefoam2shape->GetRmax(0);
1886   conefoam2shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
1887                                            conefoam2shape->GetRmax(1));
1888   conefoam2shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
1889                                            conefoam2shape->GetZ(1));
1890
1891   // SSD Cone Holes: Pcon's
1892   // A single hole volume gives an overlap with coneinsert, so
1893   // three contiguous volumes are created: one to be put in coneinsert
1894   // and two in the cone carbon fiber envelope
1895   Double_t holePhi;
1896   holePhi = (kCoolingHoleWidth/kCoolingHoleRmin)*TMath::RadToDeg();
1897
1898   TGeoPcon *coolingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
1899
1900   coolingholeshape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
1901   coolingholeshape->Rmax(0) = coolingholeshape->GetRmin(0);
1902   coolingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
1903                                              coolingholeshape->GetRmin(0));
1904
1905   coolingholeshape->Rmax(1) = coolingholeshape->GetRmax(0);
1906   coolingholeshape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
1907                                              coolingholeshape->GetRmax(1));
1908   coolingholeshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
1909                                              coolingholeshape->GetZ(1));
1910
1911   coolingholeshape->Rmin(2) = kCoolingHoleRmin;
1912   coolingholeshape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
1913                                              coolingholeshape->GetRmin(2));
1914   coolingholeshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
1915                                              coolingholeshape->GetZ(2));
1916
1917   coolingholeshape->Rmin(3) = coolingholeshape->GetRmin(2);
1918   coolingholeshape->Rmax(3) = coolingholeshape->GetRmin(3);
1919   coolingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
1920                                              coolingholeshape->GetRmax(3));
1921
1922   TGeoPcon *coolinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1923
1924   coolinghole2shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
1925   coolinghole2shape->Rmax(0) = coolinghole2shape->GetRmin(0);
1926   coolinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
1927                                               coolinghole2shape->GetRmin(0));
1928
1929   coolinghole2shape->Rmax(1) = coolinghole2shape->GetRmax(0);
1930   coolinghole2shape->Z(1)    = coolingholeshape->GetZ(0);
1931   coolinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
1932                                               coolinghole2shape->GetZ(1));
1933
1934   coolinghole2shape->Rmin(2) = kCoolingHoleRmin;
1935   coolinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
1936                                               coolinghole2shape->GetRmin(2));
1937   coolinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
1938                                               coolinghole2shape->GetZ(2));
1939
1940   coolinghole2shape->Rmin(3) = coolinghole2shape->GetRmin(2);
1941   coolinghole2shape->Rmax(3) = coolinghole2shape->GetRmin(3);
1942   coolinghole2shape->Z(3)    = coolingholeshape->GetZ(2);
1943
1944   TGeoPcon *coolinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1945
1946   coolinghole3shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
1947   coolinghole3shape->Rmax(0) = coolinghole3shape->GetRmin(0);
1948   coolinghole3shape->Z(0)    = coolingholeshape->GetZ(1);
1949
1950   coolinghole3shape->Rmax(1) = coolinghole3shape->GetRmax(0);
1951   coolinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
1952                                               coolinghole3shape->GetRmax(1));
1953   coolinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
1954                                               coolinghole3shape->GetZ(1));
1955
1956   coolinghole3shape->Rmin(2) = kCoolingHoleRmin;
1957   coolinghole3shape->Z(2)    = coolingholeshape->GetZ(3);
1958   coolinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
1959                                               coolinghole3shape->GetZ(2));
1960
1961   coolinghole3shape->Rmin(3) = coolinghole3shape->GetRmin(2);
1962   coolinghole3shape->Rmax(3) = coolinghole3shape->GetRmin(3);
1963   coolinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
1964                                               coolinghole3shape->GetRmax(3));
1965
1966   //
1967   holePhi = (kMountingHoleWidth/kMountingHoleRmin)*TMath::RadToDeg();
1968
1969   TGeoPcon *mountingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
1970
1971   mountingholeshape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
1972   mountingholeshape->Rmax(0) = mountingholeshape->GetRmin(0);
1973   mountingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
1974                                               mountingholeshape->GetRmin(0));
1975
1976   mountingholeshape->Rmin(1) = kMountingHoleRmin;
1977   mountingholeshape->Rmax(1) = mountingholeshape->GetRmax(0);
1978   mountingholeshape->Z(1)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
1979                                               mountingholeshape->GetRmin(1));
1980
1981   mountingholeshape->Rmin(2) = mountingholeshape->GetRmin(1);
1982   mountingholeshape->Rmax(2) = mountingholeshape->GetRmax(1);
1983   mountingholeshape->Z(2)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
1984                                               mountingholeshape->GetRmax(2));
1985
1986   mountingholeshape->Rmin(3) = mountingholeshape->GetRmin(2);
1987   mountingholeshape->Rmax(3) = mountingholeshape->GetRmin(3);
1988   mountingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
1989                                               mountingholeshape->GetRmax(3));
1990
1991   TGeoPcon *mountinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
1992
1993   mountinghole2shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
1994   mountinghole2shape->Rmax(0) = mountingholeshape->GetRmin(0);
1995   mountinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
1996                                                mountinghole2shape->GetRmin(0));
1997
1998   mountinghole2shape->Rmax(1) = mountinghole2shape->GetRmax(0);
1999   mountinghole2shape->Z(1)    = mountingholeshape->Z(0);
2000   mountinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2001                                                mountinghole2shape->GetZ(1));
2002
2003   mountinghole2shape->Rmin(2) = kMountingHoleRmin;
2004   mountinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2005                                                mountinghole2shape->GetRmin(2));
2006   mountinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2007                                                mountinghole2shape->GetZ(2));
2008
2009   mountinghole2shape->Rmin(3) = mountinghole2shape->Rmin(2);
2010   mountinghole2shape->Rmax(3) = mountinghole2shape->Rmin(3);
2011   mountinghole2shape->Z(3)    = mountingholeshape->Z(1);
2012
2013   TGeoPcon *mountinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2014
2015   mountinghole3shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2016   mountinghole3shape->Rmax(0) = mountingholeshape->GetRmin(0);
2017   mountinghole3shape->Z(0)    = mountingholeshape->GetZ(2);
2018
2019   mountinghole3shape->Rmax(1) = mountinghole3shape->GetRmax(0);
2020   mountinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2021                                                mountinghole3shape->GetRmax(1));
2022   mountinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2023                                                mountinghole3shape->GetZ(1));
2024
2025   mountinghole3shape->Rmin(2) = kMountingHoleRmin;
2026   mountinghole3shape->Z(2)    = mountingholeshape->Z(3);
2027   mountinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2028                                                mountinghole3shape->GetZ(2));
2029
2030   mountinghole3shape->Rmin(3) = mountinghole3shape->Rmin(2);
2031   mountinghole3shape->Rmax(3) = mountinghole3shape->Rmin(3);
2032   mountinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2033                                                mountinghole3shape->GetRmax(3));
2034
2035   // The Cable Hole is even more complicated, a Composite Shape
2036   // is unavoidable here (gosh!)
2037   TGeoPcon *coneshapecopy = new TGeoPcon("conecopy",0.0, 360.0, 12);
2038
2039   for (Int_t i=0; i<12; i++) {
2040     coneshapecopy->Rmin(i) = coneshape->GetRmin(i);
2041     coneshapecopy->Rmax(i) = coneshape->GetRmax(i);
2042     coneshapecopy->Z(i)    = coneshape->GetZ(i);
2043   }
2044
2045   holePhi = (kCableHoleWidth/kCableHoleRout)*TMath::RadToDeg();
2046   TGeoConeSeg *chCS = new TGeoConeSeg("chCS", 0.5*kConeZLength,
2047                                       kCableHoleRin, kCableHoleRout,
2048                                       kCableHoleRin, kCableHoleRout,
2049                                       -0.5*holePhi, 0.5*holePhi);
2050
2051   TGeoCompositeShape *cableholeshape = new TGeoCompositeShape(
2052                                            "SSDCableHoleShape",
2053                                            "conecopy*chCS");
2054
2055   if(GetDebug(1)){
2056     chCS->InspectShape();
2057     cableholeshape->InspectShape();
2058   }
2059
2060   // SSD Cone Wings: Tube and TubeSeg shapes
2061   Double_t angleWideWing, angleWideWingThickness;
2062   angleWideWing = (kWingWidth/kWingRmax)*TMath::RadToDeg();
2063   angleWideWingThickness = (kCFThickness/kWingRmax)*TMath::RadToDeg();
2064
2065   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kConeROuterMax, kWingRmax,
2066                                            kWingHalfThick,
2067                                            0, angleWideWing);
2068
2069   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kConeROuterMax,
2070                                  kWingRmax-kCFThickness,
2071                                  kWingHalfThick-kCFThickness,
2072                                  angleWideWingThickness,
2073                                  angleWideWing-angleWideWingThickness);
2074
2075   // SDD support plate, SSD side (Mounting Bracket): a TubeSeg
2076   TGeoTubeSeg *bracketshape = new TGeoTubeSeg(kBracketRmin, kBracketRmax,
2077                             kBracketHalfLength, -kBracketPhi/2, kBracketPhi/2);
2078
2079
2080   // We have the shapes: now create the real volumes
2081
2082   TGeoVolume *cfcone = new TGeoVolume("SSDCarbonFiberCone",
2083                                       coneshape,medSSDcf);
2084   cfcone->SetVisibility(kTRUE);
2085   cfcone->SetLineColor(4); // Blue
2086   cfcone->SetLineWidth(1);
2087   cfcone->SetFillColor(cfcone->GetLineColor());
2088   cfcone->SetFillStyle(4000); // 0% transparent
2089
2090   TGeoVolume *cfconeinsert = new TGeoVolume("SSDCarbonFiberConeInsert",
2091                                             coneinsertshape,medSSDste);
2092   cfconeinsert->SetVisibility(kTRUE);
2093   cfconeinsert->SetLineColor(2); // Red
2094   cfconeinsert->SetLineWidth(1);
2095   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2096   cfconeinsert->SetFillStyle(4050); // 50% transparent
2097
2098   TGeoVolume *cfconefoam1 = new TGeoVolume("SSDCarbonFiberConeFoam1",
2099                                             conefoam1shape,medSSDroh);
2100   cfconefoam1->SetVisibility(kTRUE);
2101   cfconefoam1->SetLineColor(3); // Green
2102   cfconefoam1->SetLineWidth(1);
2103   cfconefoam1->SetFillColor(cfconefoam1->GetLineColor());
2104   cfconefoam1->SetFillStyle(4050); // 50% transparent
2105
2106   TGeoVolume *cfconefoam2 = new TGeoVolume("SSDCarbonFiberConeFoam2",
2107                                             conefoam2shape,medSSDroh);
2108   cfconefoam2->SetVisibility(kTRUE);
2109   cfconefoam2->SetLineColor(3); // Green
2110   cfconefoam2->SetLineWidth(1);
2111   cfconefoam2->SetFillColor(cfconefoam2->GetLineColor());
2112   cfconefoam2->SetFillStyle(4050); // 50% transparent
2113
2114   TGeoVolume *coolinghole = new TGeoVolume("SSDCoolingHole",
2115                                            coolingholeshape,medSSDair);
2116   coolinghole->SetVisibility(kTRUE);
2117   coolinghole->SetLineColor(5); // Yellow
2118   coolinghole->SetLineWidth(1);
2119   coolinghole->SetFillColor(coolinghole->GetLineColor());
2120   coolinghole->SetFillStyle(4090); // 90% transparent
2121
2122   TGeoVolume *coolinghole2 = new TGeoVolume("SSDCoolingHole2",
2123                                             coolinghole2shape,medSSDair);
2124   coolinghole2->SetVisibility(kTRUE);
2125   coolinghole2->SetLineColor(5); // Yellow
2126   coolinghole2->SetLineWidth(1);
2127   coolinghole2->SetFillColor(coolinghole2->GetLineColor());
2128   coolinghole2->SetFillStyle(4090); // 90% transparent
2129
2130   TGeoVolume *coolinghole3 = new TGeoVolume("SSDCoolingHole3",
2131                                             coolinghole3shape,medSSDair);
2132   coolinghole3->SetVisibility(kTRUE);
2133   coolinghole3->SetLineColor(5); // Yellow
2134   coolinghole3->SetLineWidth(1);
2135   coolinghole3->SetFillColor(coolinghole3->GetLineColor());
2136   coolinghole3->SetFillStyle(4090); // 90% transparent
2137
2138   TGeoVolume *mountinghole = new TGeoVolume("SSDMountingHole",
2139                                             mountingholeshape,medSSDair);
2140   mountinghole->SetVisibility(kTRUE);
2141   mountinghole->SetLineColor(5); // Yellow
2142   mountinghole->SetLineWidth(1);
2143   mountinghole->SetFillColor(mountinghole->GetLineColor());
2144   mountinghole->SetFillStyle(4090); // 90% transparent
2145
2146   TGeoVolume *mountinghole2 = new TGeoVolume("SSDMountingHole2",
2147                                              mountinghole2shape,medSSDair);
2148   mountinghole2->SetVisibility(kTRUE);
2149   mountinghole2->SetLineColor(5); // Yellow
2150   mountinghole2->SetLineWidth(1);
2151   mountinghole2->SetFillColor(mountinghole2->GetLineColor());
2152   mountinghole2->SetFillStyle(4090); // 90% transparent
2153
2154   TGeoVolume *mountinghole3 = new TGeoVolume("SSDMountingHole3",
2155                                              mountinghole3shape,medSSDair);
2156   mountinghole3->SetVisibility(kTRUE);
2157   mountinghole3->SetLineColor(5); // Yellow
2158   mountinghole3->SetLineWidth(1);
2159   mountinghole3->SetFillColor(mountinghole3->GetLineColor());
2160   mountinghole3->SetFillStyle(4090); // 90% transparent
2161
2162   TGeoVolume *wing = new TGeoVolume("SSDWing",wingshape,medSSDcf);
2163   wing->SetVisibility(kTRUE);
2164   wing->SetLineColor(4); // Blue
2165   wing->SetLineWidth(1);
2166   wing->SetFillColor(wing->GetLineColor());
2167   wing->SetFillStyle(4000); // 0% transparent
2168
2169   TGeoVolume *cablehole = new TGeoVolume("SSDCableHole",
2170                                          cableholeshape,medSSDair);
2171   cablehole->SetVisibility(kTRUE);
2172   cablehole->SetLineColor(5); // Yellow
2173   cablehole->SetLineWidth(1);
2174   cablehole->SetFillColor(cablehole->GetLineColor());
2175   cablehole->SetFillStyle(4090); // 90% transparent
2176
2177   TGeoVolume *winginsert = new TGeoVolume("SSDWingInsert",
2178                                           winginsertshape,medSSDste);
2179   winginsert->SetVisibility(kTRUE);
2180   winginsert->SetLineColor(2); // Red
2181   winginsert->SetLineWidth(1);
2182   winginsert->SetFillColor(winginsert->GetLineColor());
2183   winginsert->SetFillStyle(4050); // 50% transparent
2184
2185   TGeoVolume *bracket = new TGeoVolume("SSDMountingBracket",
2186                                        bracketshape,medSSDal);
2187   bracket->SetVisibility(kTRUE);
2188   bracket->SetLineColor(6); // Purple
2189   bracket->SetLineWidth(1);
2190   bracket->SetFillColor(bracket->GetLineColor());
2191   bracket->SetFillStyle(4000); // 0% transparent
2192
2193   // Mount up a cone
2194   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
2195     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
2196     cfconefoam2->AddNode(mountinghole,i+1, new TGeoRotation("", phiH, 0, 0));
2197   }
2198
2199   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
2200     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
2201     cfconeinsert->AddNodeOverlap(coolinghole,i+1, new TGeoRotation("", phiH, 0, 0));
2202   }
2203
2204   cfconeinsert->AddNode(cfconefoam1,1,0);
2205   cfconeinsert->AddNode(cfconefoam2,1,0);
2206
2207   cfcone->AddNode(cfconeinsert,1,0);
2208
2209   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
2210     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
2211     cfcone->AddNode(coolinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
2212     cfcone->AddNode(coolinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
2213     cfcone->AddNodeOverlap(cablehole,i+1, new TGeoRotation("", phiH, 0, 0));
2214   }
2215
2216   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
2217     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
2218     cfcone->AddNode(mountinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
2219     cfcone->AddNode(mountinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
2220   }
2221
2222   wing->AddNode(winginsert,1,0);
2223
2224   // Add all volumes in the Cone assembly
2225   vC->AddNode(cfcone,1,new TGeoTranslation(0,0,-kConeZPosition));
2226
2227   for (Int_t i=0; i<4; i++) {
2228     Double_t thetaW = kThetaWing + 90.*i;
2229     vC->AddNode(wing, i+1, new TGeoCombiTrans(0, 0, -kConeZPosition, 
2230                            new TGeoRotation("",thetaW,180,0)));
2231   }
2232
2233   Double_t zBracket = kConeZPosition - coneshape->GetZ(9) +
2234                       2*bracketshape->GetDz();
2235   for (Int_t i=0; i<3; i++) {
2236     Double_t thetaB = 60 + 120.*i;
2237     vC->AddNode(bracket, i+1, new TGeoCombiTrans(0, 0, -zBracket,
2238                               new TGeoRotation("",thetaB,0,0)));
2239   }
2240
2241   // Finally put everything in the mother volume
2242   moth->AddNode(cfcylinder,1,0);
2243
2244   moth->AddNode(vC, 1, 0 );
2245   moth->AddNode(vC, 2, new TGeoRotation("",180, 180, 0) );
2246
2247   // Some debugging if requested
2248   if(GetDebug(1)){
2249     vC->PrintNodes();
2250     vC->InspectShape();
2251   }
2252
2253   return;
2254 }
2255
2256 //______________________________________________________________________
2257 void AliITSv11GeometrySupport::ServicesCableSupport(TGeoVolume *moth,
2258                                                     TGeoManager *mgr){
2259     // Define the detail ITS cable support trays on both the RB24 and 
2260     // RB26 sides..
2261     // Inputs:
2262     //   TGeoVolume  *moth  The mother volume to place this object.
2263     //   TGeoManager *mgr   A pointer to the Geo-Manager default gGeoManager
2264     // Outputs:
2265     //  none.
2266     // Return:
2267     //  none.
2268     // Based on the Drawings SSup_201A.jpg unless otherwise stated, 
2269     // Volumes A..., 
2270     TGeoMedium *medSUPcf    = 0; // SUP support cone Carbon Fiber materal nbr.
2271     TGeoMedium *medSUPfs    = 0; // SUP support cone inserto stesalite 4411w.
2272     TGeoMedium *medSUPfo    = 0; // SUP support cone foam, Rohacell 50A.
2273     TGeoMedium *medSUPss    = 0; // SUP support cone screw material,Stainless
2274     TGeoMedium *medSUPair   = 0; // SUP support cone Air
2275     TGeoMedium *medSUPal    = 0; // SUP support cone SDD mounting bracket Al
2276     TGeoMedium *medSUPwater = 0; // SUP support cone Water
2277     medSUPcf    = mgr->GetMedium("ITSssdCarbonFiber");
2278     medSUPfs    = mgr->GetMedium("ITSssdStaselite4411w");
2279     medSUPfo    = mgr->GetMedium("ITSssdRohacell50A");
2280     medSUPss    = mgr->GetMedium("ITSssdStainlessSteal");
2281     medSUPair   = mgr->GetMedium("ITSssdAir");
2282     medSUPal    = mgr->GetMedium("ITSssdAl");
2283     medSUPwater = mgr->GetMedium("ITSssdWater");
2284     //
2285     Int_t i,j,iRmin;
2286     Double_t x,y,z,t,t0,dt,di,r,l,local[3],master[3];
2287     Char_t name[100];
2288     Double_t r1,r2,m;
2289     // RB 24, Open Side.
2290     const Double_t kfrm24Z0           = 900*fgkmm;//SSup_203A.jpg
2291     const Double_t kfrm24Thss         = 5.0*fgkmm;
2292     const Double_t kfrm24Rss          = 444.5*fgkmm-kfrm24Thss; //SSup_204A.jpg
2293     const Double_t kfrm24Width        = 10.0*fgkmm;
2294     const Double_t kfrm24Hight        = 10.0*fgkmm;
2295     const Double_t kfrm24Phi0         = 15.2*fgkDegree; // SSup_602A.jpg
2296     const Double_t kfrm24Phi1         = (90.0-7.6)*fgkDegree; // SSup_802A.jpg
2297     const Double_t kfrm24ZssSection   = (415.0-10.0)*fgkmm;
2298     const Int_t    kfrm24NZsections   = 4;
2299     const Int_t    kfrm24NPhiSections = 4;
2300     const Int_t    kfrm24NPhi         = 4;
2301     // These numbers are guessed at.
2302     const Double_t kfrm24ZfracAngle   =  0.55; // frational z length to brack
2303     const Double_t kfrm24Angle        =  10.0*fgkDegree; // Guessed at
2304     //
2305     TGeoTubeSeg *sA24[kfrm24NZsections+1];
2306     TGeoArb8    *sB24[kfrm24NZsections+1];
2307     Double_t zA24[kfrm24NZsections+1];
2308     l = 4.*kfrm24ZssSection+5*kfrm24Width;
2309     j = iRmin = 0;
2310     for(i=0;i<kfrm24NZsections+1;i++){
2311         sprintf(name,"ITS sup Cable tray support frame radial section A24[%d]",
2312                 i);
2313         r1 = kfrm24Rss;
2314         if(i==0) zA24[i] = kfrm24Width;
2315         else zA24[i] = zA24[i-1] + kfrm24ZssSection + kfrm24Width;
2316         if(zA24[i]>l*kfrm24ZfracAngle){ // break, radii get larger
2317             r1 = kfrm24Rss + (zA24[i]-kfrm24ZfracAngle*l)*SinD(kfrm24Angle);
2318         } // end if
2319         r2 = r1+kfrm24Thss;
2320         sA24[i] = new TGeoTubeSeg(name,r1,r2,0.5*kfrm24Width,kfrm24Phi0,
2321                                   kfrm24Phi1);
2322         if(i>0)if(sA24[i-1]->GetRmin()==sA24[i]->GetRmin()) j = iRmin = i;
2323     } // end for i
2324     for(i=0;i<kfrm24NZsections;i++){
2325         sprintf(name,"ITS sup Cable tray support frame Z section B24[%d]",i);
2326         sB24[i] = new TGeoArb8(name,0.5*kfrm24ZssSection);
2327         sB24[i]->SetVertex(0,sA24[i]->GetRmin(),0.5*kfrm24Hight);
2328         sB24[i]->SetVertex(1,sA24[i]->GetRmax(),0.5*kfrm24Hight);
2329         sB24[i]->SetVertex(2,sA24[i]->GetRmin(),-0.5*kfrm24Hight);
2330         sB24[i]->SetVertex(3,sA24[i]->GetRmax(),-0.5*kfrm24Hight);
2331         sB24[i]->SetVertex(4,sA24[i+1]->GetRmin(),0.5*kfrm24Hight);
2332         sB24[i]->SetVertex(5,sA24[i+1]->GetRmax(),0.5*kfrm24Hight);
2333         sB24[i]->SetVertex(6,sA24[i+1]->GetRmin(),-0.5*kfrm24Hight);
2334         sB24[i]->SetVertex(7,sA24[i+1]->GetRmax(),-0.5*kfrm24Hight);
2335     } // end for i
2336     if(GetDebug(1)){
2337         for(i=0;i<kfrm24NZsections+1;i++) sA24[i]->InspectShape();
2338         for(i=0;i<kfrm24NZsections;i++)   sB24[i]->InspectShape();
2339     } // end if GetDebug(1)
2340     TGeoVolume *vA24[kfrm24NZsections+1],*vB24[kfrm24NZsections];
2341     TGeoVolumeAssembly *vM24;
2342     TGeoTranslation *tran;
2343     TGeoRotation    *rot,*rot1;
2344     TGeoCombiTrans  *tranrot;
2345     //
2346     for(i=0;i<kfrm24NZsections+1;i++){
2347         vA24[i] = 0;
2348         sprintf(name,"ITSsupFrameA24[%d]",i);
2349         vA24[i] = new TGeoVolume(name,sA24[i],medSUPss);
2350         vA24[i]->SetVisibility(kTRUE);
2351         vA24[i]->SetLineColor(1); // black
2352         vA24[i]->SetLineWidth(1);
2353         vA24[i]->SetFillColor(vA24[i]->GetLineColor());
2354         vA24[i]->SetFillStyle(4000); // 0% transparent
2355     } // end for i
2356     for(i=0;i<kfrm24NZsections;i++){
2357         vB24[i] = 0;
2358         sprintf(name,"ITSsupFrameB24[%d]",i);
2359         vB24[i] = new TGeoVolume(name,sB24[i],medSUPss);
2360         vB24[i]->SetVisibility(kTRUE);
2361         vB24[i]->SetLineColor(1); // black
2362         vB24[i]->SetLineWidth(1);
2363         vB24[i]->SetFillColor(vB24[i]->GetLineColor());
2364         vB24[i]->SetFillStyle(4000); // 0% transparent
2365     } // end for i
2366     vM24 = new TGeoVolumeAssembly("ITSsupFrameM24");
2367     //vM24->SetVisibility(kTRUE);
2368     //vM24->SetLineColor(7); // light blue
2369     //vM24->SetLineWidth(1);
2370     //vM24->SetFillColor(vM24->GetLineColor());
2371     //vM24->SetFillStyle(4090); // 90% transparent
2372     //
2373     Int_t ncopyB24[kfrm24NPhiSections];
2374     t0 = kfrm24Phi0;
2375     dt = (kfrm24Phi1-kfrm24Phi0)/((Double_t)kfrm24NPhiSections);
2376     for(i=0;i<=kfrm24NZsections;i++){
2377         z = zA24[i];
2378         tran = new TGeoTranslation("",0.0,0.0,z);
2379         vM24->AddNode(vA24[i],1,tran);
2380        if(i<kfrm24NZsections){
2381            ncopyB24[i] = 1;
2382            for(j=0;j<=kfrm24NPhiSections;j++){
2383                t = t0 + ((Double_t)j)*dt;
2384                rot = new TGeoRotation("",0.0,0.0,t);
2385                tranrot = new TGeoCombiTrans("",0.0,0.0,z+sB24[i]->GetDz(),rot);
2386                //delete rot;// rot not explicity used in AddNode functions.
2387                vM24->AddNode(vB24[i],ncopyB24[i]++,tranrot);
2388            } // end for j
2389        } // end if
2390     } // end for i
2391     tran = new TGeoTranslation("",0.0,0.0,kfrm24Z0);
2392     moth->AddNode(vM24,1,tran);
2393     for(i=1;i<kfrm24NPhi;i++){
2394         di = (Double_t) i;
2395         rot = new TGeoRotation("",0.0,0.0,90.0*di);
2396         tranrot = new TGeoCombiTrans("",0.0,0.0,kfrm24Z0,rot);
2397         //delete rot;// rot not explicity used in AddNode functions.
2398         moth->AddNode(vM24,i+1,tranrot);
2399     } // end for i
2400     if(GetDebug(1)){
2401         for(i=0;i<kfrm24NZsections+1;i++) vA24[i]->PrintNodes();
2402         for(i=0;i<kfrm24NZsections;i++) vB24[i]->PrintNodes();
2403         vM24->PrintNodes();
2404     } // end if
2405     //==================================================================
2406     // RB24 Cable Tray
2407     const Double_t kct24WidthBottom   = 44.0*fgkmm; // Serv-C_208.jpg
2408     const Double_t kct24WidthTop      = 46.0*fgkmm; // Serv-C_208.jpg
2409     const Double_t kct24Hight         = 51.0*fgkmm; // Serv-C_208.jpg
2410     const Double_t kct24AlThick       = 1.0*fgkmm; // Serv-C_208.jpg
2411     const Double_t kct24CapWidth      = 46.0*fgkmm; // Serv-C_208.jpg
2412     const Double_t kct24CapEar        = 5.0*fgkmm; // Guess
2413     const Double_t kct24Rmin          = 455.0*fgkmm; // Serv-C_203.jpg
2414     const Double_t kct24CoolSectionH  = 470.0*fgkmm-kct24Rmin;// Serv-C_203.jpg
2415     const Double_t kct24CoolCableDivEar = 2.0*fgkmm; // Guess
2416     const Int_t kct24Ntrays           = 48; // Serv-C_205.jpg
2417     //const Int_t kct24Ntubes           = 3; // Serv-C_208.jpg
2418     // Patch Pannels for RB 24 side
2419     const Double_t kft24PPHightSPDFMD = 72.0*fgkmm; // Serv-C_SPD/FMD.jpg
2420     const Double_t kft24PPHightSDDSSD = 104.0*fgkmm; // Serv-C_SDD/SSD.jpg
2421     const Double_t kft24PPlength      = 350.0*fgkmm;//Serv-C_SPD/SDD/SSD/FMD_1.jpg
2422     const Double_t kft24Theta         = 2.0*TMath::ATan2(kct24WidthBottom,
2423                                                  2.0*kct24Rmin)*fgkRadian; //
2424     const Int_t    kft24NPatchPannels = 20; //
2425     //
2426     Double_t xp[12],yp[12];
2427     TGeoPcon *sMT24;
2428     TGeoXtru *sT24,*sTs24,*sTl24,*sTt24,*sU24,*sVl24,*sVs24,*sW24;
2429     TGeoXtru *s3PP24,*s2PP24,*sV3PP24,*sV2PP24;
2430     // Outer Tray Full
2431     sT24 = new TGeoXtru(3);
2432     sT24->SetName("ITS sup Full Cable Tray for RB24 Side T24");
2433     xp[0]  = -0.5*kct24WidthBottom;
2434     yp[0]  = sA24[0]->GetRmax();
2435     yp[1]  = yp[0] + kct24Hight-kct24CapEar;
2436     xp[1]  = Xfrom2Points(xp[0],yp[0],-0.5*kct24WidthTop+kct24AlThick,
2437                           yp[0]+kct24Hight,yp[1]);
2438     yp[2]  = yp[1];
2439     xp[2]  = xp[1]-kct24AlThick;
2440     xp[3]  = -0.5*kct24CapWidth;
2441     yp[3]  = yp[0] + kct24Hight;
2442     xp[4]  = -xp[3];
2443     yp[4]  =  yp[3];
2444     xp[5]  = -xp[2];
2445     yp[5]  =  yp[2];
2446     xp[6]  = -xp[1];
2447     yp[6]  =  yp[1];
2448     xp[7]  = -xp[0];
2449     yp[7]  =  yp[0];
2450     sT24->DefinePolygon(8,xp,yp);
2451     sT24->DefineSection(0,zA24[0]-kfrm24Width,0.0,0.0,1.0);
2452     sT24->DefineSection(1,zA24[iRmin],0.0,0.0,1.0);
2453     sT24->DefineSection(2,zA24[kfrm24NZsections]+kfrm24Width,0.0,
2454                       sA24[kfrm24NZsections]->GetRmax()-sA24[0]->GetRmin());
2455     // RB 24 full tray no divider (for ALG and T0-V0 cables?)
2456     sW24 = new TGeoXtru(3);
2457     sW24->SetName("ITS sup Cable Tray No Divider for RB24 Side W24");
2458     xp[0] = sT24->GetX(0) + kct24AlThick;
2459     yp[0] = sT24->GetY(0) + kct24AlThick;
2460     yp[1] = sT24->GetY(3) - kct24AlThick;
2461     xp[1] = Xfrom2Points(sT24->GetX(0),sT24->GetY(0),sT24->GetX(1),
2462                          sT24->GetY(1),yp[1]) + kct24AlThick;
2463     xp[2] = -xp[1];
2464     yp[2] =  yp[1];
2465     xp[3] = -xp[0];
2466     yp[3] =  yp[0];
2467     sW24->DefinePolygon(4,xp,yp);
2468     for(i=0;i<sT24->GetNz();i++){
2469         sW24->DefineSection(i,sT24->GetZ(i),sT24->GetXOffset(i),
2470                             sT24->GetYOffset(i),sT24->GetScale(i));
2471     } // end for i
2472     // Outer Tray Short
2473     sTs24 = new TGeoXtru(3);
2474     sTs24->SetName("ITS sup Short Cable Tray for RB24 Side Ts24");
2475     yp[0]  = sT24->GetY(0) + kct24CoolSectionH;
2476     xp[0]  = Xfrom2Points(sT24->GetX(0),sT24->GetY(0),sT24->GetX(1),
2477                          sT24->GetY(1),yp[0]);
2478     for(i=1;i<7;i++){
2479         xp[i]  = sT24->GetX(i);
2480         yp[i]  = sT24->GetY(i);
2481     } // end for i
2482     xp[7]  = -xp[0];
2483     yp[7]  =  yp[0];
2484     sTs24->DefinePolygon(8,xp,yp);
2485     sTs24->DefineSection(0,zA24[0] -kfrm24Width+kft24PPlength);
2486     sTs24->DefineSection(1,zA24[iRmin]);
2487     sTs24->DefineSection(2,zA24[kfrm24NZsections]+kfrm24Width,
2488                          sT24->GetXOffset(2),
2489                          sT24->GetYOffset(2),sT24->GetScale(2));
2490     // Outer Tray Long
2491     sTl24 = new TGeoXtru(3);
2492     sTl24->SetName("ITS sup Long Cable Tray for RB24 Side Tl24");
2493     for(i=0;i<8;i++){
2494     xp[i]  = sTs24->GetX(i);
2495     yp[i]  = sTs24->GetY(i);
2496     } // End for i
2497     sTl24->DefinePolygon(8,xp,yp);
2498     sTl24->DefineSection(0,zA24[0]-kfrm24Width,0.0,0.0,1.0);
2499     sTl24->DefineSection(1,zA24[iRmin],0.0,0.0,1.0);
2500     sTl24->DefineSection(2,zA24[kfrm24NZsections]+kfrm24Width,0.0,
2501                      sA24[kfrm24NZsections]->GetRmax()-sA24[0]->GetRmin(),1.0);
2502     // Outer Tray for air Tubes
2503     sTt24 = new TGeoXtru(3);
2504     sTt24->SetName("ITS sup Long Air Tube Tray for RB24 Side Tt24");
2505     xp[0]  = sT24->GetX(0);
2506     yp[0]  = sT24->GetY(0);
2507     xp[1]  = sTl24->GetX(0);
2508     yp[1]  = sTl24->GetY(0);
2509     xp[2]  = -xp[1];
2510     yp[2]  =  yp[1];
2511     xp[3]  = -xp[0];
2512     yp[3]  =  yp[0];
2513     sTt24->DefinePolygon(4,xp,yp);
2514     sTt24->DefineSection(0,zA24[0]-kfrm24Width,0.0,0.0,1.0);
2515     sTt24->DefineSection(1,zA24[iRmin],0.0,0.0,1.0);
2516     sTt24->DefineSection(2,zA24[kfrm24NZsections]+kfrm24Width,0.0,
2517                          sA24[kfrm24NZsections]->GetRmax()-sA24[0]->GetRmin());
2518     // Inner opening for cooling (lower) {inside sTt24}
2519     sU24 = new TGeoXtru(3);
2520     sU24->SetName("ITS sup Cable Tray Cooling tube space RB24 Side U24");
2521     xp[0] = sTt24->GetX(0) + kct24AlThick;
2522     yp[0] = sTt24->GetY(0) + kct24AlThick;
2523     xp[1] = sTt24->GetX(1) + kct24AlThick;
2524     yp[1] = sTt24->GetY(1) - kct24AlThick;
2525     xp[2] = -xp[1];
2526     yp[2] =  yp[1];
2527     xp[3] = -xp[0];
2528     yp[3] =  yp[0];
2529     sU24->DefinePolygon(4,xp,yp);
2530     for(i=0;i<sTt24->GetNz();i++){
2531         sU24->DefineSection(i,sTt24->GetZ(i),sTt24->GetXOffset(i),
2532                             sTt24->GetYOffset(i),sTt24->GetScale(i));
2533     } // end for i
2534     // Inner opening for cables (upper) {inside sTl24}
2535     sVl24 = new TGeoXtru(3);
2536     sVl24->SetName("ITS sup Cable Tray Cable space RB24 Side Vl24");
2537     xp[0] = sTl24->GetX(0)+2.0*kct24AlThick;
2538     yp[0] = sTl24->GetY(0);
2539     yp[1] = yp[0] + kct24CoolCableDivEar;
2540     xp[1] = Xfrom2Points(sTl24->GetX(0),sTl24->GetY(0),
2541                          sTl24->GetX(1),sTl24->GetY(1),yp[1])+2.0*kct24AlThick;
2542     yp[2] = yp[1];
2543     xp[2] = xp[1] - kct24AlThick;
2544     yp[3] = sTl24->GetY(3) - kct24AlThick;
2545     xp[3] = Xfrom2Points(sTl24->GetX(0),sTl24->GetY(0),sTl24->GetX(1),
2546                          sTl24->GetY(1),yp[3]) + kct24AlThick;
2547     xp[4] = -xp[3];
2548     yp[4] =  yp[3];
2549     xp[5] = -xp[2];
2550     yp[5] =  yp[2];
2551     xp[6] = -xp[1];
2552     yp[6] =  yp[1];
2553     xp[7] = -xp[0];
2554     yp[7] =  yp[0];
2555     sVl24->DefinePolygon(8,xp,yp);
2556     for(i=0;i<sTl24->GetNz();i++){
2557         sVl24->DefineSection(i,sTl24->GetZ(i),sTl24->GetXOffset(i),
2558                             sTl24->GetYOffset(i),sTl24->GetScale(i));
2559     } // end for i
2560     // Inner opening for cables (upper) {inside sTs24}
2561     sVs24 = new TGeoXtru(3);
2562     sVs24->SetName("ITS sup Cable Tray Cable space RB24 Side Vs24");
2563     sVs24->DefinePolygon(8,xp,yp);
2564     for(i=0;i<8;i++){
2565     xp[i]  = sVl24->GetX(i);
2566     yp[i]  = sVl24->GetY(i);
2567     } // end for i
2568     for(i=0;i<sTl24->GetNz();i++){
2569         sVs24->DefineSection(i,sTs24->GetZ(i),sTs24->GetXOffset(i),
2570                             sTs24->GetYOffset(i),sTs24->GetScale(i));
2571     } // end for i
2572     //------------------------------------------------------------------
2573     // Patch Pannels on RB 24 Side
2574     rot  = new TGeoRotation("",0.0,0.0,-kft24Theta); // Gets Used later as well
2575     rot1 = new TGeoRotation("",0.0,0.0,kft24Theta);  // Gets Used later as well
2576     s3PP24 = new TGeoXtru(2);
2577     s3PP24->SetName("ITS sup 3 bay pach pannel RB24 side 3PP24");
2578     yp[5]  = sT24->GetY(7) + kct24CoolSectionH;
2579     xp[5]  = Xfrom2Points(sT24->GetX(7),sT24->GetY(7),sT24->GetX(6),
2580                           sT24->GetY(6),yp[6]);
2581     yp[6]  = sT24->GetY(0) + kct24CoolSectionH;
2582     xp[6]  =  Xfrom2Points(sT24->GetX(0),sT24->GetY(0),sT24->GetX(1),
2583                           sT24->GetY(1),yp[9]);
2584     local[0] = xp[6]; local[1] = yp[6]; local[2] = 0.0;
2585     rot1->LocalToMaster(local,master);
2586     xp[0]  = master[0];
2587     yp[0]  = master[1];
2588     local[0] = xp[6]; local[1] = yp[6] + kft24PPHightSDDSSD; local[2] = 0.0;
2589     rot1->LocalToMaster(local,master);
2590     xp[1]  = master[0];
2591     yp[1]  = master[1];
2592     xp[2]  = -xp[1];
2593     yp[2]  =  yp[1];
2594     xp[3]  = -xp[0];
2595     yp[3]  =  yp[0];
2596     local[0] = xp[6]; local[1] = yp[6]; local[2] = 0.0;
2597     rot1->MasterToLocal(local,master);
2598     xp[4]  = master[0];
2599     yp[4]  = master[1];
2600     local[0] = xp[5]; local[1] = yp[5]; local[2] = 0.0;
2601     rot1->LocalToMaster(local,master);
2602     xp[7]  = master[0];
2603     yp[7]  = master[1];
2604     s3PP24->DefinePolygon(8,xp,yp);
2605     s3PP24->DefineSection(0,0.0);
2606     s3PP24->DefineSection(1,kft24PPlength);
2607     //
2608     s2PP24 = new TGeoXtru(2);
2609     s2PP24->SetName("ITS sup 2 bay pach pannel RB24 side 2PP24");
2610     local[1] = sTl24->GetY(3); local[2] = 0.0;
2611     local[0] = Xfrom2Points(sTl24->GetX(0),sTl24->GetY(0),
2612                             sTl24->GetX(1),sTl24->GetY(1),local[1]);
2613     rot1->LocalToMaster(local,master);
2614     xp[0]  = master[0];
2615     yp[0]  = master[1];
2616     local[1] = sTl24->GetY(3) + kft24PPHightSPDFMD; local[2] = 0.0;
2617     local[0] = Xfrom2Points(sTl24->GetX(0),sTl24->GetY(0),
2618                             sTl24->GetX(1),sTl24->GetY(1),local[1]);
2619     rot1->LocalToMaster(local,master);
2620     xp[1]  = master[0];
2621     yp[1]  = master[1];
2622     yp[2]  = sTl24->GetY(4) + kft24PPHightSPDFMD;
2623     xp[2]  = Xfrom2Points(sTl24->GetX(6),sTl24->GetY(6),
2624                           sTl24->GetX(7),sTl24->GetY(7),yp[2]);
2625     yp[3]  = sTl24->GetY(7);
2626     xp[3]  = Xfrom2Points(sTl24->GetX(6),sTl24->GetY(6),
2627                           sTl24->GetX(7),sTl24->GetY(7),yp[3]);
2628     xp[4]  = sTl24->GetX(3);
2629     yp[4]  = sTl24->GetY(3);
2630     local[0] = sTl24->GetX(4);local[1] = sTl24->GetY(4); local[2] = 0.0;
2631     rot1->LocalToMaster(local,master);
2632     xp[5]  = master[0];
2633     yp[5]  = master[1];
2634     s2PP24->DefinePolygon(6,xp,yp);
2635     s2PP24->DefineSection(0,0.0);
2636     s2PP24->DefineSection(1,kft24PPlength);
2637     //
2638     sV3PP24 = new TGeoXtru(2);
2639     sV3PP24->SetName("ITS sup Patch Pannel 3 Bay inside Rb24 side V3PP24");
2640     xp[0] = s3PP24->GetX(0) + kct24AlThick;
2641     yp[0] = s3PP24->GetY(0) + kct24AlThick;
2642     local[1] = s3PP24->GetY(6) + kft24PPHightSDDSSD - kct24AlThick;local[2]=0.;
2643     local[0] = Xfrom2Points(sTl24->GetX(0),sTl24->GetY(0),
2644                            sTl24->GetX(1),sTl24->GetY(1),local[1]);
2645     rot1->LocalToMaster(local,master);
2646     xp[1] = master[0];
2647     yp[1] = master[1];
2648     xp[2] = -xp[1];
2649     yp[2] =  yp[1];
2650     xp[3] = -xp[0];
2651     yp[3] =  yp[0];
2652     xp[4] = s3PP24->GetX(4);
2653     yp[4] = s3PP24->GetY(4);
2654     xp[5] = s3PP24->GetX(5);
2655     yp[5] = s3PP24->GetY(5);
2656     xp[6] = s3PP24->GetX(6);
2657     yp[6] = s3PP24->GetY(6);
2658     xp[7] = s3PP24->GetX(7);
2659     yp[7] = s3PP24->GetY(7);
2660     sV3PP24->DefinePolygon(8,xp,yp);
2661     sV3PP24->DefineSection(0,s3PP24->GetZ(0),s3PP24->GetXOffset(0),
2662                            s3PP24->GetYOffset(0),s3PP24->GetScale(0));
2663     sV3PP24->DefineSection(1,s3PP24->GetZ(1),s3PP24->GetXOffset(1),
2664                            s3PP24->GetYOffset(1),s3PP24->GetScale(1));
2665     //
2666     sV2PP24 = new TGeoXtru(2);
2667     sV2PP24->SetName("ITS sup Patch Pannel 2 Bay inside Rb24 side V2PP24");
2668     xp[0] = s2PP24->GetX(0) + kct24AlThick;
2669     yp[0] = s2PP24->GetY(0) + kct24AlThick;
2670     local[1] = sTl24->GetY(3) + kft24PPHightSPDFMD - kct24AlThick;local[2]=0.;
2671     local[0] = Xfrom2Points(sTl24->GetX(0),sTl24->GetY(0),
2672                            sTl24->GetX(1),sTl24->GetY(1),local[1]);
2673     rot1->LocalToMaster(local,master);
2674     xp[1] = master[0];
2675     yp[1] = master[1];
2676     yp[2] = sTl24->GetY(4) + kft24PPHightSPDFMD - kct24AlThick;
2677     xp[2] = Xfrom2Points(sTl24->GetX(6),sTl24->GetY(6),
2678                            sTl24->GetX(7),sTl24->GetY(7),yp[2]);
2679     yp[3] = sTl24->GetY(4);
2680     xp[3] = Xfrom2Points(sTl24->GetX(6),sTl24->GetY(6),
2681                            sTl24->GetX(7),sTl24->GetY(7),yp[3]);;
2682     xp[4] = s2PP24->GetX(4);
2683     yp[4] = s2PP24->GetY(4);
2684     xp[5] = s2PP24->GetX(5);
2685     yp[5] = s2PP24->GetY(5);
2686     sV2PP24->DefinePolygon(6,xp,yp);
2687     sV2PP24->DefineSection(0,s2PP24->GetZ(0),s2PP24->GetXOffset(0),
2688                            s2PP24->GetYOffset(0),s2PP24->GetScale(0));
2689     sV2PP24->DefineSection(1,s2PP24->GetZ(1),s2PP24->GetXOffset(1),
2690                            s2PP24->GetYOffset(1),s2PP24->GetScale(1));
2691     // RB 24 Tray Mother Volume
2692     sMT24 = new TGeoPcon("ITS sup Cable Tray Mother Volume RB24 MT24",
2693                          0.0,360.0,5);
2694     sMT24->Z(0)    = 0.0;
2695     sMT24->Rmin(0) = sA24[0]->GetRmax();
2696     sMT24->Rmax(0) = TMath::Max(TMath::Hypot(s3PP24->GetX(1),s3PP24->GetY(1)),
2697                                 TMath::Hypot(s2PP24->GetX(1),s2PP24->GetY(1)));
2698
2699     sMT24->Z(1)    = sMT24->GetZ(0) + kft24PPlength;
2700     sMT24->Rmin(1) = sMT24->GetRmin(0);
2701     sMT24->Rmax(1) = sMT24->GetRmax(0);
2702     sMT24->Z(2)    = sMT24->GetZ(1);
2703     sMT24->Rmin(2) = sMT24->GetRmin(0);
2704     sMT24->Rmax(2) = sMT24->GetRmax(0) - kft24PPHightSPDFMD;
2705
2706     sMT24->Z(3)    = sMT24->GetZ(0) + zA24[iRmin] - zA24[0] -kfrm24Width;
2707     sMT24->Rmin(3) = sA24[iRmin]->GetRmin();
2708     sMT24->Rmax(3) = TMath::Hypot(sT24->GetX(3),sT24->GetY(3));
2709     sMT24->Z(4)    = sMT24->GetZ(0) + zA24[kfrm24NZsections] + kfrm24Width  - 
2710         zA24[0] -kfrm24Width;
2711     sMT24->Rmin(4) = sA24[kfrm24NZsections]->GetRmax();
2712     sMT24->Rmax(4) = TMath::Hypot(sT24->GetX(3)+sT24->GetXOffset(2),
2713                                   sT24->GetY(3)+sT24->GetYOffset(2));
2714     //
2715     if(GetDebug(1)){
2716         sT24->InspectShape();
2717         sW24->InspectShape();
2718         sTl24->InspectShape();
2719         sTs24->InspectShape();
2720         sTt24->InspectShape();
2721         sU24->InspectShape();
2722         sVl24->InspectShape();
2723         sVs24->InspectShape();
2724         s3PP24->InspectShape();
2725         s2PP24->InspectShape();
2726         sV3PP24->InspectShape();
2727         sV2PP24->InspectShape();
2728         sMT24->InspectShape();
2729     } // end if GetDebug(1)
2730     //
2731     TGeoVolume *vC24[kct24Ntrays],*vT24[kct24Ntrays],*vPP24[kft24NPatchPannels];
2732     TGeoVolume *vWTV024,*vW24,*vU24,*vUFMD24,*vVl24,*vVlFMD24,*vVs24;
2733     TGeoVolume *vV3PP24,*vV2PP24,*vV2PPFMD24;
2734     TGeoVolumeAssembly *vMT24;
2735     vMT24 = new TGeoVolumeAssembly("ITSsupCableTrayMotherMT24");
2736     //vMT24->SetVisibility(kTRUE);
2737     //vMT24->SetLineColor(8); // white
2738     //vMT24->SetLineWidth(1);
2739     //vMT24->SetFillColor(vMT24->GetLineColor());
2740     //vMT24->SetFillStyle(4100); // 100% transparent
2741     //
2742     vU24 = new TGeoVolume("ITSsupCableTrayLowerU24",sU24,medSUPair);
2743     vU24->SetVisibility(kTRUE);
2744     vU24->SetLineColor(7); // light blue
2745     vU24->SetLineWidth(1);
2746     vU24->SetFillColor(vU24->GetLineColor());
2747     vU24->SetFillStyle(4090); // 90% transparent
2748     vUFMD24 = new TGeoVolume("FMDsupCableTrayLowerU24",sU24,medSUPair);
2749     vUFMD24->SetVisibility(kTRUE);
2750     vUFMD24->SetLineColor(7); // light blue
2751     vUFMD24->SetLineWidth(1);
2752     vUFMD24->SetFillColor(vUFMD24->GetLineColor());
2753     vUFMD24->SetFillStyle(4090); // 90% transparent
2754     vVl24 = new TGeoVolume("ITSsupCableTrayUpperV24",sVl24,medSUPair);
2755     vVl24->SetVisibility(kTRUE);
2756     vVl24->SetLineColor(7); // light blue
2757     vVl24->SetLineWidth(1);
2758     vVl24->SetFillColor(vVl24->GetLineColor());
2759     vVl24->SetFillStyle(4090); // 90% transparent
2760     vVlFMD24 = new TGeoVolume("FMDsupCableTrayUpperVl24",sVl24,medSUPair);
2761     vVlFMD24->SetVisibility(kTRUE);
2762     vVlFMD24->SetLineColor(7); // light blue
2763     vVlFMD24->SetLineWidth(1);
2764     vVlFMD24->SetFillColor(vVlFMD24->GetLineColor());
2765     vVlFMD24->SetFillStyle(4090); // 90% transparent
2766     vVs24 = new TGeoVolume("ITSsupCableTrayUpperVs24",sVs24,medSUPair);
2767     vVs24->SetVisibility(kTRUE);
2768     vVs24->SetLineColor(7); // light blue
2769     vVs24->SetLineWidth(1);
2770     vVs24->SetFillColor(vVs24->GetLineColor());
2771     vVs24->SetFillStyle(4090); // 90% transparent
2772     vW24 = new TGeoVolume("ITSsupCableTrayUpperW24",sW24,medSUPair);
2773     vW24->SetVisibility(kTRUE);
2774     vW24->SetLineColor(7); // light blue
2775     vW24->SetLineWidth(1);
2776     vW24->SetFillColor(vW24->GetLineColor());
2777     vW24->SetFillStyle(4090); // 90% transparent
2778     //
2779     vWTV024 = new TGeoVolume("V0supCableTrayUpperWTV024",sW24,medSUPair);
2780     vWTV024->SetVisibility(kTRUE);
2781     vWTV024->SetLineColor(7); // light blue
2782     vWTV024->SetLineWidth(1);
2783     vWTV024->SetFillColor(vWTV024->GetLineColor());
2784     vWTV024->SetFillStyle(4090); // 90% transparent
2785     //
2786     vV3PP24 = new TGeoVolume("ITSsup3BayPachPannelInsideV3PP24",sV3PP24,medSUPair);
2787     vV3PP24->SetVisibility(kTRUE);
2788     vV3PP24->SetLineColor(8); // white
2789     vV3PP24->SetLineWidth(1);
2790     vV3PP24->SetFillColor(vV3PP24->GetLineColor());
2791     vV3PP24->SetFillStyle(4100); // 100% transparent
2792     vV2PP24 = new TGeoVolume("ITSsup2BayPachPannelInsideV2PP24",sV2PP24,medSUPair);
2793     vV2PP24->SetVisibility(kTRUE);
2794     vV2PP24->SetLineColor(8); // white
2795     vV2PP24->SetLineWidth(1);
2796     vV2PP24->SetFillColor(vV2PP24->GetLineColor());
2797     vV2PP24->SetFillStyle(4100); // 100% transparent
2798     vV2PPFMD24 = new TGeoVolume("FMDsup2BayPachPannelInsideV2PP24",sV2PP24,medSUPair);
2799     vV2PPFMD24->SetVisibility(kTRUE);
2800     vV2PPFMD24->SetLineColor(8); // white
2801     vV2PPFMD24->SetLineWidth(1);
2802     vV2PPFMD24->SetFillColor(vV2PPFMD24->GetLineColor());
2803     vV2PPFMD24->SetFillStyle(4100); // 100% transparent
2804     //
2805     //delete rot;
2806     //delete rot1;
2807     //
2808     Double_t tha[kct24Ntrays],thb[kft24NPatchPannels];
2809     for(i=0;i<kct24Ntrays/4;i++) {
2810         if(i==0) tha[0] = 17.0+0.5*kft24Theta;
2811         else tha[i] = tha[i-1] + kft24Theta;
2812         tha[i+  kct24Ntrays/4] =  90.0 + tha[i];
2813         tha[i+  kct24Ntrays/2] = 180.0 + tha[i];
2814         tha[i+3*kct24Ntrays/4] = 270.0 + tha[i];
2815     } // end for i
2816     if(GetDebug(1)) for(i=0;i<kct24Ntrays;i++) Info("ServicesCableSupport",
2817                                                   "tha[%d]=%f",i,tha[i]);
2818     Char_t *airName[kct24Ntrays]={"FMD0","SDD0","SSD0","SSD1","SPD0","SPD1",
2819                                   "TV00","SDD1","SDD2","SPD2","SPD3","ALG0",
2820                                   "SPD4","SPD5","SSD2","SSD3","SPD6","SPD7",
2821                                   "TV01","SDD3","SDD4","SPD8","SPD9","ALG1",
2822                                   "FMD1","SDD5","SSD4","SSD5","SPDA","SPDB",
2823                                   "TV02","SDD6","SDD7","SPDC","SPDD","ALG2",
2824                                   "SPDE","SPDF","SSD6","SSD7","SPDG","SPDH",
2825                                   "TV03","SDD8","SDD9","SPDI","SPDJ","ALG3"};
2826     Char_t *trayName[kct24Ntrays]={"FMD0","SSD0","SSD1","SSD2","SSD3","SPD0",
2827                                    "TV00","SDD0","SDD1","SDD2","SPD1","ALG0",
2828                                    "SPD2","SSD4","SSD5","SSD6","SSD7","SPD3",
2829                                    "TV01","SDD3","SDD4","SDD5","SPD4","ALG1",
2830                                    "FMD1","SSD8","SSD9","SSDA","SSDB","SPD5",
2831                                    "TV02","SDD6","SDD7","SDD8","SPD6","ALG2",
2832                                    "SPD7","SSDC","SSDD","SSDE","SSDF","SPD8",
2833                                    "TV03","SDD9","SDDA","SDDB","SPD9","ALG3"};
2834     //
2835     //Int_t ncopyW24=1,ncopyU24=1,ncopyV24=1;
2836     j = 0;
2837     for(i=0;i<kct24Ntrays;i++){
2838         if(strncmp(trayName[i],"FMD",3)==0){
2839             sprintf(name,"FMDsupCableTrayT24[%s]",trayName[i]);
2840             vT24[i] = new TGeoVolume(name,sTl24,medSUPal);
2841             vT24[i]->AddNode(vVlFMD24,1,0);
2842         }else if(strncmp(trayName[i],"TV0",3)==0){
2843             sprintf(name,"V0supCableTrayT24[%s]",trayName[i]);
2844             vT24[i] = new TGeoVolume(name,sT24,medSUPal);
2845             vT24[i]->AddNode(vWTV024,1,0);
2846         }else if(strncmp(trayName[i],"ALG",3)==0){ // ITS Alignment Channel
2847             sprintf(name,"ITSsupCableTrayT24[%s]",trayName[i]);
2848             vT24[i] = new TGeoVolume(name,sT24,medSUPal);
2849             vT24[i]->AddNode(vW24,1,0);
2850         }else  if(strncmp(trayName[i],"SPD",3)==0){ /*ITS SPD*/
2851             sprintf(name,"ITSsupCableTrayT24[%s]",trayName[i]);
2852             vT24[i] = new TGeoVolume(name,sTl24,medSUPal);
2853             vT24[i]->AddNode(vVl24,1,0);
2854         }else { /*ITS*/
2855             sprintf(name,"ITSsupCableTrayT24[%s]",trayName[i]);
2856             vT24[i] = new TGeoVolume(name,sTs24,medSUPal); /// replace solid
2857             vT24[i]->AddNode(vVs24,1,0);
2858         } // end if
2859         vT24[i]->SetVisibility(kTRUE);
2860         vT24[i]->SetLineColor(6); // purple
2861         vT24[i]->SetLineWidth(1);
2862         vT24[i]->SetFillColor(vT24[i]->GetLineColor());
2863         vT24[i]->SetFillStyle(4000); // 0% transparent
2864         rot = new TGeoRotation("",0.0,0.0,tha[i]-90.0);
2865         if(GetDebug(1)) rot->Print();
2866         vMT24->AddNode(vT24[i],1,rot);
2867         //
2868         if(strncmp(trayName[i],"FMD",3)==0){
2869             sprintf(name,"FMDsupAirTubeTrayT24[%s]",airName[i]);
2870             vC24[j] = new TGeoVolume(name,sTt24,medSUPair);
2871             vC24[j]->AddNode(vUFMD24,1,0);
2872         }else if(strncmp(trayName[i],"TV0",3)==0){
2873             continue;
2874         }else if(strncmp(trayName[i],"ALG",3)==0){
2875             continue;
2876         }else{ /*ITS*/
2877             sprintf(name,"ITSsupAirTubTrayT24[%s]",airName[i]);
2878             vC24[j] = new TGeoVolume(name,sTt24,medSUPair);
2879             vC24[j]->AddNode(vU24,1,0);
2880         } // end if
2881         vC24[j]->SetVisibility(kTRUE);
2882         vC24[j]->SetLineColor(6); // purple
2883         vC24[j]->SetLineWidth(1);
2884         vC24[j]->SetFillColor(vC24[j]->GetLineColor());
2885         vC24[j]->SetFillStyle(4000); // 0% transparent
2886         vMT24->AddNode(vC24[j++],1,rot);
2887     } // end for i
2888     for(i=0;i<kft24NPatchPannels/4;i++) {
2889         if(i==0) thb[0] = 17.0+0.5*kft24Theta;
2890         else{
2891             if(i%2) thb[i] = thb[i-1] + 3.0*kft24Theta;
2892             else thb[i] = thb[i-1] + 2.0*kft24Theta;
2893         } // end if-else
2894         thb[i+  kft24NPatchPannels/4] =  90.0 + thb[i];
2895         thb[i+  kft24NPatchPannels/2] = 180.0 + thb[i];
2896         thb[i+3*kft24NPatchPannels/4] = 270.0 + thb[i];
2897     } // end for i
2898     Char_t *pachName[kft24NPatchPannels]={"FMD0","SSD0","SPD0","SDD0","SPD1",
2899                                           "SPD2","SSD1","SPD3","SDD1","SPD4",
2900                                           "FMD1","SSD2","SPD5","SDD2","SPD6",
2901                                           "SPD7","SSD3","SPD8","SDD3","SPD9"};
2902     for(i=0;i<kft24NPatchPannels;i++){
2903         if(strncmp(pachName[i],"FMD",3)==0){
2904             sprintf(name,"FMDsupPatchPannelPP24[%s]",pachName[i]);
2905             vPP24[i] = new TGeoVolume(name,s2PP24,medSUPal);
2906             vPP24[i]->AddNode(vV2PPFMD24,1,0);
2907         }else if(strncmp(pachName[i],"SPD",3)==0){ /*ITS SPD*/
2908             sprintf(name,"ITSsupPathcPannelPP24[%s]",pachName[i]);
2909             vPP24[i] = new TGeoVolume(name,s2PP24,medSUPal);
2910             vPP24[i]->AddNode(vV2PP24,1,0);
2911         }else { /*ITS*/
2912             sprintf(name,"ITSsupPathcPannelPP24[%s]",pachName[i]);
2913             vPP24[i] = new TGeoVolume(name,s3PP24,medSUPal); /// replace solid
2914             vPP24[i]->AddNode(vV3PP24,1,0);
2915         } // end if
2916         vPP24[i]->SetVisibility(kTRUE);
2917         vPP24[i]->SetLineColor(6); // purple
2918         vPP24[i]->SetLineWidth(1);
2919         vPP24[i]->SetFillColor(vPP24[i]->GetLineColor());
2920         vPP24[i]->SetFillStyle(4000); // 0% transparent
2921         rot = new TGeoRotation("",0.0,0.0,thb[i]-90.0);
2922         if(GetDebug(1)) rot->Print();
2923         vMT24->AddNode(vPP24[i],1,rot);
2924     } // end for i
2925     tran = new TGeoTranslation("",0.0,0.0,kfrm24Z0);
2926     moth->AddNode(vMT24,1,tran);
2927     if(GetDebug(1)){
2928         for(i=0;i<kct24Ntrays;i++) vT24[i]->PrintNodes();
2929         for(i=0;i<kct24Ntrays-8;i++) vC24[i]->PrintNodes();
2930         vU24->PrintNodes();
2931         vUFMD24->PrintNodes();
2932         vVl24->PrintNodes();
2933         vVlFMD24->PrintNodes();
2934         vVs24->PrintNodes();
2935         vW24->PrintNodes();
2936         vWTV024->PrintNodes();
2937         vMT24->PrintNodes();
2938     } // end if
2939     //==================================================================
2940     //
2941     // RB 26, Muon Absober side
2942     const Double_t kfrm26Z0           = -900*fgkmm;//SSup_203A.jpg
2943     const Double_t kfrm26Thss         = 5.0*fgkmm;
2944     const Double_t kfrm26R0ss         = 444.5*fgkmm-kfrm26Thss; //SSup_204A.jpg
2945     const Double_t kfrm26R1ss         = 601.6*fgkmm-kfrm26Thss; //SSup_208A.jpg
2946     const Double_t kfrm26Width        = 10.0*fgkmm;
2947     //const Double_t kfrm26Hight       = 10.0*fgkmm;
2948     const Double_t kfrm26Phi0         = 15.2*fgkDegree; // SSup_602A.jpg
2949     const Double_t kfrm26Phi1         = (90.0-7.6)*fgkDegree; // SSup_802A.jpg
2950     const Double_t kfrm26ZssSection   = (415.0-10.0)*fgkmm;
2951     const Int_t    kfrm26NZsections   = 4;
2952     const Int_t    kfrm26NPhiSections = 4;
2953     const Int_t    kfrm26NPhi         = 4;
2954     TGeoConeSeg *sA26[kfrm26NZsections+1];//,*sM26;//Cylinderial support structure
2955     TGeoArb8     *sB26; // Cylinderial support structure
2956     /*
2957     sM26 = new TGeoConeSeg("ITS sup Cable tray support frame mother volume "
2958                           "M26",0.5*(4.*kfrm26ZssSection+5*kfrm26Width),
2959                           kfrm26R1ss,kfrm26R1ss+kfrm26Thss,
2960                           kfrm26R0ss,kfrm26R0ss+kfrm26Thss,
2961                           kfrm26Phi0,kfrm26Phi1);
2962     */
2963     m = -((kfrm26R1ss-kfrm26R0ss)/
2964          (((Double_t)kfrm26NZsections)*(kfrm26ZssSection+kfrm26Width)));
2965     for(i=0;i<kfrm26NZsections+1;i++){
2966         di = ((Double_t) i)*(kfrm26ZssSection+kfrm26Width);
2967         sprintf(name,
2968                 "ITS sup Cable tray support frame radial section A26[%d]",i);
2969         r1 = kfrm26R1ss+m*di;
2970         r2 = kfrm26R1ss+m*(di+kfrm26Width);
2971         sA26[i] = new TGeoConeSeg(name,0.5*kfrm26Width,r2,r2+kfrm26Thss,
2972                                  r1,r1+kfrm26Thss,kfrm26Phi0,kfrm26Phi1);
2973     } // end for i
2974     sB26 = new TGeoArb8("ITS sup Cable tray support frame Z section B26",
2975                        0.5*kfrm26ZssSection);
2976     r = 0.25*(sA26[0]->GetRmax1()+sA26[0]->GetRmin1()+
2977               sA26[1]->GetRmax2()+sA26[1]->GetRmin2());
2978     sB26->SetVertex(0,sA26[0]->GetRmax2()-r,+0.5*kfrm26Width);
2979     sB26->SetVertex(1,sA26[0]->GetRmax2()-r,-0.5*kfrm26Width);
2980     sB26->SetVertex(2,sA26[0]->GetRmin2()-r,-0.5*kfrm26Width);
2981     sB26->SetVertex(3,sA26[0]->GetRmin2()-r,+0.5*kfrm26Width);
2982     sB26->SetVertex(4,sA26[1]->GetRmax1()-r,+0.5*kfrm26Width);
2983     sB26->SetVertex(5,sA26[1]->GetRmax1()-r,-0.5*kfrm26Width);
2984     sB26->SetVertex(6,sA26[1]->GetRmin1()-r,-0.5*kfrm26Width);
2985     sB26->SetVertex(7,sA26[1]->GetRmin1()-r,+0.5*kfrm26Width);
2986     if(GetDebug(1)){
2987         for(i=0;i<kfrm26NZsections+1;i++) sA26[i]->InspectShape();
2988         //sM26->InspectShape();
2989         sB26->InspectShape();
2990     } // end if GetDebug(1)
2991     //
2992     TGeoVolume *vA26[kfrm26NZsections+1],*vB26;
2993     TGeoVolumeAssembly *vM26;
2994     //
2995     for(i=0;i<kfrm26NZsections+1;i++){
2996         sprintf(name,"ITSsupFrameA26[%d]",i);
2997         vA26[i] = new TGeoVolume(name,sA26[i],medSUPss);
2998         vA26[i]->SetVisibility(kTRUE);
2999         vA26[i]->SetLineColor(1); // black
3000         vA26[i]->SetLineWidth(1);
3001         vA26[i]->SetFillColor(vA26[i]->GetLineColor());
3002         vA26[i]->SetFillStyle(4000); // 0% transparent
3003     } // end for i
3004     vB26 = new TGeoVolume("ITSsupFrameB26",sB26,medSUPss);
3005     vB26->SetVisibility(kTRUE);
3006     vB26->SetLineColor(1); // black
3007     vB26->SetLineWidth(1);
3008     vB26->SetFillColor(vB26->GetLineColor());
3009     vB26->SetFillStyle(4000); // 0% transparent
3010     vM26 = new TGeoVolumeAssembly("ITSsupFrameM26");
3011     //vM26 = new TGeoVolume("ITSsupFrameM26",sM26,medSUPair);
3012     //vM26->SetVisibility(kTRUE);
3013     //vM26->SetLineColor(7); // light blue
3014     //vM26->SetLineWidth(1);
3015     //vM26->SetFillColor(vM26->GetLineColor());
3016     //vM26->SetFillStyle(4090); // 90% transparent
3017     //
3018     Int_t ncopyB26=1;
3019     t0 = kfrm26Phi0;
3020     dt = (kfrm26Phi1-kfrm26Phi0)/((Double_t)kfrm26NPhiSections);
3021     for(i=0;i<=kfrm26NZsections;i++){
3022         di = ((Double_t) i)*(kfrm26ZssSection+kfrm26Width);
3023         z = 0.5*(4.*kfrm26ZssSection+5*kfrm26Width);
3024         z = -z+sA26[i]->GetDz() + di;
3025         tran = new TGeoTranslation("",0.0,0.0,z);
3026         vM26->AddNode(vA26[i],1,tran);
3027         z = z+sB26->GetDz();
3028         if(i<kfrm26NZsections)for(j=0;j<=kfrm26NPhiSections;j++){
3029             r = 0.25*(sA26[i]->GetRmax1()+sA26[i]->GetRmin1()+
3030                       sA26[i+1]->GetRmax2()+sA26[i+1]->GetRmin2());
3031             t = t0 + ((Double_t)j)*dt;
3032             rot = new TGeoRotation("",0.0,0.0,t);
3033             y = r*SinD(t);
3034             x = r*CosD(t);
3035             tranrot = new TGeoCombiTrans("",x,y,z,rot);
3036             //delete rot; // rot not explicity used in AddNode functions.
3037             vM26->AddNode(vB26,ncopyB26++,tranrot);
3038         } // end for j
3039     } // end for i
3040     tran = new TGeoTranslation("",0.0,0.0,kfrm26Z0-0.5*(4.*kfrm26ZssSection+5*kfrm26Width));
3041     moth->AddNode(vM26,1,tran);
3042     for(i=1;i<kfrm26NPhi;i++){
3043         rot = new TGeoRotation("",0.0,0.0,90.0*((Double_t)i));
3044         tranrot = new TGeoCombiTrans(*tran,*rot);
3045         //delete rot; // rot not explicity used in AddNode functions.
3046         moth->AddNode(vM26,i+1,tranrot);
3047     } // end for i
3048     if(GetDebug(1)){
3049         for(i=0;i<kfrm26NZsections+1;i++) vA26[i]->PrintNodes();
3050         vB26->PrintNodes();
3051         vM26->PrintNodes();
3052     } // end if
3053 }