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