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