]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySupport.cxx
This should have been removed a long time ago
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySupport.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // This class Defines the Geometry for the ITS services and support cones
17 // outside of the ceneteral volume (except for the Ceneteral support 
18 // cylinders. Other classes define the rest of the ITS. Specificaly the ITS
19 // The SSD support cone,SSD Support centeral cylinder, SDD support cone,
20 // The SDD cupport centeral cylinder, the SPD Thermal Sheald, The supports
21 // and cable trays on both the RB26 (muon dump) and RB24 sides, and all of
22 // the cabling from the ladders/stave ends out past the TPC. 
23
24 /* $Id$ */
25 // General Root includes
26 #include <TMath.h>
27 // Root Geometry includes
28 //#include <AliLog.h>
29 #include <TGeoManager.h>
30 #include <TGeoVolume.h>
31 #include <TGeoPcon.h>
32 #include <TGeoCone.h>
33 #include <TGeoTube.h> // contaings TGeoTubeSeg
34 #include <TGeoArb8.h>
35 #include <TGeoXtru.h>
36 #include <TGeoCompositeShape.h>
37 #include <TGeoMatrix.h>
38 #include "AliITSv11GeometrySupport.h"
39
40 ClassImp(AliITSv11GeometrySupport)
41
42 #define SQ(A) (A)*(A)
43
44 //______________________________________________________________________
45 void AliITSv11GeometrySupport::SPDCone(TGeoVolume *moth,const TGeoManager *mgr)
46 {
47 //
48 // Creates the SPD thermal shield as a volume assembly
49 // and adds it to the mother volume
50 // (this is actually a merge of the previous SPDThermalSheald method
51 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06 and the
52 // CreateSPDThermalShield method of AliITSv11Hybrid)
53 //
54 // Input:
55 //         moth : the TGeoVolume owing the volume structure
56 //         mgr  : the GeoManager (default gGeoManager)
57 // Output:
58 //
59 // Created:         ???          ???
60 // Updated:      11 Dec 2007  Mario Sitta
61 //
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  = 399.9*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 zpos;
108   Double_t xshld[24], yshld[24];
109   Double_t xair[24] , yair[24];  // Coord. of whole air shape
110   Double_t xair1[4] , yair1[4];  // Coord. of every single air volume
111   Double_t xomega[48], yomega[48];
112   //  Double_t *xyarb8;
113
114   // The entire shield is made up of two half central shields
115   // symmetric with respect to the XZ plane, four half end cap
116   // shields, again symmetric with respect to the XZ plane, and four
117   // half cones, symmetric with respect to the XZ plane too.
118
119   TGeoVolumeAssembly *vM = new TGeoVolumeAssembly("ITSspdThermalShield");
120
121   // The central half shield: a half tube of carbon fiber,
122   // filled with air volumes, which together make the whole shield
123   // (i.e. the tube and the Omega-shaped insert).
124   // They are all XTru shapes
125
126   TGeoXtru *centralshape = new TGeoXtru(2);
127
128   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
129                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
130                         kTheta,xshld,yshld);
131
132   centralshape->DefinePolygon(24,xshld,yshld);
133   centralshape->DefineSection(0,-kHalfLengthCentral);
134   centralshape->DefineSection(1, kHalfLengthCentral);
135
136   // Now rescale to get the air volume dimensions
137     InsidePoint(xshld[23], yshld[23],
138                 xshld[ 0], yshld[ 0],
139                 xshld[ 1], yshld[ 1], kThicknessCentral,
140                 xair[0], yair[0]);
141   for (Int_t i=1; i<23; i++) {
142     InsidePoint(xshld[i-1], yshld[i-1],
143                 xshld[ i ], yshld[ i ],
144                 xshld[i+1], yshld[i+1], kThicknessCentral,
145                 xair[i], yair[i]);
146   }
147     InsidePoint(xshld[22], yshld[22],
148                 xshld[23], yshld[23],
149                 xshld[ 0], yshld[ 0], kThicknessCentral,
150                 xair[23], yair[23]);
151
152   // Then use them to determine the Omega shape points
153   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
154
155   // Finally create the single air volumes
156   TGeoXtru *centralair1shape = new TGeoXtru(2);
157
158   xair1[0] = xomega[1];
159   yair1[0] = yomega[1];
160   xair1[1] = xomega[0];
161   yair1[1] = yomega[0];
162   xair1[2] = -xair1[1];
163   yair1[2] =  yair1[1];
164   xair1[3] = -xair1[0];
165   yair1[3] =  yair1[0];
166
167   centralair1shape->DefinePolygon(4,xair1,yair1);
168   centralair1shape->DefineSection(0,-kHalfLengthCentral);
169   centralair1shape->DefineSection(1, kHalfLengthCentral);
170
171   TGeoXtru *centralair2shape = new TGeoXtru(2);
172
173   xair1[0] = xomega[21];
174   yair1[0] = yomega[21];
175   xair1[1] = xomega[20];
176   yair1[1] = yomega[20];
177   xair1[2] = xomega[23];
178   yair1[2] = yomega[23];
179   xair1[3] = xomega[22];
180   yair1[3] = yomega[22];
181
182   centralair2shape->DefinePolygon(4,xair1,yair1);
183   centralair2shape->DefineSection(0,-kHalfLengthCentral);
184   centralair2shape->DefineSection(1, kHalfLengthCentral);
185
186   TGeoXtru *centralair3shape = new TGeoXtru(2);
187
188   xair1[0] = xomega[2];
189   yair1[0] = yomega[2];
190   xair1[1] = xomega[3];
191   yair1[1] = yomega[3];
192   xair1[2] = xomega[4];
193   yair1[2] = yomega[4];
194   xair1[3] = xomega[5];
195   yair1[3] = yomega[5];
196
197   centralair3shape->DefinePolygon(4,xair1,yair1);
198   centralair3shape->DefineSection(0,-kHalfLengthCentral);
199   centralair3shape->DefineSection(1, kHalfLengthCentral);
200
201   TGeoXtru *centralair4shape = new TGeoXtru(2);
202
203   xair1[0] = xomega[16];
204   yair1[0] = yomega[16];
205   xair1[1] = xomega[17];
206   yair1[1] = yomega[17];
207   xair1[2] = xomega[18];
208   yair1[2] = yomega[18];
209   xair1[3] = xomega[19];
210   yair1[3] = yomega[19];
211
212   centralair4shape->DefinePolygon(4,xair1,yair1);
213   centralair4shape->DefineSection(0,-kHalfLengthCentral);
214   centralair4shape->DefineSection(1, kHalfLengthCentral);
215
216   TGeoXtru *centralair5shape = new TGeoXtru(2);
217
218   xair1[0] = xomega[6];
219   yair1[0] = yomega[6];
220   xair1[1] = xomega[7];
221   yair1[1] = yomega[7];
222   xair1[2] = xomega[8];
223   yair1[2] = yomega[8];
224   xair1[3] = xomega[9];
225   yair1[3] = yomega[9];
226
227   centralair5shape->DefinePolygon(4,xair1,yair1);
228   centralair5shape->DefineSection(0,-kHalfLengthCentral);
229   centralair5shape->DefineSection(1, kHalfLengthCentral);
230
231   TGeoXtru *centralair6shape = new TGeoXtru(2);
232
233   xair1[0] = xomega[12];
234   yair1[0] = yomega[12];
235   xair1[1] = xomega[13];
236   yair1[1] = yomega[13];
237   xair1[2] = xomega[14];
238   yair1[2] = yomega[14];
239   xair1[3] = xomega[15];
240   yair1[3] = yomega[15];
241
242   centralair6shape->DefinePolygon(4,xair1,yair1);
243   centralair6shape->DefineSection(0,-kHalfLengthCentral);
244   centralair6shape->DefineSection(1, kHalfLengthCentral);
245
246
247   // The end cap half shield: a half tube of carbon fiber,
248   // filled with air volumes, which together make the whole shield
249   // (i.e. the tube and the Omega-shaped insert).
250   // They are all XTru shapes
251
252   TGeoXtru *endcapshape = new TGeoXtru(2);
253
254   CreateSPDThermalShape(kInnerAEndCap,kInnerBEndCap,kInnerRadiusEndCap,
255                         kOuterAEndCap,kOuterBEndCap,kOuterRadiusEndCap,
256                         kTheta,xshld,yshld);
257
258   endcapshape->DefinePolygon(24,xshld,yshld);
259   endcapshape->DefineSection(0,-kHalfLengthEndCap);
260   endcapshape->DefineSection(1, kHalfLengthEndCap);
261
262   // Now rescale to get the air volume dimensions
263     InsidePoint(xshld[23], yshld[23],
264                 xshld[ 0], yshld[ 0],
265                 xshld[ 1], yshld[ 1], kThicknessEndCap,
266                 xair[0], yair[0]);
267   for (Int_t i=1; i<23; i++) {
268     InsidePoint(xshld[i-1], yshld[i-1],
269                 xshld[ i ], yshld[ i ],
270                 xshld[i+1], yshld[i+1], kThicknessEndCap,
271                 xair[i], yair[i]);
272   }
273     InsidePoint(xshld[22], yshld[22],
274                 xshld[23], yshld[23],
275                 xshld[ 0], yshld[ 0], kThicknessEndCap,
276                 xair[23], yair[23]);
277
278   // Then use them to determine the Omega shape points
279   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
280
281   // Finally create the single air volumes
282   TGeoXtru *endcapair1shape = new TGeoXtru(2);
283
284   xair1[0] = xomega[1];
285   yair1[0] = yomega[1];
286   xair1[1] = xomega[0];
287   yair1[1] = yomega[0];
288   xair1[2] = -xair1[1];
289   yair1[2] =  yair1[1];
290   xair1[3] = -xair1[0];
291   yair1[3] =  yair1[0];
292
293   endcapair1shape->DefinePolygon(4,xair1,yair1);
294   endcapair1shape->DefineSection(0,-kHalfLengthEndCap);
295   endcapair1shape->DefineSection(1, kHalfLengthEndCap);
296
297   TGeoXtru *endcapair2shape = new TGeoXtru(2);
298
299   xair1[0] = xomega[21];
300   yair1[0] = yomega[21];
301   xair1[1] = xomega[20];
302   yair1[1] = yomega[20];
303   xair1[2] = xomega[23];
304   yair1[2] = yomega[23];
305   xair1[3] = xomega[22];
306   yair1[3] = yomega[22];
307
308   endcapair2shape->DefinePolygon(4,xair1,yair1);
309   endcapair2shape->DefineSection(0,-kHalfLengthEndCap);
310   endcapair2shape->DefineSection(1, kHalfLengthEndCap);
311
312   TGeoXtru *endcapair3shape = new TGeoXtru(2);
313
314   xair1[0] = xomega[2];
315   yair1[0] = yomega[2];
316   xair1[1] = xomega[3];
317   yair1[1] = yomega[3];
318   xair1[2] = xomega[4];
319   yair1[2] = yomega[4];
320   xair1[3] = xomega[5];
321   yair1[3] = yomega[5];
322
323   endcapair3shape->DefinePolygon(4,xair1,yair1);
324   endcapair3shape->DefineSection(0,-kHalfLengthEndCap);
325   endcapair3shape->DefineSection(1, kHalfLengthEndCap);
326
327   TGeoXtru *endcapair4shape = new TGeoXtru(2);
328
329   xair1[0] = xomega[16];
330   yair1[0] = yomega[16];
331   xair1[1] = xomega[17];
332   yair1[1] = yomega[17];
333   xair1[2] = xomega[18];
334   yair1[2] = yomega[18];
335   xair1[3] = xomega[19];
336   yair1[3] = yomega[19];
337
338   endcapair4shape->DefinePolygon(4,xair1,yair1);
339   endcapair4shape->DefineSection(0,-kHalfLengthEndCap);
340   endcapair4shape->DefineSection(1, kHalfLengthEndCap);
341
342   TGeoXtru *endcapair5shape = new TGeoXtru(2);
343
344   xair1[0] = xomega[6];
345   yair1[0] = yomega[6];
346   xair1[1] = xomega[7];
347   yair1[1] = yomega[7];
348   xair1[2] = xomega[8];
349   yair1[2] = yomega[8];
350   xair1[3] = xomega[9];
351   yair1[3] = yomega[9];
352
353   endcapair5shape->DefinePolygon(4,xair1,yair1);
354   endcapair5shape->DefineSection(0,-kHalfLengthEndCap);
355   endcapair5shape->DefineSection(1, kHalfLengthEndCap);
356
357   TGeoXtru *endcapair6shape = new TGeoXtru(2);
358
359   xair1[0] = xomega[12];
360   yair1[0] = yomega[12];
361   xair1[1] = xomega[13];
362   yair1[1] = yomega[13];
363   xair1[2] = xomega[14];
364   yair1[2] = yomega[14];
365   xair1[3] = xomega[15];
366   yair1[3] = yomega[15];
367
368   endcapair6shape->DefinePolygon(4,xair1,yair1);
369   endcapair6shape->DefineSection(0,-kHalfLengthEndCap);
370   endcapair6shape->DefineSection(1, kHalfLengthEndCap);
371
372   // The cone half shield is more complex since there is no basic
373   // TGeo shape to describe it correctly. So it is made of a series
374   // of TGeoArb8 shapes filled with air, which all together make up the
375   // the cone AND its internal insert. Part of the following code is
376   // adapted from SPDThermalSheald method.
377
378   // sCn : Filled portions, sChn : Air holes
379   TGeoArb8 *sC1  = new TGeoArb8(kHalfLengthCone);
380   TGeoArb8 *sC2  = new TGeoArb8(kHalfLengthCone);
381   TGeoArb8 *sC3  = new TGeoArb8(kHalfLengthCone);
382   TGeoArb8 *sC4  = new TGeoArb8(kHalfLengthCone);
383   TGeoArb8 *sC5  = new TGeoArb8(kHalfLengthCone);
384   TGeoArb8 *sC6  = new TGeoArb8(kHalfLengthCone);
385   TGeoArb8 *sC7  = new TGeoArb8(kHalfLengthCone);
386   TGeoArb8 *sC8  = new TGeoArb8(kHalfLengthCone);
387   TGeoArb8 *sC9  = new TGeoArb8(kHalfLengthCone);
388   TGeoArb8 *sC10 = new TGeoArb8(kHalfLengthCone);
389   TGeoArb8 *sC11 = new TGeoArb8(kHalfLengthCone);
390
391   sC1->SetName("sC1");
392   sC2->SetName("sC2");
393   sC3->SetName("sC3");
394   sC4->SetName("sC4");
395   sC5->SetName("sC5");
396   sC6->SetName("sC6");
397   sC7->SetName("sC7");
398   sC8->SetName("sC8");
399   sC9->SetName("sC9");
400   sC10->SetName("sC10");
401   sC11->SetName("sC11");
402
403   TGeoArb8 *sCh1  = new TGeoArb8(kHalfLengthCone);
404   TGeoArb8 *sCh2  = new TGeoArb8(kHalfLengthCone);
405   TGeoArb8 *sCh3  = new TGeoArb8(kHalfLengthCone);
406   TGeoArb8 *sCh4  = new TGeoArb8(kHalfLengthCone);
407   TGeoArb8 *sCh5  = new TGeoArb8(kHalfLengthCone);
408   TGeoArb8 *sCh6  = new TGeoArb8(kHalfLengthCone);
409   TGeoArb8 *sCh7  = new TGeoArb8(kHalfLengthCone);
410   TGeoArb8 *sCh8  = new TGeoArb8(kHalfLengthCone);
411   TGeoArb8 *sCh9  = new TGeoArb8(kHalfLengthCone);
412   TGeoArb8 *sCh10 = new TGeoArb8(kHalfLengthCone);
413   TGeoArb8 *sCh11 = new TGeoArb8(kHalfLengthCone);
414
415   sCh1->SetName("sCh1");
416   sCh2->SetName("sCh2");
417   sCh3->SetName("sCh3");
418   sCh4->SetName("sCh4");
419   sCh5->SetName("sCh5");
420   sCh6->SetName("sCh6");
421   sCh7->SetName("sCh7");
422   sCh8->SetName("sCh8");
423   sCh9->SetName("sCh9");
424   sCh10->SetName("sCh10");
425   sCh11->SetName("sCh11");
426
427   // Smaller end: determine the coordinates of the points of carbon fiber
428   CreateSPDThermalShape(kInnerACentral,kInnerBCentral,kInnerRadiusCentral,
429                         kOuterACentral,kOuterBCentral,kOuterRadiusCentral,
430                         kTheta,xshld,yshld);
431
432   sC1->SetVertex(0, xshld[12], yshld[12]);
433   sC1->SetVertex(1, xshld[11], yshld[11]);
434   sC1->SetVertex(2, xshld[ 0], yshld[ 0]);
435   sC1->SetVertex(3, xshld[23], yshld[23]);
436
437   sC2->SetVertex(0, xshld[11], yshld[11]);
438   sC2->SetVertex(1, xshld[10], yshld[10]);
439   sC2->SetVertex(2, xshld[ 1], yshld[ 1]);
440   sC2->SetVertex(3, xshld[ 0], yshld[ 0]);
441
442   sC3->SetVertex(0, xshld[10], yshld[10]);
443   sC3->SetVertex(1, xshld[ 9], yshld[ 9]);
444   sC3->SetVertex(2, xshld[ 2], yshld[ 2]);
445   sC3->SetVertex(3, xshld[ 1], yshld[ 1]);
446
447   sC4->SetVertex(0, xshld[ 9], yshld[ 9]);
448   sC4->SetVertex(1, xshld[ 8], yshld[ 8]);
449   sC4->SetVertex(2, xshld[ 3], yshld[ 3]);
450   sC4->SetVertex(3, xshld[ 2], yshld[ 2]);
451
452   sC5->SetVertex(0, xshld[ 8], yshld[ 8]);
453   sC5->SetVertex(1, xshld[ 7], yshld[ 7]);
454   sC5->SetVertex(2, xshld[ 4], yshld[ 4]);
455   sC5->SetVertex(3, xshld[ 3], yshld[ 3]);
456
457   sC6->SetVertex(0, xshld[ 7], yshld[ 7]);
458   sC6->SetVertex(1, xshld[ 6], yshld[ 6]);
459   sC6->SetVertex(2, xshld[ 5], yshld[ 5]);
460   sC6->SetVertex(3, xshld[ 4], yshld[ 4]);
461
462   sC7->SetVertex(0,-xshld[10], yshld[10]);
463   sC7->SetVertex(1,-xshld[11], yshld[11]);
464   sC7->SetVertex(2,-xshld[ 0], yshld[ 0]);
465   sC7->SetVertex(3,-xshld[ 1], yshld[ 1]);
466
467   sC8->SetVertex(0,-xshld[ 9], yshld[ 9]);
468   sC8->SetVertex(1,-xshld[10], yshld[10]);
469   sC8->SetVertex(2,-xshld[ 1], yshld[ 1]);
470   sC8->SetVertex(3,-xshld[ 2], yshld[ 2]);
471
472   sC9->SetVertex(0,-xshld[ 8], yshld[ 8]);
473   sC9->SetVertex(1,-xshld[ 9], yshld[ 9]);
474   sC9->SetVertex(2,-xshld[ 2], yshld[ 2]);
475   sC9->SetVertex(3,-xshld[ 3], yshld[ 3]);
476
477   sC10->SetVertex(0,-xshld[ 7], yshld[ 7]);
478   sC10->SetVertex(1,-xshld[ 8], yshld[ 8]);
479   sC10->SetVertex(2,-xshld[ 3], yshld[ 3]);
480   sC10->SetVertex(3,-xshld[ 4], yshld[ 4]);
481
482   sC11->SetVertex(0,-xshld[ 6], yshld[ 6]);
483   sC11->SetVertex(1,-xshld[ 7], yshld[ 7]);
484   sC11->SetVertex(2,-xshld[ 4], yshld[ 4]);
485   sC11->SetVertex(3,-xshld[ 5], yshld[ 5]);
486
487   // Then rescale to get the air volume dimensions
488     InsidePoint(xshld[23], yshld[23],
489                 xshld[ 0], yshld[ 0],
490                 xshld[ 1], yshld[ 1], kThicknessCone,
491                 xair[0], yair[0]);
492   for (Int_t i=1; i<23; i++) {
493     InsidePoint(xshld[i-1], yshld[i-1],
494                 xshld[ i ], yshld[ i ],
495                 xshld[i+1], yshld[i+1], kThicknessCone,
496                 xair[i], yair[i]);
497   }
498     InsidePoint(xshld[22], yshld[22],
499                 xshld[23], yshld[23],
500                 xshld[ 0], yshld[ 0], kThicknessCone,
501                 xair[23], yair[23]);
502
503   // Then use them to determine the Omega shape points
504   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
505
506   // Finally fill the small end coordinates of the air shapes
507   sCh1->SetVertex(0, xomega[ 0], yomega[ 0]);
508   sCh1->SetVertex(1, xomega[ 1], yomega[ 1]);
509   sCh1->SetVertex(2,-xomega[ 1], yomega[ 1]);
510   sCh1->SetVertex(3,-xomega[ 0], yomega[ 0]);
511
512   sCh2->SetVertex(0, xomega[20], yomega[20]);
513   sCh2->SetVertex(1, xomega[21], yomega[21]);
514   sCh2->SetVertex(2, xomega[22], yomega[22]);
515   sCh2->SetVertex(3, xomega[23], yomega[23]);
516
517   sCh3->SetVertex(0, xomega[ 2], yomega[ 2]);
518   sCh3->SetVertex(1, xomega[ 3], yomega[ 3]);
519   sCh3->SetVertex(2, xomega[ 4], yomega[ 4]);
520   sCh3->SetVertex(3, xomega[ 5], yomega[ 5]);
521
522   sCh4->SetVertex(0, xomega[16], yomega[16]);
523   sCh4->SetVertex(1, xomega[17], yomega[17]);
524   sCh4->SetVertex(2, xomega[18], yomega[18]);
525   sCh4->SetVertex(3, xomega[19], yomega[19]);
526
527   sCh5->SetVertex(0, xomega[ 6], yomega[ 6]);
528   sCh5->SetVertex(1, xomega[ 7], yomega[ 7]);
529   sCh5->SetVertex(2, xomega[ 8], yomega[ 8]);
530   sCh5->SetVertex(3, xomega[ 9], yomega[ 9]);
531
532   sCh6->SetVertex(0, xomega[12], yomega[12]);
533   sCh6->SetVertex(1, xomega[13], yomega[13]);
534   sCh6->SetVertex(2, xomega[14], yomega[14]);
535   sCh6->SetVertex(3, xomega[15], yomega[15]);
536
537   sCh7->SetVertex(0,-xomega[21], yomega[21]);
538   sCh7->SetVertex(1,-xomega[20], yomega[20]);
539   sCh7->SetVertex(2,-xomega[23], yomega[23]);
540   sCh7->SetVertex(3,-xomega[22], yomega[22]);
541
542   sCh8->SetVertex(0,-xomega[ 3], yomega[ 3]);
543   sCh8->SetVertex(1,-xomega[ 2], yomega[ 2]);
544   sCh8->SetVertex(2,-xomega[ 5], yomega[ 5]);
545   sCh8->SetVertex(3,-xomega[ 4], yomega[ 4]);
546
547   sCh9->SetVertex(0,-xomega[17], yomega[17]);
548   sCh9->SetVertex(1,-xomega[16], yomega[16]);
549   sCh9->SetVertex(2,-xomega[19], yomega[19]);
550   sCh9->SetVertex(3,-xomega[18], yomega[18]);
551
552   sCh10->SetVertex(0,-xomega[ 7], yomega[ 7]);
553   sCh10->SetVertex(1,-xomega[ 6], yomega[ 6]);
554   sCh10->SetVertex(2,-xomega[ 9], yomega[ 9]);
555   sCh10->SetVertex(3,-xomega[ 8], yomega[ 8]);
556
557   sCh11->SetVertex(0,-xomega[13], yomega[13]);
558   sCh11->SetVertex(1,-xomega[12], yomega[12]);
559   sCh11->SetVertex(2,-xomega[15], yomega[15]);
560   sCh11->SetVertex(3,-xomega[14], yomega[14]);
561
562   // Bigger end: determine the coordinates of the points of carbon fiber
563
564   // Drawings give only the radius, convert it to the apothegm
565   Double_t kInnerRadiusCone = TMath::Sqrt(kInnerRadialCone*kInnerRadialCone
566                                           - 0.25*kInnerACone*kInnerACone);
567   Double_t kOuterRadiusCone = TMath::Sqrt(kOuterRadialCone*kOuterRadialCone
568                                           - 0.25*kOuterACone*kOuterACone);
569
570   CreateSPDThermalShape(kInnerACone,kInnerBCone,kInnerRadiusCone,
571                         kOuterACone,kOuterBCone,kOuterRadiusCone,
572                         kTheta,xshld,yshld);
573
574   sC1->SetVertex(4, xshld[12], yshld[12]);
575   sC1->SetVertex(5, xshld[11], yshld[11]);
576   sC1->SetVertex(6, xshld[ 0], yshld[ 0]);
577   sC1->SetVertex(7, xshld[23], yshld[23]);
578
579   sC2->SetVertex(4, xshld[11], yshld[11]);
580   sC2->SetVertex(5, xshld[10], yshld[10]);
581   sC2->SetVertex(6, xshld[ 1], yshld[ 1]);
582   sC2->SetVertex(7, xshld[ 0], yshld[ 0]);
583
584   sC3->SetVertex(4, xshld[10], yshld[10]);
585   sC3->SetVertex(5, xshld[ 9], yshld[ 9]);
586   sC3->SetVertex(6, xshld[ 2], yshld[ 2]);
587   sC3->SetVertex(7, xshld[ 1], yshld[ 1]);
588
589   sC4->SetVertex(4, xshld[ 9], yshld[ 9]);
590   sC4->SetVertex(5, xshld[ 8], yshld[ 8]);
591   sC4->SetVertex(6, xshld[ 3], yshld[ 3]);
592   sC4->SetVertex(7, xshld[ 2], yshld[ 2]);
593
594   sC5->SetVertex(4, xshld[ 8], yshld[ 8]);
595   sC5->SetVertex(5, xshld[ 7], yshld[ 7]);
596   sC5->SetVertex(6, xshld[ 4], yshld[ 4]);
597   sC5->SetVertex(7, xshld[ 3], yshld[ 3]);
598
599   sC6->SetVertex(4, xshld[ 7], yshld[ 7]);
600   sC6->SetVertex(5, xshld[ 6], yshld[ 6]);
601   sC6->SetVertex(6, xshld[ 5], yshld[ 5]);
602   sC6->SetVertex(7, xshld[ 4], yshld[ 4]);
603
604   sC7->SetVertex(4,-xshld[10], yshld[10]);
605   sC7->SetVertex(5,-xshld[11], yshld[11]);
606   sC7->SetVertex(6,-xshld[ 0], yshld[ 0]);
607   sC7->SetVertex(7,-xshld[ 1], yshld[ 1]);
608
609   sC8->SetVertex(4,-xshld[ 9], yshld[ 9]);
610   sC8->SetVertex(5,-xshld[10], yshld[10]);
611   sC8->SetVertex(6,-xshld[ 1], yshld[ 1]);
612   sC8->SetVertex(7,-xshld[ 2], yshld[ 2]);
613
614   sC9->SetVertex(4,-xshld[ 8], yshld[ 8]);
615   sC9->SetVertex(5,-xshld[ 9], yshld[ 9]);
616   sC9->SetVertex(6,-xshld[ 2], yshld[ 2]);
617   sC9->SetVertex(7,-xshld[ 3], yshld[ 3]);
618
619   sC10->SetVertex(4,-xshld[ 7], yshld[ 7]);
620   sC10->SetVertex(5,-xshld[ 8], yshld[ 8]);
621   sC10->SetVertex(6,-xshld[ 3], yshld[ 3]);
622   sC10->SetVertex(7,-xshld[ 4], yshld[ 4]);
623
624   sC11->SetVertex(4,-xshld[ 6], yshld[ 6]);
625   sC11->SetVertex(5,-xshld[ 7], yshld[ 7]);
626   sC11->SetVertex(6,-xshld[ 4], yshld[ 4]);
627   sC11->SetVertex(7,-xshld[ 5], yshld[ 5]);
628
629   // Then rescale to get the air volume dimensions
630     InsidePoint(xshld[23], yshld[23],
631                 xshld[ 0], yshld[ 0],
632                 xshld[ 1], yshld[ 1], kThicknessCone,
633                 xair[0], yair[0]);
634   for (Int_t i=1; i<23; i++) {
635     InsidePoint(xshld[i-1], yshld[i-1],
636                 xshld[ i ], yshld[ i ],
637                 xshld[i+1], yshld[i+1], kThicknessCone,
638                 xair[i], yair[i]);
639   }
640     InsidePoint(xshld[22], yshld[22],
641                 xshld[23], yshld[23],
642                 xshld[ 0], yshld[ 0], kThicknessCone,
643                 xair[23], yair[23]);
644
645   // Then use them to determine the Omega shape points
646   CreateSPDOmegaShape(xair,yair,kThicknessOmega,xomega,yomega);
647
648   // Finally fill the big end coordinates of the air shapes
649   sCh1->SetVertex(4, xomega[ 0], yomega[ 0]);
650   sCh1->SetVertex(5, xomega[ 1], yomega[ 1]);
651   sCh1->SetVertex(6,-xomega[ 1], yomega[ 1]);
652   sCh1->SetVertex(7,-xomega[ 0], yomega[ 0]);
653
654   sCh2->SetVertex(4, xomega[20], yomega[20]);
655   sCh2->SetVertex(5, xomega[21], yomega[21]);
656   sCh2->SetVertex(6, xomega[22], yomega[22]);
657   sCh2->SetVertex(7, xomega[23], yomega[23]);
658
659   sCh3->SetVertex(4, xomega[ 2], yomega[ 2]);
660   sCh3->SetVertex(5, xomega[ 3], yomega[ 3]);
661   sCh3->SetVertex(6, xomega[ 4], yomega[ 4]);
662   sCh3->SetVertex(7, xomega[ 5], yomega[ 5]);
663
664   sCh4->SetVertex(4, xomega[16], yomega[16]);
665   sCh4->SetVertex(5, xomega[17], yomega[17]);
666   sCh4->SetVertex(6, xomega[18], yomega[18]);
667   sCh4->SetVertex(7, xomega[19], yomega[19]);
668
669   sCh5->SetVertex(4, xomega[ 6], yomega[ 6]);
670   sCh5->SetVertex(5, xomega[ 7], yomega[ 7]);
671   sCh5->SetVertex(6, xomega[ 8], yomega[ 8]);
672   sCh5->SetVertex(7, xomega[ 9], yomega[ 9]);
673
674   sCh6->SetVertex(4, xomega[12], yomega[12]);
675   sCh6->SetVertex(5, xomega[13], yomega[13]);
676   sCh6->SetVertex(6, xomega[14], yomega[14]);
677   sCh6->SetVertex(7, xomega[15], yomega[15]);
678
679   sCh7->SetVertex(4,-xomega[21], yomega[21]);
680   sCh7->SetVertex(5,-xomega[20], yomega[20]);
681   sCh7->SetVertex(6,-xomega[23], yomega[23]);
682   sCh7->SetVertex(7,-xomega[22], yomega[22]);
683
684   sCh8->SetVertex(4,-xomega[ 3], yomega[ 3]);
685   sCh8->SetVertex(5,-xomega[ 2], yomega[ 2]);
686   sCh8->SetVertex(6,-xomega[ 5], yomega[ 5]);
687   sCh8->SetVertex(7,-xomega[ 4], yomega[ 4]);
688
689   sCh9->SetVertex(4,-xomega[17], yomega[17]);
690   sCh9->SetVertex(5,-xomega[16], yomega[16]);
691   sCh9->SetVertex(6,-xomega[19], yomega[19]);
692   sCh9->SetVertex(7,-xomega[18], yomega[18]);
693
694   sCh10->SetVertex(4,-xomega[ 7], yomega[ 7]);
695   sCh10->SetVertex(5,-xomega[ 6], yomega[ 6]);
696   sCh10->SetVertex(6,-xomega[ 9], yomega[ 9]);
697   sCh10->SetVertex(7,-xomega[ 8], yomega[ 8]);
698
699   sCh11->SetVertex(4,-xomega[13], yomega[13]);
700   sCh11->SetVertex(5,-xomega[12], yomega[12]);
701   sCh11->SetVertex(6,-xomega[15], yomega[15]);
702   sCh11->SetVertex(7,-xomega[14], yomega[14]);
703
704 /*
705   for(Int_t i=0; i<4; i++){
706     InsidePoint(sC1->GetVertices()[((i+3)%4)*2+0],
707                 sC1->GetVertices()[((i+3)%4)*2+1],
708                 sC1->GetVertices()[i*2+0],
709                 sC1->GetVertices()[i*2+1],
710                 sC1->GetVertices()[((i+1)%4)*2+0],
711                 sC1->GetVertices()[((i+1)%4)*2+1],-kThicknessCone,x,y);
712     sCh1->SetVertex(i,x,y);
713
714     InsidePoint(sC1->GetVertices()[((i+3)%4 +4)*2+0],
715                 sC1->GetVertices()[((i+3)%4 +4)*2+1],
716                 sC1->GetVertices()[(i+4)*2+0],
717                 sC1->GetVertices()[(i+4)*2+1],
718                 sC1->GetVertices()[((i+1)%4 +4)*2+0],
719                 sC1->GetVertices()[((i+1)%4 +4)*2+1],-kThicknessCone,x,y);
720     sCh1->SetVertex(i+4,x,y);
721
722     InsidePoint(sC2->GetVertices()[((i+3)%4)*2+0],
723                 sC2->GetVertices()[((i+3)%4)*2+1],
724                 sC2->GetVertices()[i*2+0],
725                 sC2->GetVertices()[i*2+1],
726                 sC2->GetVertices()[((i+1)%4)*2+0],
727                 sC2->GetVertices()[((i+1)%4)*2+1],-kThicknessCone,x,y);
728     sCh2->SetVertex(i,x,y);
729
730     InsidePoint(sC2->GetVertices()[((i+3)%4 +4)*2+0],
731                 sC2->GetVertices()[((i+3)%4 +4)*2+1],
732                 sC2->GetVertices()[(i+4)*2+0],
733                 sC2->GetVertices()[(i+4)*2+1],
734                 sC2->GetVertices()[((i+1)%4 +4)*2+0],
735                 sC2->GetVertices()[((i+1)%4 +4)*2+1],-kThicknessCone,x,y);
736     sCh2->SetVertex(i+4,x,y);
737   }
738 */
739   // Finally the carbon fiber Ring with its Wings and their
740   // stesalite inserts. They are Tube and TubeSeg shapes
741
742   TGeoTube *ringshape = new TGeoTube(kInnerRadiusRing,kOuterRadiusRing,
743                                      kHalfLengthRing);
744
745   TGeoTube *ringinsertshape = new TGeoTube(kInnerRadiusRing+kThicknessRing,
746                                            kOuterRadiusRing-kThicknessRing,
747                                            kHalfLengthRing-kThicknessRing);
748
749   Double_t angleWideWing, angleWideWingThickness;
750   angleWideWing = (kWideWing/kOuterRadiusWing)*TMath::RadToDeg();
751   angleWideWingThickness = (kThicknessRing/kOuterRadiusWing)*TMath::RadToDeg();
752
753   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kOuterRadiusRing,kOuterRadiusWing,
754                                            kHalfLengthRing, 0, angleWideWing);
755
756   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kOuterRadiusRing,
757              kOuterRadiusWing-kThicknessRing, kHalfLengthRing-kThicknessRing,
758              angleWideWingThickness, angleWideWing-angleWideWingThickness);
759
760
761   // We have the shapes: now create the real volumes
762
763   TGeoMedium *medSPDcf  = mgr->GetMedium("ITS_SPD shield$");
764   TGeoMedium *medSPDair = mgr->GetMedium("ITS_SPD AIR$");
765   TGeoMedium *medSPDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
766
767   TGeoVolume *centralshield = new TGeoVolume("SPDcentralshield",
768                                              centralshape,medSPDcf);
769   centralshield->SetVisibility(kTRUE);
770   centralshield->SetLineColor(7);
771   centralshield->SetLineWidth(1);
772   centralshield->SetFillColor(centralshield->GetLineColor());
773   centralshield->SetFillStyle(4090); // 90% transparent
774
775   TGeoVolume *centralair1 = new TGeoVolume("SPDcentralair1shield",
776                                            centralair1shape,medSPDair);
777   centralair1->SetVisibility(kTRUE);
778   centralair1->SetLineColor(5); // Yellow
779   centralair1->SetLineWidth(1);
780   centralair1->SetFillColor(centralair1->GetLineColor());
781   centralair1->SetFillStyle(4090); // 90% transparent
782
783   TGeoVolume *centralair2 = new TGeoVolume("SPDcentralair2shield",
784                                            centralair2shape,medSPDair);
785   centralair2->SetVisibility(kTRUE);
786   centralair2->SetLineColor(5); // Yellow
787   centralair2->SetLineWidth(1);
788   centralair2->SetFillColor(centralair2->GetLineColor());
789   centralair2->SetFillStyle(4090); // 90% transparent
790
791   TGeoVolume *centralair3 = new TGeoVolume("SPDcentralair3shield",
792                                            centralair3shape,medSPDair);
793   centralair3->SetVisibility(kTRUE);
794   centralair3->SetLineColor(5); // Yellow
795   centralair3->SetLineWidth(1);
796   centralair3->SetFillColor(centralair3->GetLineColor());
797   centralair3->SetFillStyle(4090); // 90% transparent
798
799   TGeoVolume *centralair4 = new TGeoVolume("SPDcentralair4shield",
800                                            centralair4shape,medSPDair);
801   centralair4->SetVisibility(kTRUE);
802   centralair4->SetLineColor(5); // Yellow
803   centralair4->SetLineWidth(1);
804   centralair4->SetFillColor(centralair4->GetLineColor());
805   centralair4->SetFillStyle(4090); // 90% transparent
806
807   TGeoVolume *centralair5 = new TGeoVolume("SPDcentralair5shield",
808                                            centralair5shape,medSPDair);
809   centralair5->SetVisibility(kTRUE);
810   centralair5->SetLineColor(5); // Yellow
811   centralair5->SetLineWidth(1);
812   centralair5->SetFillColor(centralair5->GetLineColor());
813   centralair5->SetFillStyle(4090); // 90% transparent
814
815   TGeoVolume *centralair6 = new TGeoVolume("SPDcentralair6shield",
816                                            centralair6shape,medSPDair);
817   centralair6->SetVisibility(kTRUE);
818   centralair6->SetLineColor(5); // Yellow
819   centralair6->SetLineWidth(1);
820   centralair6->SetFillColor(centralair6->GetLineColor());
821   centralair6->SetFillStyle(4090); // 90% transparent
822
823   centralshield->AddNode(centralair1,1,0);
824   centralshield->AddNode(centralair2,1,0);
825   centralshield->AddNode(centralair2,2,new TGeoRotation("",90,180,-90));
826   centralshield->AddNode(centralair3,1,0);
827   centralshield->AddNode(centralair3,2,new TGeoRotation("",90,180,-90));
828   centralshield->AddNode(centralair4,1,0);
829   centralshield->AddNode(centralair4,2,new TGeoRotation("",90,180,-90));
830   centralshield->AddNode(centralair5,1,0);
831   centralshield->AddNode(centralair5,2,new TGeoRotation("",90,180,-90));
832   centralshield->AddNode(centralair6,1,0);
833   centralshield->AddNode(centralair6,2,new TGeoRotation("",90,180,-90));
834
835   TGeoVolume *endcapshield = new TGeoVolume("SPDendcapshield",
836                                              endcapshape,medSPDcf);
837   endcapshield->SetVisibility(kTRUE);
838   endcapshield->SetLineColor(7);
839   endcapshield->SetLineWidth(1);
840
841   TGeoVolume *endcapair1 = new TGeoVolume("SPDendcapair1shield",
842                                           endcapair1shape,medSPDair);
843   endcapair1->SetVisibility(kTRUE);
844   endcapair1->SetLineColor(5); // Yellow
845   endcapair1->SetLineWidth(1);
846   endcapair1->SetFillColor(endcapair1->GetLineColor());
847   endcapair1->SetFillStyle(4090); // 90% transparent
848
849   TGeoVolume *endcapair2 = new TGeoVolume("SPDendcapair2shield",
850                                           endcapair2shape,medSPDair);
851   endcapair2->SetVisibility(kTRUE);
852   endcapair2->SetLineColor(5); // Yellow
853   endcapair2->SetLineWidth(1);
854   endcapair2->SetFillColor(endcapair2->GetLineColor());
855   endcapair2->SetFillStyle(4090); // 90% transparent
856
857   TGeoVolume *endcapair3 = new TGeoVolume("SPDendcapair3shield",
858                                           endcapair3shape,medSPDair);
859   endcapair3->SetVisibility(kTRUE);
860   endcapair3->SetLineColor(5); // Yellow
861   endcapair3->SetLineWidth(1);
862   endcapair3->SetFillColor(endcapair3->GetLineColor());
863   endcapair3->SetFillStyle(4090); // 90% transparent
864
865   TGeoVolume *endcapair4 = new TGeoVolume("SPDendcapair4shield",
866                                           endcapair4shape,medSPDair);
867   endcapair4->SetVisibility(kTRUE);
868   endcapair4->SetLineColor(5); // Yellow
869   endcapair4->SetLineWidth(1);
870   endcapair4->SetFillColor(endcapair4->GetLineColor());
871   endcapair4->SetFillStyle(4090); // 90% transparent
872
873   TGeoVolume *endcapair5 = new TGeoVolume("SPDendcapair5shield",
874                                           endcapair5shape,medSPDair);
875   endcapair5->SetVisibility(kTRUE);
876   endcapair5->SetLineColor(5); // Yellow
877   endcapair5->SetLineWidth(1);
878   endcapair5->SetFillColor(endcapair5->GetLineColor());
879   endcapair5->SetFillStyle(4090); // 90% transparent
880
881   TGeoVolume *endcapair6 = new TGeoVolume("SPDendcapair6shield",
882                                           endcapair6shape,medSPDair);
883   endcapair6->SetVisibility(kTRUE);
884   endcapair6->SetLineColor(5); // Yellow
885   endcapair6->SetLineWidth(1);
886   endcapair6->SetFillColor(endcapair6->GetLineColor());
887   endcapair6->SetFillStyle(4090); // 90% transparent
888
889   endcapshield->AddNode(endcapair1,1,0);
890   endcapshield->AddNode(endcapair2,1,0);
891   endcapshield->AddNode(endcapair2,2,new TGeoRotation("",90,180,-90));
892   endcapshield->AddNode(endcapair3,1,0);
893   endcapshield->AddNode(endcapair3,2,new TGeoRotation("",90,180,-90));
894   endcapshield->AddNode(endcapair4,1,0);
895   endcapshield->AddNode(endcapair4,2,new TGeoRotation("",90,180,-90));
896   endcapshield->AddNode(endcapair5,1,0);
897   endcapshield->AddNode(endcapair5,2,new TGeoRotation("",90,180,-90));
898   endcapshield->AddNode(endcapair6,1,0);
899   endcapshield->AddNode(endcapair6,2,new TGeoRotation("",90,180,-90));
900
901   TGeoVolume *vC1 = new TGeoVolume("SPDconeshieldV1",sC1,medSPDcf);
902   vC1->SetVisibility(kTRUE);
903   vC1->SetLineColor(7);
904   vC1->SetLineWidth(1);
905   vC1->SetFillColor(vC1->GetLineColor());
906   vC1->SetFillStyle(4090); // 90% transparent
907
908   TGeoVolume *vCh1 = new TGeoVolume("SPDconeshieldH1",sCh1,medSPDair);
909   vCh1->SetVisibility(kTRUE);
910   vCh1->SetLineColor(5); // Yellow
911   vCh1->SetLineWidth(1);
912   vCh1->SetFillColor(vCh1->GetLineColor());
913   vCh1->SetFillStyle(4090); // 90% transparent
914
915   vC1->AddNode(vCh1,1,0);
916
917   TGeoVolume *vC2 = new TGeoVolume("SPDconeshieldV2",sC2,medSPDcf);
918   vC2->SetVisibility(kTRUE);
919   vC2->SetLineColor(7);
920   vC2->SetLineWidth(1);
921   vC2->SetFillColor(vC2->GetLineColor());
922   vC2->SetFillStyle(4090); // 90% transparent
923
924   TGeoVolume *vCh2 = new TGeoVolume("SPDconeshieldH2",sCh2,medSPDair);
925   vCh2->SetVisibility(kTRUE);
926   vCh2->SetLineColor(5); // Yellow
927   vCh2->SetLineWidth(1);
928   vCh2->SetFillColor(vCh2->GetLineColor());
929   vCh2->SetFillStyle(4090); // 90% transparent
930
931   vC2->AddNode(vCh2,1,0);
932
933   TGeoVolume *vC3 = new TGeoVolume("SPDconeshieldV3",sC3,medSPDcf);
934   vC3->SetVisibility(kTRUE);
935   vC3->SetLineColor(7);
936   vC3->SetLineWidth(1);
937   vC3->SetFillColor(vC3->GetLineColor());
938   vC3->SetFillStyle(4090); // 90% transparent
939
940   TGeoVolume *vCh3 = new TGeoVolume("SPDconeshieldH3",sCh3,medSPDair);
941   vCh3->SetVisibility(kTRUE);
942   vCh3->SetLineColor(5); // Yellow
943   vCh3->SetLineWidth(1);
944   vCh3->SetFillColor(vCh3->GetLineColor());
945   vCh3->SetFillStyle(4090); // 90% transparent
946
947   vC3->AddNode(vCh3,1,0);
948
949   TGeoVolume *vC4 = new TGeoVolume("SPDconeshieldV4",sC4,medSPDcf);
950   vC4->SetVisibility(kTRUE);
951   vC4->SetLineColor(7);
952   vC4->SetLineWidth(1);
953   vC4->SetFillColor(vC4->GetLineColor());
954   vC4->SetFillStyle(4090); // 90% transparent
955
956   TGeoVolume *vCh4 = new TGeoVolume("SPDconeshieldH4",sCh4,medSPDair);
957   vCh4->SetVisibility(kTRUE);
958   vCh4->SetLineColor(5); // Yellow
959   vCh4->SetLineWidth(1);
960   vCh4->SetFillColor(vCh4->GetLineColor());
961   vCh4->SetFillStyle(4090); // 90% transparent
962
963   vC4->AddNode(vCh4,1,0);
964
965   TGeoVolume *vC5 = new TGeoVolume("SPDconeshieldV5",sC5,medSPDcf);
966   vC5->SetVisibility(kTRUE);
967   vC5->SetLineColor(7);
968   vC5->SetLineWidth(1);
969   vC5->SetFillColor(vC5->GetLineColor());
970   vC5->SetFillStyle(4090); // 90% transparent
971
972   TGeoVolume *vCh5 = new TGeoVolume("SPDconeshieldH5",sCh5,medSPDair);
973   vCh5->SetVisibility(kTRUE);
974   vCh5->SetLineColor(5); // Yellow
975   vCh5->SetLineWidth(1);
976   vCh5->SetFillColor(vCh5->GetLineColor());
977   vCh5->SetFillStyle(4090); // 90% transparent
978
979   vC5->AddNode(vCh5,1,0);
980
981   TGeoVolume *vC6 = new TGeoVolume("SPDconeshieldV6",sC6,medSPDcf);
982   vC6->SetVisibility(kTRUE);
983   vC6->SetLineColor(7);
984   vC6->SetLineWidth(1);
985   vC6->SetFillColor(vC6->GetLineColor());
986   vC6->SetFillStyle(4090); // 90% transparent
987
988   TGeoVolume *vCh6 = new TGeoVolume("SPDconeshieldH6",sCh6,medSPDair);
989   vCh6->SetVisibility(kTRUE);
990   vCh6->SetLineColor(5); // Yellow
991   vCh6->SetLineWidth(1);
992   vCh6->SetFillColor(vCh6->GetLineColor());
993   vCh6->SetFillStyle(4090); // 90% transparent
994
995   vC6->AddNode(vCh6,1,0);
996
997   TGeoVolume *vC7 = new TGeoVolume("SPDconeshieldV7",sC7,medSPDcf);
998   vC7->SetVisibility(kTRUE);
999   vC7->SetLineColor(7);
1000   vC7->SetLineWidth(1);
1001   vC7->SetFillColor(vC7->GetLineColor());
1002   vC7->SetFillStyle(4090); // 90% transparent
1003
1004   TGeoVolume *vCh7 = new TGeoVolume("SPDconeshieldH7",sCh7,medSPDair);
1005   vCh7->SetVisibility(kTRUE);
1006   vCh7->SetLineColor(5); // Yellow
1007   vCh7->SetLineWidth(1);
1008   vCh7->SetFillColor(vCh7->GetLineColor());
1009   vCh7->SetFillStyle(4090); // 90% transparent
1010
1011   vC7->AddNode(vCh7,1,0);
1012
1013   TGeoVolume *vC8 = new TGeoVolume("SPDconeshieldV8",sC8,medSPDcf);
1014   vC8->SetVisibility(kTRUE);
1015   vC8->SetLineColor(7);
1016   vC8->SetLineWidth(1);
1017   vC8->SetFillColor(vC8->GetLineColor());
1018   vC8->SetFillStyle(4090); // 90% transparent
1019
1020   TGeoVolume *vCh8 = new TGeoVolume("SPDconeshieldH8",sCh8,medSPDair);
1021   vCh8->SetVisibility(kTRUE);
1022   vCh8->SetLineColor(5); // Yellow
1023   vCh8->SetLineWidth(1);
1024   vCh8->SetFillColor(vCh8->GetLineColor());
1025   vCh8->SetFillStyle(4090); // 90% transparent
1026
1027   vC8->AddNode(vCh8,1,0);
1028
1029   TGeoVolume *vC9 = new TGeoVolume("SPDconeshieldV9",sC9,medSPDcf);
1030   vC9->SetVisibility(kTRUE);
1031   vC9->SetLineColor(7);
1032   vC9->SetLineWidth(1);
1033   vC9->SetFillColor(vC9->GetLineColor());
1034   vC9->SetFillStyle(4090); // 90% transparent
1035
1036   TGeoVolume *vCh9 = new TGeoVolume("SPDconeshieldH9",sCh9,medSPDair);
1037   vCh9->SetVisibility(kTRUE);
1038   vCh9->SetLineColor(5); // Yellow
1039   vCh9->SetLineWidth(1);
1040   vCh9->SetFillColor(vCh9->GetLineColor());
1041   vCh9->SetFillStyle(4090); // 90% transparent
1042
1043   vC9->AddNode(vCh9,1,0);
1044
1045   TGeoVolume *vC10 = new TGeoVolume("SPDconeshieldV10",sC10,medSPDcf);
1046   vC10->SetVisibility(kTRUE);
1047   vC10->SetLineColor(7);
1048   vC10->SetLineWidth(1);
1049   vC10->SetFillColor(vC10->GetLineColor());
1050   vC10->SetFillStyle(4090); // 90% transparent
1051
1052   TGeoVolume *vCh10 = new TGeoVolume("SPDconeshieldH10",sCh10,medSPDair);
1053   vCh10->SetVisibility(kTRUE);
1054   vCh10->SetLineColor(5); // Yellow
1055   vCh10->SetLineWidth(1);
1056   vCh10->SetFillColor(vCh10->GetLineColor());
1057   vCh10->SetFillStyle(4090); // 90% transparent
1058
1059   vC10->AddNode(vCh10,1,0);
1060
1061   TGeoVolume *vC11 = new TGeoVolume("SPDconeshieldV11",sC11,medSPDcf);
1062   vC11->SetVisibility(kTRUE);
1063   vC11->SetLineColor(7);
1064   vC11->SetLineWidth(1);
1065   vC11->SetFillColor(vC11->GetLineColor());
1066   vC11->SetFillStyle(4090); // 90% transparent
1067
1068   TGeoVolume *vCh11 = new TGeoVolume("SPDconeshieldH11",sCh11,medSPDair);
1069   vCh11->SetVisibility(kTRUE);
1070   vCh11->SetLineColor(5); // Yellow
1071   vCh11->SetLineWidth(1);
1072   vCh11->SetFillColor(vCh11->GetLineColor());
1073   vCh11->SetFillStyle(4090); // 90% transparent
1074
1075   vC11->AddNode(vCh11,1,0);
1076
1077   TGeoVolume *ring = new TGeoVolume("SPDshieldring",ringshape,medSPDcf);
1078   ring->SetVisibility(kTRUE);
1079   ring->SetLineColor(7);
1080   ring->SetLineWidth(1);
1081
1082   TGeoVolume *ringinsert = new TGeoVolume("SPDshieldringinsert",
1083                                           ringinsertshape,medSPDste);
1084   ringinsert->SetVisibility(kTRUE);
1085   ringinsert->SetLineColor(3); // Green
1086 //  ringinsert->SetLineWidth(1);
1087   ringinsert->SetFillColor(ringinsert->GetLineColor());
1088   ringinsert->SetFillStyle(4010); // 10% transparent
1089
1090   ring->AddNode(ringinsert,1,0);
1091
1092   TGeoVolume *wing = new TGeoVolume("SPDshieldringwing",wingshape,medSPDcf);
1093   wing->SetVisibility(kTRUE);
1094   wing->SetLineColor(7);
1095   wing->SetLineWidth(1);
1096
1097   TGeoVolume *winginsert = new TGeoVolume("SPDshieldringinsert",
1098                                           winginsertshape,medSPDste);
1099   winginsert->SetVisibility(kTRUE);
1100   winginsert->SetLineColor(3); // Green
1101 //  winginsert->SetLineWidth(1);
1102   winginsert->SetFillColor(winginsert->GetLineColor());
1103   winginsert->SetFillStyle(4010); // 10% transparent
1104
1105   wing->AddNode(winginsert,1,0);
1106
1107
1108   // Add all volumes in the assembly
1109   const Double_t kLittleZTrans = 0.1*fgkmm;
1110   vM->AddNode(centralshield,1,new TGeoTranslation(0,0,-kLittleZTrans));
1111   vM->AddNode(centralshield,2,new TGeoCombiTrans( 0,0,-kLittleZTrans,
1112                                   new TGeoRotation("",180,0,0)));
1113
1114   zpos = kHalfLengthCentral+kHalfLengthEndCap;
1115   vM->AddNode(endcapshield,1,
1116               new TGeoTranslation(0,0, zpos-kLittleZTrans));
1117   vM->AddNode(endcapshield,2,
1118               new TGeoTranslation(0,0,-zpos-kLittleZTrans));
1119   vM->AddNode(endcapshield,3,new TGeoCombiTrans(
1120               0, 0, zpos-kLittleZTrans, new TGeoRotation("",180,0,0) ) );
1121   vM->AddNode(endcapshield,4,new TGeoCombiTrans(
1122               0, 0,-zpos-kLittleZTrans, new TGeoRotation("",180,0,0) ) );
1123
1124   zpos = kHalfLengthCentral+2*kHalfLengthEndCap+kHalfLengthCone;
1125   vM->AddNode(vC1 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1126   vM->AddNode(vC2 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1127   vM->AddNode(vC3 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1128   vM->AddNode(vC4 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1129   vM->AddNode(vC5 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1130   vM->AddNode(vC6 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1131   vM->AddNode(vC7 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1132   vM->AddNode(vC8 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1133   vM->AddNode(vC9 ,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1134   vM->AddNode(vC10,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1135   vM->AddNode(vC11,1, new TGeoTranslation(0, 0,  zpos-kLittleZTrans));
1136
1137   vM->AddNode(vC1 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1138                                 new TGeoRotation("", 0, 0, 180)   ));
1139   vM->AddNode(vC2 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1140                                 new TGeoRotation("", 0, 0, 180)   ));
1141   vM->AddNode(vC3 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1142                                 new TGeoRotation("", 0, 0, 180)   ));
1143   vM->AddNode(vC4 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1144                                 new TGeoRotation("", 0, 0, 180)   ));
1145   vM->AddNode(vC5 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1146                                 new TGeoRotation("", 0, 0, 180)   ));
1147   vM->AddNode(vC6 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1148                                 new TGeoRotation("", 0, 0, 180)   ));
1149   vM->AddNode(vC7 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1150                                 new TGeoRotation("", 0, 0, 180)   ));
1151   vM->AddNode(vC8 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1152                                 new TGeoRotation("", 0, 0, 180)   ));
1153   vM->AddNode(vC9 ,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1154                                 new TGeoRotation("", 0, 0, 180)   ));
1155   vM->AddNode(vC10,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1156                                 new TGeoRotation("", 0, 0, 180)   ));
1157   vM->AddNode(vC11,2, new TGeoCombiTrans(0, 0,  zpos-kLittleZTrans,
1158                                 new TGeoRotation("", 0, 0, 180)   ));
1159
1160   vM->AddNode(vC1 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1161                                 new TGeoRotation("", 0, 180, 0)   ));
1162   vM->AddNode(vC2 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1163                                 new TGeoRotation("", 0, 180, 0)   ));
1164   vM->AddNode(vC3 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1165                                 new TGeoRotation("", 0, 180, 0)   ));
1166   vM->AddNode(vC4 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1167                                 new TGeoRotation("", 0, 180, 0)   ));
1168   vM->AddNode(vC5 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1169                                 new TGeoRotation("", 0, 180, 0)   ));
1170   vM->AddNode(vC6 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1171                                 new TGeoRotation("", 0, 180, 0)   ));
1172   vM->AddNode(vC7 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1173                                 new TGeoRotation("", 0, 180, 0)   ));
1174   vM->AddNode(vC8 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1175                                 new TGeoRotation("", 0, 180, 0)   ));
1176   vM->AddNode(vC9 ,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1177                                 new TGeoRotation("", 0, 180, 0)   ));
1178   vM->AddNode(vC10,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1179                                 new TGeoRotation("", 0, 180, 0)   ));
1180   vM->AddNode(vC11,3, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1181                                 new TGeoRotation("", 0, 180, 0)   ));
1182
1183   vM->AddNode(vC1 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1184                                 new TGeoRotation("", 0, 180, 180)   ));
1185   vM->AddNode(vC2 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1186                                 new TGeoRotation("", 0, 180, 180)   ));
1187   vM->AddNode(vC3 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1188                                 new TGeoRotation("", 0, 180, 180)   ));
1189   vM->AddNode(vC4 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1190                                 new TGeoRotation("", 0, 180, 180)   ));
1191   vM->AddNode(vC5 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1192                                 new TGeoRotation("", 0, 180, 180)   ));
1193   vM->AddNode(vC6 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1194                                 new TGeoRotation("", 0, 180, 180)   ));
1195   vM->AddNode(vC7 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1196                                 new TGeoRotation("", 0, 180, 180)   ));
1197   vM->AddNode(vC8 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1198                                 new TGeoRotation("", 0, 180, 180)   ));
1199   vM->AddNode(vC9 ,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1200                                 new TGeoRotation("", 0, 180, 180)   ));
1201   vM->AddNode(vC10,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1202                                 new TGeoRotation("", 0, 180, 180)   ));
1203   vM->AddNode(vC11,4, new TGeoCombiTrans(0, 0, -zpos-kLittleZTrans,
1204                                 new TGeoRotation("", 0, 180, 180)   ));
1205
1206   zpos = kHalfLengthCentral+2*kHalfLengthEndCap+2*kHalfLengthCone
1207        + kHalfLengthRing;
1208   vM->AddNode(ring,1,new TGeoTranslation(0, 0, zpos-kLittleZTrans));
1209   vM->AddNode(ring,2,new TGeoTranslation(0, 0,-zpos-kLittleZTrans));
1210
1211   for (Int_t i=0; i<4; i++) {
1212     Double_t thetaW = kThetaWing*(2*i+1) - angleWideWing/2.;
1213     vM->AddNode(wing,2*i+1,new TGeoCombiTrans(0, 0, zpos-kLittleZTrans,
1214                                new TGeoRotation("",thetaW,0,0) ) );
1215     vM->AddNode(wing,2*i+2,new TGeoCombiTrans(0, 0,-zpos-kLittleZTrans,
1216                                new TGeoRotation("",thetaW,0,0) ) );
1217   }
1218
1219   // Some debugging if requested
1220   if(GetDebug(1)){
1221     vM->PrintNodes();
1222     vM->InspectShape();
1223   }
1224
1225   // Finally put the entire shield in the mother volume
1226   moth->AddNode(vM,1,0);
1227
1228   return;
1229 }
1230
1231 //______________________________________________________________________
1232 void AliITSv11GeometrySupport::CreateSPDThermalShape(
1233      Double_t ina, Double_t inb, Double_t inr,
1234      Double_t oua, Double_t oub, Double_t our,
1235      Double_t   t, Double_t *x , Double_t *y ) const
1236 {
1237 //
1238 // Creates the proper sequence of X and Y coordinates to determine
1239 // the base XTru polygon for the SPD thermal shapes
1240 //
1241 // Input:
1242 //        ina, inb : inner shape sides
1243 //        inr      : inner radius
1244 //        oua, oub : outer shape sides
1245 //        our      : outer radius
1246 //        t        : theta angle
1247 //
1248 // Output:
1249 //        x, y : coordinate vectors [24]
1250 //
1251 // Created:      14 Nov 2007  Mario Sitta
1252 // Updated:      11 Dec 2007  Mario Sitta
1253 //
1254   Double_t xlocal[6],ylocal[6];
1255
1256   //Create the first inner quadrant (X > 0)
1257   FillSPDXtruShape(ina,inb,inr,t,xlocal,ylocal);
1258   for (Int_t i=0; i<6; i++) {
1259     x[i] = xlocal[i];
1260     y[i] = ylocal[i];
1261   }
1262
1263   // Then reflex on the second quadrant (X < 0)
1264   for (Int_t i=0; i<6; i++) {
1265     x[23-i] = -x[i];
1266     y[23-i] =  y[i];
1267   }
1268
1269   // Now create the first outer quadrant (X > 0)
1270   FillSPDXtruShape(oua,oub,our,t,xlocal,ylocal);
1271   for (Int_t i=0; i<6; i++) {
1272     x[11-i] = xlocal[i];
1273     y[11-i] = ylocal[i];
1274   }
1275
1276   // Finally reflex on the second quadrant (X < 0)
1277   for (Int_t i=0; i<6; i++) {
1278     x[12+i] = -x[11-i];
1279     y[12+i] =  y[11-i];
1280   }
1281
1282   return;
1283 }
1284
1285 //______________________________________________________________________
1286 void AliITSv11GeometrySupport::CreateSPDOmegaShape(
1287                    const Double_t *xin, const Double_t *yin, Double_t  d,
1288                    Double_t   *x, Double_t *y)
1289 {
1290 //
1291 // Creates the proper sequence of X and Y coordinates to determine
1292 // the SPD Omega XTru polygon
1293 //
1294 // Input:
1295 //        xin, yin : coordinates of the air volume
1296 //        d        : Omega shape thickness
1297 //        t        : theta angle
1298 //
1299 // Output:
1300 //        x, y     : coordinate vectors [48]
1301 //
1302 // Created:      17 Nov 2007  Mario Sitta
1303 // Updated:      11 Dec 2007  Mario Sitta
1304 // Updated:      20 Feb 2009  Mario Sitta       New algorithm (the old one
1305 //                                              gives erroneous vertexes)
1306 //
1307
1308   // This vector contains the index of those points which coincide
1309   // with the corresponding points in the air shape
1310   Int_t indexAir2Omega[12] = {1, 2, 5, 6, 9, 10, 11, 15, 16, 19, 20, 23};
1311
1312   // First fill those vertexes corresponding to
1313   // the edges aligned to the air shape edges
1314   for (Int_t j=0; j<12; j++) {
1315     x[*(indexAir2Omega+j)] = xin[j];
1316     y[*(indexAir2Omega+j)] = yin[j];
1317   }
1318
1319   // Now get the coordinates of the first inner point
1320   PointFromParallelLines(x[23],y[23],x[1],y[1],d,x[0],y[0]);
1321
1322   // Knowing this, the second internal point can be determined
1323   InsidePoint(x[0],y[0],x[1],y[1],x[2],y[2],d,x[22],y[22]);
1324
1325   // The third point is now computable
1326   ReflectPoint(x[1],y[1],x[2],y[2],x[22],y[22],x[21],y[21]);
1327
1328   // Repeat this logic
1329   InsidePoint(x[21],y[21],x[20],y[20],x[19],y[19],-d,x[3],y[3]);
1330
1331   ReflectPoint(x[20],y[20],x[19],y[19],x[3],y[3],x[4],y[4]);
1332
1333   InsidePoint(x[4],y[4],x[5],y[5],x[6],y[6],d,x[18],y[18]);
1334
1335   ReflectPoint(x[5],y[5],x[6],y[6],x[18],y[18],x[17],y[17]);
1336
1337   InsidePoint(x[17],y[17],x[16],y[16],x[15],y[15],-d,x[7],y[7]);
1338
1339   ReflectPoint(x[16],y[16],x[15],y[15],x[7],y[7],x[8],y[8]);
1340
1341   InsidePoint(x[8],y[8],x[9],y[9],x[10],y[10],d,x[14],y[14]);
1342
1343   // These need to be fixed explicitly
1344   x[12] = x[11];
1345   y[12] = y[11] + d;
1346   x[13] = x[10] + d;
1347   y[13] = y[12];
1348
1349   // Finally reflect on the negative side
1350   for (Int_t i=0; i<24; i++) {
1351     x[24+i] = -x[23-i];
1352     y[24+i] =  y[23-i];
1353   }
1354
1355   // Wow ! We've finished
1356   return;
1357 }
1358
1359 //______________________________________________________________________
1360 void AliITSv11GeometrySupport::FillSPDXtruShape(Double_t a, Double_t b,
1361                                                 Double_t r, Double_t t,
1362                                                 Double_t *x, Double_t *y) const
1363 {
1364 //
1365 // Creates the partial sequence of X and Y coordinates to determine
1366 // the lateral part of the SPD thermal shield
1367 //
1368 // Input:
1369 //        a, b : shape sides
1370 //        r    : radius
1371 //        t    : theta angle
1372 //
1373 // Output:
1374 //        x, y : coordinate vectors [6]
1375 //
1376 // Created:      14 Nov 2007  Mario Sitta
1377 //
1378   x[0] = a/2;
1379   y[0] = r;
1380
1381   x[1] = x[0] + b * TMath::Cos(t/2);
1382   y[1] = y[0] - b * TMath::Sin(t/2);
1383
1384   x[2] = x[1] + a * TMath::Cos(t);
1385   y[2] = y[1] - a * TMath::Sin(t);
1386
1387   x[3] = x[2] + b * TMath::Cos(3*t/2);
1388   y[3] = y[2] - b * TMath::Sin(3*t/2);
1389
1390   x[4] = x[3] + a * TMath::Cos(2*t);
1391   y[4] = y[3] - a * TMath::Sin(2*t);
1392
1393   x[5] = x[4];
1394   y[5] = 0.;
1395
1396   return;
1397 }
1398
1399 //______________________________________________________________________
1400 void AliITSv11GeometrySupport::PointFromParallelLines(Double_t x1, Double_t y1,
1401                               Double_t x2, Double_t y2, Double_t d,
1402                               Double_t &x, Double_t &y) const
1403 {
1404 //
1405 // Determines the X and Y of the first internal point of the Omega shape
1406 // (i.e. the coordinates of a point given two parallel lines passing by
1407 // two points and placed at a known distance)
1408 //
1409 // Input:
1410 //        x1, y1 : first point
1411 //        x2, y2 : second point
1412 //        d      : distance between the two lines
1413 //
1414 // Output:
1415 //        x, y   : coordinate of the point
1416 //
1417 // Created:      22 Feb 2009  Mario Sitta
1418 //
1419 //Begin_Html
1420 /*
1421 <img src="ITS/doc/PointFromParallelLines.gif">
1422 */
1423 //End_Html
1424
1425   // The slope of the paralles lines at a distance d
1426   Double_t m; 
1427
1428   // The parameters of the solving equation
1429   // a x^2 - 2 b x + c = 0
1430   Double_t a = (x1 - x2)*(x1 - x2) - d*d;
1431   Double_t b = (x1 - x2)*(y1 - y2);
1432   Double_t c = (y1 - y2)*(y1 - y2) - d*d;
1433
1434   // (delta4 is Delta/4 because we use the reduced formula)
1435   Double_t delta4 = b*b - a*c;
1436
1437   // Compute the slope of the two parallel lines
1438   // (one of the two possible slopes, the one with the smaller
1439   // absolute value is needed)
1440   if (delta4 < 0) { // Should never happen with our data, but just to be sure
1441     x = -1;         // x is expected positive, so this flags an error
1442     return;
1443   } else
1444     m = (b + TMath::Sqrt(delta4))/a;  // b is negative with our data
1445
1446   // Finally compute the coordinates of the point
1447   x = x2 + (y1 - y2 - d)/m;
1448   y = y1 - d;
1449
1450   // Done
1451   return;
1452 }
1453
1454 //______________________________________________________________________
1455 void AliITSv11GeometrySupport::ReflectPoint(Double_t x1, Double_t y1,
1456                                             Double_t x2, Double_t y2,
1457                                             Double_t x3, Double_t y3,
1458                                             Double_t &x, Double_t &y) const
1459 {
1460 //
1461 // Given two points (x1,y1) and (x2,y2), determines the point (x,y)
1462 // lying on the line parallel to the line passing by these points,
1463 // at a distance d and passing by the point (x3,y3), which is symmetric to
1464 // the third point with respect to the axis of the segment delimited by
1465 // the two first points.
1466 //
1467 // Input:
1468 //        x1, y1 : first point
1469 //        x2, y2 : second point
1470 //        x3, y3 : third point
1471 //        d      : distance between the two lines
1472 //
1473 // Output:
1474 //        x, y   : coordinate of the reflected point
1475 //
1476 // Created:      22 Feb 2009  Mario Sitta
1477 //
1478 //Begin_Html
1479 /*
1480 <img src="ITS/doc/ReflectPoint.gif">
1481 */
1482 //End_Html
1483
1484   // The slope of the line passing by the first two points
1485   Double_t k = (y2 - y1)/(x2 - x1);
1486
1487   // The middle point of the segment 1-2
1488   Double_t xK = (x1 + x2)/2.;
1489   Double_t yK = (y1 + y2)/2.;
1490
1491   // The intercept between the axis of the segment 1-2 and the line
1492   // passing by 3 and parallel to the line passing by 1-2
1493   Double_t xH = (k*k*x3 + k*(yK - y3) + xK)/(k*k + 1);
1494   Double_t yH = k*(xH - x3) + y3;
1495
1496   // The point symmetric to 3 with respect to H
1497   x = 2*xH - x3;
1498   y = 2*yH - y3;
1499
1500   // Done
1501   return;
1502 }
1503
1504 //______________________________________________________________________
1505 void AliITSv11GeometrySupport::SDDCone(TGeoVolume *moth,const TGeoManager *mgr)
1506 {
1507 //
1508 // Creates the SDD support cone and cylinder geometry as a
1509 // volume assembly and adds it to the mother volume
1510 // (part of this code is taken or anyway inspired to SDDCone method
1511 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
1512 //
1513 // Input:
1514 //         moth : the TGeoVolume owing the volume structure
1515 //         mgr  : the GeoManager (default gGeoManager)
1516 // Output:
1517 //
1518 // Created:         ???       Bjorn S. Nilsen
1519 // Updated:      18 Feb 2008  Mario Sitta
1520 // Updated:      25 Jul 2008  Mario Sitta   SDDCarbonFiberCone simpler
1521 // Updated:      10 Jun 2010  Mario Sitta   Cables across cone holes added
1522 //
1523 // Technical data are taken from:  "Supporto Generale Settore SDD"
1524 // (technical drawings ALR-0816/1-B), "Supporto Globale Settore SDD"
1525 // (technical drawings ALR-0816/2A, ALR-0816/2B, ALR-0816/2C, ALR-0816/2D), 
1526 // private communication with B. Giraudo
1527
1528   // Dimensions of the Central cylinder and flanges
1529   const Double_t kCylinderHalfLength = (790.0/2)*fgkmm;
1530   const Double_t kCylinderInnerR     = (210.0/2)*fgkmm;
1531   const Double_t kCylinderOuterR     = (231.0/2)*fgkmm;
1532   const Double_t kFlangeHalfLength   = ( 15.0/2)*fgkmm;
1533   const Double_t kFlangeInnerR       = (210.5/2)*fgkmm;
1534   const Double_t kFlangeOuterR       = (230.5/2)*fgkmm;
1535   const Double_t kInsertoHalfLength  =
1536                                      kCylinderHalfLength - 2*kFlangeHalfLength;
1537 //  const Double_t kCFThickness        = kFlangeInnerR - kCylinderInnerR;
1538   const Double_t kBoltDiameter       =       6.0*fgkmm; // M6 screw
1539   const Double_t kBoltDepth          =       6.0*fgkmm; // In the flange
1540   const Double_t kBoltRadius         = (220.0/2)*fgkmm; // Radius in flange
1541   const Double_t kThetaBolt          =      30.0*fgkDegree;
1542   const Int_t    kNBolts             = (Int_t)(360.0/kThetaBolt);
1543   // Dimensions of the Cone
1544   const Double_t kConeROutMin        = (540.0/2)*fgkmm;
1545   const Double_t kConeROutMax        = (560.0/2)*fgkmm;
1546   const Double_t kConeRCurv          =      10.0*fgkmm; // Radius of curvature
1547   const Double_t kConeRinMin         = (210.0/2)*fgkmm;
1548 //  const Double_t kConeRinMax         = (216.0/2)*fgkmm;
1549   const Double_t kConeRinCylinder    = (231.0/2)*fgkmm;
1550   const Double_t kConeZCylinder      =     192.0*fgkmm;
1551   const Double_t kConeZOuterMilled   =      23.0*fgkmm;
1552   const Double_t kConeDZin           =      15.0*fgkmm; // ???
1553   const Double_t kConeThickness      =      10.0*fgkmm; // Rohacell + Carb.Fib.
1554   const Double_t kConeTheta          =      45.0*fgkDegree; // SDD cone angle
1555   const Double_t kSinConeTheta       =
1556                                      TMath::Sin(kConeTheta*TMath::DegToRad());
1557   const Double_t kCosConeTheta       =
1558                                      TMath::Cos(kConeTheta*TMath::DegToRad());
1559   const Double_t kTanConeTheta       =
1560                                      TMath::Tan(kConeTheta*TMath::DegToRad());
1561   // Dimensions of the Cone Inserts
1562   const Double_t kConeCFThickness    =       1.5*fgkmm;//Carbon fiber thickness
1563   // Dimensions of the Cone Holes
1564   const Double_t kHole1RMin          = (450.0/2)*fgkmm;
1565   const Double_t kHole1RMax          = (530.0/2)*fgkmm;
1566   const Double_t kHole2RMin          = (280.0/2)*fgkmm;
1567   const Double_t kHole2RMax          = (375.0/2)*fgkmm;
1568   const Double_t kHole1Phi           =      25.0*fgkDegree;
1569   const Double_t kHole2Phi           =      50.0*fgkDegree;
1570   const Double_t kHole3RMin          =     205.0*fgkmm;
1571   const Double_t kHole3DeltaR        =        15*fgkmm;
1572   const Double_t kHole3Width         =        30*fgkmm;
1573   const Int_t    kNHole3             =         6      ;
1574   const Double_t kHole4RMin          =     116.0*fgkmm;
1575   const Double_t kHole4DeltaR        =        15*fgkmm;
1576   const Double_t kHole4Width         =        30*fgkmm;
1577   //  const Int_t    kNHole4             =         3      ;
1578   // Fraction of materials in holes
1579   const Double_t kHolePlasticFrac    =       0.55846;
1580   const Double_t kHoleCuFrac         =       0.06319;
1581   const Double_t kHoleGlassFrac      =       0.02652;
1582
1583   // Local variables
1584   Double_t x, y, z, t, dza, rmin, rmax;
1585
1586
1587   // Recover the needed materials
1588   TGeoMedium *medSDDcf    = mgr->GetMedium("ITS_SDD C (M55J)$");
1589   TGeoMedium *medSDDair   = mgr->GetMedium("ITS_SDD AIR$");
1590   TGeoMedium *medSDDste   = mgr->GetMedium("ITS_G10FR4$"); // stesalite
1591   TGeoMedium *medSDDroh   = mgr->GetMedium("ITS_ROHACELL$");
1592   TGeoMedium *medSDDss    = mgr->GetMedium("ITS_INOX$");
1593   TGeoMedium *medSDDplast = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
1594   TGeoMedium *medSDDCu    = mgr->GetMedium("ITS_COPPER$");
1595   TGeoMedium *medSDDglass = mgr->GetMedium("ITS_SDD OPTICFIB$");
1596
1597   // First define the geometrical shapes
1598
1599   // Central cylinder with its internal foam and the lateral flanges:
1600   // a carbon fiber Tube which contains a rohacell Tube and two
1601   // stesalite Tube's
1602   TGeoTube *cylindershape = new TGeoTube(kCylinderInnerR,kCylinderOuterR,
1603                                          kCylinderHalfLength);
1604
1605   TGeoTube *insertoshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
1606                                         kInsertoHalfLength);
1607
1608   TGeoTube *flangeshape = new TGeoTube(kFlangeInnerR,kFlangeOuterR,
1609                                        kFlangeHalfLength);
1610
1611   // The flange bolt: it is a Tube
1612   TGeoTube *boltshape = new TGeoTube(0.0, 0.5*kBoltDiameter, 0.5*kBoltDepth);
1613
1614   // Debug if requested
1615   if (GetDebug(1)) {
1616     cylindershape->InspectShape();
1617     insertoshape->InspectShape();
1618     flangeshape->InspectShape();
1619     boltshape->InspectShape();
1620   }
1621
1622
1623   // We have the shapes: now create the real volumes
1624
1625   TGeoVolume *cfcylinder = new TGeoVolume("SDDCarbonFiberCylinder",
1626                                           cylindershape,medSDDcf);
1627   cfcylinder->SetVisibility(kTRUE);
1628   cfcylinder->SetLineColor(4); // Blue
1629   cfcylinder->SetLineWidth(1);
1630   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
1631   cfcylinder->SetFillStyle(4000); // 0% transparent
1632
1633   TGeoVolume *foamcylinder = new TGeoVolume("SDDFoamCylinder",
1634                                             insertoshape,medSDDroh);
1635   foamcylinder->SetVisibility(kTRUE);
1636   foamcylinder->SetLineColor(3); // Green
1637   foamcylinder->SetLineWidth(1);
1638   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
1639   foamcylinder->SetFillStyle(4050); // 50% transparent
1640
1641   TGeoVolume *flangecylinder = new TGeoVolume("SDDFlangeCylinder",
1642                                               flangeshape,medSDDste);
1643   flangecylinder->SetVisibility(kTRUE);
1644   flangecylinder->SetLineColor(2); // Red
1645   flangecylinder->SetLineWidth(1);
1646   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
1647   flangecylinder->SetFillStyle(4050); // 50% transparent
1648
1649   TGeoVolume *bolt = new TGeoVolume("SDDFlangeBolt",boltshape,medSDDss);
1650   bolt->SetVisibility(kTRUE);
1651   bolt->SetLineColor(1);  // Black
1652   bolt->SetLineWidth(1);
1653   bolt->SetFillColor(bolt->GetLineColor());
1654   bolt->SetFillStyle(4050); // 50% transparent
1655
1656   // Mount up the cylinder
1657   for(Int_t i=0; i<kNBolts; i++){
1658     t = kThetaBolt*i;
1659     x = kBoltRadius*CosD(t);
1660     y = kBoltRadius*SinD(t);
1661     z = kFlangeHalfLength-kBoltDepth;
1662     flangecylinder->AddNode(bolt, i+1, new TGeoTranslation("",x,y,z));
1663   }
1664
1665   cfcylinder->AddNode(foamcylinder,1,0);
1666   cfcylinder->AddNode(flangecylinder,1,
1667               new TGeoTranslation(0, 0, kInsertoHalfLength+kFlangeHalfLength));
1668   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
1669               0, 0, -kInsertoHalfLength-kFlangeHalfLength,
1670               new TGeoRotation("",0,180,0)     ) );
1671
1672
1673   // SDD Support Cone with its internal inserts: a carbon fiber Pcon
1674   // with holes which contains a stesalite Pcon which on turn contains a
1675   // rohacell Pcon
1676
1677   dza = kConeThickness/kSinConeTheta-(kConeROutMax-kConeROutMin)/kTanConeTheta;
1678
1679   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 10);
1680
1681   coneshape->Z(0)     = 0.0;
1682   coneshape->Rmin(0)  = kConeROutMin;
1683   coneshape->Rmax(0)  = kConeROutMax;
1684
1685   coneshape->Z(1)     = kConeZOuterMilled - dza;
1686   coneshape->Rmin(1)  = coneshape->GetRmin(0);
1687   coneshape->Rmax(1)  = coneshape->GetRmax(0);
1688
1689   coneshape->Z(2)     = kConeZOuterMilled;
1690   coneshape->Rmax(2)  = coneshape->GetRmax(0);
1691
1692   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(1),
1693                     coneshape->GetRmin(1),kConeTheta,z,rmin);
1694   coneshape->Z(3)     = z;
1695   coneshape->Rmin(3)  = rmin;
1696
1697   coneshape->Rmin(2)  = RminFrom2Points(coneshape,3,1,coneshape->GetZ(2));
1698
1699   RadiusOfCurvature(kConeRCurv,0.,coneshape->GetZ(2),
1700                     coneshape->GetRmax(2),kConeTheta,z,rmax);
1701   coneshape->Z(4)     = z;
1702   coneshape->Rmax(4)  = rmax;
1703   coneshape->Rmin(4)  = RminFromZpCone(coneshape,3,kConeTheta,
1704                                        coneshape->GetZ(4),0.0);
1705
1706   coneshape->Rmax(3)  = RmaxFrom2Points(coneshape,4,2,coneshape->GetZ(3));
1707
1708   coneshape->Z(6)     = kConeZCylinder - kConeDZin;
1709
1710   RadiusOfCurvature(kConeRCurv,90.0,coneshape->GetZ(6),0.0,
1711                     90.0-kConeTheta,z,rmin);
1712   coneshape->Z(5)     = z;
1713   coneshape->Rmin(5)  = RminFromZpCone(coneshape,3,kConeTheta,z);
1714   coneshape->Rmax(5)  = RmaxFromZpCone(coneshape,4,kConeTheta,z);
1715
1716   RadiusOfCurvature(kConeRCurv,90.-kConeTheta,
1717                     0.0,coneshape->Rmin(5),90.0,z,rmin);
1718   coneshape->Rmin(6)  = rmin;
1719   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,4,kConeTheta,
1720                                        coneshape->GetZ(6));
1721
1722   coneshape->Z(7)     = coneshape->GetZ(6);
1723   coneshape->Rmin(7)  = kConeRinMin;
1724   coneshape->Rmax(7)  = coneshape->GetRmax(6);
1725
1726   coneshape->Rmin(8)  = kConeRinMin;
1727
1728   RadiusOfCurvature(kConeRCurv,90.0,kConeZCylinder,kConeRinCylinder,
1729                     90.0-kConeTheta,z,rmax);
1730   coneshape->Z(8)     = z;
1731   coneshape->Rmax(8)  = rmax;
1732
1733   coneshape->Z(9)     = kConeZCylinder;
1734   coneshape->Rmin(9)  = kConeRinMin;
1735   coneshape->Rmax(9)  = kConeRinCylinder;
1736
1737
1738   // SDD Cone Insert: another Pcon
1739   Double_t x0, y0, x1, y1, x2, y2;
1740   TGeoPcon *coneinsertshape = new TGeoPcon(0.0, 360.0, 9);
1741
1742   coneinsertshape->Z(0)    = coneshape->GetZ(0) + kConeCFThickness;
1743   coneinsertshape->Rmin(0) = coneshape->GetRmin(0) + kConeCFThickness;
1744   coneinsertshape->Rmax(0) = coneshape->GetRmax(0) - kConeCFThickness;
1745
1746   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
1747   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
1748   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
1749   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1750   coneinsertshape->Z(1)    = z;
1751   coneinsertshape->Rmin(1) = rmin;
1752   coneinsertshape->Rmax(1) = coneinsertshape->GetRmax(0);
1753
1754   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmax(1);
1755   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmax(2);
1756   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmax(3);
1757   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1758   coneinsertshape->Z(2)    = z;
1759   coneinsertshape->Rmax(2) = rmax;
1760
1761   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
1762   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
1763   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
1764   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1765   coneinsertshape->Z(3)    = z;
1766   coneinsertshape->Rmin(3) = rmin;
1767
1768   x0 = coneinsertshape->GetZ(1); y0 = coneinsertshape->GetRmin(1);
1769   x1 = coneinsertshape->GetZ(3); y1 = coneinsertshape->GetRmin(3);
1770   coneinsertshape->Rmin(2) = Yfrom2Points(x0, y0, x1, y1,
1771                                           coneinsertshape->Z(2));
1772
1773   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
1774   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
1775   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
1776   InsidePoint(x0, y0, x1, y1, x2, y2, -kConeCFThickness, z, rmax);
1777   coneinsertshape->Z(4)    = z;
1778   coneinsertshape->Rmax(4) = rmax;
1779
1780   x0 = coneinsertshape->GetZ(2); y0 = coneinsertshape->GetRmax(2);
1781   x1 = coneinsertshape->GetZ(4); y1 = coneinsertshape->GetRmax(4);
1782   coneinsertshape->Rmax(3) = Yfrom2Points(x0, y0, x1, y1,
1783                                           coneinsertshape->Z(3));
1784
1785   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmin(4);
1786   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmin(5);
1787   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmin(6);
1788   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1789   coneinsertshape->Z(5)    = z;
1790   coneinsertshape->Rmin(5) = rmin;
1791   coneinsertshape->Rmax(5) = coneinsertshape->GetRmax(4) -
1792           kTanConeTheta*(coneinsertshape->GetZ(5) - coneinsertshape->GetZ(4));
1793
1794   x0 = coneinsertshape->GetZ(3); y0 = coneinsertshape->GetRmin(3);
1795   x1 = coneinsertshape->GetZ(5); y1 = coneinsertshape->GetRmin(5);
1796   coneinsertshape->Rmin(4) = Yfrom2Points(x0, y0, x1, y1,
1797                                           coneinsertshape->Z(4));
1798
1799   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmin(5);
1800   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmin(6);
1801   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmin(7);
1802   InsidePoint(x0, y0, x1, y1, x2, y2,  kConeCFThickness, z, rmin);
1803   coneinsertshape->Z(6)    = z;
1804   coneinsertshape->Rmin(6) = rmin;
1805   coneinsertshape->Rmax(6) = coneinsertshape->GetRmax(4) -
1806           kTanConeTheta*(coneinsertshape->GetZ(6) - coneinsertshape->GetZ(4));
1807
1808   coneinsertshape->Z(7)    = coneinsertshape->GetZ(6);
1809   coneinsertshape->Rmin(7) = coneshape->GetRmin(7) + kConeCFThickness;
1810   coneinsertshape->Rmax(7) = coneinsertshape->GetRmax(6);
1811
1812   coneinsertshape->Z(8)    = coneshape->GetZ(9) - kConeCFThickness;
1813   coneinsertshape->Rmin(8) = coneinsertshape->GetRmin(7);
1814   coneinsertshape->Rmax(8) = coneinsertshape->GetRmax(4) -
1815           kTanConeTheta*(coneinsertshape->GetZ(8) - coneinsertshape->GetZ(4));
1816
1817   // SDD Cone Foam: another Pcon
1818   TGeoPcon *conefoamshape = new TGeoPcon(0.0, 360.0, 4);
1819
1820   RadiusOfCurvature(kConeRCurv+kConeCFThickness,0.0,coneinsertshape->GetZ(1),
1821                     coneinsertshape->GetRmin(1),kConeTheta,z,rmin);
1822
1823   conefoamshape->Z(0)    = z;
1824   conefoamshape->Rmin(0) = rmin;
1825   conefoamshape->Rmax(0) = conefoamshape->GetRmin(0);
1826
1827   conefoamshape->Z(1)    = conefoamshape->GetZ(0)+
1828                          (kConeThickness-2.0*kConeCFThickness)/kSinConeTheta;
1829   conefoamshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1830                                           conefoamshape->GetZ(1));
1831   conefoamshape->Rmax(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1832                                           conefoamshape->GetZ(1));
1833
1834   conefoamshape->Z(2)    = coneshape->GetZ(5)-kConeCFThickness;
1835   conefoamshape->Rmin(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1836                                           conefoamshape->GetZ(2));
1837   conefoamshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1838                                           conefoamshape->GetZ(2));
1839
1840   conefoamshape->Z(3)    = coneinsertshape->GetZ(5)+
1841                          (kConeThickness-2.0*kConeCFThickness)*kCosConeTheta;
1842   conefoamshape->Rmax(3) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1843                                           conefoamshape->GetZ(3));
1844   conefoamshape->Rmin(3) = conefoamshape->GetRmax(3);
1845
1846   // SDD Cone Holes: Pcon's
1847   // A single hole volume gives an overlap with coneinsert, so
1848   // three contiguous volumes are created: one to be put in the cone foam
1849   // and two in the cone carbon fiber envelope
1850   TGeoPcon *hole1shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1851
1852   hole1shape->Rmin(0) = kHole1RMax;
1853   hole1shape->Rmax(0) = hole1shape->GetRmin(0);
1854   hole1shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1855                                        hole1shape->GetRmin(0));
1856
1857   hole1shape->Rmax(1) = hole1shape->GetRmax(0);
1858   hole1shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1859                                        hole1shape->GetRmax(1));
1860   hole1shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1861                                        hole1shape->GetZ(1));
1862
1863   hole1shape->Rmin(2) = kHole1RMin;
1864   hole1shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1865                                        hole1shape->GetRmin(2));
1866   hole1shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1867                                        hole1shape->GetZ(2));
1868
1869   hole1shape->Rmin(3) = hole1shape->GetRmin(2);
1870   hole1shape->Rmax(3) = hole1shape->GetRmin(3);
1871   hole1shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1872                                        hole1shape->GetRmax(3));
1873
1874   TGeoPcon *hole11shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1875
1876   hole11shape->Rmin(0) = kHole1RMax;
1877   hole11shape->Rmax(0) = hole11shape->GetRmin(0);
1878   hole11shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1879                                         hole11shape->GetRmin(0));
1880
1881   hole11shape->Rmax(1) = hole11shape->GetRmax(0);
1882   hole11shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1883                                         hole11shape->GetRmax(1));
1884   hole11shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1885                                         hole11shape->GetZ(1));
1886
1887   hole11shape->Rmin(2) = kHole1RMin;
1888   hole11shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1889                                         hole11shape->GetRmin(2));
1890   hole11shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1891                                         hole11shape->GetZ(2));
1892
1893   hole11shape->Rmin(3) = hole11shape->GetRmin(2);
1894   hole11shape->Rmax(3) = hole11shape->GetRmin(3);
1895   hole11shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1896                                         hole11shape->GetRmax(3));
1897
1898   TGeoPcon *hole12shape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
1899
1900   hole12shape->Rmin(0) = kHole1RMax;
1901   hole12shape->Rmax(0) = hole12shape->GetRmin(0);
1902   hole12shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1903                                         hole12shape->GetRmin(0));
1904
1905   hole12shape->Rmax(1) = hole12shape->GetRmax(0);
1906   hole12shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1907                                         hole12shape->GetRmax(1));
1908   hole12shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1909                                         hole12shape->GetZ(1));
1910
1911   hole12shape->Rmin(2) = kHole1RMin;
1912   hole12shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1913                                         hole12shape->GetRmin(2));
1914   hole12shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1915                                         hole12shape->GetZ(2));
1916
1917   hole12shape->Rmin(3) = hole12shape->GetRmin(2);
1918   hole12shape->Rmax(3) = hole12shape->GetRmin(3);
1919   hole12shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1920                                         hole12shape->GetRmax(3));
1921
1922   //
1923   TGeoPcon *hole2shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1924
1925   hole2shape->Rmin(0) = kHole2RMax;
1926   hole2shape->Rmax(0) = hole2shape->GetRmin(0);
1927   hole2shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
1928                                        hole2shape->GetRmin(0));
1929
1930   hole2shape->Rmax(1) = hole2shape->GetRmax(0);
1931   hole2shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1932                                        hole2shape->GetRmax(1));
1933   hole2shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
1934                                        hole2shape->GetZ(1));
1935
1936   hole2shape->Rmin(2) = kHole2RMin;
1937   hole2shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
1938                                        hole2shape->GetRmin(2));
1939   hole2shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
1940                                        hole2shape->GetZ(2));
1941
1942   hole2shape->Rmin(3) = hole2shape->GetRmin(2);
1943   hole2shape->Rmax(3) = hole2shape->GetRmin(3);
1944   hole2shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
1945                                        hole2shape->GetRmax(3));
1946
1947   TGeoPcon *hole21shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1948
1949   hole21shape->Rmin(0) = kHole2RMax;
1950   hole21shape->Rmax(0) = hole21shape->GetRmin(0);
1951   hole21shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
1952                                         hole21shape->GetRmin(0));
1953
1954   hole21shape->Rmax(1) = hole21shape->GetRmax(0);
1955   hole21shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1956                                         hole21shape->GetRmax(1));
1957   hole21shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
1958                                         hole21shape->GetZ(1));
1959
1960   hole21shape->Rmin(2) = kHole2RMin;
1961   hole21shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
1962                                         hole21shape->GetRmin(2));
1963   hole21shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
1964                                         hole21shape->GetZ(2));
1965
1966   hole21shape->Rmin(3) = hole21shape->GetRmin(2);
1967   hole21shape->Rmax(3) = hole21shape->GetRmin(3);
1968   hole21shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
1969                                         hole21shape->GetRmax(3));
1970
1971   TGeoPcon *hole22shape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
1972
1973   hole22shape->Rmin(0) = kHole2RMax;
1974   hole22shape->Rmax(0) = hole22shape->GetRmin(0);
1975   hole22shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1976                                         hole22shape->GetRmin(0));
1977
1978   hole22shape->Rmax(1) = hole22shape->GetRmax(0);
1979   hole22shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1980                                         hole22shape->GetRmax(1));
1981   hole22shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
1982                                         hole22shape->GetZ(1));
1983
1984   hole22shape->Rmin(2) = kHole2RMin;
1985   hole22shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
1986                                         hole22shape->GetRmin(2));
1987   hole22shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
1988                                         hole22shape->GetZ(2));
1989
1990   hole22shape->Rmin(3) = hole22shape->GetRmin(2);
1991   hole22shape->Rmax(3) = hole22shape->GetRmin(3);
1992   hole22shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
1993                                         hole22shape->GetRmax(3));
1994
1995   //
1996   Double_t holePhi;
1997   holePhi = (kHole3Width/kHole3RMin)*TMath::RadToDeg();
1998
1999   TGeoPcon *hole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2000
2001   hole3shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
2002   hole3shape->Rmax(0) = hole3shape->GetRmin(0);
2003   hole3shape->Z(0)    = ZFromRminpCone(conefoamshape,0,kConeTheta,
2004                                        hole3shape->GetRmin(0));
2005
2006   hole3shape->Rmax(1) = hole3shape->GetRmax(0);
2007   hole3shape->Z(1)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2008                                        hole3shape->GetRmax(1));
2009   hole3shape->Rmin(1) = RminFromZpCone(conefoamshape,1,kConeTheta,
2010                                        hole3shape->GetZ(1));
2011
2012   hole3shape->Rmin(2) = kHole3RMin;
2013   hole3shape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2014                                        hole3shape->GetRmin(2));
2015   hole3shape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
2016                                        hole3shape->GetZ(2));
2017
2018   hole3shape->Rmin(3) = hole3shape->GetRmin(2);
2019   hole3shape->Rmax(3) = hole3shape->GetRmin(3);
2020   hole3shape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2021                                        hole3shape->GetRmax(3));
2022
2023   TGeoPcon *hole31shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2024
2025   hole31shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
2026   hole31shape->Rmax(0) = hole31shape->GetRmin(0);
2027   hole31shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
2028                                         hole31shape->GetRmin(0));
2029
2030   hole31shape->Rmax(1) = hole31shape->GetRmax(0);
2031   hole31shape->Z(1)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
2032                                         hole31shape->GetRmax(1));
2033   hole31shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
2034                                         hole31shape->GetZ(1));
2035
2036   hole31shape->Rmin(2) = kHole3RMin;
2037   hole31shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
2038                                         hole31shape->GetRmin(2));
2039   hole31shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,kConeTheta,
2040                                         hole31shape->GetZ(2));
2041
2042   hole31shape->Rmin(3) = hole31shape->GetRmin(2);
2043   hole31shape->Rmax(3) = hole31shape->GetRmin(3);
2044   hole31shape->Z(3)    = ZFromRminpCone(coneinsertshape,3,kConeTheta,
2045                                         hole31shape->GetRmax(3));
2046
2047   TGeoPcon *hole32shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2048
2049   hole32shape->Rmin(0) = kHole3RMin + kHole3DeltaR;
2050   hole32shape->Rmax(0) = hole32shape->GetRmin(0);
2051   hole32shape->Z(0)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
2052                                         hole32shape->GetRmin(0));
2053
2054   hole32shape->Rmax(1) = hole32shape->GetRmax(0);
2055   hole32shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
2056                                         hole32shape->GetRmax(1));
2057   hole32shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,4,kConeTheta,
2058                                         hole32shape->GetZ(1));
2059
2060   hole32shape->Rmin(2) = kHole3RMin;
2061   hole32shape->Z(2)    = ZFromRmaxpCone(coneinsertshape,4,kConeTheta,
2062                                         hole32shape->GetRmin(2));
2063   hole32shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
2064                                         hole32shape->GetZ(2));
2065
2066   hole32shape->Rmin(3) = hole32shape->GetRmin(2);
2067   hole32shape->Rmax(3) = hole32shape->GetRmin(3);
2068   hole32shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
2069                                         hole32shape->GetRmax(3));
2070
2071   //
2072   holePhi = (kHole4Width/kHole4RMin)*TMath::RadToDeg();
2073
2074   TGeoPcon *hole4shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2075
2076   hole4shape->Rmin(0) = kHole4RMin + kHole4DeltaR;
2077   hole4shape->Rmax(0) = hole4shape->GetRmin(0);
2078   hole4shape->Z(0)    = ZFromRminpCone(coneshape,3,kConeTheta,
2079                                        hole4shape->GetRmin(0));
2080
2081   hole4shape->Rmax(1) = hole4shape->GetRmax(0);
2082   hole4shape->Z(1)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
2083                                        hole4shape->GetRmax(1));
2084   hole4shape->Rmin(1) = RminFromZpCone(coneshape,3,kConeTheta,
2085                                        hole4shape->GetZ(1));
2086
2087   hole4shape->Rmin(2) = kHole4RMin;
2088   hole4shape->Z(2)    = ZFromRminpCone(coneshape,3,kConeTheta,
2089                                        hole4shape->GetRmin(2));
2090   hole4shape->Rmax(2) = RmaxFromZpCone(coneshape,4,kConeTheta,
2091                                        hole4shape->GetZ(2));
2092
2093   hole4shape->Rmin(3) = hole4shape->GetRmin(2);
2094   hole4shape->Rmax(3) = hole4shape->GetRmin(3);
2095   hole4shape->Z(3)    = ZFromRmaxpCone(coneshape,4,kConeTheta,
2096                                        hole4shape->GetRmax(3));
2097
2098   // Cables to be put inside the holes: Pcon's
2099   // (fractions are manually computed from AliITSv11GeometrySDD::SDDCables
2100   TGeoPcon *hole1plastshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
2101
2102   hole1plastshape->Rmin(0) = hole1shape->GetRmin(0);
2103   hole1plastshape->Rmax(0) = hole1shape->GetRmax(0);
2104   hole1plastshape->Z(0)    = hole1shape->GetZ(0);
2105
2106   hole1plastshape->Rmin(1) = hole1shape->GetRmin(1);
2107   hole1plastshape->Rmax(1) = hole1shape->GetRmax(1);
2108   hole1plastshape->Z(1)    = hole1shape->GetZ(1);
2109
2110   dza = hole1plastshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHolePlasticFrac;
2111
2112   hole1plastshape->Rmin(2) = dza;
2113   hole1plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2114                                             hole1plastshape->GetRmin(2));
2115   hole1plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
2116                                             hole1plastshape->GetZ(2));
2117
2118   hole1plastshape->Rmin(3) = hole1plastshape->GetRmin(2);
2119   hole1plastshape->Rmax(3) = hole1plastshape->GetRmin(3);
2120   hole1plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2121                                             hole1plastshape->GetRmax(3));
2122
2123   TGeoPcon *hole1Cushape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
2124
2125   hole1Cushape->Rmin(0) = hole1plastshape->GetRmin(2);
2126   hole1Cushape->Rmax(0) = hole1Cushape->GetRmin(0);
2127   hole1Cushape->Z(0)    = hole1plastshape->GetZ(2);
2128
2129   dza = hole1Cushape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleCuFrac;
2130
2131   hole1Cushape->Rmin(1) = dza;
2132   hole1Cushape->Rmax(1) = hole1Cushape->GetRmax(0);
2133   hole1Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2134                                          hole1Cushape->GetRmin(1));
2135
2136   hole1Cushape->Rmax(2) = hole1Cushape->GetRmax(0);
2137   hole1Cushape->Rmin(2) = hole1Cushape->GetRmin(1);
2138   hole1Cushape->Z(2)    = hole1plastshape->GetZ(3);
2139
2140   hole1Cushape->Rmin(3) = hole1Cushape->GetRmin(1);
2141   hole1Cushape->Rmax(3) = hole1Cushape->GetRmin(3);
2142   hole1Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2143                                          hole1Cushape->GetRmax(3));
2144
2145   TGeoPcon *hole1glassshape = new TGeoPcon(-kHole1Phi/2., kHole1Phi, 4);
2146
2147   hole1glassshape->Rmin(0) = hole1Cushape->GetRmin(1);
2148   hole1glassshape->Rmax(0) = hole1glassshape->GetRmin(0);
2149   hole1glassshape->Z(0)    = hole1Cushape->GetZ(1);
2150
2151   dza = hole1glassshape->GetRmax(0) - (kHole1RMax-kHole1RMin)*kHoleGlassFrac;
2152
2153   hole1glassshape->Rmin(1) = dza;
2154   hole1glassshape->Rmax(1) = hole1glassshape->GetRmax(0);
2155   hole1glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2156                                             hole1glassshape->GetRmin(1));
2157
2158   hole1glassshape->Rmax(2) = hole1glassshape->GetRmax(0);
2159   hole1glassshape->Rmin(2) = hole1glassshape->GetRmin(1);
2160   hole1glassshape->Z(2)    = hole1Cushape->GetZ(3);
2161
2162   hole1glassshape->Rmin(3) = hole1glassshape->GetRmin(1);
2163   hole1glassshape->Rmax(3) = hole1glassshape->GetRmin(3);
2164   hole1glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2165                                             hole1glassshape->GetRmax(3));
2166   //
2167   TGeoPcon *hole2plastshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2168
2169   hole2plastshape->Rmin(0) = hole2shape->GetRmin(0);
2170   hole2plastshape->Rmax(0) = hole2shape->GetRmax(0);
2171   hole2plastshape->Z(0)    = hole2shape->GetZ(0);
2172
2173   hole2plastshape->Rmin(1) = hole2shape->GetRmin(1);
2174   hole2plastshape->Rmax(1) = hole2shape->GetRmax(1);
2175   hole2plastshape->Z(1)    = hole2shape->GetZ(1);
2176
2177   dza = hole2plastshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHolePlasticFrac;
2178
2179   hole2plastshape->Rmin(2) = dza;
2180   hole2plastshape->Z(2)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2181                                             hole2plastshape->GetRmin(2));
2182   hole2plastshape->Rmax(2) = RmaxFromZpCone(conefoamshape,3,kConeTheta,
2183                                             hole2plastshape->GetZ(2));
2184
2185   hole2plastshape->Rmin(3) = hole2plastshape->GetRmin(2);
2186   hole2plastshape->Rmax(3) = hole2plastshape->GetRmin(3);
2187   hole2plastshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2188                                             hole2plastshape->GetRmax(3));
2189
2190   TGeoPcon *hole2Cushape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2191
2192   hole2Cushape->Rmin(0) = hole2plastshape->GetRmin(2);
2193   hole2Cushape->Rmax(0) = hole2Cushape->GetRmin(0);
2194   hole2Cushape->Z(0)    = hole2plastshape->GetZ(2);
2195
2196   dza = hole2Cushape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleCuFrac;
2197
2198   hole2Cushape->Rmin(1) = dza;
2199   hole2Cushape->Rmax(1) = hole2Cushape->GetRmax(0);
2200   hole2Cushape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2201                                          hole2Cushape->GetRmin(1));
2202
2203   hole2Cushape->Rmax(2) = hole2Cushape->GetRmax(0);
2204   hole2Cushape->Rmin(2) = hole2Cushape->GetRmin(1);
2205   hole2Cushape->Z(2)    = hole2plastshape->GetZ(3);
2206
2207   hole2Cushape->Rmin(3) = hole2Cushape->GetRmin(1);
2208   hole2Cushape->Rmax(3) = hole2Cushape->GetRmin(3);
2209   hole2Cushape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2210                                          hole2Cushape->GetRmax(3));
2211
2212   TGeoPcon *hole2glassshape = new TGeoPcon(-kHole2Phi/2., kHole2Phi, 4);
2213
2214   hole2glassshape->Rmin(0) = hole2Cushape->GetRmin(1);
2215   hole2glassshape->Rmax(0) = hole2glassshape->GetRmin(0);
2216   hole2glassshape->Z(0)    = hole2Cushape->GetZ(1);
2217
2218   dza = hole2glassshape->GetRmax(0) - (kHole2RMax-kHole2RMin)*kHoleGlassFrac;
2219
2220   hole2glassshape->Rmin(1) = dza;
2221   hole2glassshape->Rmax(1) = hole2glassshape->GetRmax(0);
2222   hole2glassshape->Z(1)    = ZFromRminpCone(conefoamshape,1,kConeTheta,
2223                                             hole2glassshape->GetRmin(1));
2224
2225   hole2glassshape->Rmax(2) = hole2glassshape->GetRmax(0);
2226   hole2glassshape->Rmin(2) = hole2glassshape->GetRmin(1);
2227   hole2glassshape->Z(2)    = hole2Cushape->GetZ(3);
2228
2229   hole2glassshape->Rmin(3) = hole2glassshape->GetRmin(1);
2230   hole2glassshape->Rmax(3) = hole2glassshape->GetRmin(3);
2231   hole2glassshape->Z(3)    = ZFromRmaxpCone(conefoamshape,3,kConeTheta,
2232                                             hole2glassshape->GetRmax(3));
2233
2234
2235   // Debug if requested
2236   if (GetDebug(1)) {
2237     coneshape->InspectShape();
2238     coneinsertshape->InspectShape();
2239     conefoamshape->InspectShape();
2240     hole1shape->InspectShape();
2241     hole2shape->InspectShape();
2242     hole3shape->InspectShape();
2243     hole4shape->InspectShape();
2244   }
2245
2246
2247   // We have the shapes: now create the real volumes
2248
2249   TGeoVolume *cfcone = new TGeoVolume("SDDCarbonFiberCone",
2250                                       coneshape,medSDDcf);
2251   cfcone->SetVisibility(kTRUE);
2252   cfcone->SetLineColor(4); // Blue
2253   cfcone->SetLineWidth(1);
2254   cfcone->SetFillColor(cfcone->GetLineColor());
2255   cfcone->SetFillStyle(4000); // 0% transparent
2256
2257   TGeoVolume *cfconeinsert = new TGeoVolume("SDDCarbonFiberConeInsert",
2258                                             coneinsertshape,medSDDste);
2259   cfconeinsert->SetVisibility(kTRUE);
2260   cfconeinsert->SetLineColor(2); // Red
2261   cfconeinsert->SetLineWidth(1);
2262   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
2263   cfconeinsert->SetFillStyle(4050); // 50% transparent
2264
2265   TGeoVolume *cfconefoam = new TGeoVolume("SDDCarbonFiberConeFoam",
2266                                           conefoamshape,medSDDroh);
2267   cfconefoam->SetVisibility(kTRUE);
2268   cfconefoam->SetLineColor(7); // Light blue
2269   cfconefoam->SetLineWidth(1);
2270   cfconefoam->SetFillColor(cfconefoam->GetLineColor());
2271   cfconefoam->SetFillStyle(4050); // 50% transparent
2272
2273   TGeoVolume *hole1 = new TGeoVolume("SDDCableHole1",
2274                                      hole1shape,medSDDair);
2275   hole1->SetVisibility(kTRUE);
2276   hole1->SetLineColor(5); // Yellow
2277   hole1->SetLineWidth(1);
2278   hole1->SetFillColor(hole1->GetLineColor());
2279   hole1->SetFillStyle(4090); // 90% transparent
2280
2281   TGeoVolume *hole11 = new TGeoVolume("SDDCableHole11",
2282                                       hole11shape,medSDDair);
2283   hole11->SetVisibility(kTRUE);
2284   hole11->SetLineColor(5); // Yellow
2285   hole11->SetLineWidth(1);
2286   hole11->SetFillColor(hole11->GetLineColor());
2287   hole11->SetFillStyle(4090); // 90% transparent
2288
2289   TGeoVolume *hole12 = new TGeoVolume("SDDCableHole12",
2290                                       hole12shape,medSDDair);
2291   hole12->SetVisibility(kTRUE);
2292   hole12->SetLineColor(5); // Yellow
2293   hole12->SetLineWidth(1);
2294   hole12->SetFillColor(hole12->GetLineColor());
2295   hole12->SetFillStyle(4090); // 90% transparent
2296
2297   TGeoVolume *hole1plast = new TGeoVolume("SDDCableHole1Plast",
2298                                           hole1plastshape,medSDDplast);
2299   hole1plast->SetVisibility(kTRUE);
2300   hole1plast->SetLineColor(kBlue);
2301   hole1plast->SetLineWidth(1);
2302   hole1plast->SetFillColor(hole1plast->GetLineColor());
2303   hole1plast->SetFillStyle(4090); // 90% transparent
2304
2305   TGeoVolume *hole1Cu = new TGeoVolume("SDDCableHole1Cu",
2306                                        hole1Cushape,medSDDCu);
2307   hole1Cu->SetVisibility(kTRUE);
2308   hole1Cu->SetLineColor(kRed);
2309   hole1Cu->SetLineWidth(1);
2310   hole1Cu->SetFillColor(hole1Cu->GetLineColor());
2311   hole1Cu->SetFillStyle(4090); // 90% transparent
2312
2313   TGeoVolume *hole1glass = new TGeoVolume("SDDCableHole1glass",
2314                                           hole1glassshape,medSDDglass);
2315   hole1glass->SetVisibility(kTRUE);
2316   hole1glass->SetLineColor(kGreen);
2317   hole1glass->SetLineWidth(1);
2318   hole1glass->SetFillColor(hole1glass->GetLineColor());
2319   hole1glass->SetFillStyle(4090); // 90% transparent
2320
2321   TGeoVolume *hole2 = new TGeoVolume("SDDCableHole2",
2322                                      hole2shape,medSDDair);
2323   hole2->SetVisibility(kTRUE);
2324   hole2->SetLineColor(5); // Yellow
2325   hole2->SetLineWidth(1);
2326   hole2->SetFillColor(hole2->GetLineColor());
2327   hole2->SetFillStyle(4090); // 90% transparent
2328
2329   TGeoVolume *hole21 = new TGeoVolume("SDDCableHole21",
2330                                       hole21shape,medSDDair);
2331   hole21->SetVisibility(kTRUE);
2332   hole21->SetLineColor(5); // Yellow
2333   hole21->SetLineWidth(1);
2334   hole21->SetFillColor(hole21->GetLineColor());
2335   hole21->SetFillStyle(4090); // 90% transparent
2336
2337   TGeoVolume *hole22 = new TGeoVolume("SDDCableHole22",
2338                                       hole22shape,medSDDair);
2339   hole22->SetVisibility(kTRUE);
2340   hole22->SetLineColor(5); // Yellow
2341   hole22->SetLineWidth(1);
2342   hole22->SetFillColor(hole22->GetLineColor());
2343   hole22->SetFillStyle(4090); // 90% transparent
2344
2345   TGeoVolume *hole2plast = new TGeoVolume("SDDCableHole2Plast",
2346                                           hole2plastshape,medSDDplast);
2347   hole2plast->SetVisibility(kTRUE);
2348   hole2plast->SetLineColor(kBlue);
2349   hole2plast->SetLineWidth(1);
2350   hole2plast->SetFillColor(hole2plast->GetLineColor());
2351   hole2plast->SetFillStyle(4090); // 90% transparent
2352
2353   TGeoVolume *hole2Cu = new TGeoVolume("SDDCableHole2Cu",
2354                                        hole2Cushape,medSDDCu);
2355   hole2Cu->SetVisibility(kTRUE);
2356   hole2Cu->SetLineColor(kRed);
2357   hole2Cu->SetLineWidth(1);
2358   hole2Cu->SetFillColor(hole2Cu->GetLineColor());
2359   hole2Cu->SetFillStyle(4090); // 90% transparent
2360
2361   TGeoVolume *hole2glass = new TGeoVolume("SDDCableHole2glass",
2362                                           hole2glassshape,medSDDglass);
2363   hole2glass->SetVisibility(kTRUE);
2364   hole2glass->SetLineColor(kGreen);
2365   hole2glass->SetLineWidth(1);
2366   hole2glass->SetFillColor(hole2glass->GetLineColor());
2367   hole2glass->SetFillStyle(4090); // 90% transparent
2368
2369   TGeoVolume *hole3 = new TGeoVolume("SDDCableHole3",
2370                                      hole3shape,medSDDair);
2371   hole3->SetVisibility(kTRUE);
2372   hole3->SetLineColor(5); // Yellow
2373   hole3->SetLineWidth(1);
2374   hole3->SetFillColor(hole3->GetLineColor());
2375   hole3->SetFillStyle(4090); // 90% transparent
2376
2377   TGeoVolume *hole31 = new TGeoVolume("SDDCableHole31",
2378                                       hole31shape,medSDDair);
2379   hole31->SetVisibility(kTRUE);
2380   hole31->SetLineColor(5); // Yellow
2381   hole31->SetLineWidth(1);
2382   hole31->SetFillColor(hole31->GetLineColor());
2383   hole31->SetFillStyle(4090); // 90% transparent
2384
2385   TGeoVolume *hole32 = new TGeoVolume("SDDCableHole32",
2386                                       hole32shape,medSDDair);
2387   hole32->SetVisibility(kTRUE);
2388   hole32->SetLineColor(5); // Yellow
2389   hole32->SetLineWidth(1);
2390   hole32->SetFillColor(hole32->GetLineColor());
2391   hole32->SetFillStyle(4090); // 90% transparent
2392
2393   TGeoVolume *hole4 = new TGeoVolume("SDDCableHole4",
2394                                      hole4shape,medSDDair);
2395   hole4->SetVisibility(kTRUE);
2396   hole4->SetLineColor(5); // Yellow
2397   hole4->SetLineWidth(1);
2398   hole4->SetFillColor(hole4->GetLineColor());
2399   hole4->SetFillStyle(4090); // 90% transparent
2400
2401   // Mount up a cone
2402   cfconeinsert->AddNode(cfconefoam,1,0);
2403
2404   hole1->AddNode(hole1plast, 1, 0);
2405   hole1->AddNode(hole1Cu, 1, 0);
2406   hole1->AddNode(hole1glass, 1, 0);
2407
2408   hole2->AddNode(hole2plast, 1, 0);
2409   hole2->AddNode(hole2Cu, 1, 0);
2410   hole2->AddNode(hole2glass, 1, 0);
2411
2412   for (Int_t i=0; i<12; i++) {
2413     Double_t phiH = i*30.0;
2414     cfconefoam->AddNode(hole1 , i+1, new TGeoRotation("", 0, 0, phiH));
2415         cfcone->AddNode(hole11, i+1, new TGeoRotation("", 0, 0, phiH));
2416         cfcone->AddNode(hole12, i+1, new TGeoRotation("", 0, 0, phiH));
2417   }
2418
2419   for (Int_t i=0; i<6; i++) {
2420     Double_t phiH = i*60.0;
2421     cfconefoam->AddNode(hole2 , i+1, new TGeoRotation("", 0, 0, phiH));
2422         cfcone->AddNode(hole21, i+1, new TGeoRotation("", 0, 0, phiH));
2423         cfcone->AddNode(hole22, i+1, new TGeoRotation("", 0, 0, phiH));
2424   }
2425
2426   for (Int_t i=0; i<kNHole3; i++) {
2427     Double_t phiH0 = 360./(Double_t)kNHole3;
2428     Double_t phiH  = i*phiH0 + 0.5*phiH0;
2429     cfconefoam->AddNode(hole3 , i+1, new TGeoRotation("", phiH, 0, 0));
2430         cfcone->AddNode(hole31, i+1, new TGeoRotation("", phiH, 0, 0));
2431         cfcone->AddNode(hole32, i+1, new TGeoRotation("", phiH, 0, 0));
2432   }
2433
2434   cfcone->AddNode(cfconeinsert,1,0);
2435
2436 /*
2437   for (Int_t i=0; i<kNHole4; i++) {
2438     Double_t phiH0 = 360./(Double_t)kNHole4;
2439     Double_t phiH  = i*phiH0 + 0.25*phiH0;
2440     cfcone->AddNode(hole4, i+1, new TGeoRotation("", phiH, 0, 0));
2441   }
2442 */
2443   // Finally put everything in the mother volume
2444   moth->AddNode(cfcylinder,1,0);
2445
2446   z = coneshape->Z(9);
2447   moth->AddNode(cfcone,1,new TGeoTranslation(0, 0, -z - kCylinderHalfLength));
2448   moth->AddNode(cfcone,2,new TGeoCombiTrans (0, 0,  z + kCylinderHalfLength,
2449                          new TGeoRotation("", 0, 180, 0)                   ));
2450
2451
2452   return;
2453 }
2454
2455 //______________________________________________________________________
2456 void AliITSv11GeometrySupport::SSDCone(TGeoVolume *moth,const TGeoManager *mgr)
2457 {
2458 //
2459 // Creates the SSD support cone and cylinder geometry. as a
2460 // volume assembly and adds it to the mother volume
2461 // (part of this code is taken or anyway inspired to SSDCone method
2462 // of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
2463 //
2464 // Input:
2465 //         moth : the TGeoVolume owing the volume structure
2466 //         mgr  : the GeoManager (default gGeoManager)
2467 // Output:
2468 //
2469 // Created:         ???       Bjorn S. Nilsen
2470 // Updated:      08 Mar 2008  Mario Sitta
2471 //
2472 // Technical data are taken from:  "ITS Supporto Generale" (technical
2473 // drawings ALR3-0743/1, ALR3-0743/1A and ALR3-0743/1B), "Supporto Generale
2474 // Settore SSD" (technical drawings ALR3-0743/2A and ALR3-0743/2E), private
2475 // communication with B. Giraudo
2476 //
2477 // Updated:      11 Apr 2008  Mario Sitta
2478 // Measures from drawings give overlaps with SPD thermal shield wings,
2479 // so the terminal part of the SSD cone was reduced
2480 //
2481 // Updated:      30 Mar 2010  Mario Sitta
2482 // Following M. van Leeuwen's suggestion on material budget, the thickness
2483 // of the carbon fiber cylinder was increased from 0.6 to 0.625mm
2484
2485   // Dimensions of the Central cylinder and flanges
2486   const Double_t kCylinderHalfLength   = (1143.6/2) *fgkmm;
2487   const Double_t kCylinderOuterRadius  = ( 595.0/2) *fgkmm;
2488   const Double_t kCylinderThickness    =       0.625*fgkmm;
2489   const Double_t kFoamHalfLength       = (1020.0/2) *fgkmm;
2490   const Double_t kFoamThickness        =        5.0 *fgkmm;
2491   const Double_t kFlangeHalfLength     =
2492                                       (kCylinderHalfLength-kFoamHalfLength)/2.;
2493   const Double_t kFlangeInnerRadius    = ( 563.0/2) *fgkmm;
2494   // Dimensions of the Cone
2495   const Double_t kConeROuterMin        = ( 957.0/2) *fgkmm;
2496   const Double_t kConeROuterMax        = ( 997.0/2) *fgkmm;
2497   const Double_t kConeRInnerMin        = ( 564.0/2) *fgkmm;
2498   const Double_t kConeRCurv1           =       10.0 *fgkmm;
2499   const Double_t kConeRCurv2           =       25.0 *fgkmm;
2500   const Double_t kConeCent1RCurv2      = ( 578.0/2) *fgkmm;
2501   const Double_t kConeCent2RCurv2      = ( 592.0/2) *fgkmm;
2502 //  const Double_t kConeZOuterRing       =       47.0 *fgkmm;
2503 //  const Double_t kConeZOuterRingInside =       30.25*fgkmm;
2504 //  const Double_t kConeZInnerRing       =      161.5 *fgkmm;
2505 //  const Double_t kConeZLength          =      176.5 *fgkmm;
2506   const Double_t kConeZOuterRing       =       38.5 *fgkmm;
2507   const Double_t kConeZOuterRingInside =       22.2 *fgkmm;
2508   const Double_t kConeZInnerRing       =      153.0 *fgkmm;
2509   const Double_t kConeZLength          =      168.0 *fgkmm;
2510   const Double_t kConeZPosition        = kConeZLength + kCylinderHalfLength;
2511   const Double_t kConeThickness        =       13.0 *fgkmm; // Cone thickness
2512   const Double_t kConeTheta            =       39.1 *fgkDegree; // Cone angle
2513   const Double_t kSinConeTheta         =
2514                                       TMath::Sin(kConeTheta*TMath::DegToRad());
2515   const Double_t kCosConeTheta         =
2516                                       TMath::Cos(kConeTheta*TMath::DegToRad());
2517   // Dimensions of the Foam cores
2518   const Double_t kConeFoam1Length      =      112.3 *fgkmm;
2519   const Double_t kConeFoam2Length      =       58.4 *fgkmm;
2520   // Dimensions of the Cone Holes
2521   const Double_t kCoolingHoleWidth     =       40.0 *fgkmm;
2522   const Double_t kCoolingHoleHight     =       30.0 *fgkmm;
2523   const Double_t kCoolingHoleRmin      =      350.0 *fgkmm;
2524   const Double_t kCoolingHolePhi       =       45.0 *fgkDegree;
2525   const Double_t kMountingHoleWidth    =       20.0 *fgkmm;
2526   const Double_t kMountingHoleHight    =       20.0 *fgkmm;
2527   const Double_t kMountingHoleRmin     =      317.5 *fgkmm;
2528   const Double_t kMountingHolePhi      =       60.0 *fgkDegree;
2529   const Double_t kCableHoleRin         = ( 800.0/2) *fgkmm;
2530   const Double_t kCableHoleRout        = ( 920.0/2) *fgkmm;
2531   const Double_t kCableHoleWidth       =      200.0 *fgkmm;
2532 //  const Double_t kCableHoleAngle       =       42.0 *fgkDegree;
2533   // Dimensions of the Cone Wings
2534   const Double_t kWingRmax             =      527.5 *fgkmm;
2535   const Double_t kWingWidth            =       70.0 *fgkmm;
2536   const Double_t kWingHalfThick        = (  10.0/2) *fgkmm;
2537   const Double_t kThetaWing            =       45.0 *fgkDegree;
2538   // Dimensions of the SSD-SDD Mounting Brackets
2539   const Double_t kBracketRmin          = ( 541.0/2) *fgkmm;// See SDD ROutMin
2540   const Double_t kBracketRmax          = ( 585.0/2) *fgkmm;
2541   const Double_t kBracketHalfLength    = (   4.0/2) *fgkmm;
2542   const Double_t kBracketPhi           = (70.*fgkmm/kBracketRmax)*fgkRadian;
2543   // Common data
2544   const Double_t kCFThickness          =        0.75*fgkmm; //Carb. fib. thick.
2545
2546
2547   // Local variables
2548   Double_t rmin1, rmin2, rmax, z;
2549
2550   //
2551   //Begin_Html
2552   /*
2553     <img src="picts/ITS/file_name.gif">
2554     <P>
2555     <FONT FACE'"TIMES">
2556     ITS SSD central support and thermal shield cylinder.
2557     </FONT>
2558     </P>
2559   */
2560   //End_Html
2561   //
2562
2563   // Central cylinder with its internal foam and the lateral flanges:
2564   // a carbon fiber Pcon which contains a rohacell Tube and two
2565   // stesalite Cone's
2566   TGeoPcon *externalcylshape = new TGeoPcon(0,360,4);
2567
2568   rmax  = kCylinderOuterRadius;
2569   rmin1 = kFlangeInnerRadius - kCylinderThickness;
2570   rmin2 = rmax - 2*kCylinderThickness - kFoamThickness;
2571   externalcylshape->DefineSection(0,-kCylinderHalfLength,rmin1,rmax);
2572   externalcylshape->DefineSection(1,-kFoamHalfLength    ,rmin2,rmax);
2573   externalcylshape->DefineSection(2, kFoamHalfLength    ,rmin2,rmax);
2574   externalcylshape->DefineSection(3, kCylinderHalfLength,rmin1,rmax);
2575
2576   rmax  = kCylinderOuterRadius - kCylinderThickness;
2577   rmin1 = rmax - kFoamThickness;
2578   TGeoTube *foamshape = new TGeoTube(rmin1,rmax,kFoamHalfLength);
2579
2580   rmax  = kCylinderOuterRadius - kCylinderThickness;
2581   rmin1 = rmax - kFoamThickness;
2582   rmin2 = kFlangeInnerRadius;
2583   TGeoCone *flangeshape = new TGeoCone(kFlangeHalfLength,
2584                                        rmin1,rmax,rmin2,rmax);
2585
2586
2587   // We have the shapes: now create the real volumes
2588
2589   TGeoMedium *medSSDcf  = mgr->GetMedium("ITS_SSD C (M55J)$");
2590   TGeoMedium *medSSDair = mgr->GetMedium("ITS_SSD AIR$");
2591   TGeoMedium *medSSDste = mgr->GetMedium("ITS_G10FR4$"); // stesalite
2592   TGeoMedium *medSSDroh = mgr->GetMedium("ITS_ROHACELL$");
2593   TGeoMedium *medSSDal  = mgr->GetMedium("ITS_ALUMINUM$");
2594
2595   TGeoVolume *cfcylinder = new TGeoVolume("SSDexternalcylinder",
2596                                            externalcylshape,medSSDcf);
2597   cfcylinder->SetVisibility(kTRUE);
2598   cfcylinder->SetLineColor(4); // blue
2599   cfcylinder->SetLineWidth(1);
2600   cfcylinder->SetFillColor(cfcylinder->GetLineColor());
2601   cfcylinder->SetFillStyle(4000); // 0% transparent
2602
2603   TGeoVolume *foamcylinder = new TGeoVolume("SSDfoamcylinder",
2604                                             foamshape,medSSDroh);
2605   foamcylinder->SetVisibility(kTRUE);
2606   foamcylinder->SetLineColor(3); // green
2607   foamcylinder->SetLineWidth(1);
2608   foamcylinder->SetFillColor(foamcylinder->GetLineColor());
2609   foamcylinder->SetFillStyle(4050); // 50% transparent
2610
2611   TGeoVolume *flangecylinder = new TGeoVolume("SSDflangecylinder",
2612                                               flangeshape,medSSDste);
2613   flangecylinder->SetVisibility(kTRUE);
2614   flangecylinder->SetLineColor(2); // red
2615   flangecylinder->SetLineWidth(1);
2616   flangecylinder->SetFillColor(flangecylinder->GetLineColor());
2617   flangecylinder->SetFillStyle(4050); // 50% transparent
2618
2619   // Mount up the cylinder
2620   cfcylinder->AddNode(foamcylinder,1,0);
2621   cfcylinder->AddNode(flangecylinder,1,
2622               new TGeoTranslation(0, 0, kFoamHalfLength+kFlangeHalfLength));
2623   cfcylinder->AddNode(flangecylinder,2,new TGeoCombiTrans(
2624               0, 0, -kFoamHalfLength-kFlangeHalfLength,
2625               new TGeoRotation("",0,180,0)     ) );
2626
2627
2628   // The whole Cone as an assembly
2629   TGeoVolumeAssembly *vC = new TGeoVolumeAssembly("ITSssdCone");
2630
2631
2632   // SSD Support Cone with its internal inserts: a carbon fiber Pcon
2633   // with holes which contains a stesalite Pcon which on turn contains a
2634   // rohacell Pcon
2635   TGeoPcon *coneshape = new TGeoPcon(0.0, 360.0, 12);
2636
2637   coneshape->Z(0)     = 0.0;
2638   coneshape->Rmin(0)  = kConeROuterMin;
2639   coneshape->Rmax(0)  = kConeROuterMax;
2640
2641   coneshape->Z(1)     = kConeZOuterRingInside - kConeRCurv1;
2642   coneshape->Rmin(1)  = coneshape->GetRmin(0);
2643   coneshape->Rmax(1)  = coneshape->GetRmax(0);
2644
2645   coneshape->Z(2)     = kConeZOuterRingInside;
2646   coneshape->Rmin(2)  = coneshape->GetRmin(1) - kConeRCurv1;
2647   coneshape->Rmax(2)  = coneshape->GetRmax(0);
2648
2649   coneshape->Z(3)     = coneshape->GetZ(2);
2650   coneshape->Rmax(3)  = coneshape->GetRmax(0);
2651
2652   coneshape->Z(4)     = kConeZOuterRing - kConeRCurv1;
2653   coneshape->Rmax(4)  = coneshape->GetRmax(0);
2654
2655   coneshape->Z(5)     = kConeZOuterRing;
2656   coneshape->Rmax(5)  = coneshape->GetRmax(4) - kConeRCurv1;
2657
2658   coneshape->Z(6)     = coneshape->GetZ(5);
2659
2660   RadiusOfCurvature(kConeRCurv2,90.0,kConeZInnerRing,kConeCent1RCurv2,
2661                     90.0-kConeTheta,z,rmin1);
2662   coneshape->Z(7)     = z;
2663   coneshape->Rmin(7)  = rmin1;
2664
2665   coneshape->Rmin(3)  = RminFromZpCone(coneshape,7,90.-kConeTheta,
2666                                        coneshape->GetZ(3));
2667
2668   coneshape->Rmin(4)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(4));
2669
2670   coneshape->Rmin(5)  = RminFrom2Points(coneshape,3,7,coneshape->GetZ(5));
2671
2672   coneshape->Rmin(6) = coneshape->GetRmin(5);
2673
2674   coneshape->Z(8)     = kConeZInnerRing;
2675   coneshape->Rmin(8)  = kConeCent1RCurv2;
2676
2677   coneshape->Z(9)     = coneshape->GetZ(8);
2678   coneshape->Rmin(9)  = kConeRInnerMin;
2679
2680   RadiusOfCurvature(kConeRCurv2,90.0,kConeZLength,kConeCent2RCurv2,
2681                     90.0-kConeTheta,z,rmax);
2682
2683   coneshape->Z(10)    = z;
2684   coneshape->Rmin(10) = coneshape->GetRmin(9);
2685   coneshape->Rmax(10) = rmax;
2686
2687   coneshape->Rmax(6)  = RmaxFromZpCone(coneshape,10,90.-kConeTheta,
2688                                        coneshape->GetZ(6));
2689
2690   coneshape->Rmax(7)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(7));
2691
2692   coneshape->Rmax(8)  = RmaxFrom2Points(coneshape,6,10,coneshape->GetZ(8));
2693
2694   coneshape->Rmax(9)  = coneshape->GetRmax(8);
2695
2696   coneshape->Z(11)    = kConeZLength;
2697   coneshape->Rmin(11) = coneshape->GetRmin(10);
2698   coneshape->Rmax(11) = kConeCent2RCurv2;
2699
2700   // SSD Cone Insert: another Pcon
2701   Double_t x0, y0, x1, y1, x2, y2;
2702   TGeoPcon *coneinsertshape = new TGeoPcon(0.0,360.0,12);
2703
2704   coneinsertshape->Z(0)     = coneshape->GetZ(0) + kCFThickness;
2705   coneinsertshape->Rmin(0)  = coneshape->GetRmin(0) + kCFThickness;
2706   coneinsertshape->Rmax(0)  = coneshape->GetRmax(0) - kCFThickness;
2707
2708   x0 = coneshape->GetZ(0); y0 = coneshape->GetRmin(0);
2709   x1 = coneshape->GetZ(1); y1 = coneshape->GetRmin(1);
2710   x2 = coneshape->GetZ(2); y2 = coneshape->GetRmin(2);
2711   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2712   coneinsertshape->Z(1)     = z;
2713   coneinsertshape->Rmin(1)  = rmin1;
2714   coneinsertshape->Rmax(1)  = coneinsertshape->GetRmax(0);
2715
2716   x0 = coneshape->GetZ(1); y0 = coneshape->GetRmin(1);
2717   x1 = coneshape->GetZ(2); y1 = coneshape->GetRmin(2);
2718   x2 = coneshape->GetZ(3); y2 = coneshape->GetRmin(3);
2719   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2720   coneinsertshape->Z(2)     = z;
2721   coneinsertshape->Rmin(2)  = rmin1;
2722   coneinsertshape->Rmax(2)  = coneinsertshape->GetRmax(1);
2723
2724   x0 = coneshape->GetZ(2); y0 = coneshape->GetRmin(2);
2725   x1 = coneshape->GetZ(3); y1 = coneshape->GetRmin(3);
2726   x2 = coneshape->GetZ(4); y2 = coneshape->GetRmin(4);
2727   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2728   coneinsertshape->Z(3)     = z;
2729   coneinsertshape->Rmin(3)  = rmin1;
2730   coneinsertshape->Rmax(3)  = coneinsertshape->GetRmax(2);
2731
2732   x0 = coneshape->GetZ(3); y0 = coneshape->GetRmax(3);
2733   x1 = coneshape->GetZ(4); y1 = coneshape->GetRmax(4);
2734   x2 = coneshape->GetZ(5); y2 = coneshape->GetRmax(5);
2735   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2736   coneinsertshape->Z(4)     = z;
2737   coneinsertshape->Rmax(4)  = rmax;
2738
2739   x0 = coneshape->GetZ(4); y0 = coneshape->GetRmax(4);
2740   x1 = coneshape->GetZ(5); y1 = coneshape->GetRmax(5);
2741   x2 = coneshape->GetZ(6); y2 = coneshape->GetRmax(6);
2742   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2743   coneinsertshape->Z(5)     = z;
2744   coneinsertshape->Rmax(5)  = rmax;
2745
2746   x0 = coneshape->GetZ(5); y0 = coneshape->GetRmax(5);
2747   x1 = coneshape->GetZ(6); y1 = coneshape->GetRmax(6);
2748   x2 = coneshape->GetZ(7); y2 = coneshape->GetRmax(7);
2749   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2750   coneinsertshape->Z(6)     = z;
2751   coneinsertshape->Rmax(6)  = rmax;
2752
2753   x0 = coneshape->GetZ(6); y0 = coneshape->GetRmin(6);
2754   x1 = coneshape->GetZ(7); y1 = coneshape->GetRmin(7);
2755   x2 = coneshape->GetZ(8); y2 = coneshape->GetRmin(8);
2756   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2757   coneinsertshape->Z(7)     = z;
2758   coneinsertshape->Rmin(7)  = rmin1;
2759
2760   coneinsertshape->Rmin(4)  = RminFrom2Points(coneinsertshape,3,7,
2761                                               coneinsertshape->GetZ(4));
2762
2763   coneinsertshape->Rmin(5)  = RminFrom2Points(coneinsertshape,3,7,
2764                                               coneinsertshape->GetZ(5));
2765
2766   coneinsertshape->Rmin(6)  = coneinsertshape->GetRmin(5);
2767
2768   x0 = coneshape->GetZ(7); y0 = coneshape->GetRmin(7);
2769   x1 = coneshape->GetZ(8); y1 = coneshape->GetRmin(8);
2770   x2 = coneshape->GetZ(9); y2 = coneshape->GetRmin(9);
2771   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2772   coneinsertshape->Z(8)     = z;
2773   coneinsertshape->Rmin(8)  = rmin1;
2774
2775   x0 = coneshape->GetZ( 8); y0 = coneshape->GetRmin( 8);
2776   x1 = coneshape->GetZ( 9); y1 = coneshape->GetRmin( 9);
2777   x2 = coneshape->GetZ(10); y2 = coneshape->GetRmin(10);
2778   InsidePoint(x0, y0, x1, y1, x2, y2,  kCFThickness, z, rmin1);
2779   coneinsertshape->Z(9)     = z;
2780   coneinsertshape->Rmin(9)  = rmin1;
2781
2782   x0 = coneshape->GetZ( 9); y0 = coneshape->GetRmax( 9);
2783   x1 = coneshape->GetZ(10); y1 = coneshape->GetRmax(10);
2784   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmax(11);
2785   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2786   coneinsertshape->Z(10)    = z;
2787   coneinsertshape->Rmax(10) = rmax;
2788   coneinsertshape->Rmin(10) = coneinsertshape->GetRmin(9);
2789
2790   coneinsertshape->Rmax(7)  = RmaxFrom2Points(coneinsertshape,6,10,
2791                                               coneinsertshape->GetZ(7));
2792
2793   coneinsertshape->Rmax(8)  = RmaxFrom2Points(coneinsertshape,6,10,
2794                                               coneinsertshape->GetZ(8));
2795
2796   coneinsertshape->Rmax(9)  = coneinsertshape->GetRmax(8);
2797
2798   x0 = coneshape->GetZ(10); y0 = coneshape->GetRmax(10);
2799   x1 = coneshape->GetZ(11); y1 = coneshape->GetRmax(11);
2800   x2 = coneshape->GetZ(11); y2 = coneshape->GetRmin(11);
2801   InsidePoint(x0, y0, x1, y1, x2, y2, -kCFThickness, z, rmax);
2802   coneinsertshape->Z(11)    = z;
2803   coneinsertshape->Rmax(11) = rmax;
2804   coneinsertshape->Rmin(11) = coneinsertshape->GetRmin(10);
2805
2806   // SSD Cone Foams: two other Pcon's
2807   TGeoPcon *conefoam1shape = new TGeoPcon(0.0, 360.0, 4);
2808
2809   conefoam1shape->Z(0)    = coneinsertshape->GetZ(3);
2810   conefoam1shape->Rmin(0) = coneinsertshape->GetRmin(3);
2811   conefoam1shape->Rmax(0) = conefoam1shape->GetRmin(0);
2812
2813   conefoam1shape->Rmax(1) = conefoam1shape->GetRmax(0);
2814   conefoam1shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2815                                            conefoam1shape->GetRmax(1));
2816   conefoam1shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2817                                            conefoam1shape->GetZ(1));
2818
2819   Double_t t = kConeThickness - 2*kCFThickness;
2820   conefoam1shape->Rmin(2) = conefoam1shape->GetRmax(0) -
2821                            (kConeFoam1Length*kCosConeTheta - t*kSinConeTheta);
2822   conefoam1shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2823                                            conefoam1shape->GetRmin(2));
2824   conefoam1shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2825                                            conefoam1shape->GetZ(2));
2826
2827   conefoam1shape->Rmin(3) = conefoam1shape->GetRmin(2);
2828   conefoam1shape->Rmax(3) = conefoam1shape->GetRmin(3);
2829   conefoam1shape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2830                                            conefoam1shape->GetRmax(3));
2831
2832   TGeoPcon *conefoam2shape = new TGeoPcon(0.0, 360.0, 4);
2833
2834   conefoam2shape->Z(3)    = coneinsertshape->GetZ(10);
2835   conefoam2shape->Rmin(3) = coneinsertshape->GetRmax(10);
2836   conefoam2shape->Rmax(3) = conefoam2shape->GetRmin(3);
2837
2838   conefoam2shape->Rmin(2) = conefoam2shape->GetRmin(3);
2839   conefoam2shape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2840                                            conefoam2shape->GetRmin(2));
2841   conefoam2shape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2842                                            conefoam2shape->GetZ(2));
2843
2844   conefoam2shape->Rmin(0) = conefoam2shape->GetRmax(2) +
2845                            (kConeFoam2Length*kCosConeTheta - t*kSinConeTheta);
2846   conefoam2shape->Rmax(0) = conefoam2shape->GetRmin(0);
2847   conefoam2shape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2848                                            conefoam2shape->GetRmin(0));
2849
2850   conefoam2shape->Rmax(1) = conefoam2shape->GetRmax(0);
2851   conefoam2shape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2852                                            conefoam2shape->GetRmax(1));
2853   conefoam2shape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2854                                            conefoam2shape->GetZ(1));
2855
2856   // SSD Cone Holes: Pcon's
2857   // A single hole volume gives an overlap with coneinsert, so
2858   // three contiguous volumes are created: one to be put in coneinsert
2859   // and two in the cone carbon fiber envelope
2860   Double_t holePhi;
2861   holePhi = (kCoolingHoleWidth/kCoolingHoleRmin)*TMath::RadToDeg();
2862
2863   TGeoPcon *coolingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2864
2865   coolingholeshape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2866   coolingholeshape->Rmax(0) = coolingholeshape->GetRmin(0);
2867   coolingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2868                                              coolingholeshape->GetRmin(0));
2869
2870   coolingholeshape->Rmax(1) = coolingholeshape->GetRmax(0);
2871   coolingholeshape->Z(1)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2872                                              coolingholeshape->GetRmax(1));
2873   coolingholeshape->Rmin(1) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2874                                              coolingholeshape->GetZ(1));
2875
2876   coolingholeshape->Rmin(2) = kCoolingHoleRmin;
2877   coolingholeshape->Z(2)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2878                                              coolingholeshape->GetRmin(2));
2879   coolingholeshape->Rmax(2) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2880                                              coolingholeshape->GetZ(2));
2881
2882   coolingholeshape->Rmin(3) = coolingholeshape->GetRmin(2);
2883   coolingholeshape->Rmax(3) = coolingholeshape->GetRmin(3);
2884   coolingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2885                                              coolingholeshape->GetRmax(3));
2886
2887   TGeoPcon *coolinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2888
2889   coolinghole2shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2890   coolinghole2shape->Rmax(0) = coolinghole2shape->GetRmin(0);
2891   coolinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2892                                               coolinghole2shape->GetRmin(0));
2893
2894   coolinghole2shape->Rmax(1) = coolinghole2shape->GetRmax(0);
2895   coolinghole2shape->Z(1)    = coolingholeshape->GetZ(0);
2896   coolinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2897                                               coolinghole2shape->GetZ(1));
2898
2899   coolinghole2shape->Rmin(2) = kCoolingHoleRmin;
2900   coolinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2901                                               coolinghole2shape->GetRmin(2));
2902   coolinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2903                                               coolinghole2shape->GetZ(2));
2904
2905   coolinghole2shape->Rmin(3) = coolinghole2shape->GetRmin(2);
2906   coolinghole2shape->Rmax(3) = coolinghole2shape->GetRmin(3);
2907   coolinghole2shape->Z(3)    = coolingholeshape->GetZ(2);
2908
2909   TGeoPcon *coolinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2910
2911   coolinghole3shape->Rmin(0) = kCoolingHoleRmin + kCoolingHoleHight;
2912   coolinghole3shape->Rmax(0) = coolinghole3shape->GetRmin(0);
2913   coolinghole3shape->Z(0)    = coolingholeshape->GetZ(1);
2914
2915   coolinghole3shape->Rmax(1) = coolinghole3shape->GetRmax(0);
2916   coolinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2917                                               coolinghole3shape->GetRmax(1));
2918   coolinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2919                                               coolinghole3shape->GetZ(1));
2920
2921   coolinghole3shape->Rmin(2) = kCoolingHoleRmin;
2922   coolinghole3shape->Z(2)    = coolingholeshape->GetZ(3);
2923   coolinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2924                                               coolinghole3shape->GetZ(2));
2925
2926   coolinghole3shape->Rmin(3) = coolinghole3shape->GetRmin(2);
2927   coolinghole3shape->Rmax(3) = coolinghole3shape->GetRmin(3);
2928   coolinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2929                                               coolinghole3shape->GetRmax(3));
2930
2931   //
2932   holePhi = (kMountingHoleWidth/kMountingHoleRmin)*TMath::RadToDeg();
2933
2934   TGeoPcon *mountingholeshape = new TGeoPcon(-holePhi/2., holePhi, 4);
2935
2936   mountingholeshape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2937   mountingholeshape->Rmax(0) = mountingholeshape->GetRmin(0);
2938   mountingholeshape->Z(0)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2939                                               mountingholeshape->GetRmin(0));
2940
2941   mountingholeshape->Rmin(1) = kMountingHoleRmin;
2942   mountingholeshape->Rmax(1) = mountingholeshape->GetRmax(0);
2943   mountingholeshape->Z(1)    = ZFromRminpCone(coneinsertshape,3,90.-kConeTheta,
2944                                               mountingholeshape->GetRmin(1));
2945
2946   mountingholeshape->Rmin(2) = mountingholeshape->GetRmin(1);
2947   mountingholeshape->Rmax(2) = mountingholeshape->GetRmax(1);
2948   mountingholeshape->Z(2)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2949                                               mountingholeshape->GetRmax(2));
2950
2951   mountingholeshape->Rmin(3) = mountingholeshape->GetRmin(2);
2952   mountingholeshape->Rmax(3) = mountingholeshape->GetRmin(3);
2953   mountingholeshape->Z(3)    = ZFromRmaxpCone(coneinsertshape,7,90.-kConeTheta,
2954                                               mountingholeshape->GetRmax(3));
2955
2956   TGeoPcon *mountinghole2shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2957
2958   mountinghole2shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2959   mountinghole2shape->Rmax(0) = mountingholeshape->GetRmin(0);
2960   mountinghole2shape->Z(0)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2961                                                mountinghole2shape->GetRmin(0));
2962
2963   mountinghole2shape->Rmax(1) = mountinghole2shape->GetRmax(0);
2964   mountinghole2shape->Z(1)    = mountingholeshape->Z(0);
2965   mountinghole2shape->Rmin(1) = RminFromZpCone(coneshape,3,90.-kConeTheta,
2966                                                mountinghole2shape->GetZ(1));
2967
2968   mountinghole2shape->Rmin(2) = kMountingHoleRmin;
2969   mountinghole2shape->Z(2)    = ZFromRminpCone(coneshape,3,90.-kConeTheta,
2970                                                mountinghole2shape->GetRmin(2));
2971   mountinghole2shape->Rmax(2) = RminFromZpCone(coneinsertshape,3,90.-kConeTheta,
2972                                                mountinghole2shape->GetZ(2));
2973
2974   mountinghole2shape->Rmin(3) = mountinghole2shape->Rmin(2);
2975   mountinghole2shape->Rmax(3) = mountinghole2shape->Rmin(3);
2976   mountinghole2shape->Z(3)    = mountingholeshape->Z(1);
2977
2978   TGeoPcon *mountinghole3shape = new TGeoPcon(-holePhi/2., holePhi, 4);
2979
2980   mountinghole3shape->Rmin(0) = kMountingHoleRmin + kMountingHoleHight;
2981   mountinghole3shape->Rmax(0) = mountingholeshape->GetRmin(0);
2982   mountinghole3shape->Z(0)    = mountingholeshape->GetZ(2);
2983
2984   mountinghole3shape->Rmax(1) = mountinghole3shape->GetRmax(0);
2985   mountinghole3shape->Z(1)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2986                                                mountinghole3shape->GetRmax(1));
2987   mountinghole3shape->Rmin(1) = RmaxFromZpCone(coneinsertshape,7,90.-kConeTheta,
2988                                                mountinghole3shape->GetZ(1));
2989
2990   mountinghole3shape->Rmin(2) = kMountingHoleRmin;
2991   mountinghole3shape->Z(2)    = mountingholeshape->Z(3);
2992   mountinghole3shape->Rmax(2) = RmaxFromZpCone(coneshape,7,90.-kConeTheta,
2993                                                mountinghole3shape->GetZ(2));
2994
2995   mountinghole3shape->Rmin(3) = mountinghole3shape->Rmin(2);
2996   mountinghole3shape->Rmax(3) = mountinghole3shape->Rmin(3);
2997   mountinghole3shape->Z(3)    = ZFromRmaxpCone(coneshape,7,90.-kConeTheta,
2998                                                mountinghole3shape->GetRmax(3));
2999
3000   // The Cable Hole is even more complicated, a Composite Shape
3001   // is unavoidable here (gosh!)
3002   TGeoPcon *coneshapecopy = new TGeoPcon("conecopy",0.0, 360.0, 12);
3003
3004   for (Int_t i=0; i<12; i++) {
3005     coneshapecopy->Rmin(i) = coneshape->GetRmin(i);
3006     coneshapecopy->Rmax(i) = coneshape->GetRmax(i);
3007     coneshapecopy->Z(i)    = coneshape->GetZ(i);
3008   }
3009
3010   holePhi = (kCableHoleWidth/kCableHoleRout)*TMath::RadToDeg();
3011   TGeoConeSeg *chCS = new TGeoConeSeg("chCS", 0.5*kConeZLength,
3012                                       kCableHoleRin, kCableHoleRout,
3013                                       kCableHoleRin, kCableHoleRout,
3014                                       -0.5*holePhi, 0.5*holePhi);
3015
3016   TGeoCompositeShape *cableholeshape = new TGeoCompositeShape(
3017                                            "SSDCableHoleShape",
3018                                            "conecopy*chCS");
3019
3020   if(GetDebug(1)){
3021     chCS->InspectShape();
3022     cableholeshape->InspectShape();
3023   }
3024
3025   // SSD Cone Wings: Tube and TubeSeg shapes
3026   Double_t angleWideWing, angleWideWingThickness;
3027   angleWideWing = (kWingWidth/kWingRmax)*TMath::RadToDeg();
3028   angleWideWingThickness = (kCFThickness/kWingRmax)*TMath::RadToDeg();
3029
3030   TGeoTubeSeg *wingshape = new TGeoTubeSeg(kConeROuterMax, kWingRmax,
3031                                            kWingHalfThick,
3032                                            0, angleWideWing);
3033
3034   TGeoTubeSeg *winginsertshape = new TGeoTubeSeg(kConeROuterMax,
3035                                  kWingRmax-kCFThickness,
3036                                  kWingHalfThick-kCFThickness,
3037                                  angleWideWingThickness,
3038                                  angleWideWing-angleWideWingThickness);
3039
3040   // SDD support plate, SSD side (Mounting Bracket): a TubeSeg
3041   TGeoTubeSeg *bracketshape = new TGeoTubeSeg(kBracketRmin, kBracketRmax,
3042                             kBracketHalfLength, -kBracketPhi/2, kBracketPhi/2);
3043
3044
3045   // We have the shapes: now create the real volumes
3046
3047   TGeoVolume *cfcone = new TGeoVolume("SSDCarbonFiberCone",
3048                                       coneshape,medSSDcf);
3049   cfcone->SetVisibility(kTRUE);
3050   cfcone->SetLineColor(4); // Blue
3051   cfcone->SetLineWidth(1);
3052   cfcone->SetFillColor(cfcone->GetLineColor());
3053   cfcone->SetFillStyle(4000); // 0% transparent
3054
3055   TGeoVolume *cfconeinsert = new TGeoVolume("SSDCarbonFiberConeInsert",
3056                                             coneinsertshape,medSSDste);
3057   cfconeinsert->SetVisibility(kTRUE);
3058   cfconeinsert->SetLineColor(2); // Red
3059   cfconeinsert->SetLineWidth(1);
3060   cfconeinsert->SetFillColor(cfconeinsert->GetLineColor());
3061   cfconeinsert->SetFillStyle(4050); // 50% transparent
3062
3063   TGeoVolume *cfconefoam1 = new TGeoVolume("SSDCarbonFiberConeFoam1",
3064                                             conefoam1shape,medSSDroh);
3065   cfconefoam1->SetVisibility(kTRUE);
3066   cfconefoam1->SetLineColor(3); // Green
3067   cfconefoam1->SetLineWidth(1);
3068   cfconefoam1->SetFillColor(cfconefoam1->GetLineColor());
3069   cfconefoam1->SetFillStyle(4050); // 50% transparent
3070
3071   TGeoVolume *cfconefoam2 = new TGeoVolume("SSDCarbonFiberConeFoam2",
3072                                             conefoam2shape,medSSDroh);
3073   cfconefoam2->SetVisibility(kTRUE);
3074   cfconefoam2->SetLineColor(3); // Green
3075   cfconefoam2->SetLineWidth(1);
3076   cfconefoam2->SetFillColor(cfconefoam2->GetLineColor());
3077   cfconefoam2->SetFillStyle(4050); // 50% transparent
3078
3079   TGeoVolume *coolinghole = new TGeoVolume("SSDCoolingHole",
3080                                            coolingholeshape,medSSDair);
3081   coolinghole->SetVisibility(kTRUE);
3082   coolinghole->SetLineColor(5); // Yellow
3083   coolinghole->SetLineWidth(1);
3084   coolinghole->SetFillColor(coolinghole->GetLineColor());
3085   coolinghole->SetFillStyle(4090); // 90% transparent
3086
3087   TGeoVolume *coolinghole2 = new TGeoVolume("SSDCoolingHole2",
3088                                             coolinghole2shape,medSSDair);
3089   coolinghole2->SetVisibility(kTRUE);
3090   coolinghole2->SetLineColor(5); // Yellow
3091   coolinghole2->SetLineWidth(1);
3092   coolinghole2->SetFillColor(coolinghole2->GetLineColor());
3093   coolinghole2->SetFillStyle(4090); // 90% transparent
3094
3095   TGeoVolume *coolinghole3 = new TGeoVolume("SSDCoolingHole3",
3096                                             coolinghole3shape,medSSDair);
3097   coolinghole3->SetVisibility(kTRUE);
3098   coolinghole3->SetLineColor(5); // Yellow
3099   coolinghole3->SetLineWidth(1);
3100   coolinghole3->SetFillColor(coolinghole3->GetLineColor());
3101   coolinghole3->SetFillStyle(4090); // 90% transparent
3102
3103   TGeoVolume *mountinghole = new TGeoVolume("SSDMountingHole",
3104                                             mountingholeshape,medSSDair);
3105   mountinghole->SetVisibility(kTRUE);
3106   mountinghole->SetLineColor(5); // Yellow
3107   mountinghole->SetLineWidth(1);
3108   mountinghole->SetFillColor(mountinghole->GetLineColor());
3109   mountinghole->SetFillStyle(4090); // 90% transparent
3110
3111   TGeoVolume *mountinghole2 = new TGeoVolume("SSDMountingHole2",
3112                                              mountinghole2shape,medSSDair);
3113   mountinghole2->SetVisibility(kTRUE);
3114   mountinghole2->SetLineColor(5); // Yellow
3115   mountinghole2->SetLineWidth(1);
3116   mountinghole2->SetFillColor(mountinghole2->GetLineColor());
3117   mountinghole2->SetFillStyle(4090); // 90% transparent
3118
3119   TGeoVolume *mountinghole3 = new TGeoVolume("SSDMountingHole3",
3120                                              mountinghole3shape,medSSDair);
3121   mountinghole3->SetVisibility(kTRUE);
3122   mountinghole3->SetLineColor(5); // Yellow
3123   mountinghole3->SetLineWidth(1);
3124   mountinghole3->SetFillColor(mountinghole3->GetLineColor());
3125   mountinghole3->SetFillStyle(4090); // 90% transparent
3126
3127   TGeoVolume *wing = new TGeoVolume("SSDWing",wingshape,medSSDcf);
3128   wing->SetVisibility(kTRUE);
3129   wing->SetLineColor(4); // Blue
3130   wing->SetLineWidth(1);
3131   wing->SetFillColor(wing->GetLineColor());
3132   wing->SetFillStyle(4000); // 0% transparent
3133
3134   TGeoVolume *cablehole = new TGeoVolume("SSDCableHole",
3135                                          cableholeshape,medSSDair);
3136   cablehole->SetVisibility(kTRUE);
3137   cablehole->SetLineColor(5); // Yellow
3138   cablehole->SetLineWidth(1);
3139   cablehole->SetFillColor(cablehole->GetLineColor());
3140   cablehole->SetFillStyle(4090); // 90% transparent
3141
3142   TGeoVolume *winginsert = new TGeoVolume("SSDWingInsert",
3143                                           winginsertshape,medSSDste);
3144   winginsert->SetVisibility(kTRUE);
3145   winginsert->SetLineColor(2); // Red
3146   winginsert->SetLineWidth(1);
3147   winginsert->SetFillColor(winginsert->GetLineColor());
3148   winginsert->SetFillStyle(4050); // 50% transparent
3149
3150   TGeoVolume *bracket = new TGeoVolume("SSDMountingBracket",
3151                                        bracketshape,medSSDal);
3152   bracket->SetVisibility(kTRUE);
3153   bracket->SetLineColor(6); // Purple
3154   bracket->SetLineWidth(1);
3155   bracket->SetFillColor(bracket->GetLineColor());
3156   bracket->SetFillStyle(4000); // 0% transparent
3157
3158   // Mount up a cone
3159   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
3160     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
3161     cfconefoam2->AddNode(mountinghole,i+1, new TGeoRotation("", phiH, 0, 0));
3162   }
3163
3164   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
3165     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
3166     cfconeinsert->AddNodeOverlap(coolinghole,i+1, new TGeoRotation("", phiH, 0, 0));
3167   }
3168
3169   cfconeinsert->AddNode(cfconefoam1,1,0);
3170   cfconeinsert->AddNode(cfconefoam2,1,0);
3171
3172   cfcone->AddNode(cfconeinsert,1,0);
3173
3174   for (Int_t i=0; i<(Int_t)(360./kCoolingHolePhi); i++) {
3175     Double_t phiH = i*kCoolingHolePhi + 0.5*kCoolingHolePhi;
3176     cfcone->AddNode(coolinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
3177     cfcone->AddNode(coolinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
3178     cfcone->AddNodeOverlap(cablehole,i+1, new TGeoRotation("", phiH, 0, 0));
3179   }
3180
3181   for (Int_t i=0; i<(Int_t)(360./kMountingHolePhi); i++) {
3182     Double_t phiH = i*kMountingHolePhi + 0.5*kMountingHolePhi;
3183     cfcone->AddNode(mountinghole2,i+1, new TGeoRotation("", phiH, 0, 0));
3184     cfcone->AddNode(mountinghole3,i+1, new TGeoRotation("", phiH, 0, 0));
3185   }
3186
3187   wing->AddNode(winginsert,1,0);
3188
3189   // Add all volumes in the Cone assembly
3190   vC->AddNode(cfcone,1,new TGeoTranslation(0,0,-kConeZPosition));
3191
3192   for (Int_t i=0; i<4; i++) {
3193     Double_t thetaW = kThetaWing + 90.*i + angleWideWing/2.;
3194     vC->AddNode(wing, i+1, new TGeoCombiTrans(0, 0, -kConeZPosition+kWingHalfThick,
3195                            new TGeoRotation("",thetaW,180,0)));
3196   }
3197
3198   Double_t zBracket = kConeZPosition - coneshape->GetZ(9) +
3199                       2*bracketshape->GetDz();
3200   for (Int_t i=0; i<3; i++) {
3201     Double_t thetaB = 60 + 120.*i;
3202     vC->AddNode(bracket, i+1, new TGeoCombiTrans(0, 0, -zBracket,
3203                               new TGeoRotation("",thetaB,0,0)));
3204   }
3205
3206   // Finally put everything in the mother volume
3207   moth->AddNode(cfcylinder,1,0);
3208
3209   moth->AddNode(vC, 1, 0 );
3210   moth->AddNode(vC, 2, new TGeoRotation("",180, 180, 0) );
3211
3212   // Some debugging if requested
3213   if(GetDebug(1)){
3214     vC->PrintNodes();
3215     vC->InspectShape();
3216   }
3217
3218   return;
3219 }
3220
3221 //______________________________________________________________________
3222 void AliITSv11GeometrySupport::ServicesCableSupport(TGeoVolume *moth,
3223                                                     TGeoManager *mgr){
3224 //
3225 // Creates the cable trays which are outside the ITS support cones
3226 // but still inside the TPC
3227 // This is now a stearing routine, the actual work is done by three
3228 // specialized methods to avoid a really huge unique method
3229 //
3230 // Input:
3231 //         moth : the TGeoVolume owing the volume structure
3232 //         mgr  : the GeoManager (default gGeoManager)
3233 // Output:
3234 //
3235 // Created:      15 Nov 2009  Mario Sitta
3236 //
3237
3238   TraySupportsSideA(moth, mgr);
3239
3240   ServicesCableSupportSPD(moth, mgr);
3241   ServicesCableSupportSDD(moth, mgr);
3242   ServicesCableSupportSSD(moth, mgr);
3243
3244   return;
3245 }
3246
3247 //______________________________________________________________________
3248 void AliITSv11GeometrySupport::TraySupportsSideA(TGeoVolume *moth,
3249                                            const TGeoManager *mgr){
3250 //
3251 // Creates the structure supporting the ITS cable trays on Side A
3252 //
3253 // Input:
3254 //         moth : the TGeoVolume owing the volume structure
3255 //         mgr  : the GeoManager (default gGeoManager)
3256 // Output:
3257 //
3258 // Created:      14 Dec 2009  Mario Sitta
3259 // Updated:      26 Feb 2010  Mario Sitta
3260 //
3261 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
3262 // drawings and other (oral) information given by F.Tosello
3263 //
3264
3265   // Dimensions and positions of the A-Side Cable Tray Support Ring
3266   // (0872/G/A/01)
3267   const Double_t kSuppRingYTrans      =  110.00 *fgkmm;
3268   const Double_t kSuppRingZTrans      =(1011.00+435.00) *fgkmm;
3269   const Double_t kSuppForwYTrans      =  185.00 *fgkmm;
3270
3271   const Double_t kExtSuppRingSpace1   =   33.00 *fgkmm;
3272   const Double_t kExtSuppRingSpace2   =   45.00 *fgkmm;
3273   const Double_t kExtSuppRingSpcAbov  =   30.00 *fgkmm;
3274   const Double_t kExtSuppRingBase     =  491.50 *fgkmm;
3275   const Double_t kExtSuppRingInward   =   35.00 *fgkmm;
3276   const Double_t kExtSuppRingRmax     =  540.00 *fgkmm;
3277   const Double_t kExtSuppRingRint1    =  465.00 *fgkmm;
3278   const Double_t kExtSuppRingRint2    =  467.00 *fgkmm;
3279   const Double_t kExtSuppRingInnerHi  =  450.00 *fgkmm;
3280   const Double_t kExtSuppRingInWide   =  100.00 *fgkmm;
3281   const Double_t kExtSuppRingR7       =    7.00 *fgkmm;
3282   const Double_t kExtSuppRingR5       =    5.00 *fgkmm;
3283   const Double_t kExtSuppRingThick    =   20.00 *fgkmm;
3284
3285   const Double_t kExtSuppRingSpcAng   =   10.50 *TMath::DegToRad();
3286   const Double_t kExtSuppRingPartPhi  =   15.00 *TMath::DegToRad();
3287   const Double_t kExtSuppRingIntAng   =    7.00 *TMath::DegToRad();
3288   const Double_t kExtSuppRingBaseAng  =   75.00 *TMath::DegToRad();
3289   const Double_t kExtSuppRingR7Ang    =  100.00 *TMath::DegToRad(); // Guessed
3290
3291   const Int_t    kExtSuppRingNPtsArc  =   10; // N.points to approximate arc
3292
3293   const Double_t kIntSuppRingThick1   =   15.00 *fgkmm;
3294   const Double_t kIntSuppRingThick2   =   13.00 *fgkmm;
3295   const Double_t kIntSuppRingInward   =   24.00 *fgkmm;
3296   const Double_t kIntSuppRingThick    =   20.00 *fgkmm;
3297
3298   const Double_t kSuppCylHeight       =  340.00 *fgkmm;
3299   const Double_t kSuppCylRint         =  475.00 *fgkmm;
3300   const Double_t kSuppCylRext         =  478.00 *fgkmm;
3301   const Double_t kSuppCylDispl        =  137.70 *fgkmm;
3302
3303   const Double_t kSuppSpacerHeight    =   30.00 *fgkmm;
3304   const Double_t kSuppSpacerThick     =   10.00 *fgkmm;
3305
3306   const Double_t kSuppSpacerAngle     =   15.00;  // Degrees
3307
3308   const Double_t kSuppForwRingRint1   =  500.00 *fgkmm;
3309   const Double_t kSuppForwRingRint2   =  540.00 *fgkmm;
3310   const Double_t kSuppForwRingRext    =  560.00 *fgkmm;
3311   const Double_t kSuppForwRingThikAll =   50.00 *fgkmm;
3312   const Double_t kSuppForwRingThikInt =   20.00 *fgkmm;
3313
3314   // (0872/G/B/01)
3315   const Double_t kSuppForwConeRmin    =  558.00 *fgkmm;
3316   const Double_t kSuppForwConeRmax    =  681.00 *fgkmm;
3317   const Double_t kSuppForwConeLen1    =  318.00 *fgkmm;
3318   const Double_t kSuppForwConeLen2    =  662.00 *fgkmm;
3319   const Double_t kSuppForwConeThick   =    3.00 *fgkmm;
3320
3321   const Double_t kSuppBackRingPlacTop =   90.00 *fgkmm;
3322   const Double_t kSuppBackRingPlacSid =   50.00 *fgkmm;
3323   const Double_t kSuppBackRingHeight  =  760.00 *fgkmm;
3324   const Double_t kSuppBackRingRext    =  760.00 *fgkmm;
3325   const Double_t kSuppBackRingRint    =  685.00 *fgkmm;
3326 //  const Double_t kSuppBackRingRint2   =  675.00 *fgkmm;
3327   const Double_t kSuppBackRingR10     =   10.00 *fgkmm;
3328   const Double_t kSuppBackRingBase    =  739.00 *fgkmm;
3329   const Double_t kSuppBackRingThikAll =   50.00 *fgkmm;
3330   const Double_t kSuppBackRingThick1  =   20.00 *fgkmm;
3331   const Double_t kSuppBackRingThick2  =   20.00 *fgkmm;
3332
3333 //  const Double_t kSuppBackRingPlacAng =   10.00 *TMath::DegToRad();
3334   const Double_t kSuppBackRingPlacAng =   10.25 *TMath::DegToRad();//Fix ovlp.
3335   const Double_t kSuppBackRing2ndAng1 =   78.40 *TMath::DegToRad();
3336   const Double_t kSuppBackRing2ndAng2 =   45.00 *TMath::DegToRad();
3337
3338   const Int_t    kSuppBackRingNPtsArc =   10; // N.points to approximate arc
3339
3340   // (0872/G/C/01)
3341   const Double_t kRearSuppZTransGlob  =(1011.00+9315.00-6040.00) *fgkmm;
3342   const Double_t kBackRodZTrans       = 2420.00 *fgkmm;
3343
3344   const Double_t kBackRodLength       = 1160.00 *fgkmm;
3345   const Double_t kBackRodThickLen     =   20.00 *fgkmm;
3346   const Double_t kBackRodDiameter     =   20.00 *fgkmm;
3347
3348   const Double_t kSuppRearRingRint    =  360.00 *fgkmm;
3349   const Double_t kSuppRearRingRext1   =  410.00 *fgkmm;
3350   const Double_t kSuppRearRingRext2   =  414.00 *fgkmm;
3351   const Double_t kSuppRearRingHeight  =  397.00 *fgkmm;
3352   const Double_t kSuppRearRingTopWide =  111.87 *fgkmm;
3353   const Double_t kSuppRearRingBase    =  451.50 *fgkmm;
3354   const Double_t kSuppRearRingBaseHi  =   58.00 *fgkmm;
3355   const Double_t kSuppRearRingSideHi  =   52.00 *fgkmm;
3356   const Double_t kSuppRearRingInside  =   40.00 *fgkmm;
3357   const Double_t kSuppRearRingInsideHi=   12.00 *fgkmm;
3358   const Double_t kSuppRearRingThick   =   20.00 *fgkmm;
3359   const Double_t kSuppRearRingXRodHole=  441.50 *fgkmm;
3360   const Double_t kSuppRearRingYRodHole=   42.00 *fgkmm;
3361
3362   const Double_t kSuppRearRing1stAng  =   22.00 *TMath::DegToRad();
3363   const Double_t kSuppRearRingStepAng =   15.00 *TMath::DegToRad();
3364
3365   const Int_t    kSuppRearRingNPtsArc =   10; // N.points to approximate arc
3366
3367
3368   // Local variables
3369   Double_t xprof[2*(15+kExtSuppRingNPtsArc)],yprof[2*(15+kExtSuppRingNPtsArc)];
3370   Double_t slp1, slp2, phi, xm, ym;
3371   Double_t xloc, yloc, zloc, rmin, rmax, deltaR;
3372   Int_t npoints;
3373
3374
3375   // The whole support as an assembly
3376   TGeoVolumeAssembly *trayASuppStruct = new TGeoVolumeAssembly("ITSsuppSideAStructure");
3377   
3378
3379   // First create all needed shapes
3380
3381   // The External Ring (part of 0872/G/A/01): a really complex Xtru
3382   TGeoXtru *extSuppRing = new TGeoXtru(2);
3383
3384   // First the upper notch...
3385   xprof[ 0] = kExtSuppRingSpace1;
3386   yprof[ 0] = kExtSuppRingInnerHi + kExtSuppRingSpcAbov;
3387
3388   slp1 = TMath::Tan(TMath::Pi()/2 - kExtSuppRingSpcAng);
3389   IntersectCircle(slp1, xprof[0], yprof[0], kExtSuppRingRmax, 0., 0.,
3390                   xprof[5], yprof[5], xm, ym); // Ignore dummy xm,ym
3391
3392   xprof[ 4] = xprof[5];
3393   yprof[ 4] = yprof[5] - kExtSuppRingR5/TMath::Tan(kExtSuppRingSpcAng);
3394   xprof[ 3] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/6));
3395   yprof[ 3] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/6));
3396   xprof[ 2] = xprof[4] - kExtSuppRingR5*(1 - TMath::Cos(TMath::Pi()/3));
3397   yprof[ 2] = yprof[4] - kExtSuppRingR5*(    TMath::Sin(TMath::Pi()/3));
3398   xprof[ 1] = xprof[4] - kExtSuppRingR5;
3399   yprof[ 1] = yprof[4] - kExtSuppRingR5;
3400
3401   Int_t indx = 5+kExtSuppRingNPtsArc;
3402   // ...then the external arc, approximated with segments,...
3403   xprof[indx] = kExtSuppRingBase;
3404   yprof[indx] = TMath::Sqrt(kExtSuppRingRmax*kExtSuppRingRmax -
3405                             kExtSuppRingBase*kExtSuppRingBase);
3406   Double_t alphamin = TMath::ASin(kExtSuppRingSpace2/kExtSuppRingRmax);
3407   Double_t alphamax = TMath::Pi()/2 -
3408                     TMath::ASin(yprof[5+kExtSuppRingNPtsArc]/kExtSuppRingRmax);
3409
3410   for (Int_t jp = 1; jp < kExtSuppRingNPtsArc; jp++) {
3411     Double_t alpha = jp*(alphamax-alphamin)/kExtSuppRingNPtsArc;
3412     xprof[5+jp] = kExtSuppRingRmax*TMath::Sin(alpha);
3413     yprof[5+jp] = kExtSuppRingRmax*TMath::Cos(alpha);
3414   }
3415   // ...and finally the interior profile
3416   xprof[indx+1] = kExtSuppRingBase;
3417   yprof[indx+1] = kSuppRingYTrans;
3418   xprof[indx+2] = xprof[indx+1] - kExtSuppRingInward;
3419   yprof[indx+2] = yprof[indx+1];
3420
3421   phi  = TMath::Pi()/2 - 4*kExtSuppRingPartPhi - kExtSuppRingIntAng;
3422   slp1 = TMath::Tan(TMath::Pi() - kExtSuppRingBaseAng);
3423   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3424   xm   = kExtSuppRingRint2*TMath::Cos(phi);
3425   ym   = kExtSuppRingRint2*TMath::Sin(phi);
3426   IntersectLines(slp1, xprof[indx+2], yprof[indx+2], slp2, xm, ym,
3427                  xprof[indx+3], yprof[indx+3]);
3428
3429   slp1 = slp2;
3430   phi += kExtSuppRingPartPhi;
3431   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3432   xm   = kExtSuppRingRint1*TMath::Cos(phi);
3433   ym   = kExtSuppRingRint1*TMath::Sin(phi);
3434   IntersectLines(slp1, xprof[indx+3], yprof[indx+3], slp2, xm, ym,
3435                  xprof[indx+4], yprof[indx+4]);
3436   
3437   slp1 = slp2;
3438   phi += kExtSuppRingPartPhi;
3439   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3440   xm   = kExtSuppRingRint2*TMath::Cos(phi);
3441   ym   = kExtSuppRingRint2*TMath::Sin(phi);
3442   IntersectLines(slp1, xprof[indx+4], yprof[indx+4], slp2, xm, ym,
3443                  xprof[indx+5], yprof[indx+5]);
3444   
3445   slp1 = slp2;
3446   phi += kExtSuppRingPartPhi;
3447   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3448   xm   = kExtSuppRingRint1*TMath::Cos(phi);
3449   ym   = kExtSuppRingRint1*TMath::Sin(phi);
3450   IntersectLines(slp1, xprof[indx+5], yprof[indx+5], slp2, xm, ym,
3451                  xprof[indx+6], yprof[indx+6]);
3452   
3453   xprof[indx+9] = kExtSuppRingInWide;
3454   yprof[indx+9] = kExtSuppRingInnerHi;
3455   xprof[indx+8] = xprof[indx+9] +
3456                   (1 - TMath::Cos(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
3457   yprof[indx+8] = yprof[indx+9] +
3458                   (    TMath::Sin(kExtSuppRingR7Ang/2))*kExtSuppRingR7;
3459   xprof[indx+7] = xprof[indx+9] +
3460                   (1 + TMath::Cos(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
3461   yprof[indx+7] = yprof[indx+9] +
3462                   (    TMath::Sin(kExtSuppRingR7Ang  ))*kExtSuppRingR7;
3463   // Gosh, we did the right side! now reflex on the left side
3464   npoints = (sizeof(xprof)/sizeof(Double_t))/2;
3465   for (Int_t jp = 0; jp < npoints; jp++) {
3466     xprof[npoints+jp] = -xprof[npoints-1-jp];
3467     yprof[npoints+jp] =  yprof[npoints-1-jp];
3468   }
3469   // wow! now the actual Xtru
3470   extSuppRing->DefinePolygon(2*npoints, xprof, yprof);
3471   extSuppRing->DefineSection(0,0);
3472   extSuppRing->DefineSection(1,kExtSuppRingThick);
3473
3474   // The Internal Ring (part of 0872/G/A/01): another complex Xtru
3475   TGeoXtru *intSuppRing = new TGeoXtru(2);
3476
3477   // First the external profile...
3478   npoints = 0;
3479
3480   slp1 = 0;
3481   phi  = TMath::Pi()/2 - kExtSuppRingPartPhi - kExtSuppRingIntAng;
3482   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3483   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
3484   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
3485   IntersectLines(slp1,  0, kExtSuppRingInnerHi+kExtSuppRingSpcAbov,
3486                  slp2, xm, ym,
3487                  xprof[npoints], yprof[npoints]);
3488   npoints++;
3489
3490   slp1 = slp2;
3491   phi -= kExtSuppRingPartPhi;
3492   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3493   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
3494   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
3495   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3496                  slp2, xm, ym,
3497                  xprof[npoints], yprof[npoints]);
3498   npoints++;
3499
3500   slp1 = slp2;
3501   phi -= kExtSuppRingPartPhi;
3502   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3503   xm   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Cos(phi);
3504   ym   = (kExtSuppRingRint1+kIntSuppRingThick1)*TMath::Sin(phi);
3505   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3506                  slp2, xm, ym,
3507                  xprof[npoints], yprof[npoints]);
3508   npoints++;
3509
3510   slp1 = slp2;
3511   phi -= kExtSuppRingPartPhi;
3512   slp2 = TMath::Tan(TMath::Pi()/2 + phi);
3513   xm   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Cos(phi);
3514   ym   = (kExtSuppRingRint2+kIntSuppRingThick2)*TMath::Sin(phi);
3515   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3516                  slp2, xm, ym,
3517                  xprof[npoints], yprof[npoints]);
3518   npoints++;
3519
3520   xprof[npoints] = kExtSuppRingBase-kIntSuppRingInward;
3521   yprof[npoints] = Yfrom2Points(xprof[npoints-1], yprof[npoints-1], xm, ym,
3522                                 xprof[npoints]);
3523   npoints++;
3524
3525   xprof[npoints] = xprof[npoints-1];
3526   yprof[npoints] = kSuppRingYTrans;
3527   npoints++;
3528   // ...and then the interior profile, which is identical to extSuppRing one
3529   for (Int_t jp=0; jp < 8; jp++) {
3530     xprof[npoints] = extSuppRing->GetX(17+jp);
3531     yprof[npoints] = extSuppRing->GetY(17+jp);
3532     npoints++;
3533   }
3534   // We did the right side! now reflex on the left side
3535   for (Int_t jp = 0; jp < npoints; jp++) {
3536     xprof[npoints+jp] = -xprof[npoints-1-jp];
3537     yprof[npoints+jp] =  yprof[npoints-1-jp];
3538   }
3539   // And now the actual Xtru
3540   intSuppRing->DefinePolygon(2*npoints, xprof, yprof);
3541   intSuppRing->DefineSection(0,0);
3542   intSuppRing->DefineSection(1,kIntSuppRingThick);
3543
3544   // The intermediate cylinder (0872/G/A/03): a TubeSeg
3545   alphamin = TMath::ASin(kSuppCylDispl/kSuppCylRint)*TMath::RadToDeg();
3546   alphamax = 180 - alphamin;
3547   TGeoTubeSeg *interCylind = new TGeoTubeSeg(kSuppCylRint, kSuppCylRext,
3548                                      kSuppCylHeight/2, alphamin, alphamax);
3549
3550   // The spacer (0872/G/A/03): a simple Xtru
3551   TGeoXtru *suppSpacer = new TGeoXtru(2);
3552
3553   xprof[0] = kSuppSpacerHeight;
3554   yprof[0] = kSuppSpacerThick;
3555   xprof[1] = xprof[0];
3556   yprof[1] = 0;
3557   xprof[2] = 0;
3558   yprof[2] = 0;
3559   xprof[3] = kSuppSpacerThick*SinD(kSuppSpacerAngle);
3560   yprof[3] = yprof[0];
3561
3562   suppSpacer->DefinePolygon(4, xprof, yprof);
3563   suppSpacer->DefineSection(0,-kSuppCylHeight/2);
3564   suppSpacer->DefineSection(1, kSuppCylHeight/2);
3565
3566   // The forward ring (0872/G/B/02): a Pcon (slight oversimplification)
3567   Double_t rmean = (kSuppForwRingRint1+kSuppForwRingRext)/2;
3568   alphamin = TMath::ASin(kSuppForwYTrans/rmean)*TMath::RadToDeg();
3569   alphamax = 180 - alphamin;
3570
3571   TGeoPcon *forwardRing = new TGeoPcon(alphamin,alphamax-alphamin,4);
3572
3573   forwardRing->DefineSection(0,0,
3574                              kSuppForwRingRint1,kSuppForwRingRext);
3575   forwardRing->DefineSection(1,kSuppForwRingThikInt,
3576                              kSuppForwRingRint1,kSuppForwRingRext);
3577   forwardRing->DefineSection(2,kSuppForwRingThikInt,
3578                              kSuppForwRingRint2,kSuppForwRingRext);
3579   forwardRing->DefineSection(3,kSuppForwRingThikAll,
3580                              kSuppForwRingRint2,kSuppForwRingRext);
3581
3582   // The forward cone (0872/G/B/03): a TGeoPcon
3583   TGeoPcon *forwardCone = new TGeoPcon(alphamin,alphamax-alphamin,3);
3584
3585   forwardCone->DefineSection(0,0,
3586                              kSuppForwConeRmin-kSuppForwConeThick,
3587                              kSuppForwConeRmin);
3588   forwardCone->DefineSection(1,kSuppForwConeLen1,
3589                              kSuppForwConeRmin-kSuppForwConeThick,
3590                              kSuppForwConeRmin);
3591   forwardCone->DefineSection(2,kSuppForwConeLen1+kSuppForwConeLen2,
3592                              kSuppForwConeRmax-kSuppForwConeThick,
3593                              kSuppForwConeRmax);
3594
3595   // The first part of the Back Ring (part of 0872/G/B/01): a complex Xtru
3596   TGeoXtru *firstSuppBackRing = new TGeoXtru(2);
3597
3598   // First the external profile... (the arc is approximated with segments)
3599   npoints = 0;
3600
3601   xprof[npoints] = kSuppBackRingPlacTop;
3602   yprof[npoints] = kSuppBackRingHeight;
3603   npoints++;
3604
3605   alphamax = TMath::Pi()/2 - TMath::ASin(kSuppBackRingPlacTop/kSuppBackRingRext);
3606   alphamin = TMath::ASin((kSuppForwYTrans+kSuppBackRingPlacSid)/kSuppBackRingRext);
3607
3608   xprof[npoints] = xprof[npoints-1];
3609   yprof[npoints] = kSuppBackRingRext*TMath::Sin(alphamax);
3610   npoints++;
3611
3612   for (Int_t jp = 1; jp <= kSuppBackRingNPtsArc; jp++) {
3613     Double_t alpha = alphamax - jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
3614     xprof[npoints] = kSuppBackRingRext*TMath::Cos(alpha);
3615     yprof[npoints] = kSuppBackRingRext*TMath::Sin(alpha);
3616     npoints++;
3617   }
3618
3619   xprof[npoints] = kSuppBackRingBase -
3620                    kSuppBackRingPlacSid*TMath::Tan(kSuppBackRingPlacAng);
3621   yprof[npoints] = yprof[npoints-1];
3622   npoints++;
3623
3624   xprof[npoints] = kSuppBackRingBase;
3625   yprof[npoints] = kSuppForwYTrans;
3626   npoints++;
3627   // ...then the internal profile (the arc is approximated with segments)
3628   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint);
3629   alphamax = TMath::Pi()/2;
3630
3631   for (Int_t jp = 0; jp < kSuppBackRingNPtsArc; jp++) {
3632     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppBackRingNPtsArc;
3633     xprof[npoints] = kSuppBackRingRint*TMath::Cos(alpha);
3634     yprof[npoints] = kSuppBackRingRint*TMath::Sin(alpha);
3635     npoints++;
3636   }
3637
3638   xprof[npoints] = 0;
3639   yprof[npoints] = kSuppBackRingRint;
3640   npoints++;
3641   // We did the right side! now reflex on the left side (except last point)
3642   for (Int_t jp = 0; jp < npoints-1; jp++) {
3643     xprof[npoints+jp] = -xprof[npoints-jp-2];
3644     yprof[npoints+jp] =  yprof[npoints-jp-2];
3645   }
3646   // And now the actual Xtru
3647   firstSuppBackRing->DefinePolygon(2*npoints-1, xprof, yprof);
3648   firstSuppBackRing->DefineSection(0,0);
3649   firstSuppBackRing->DefineSection(1,kSuppBackRingThick1);
3650
3651   // The second part of the Back Ring (part of 0872/G/B/01): a Pcon
3652   // (slight oversimplification)
3653   alphamin = TMath::ASin(kSuppForwYTrans/kSuppBackRingRint)*TMath::RadToDeg();
3654   alphamax = 180 - alphamin;
3655
3656   TGeoPcon *secondSuppBackRing = new TGeoPcon(alphamin,alphamax-alphamin,6);
3657
3658   deltaR = kSuppBackRingThick2/TMath::Sin(kSuppBackRing2ndAng1);
3659   rmin = kSuppBackRingRint - kSuppBackRingThick1/TMath::Tan(kSuppBackRing2ndAng1);
3660   rmax = rmin + deltaR + kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
3661   secondSuppBackRing->DefineSection(0, 0, rmin, rmax);
3662
3663   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1/3));
3664   rmax -= kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1/3);
3665   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3666   secondSuppBackRing->DefineSection(1, zloc, rmin, rmax);
3667
3668   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1*2/3));
3669   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1*2/3);
3670   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3671   secondSuppBackRing->DefineSection(2, zloc, rmin, rmax);
3672
3673   zloc = kSuppBackRingR10*(1 - TMath::Cos(kSuppBackRing2ndAng1));
3674   rmax = secondSuppBackRing->GetRmax(0) - kSuppBackRingR10*TMath::Sin(kSuppBackRing2ndAng1);
3675   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3676   secondSuppBackRing->DefineSection(3, zloc, rmin, rmax);
3677
3678   slp1 = TMath::Tan(kSuppBackRing2ndAng2);
3679   slp2 = TMath::Tan(TMath::Pi()/2 + kSuppBackRing2ndAng1);
3680   IntersectLines(-slp1,kSuppBackRingThikAll,deltaR/2,
3681                   slp2,kSuppBackRingThikAll,deltaR,
3682                   xm, ym);
3683
3684   zloc = xm - kSuppBackRingThick1;
3685   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3686   rmax = rmin + deltaR;
3687   secondSuppBackRing->DefineSection(4, zloc, rmin, rmax);
3688
3689   zloc = kSuppBackRingThikAll - kSuppBackRingThick1;
3690   rmin = secondSuppBackRing->GetRmin(0) - zloc/TMath::Tan(kSuppBackRing2ndAng1);
3691   rmax = rmin + deltaR/2;
3692   secondSuppBackRing->DefineSection(5, zloc, rmin, rmax);
3693
3694   // The supporting rod: a Tube
3695   TGeoTube *suppRod = new TGeoTube(0, kBackRodDiameter/2,
3696                                    (kBackRodLength - kBackRodThickLen)/2);
3697
3698   // The Back Ring (0872/G/C/01): another complex Xtru
3699   TGeoXtru *suppRearRing = new TGeoXtru(2);
3700
3701   // First the external profile...
3702   npoints = 0;
3703
3704   xprof[npoints] = kSuppRearRingTopWide;
3705   yprof[npoints] = kSuppRearRingHeight;
3706   npoints++;
3707
3708   phi = kSuppRearRing1stAng;
3709   slp1 = TMath::Tan(TMath::Pi() - phi);
3710   phi += kSuppRearRingStepAng;
3711   slp2 = TMath::Tan(TMath::Pi() - phi);
3712   xm = kSuppRearRingRext2*TMath::Sin(phi);
3713   ym = kSuppRearRingRext2*TMath::Cos(phi);
3714   IntersectLines(slp1, kSuppRearRingTopWide, kSuppRearRingHeight,
3715                  slp2, xm, ym,
3716                  xprof[npoints], yprof[npoints]);
3717   npoints++;
3718
3719   slp1 = slp2;
3720   phi += kSuppRearRingStepAng;
3721   slp2 = TMath::Tan(TMath::Pi() - phi);
3722   xm = kSuppRearRingRext1*TMath::Sin(phi);
3723   ym = kSuppRearRingRext1*TMath::Cos(phi);
3724   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3725                  slp2, xm, ym,
3726                  xprof[npoints], yprof[npoints]);
3727   npoints++;
3728
3729   slp1 = slp2;
3730   phi += kSuppRearRingStepAng;
3731   slp2 = TMath::Tan(TMath::Pi() - phi);
3732   xm = kSuppRearRingRext2*TMath::Sin(phi);
3733   ym = kSuppRearRingRext2*TMath::Cos(phi);
3734   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3735                  slp2, xm, ym,
3736                  xprof[npoints], yprof[npoints]);
3737   npoints++;
3738
3739   slp1 = slp2;
3740   slp2 = 0;
3741   xm = kSuppRearRingBase;
3742   ym = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3743   IntersectLines(slp1, xprof[npoints-1], yprof[npoints-1],
3744                  slp2, xm, ym,
3745                  xprof[npoints], yprof[npoints]);
3746   npoints++;
3747
3748   xprof[npoints] = kSuppRearRingBase;
3749   yprof[npoints] = kSuppRearRingBaseHi + kSuppRearRingSideHi;
3750   npoints++;
3751   xprof[npoints] = xprof[npoints - 1];
3752   yprof[npoints] = kSuppRearRingBaseHi;
3753   npoints++;
3754   xprof[npoints] = xprof[npoints - 1] - kSuppRearRingInside;
3755   yprof[npoints] = yprof[npoints - 1];
3756   npoints++;
3757   xprof[npoints] = xprof[npoints - 1];
3758   yprof[npoints] = yprof[npoints - 1] + kSuppRearRingInsideHi;
3759   npoints++;
3760   // ...then the internal arc, approximated with segments,...
3761   xprof[npoints] = kSuppRearRingRint;
3762   yprof[npoints] = yprof[npoints - 1];
3763
3764   alphamin = TMath::ASin(kSuppRearRingBaseHi/kSuppRearRingRint);
3765   alphamax = TMath::Pi()/2;
3766
3767   for (Int_t jp = 1; jp < kSuppRearRingNPtsArc; jp++) {
3768     Double_t alpha = alphamin + jp*(alphamax-alphamin)/kSuppRearRingNPtsArc;
3769     xprof[npoints+jp] = kSuppRearRingRint*TMath::Cos(alpha);
3770     yprof[npoints+jp] = kSuppRearRingRint*TMath::Sin(alpha);
3771   }
3772
3773   xprof[npoints+kSuppRearRingNPtsArc] = 0;
3774   yprof[npoints+kSuppRearRingNPtsArc] = kSuppRearRingRint;
3775   // We did the right side! now reflex on the left side
3776   Int_t nTotalPoints = npoints+kSuppRearRingNPtsArc;
3777   for (Int_t jp = 0; jp < nTotalPoints; jp++) {
3778     xprof[nTotalPoints+1+jp] = -xprof[nTotalPoints-1-jp];
3779     yprof[nTotalPoints+1+jp] =  yprof[nTotalPoints-1-jp];
3780   }
3781
3782   // And now the actual Xtru
3783   suppRearRing->DefinePolygon(2*nTotalPoints+1, xprof, yprof);
3784   suppRearRing->DefineSection(0,0);
3785   suppRearRing->DefineSection(1,kSuppRearRingThick);
3786
3787
3788   // We have all shapes: now create the real volumes
3789   TGeoMedium *medAl = mgr->GetMedium("ITS_ANTICORODAL$");
3790
3791   TGeoVolume *sideAExtSuppRing = new TGeoVolume("ITSsuppSideAExtSuppRing",
3792                                                  extSuppRing, medAl);
3793
3794   sideAExtSuppRing->SetVisibility(kTRUE);
3795   sideAExtSuppRing->SetLineColor(kMagenta+1);
3796   sideAExtSuppRing->SetLineWidth(1);
3797   sideAExtSuppRing->SetFillColor(sideAExtSuppRing->GetLineColor());
3798   sideAExtSuppRing->SetFillStyle(4000); // 0% transparent
3799
3800   TGeoVolume *sideAIntSuppRing = new TGeoVolume("ITSsuppSideAIntSuppRing",
3801                                                  intSuppRing, medAl);
3802
3803   sideAIntSuppRing->SetVisibility(kTRUE);
3804   sideAIntSuppRing->SetLineColor(kMagenta+1);
3805   sideAIntSuppRing->SetLineWidth(1);
3806   sideAIntSuppRing->SetFillColor(sideAIntSuppRing->GetLineColor());
3807   sideAIntSuppRing->SetFillStyle(4000); // 0% transparent
3808
3809   TGeoVolume *sideASuppCyl = new TGeoVolume("ITSsuppSideASuppCyl",
3810                                             interCylind, medAl);
3811
3812   sideASuppCyl->SetVisibility(kTRUE);
3813   sideASuppCyl->SetLineColor(kMagenta+1);
3814   sideASuppCyl->SetLineWidth(1);
3815   sideASuppCyl->SetFillColor(sideASuppCyl->GetLineColor());
3816   sideASuppCyl->SetFillStyle(4000); // 0% transparent
3817
3818   TGeoVolume *sideASuppSpacer = new TGeoVolume("ITSsuppSideASuppSpacer",
3819                                                suppSpacer, medAl);
3820
3821   sideASuppSpacer->SetVisibility(kTRUE);
3822   sideASuppSpacer->SetLineColor(kMagenta+1);
3823   sideASuppSpacer->SetLineWidth(1);
3824   sideASuppSpacer->SetFillColor(sideASuppSpacer->GetLineColor());
3825   sideASuppSpacer->SetFillStyle(4000); // 0% transparent
3826
3827   TGeoVolume *sideASuppForwRing = new TGeoVolume("ITSsuppSideASuppForwRing",
3828                                                  forwardRing, medAl);
3829
3830   sideASuppForwRing->SetVisibility(kTRUE);
3831   sideASuppForwRing->SetLineColor(kMagenta+1);
3832   sideASuppForwRing->SetLineWidth(1);
3833   sideASuppForwRing->SetFillColor(sideASuppForwRing->GetLineColor());
3834   sideASuppForwRing->SetFillStyle(4000); // 0% transparent
3835
3836   TGeoVolume *sideASuppForwCone = new TGeoVolume("ITSsuppSideASuppForwCone",
3837                                                  forwardCone, medAl);
3838
3839   sideASuppForwCone->SetVisibility(kTRUE);
3840   sideASuppForwCone->SetLineColor(kMagenta+1);
3841   sideASuppForwCone->SetLineWidth(1);
3842   sideASuppForwCone->SetFillColor(sideASuppForwCone->GetLineColor());
3843   sideASuppForwCone->SetFillStyle(4000); // 0% transparent
3844
3845   TGeoVolume *sideAFirstSuppBackRing = new TGeoVolume("ITSsuppSideAFirstSuppBackRing",
3846                                                      firstSuppBackRing, medAl);
3847
3848   sideAFirstSuppBackRing->SetVisibility(kTRUE);
3849   sideAFirstSuppBackRing->SetLineColor(kMagenta+1);
3850   sideAFirstSuppBackRing->SetLineWidth(1);
3851   sideAFirstSuppBackRing->SetFillColor(sideAFirstSuppBackRing->GetLineColor());
3852   sideAFirstSuppBackRing->SetFillStyle(4000); // 0% transparent
3853
3854   TGeoVolume *sideASecondSuppBackRing = new TGeoVolume("ITSsuppSideASecondSuppBackRing",
3855                                                        secondSuppBackRing, medAl);
3856
3857   sideASecondSuppBackRing->SetVisibility(kTRUE);
3858   sideASecondSuppBackRing->SetLineColor(kMagenta+1);
3859   sideASecondSuppBackRing->SetLineWidth(1);
3860   sideASecondSuppBackRing->SetFillColor(sideASecondSuppBackRing->GetLineColor());
3861   sideASecondSuppBackRing->SetFillStyle(4000); // 0% transparent
3862
3863   TGeoVolume *sideASuppRod = new TGeoVolume("ITSsuppSideASuppRod",
3864                                             suppRod, medAl);
3865
3866   sideASuppRod->SetVisibility(kTRUE);
3867   sideASuppRod->SetLineColor(kMagenta+1);
3868   sideASuppRod->SetLineWidth(1);
3869   sideASuppRod->SetFillColor(sideASuppRod->GetLineColor());
3870   sideASuppRod->SetFillStyle(4000); // 0% transparent
3871
3872   TGeoVolume *sideASuppRearRing = new TGeoVolume("ITSsuppSideASuppRearRing",
3873                                                  suppRearRing, medAl);
3874
3875   sideASuppRearRing->SetVisibility(kTRUE);
3876   sideASuppRearRing->SetLineColor(kMagenta+1);
3877   sideASuppRearRing->SetLineWidth(1);
3878   sideASuppRearRing->SetFillColor(sideASuppRearRing->GetLineColor());
3879   sideASuppRearRing->SetFillStyle(4000); // 0% transparent
3880
3881
3882   // Now build up the support structure
3883   zloc = kSuppRingZTrans;
3884   trayASuppStruct->AddNode(sideAExtSuppRing, 1,
3885                            new TGeoTranslation(0, 0, zloc) );
3886   trayASuppStruct->AddNode(sideAExtSuppRing, 2,
3887                            new TGeoCombiTrans( 0, 0, zloc,
3888                                                new TGeoRotation("",180,0,0)));
3889
3890   zloc += kExtSuppRingThick;
3891   trayASuppStruct->AddNode(sideAIntSuppRing, 1,
3892                            new TGeoTranslation(0, 0, zloc) );
3893   trayASuppStruct->AddNode(sideAIntSuppRing, 2,
3894                            new TGeoCombiTrans( 0, 0, zloc,
3895                                                new TGeoRotation("",180,0,0)));
3896
3897   xloc = kExtSuppRingBase - kIntSuppRingInward;
3898   yloc = kSuppRingYTrans;
3899   zloc += (kIntSuppRingThick + kSuppCylHeight/2);
3900   trayASuppStruct->AddNode(sideASuppCyl, 1,
3901                            new TGeoTranslation(0, 0, zloc) );
3902   trayASuppStruct->AddNode(sideASuppCyl, 2,
3903                            new TGeoCombiTrans( 0, 0, zloc,
3904                                                new TGeoRotation("",180,0,0)));
3905   trayASuppStruct->AddNode(sideASuppSpacer, 1,
3906                            new TGeoCombiTrans( xloc, yloc, zloc,
3907                            new TGeoRotation("",90+kSuppSpacerAngle,0,0)));
3908   trayASuppStruct->AddNode(sideASuppSpacer, 2,
3909                            new TGeoCombiTrans(-xloc, yloc, zloc,
3910                            new TGeoRotation("",0,180,kSuppSpacerAngle-90)));
3911   trayASuppStruct->AddNode(sideASuppSpacer, 3,
3912                            new TGeoCombiTrans( xloc,-yloc, zloc,
3913                            new TGeoRotation("",180,180,kSuppSpacerAngle-90)));
3914   trayASuppStruct->AddNode(sideASuppSpacer, 4,
3915                            new TGeoCombiTrans(-xloc,-yloc, zloc,
3916                            new TGeoRotation("",270+kSuppSpacerAngle,0,0)));
3917
3918
3919   zloc += kSuppCylHeight/2;
3920   trayASuppStruct->AddNode(sideAIntSuppRing, 3,
3921                            new TGeoTranslation(0, 0, zloc) );
3922   trayASuppStruct->AddNode(sideAIntSuppRing, 4,
3923                            new TGeoCombiTrans( 0, 0, zloc,
3924                                                new TGeoRotation("",180,0,0)));
3925
3926   zloc += kIntSuppRingThick;
3927   trayASuppStruct->AddNode(sideAExtSuppRing, 3,
3928                            new TGeoTranslation(0, 0, zloc) );
3929   trayASuppStruct->AddNode(sideAExtSuppRing, 4,
3930                            new TGeoCombiTrans( 0, 0, zloc,
3931                                                new TGeoRotation("",180,0,0)));
3932
3933   zloc += kExtSuppRingThick;
3934   trayASuppStruct->AddNode(sideASuppForwRing, 1,
3935                            new TGeoTranslation(0, 0, zloc) );
3936   trayASuppStruct->AddNode(sideASuppForwRing, 2,
3937                            new TGeoCombiTrans( 0, 0, zloc,
3938                                                new TGeoRotation("",180,0,0)));
3939
3940   zloc += kSuppForwRingThikAll;
3941   trayASuppStruct->AddNode(sideASuppForwCone, 1,
3942                            new TGeoTranslation(0, 0, zloc) );
3943   trayASuppStruct->AddNode(sideASuppForwCone, 2,
3944                            new TGeoCombiTrans( 0, 0, zloc,
3945                                                new TGeoRotation("",180,0,0)));
3946
3947   zloc += (kSuppForwConeLen1+kSuppForwConeLen2);
3948   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 1,
3949                            new TGeoTranslation(0, 0, zloc) );
3950   trayASuppStruct->AddNode(sideAFirstSuppBackRing, 2,
3951                            new TGeoCombiTrans( 0, 0, zloc,
3952                                                new TGeoRotation("",180,0,0)));
3953
3954   zloc += kSuppBackRingThick1;
3955   trayASuppStruct->AddNode(sideASecondSuppBackRing, 1,
3956                            new TGeoTranslation(0, 0, zloc) );
3957   trayASuppStruct->AddNode(sideASecondSuppBackRing, 2,
3958                            new TGeoCombiTrans( 0, 0, zloc,
3959                                                new TGeoRotation("",180,0,0)));
3960
3961   xloc = kSuppRearRingXRodHole;
3962   yloc = kSuppRearRingBaseHi + kSuppRearRingYRodHole;
3963   zloc = kRearSuppZTransGlob - kBackRodZTrans + suppRod->GetDz();
3964   trayASuppStruct->AddNode(sideASuppRod, 1,
3965                            new TGeoTranslation( xloc, yloc, zloc) );
3966   trayASuppStruct->AddNode(sideASuppRod, 2,
3967                            new TGeoTranslation(-xloc, yloc, zloc) );
3968   trayASuppStruct->AddNode(sideASuppRod, 3,
3969                            new TGeoTranslation( xloc,-yloc, zloc) );
3970   trayASuppStruct->AddNode(sideASuppRod, 4,
3971                            new TGeoTranslation(-xloc,-yloc, zloc) );
3972
3973   zloc += suppRod->GetDz();
3974   trayASuppStruct->AddNode(sideASuppRearRing, 1,
3975                            new TGeoTranslation( 0, 0, zloc) );
3976   trayASuppStruct->AddNode(sideASuppRearRing, 2,
3977                            new TGeoCombiTrans( 0, 0, zloc,
3978                                                new TGeoRotation("",180,0,0)));
3979
3980
3981   // Finally put everything in the mother volume
3982   moth->AddNode(trayASuppStruct,1,0);
3983
3984   return;
3985 }
3986
3987 //______________________________________________________________________
3988 void AliITSv11GeometrySupport::ServicesCableSupportSPD(TGeoVolume *moth,
3989                                                        TGeoManager *mgr){
3990 //
3991 // Creates the all SPD cable trays which are outside the ITS support cones
3992 // but still inside the TPC
3993 // In order to avoid a huge monolithic routine, this method actually
3994 // calls inner methods to create and assemble the various (macro)pieces
3995 //
3996 // Input:
3997 //         moth : the TGeoVolume owing the volume structure
3998 //         mgr  : the GeoManager (default gGeoManager)
3999 // Output:
4000 //
4001 // Created:         ???       Bjorn S. Nilsen
4002 // Updated:      15 Nov 2009  Mario Sitta
4003 //
4004 // Technical data are taken from AutoCAD drawings and other (oral)
4005 // information given by F.Tosello
4006 //
4007
4008   SPDCableTraysSideA(moth, mgr);
4009   SPDCableTraysSideC(moth, mgr);
4010
4011 }
4012
4013 //______________________________________________________________________
4014 void AliITSv11GeometrySupport::ServicesCableSupportSDD(TGeoVolume *moth,
4015                                                        TGeoManager *mgr){
4016 //
4017 // Creates the all SDD cable trays which are outside the ITS support cones
4018 // but still inside the TPC
4019 // In order to avoid a huge monolithic routine, this method actually
4020 // calls inner methods to create and assemble the various (macro)pieces
4021 //
4022 // Input:
4023 //         moth : the TGeoVolume owing the volume structure
4024 //         mgr  : the GeoManager (default gGeoManager)
4025 // Output:
4026 //
4027 // Created:      14 Dec 2009  Mario Sitta
4028 //
4029
4030   SDDCableTraysSideA(moth, mgr);
4031   SDDCableTraysSideC(moth, mgr);
4032
4033   return;
4034 }
4035
4036 //______________________________________________________________________
4037 void AliITSv11GeometrySupport::ServicesCableSupportSSD(TGeoVolume *moth,
4038                                                        TGeoManager *mgr){
4039 //
4040 // Creates the SSD cable trays which are outside the ITS support cones
4041 // but still inside the TPC
4042 // In order to avoid a huge monolithic routine, this method actually
4043 // calls inner methods to create and assemble the various (macro)pieces
4044 //
4045 // Input:
4046 //         moth : the TGeoVolume owing the volume structure
4047 //         mgr  : the GeoManager (default gGeoManager)
4048 // Output:
4049 //
4050 // Created:      15 Nov 2009  Mario Sitta
4051 //
4052
4053   SSDCableTraysSideA(moth, mgr);
4054   SSDCableTraysSideC(moth, mgr);
4055
4056   return;
4057 }
4058
4059 //______________________________________________________________________
4060 void AliITSv11GeometrySupport::SPDCableTraysSideA(TGeoVolume *moth,
4061                                             const TGeoManager *mgr){
4062 //
4063 // Creates the SPD cable trays which are outside the ITS support cones
4064 // but still inside the TPC on Side A
4065 // (part of this code is taken or anyway inspired to ServicesCableSupport
4066 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
4067 //
4068 // Input:
4069 //         moth : the TGeoVolume owing the volume structure
4070 //         mgr  : the GeoManager (default gGeoManager)
4071 // Output:
4072 //
4073 // Created:      15 Feb 2010  Mario Sitta
4074 // Updated:      10 Jun 2010  Mario Sitta  Freon inside cooling pipes
4075 // Updated:      08 Sep 2010  Mario Sitta
4076 // Updated:      14 Sep 2010  Mario Sitta  Cables prolonged till cone
4077 //
4078 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
4079 // drawings and other (oral) information given by F.Tosello and D.Elia
4080 // (small differences with blueprints - e.g. -0.07mm in R1Trans and
4081 // R2Trans - fix small overlaps; they are then compensated in positioning
4082 // the Rear Tray to avoid its own overlaps with the rear supporting ring)
4083 // Optical fibers and voltage cables are approximated with mean materials
4084 // and square cross sections, but preserving the total material budget.
4085 //
4086
4087   // Overall position and rotation of the A-Side Cable Trays
4088   // (parts of 0872/G/D)
4089   const Double_t kTrayAR1Trans           =  396.93 *fgkmm;
4090   const Double_t kTrayAR2Trans           =  413.93 *fgkmm;
4091   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
4092   const Double_t kTrayAZRot              = (180-169.5);// Degrees
4093   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
4094   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
4095
4096   const Double_t kForwardTrayWide        =   94.00 *fgkmm;//!!!TO BE CHECKED!!!
4097   const Double_t kForwardTrayFirstHigh   =   83.00 *fgkmm;//!!!TO BE CHECKED!!!
4098   const Double_t kForwardTraySecondHigh  =   52.70 *fgkmm;//!!!TO BE CHECKED!!!
4099   const Double_t kForwardTrayTotalLen    =  853.00 *fgkmm;
4100   const Double_t kForwardTrayFirstLen    =  435.00 *fgkmm;
4101   const Double_t kForwardTrayWingWide    =   16.00 *fgkmm;//!!!TO BE CHECKED!!!
4102   const Double_t kForwardTrayInterSpace  =   18.00 *fgkmm;//!!!TO BE CHECKED!!!
4103   const Double_t kForwardTrayThick       =    2.00 *fgkmm;
4104
4105   const Int_t    kForwardSideNpoints     =    6;
4106
4107   const Double_t kExternalTrayLen        = 1200.00 *fgkmm;
4108   const Double_t kExternalTrayWide       = kForwardTrayWide;
4109   const Double_t kExternalTrayHigh       = kForwardTraySecondHigh;
4110   const Double_t kExternalTrayThick      = kForwardTrayThick;
4111
4112   const Double_t kCoolingTubeRmin        =    2.00 *fgkmm;
4113   const Double_t kCoolingTubeRmax        =    3.00 *fgkmm;
4114
4115   const Double_t kOpticalFibersSect      =    8.696*fgkmm;//!!!ESTIMATED!!!
4116   const Double_t kLowVoltageCableSectCu  =    7.675*fgkmm;// Computed
4117   const Double_t kLowVoltageCableHighPUR =    1.000*fgkmm;// Computed
4118   const Double_t kHiVoltageCableSectCu   =    1.535*fgkmm;// Computed
4119   const Double_t kHiVoltageCableHighPUR  =    0.500*fgkmm;// Computed
4120   const Double_t kCoaxCableSectCu        =    6.024*fgkmm;// Computed
4121   const Double_t kCoaxCableHighMeg       =    5.695*fgkmm;// Computed
4122
4123   const Double_t kTrayCCablesRot         =   75.000*fgkDegree;// Computed
4124   const Double_t kTrayCCablesZLenOut     =  227.000*fgkmm;// Computed
4125
4126
4127   // Local variables
4128   Double_t xprof[kForwardSideNpoints], yprof[kForwardSideNpoints];
4129   Double_t xloc, yloc, zloc, alpharot;
4130
4131
4132   // The two tray components as assemblies
4133   TGeoVolumeAssembly *cableTrayAForw =
4134     new TGeoVolumeAssembly("ITSsupportSPDTrayAForwRear");
4135   TGeoVolumeAssembly *cableTrayAExt =
4136     new TGeoVolumeAssembly("ITSsupportSPDTrayAExt");
4137   
4138
4139   // First create all needed shapes
4140
4141   // The lower face of the forward tray: a BBox
4142   TGeoBBox *forwTrayLowerFace = new TGeoBBox(kForwardTrayWide/2,
4143                                              kForwardTrayThick/2,
4144                                              kForwardTrayTotalLen/2);
4145
4146   // The side face of the forward tray: a Xtru
4147   TGeoXtru *forwTraySideFace = new TGeoXtru(2);
4148   forwTraySideFace->SetName("ITSsuppSPDForwTraySide");
4149
4150   xprof[0] = 0;
4151   yprof[0] = kForwardTrayThick;
4152   xprof[1] = kForwardTrayTotalLen;
4153   yprof[1] = yprof[0];
4154   xprof[2] = xprof[1];
4155   yprof[2] = kForwardTraySecondHigh - kForwardTrayThick;
4156   xprof[3] = kForwardTrayFirstLen;
4157   yprof[3] = yprof[2];
4158   xprof[4] = xprof[3];
4159   yprof[4] = kForwardTrayFirstHigh - kForwardTrayThick;
4160   xprof[5] = xprof[0];
4161   yprof[5] = yprof[4];
4162
4163   forwTraySideFace->DefinePolygon(6, xprof, yprof);
4164   forwTraySideFace->DefineSection(0, 0);
4165   forwTraySideFace->DefineSection(1, kForwardTrayThick);
4166
4167   // The covers of the forward tray: two BBox's
4168   TGeoBBox *forwTrayShortCover = new TGeoBBox(kForwardTrayWide/2,
4169                                               kForwardTrayThick/2,
4170                                               kForwardTrayFirstLen/2);
4171
4172   TGeoBBox *forwTrayLongCover = new TGeoBBox(kForwardTrayWide/2,
4173                                              kForwardTrayThick/2,
4174                              (kForwardTrayTotalLen - kForwardTrayFirstLen)/2);
4175
4176   // Each small wing of the forward tray: a BBox
4177   TGeoBBox *forwTrayWing = new TGeoBBox(kForwardTrayWingWide/2,
4178                              (kForwardTrayFirstHigh-kForwardTraySecondHigh)/2,
4179                                         kForwardTrayThick/2);
4180
4181   // The internal plane of the forward tray: a BBox
4182   TGeoBBox *forwTrayPlane = new TGeoBBox(kForwardTrayWide/2-kForwardTrayThick,
4183                                          kForwardTrayThick/2,
4184                                          kForwardTrayTotalLen/2);
4185
4186   // The internal wall of the forward tray: a BBox
4187   TGeoBBox *forwTrayWall = new TGeoBBox(kForwardTrayThick/2,
4188                                  (kForwardTrayInterSpace-kForwardTrayThick)/2,
4189                                         kForwardTrayTotalLen/2);
4190
4191   // Each horizontal face of the external tray: a BBox
4192   TGeoBBox *extTrayHorFace = new TGeoBBox(kExternalTrayWide/2-kExternalTrayThick,
4193                                           kExternalTrayThick/2,
4194                                           kExternalTrayLen/2);
4195
4196   // Each vertical face of the external tray: a BBox
4197   TGeoBBox *extTrayVerFace = new TGeoBBox(kExternalTrayThick/2,
4198                                           kExternalTrayHigh/2,
4199                                           kExternalTrayLen/2);
4200
4201   // The internal wall of the external tray: a BBox
4202   TGeoBBox *extTrayWall = new TGeoBBox(kExternalTrayThick/2,
4203                                  (kForwardTrayInterSpace-kExternalTrayThick)/2,
4204                                        kExternalTrayLen/2);
4205
4206   // The cooling tube inside the forward tray: a Tube
4207   Double_t zelong = (kForwardTraySecondHigh - 2*kForwardTrayThick
4208                 - 2*forwTrayWall->GetDY() - kCoolingTubeRmax)*SinD(kTrayAZRot);
4209   Double_t zlen = (zelong + kForwardTrayTotalLen)/2;
4210   TGeoTube *coolTubeForw = new TGeoTube(0, kCoolingTubeRmax, zlen);
4211
4212   // The freon inside the forward tray tubes: a Tube
4213   TGeoTube *freonTubeForw = new TGeoTube(0, kCoolingTubeRmin, zlen);
4214
4215   // The cooling tube inside the external tray: a Ctub
4216   TGeoCtub *coolTubeExt = new TGeoCtub(0, kCoolingTubeRmax,
4217                                        kExternalTrayLen/2, 0, 360,
4218                                        0, SinD(kTrayAZRot),-CosD(kTrayAZRot),
4219                                        0,                0,               1);
4220
4221   // The freon inside the forward tray tubes: a Tube
4222   TGeoCtub *freonTubeExt = new TGeoCtub(0, kCoolingTubeRmin,
4223                                         kExternalTrayLen/2, 0, 360,
4224                                         0, SinD(kTrayAZRot),-CosD(kTrayAZRot),
4225                                         0,                0,               1);
4226
4227   // The optical fibers inside the forward tray: a Xtru
4228   TGeoXtru *optFibsForw = new TGeoXtru(2);
4229
4230   xprof[0] = -kTrayCCablesZLenOut;
4231   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4232   xprof[1] = 0;
4233   yprof[1] = 0;
4234   xprof[2] = kForwardTrayTotalLen;
4235   yprof[2] = yprof[1];
4236   xprof[3] = xprof[2];
4237   yprof[3] = yprof[2] + kOpticalFibersSect;
4238   xprof[4] = xprof[1];
4239   yprof[4] = yprof[3];
4240   xprof[5] = xprof[0];
4241   yprof[5] = yprof[0] + kOpticalFibersSect;
4242
4243   optFibsForw->DefinePolygon(6, xprof, yprof);
4244   optFibsForw->DefineSection(0,-kOpticalFibersSect/2);
4245   optFibsForw->DefineSection(1, kOpticalFibersSect/2);
4246
4247   // The optical fibers inside the external tray: a Xtru
4248   TGeoXtru *optFibsExt = new TGeoXtru(2);
4249   optFibsExt->SetName("ITSsuppSPDExtTrayOptFibs");
4250
4251   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4252            + 2*forwTrayWall->GetDY();
4253   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4254   xprof[1] = kExternalTrayLen;
4255   yprof[1] = yprof[0];
4256   xprof[2] = xprof[1];
4257   yprof[2] = yprof[1] + kOpticalFibersSect;
4258   yprof[3] = yprof[2];
4259   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4260
4261   optFibsExt->DefinePolygon(4, xprof, yprof);
4262   optFibsExt->DefineSection(0, 0);
4263   optFibsExt->DefineSection(1, kOpticalFibersSect);
4264
4265   // The Low Voltage cables inside the forward tray: two Xtru
4266   TGeoXtru *lowCablesForwCu = new TGeoXtru(2);
4267
4268   xprof[0] = -kTrayCCablesZLenOut;
4269   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4270   xprof[1] = 0;
4271   yprof[1] = 0;
4272   xprof[2] = kForwardTrayTotalLen;
4273   yprof[2] = yprof[1];
4274   xprof[3] = xprof[2];
4275   yprof[3] = yprof[2] + kLowVoltageCableSectCu/2;
4276   xprof[4] = xprof[1];
4277   yprof[4] = yprof[3];
4278   xprof[5] = xprof[0];
4279   yprof[5] = yprof[0] + kLowVoltageCableSectCu/2;
4280
4281   lowCablesForwCu->DefinePolygon(6, xprof, yprof);
4282   lowCablesForwCu->DefineSection(0,-kLowVoltageCableSectCu);
4283   lowCablesForwCu->DefineSection(1, kLowVoltageCableSectCu);
4284
4285   TGeoXtru *lowCablesForwPUR = new TGeoXtru(2);
4286
4287   xprof[0] = lowCablesForwCu->GetX(5);
4288   yprof[0] = lowCablesForwCu->GetY(5);
4289   xprof[1] = lowCablesForwCu->GetX(4);
4290   yprof[1] = lowCablesForwCu->GetY(4);
4291   xprof[2] = lowCablesForwCu->GetX(3);
4292   yprof[2] = lowCablesForwCu->GetY(3);
4293   xprof[3] = xprof[2];
4294   yprof[3] = yprof[2] + kLowVoltageCableHighPUR/2;
4295   xprof[4] = xprof[1];
4296   yprof[4] = yprof[3];
4297   xprof[5] = xprof[0];
4298   yprof[5] = yprof[0] + kLowVoltageCableHighPUR/2;
4299
4300   lowCablesForwPUR->DefinePolygon(6, xprof, yprof);
4301   lowCablesForwPUR->DefineSection(0,-kLowVoltageCableSectCu);
4302   lowCablesForwPUR->DefineSection(1, kLowVoltageCableSectCu);
4303
4304   // The Low Voltage inside the external tray: two Xtru
4305   TGeoXtru *lowCablesExtCu = new TGeoXtru(2);
4306   lowCablesExtCu->SetName("ITSsuppSPDExtTrayLowVoltageCu");
4307
4308   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4309            + 2*forwTrayWall->GetDY();
4310   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4311   xprof[1] = kExternalTrayLen;
4312   yprof[1] = yprof[0];
4313   xprof[2] = xprof[1];
4314   yprof[2] = yprof[1] + kLowVoltageCableSectCu/2;
4315   yprof[3] = yprof[2];
4316   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4317
4318   lowCablesExtCu->DefinePolygon(4, xprof, yprof);
4319   lowCablesExtCu->DefineSection(0, 0);
4320   lowCablesExtCu->DefineSection(1, kLowVoltageCableSectCu*2);
4321
4322   TGeoXtru *lowCablesExtPUR = new TGeoXtru(2);
4323   lowCablesExtPUR->SetName("ITSsuppSPDExtTrayLowVoltagePUR");
4324
4325   xprof[0] = lowCablesExtCu->GetX(3);
4326   yprof[0] = lowCablesExtCu->GetY(3);
4327   xprof[1] = lowCablesExtCu->GetX(2);
4328   yprof[1] = lowCablesExtCu->GetY(2);
4329   xprof[2] = xprof[1];
4330   yprof[2] = yprof[1] + kLowVoltageCableHighPUR/2;
4331   yprof[3] = yprof[2];
4332   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4333
4334   lowCablesExtPUR->DefinePolygon(4, xprof, yprof);
4335   lowCablesExtPUR->DefineSection(0, 0);
4336   lowCablesExtPUR->DefineSection(1, kLowVoltageCableSectCu*2);
4337
4338   // The High Voltage cables inside the forward tray: two Xtru
4339   TGeoXtru *hiCablesForwCu = new TGeoXtru(2);
4340
4341   xprof[0] = -kTrayCCablesZLenOut;
4342   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4343   xprof[1] = 0;
4344   yprof[1] = 0;
4345   xprof[2] = kForwardTrayTotalLen;
4346   yprof[2] = yprof[1];
4347   xprof[3] = xprof[2];
4348   yprof[3] = yprof[2] + kHiVoltageCableSectCu/2;
4349   xprof[4] = xprof[1];
4350   yprof[4] = yprof[3];
4351   xprof[5] = xprof[0];
4352   yprof[5] = yprof[0] + kHiVoltageCableSectCu/2;
4353
4354   hiCablesForwCu->DefinePolygon(6, xprof, yprof);
4355   hiCablesForwCu->DefineSection(0,-kHiVoltageCableSectCu);
4356   hiCablesForwCu->DefineSection(1, kHiVoltageCableSectCu);
4357
4358   TGeoXtru *hiCablesForwPUR = new TGeoXtru(2);
4359
4360   xprof[0] = hiCablesForwCu->GetX(5);
4361   yprof[0] = hiCablesForwCu->GetY(5);
4362   xprof[1] = hiCablesForwCu->GetX(4);
4363   yprof[1] = hiCablesForwCu->GetY(4);
4364   xprof[2] = hiCablesForwCu->GetX(3);
4365   yprof[2] = hiCablesForwCu->GetY(3);
4366   xprof[3] = xprof[2];
4367   yprof[3] = yprof[2] + kHiVoltageCableHighPUR/2;
4368   xprof[4] = xprof[1];
4369   yprof[4] = yprof[3];
4370   xprof[5] = xprof[0];
4371   yprof[5] = yprof[0] + kHiVoltageCableHighPUR/2;
4372
4373   hiCablesForwPUR->DefinePolygon(6, xprof, yprof);
4374   hiCablesForwPUR->DefineSection(0,-kHiVoltageCableSectCu);
4375   hiCablesForwPUR->DefineSection(1, kHiVoltageCableSectCu);
4376
4377   // The High Voltage inside the external tray: two Xtru
4378   TGeoXtru *hiCablesExtCu = new TGeoXtru(2);
4379   hiCablesExtCu->SetName("ITSsuppSPDExtTrayHiVoltageCu");
4380
4381   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4382            + 2*forwTrayWall->GetDY();
4383   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4384   xprof[1] = kExternalTrayLen;
4385   yprof[1] = yprof[0];
4386   xprof[2] = xprof[1];
4387   yprof[2] = yprof[1] + kHiVoltageCableSectCu/2;
4388   yprof[3] = yprof[2];
4389   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4390
4391   hiCablesExtCu->DefinePolygon(4, xprof, yprof);
4392   hiCablesExtCu->DefineSection(0, 0);
4393   hiCablesExtCu->DefineSection(1, kHiVoltageCableSectCu*2);
4394
4395   TGeoXtru *hiCablesExtPUR = new TGeoXtru(2);
4396   hiCablesExtPUR->SetName("ITSsuppSPDExtTrayHiVoltagePUR");
4397
4398   xprof[0] = hiCablesExtCu->GetX(3);
4399   yprof[0] = hiCablesExtCu->GetY(3);
4400   xprof[1] = hiCablesExtCu->GetX(2);
4401   yprof[1] = hiCablesExtCu->GetY(2);
4402   xprof[2] = xprof[1];
4403   yprof[2] = yprof[1] + kHiVoltageCableHighPUR/2;
4404   yprof[3] = yprof[2];
4405   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4406
4407   hiCablesExtPUR->DefinePolygon(4, xprof, yprof);
4408   hiCablesExtPUR->DefineSection(0, 0);
4409   hiCablesExtPUR->DefineSection(1, kHiVoltageCableSectCu*2);
4410
4411   // The Coaxial cables inside the forward tray: two Xtru
4412   TGeoXtru *coaxCablesForwCu = new TGeoXtru(2);
4413   coaxCablesForwCu->SetName("ITSsuppSPDForwTrayCoaxCu");
4414
4415   xprof[0] = -kTrayCCablesZLenOut;
4416   yprof[0] = xprof[0]/TanD(kTrayCCablesRot);
4417   xprof[1] = 0;
4418   yprof[1] = 0;
4419   xprof[2] = kForwardTrayTotalLen;
4420   yprof[2] = yprof[1];
4421   xprof[3] = xprof[2];
4422   yprof[3] = yprof[2] + kCoaxCableSectCu/2;
4423   xprof[4] = xprof[1];
4424   yprof[4] = yprof[3];
4425   xprof[5] = xprof[0];
4426   yprof[5] = yprof[0] + kCoaxCableSectCu/2;
4427
4428   coaxCablesForwCu->DefinePolygon(6, xprof, yprof);
4429   coaxCablesForwCu->DefineSection(0,-kCoaxCableSectCu);
4430   coaxCablesForwCu->DefineSection(1, kCoaxCableSectCu);
4431
4432   TGeoXtru *coaxCablesForwMeg = new TGeoXtru(2);
4433   coaxCablesForwMeg->SetName("ITSsuppSPDForwTrayCoaxMeg");
4434
4435   xprof[0] = coaxCablesForwCu->GetX(5);
4436   yprof[0] = coaxCablesForwCu->GetY(5);
4437   xprof[1] = coaxCablesForwCu->GetX(4);
4438   yprof[1] = coaxCablesForwCu->GetY(4);
4439   xprof[2] = coaxCablesForwCu->GetX(3);
4440   yprof[2] = coaxCablesForwCu->GetY(3);
4441   xprof[3] = xprof[2];
4442   yprof[3] = yprof[2] + kCoaxCableHighMeg/2;
4443   xprof[4] = xprof[1];
4444   yprof[4] = yprof[3];
4445   xprof[5] = xprof[0];
4446   yprof[5] = yprof[0] + kCoaxCableHighMeg/2;
4447
4448   coaxCablesForwMeg->DefinePolygon(6, xprof, yprof);
4449   coaxCablesForwMeg->DefineSection(0,-kCoaxCableSectCu);
4450   coaxCablesForwMeg->DefineSection(1, kCoaxCableSectCu);
4451
4452   // The Coaxial inside the external tray: two Xtru
4453   TGeoXtru *coaxCablesExtCu = new TGeoXtru(2);
4454   coaxCablesExtCu->SetName("ITSsuppSPDExtTrayCoaxCu");
4455
4456   yprof[0] = -kExternalTrayHigh + 2*kExternalTrayThick
4457            + 2*forwTrayWall->GetDY();
4458   xprof[0] = yprof[0]*TanD(kTrayAZRot);
4459   xprof[1] = kExternalTrayLen;
4460   yprof[1] = yprof[0];
4461   xprof[2] = xprof[1];
4462   yprof[2] = yprof[1] + kCoaxCableSectCu/2;
4463   yprof[3] = yprof[2];
4464   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4465
4466   coaxCablesExtCu->DefinePolygon(4, xprof, yprof);
4467   coaxCablesExtCu->DefineSection(0, 0);
4468   coaxCablesExtCu->DefineSection(1, kCoaxCableSectCu*2);
4469
4470   TGeoXtru *coaxCablesExtMeg = new TGeoXtru(2);
4471   coaxCablesExtMeg->SetName("ITSsuppSPDExtTrayCoaxMeg");
4472
4473   xprof[0] = coaxCablesExtCu->GetX(3);
4474   yprof[0] = coaxCablesExtCu->GetY(3);
4475   xprof[1] = coaxCablesExtCu->GetX(2);
4476   yprof[1] = coaxCablesExtCu->GetY(2);
4477   xprof[2] = xprof[1];
4478   yprof[2] = yprof[1] + kCoaxCableHighMeg/2;
4479   yprof[3] = yprof[2];
4480   xprof[3] = yprof[2]*TanD(kTrayAZRot);
4481
4482   coaxCablesExtMeg->DefinePolygon(4, xprof, yprof);
4483   coaxCablesExtMeg->DefineSection(0, 0);
4484   coaxCablesExtMeg->DefineSection(1, kCoaxCableSectCu*2);
4485
4486
4487   // We have all shapes: now create the real volumes
4488   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
4489   TGeoMedium *medIn    = mgr->GetMedium("ITS_INOX$");
4490   TGeoMedium *medFreon = mgr->GetMedium("ITS_GASEOUS FREON$");
4491   TGeoMedium *medFibs  = mgr->GetMedium("ITS_SDD OPTICFIB$");//!TO BE CHECKED!
4492   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
4493   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
4494   TGeoMedium *medMeg   = mgr->GetMedium("ITS_MEGOLON$");
4495
4496   TGeoVolume *forwTrayABase = new TGeoVolume("ITSsuppSPDSideAForwTrayABase",
4497                                             forwTrayLowerFace, medAl);
4498
4499   forwTrayABase->SetVisibility(kTRUE);
4500   forwTrayABase->SetLineColor(6); // Purple
4501   forwTrayABase->SetLineWidth(1);
4502   forwTrayABase->SetFillColor(forwTrayABase->GetLineColor());
4503   forwTrayABase->SetFillStyle(4000); // 0% transparent
4504
4505   TGeoVolume *forwTrayASide = new TGeoVolume("ITSsuppSPDSideAForwTrayASide",
4506                                             forwTraySideFace, medAl);
4507
4508   forwTrayASide->SetVisibility(kTRUE);
4509   forwTrayASide->SetLineColor(6); // Purple
4510   forwTrayASide->SetLineWidth(1);
4511   forwTrayASide->SetFillColor(forwTrayASide->GetLineColor());
4512   forwTrayASide->SetFillStyle(4000); // 0% transparent
4513
4514   TGeoVolume *forwTrayACoverShort = new TGeoVolume("ITSsuppSPDSideAForwTrayASC",
4515                                                   forwTrayShortCover, medAl);
4516
4517   forwTrayACoverShort->SetVisibility(kTRUE);
4518   forwTrayACoverShort->SetLineColor(6); // Purple
4519   forwTrayACoverShort->SetLineWidth(1);
4520   forwTrayACoverShort->SetFillColor(forwTrayACoverShort->GetLineColor());
4521   forwTrayACoverShort->SetFillStyle(4000); // 0% transparent
4522
4523   TGeoVolume *forwTrayACoverLong = new TGeoVolume("ITSsuppSPDSideAForwTrayALC",
4524                                                  forwTrayLongCover, medAl);
4525
4526   forwTrayACoverLong->SetVisibility(kTRUE);
4527   forwTrayACoverLong->SetLineColor(6); // Purple
4528   forwTrayACoverLong->SetLineWidth(1);
4529   forwTrayACoverLong->SetFillColor(forwTrayACoverLong->GetLineColor());
4530   forwTrayACoverLong->SetFillStyle(4000); // 0% transparent
4531
4532   TGeoVolume *forwTrayAWing = new TGeoVolume("ITSsuppSPDSideAForwTrayAWing",
4533                                              forwTrayWing, medAl);
4534
4535   forwTrayAWing->SetVisibility(kTRUE);
4536   forwTrayAWing->SetLineColor(6); // Purple
4537   forwTrayAWing->SetLineWidth(1);
4538   forwTrayAWing->SetFillColor(forwTrayAWing->GetLineColor());
4539   forwTrayAWing->SetFillStyle(4000); // 0% transparent
4540
4541   TGeoVolume *forwTrayAPlane = new TGeoVolume("ITSsuppSPDSideAForwTrayAPlane",
4542                                               forwTrayPlane, medAl);
4543
4544   forwTrayAPlane->SetVisibility(kTRUE);
4545   forwTrayAPlane->SetLineColor(6); // Purple
4546   forwTrayAPlane->SetLineWidth(1);
4547   forwTrayAPlane->SetFillColor(forwTrayAPlane->GetLineColor());
4548   forwTrayAPlane->SetFillStyle(4000); // 0% transparent
4549
4550   TGeoVolume *forwTrayAWall = new TGeoVolume("ITSsuppSPDSideAForwTrayAWall",
4551                                              forwTrayWall, medAl);
4552
4553   forwTrayAWall->SetVisibility(kTRUE);
4554   forwTrayAWall->SetLineColor(6); // Purple
4555   forwTrayAWall->SetLineWidth(1);
4556   forwTrayAWall->SetFillColor(forwTrayAWall->GetLineColor());
4557   forwTrayAWall->SetFillStyle(4000); // 0% transparent
4558
4559   TGeoVolume *extTrayAHorFace = new TGeoVolume("ITSsuppSPDSideAExtTrayHorFace",
4560                                                extTrayHorFace, medAl);
4561
4562   extTrayAHorFace->SetVisibility(kTRUE);
4563   extTrayAHorFace->SetLineColor(6); // Purple
4564   extTrayAHorFace->SetLineWidth(1);
4565   extTrayAHorFace->SetFillColor(extTrayAHorFace->GetLineColor());
4566   extTrayAHorFace->SetFillStyle(4000); // 0% transparent
4567
4568   TGeoVolume *extTrayAVerFace = new TGeoVolume("ITSsuppSPDSideAExtTrayVerFace",
4569                                                extTrayVerFace, medAl);
4570
4571   extTrayAVerFace->SetVisibility(kTRUE);
4572   extTrayAVerFace->SetLineColor(6); // Purple
4573   extTrayAVerFace->SetLineWidth(1);
4574   extTrayAVerFace->SetFillColor(extTrayAVerFace->GetLineColor());
4575   extTrayAVerFace->SetFillStyle(4000); // 0% transparent
4576
4577   TGeoVolume *extTrayAWall = new TGeoVolume("ITSsuppSPDSideAExtTrayWall",
4578                                             extTrayWall, medAl);
4579
4580   extTrayAWall->SetVisibility(kTRUE);
4581   extTrayAWall->SetLineColor(6); // Purple
4582   extTrayAWall->SetLineWidth(1);
4583   extTrayAWall->SetFillColor(extTrayAWall->GetLineColor());
4584   extTrayAWall->SetFillStyle(4000); // 0% transparent
4585
4586   TGeoVolume *forwCoolTube = new TGeoVolume("ITSsuppSPDSideAForwTrayCoolTube",
4587                                             coolTubeForw, medIn);
4588
4589   forwCoolTube->SetVisibility(kTRUE);
4590   forwCoolTube->SetLineColor(kGray); // as in GeometrySPD
4591   forwCoolTube->SetLineWidth(1);
4592   forwCoolTube->SetFillColor(forwCoolTube->GetLineColor());
4593   forwCoolTube->SetFillStyle(4000); // 0% transparent
4594
4595   TGeoVolume *forwCoolFreon = new TGeoVolume("ITSsuppSPDSideAForwTrayFreon",
4596                                              freonTubeForw, medFreon);
4597
4598   forwCoolFreon->SetVisibility(kTRUE);
4599   forwCoolFreon->SetLineColor(kBlue); // Blue
4600   forwCoolFreon->SetLineWidth(1);
4601   forwCoolFreon->SetFillColor(forwCoolFreon->GetLineColor());
4602   forwCoolFreon->SetFillStyle(4000); // 0% transparent
4603
4604   TGeoVolume *extCoolTube = new TGeoVolume("ITSsuppSPDSideAExtTrayCoolTube",
4605                                            coolTubeExt, medIn);
4606
4607   extCoolTube->SetVisibility(kTRUE);
4608   extCoolTube->SetLineColor(kGray); // as in GeometrySPD
4609   extCoolTube->SetLineWidth(1);
4610   extCoolTube->SetFillColor(extCoolTube->GetLineColor());
4611   extCoolTube->SetFillStyle(4000); // 0% transparent
4612
4613   TGeoVolume *extCoolFreon = new TGeoVolume("ITSsuppSPDSideAExtTrayFreon",
4614                                             freonTubeExt, medFreon);
4615
4616   extCoolFreon->SetVisibility(kTRUE);
4617   extCoolFreon->SetLineColor(kBlue); // Blue
4618   extCoolFreon->SetLineWidth(1);
4619   extCoolFreon->SetFillColor(extCoolFreon->GetLineColor());
4620   extCoolFreon->SetFillStyle(4000); // 0% transparent
4621
4622   TGeoVolume *forwOptFibs = new TGeoVolume("ITSsuppSPDSideAForwTrayOptFibs",
4623                                            optFibsForw, medFibs);
4624
4625   forwOptFibs->SetVisibility(kTRUE);
4626   forwOptFibs->SetLineColor(kOrange); // Orange
4627   forwOptFibs->SetLineWidth(1);
4628   forwOptFibs->SetFillColor(forwOptFibs->GetLineColor());
4629   forwOptFibs->SetFillStyle(4000); // 0% transparent
4630
4631   TGeoVolume *extOptFibs = new TGeoVolume("ITSsuppSPDSideAExtTrayOptFibs",
4632                                           optFibsExt, medFibs);
4633
4634   extOptFibs->SetVisibility(kTRUE);
4635   extOptFibs->SetLineColor(kOrange); // Orange
4636   extOptFibs->SetLineWidth(1);
4637   extOptFibs->SetFillColor(extOptFibs->GetLineColor());
4638   extOptFibs->SetFillStyle(4000); // 0% transparent
4639
4640   TGeoVolume *forwLowCabsCu = new TGeoVolume("ITSsuppSPDSideAForwLowCabsCu",
4641                                              lowCablesForwCu, medCu);
4642
4643   forwLowCabsCu->SetVisibility(kTRUE);
4644   forwLowCabsCu->SetLineColor(kRed); // Red
4645   forwLowCabsCu->SetLineWidth(1);
4646   forwLowCabsCu->SetFillColor(forwLowCabsCu->GetLineColor());
4647   forwLowCabsCu->SetFillStyle(4000); // 0% transparent
4648
4649   TGeoVolume *forwLowCabsPUR = new TGeoVolume("ITSsuppSPDSideAForwLowCabsPUR",
4650                                               lowCablesForwPUR, medPUR);
4651
4652   forwLowCabsPUR->SetVisibility(kTRUE);
4653   forwLowCabsPUR->SetLineColor(kBlack); // Black
4654   forwLowCabsPUR->SetLineWidth(1);
4655   forwLowCabsPUR->SetFillColor(forwLowCabsPUR->GetLineColor());
4656   forwLowCabsPUR->SetFillStyle(4000); // 0% transparent
4657
4658   TGeoVolume *extLowCabsCu = new TGeoVolume("ITSsuppSPDSideAExtLowCabsCu",
4659                                             lowCablesExtCu, medCu);
4660
4661   extLowCabsCu->SetVisibility(kTRUE);
4662   extLowCabsCu->SetLineColor(kRed); // Red
4663   extLowCabsCu->SetLineWidth(1);
4664   extLowCabsCu->SetFillColor(extLowCabsCu->GetLineColor());
4665   extLowCabsCu->SetFillStyle(4000); // 0% transparent
4666
4667   TGeoVolume *extLowCabsPUR = new TGeoVolume("ITSsuppSPDSideAExtLowCabsPUR",
4668                                              lowCablesExtPUR, medPUR);
4669
4670   extLowCabsPUR->SetVisibility(kTRUE);
4671   extLowCabsPUR->SetLineColor(kBlack); // Black
4672   extLowCabsPUR->SetLineWidth(1);
4673   extLowCabsPUR->SetFillColor(extLowCabsPUR->GetLineColor());
4674   extLowCabsPUR->SetFillStyle(4000); // 0% transparent
4675
4676   TGeoVolume *forwHiCabsCu = new TGeoVolume("ITSsuppSPDSideAForwTrayHiCabsCu",
4677                                             hiCablesForwCu, medCu);
4678
4679   forwHiCabsCu->SetVisibility(kTRUE);
4680   forwHiCabsCu->SetLineColor(kRed); // Red
4681   forwHiCabsCu->SetLineWidth(1);
4682   forwHiCabsCu->SetFillColor(forwHiCabsCu->GetLineColor());
4683   forwHiCabsCu->SetFillStyle(4000); // 0% transparent
4684
4685   TGeoVolume *forwHiCabsPUR = new TGeoVolume("ITSsuppSPDSideAForwTrayHiCabsPUR",
4686                                              hiCablesForwPUR, medPUR);
4687
4688   forwHiCabsPUR->SetVisibility(kTRUE);
4689   forwHiCabsPUR->SetLineColor(kBlack); // Black
4690   forwHiCabsPUR->SetLineWidth(1);
4691   forwHiCabsPUR->SetFillColor(forwHiCabsPUR->GetLineColor());
4692   forwHiCabsPUR->SetFillStyle(4000); // 0% transparent
4693
4694   TGeoVolume *extHiCabsCu = new TGeoVolume("ITSsuppSPDSideAExtTrayHiCabsCu",
4695                                            hiCablesExtCu, medCu);
4696
4697   extHiCabsCu->SetVisibility(kTRUE);
4698   extHiCabsCu->SetLineColor(kRed); // Red
4699   extHiCabsCu->SetLineWidth(1);
4700   extHiCabsCu->SetFillColor(extHiCabsCu->GetLineColor());
4701   extHiCabsCu->SetFillStyle(4000); // 0% transparent
4702
4703   TGeoVolume *extHiCabsPUR = new TGeoVolume("ITSsuppSPDSideAExtTrayHiCabsPUR",
4704                                             hiCablesExtPUR, medPUR);
4705
4706   extHiCabsPUR->SetVisibility(kTRUE);
4707   extHiCabsPUR->SetLineColor(kBlack); // Black
4708   extHiCabsPUR->SetLineWidth(1);
4709   extHiCabsPUR->SetFillColor(extHiCabsPUR->GetLineColor());
4710   extHiCabsPUR->SetFillStyle(4000); // 0% transparent
4711
4712   TGeoVolume *forwCoaxCu = new TGeoVolume("ITSsuppSPDSideAForwTrayCoaxCu",
4713                                           coaxCablesForwCu, medCu);
4714
4715   forwCoaxCu->SetVisibility(kTRUE);
4716   forwCoaxCu->SetLineColor(kRed); // Red
4717   forwCoaxCu->SetLineWidth(1);
4718   forwCoaxCu->SetFillColor(forwCoaxCu->GetLineColor());
4719   forwCoaxCu->SetFillStyle(4000); // 0% transparent
4720
4721   TGeoVolume *forwCoaxMeg = new TGeoVolume("ITSsuppSPDSideAForwTrayCoaxMeg",
4722                                            coaxCablesForwMeg, medMeg);
4723
4724   forwCoaxMeg->SetVisibility(kTRUE);
4725   forwCoaxMeg->SetLineColor(kBlack); // Black
4726   forwCoaxMeg->SetLineWidth(1);
4727   forwCoaxMeg->SetFillColor(forwCoaxMeg->GetLineColor());
4728   forwCoaxMeg->SetFillStyle(4000); // 0% transparent
4729
4730   TGeoVolume *extCoaxCu = new TGeoVolume("ITSsuppSPDSideAExtTrayCoaxCu",
4731                                          coaxCablesExtCu, medCu);
4732
4733   extCoaxCu->SetVisibility(kTRUE);
4734   extCoaxCu->SetLineColor(kRed); // Red
4735   extCoaxCu->SetLineWidth(1);
4736   extCoaxCu->SetFillColor(extCoaxCu->GetLineColor());
4737   extCoaxCu->SetFillStyle(4000); // 0% transparent
4738
4739   TGeoVolume *extCoaxMeg = new TGeoVolume("ITSsuppSPDSideAExtTrayCoaxMeg",
4740                                           coaxCablesExtMeg, medMeg);
4741
4742   extCoaxMeg->SetVisibility(kTRUE);
4743   extCoaxMeg->SetLineColor(kBlack); // Black
4744   extCoaxMeg->SetLineWidth(1);
4745   extCoaxMeg->SetFillColor(extCoaxMeg->GetLineColor());
4746   extCoaxMeg->SetFillStyle(4000); // 0% transparent
4747
4748
4749   // Now build up the trays
4750   yloc = forwTrayLowerFace->GetDY();
4751   zloc = forwTrayLowerFace->GetDZ();
4752   cableTrayAForw->AddNode(forwTrayABase, 1,
4753                       new TGeoTranslation(0, yloc, zloc));
4754
4755   xloc = kForwardTrayWide/2;
4756   cableTrayAForw->AddNode(forwTrayASide, 1,
4757                       new TGeoCombiTrans( xloc, 0, 0,
4758                                          new TGeoRotation("",90,-90,-90)));
4759   cableTrayAForw->AddNode(forwTrayASide, 2,
4760                       new TGeoCombiTrans(-xloc+kForwardTrayThick, 0, 0,
4761                                          new TGeoRotation("",90,-90,-90)));
4762
4763   yloc = kForwardTrayFirstHigh - forwTrayShortCover->GetDY();
4764   zloc = forwTrayShortCover->GetDZ();
4765   cableTrayAForw->AddNode(forwTrayACoverShort, 1,
4766                       new TGeoTranslation(0, yloc, zloc));
4767
4768   yloc = kForwardTraySecondHigh - forwTrayLongCover->GetDY();
4769   zloc = kForwardTrayFirstLen + forwTrayLongCover->GetDZ();
4770   cableTrayAForw->AddNode(forwTrayACoverLong, 1,
4771                       new TGeoTranslation(0, yloc, zloc));
4772
4773   xloc = kForwardTrayWide/2 - kForwardTrayThick - forwTrayWing->GetDX();
4774   yloc = kForwardTrayFirstHigh - kForwardTrayThick - forwTrayWing->GetDY();
4775   zloc = kForwardTrayFirstLen - forwTrayWing->GetDZ();
4776   cableTrayAForw->AddNode(forwTrayAWing, 1,
4777                       new TGeoTranslation( xloc, yloc, zloc));
4778   cableTrayAForw->AddNode(forwTrayAWing, 2,
4779                       new TGeoTranslation(-xloc, yloc, zloc));
4780
4781   yloc = kForwardTrayThick + kForwardTrayInterSpace - forwTrayPlane->GetDY();
4782   zloc = forwTrayPlane->GetDZ();
4783   cableTrayAForw->AddNode(forwTrayAPlane, 1,
4784                       new TGeoTranslation(0, yloc, zloc));
4785
4786   yloc = kForwardTrayThick + forwTrayWall->GetDY();
4787   zloc = forwTrayWall->GetDZ();
4788   cableTrayAForw->AddNode(forwTrayAWall, 1,
4789                       new TGeoTranslation(0, yloc, zloc));
4790
4791   forwCoolTube->AddNode(forwCoolFreon, 1, 0);
4792
4793   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY()
4794        + coolTubeForw->GetRmax();
4795   zloc = coolTubeForw->GetDz();
4796   cableTrayAForw->AddNode(forwCoolTube, 1,
4797                       new TGeoTranslation(0, yloc, zloc));
4798
4799   xloc = optFibsForw->GetZ(1) + coolTubeForw->GetRmax();
4800   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4801   cableTrayAForw->AddNode(forwOptFibs, 1,
4802                       new TGeoCombiTrans( xloc, yloc, 0,
4803                                          new TGeoRotation("",-90.,90.,90.)));
4804
4805   xloc = lowCablesForwCu->GetZ(1) + coolTubeForw->GetRmax();
4806   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4807   cableTrayAForw->AddNode(forwLowCabsCu, 1,
4808                       new TGeoCombiTrans(-xloc, yloc, 0,
4809                                          new TGeoRotation("",-90.,90.,90.)));
4810   cableTrayAForw->AddNode(forwLowCabsPUR, 1,
4811                       new TGeoCombiTrans(-xloc, yloc, 0,
4812                                          new TGeoRotation("",-90.,90.,90.)));
4813
4814   xloc = 2*lowCablesForwCu->GetZ(1) +
4815          hiCablesForwCu->GetZ(1) + coolTubeForw->GetRmax();
4816   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4817   cableTrayAForw->AddNode(forwHiCabsCu, 1,
4818                       new TGeoCombiTrans(-xloc, yloc, 0,
4819                                          new TGeoRotation("",-90.,90.,90.)));
4820   cableTrayAForw->AddNode(forwHiCabsPUR, 1,
4821                       new TGeoCombiTrans(-xloc, yloc, 0,
4822                                          new TGeoRotation("",-90.,90.,90.)));
4823
4824   xloc = 2*optFibsForw->GetZ(1) + coaxCablesForwCu->GetZ(1) +
4825          coolTubeForw->GetRmax();
4826   yloc = 2*kForwardTrayThick + 2*forwTrayWall->GetDY();
4827   cableTrayAForw->AddNode(forwCoaxCu, 1,
4828                       new TGeoCombiTrans( xloc, yloc, 0,
4829                                          new TGeoRotation("",-90.,90.,90.)));
4830   cableTrayAForw->AddNode(forwCoaxMeg, 1,
4831                       new TGeoCombiTrans( xloc, yloc, 0,
4832                                          new TGeoRotation("",-90.,90.,90.)));
4833
4834   // To simplify following placement in MARS, origin is on top
4835   yloc = -kExternalTrayHigh + kExternalTrayThick/2;
4836   zloc = kExternalTrayLen/2;
4837   cableTrayAExt->AddNode(extTrayAHorFace, 1,
4838                       new TGeoTranslation( 0, yloc, zloc));
4839
4840   xloc = kExternalTrayWide/2 - kExternalTrayThick/2;
4841   yloc = -kExternalTrayHigh/2;
4842   cableTrayAExt->AddNode(extTrayAVerFace, 1,
4843                       new TGeoTranslation( xloc, yloc, zloc));
4844   cableTrayAExt->AddNode(extTrayAVerFace, 2,
4845                       new TGeoTranslation(-xloc, yloc, zloc));
4846
4847   yloc = -kExternalTrayThick/2;
4848   cableTrayAExt->AddNode(extTrayAHorFace, 2,
4849                       new TGeoTranslation( 0, yloc, zloc));
4850
4851   yloc = -kExternalTrayHigh
4852        + kExternalTrayThick + kForwardTrayInterSpace - kExternalTrayThick/2;
4853   cableTrayAExt->AddNode(extTrayAHorFace, 3,
4854                       new TGeoTranslation( 0, yloc, zloc));
4855
4856   yloc = -kExternalTrayHigh + kExternalTrayThick + extTrayWall->GetDY();
4857   cableTrayAExt->AddNode(extTrayAWall, 1,
4858                       new TGeoTranslation( 0, yloc, zloc));
4859
4860   extCoolTube->AddNode(extCoolFreon, 1, 0);
4861
4862   yloc = -kExternalTrayHigh + 2*kExternalTrayThick + 2*extTrayWall->GetDY()
4863        + coolTubeExt->GetRmax();
4864   zloc = coolTubeExt->GetDz();
4865   cableTrayAExt->AddNode(extCoolTube, 1,
4866                       new TGeoTranslation(0, yloc, zloc));
4867
4868   xloc = optFibsExt->GetZ(1) + coolTubeExt->GetRmax();
4869   cableTrayAExt->AddNode(extOptFibs, 1,
4870                       new TGeoCombiTrans( xloc, 0, 0,
4871                                          new TGeoRotation("",90,-90,-90)));
4872
4873   xloc = coolTubeExt->GetRmax();
4874   cableTrayAExt->AddNode(extLowCabsCu, 1,
4875                       new TGeoCombiTrans(-xloc, 0, 0,
4876                                          new TGeoRotation("",90,-90,-90)));
4877   cableTrayAExt->AddNode(extLowCabsPUR, 1,
4878                       new TGeoCombiTrans(-xloc, 0, 0,
4879                                          new TGeoRotation("",90,-90,-90)));
4880
4881   xloc = lowCablesExtCu->GetZ(1) + coolTubeExt->GetRmax();
4882   cableTrayAExt->AddNode(extHiCabsCu, 1,
4883                       new TGeoCombiTrans(-xloc, 0, 0,
4884                                          new TGeoRotation("",90,-90,-90)));
4885   cableTrayAExt->AddNode(extHiCabsPUR, 1,
4886                       new TGeoCombiTrans(-xloc, 0, 0,
4887                                          new TGeoRotation("",90,-90,-90)));
4888
4889   xloc = coaxCablesExtCu->GetZ(1) + optFibsExt->GetZ(1) +
4890          coolTubeExt->GetRmax();
4891   cableTrayAExt->AddNode(extCoaxCu, 1,
4892                       new TGeoCombiTrans( xloc, 0, 0,
4893                                          new TGeoRotation("",90,-90,-90)));
4894   cableTrayAExt->AddNode(extCoaxMeg, 1,
4895                       new TGeoCombiTrans( xloc, 0, 0,
4896                                          new TGeoRotation("",90,-90,-90)));
4897
4898
4899   // Finally put everything in the mother volume
4900   Double_t rExtTray = kTrayAR2Trans + kExternalTrayHigh;
4901
4902   moth->AddNode(cableTrayAForw,1,
4903                 new TGeoTranslation( 0, kTrayAR1Trans, kTrayAZTrans));
4904   moth->AddNode(cableTrayAForw,2,
4905                 new TGeoCombiTrans(  0,-kTrayAR1Trans, kTrayAZTrans,
4906                                     new TGeoRotation("",180, 0, 0)));
4907
4908   yloc = kTrayAR1Trans + kExternalTrayHigh;
4909   zloc = kTrayAZTrans + kForwardTrayTotalLen;
4910   moth->AddNode(cableTrayAExt,1,
4911                 new TGeoCombiTrans( 0, yloc, zloc,
4912                                     new TGeoRotation("",  0,-kTrayAZRot, 0)));
4913   moth->AddNode(cableTrayAExt,2,
4914                 new TGeoCombiTrans( 0,-yloc, zloc,
4915                                     new TGeoRotation("",180,-kTrayAZRot, 0)));
4916
4917   alpharot = kTrayAFirstRotAng + kTrayASecondRotAng;
4918   xloc = kTrayAR2Trans*SinD(alpharot);
4919   yloc = kTrayAR2Trans*CosD(alpharot);
4920   moth->AddNode(cableTrayAForw,3,
4921                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4922                             new TGeoRotation("",-alpharot,0,0)   )   );
4923   xloc = rExtTray*SinD(alpharot);
4924   yloc = rExtTray*CosD(alpharot);
4925   moth->AddNode(cableTrayAExt,3,
4926                             new TGeoCombiTrans( xloc, yloc, zloc,
4927                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4928
4929   alpharot += 180;
4930   xloc = kTrayAR2Trans*SinD(alpharot);
4931   yloc = kTrayAR2Trans*CosD(alpharot);
4932   moth->AddNode(cableTrayAForw,4,
4933                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4934                             new TGeoRotation("",-alpharot,0,0)   )   );
4935   xloc = rExtTray*SinD(alpharot);
4936   yloc = rExtTray*CosD(alpharot);
4937   moth->AddNode(cableTrayAExt,4,
4938                             new TGeoCombiTrans( xloc, yloc, zloc,
4939                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4940
4941   alpharot = - kTrayAFirstRotAng - kTrayASecondRotAng;
4942   xloc = kTrayAR2Trans*SinD(alpharot);
4943   yloc = kTrayAR2Trans*CosD(alpharot);
4944   moth->AddNode(cableTrayAForw,5,
4945                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4946                             new TGeoRotation("",-alpharot,0,0)   )   );
4947   xloc = rExtTray*SinD(alpharot);
4948   yloc = rExtTray*CosD(alpharot);
4949   moth->AddNode(cableTrayAExt,5,
4950                             new TGeoCombiTrans( xloc, yloc, zloc,
4951                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4952
4953   alpharot += 180;
4954   xloc = kTrayAR2Trans*SinD(alpharot);
4955   yloc = kTrayAR2Trans*CosD(alpharot);
4956   moth->AddNode(cableTrayAForw,6,
4957                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4958                             new TGeoRotation("",-alpharot,0,0)   )   );
4959   xloc = rExtTray*SinD(alpharot);
4960   yloc = rExtTray*CosD(alpharot);
4961   moth->AddNode(cableTrayAExt,6,
4962                             new TGeoCombiTrans( xloc, yloc, zloc,
4963                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4964
4965   alpharot = kTrayAFirstRotAng + 3*kTrayASecondRotAng;
4966   xloc = kTrayAR2Trans*SinD(alpharot);
4967   yloc = kTrayAR2Trans*CosD(alpharot);
4968   moth->AddNode(cableTrayAForw,7,
4969                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4970                             new TGeoRotation("",-alpharot,0,0)   )   );
4971   xloc = rExtTray*SinD(alpharot);
4972   yloc = rExtTray*CosD(alpharot);
4973   moth->AddNode(cableTrayAExt,7,
4974                             new TGeoCombiTrans( xloc, yloc, zloc,
4975                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4976
4977   alpharot += 180;
4978   xloc = kTrayAR2Trans*SinD(alpharot);
4979   yloc = kTrayAR2Trans*CosD(alpharot);
4980   moth->AddNode(cableTrayAForw,8,
4981                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4982                             new TGeoRotation("",-alpharot,0,0)   )   );
4983   xloc = rExtTray*SinD(alpharot);
4984   yloc = rExtTray*CosD(alpharot);
4985   moth->AddNode(cableTrayAExt,8,
4986                             new TGeoCombiTrans( xloc, yloc, zloc,
4987                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
4988
4989   alpharot = - kTrayAFirstRotAng - 3*kTrayASecondRotAng;
4990   xloc = kTrayAR2Trans*SinD(alpharot);
4991   yloc = kTrayAR2Trans*CosD(alpharot);
4992   moth->AddNode(cableTrayAForw,9,
4993                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
4994                             new TGeoRotation("",-alpharot,0,0)   )   );
4995   xloc = rExtTray*SinD(alpharot);
4996   yloc = rExtTray*CosD(alpharot);
4997   moth->AddNode(cableTrayAExt,9,
4998                             new TGeoCombiTrans( xloc, yloc, zloc,
4999                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
5000
5001   alpharot += 180;
5002   xloc = kTrayAR2Trans*SinD(alpharot);
5003   yloc = kTrayAR2Trans*CosD(alpharot);
5004   moth->AddNode(cableTrayAForw,10,
5005                             new TGeoCombiTrans( xloc, yloc, kTrayAZTrans,
5006                             new TGeoRotation("",-alpharot,0,0)   )   );
5007   xloc = rExtTray*SinD(alpharot);
5008   yloc = rExtTray*CosD(alpharot);
5009   moth->AddNode(cableTrayAExt,10,
5010                             new TGeoCombiTrans( xloc, yloc, zloc,
5011                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
5012
5013
5014   return;
5015 }
5016
5017 //______________________________________________________________________
5018 void AliITSv11GeometrySupport::SPDCableTraysSideC(TGeoVolume *moth,
5019                                             const TGeoManager *mgr){
5020 //
5021 // Creates the SPD cable trays which are outside the ITS support cones
5022 // but still inside the TPC on Side C
5023 // (part of this code is taken or anyway inspired to ServicesCableSupport
5024 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
5025 //
5026 // Input:
5027 //         moth : the TGeoVolume owing the volume structure
5028 //         mgr  : the GeoManager (default gGeoManager)
5029 // Output:
5030 //
5031 // Return:
5032 //
5033 // Created:         ???       Bjorn S. Nilsen
5034 // Updated:      22 Apr 2010  Mario Sitta
5035 // Updated:      10 Jun 2010  Mario Sitta  Freon inside cooling pipes
5036 // Updated:      08 Sep 2010  Mario Sitta
5037 // Updated:      14 Sep 2010  Mario Sitta  Cables prolonged till cone
5038 // Updated:      20 Dec 2011  Mario Sitta  Composite vol to avoid new overlap
5039 //
5040 // Technical data are taken from AutoCAD drawings and other (oral)
5041 // information given by D.Elia
5042 // Optical fibers and voltage cables are approximated with mean materials
5043 // and square cross sections, but preserving the total material budget.
5044 //
5045
5046   // Dimensions and positions of the C-Side Cable Tray elements
5047   const Int_t    kNumTraysSideC       =   10;
5048
5049   const Double_t kTrayCCablesOutRot   =   75.000 *fgkDegree;// Computed
5050   const Double_t kTrayCCablesZLenOut  =  245.000 *fgkmm;// Computed
5051
5052   const Double_t kTrayCHalfWide       =    6.350 *fgkcm;
5053   const Double_t kTrayCLength1        =  172.800 *fgkcm;
5054   const Double_t kTrayCLength2        =  189.300 *fgkcm;
5055   const Double_t kTrayCFirstLen       =  435.000 *fgkmm;
5056   const Double_t kTrayCFirstHigh      =   83.000 *fgkmm;//!!!TO BE CHECKED!!!
5057   const Double_t kTrayCSecondHigh     =   52.700 *fgkmm;//!!!TO BE CHECKED!!!
5058   const Double_t kTrayCThick          =    0.200 *fgkcm;
5059   const Double_t kTrayCInterSpace     =   18.000 *fgkmm;//!!!TO BE CHECKED!!!
5060   const Double_t kTrayCFoldAngle      =    5.000 *fgkDegree;
5061
5062   const Double_t kCoolingTubeRmin     =    2.000 *fgkmm;
5063   const Double_t kCoolingTubeRmax     =    3.000 *fgkmm;
5064   const Double_t kOpticalFibersSect   =    8.696 *fgkmm;//!!!ESTIMATED!!!
5065   const Double_t kLowVoltCableSectCu  =    7.675 *fgkmm;// Computed
5066   const Double_t kLowVoltCableHighPUR =    1.000 *fgkmm;// Computed
5067   const Double_t kHiVoltCableSectCu   =    1.535 *fgkmm;// Computed
5068   const Double_t kHiVoltCableHighPUR  =    0.500 *fgkmm;// Computed
5069   const Double_t kCoaxCableSectCu     =    6.024 *fgkmm;// Computed
5070   const Double_t kCoaxCableHighMeg    =    5.695 *fgkmm;// Computed
5071
5072   const Double_t kCablesYtrans        =    2.500 *fgkmm;// Avoid ovlps
5073
5074   // Overall position and rotation of the C-Side Cable Trays
5075   const Double_t kTraySideCRPos       =   45.300 *fgkcm;
5076   const Double_t kTraySideCZPos       = -102.400 *fgkcm;
5077   const Double_t kTraySideCAlphaRot[kNumTraysSideC/2]  =
5078     {    0.0,      41.0,     -41.0,      76.0,      -76.0};
5079   // From position of the other trays
5080
5081
5082   // Local variables
5083   Double_t xprof[8], yprof[8];
5084   Double_t xloc, yloc, zloc, delta, alpharot;
5085
5086
5087   // The single C-Side Cable tray as an assembly
5088   TGeoVolumeAssembly *cableTrayC = new TGeoVolumeAssembly("ITSsupportSPDTrayC");
5089
5090   // First create all needed shapes
5091
5092   // The Cable Tray lower face: a Xtru
5093   TGeoXtru *sideCHorFace = new TGeoXtru(2);
5094   sideCHorFace->SetName("ITSsuppSPDTraySideCHor");
5095
5096   xprof[0] = 0.;
5097   yprof[0] = 0.;
5098   xprof[1] = kTrayCLength1;
5099   yprof[1] = 0.;
5100   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
5101   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
5102   xprof[3] = xprof[2] - kTrayCThick*SinD(kTrayCFoldAngle);
5103   yprof[3] = yprof[2] + kTrayCThick*CosD(kTrayCFoldAngle);
5104   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5105               kTrayCThick , xprof[4], yprof[4]);
5106   xprof[5] = 0.;
5107   yprof[5] = kTrayCThick;
5108
5109   delta = kTrayCHalfWide - kTrayCThick;
5110
5111   sideCHorFace->DefinePolygon(6, xprof, yprof);
5112   sideCHorFace->DefineSection(0,-delta);
5113   sideCHorFace->DefineSection(1, delta);
5114
5115   // The Cable Tray middle face: a Xtru
5116   // (somehow duplicate of HorFace, but in this way avoid an overlap with Wall)
5117   TGeoXtru *sideCMidFace = new TGeoXtru(2);
5118
5119   xprof[0] = 0.;
5120   yprof[0] = kTrayCInterSpace + kTrayCThick;
5121   xprof[1] = kTrayCLength1;
5122   yprof[1] = yprof[0];
5123   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
5124   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
5125   xprof[3] = xprof[2] - kTrayCThick*SinD(kTrayCFoldAngle);
5126   yprof[3] = yprof[2] + kTrayCThick*CosD(kTrayCFoldAngle);
5127   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5128               kTrayCThick , xprof[4], yprof[4]);
5129   xprof[5] = 0.;
5130   yprof[5] = yprof[0] + kTrayCThick;
5131
5132   delta = kTrayCHalfWide - kTrayCThick;
5133
5134   sideCMidFace->DefinePolygon(6, xprof, yprof);
5135   sideCMidFace->DefineSection(0,-delta);
5136   sideCMidFace->DefineSection(1, delta);
5137
5138   // The Cable Tray lower face: a Xtru
5139   TGeoXtru *sideCSideFace = new TGeoXtru(2);
5140
5141   xprof[0] = 0.;
5142   yprof[0] = 0.;
5143   xprof[1] = kTrayCLength1;
5144   yprof[1] = 0.;
5145   xprof[2] = xprof[1] + kTrayCLength2*CosD(kTrayCFoldAngle);
5146   yprof[2] = yprof[1] + kTrayCLength2*SinD(kTrayCFoldAngle);
5147   xprof[3] = xprof[2] - kTrayCSecondHigh*SinD(kTrayCFoldAngle);
5148   yprof[3] = yprof[2] + kTrayCSecondHigh*CosD(kTrayCFoldAngle);
5149   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5150               kTrayCSecondHigh , xprof[4], yprof[4]);
5151   xprof[5] = kTrayCFirstLen;
5152   yprof[5] = kTrayCSecondHigh;
5153   xprof[6] = xprof[5];
5154   yprof[6] = kTrayCFirstHigh;
5155   xprof[7] = xprof[0];
5156   yprof[7] = yprof[6];
5157
5158   sideCSideFace->DefinePolygon(8, xprof, yprof);
5159   sideCSideFace->DefineSection(0, 0);
5160   sideCSideFace->DefineSection(1, kTrayCThick);
5161
5162   // The short cover: a BBox
5163   TGeoBBox *sideCShortCover = new TGeoBBox(kTrayCFirstLen/2,
5164                                            kTrayCThick/2,
5165                                            kTrayCHalfWide-kTrayCThick);
5166
5167   // The long cover: a Xtru
5168   TGeoXtru *sideCLongCover = new TGeoXtru(2);
5169
5170   xprof[5] = sideCSideFace->GetX(5);
5171   yprof[5] = sideCSideFace->GetY(5);
5172   xprof[4] = sideCSideFace->GetX(4);
5173   yprof[4] = sideCSideFace->GetY(4);
5174   xprof[3] = sideCSideFace->GetX(3);
5175   yprof[3] = sideCSideFace->GetY(3);
5176   xprof[2] = xprof[3] + kTrayCThick*SinD(kTrayCFoldAngle);
5177   yprof[2] = yprof[3] - kTrayCThick*CosD(kTrayCFoldAngle);
5178   InsidePoint(xprof[5], yprof[5], xprof[4], yprof[4], xprof[3], yprof[3],
5179              -kTrayCThick , xprof[1], yprof[1]);
5180   xprof[0] = xprof[5];
5181   yprof[0] = yprof[5] - kTrayCThick;
5182
5183   delta = kTrayCHalfWide - kTrayCThick;
5184
5185   sideCLongCover->DefinePolygon(6, xprof, yprof);
5186   sideCLongCover->DefineSection(0,-delta);
5187   sideCLongCover->DefineSection(1, delta);
5188
5189   // The internal wall: a Xtru
5190   TGeoXtru *intWall = new TGeoXtru(2);
5191   intWall->SetName("ITSsuppSPDTraySideCWall");
5192
5193   xprof[0] = sideCHorFace->GetX(5);
5194   yprof[0] = sideCHorFace->GetY(5);
5195   xprof[1] = sideCHorFace->GetX(4);
5196   yprof[1] = sideCHorFace->GetY(4);
5197   xprof[2] = sideCHorFace->GetX(3);
5198   yprof[2] = sideCHorFace->GetY(3);
5199   xprof[3] = sideCMidFace->GetX(2);
5200   yprof[3] = sideCMidFace->GetY(2);
5201   xprof[4] = sideCMidFace->GetX(1);
5202   yprof[4] = sideCMidFace->GetY(1);
5203   xprof[5] = sideCMidFace->GetX(0);
5204   yprof[5] = sideCMidFace->GetY(0);
5205
5206   intWall->DefinePolygon(6, xprof, yprof);
5207   intWall->DefineSection(0,-kTrayCThick/2);
5208   intWall->DefineSection(1, kTrayCThick/2);
5209
5210   // The horizontal part of the cooling tube inside the tray: a Tube
5211   delta = sideCMidFace->GetX(4) - sideCMidFace->GetX(5);
5212   TGeoTube *horTube = new TGeoTube(0, kCoolingTubeRmax, delta/2);
5213
5214   // The freon inside the horizontal part of the cooling tube: a Tube
5215   TGeoTube *horFreon = new TGeoTube(0, kCoolingTubeRmin, delta/2);
5216
5217   // The inclined part of the cooling tube inside the tray: a Ctub
5218   Double_t x3, y3, x4, y4;
5219   x3 = sideCMidFace->GetX(3);
5220   y3 = sideCMidFace->GetY(3);
5221   x4 = sideCMidFace->GetX(4);
5222   y4 = sideCMidFace->GetY(4);
5223   delta = TMath::Sqrt( (x4 - x3 + kCoolingTubeRmax*SinD(kTrayCFoldAngle))*
5224                        (x4 - x3 + kCoolingTubeRmax*SinD(kTrayCFoldAngle))    +
5225        (y4 + kCoolingTubeRmax - y3 - kCoolingTubeRmax*SinD(kTrayCFoldAngle))*
5226        (y4 + kCoolingTubeRmax - y3 - kCoolingTubeRmax*SinD(kTrayCFoldAngle)) );
5227
5228   TGeoCtub *incTube = new TGeoCtub(0, kCoolingTubeRmax, delta/2, 0, 360,
5229                                0, SinD(kTrayCFoldAngle),-CosD(kTrayCFoldAngle),
5230                                0,                     0,                    1);
5231
5232   // The freon inside the inclined part of the cooling tube: a Ctub
5233   TGeoCtub *incFreon = new TGeoCtub(0, kCoolingTubeRmin, delta/2, 0, 360,
5234                                0, SinD(kTrayCFoldAngle),-CosD(kTrayCFoldAngle),
5235                                0,                     0,                    1);
5236
5237   // The part of the cooling tube outside the tray: a Ctub
5238   TGeoCtub *outTube = new TGeoCtub(0, kCoolingTubeRmax,
5239                         0.5*kTrayCCablesZLenOut/SinD(kTrayCCablesOutRot),
5240                         0, 360,
5241                         0,                        0,                      -1,
5242                         0,-SinD(kTrayCCablesOutRot), CosD(kTrayCCablesOutRot));
5243
5244   // The freon inside the part of the cooling tube outside the tray: a Ctub
5245   TGeoCtub *outFreon = new TGeoCtub(0, kCoolingTubeRmin,
5246                         outTube->GetDz(),
5247                         0, 360,
5248                         0,                        0,                      -1,
5249                         0,-SinD(kTrayCCablesOutRot), CosD(kTrayCCablesOutRot));
5250
5251   // The optical fibers inside the tray: a Xtru
5252   TGeoXtru *optFibs = new TGeoXtru(2);
5253
5254   xprof[0] = -kTrayCCablesZLenOut;
5255   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5256   xprof[1] = sideCMidFace->GetX(5);
5257   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5258   xprof[2] = sideCMidFace->GetX(4);
5259   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5260   xprof[3] = sideCMidFace->GetX(3);
5261   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5262   xprof[4] = xprof[3] - kOpticalFibersSect*SinD(kTrayCFoldAngle);
5263   yprof[4] = yprof[3] + kOpticalFibersSect*CosD(kTrayCFoldAngle);
5264   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5265               kOpticalFibersSect , xprof[5], yprof[5]);
5266   xprof[6] = 0.;
5267   yprof[6] = yprof[1] + kOpticalFibersSect;
5268   xprof[7] = xprof[0];
5269   yprof[7] = yprof[0] + kOpticalFibersSect;
5270
5271   optFibs->DefinePolygon(8, xprof, yprof);
5272   optFibs->DefineSection(0, 0);
5273   optFibs->DefineSection(1, kOpticalFibersSect);
5274
5275   // The low voltage cables inside the tray: two Xtru
5276   TGeoXtru *lowCablesCu = new TGeoXtru(2);
5277
5278   xprof[0] = -kTrayCCablesZLenOut;
5279   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5280   xprof[1] = sideCMidFace->GetX(5);
5281   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5282   xprof[2] = sideCMidFace->GetX(4);
5283   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5284   xprof[3] = sideCMidFace->GetX(3);
5285   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5286   xprof[4] = xprof[3] - kLowVoltCableSectCu*SinD(kTrayCFoldAngle);
5287   yprof[4] = yprof[3] + kLowVoltCableSectCu*CosD(kTrayCFoldAngle);
5288   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5289               kLowVoltCableSectCu , xprof[5], yprof[5]);
5290   xprof[6] = 0.;
5291   yprof[6] = yprof[1] + kLowVoltCableSectCu;
5292   xprof[7] = xprof[0];
5293   yprof[7] = yprof[0] + kLowVoltCableSectCu;
5294
5295   lowCablesCu->DefinePolygon(8, xprof, yprof);
5296   lowCablesCu->DefineSection(0, 0);
5297   lowCablesCu->DefineSection(1, kLowVoltCableSectCu);
5298
5299   TGeoXtru *lowCablesPUR = new TGeoXtru(2);
5300
5301   xprof[0] = lowCablesCu->GetX(7);
5302   yprof[0] = lowCablesCu->GetY(7);
5303   xprof[1] = lowCablesCu->GetX(6);
5304   yprof[1] = lowCablesCu->GetY(6);
5305   xprof[2] = lowCablesCu->GetX(5);
5306   yprof[2] = lowCablesCu->GetY(5);
5307   xprof[3] = lowCablesCu->GetX(4);
5308   yprof[3] = lowCablesCu->GetY(4);
5309   xprof[4] = xprof[3] - kLowVoltCableHighPUR*SinD(kTrayCFoldAngle);
5310   yprof[4] = yprof[3] + kLowVoltCableHighPUR*CosD(kTrayCFoldAngle);
5311   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5312               kLowVoltCableHighPUR , xprof[5], yprof[5]);
5313   xprof[6] = 0.;
5314   yprof[6] = yprof[1] + kLowVoltCableHighPUR;
5315   xprof[7] = xprof[0];
5316   yprof[7] = yprof[0] + kLowVoltCableHighPUR;
5317
5318   lowCablesPUR->DefinePolygon(8, xprof, yprof);
5319   lowCablesPUR->DefineSection(0, 0);
5320   lowCablesPUR->DefineSection(1, kLowVoltCableSectCu);
5321
5322   // The high voltage cables inside the tray: two Xtru
5323   TGeoXtru *hiCablesCu = new TGeoXtru(2);
5324
5325   xprof[0] = -kTrayCCablesZLenOut;
5326   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5327   xprof[1] = sideCMidFace->GetX(5);
5328   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5329   xprof[2] = sideCMidFace->GetX(4);
5330   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5331   xprof[3] = sideCMidFace->GetX(3);
5332   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5333   xprof[4] = xprof[3] - kHiVoltCableSectCu*SinD(kTrayCFoldAngle);
5334   yprof[4] = yprof[3] + kHiVoltCableSectCu*CosD(kTrayCFoldAngle);
5335   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5336               kHiVoltCableSectCu , xprof[5], yprof[5]);
5337   xprof[6] = 0.;
5338   yprof[6] = yprof[1] + kHiVoltCableSectCu;
5339   xprof[7] = xprof[0];
5340   yprof[7] = yprof[0] + kHiVoltCableSectCu;
5341
5342   hiCablesCu->DefinePolygon(8, xprof, yprof);
5343   hiCablesCu->DefineSection(0, 0);
5344   hiCablesCu->DefineSection(1, kHiVoltCableSectCu);
5345
5346   TGeoXtru *hiCablesPUR = new TGeoXtru(2);
5347
5348   xprof[0] = hiCablesCu->GetX(7);
5349   yprof[0] = hiCablesCu->GetY(7);
5350   xprof[1] = hiCablesCu->GetX(6);
5351   yprof[1] = hiCablesCu->GetY(6);
5352   xprof[2] = hiCablesCu->GetX(5);
5353   yprof[2] = hiCablesCu->GetY(5);
5354   xprof[3] = hiCablesCu->GetX(4);
5355   yprof[3] = hiCablesCu->GetY(4);
5356   xprof[4] = xprof[3] - kHiVoltCableHighPUR*SinD(kTrayCFoldAngle);
5357   yprof[4] = yprof[3] + kHiVoltCableHighPUR*CosD(kTrayCFoldAngle);
5358   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5359               kHiVoltCableHighPUR , xprof[5], yprof[5]);
5360   xprof[6] = 0.;
5361   yprof[6] = yprof[1] + kHiVoltCableHighPUR;
5362   xprof[7] = xprof[0];
5363   yprof[7] = yprof[0] + kHiVoltCableHighPUR;
5364
5365   hiCablesPUR->DefinePolygon(8, xprof, yprof);
5366   hiCablesPUR->DefineSection(0, 0);
5367   hiCablesPUR->DefineSection(1, kHiVoltCableSectCu);
5368
5369   // The coaxial cables inside the tray: two Xtru
5370   TGeoXtru *coaxCablesCu = new TGeoXtru(2);
5371
5372   xprof[0] = -kTrayCCablesZLenOut;
5373   yprof[0] = xprof[0]/TanD(kTrayCCablesOutRot);
5374   xprof[1] = sideCMidFace->GetX(5);
5375   yprof[1] = sideCMidFace->GetY(5) + kCablesYtrans;
5376   xprof[2] = sideCMidFace->GetX(4);
5377   yprof[2] = sideCMidFace->GetY(4) + kCablesYtrans;
5378   xprof[3] = sideCMidFace->GetX(3);
5379   yprof[3] = sideCMidFace->GetY(3) + kCablesYtrans;
5380   xprof[4] = xprof[3] - kCoaxCableSectCu*SinD(kTrayCFoldAngle);
5381   yprof[4] = yprof[3] + kCoaxCableSectCu*CosD(kTrayCFoldAngle);
5382   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5383               kCoaxCableSectCu , xprof[5], yprof[5]);
5384   xprof[6] = 0.;
5385   yprof[6] = yprof[1] + kCoaxCableSectCu;
5386   xprof[7] = xprof[0];
5387   yprof[7] = yprof[0] + kCoaxCableSectCu;
5388
5389   coaxCablesCu->DefinePolygon(8, xprof, yprof);
5390   coaxCablesCu->DefineSection(0, 0);
5391   coaxCablesCu->DefineSection(1, kCoaxCableSectCu);
5392
5393   TGeoXtru *coaxCablesMeg = new TGeoXtru(2);
5394
5395   xprof[0] = coaxCablesCu->GetX(7);
5396   yprof[0] = coaxCablesCu->GetY(7);
5397   xprof[1] = coaxCablesCu->GetX(6);
5398   yprof[1] = coaxCablesCu->GetY(6);
5399   xprof[2] = coaxCablesCu->GetX(5);
5400   yprof[2] = coaxCablesCu->GetY(5);
5401   xprof[3] = coaxCablesCu->GetX(4);
5402   yprof[3] = coaxCablesCu->GetY(4);
5403   xprof[4] = xprof[3] - kCoaxCableHighMeg*SinD(kTrayCFoldAngle);
5404   yprof[4] = yprof[3] + kCoaxCableHighMeg*CosD(kTrayCFoldAngle);
5405   InsidePoint(xprof[1], yprof[1], xprof[2], yprof[2], xprof[3], yprof[3],
5406               kCoaxCableHighMeg , xprof[5], yprof[5]);
5407   xprof[6] = 0.;
5408   yprof[6] = yprof[1] + kCoaxCableHighMeg;
5409   xprof[7] = xprof[0];
5410   yprof[7] = yprof[0] + kCoaxCableHighMeg;
5411
5412   coaxCablesMeg->DefinePolygon(8, xprof, yprof);
5413   coaxCablesMeg->DefineSection(0, 0);
5414   coaxCablesMeg->DefineSection(1, kCoaxCableSectCu);
5415
5416   // To avoid a newly discovered overlap,
5417   // transform the two overlapping volumes into a Composite Shape
5418   TGeoCompositeShape *trayIntern =
5419     new TGeoCompositeShape("ITSSPDInternalTrayC",
5420                            "ITSsuppSPDTraySideCHor+ITSsuppSPDTraySideCWall");
5421
5422   // We have all shapes: now create the real volumes
5423   TGeoMedium *medAl   = mgr->GetMedium("ITS_ALUMINUM$");
5424   TGeoMedium *medIn   = mgr->GetMedium("ITS_INOX$");
5425   TGeoMedium *medFr   = mgr->GetMedium("ITS_Freon$");
5426   TGeoMedium *medFibs = mgr->GetMedium("ITS_SDD OPTICFIB$");//!!TO BE CHECKED!!
5427   TGeoMedium *medCu   = mgr->GetMedium("ITS_COPPER$");
5428   TGeoMedium *medPUR  = mgr->GetMedium("ITS_POLYURETHANE$");
5429   TGeoMedium *medMeg  = mgr->GetMedium("ITS_MEGOLON$");
5430
5431   TGeoVolume *traySideCIntern  = new TGeoVolume("ITSsuppSPDTraySideCInternal",
5432                                                 trayIntern, medAl);
5433
5434   traySideCIntern->SetVisibility(kTRUE);
5435   traySideCIntern->SetLineColor(6); // Purple
5436   traySideCIntern->SetLineWidth(1);
5437   traySideCIntern->SetFillColor(traySideCIntern->GetLineColor());
5438   traySideCIntern->SetFillStyle(4000); // 0% transparent
5439
5440   TGeoVolume *traySideCMidFace  = new TGeoVolume("ITSsuppSPDTraySideCMid",
5441                                                  sideCMidFace, medAl);
5442
5443   traySideCMidFace->SetVisibility(kTRUE);
5444   traySideCMidFace->SetLineColor(6); // Purple
5445   traySideCMidFace->SetLineWidth(1);
5446   traySideCMidFace->SetFillColor(traySideCMidFace->GetLineColor());
5447   traySideCMidFace->SetFillStyle(4000); // 0% transparent
5448
5449   TGeoVolume *traySideCSideFace  = new TGeoVolume("ITSsuppSPDTraySideCSide",
5450                                                   sideCSideFace, medAl);
5451
5452   traySideCSideFace->SetVisibility(kTRUE);
5453   traySideCSideFace->SetLineColor(6); // Purple
5454   traySideCSideFace->SetLineWidth(1);
5455   traySideCSideFace->SetFillColor(traySideCSideFace->GetLineColor());
5456   traySideCSideFace->SetFillStyle(4000); // 0% transparent
5457
5458   TGeoVolume *traySideCShortCover  = new TGeoVolume("ITSsuppSPDTraySideCShCov",
5459                                                     sideCShortCover, medAl);
5460
5461   traySideCShortCover->SetVisibility(kTRUE);
5462   traySideCShortCover->SetLineColor(6); // Purple
5463   traySideCShortCover->SetLineWidth(1);
5464   traySideCShortCover->SetFillColor(traySideCShortCover->GetLineColor());
5465   traySideCShortCover->SetFillStyle(4000); // 0% transparent
5466
5467   TGeoVolume *traySideCLongCover  = new TGeoVolume("ITSsuppSPDTraySideCLnCov",
5468                                                    sideCLongCover, medAl);
5469
5470   traySideCLongCover->SetVisibility(kTRUE);
5471   traySideCLongCover->SetLineColor(6); // Purple
5472   traySideCLongCover->SetLineWidth(1);
5473   traySideCLongCover->SetFillColor(traySideCLongCover->GetLineColor());
5474   traySideCLongCover->SetFillStyle(4000); // 0% transparent
5475
5476   TGeoVolume *traySideCHorTube = new TGeoVolume("ITSsuppSPDTraySideCHorTube",
5477                                                 horTube, medIn);
5478
5479   traySideCHorTube->SetVisibility(kTRUE);
5480   traySideCHorTube->SetLineColor(kGray); // as in GeometrySPD
5481   traySideCHorTube->SetLineWidth(1);
5482   traySideCHorTube->SetFillColor(traySideCHorTube->GetLineColor());
5483   traySideCHorTube->SetFillStyle(4000); // 0% transparent
5484
5485   TGeoVolume *traySideCHorFreon = new TGeoVolume("ITSsuppSPDTraySideCHorFreon",
5486                                                  horFreon, medFr);
5487
5488   traySideCHorFreon->SetVisibility(kTRUE);
5489   traySideCHorFreon->SetLineColor(kBlue); // Blue
5490   traySideCHorFreon->SetLineWidth(1);
5491   traySideCHorFreon->SetFillColor(traySideCHorFreon->GetLineColor());
5492   traySideCHorFreon->SetFillStyle(4000); // 0% transparent
5493
5494   TGeoVolume *traySideCIncTube = new TGeoVolume("ITSsuppSPDTraySideCIncTube",
5495                                                 incTube, medIn);
5496
5497   traySideCIncTube->SetVisibility(kTRUE);
5498   traySideCIncTube->SetLineColor(kGray); // as in GeometrySPD
5499   traySideCIncTube->SetLineWidth(1);
5500   traySideCIncTube->SetFillColor(traySideCIncTube->GetLineColor());
5501   traySideCIncTube->SetFillStyle(4000); // 0% transparent
5502
5503   TGeoVolume *traySideCIncFreon = new TGeoVolume("ITSsuppSPDTraySideCIncFreon",
5504                                                  incFreon, medFr);
5505
5506   traySideCIncFreon->SetVisibility(kTRUE);
5507   traySideCIncFreon->SetLineColor(kBlue); // Blue
5508   traySideCIncFreon->SetLineWidth(1);
5509   traySideCIncFreon->SetFillColor(traySideCIncFreon->GetLineColor());
5510   traySideCIncFreon->SetFillStyle(4000); // 0% transparent
5511
5512   TGeoVolume *traySideCOutTube = new TGeoVolume("ITSsuppSPDTraySideCOutTube",
5513                                                 outTube, medIn);
5514
5515   traySideCOutTube->SetVisibility(kTRUE);
5516   traySideCOutTube->SetLineColor(kGray); // as in GeometrySPD
5517   traySideCOutTube->SetLineWidth(1);
5518   traySideCOutTube->SetFillColor(traySideCOutTube->GetLineColor());
5519   traySideCOutTube->SetFillStyle(4000); // 0% transparent
5520
5521   TGeoVolume *traySideCOutFreon = new TGeoVolume("ITSsuppSPDTraySideCOutFreon",
5522                                                  outFreon, medFr);
5523
5524   traySideCOutFreon->SetVisibility(kTRUE);
5525   traySideCOutFreon->SetLineColor(kBlue); // Blue
5526   traySideCOutFreon->SetLineWidth(1);
5527   traySideCOutFreon->SetFillColor(traySideCOutFreon->GetLineColor());
5528   traySideCOutFreon->SetFillStyle(4000); // 0% transparent
5529
5530   TGeoVolume *traySideCOptFibs = new TGeoVolume("ITSsuppSPDTraySideCOptFibs",
5531                                                 optFibs, medFibs);
5532
5533   traySideCOptFibs->SetVisibility(kTRUE);
5534   traySideCOptFibs->SetLineColor(kOrange); // Orange
5535   traySideCOptFibs->SetLineWidth(1);
5536   traySideCOptFibs->SetFillColor(traySideCOptFibs->GetLineColor());
5537   traySideCOptFibs->SetFillStyle(4000); // 0% transparent
5538
5539   TGeoVolume *traySideCLowCabsCu = new TGeoVolume("ITSsuppSPDTraySideCLVCu",
5540                                                   lowCablesCu, medCu);
5541
5542   traySideCLowCabsCu->SetVisibility(kTRUE);
5543   traySideCLowCabsCu->SetLineColor(kRed); // Red
5544   traySideCLowCabsCu->SetLineWidth(1);
5545   traySideCLowCabsCu->SetFillColor(traySideCLowCabsCu->GetLineColor());
5546   traySideCLowCabsCu->SetFillStyle(4000); // 0% transparent
5547
5548   TGeoVolume *traySideCLowCabsPUR = new TGeoVolume("ITSsuppSPDTraySideCLVPUR",
5549                                                    lowCablesPUR, medPUR);
5550
5551   traySideCLowCabsPUR->SetVisibility(kTRUE);
5552   traySideCLowCabsPUR->SetLineColor(kBlack); // Black
5553   traySideCLowCabsPUR->SetLineWidth(1);
5554   traySideCLowCabsPUR->SetFillColor(traySideCLowCabsPUR->GetLineColor());
5555   traySideCLowCabsPUR->SetFillStyle(4000); // 0% transparent
5556
5557   TGeoVolume *traySideCHiCabsCu = new TGeoVolume("ITSsuppSPDTraySideCHVCu",
5558                                                  hiCablesCu, medCu);
5559
5560   traySideCHiCabsCu->SetVisibility(kTRUE);
5561   traySideCHiCabsCu->SetLineColor(kRed); // Red
5562   traySideCHiCabsCu->SetLineWidth(1);
5563   traySideCHiCabsCu->SetFillColor(traySideCHiCabsCu->GetLineColor());
5564   traySideCHiCabsCu->SetFillStyle(4000); // 0% transparent
5565
5566   TGeoVolume *traySideCHiCabsPUR = new TGeoVolume("ITSsuppSPDTraySideCHVPUR",
5567                                                   hiCablesPUR, medPUR);
5568
5569   traySideCHiCabsPUR->SetVisibility(kTRUE);
5570   traySideCHiCabsPUR->SetLineColor(kBlack); // Black
5571   traySideCHiCabsPUR->SetLineWidth(1);
5572   traySideCHiCabsPUR->SetFillColor(traySideCHiCabsPUR->GetLineColor());
5573   traySideCHiCabsPUR->SetFillStyle(4000); // 0% transparent
5574
5575   TGeoVolume *traySideCCoaxCu = new TGeoVolume("ITSsuppSPDTraySideCCoaxCu",
5576                                                coaxCablesCu, medCu);
5577
5578   traySideCCoaxCu->SetVisibility(kTRUE);
5579   traySideCCoaxCu->SetLineColor(kRed); // Red
5580   traySideCCoaxCu->SetLineWidth(1);
5581   traySideCCoaxCu->SetFillColor(traySideCCoaxCu->GetLineColor());
5582   traySideCCoaxCu->SetFillStyle(4000); // 0% transparent
5583
5584   TGeoVolume *traySideCCoaxMeg = new TGeoVolume("ITSsuppSPDTraySideCCoaxMeg",
5585                                                 coaxCablesMeg, medMeg);
5586
5587   traySideCCoaxMeg->SetVisibility(kTRUE);
5588   traySideCCoaxMeg->SetLineColor(kBlack); // Black
5589   traySideCCoaxMeg->SetLineWidth(1);
5590   traySideCCoaxMeg->SetFillColor(traySideCCoaxMeg->GetLineColor());
5591   traySideCCoaxMeg->SetFillStyle(4000); // 0% transparent
5592
5593
5594   // Now build up the trays
5595   cableTrayC->AddNode(traySideCIntern,1,0);
5596
5597   cableTrayC->AddNode(traySideCMidFace,1,0);
5598
5599   zloc = kTrayCHalfWide - kTrayCThick;
5600   cableTrayC->AddNode(traySideCSideFace, 1,
5601                       new TGeoTranslation( 0, 0, zloc));
5602   zloc = -kTrayCHalfWide;
5603   cableTrayC->AddNode(traySideCSideFace, 2,
5604                       new TGeoTranslation( 0, 0, zloc));
5605
5606   xloc = sideCShortCover->GetDX();
5607   yloc = kTrayCFirstHigh - sideCShortCover->GetDY();
5608   cableTrayC->AddNode(traySideCShortCover, 1,
5609                       new TGeoTranslation( xloc, yloc, 0));
5610
5611   cableTrayC->AddNode(traySideCLongCover,1,0);
5612
5613   traySideCHorTube->AddNode(traySideCHorFreon, 1, 0);
5614   traySideCIncTube->AddNode(traySideCIncFreon, 1, 0);
5615   traySideCOutTube->AddNode(traySideCOutFreon, 1, 0);
5616
5617   xloc = horTube->GetDz();
5618   yloc = sideCMidFace->GetY(5) + horTube->GetRmax();
5619   cableTrayC->AddNode(traySideCHorTube, 1,
5620                       new TGeoCombiTrans( xloc, yloc, 0,
5621                       new TGeoRotation("",-90.,-90.,90.)));
5622
5623   xloc = sideCMidFace->GetX(4) + (incTube->GetDz())*CosD(kTrayCFoldAngle);
5624   yloc = sideCMidFace->GetY(4) +  incTube->GetRmax() +
5625             (incTube->GetDz())*SinD(kTrayCFoldAngle)+0.005;//Avoid small ovrlp
5626   cableTrayC->AddNode(traySideCIncTube, 1,
5627                       new TGeoCombiTrans( xloc, yloc, 0,
5628                       new TGeoRotation("",-90.+kTrayCFoldAngle,-90.,90.)));
5629
5630   xloc = -kTrayCCablesZLenOut/2 - outTube->GetRmax();
5631   yloc = xloc/TanD(kTrayCCablesOutRot) + sideCMidFace->GetY(4) -
5632          2*outTube->GetRmax();
5633   cableTrayC->AddNode(traySideCOutTube, 1,
5634                       new TGeoCombiTrans( xloc, yloc, 0,
5635                       new TGeoRotation("",-70.,-90.,90.)));
5636
5637   zloc = horTube->GetRmax();
5638   cableTrayC->AddNode(traySideCOptFibs, 1,
5639                       new TGeoTranslation( 0, 0, zloc));
5640
5641   zloc = kLowVoltCableSectCu + horTube->GetRmax();
5642   cableTrayC->AddNode(traySideCLowCabsCu, 1,
5643                       new TGeoTranslation( 0, 0,-zloc));
5644   cableTrayC->AddNode(traySideCLowCabsPUR, 1,
5645                       new TGeoTranslation( 0, 0,-zloc));
5646
5647   zloc = kHiVoltCableSectCu + kLowVoltCableSectCu + horTube->GetRmax();
5648   cableTrayC->AddNode(traySideCHiCabsCu, 1,
5649                       new TGeoTranslation( 0, 0,-zloc));
5650   cableTrayC->AddNode(traySideCHiCabsPUR, 1,
5651                       new TGeoTranslation( 0, 0,-zloc));
5652
5653   zloc = kOpticalFibersSect + kCoaxCableSectCu + horTube->GetRmax();
5654   cableTrayC->AddNode(traySideCCoaxCu, 1,
5655                       new TGeoTranslation( 0, 0, zloc));
5656   cableTrayC->AddNode(traySideCCoaxMeg, 1,
5657                       new TGeoTranslation( 0, 0, zloc));
5658
5659
5660   // Finally put everything in the mother volume
5661   for (Int_t jt = 0; jt < kNumTraysSideC/2; jt++) {
5662     alpharot = kTraySideCAlphaRot[jt];
5663
5664     xloc = kTraySideCRPos*SinD(alpharot);
5665     yloc = kTraySideCRPos*CosD(alpharot);
5666     moth->AddNode(cableTrayC,2*jt+1,
5667                 new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
5668                 new TGeoRotation("",-90.+alpharot,-90.,90.+kTrayCFoldAngle)));
5669     alpharot += 180;
5670     xloc = kTraySideCRPos*SinD(alpharot);
5671     yloc = kTraySideCRPos*CosD(alpharot);
5672     moth->AddNode(cableTrayC,2*jt+2,
5673                 new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
5674                 new TGeoRotation("",-90.+alpharot,-90.,90.+kTrayCFoldAngle)));
5675   }
5676
5677
5678   return;
5679 }
5680
5681 //______________________________________________________________________
5682 void AliITSv11GeometrySupport::SDDCableTraysSideA(TGeoVolume *moth,
5683                                              const TGeoManager *mgr){
5684 //
5685 // Creates the SDD cable trays which are outside the ITS support cones
5686 // but still inside the TPC on Side A
5687 // (part of this code is taken or anyway inspired to ServicesCableSupport
5688 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
5689 //
5690 // Input:
5691 //         moth : the TGeoVolume owing the volume structure
5692 //         mgr  : the GeoManager (default gGeoManager)
5693 // Output:
5694 //
5695 // Created:         ???       Bjorn S. Nilsen
5696 // Updated:       5 Jan 2010  Mario Sitta
5697 // Updated:      26 Feb 2010  Mario Sitta
5698 // Updated:      06 Sep 2010  Mario Sitta
5699 //
5700 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
5701 // drawings and other (oral) information given by F.Tosello
5702 //
5703
5704   // Overall position and rotation of the A-Side Cable Trays
5705   // (parts of 0872/G/D)
5706   const Double_t kTrayARTrans            =  408.35 *fgkmm;
5707   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
5708   const Double_t kTrayAZToSupportRing    =  435.00 *fgkmm;
5709   const Double_t kExternTrayYTrans       =   96.00 *fgkmm; // Computed
5710   const Double_t kExternTrayZTrans       =  823.00 *fgkmm;
5711   const Double_t kExternCoverYTrans      =    2.00 *fgkmm;
5712   const Double_t kTrayAZRot              = (180-169.5);// Degrees
5713   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
5714   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
5715
5716   const Double_t kForwardTrayThick       =    2.00 *fgkmm;
5717   const Double_t kForwardTrayTailHeight  =  100.00 *fgkmm; // Computed
5718   const Double_t kForwardTrayTotalHeight =  170.00 *fgkmm; // Computed
5719   const Double_t kForwardTrayUpperLength =  405.00 *fgkmm; // Computed
5720   const Double_t kForwardCoverLength     =  380.00 *fgkmm;
5721   const Double_t kForwardCoverWide       =  133.00 *fgkmm;
5722   const Double_t kForwardCoverHeight     =   10.00 *fgkmm;
5723   const Double_t kForwardCoverThick      =    1.00 *fgkmm;
5724
5725   const Double_t kExternTrayTotalLen     = 1200.00 *fgkmm;
5726   const Double_t kExternTrayTotalHeight  =   52.00 *fgkmm;
5727   const Double_t kExternCoverLen         = kExternTrayTotalLen;
5728   const Double_t kExternCoverThick       =    5.00 *fgkmm;
5729   const Double_t kExternCoverSideThick   =    3.00 *fgkmm;
5730
5731   const Int_t    kForwardTrayNpoints     =    8;
5732
5733   // Dimensions and positions of the Cable Tray elements
5734   const Double_t kSideACoolManifWide     =    8.23 *fgkcm;
5735   const Double_t kSideACoolManifHigh     =    8.06 *fgkcm;
5736   const Double_t kSideACoolManifLen      =    3.90 *fgkcm;
5737   const Double_t kSideACoolManifPOMFrac  =    0.0054;
5738   const Double_t kSideACoolManifSteelFrac=    0.8850;
5739   const Double_t kSideACoolManifWaterFrac=    0.0913;
5740   const Double_t kSideACoolManifAlFrac   =    0.0183;
5741
5742   const Double_t kSideACoolTubesWide     =    9.07 *fgkcm;
5743   const Double_t kSideACoolTubesHigh     =    1.88 *fgkcm;
5744   const Double_t kSideACoolTubesTrans    =    0.88 *fgkcm;
5745   const Double_t kSideACoolTubesPURFrac  =    0.5897;
5746   const Double_t kSideACoolTubesWaterFrac=    0.4101;
5747   const Double_t kSideACoolTubesAirFrac  =    0.0002;
5748
5749   const Double_t kSideAOptConnWide       =    0.90    *fgkcm;
5750   const Double_t kSideAOptConnLen        =    1.37    *fgkcm;
5751   const Double_t kSideAOptConnPBTFrac    =    0.5010;
5752   const Double_t kSideAOptConnSteelFrac  =    0.1784;
5753   const Double_t kSideAOptConnAlFrac     =    0.3206;
5754
5755   const Double_t kSideAOptFibsWide       =    0.71    *fgkcm;
5756   const Double_t kSideAOptFibsHigh       =    3.20    *fgkcm;
5757
5758   const Double_t kSideAInputCablesWide   =   12.50    *fgkcm;
5759   const Double_t kSideAInputCablesHigh   =    1.24    *fgkcm;
5760   const Double_t kSideAInputCablesLen    =   25.20    *fgkcm;
5761   const Double_t kSideAInputCablesYTrans =    1.15    *fgkcm;
5762   const Double_t kSideAInputCablesCu     =    0.7404;
5763   const Double_t kSideAInputCablesPlast  =    0.1269;
5764   const Double_t kSideAInputCablesAl     =    0.0057;
5765   const Double_t kSideAInputCablesKapton =    0.0172;
5766   const Double_t kSideAInputCablesPOLYAX =    0.1098;
5767
5768   const Double_t kSideAOutputCablesWide  =    8.30    *fgkcm;
5769   const Double_t kSideAOutputCablesHigh  =    1.56    *fgkcm;
5770   const Double_t kSideAOutputCablesCu    =    0.6783;
5771   const Double_t kSideAOutputCablesPlast =    0.1605;
5772   const Double_t kSideAOutputCablesAl    =    0.0078;
5773   const Double_t kSideAOutputCablesKapton=    0.0232;
5774   const Double_t kSideAOutputCablesPOLYAX=    0.1302;
5775
5776   const Double_t kSideAPCBBoardsWide     =   12.50    *fgkcm;
5777   const Double_t kSideAPCBBoardsHigh     =    6.32    *fgkcm;
5778   const Double_t kSideAPCBBoardsLen      =   24.00    *fgkcm;
5779   const Double_t kSideAPCBBoardsYTrans   =    0.75    *fgkcm;
5780   const Double_t kSideAPCBBoardsCu       =    0.3864;
5781   const Double_t kSideAPCBBoardsEpoxy    =    0.1486;
5782   const Double_t kSideAPCBBoardsPlast    =    0.0578;
5783   const Double_t kSideAPCBBoardsSteel    =    0.1521;
5784   const Double_t kSideAPCBBoardsPPS      =    0.2551;
5785
5786
5787   // Local variables
5788   Double_t xprof[kForwardTrayNpoints], yprof[kForwardTrayNpoints];
5789   Double_t xloc, yloc, zloc, alpharot, height;
5790
5791
5792   // The whole tray as an assembly
5793   TGeoVolumeAssembly *cableTrayA = new TGeoVolumeAssembly("ITSsupportSDDTrayA");
5794   
5795
5796   // First create all needed shapes
5797
5798   // The forward tray is very complex and deserves a dedicated method
5799   CreateSDDForwardTraySideA(cableTrayA,mgr);
5800
5801   // The forward cover: a Xtru
5802   TGeoXtru *forwardCover = new TGeoXtru(2);
5803   forwardCover->SetName("ITSsuppSDDForwCover");
5804
5805   xprof[0] = kForwardCoverWide/2;
5806   yprof[0] = kForwardCoverHeight;
5807   xprof[1] = xprof[0];
5808   yprof[1] = 0;
5809   xprof[2] = xprof[1] - kForwardCoverThick;
5810   yprof[2] = yprof[1];
5811   xprof[3] = xprof[2];
5812   yprof[3] = yprof[0] - kForwardCoverThick;
5813
5814   // We did the right side, now reflex on the left side
5815   for (Int_t jp = 0; jp < 4; jp++) {
5816     xprof[4+jp] = -xprof[3-jp];
5817     yprof[4+jp] =  yprof[3-jp];
5818   }
5819
5820   forwardCover->DefinePolygon(8, xprof, yprof);
5821   forwardCover->DefineSection(0, 0);
5822   forwardCover->DefineSection(1, kForwardCoverLength);
5823
5824   // The external tray (as 0872/G/D/03): a Xtru
5825   TGeoXtru *externalTray = CreateSDDSSDTraysSideA(kExternTrayTotalLen,
5826                                                   kExternTrayTotalHeight);
5827
5828   // The external covers: a Composite Shape
5829   TGeoCompositeShape *externCover = CreateTrayAExternalCover(kExternCoverLen);
5830
5831   // Now the volumes inside it
5832   // The cooling manifold: four boxes
5833   TGeoBBox *coolManifPOM = new TGeoBBox(kSideACoolManifWide/2,
5834                  kSideACoolManifPOMFrac*kSideACoolManifHigh/2,
5835                                         kSideACoolManifLen/2);
5836
5837   TGeoBBox *coolManifSteel = new TGeoBBox(kSideACoolManifWide/2,
5838                  kSideACoolManifSteelFrac*kSideACoolManifHigh/2,
5839                                           kSideACoolManifLen/2);
5840
5841   TGeoBBox *coolManifWater = new TGeoBBox(kSideACoolManifWide/2,
5842                  kSideACoolManifWaterFrac*kSideACoolManifHigh/2,
5843                                           kSideACoolManifLen/2);
5844
5845   TGeoBBox *coolManifAl = new TGeoBBox(kSideACoolManifWide/2,
5846                  kSideACoolManifAlFrac*kSideACoolManifHigh/2,
5847                                        kSideACoolManifLen/2);
5848
5849   // The cooling tubes: three Xtru's
5850   TGeoXtru *coolTubesPUR = new TGeoXtru(2);
5851
5852   height = kSideACoolTubesHigh*kSideACoolTubesPURFrac;
5853
5854   xprof[0] = kSideACoolManifLen;
5855   yprof[0] = kForwardTrayThick + kSideACoolTubesTrans;
5856   xprof[2] = kExternTrayZTrans + kForwardTrayTotalHeight*SinD(kTrayAZRot) +
5857              kExternTrayTotalLen*CosD(kTrayAZRot) - xprof[0]/2;
5858   yprof[2] = kForwardTrayTotalHeight*(1 - CosD(kTrayAZRot)) +
5859              kExternTrayYTrans - kExternTrayTotalHeight*CosD(kTrayAZRot) +
5860              kExternTrayTotalLen*SinD(kTrayAZRot) + yprof[0];
5861   IntersectLines(              0 , xprof[0], yprof[0],
5862                  TanD(kTrayAZRot), xprof[2], yprof[2],
5863                                    xprof[1], yprof[1]);
5864   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5865   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5866   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5867               height, xprof[4], yprof[4]);
5868   xprof[5] = xprof[0];
5869   yprof[5] = yprof[0] + height;
5870
5871   coolTubesPUR->DefinePolygon(6, xprof, yprof);
5872   coolTubesPUR->DefineSection(0,-kSideACoolTubesWide/2);
5873   coolTubesPUR->DefineSection(1, kSideACoolTubesWide/2);
5874
5875   TGeoXtru *coolTubesWater = new TGeoXtru(2);
5876
5877   height = kSideACoolTubesHigh*kSideACoolTubesWaterFrac;
5878
5879   xprof[0] = coolTubesPUR->GetX(5);
5880   yprof[0] = coolTubesPUR->GetY(5);
5881   xprof[1] = coolTubesPUR->GetX(4);
5882   yprof[1] = coolTubesPUR->GetY(4);
5883   xprof[2] = coolTubesPUR->GetX(3);
5884   yprof[2] = coolTubesPUR->GetY(3);
5885   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5886   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5887   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5888               height, xprof[4], yprof[4]);
5889   xprof[5] = xprof[0];
5890   yprof[5] = yprof[0] + height;
5891
5892   coolTubesWater->DefinePolygon(6, xprof, yprof);
5893   coolTubesWater->DefineSection(0,-kSideACoolTubesWide/2);
5894   coolTubesWater->DefineSection(1, kSideACoolTubesWide/2);
5895
5896   TGeoXtru *coolTubesAir = new TGeoXtru(2);
5897
5898   height = kSideACoolTubesHigh*kSideACoolTubesAirFrac;
5899
5900   xprof[0] = coolTubesWater->GetX(5);
5901   yprof[0] = coolTubesWater->GetY(5);
5902   xprof[1] = coolTubesWater->GetX(4);
5903   yprof[1] = coolTubesWater->GetY(4);
5904   xprof[2] = coolTubesWater->GetX(3);
5905   yprof[2] = coolTubesWater->GetY(3);
5906   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5907   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5908   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5909               height, xprof[4], yprof[4]);
5910   xprof[5] = xprof[0];
5911   yprof[5] = yprof[0] + height;
5912
5913   coolTubesAir->DefinePolygon(6, xprof, yprof);
5914   coolTubesAir->DefineSection(0,-kSideACoolTubesWide/2);
5915   coolTubesAir->DefineSection(1, kSideACoolTubesWide/2);
5916
5917   // The optical fiber connectors: three boxes
5918   TGeoBBox *optConnPBT = new TGeoBBox(kSideAOptConnWide/2,
5919                  kSideAOptConnPBTFrac*kSideACoolManifHigh/2,
5920                                       kSideAOptConnLen/2);
5921
5922   TGeoBBox *optConnSteel = new TGeoBBox(kSideAOptConnWide/2,
5923                  kSideAOptConnSteelFrac*kSideACoolManifHigh/2,
5924                                         kSideAOptConnLen/2);
5925
5926   TGeoBBox *optConnAl = new TGeoBBox(kSideAOptConnWide/2,
5927                  kSideAOptConnAlFrac*kSideACoolManifHigh/2,
5928                                      kSideAOptConnLen/2);
5929
5930   // The optical fibers: a Xtru
5931   TGeoXtru *opticalFibs = new TGeoXtru(2);
5932
5933   xprof[0] = kSideAOptConnLen;
5934   yprof[0] = coolTubesPUR->GetY(0);
5935   xprof[1] = coolTubesPUR->GetX(1);
5936   yprof[1] = coolTubesPUR->GetY(1);
5937   xprof[2] = coolTubesPUR->GetX(2);
5938   yprof[2] = coolTubesPUR->GetY(2);
5939   xprof[3] = xprof[2] - kSideAOptFibsHigh*SinD(kTrayAZRot);
5940   yprof[3] = yprof[2] + kSideAOptFibsHigh*CosD(kTrayAZRot);
5941   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5942               kSideAOptFibsHigh, xprof[4], yprof[4]);
5943   xprof[5] = xprof[0];
5944   yprof[5] = yprof[0] + kSideAOptFibsHigh;
5945
5946   opticalFibs->DefinePolygon(6, xprof, yprof);
5947   opticalFibs->DefineSection(0,-kSideAOptFibsWide/2);
5948   opticalFibs->DefineSection(1, kSideAOptFibsWide/2);
5949
5950   // The input cables: five boxes
5951   TGeoBBox *inputCabsCu = new TGeoBBox(kSideAInputCablesWide/2,
5952                    kSideAInputCablesCu*kSideAInputCablesHigh/2,
5953                                        kSideAInputCablesLen/2);
5954
5955   TGeoBBox *inputCabsPlast = new TGeoBBox(kSideAInputCablesWide/2,
5956                    kSideAInputCablesPlast*kSideAInputCablesHigh/2,
5957                                           kSideAInputCablesLen/2);
5958
5959   TGeoBBox *inputCabsAl = new TGeoBBox(kSideAInputCablesWide/2,
5960                    kSideAInputCablesAl*kSideAInputCablesHigh/2,
5961                                        kSideAInputCablesLen/2);
5962
5963   TGeoBBox *inputCabsKapton = new TGeoBBox(kSideAInputCablesWide/2,
5964                    kSideAInputCablesKapton*kSideAInputCablesHigh/2,
5965                                            kSideAInputCablesLen/2);
5966
5967   TGeoBBox *inputCabsPOLYAX = new TGeoBBox(kSideAInputCablesWide/2,
5968                    kSideAInputCablesPOLYAX*kSideAInputCablesHigh/2,
5969                                            kSideAInputCablesLen/2);
5970
5971   // The output cables: five Xtru
5972   TGeoXtru *outputCabsCu = new TGeoXtru(2);
5973
5974   height = kSideAOutputCablesCu*kSideAOutputCablesHigh;
5975
5976   xprof[0] = kSideAInputCablesLen/2 + kSideAPCBBoardsLen/2;
5977   yprof[0] = coolTubesAir->GetY(5);
5978   xprof[1] = coolTubesAir->GetX(4);
5979   yprof[1] = coolTubesAir->GetY(4);
5980   xprof[2] = coolTubesAir->GetX(3);
5981   yprof[2] = coolTubesAir->GetY(3);
5982   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
5983   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
5984   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
5985               height, xprof[4], yprof[4]);
5986   xprof[5] = xprof[0];
5987   yprof[5] = yprof[0] + height;
5988
5989   outputCabsCu->DefinePolygon(6, xprof, yprof);
5990   outputCabsCu->DefineSection(0,-kSideAOutputCablesWide/2);
5991   outputCabsCu->DefineSection(1, kSideAOutputCablesWide/2);
5992
5993   TGeoXtru *outputCabsPlast = new TGeoXtru(2);
5994
5995   height = kSideAOutputCablesPlast*kSideAOutputCablesHigh;
5996
5997   xprof[0] = outputCabsCu->GetX(5);
5998   yprof[0] = outputCabsCu->GetY(5);
5999   xprof[1] = outputCabsCu->GetX(4);
6000   yprof[1] = outputCabsCu->GetY(4);
6001   xprof[2] = outputCabsCu->GetX(3);
6002   yprof[2] = outputCabsCu->GetY(3);
6003   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
6004   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
6005   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6006               height, xprof[4], yprof[4]);
6007   xprof[5] = xprof[0];
6008   yprof[5] = yprof[0] + height;
6009
6010   outputCabsPlast->DefinePolygon(6, xprof, yprof);
6011   outputCabsPlast->DefineSection(0,-kSideAOutputCablesWide/2);
6012   outputCabsPlast->DefineSection(1, kSideAOutputCablesWide/2);
6013
6014   TGeoXtru *outputCabsAl = new TGeoXtru(2);
6015
6016   height = kSideAOutputCablesAl*kSideAOutputCablesHigh;
6017
6018   xprof[0] = outputCabsPlast->GetX(5);
6019   yprof[0] = outputCabsPlast->GetY(5);
6020   xprof[1] = outputCabsPlast->GetX(4);
6021   yprof[1] = outputCabsPlast->GetY(4);
6022   xprof[2] = outputCabsPlast->GetX(3);
6023   yprof[2] = outputCabsPlast->GetY(3);
6024   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
6025   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
6026   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6027               height, xprof[4], yprof[4]);
6028   xprof[5] = xprof[0];
6029   yprof[5] = yprof[0] + height;
6030
6031   outputCabsAl->DefinePolygon(6, xprof, yprof);
6032   outputCabsAl->DefineSection(0,-kSideAOutputCablesWide/2);
6033   outputCabsAl->DefineSection(1, kSideAOutputCablesWide/2);
6034
6035   TGeoXtru *outputCabsKapton = new TGeoXtru(2);
6036
6037   height = kSideAOutputCablesKapton*kSideAOutputCablesHigh;
6038
6039   xprof[0] = outputCabsAl->GetX(5);
6040   yprof[0] = outputCabsAl->GetY(5);
6041   xprof[1] = outputCabsAl->GetX(4);
6042   yprof[1] = outputCabsAl->GetY(4);
6043   xprof[2] = outputCabsAl->GetX(3);
6044   yprof[2] = outputCabsAl->GetY(3);
6045   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
6046   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
6047   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6048               height, xprof[4], yprof[4]);
6049   xprof[5] = xprof[0];
6050   yprof[5] = yprof[0] + height;
6051
6052   outputCabsKapton->DefinePolygon(6, xprof, yprof);
6053   outputCabsKapton->DefineSection(0,-kSideAOutputCablesWide/2);
6054   outputCabsKapton->DefineSection(1, kSideAOutputCablesWide/2);
6055
6056   TGeoXtru *outputCabsPOLYAX = new TGeoXtru(2);
6057
6058   height = kSideAOutputCablesPOLYAX*kSideAOutputCablesHigh;
6059
6060   xprof[0] = outputCabsKapton->GetX(5);
6061   yprof[0] = outputCabsKapton->GetY(5);
6062   xprof[1] = outputCabsKapton->GetX(4);
6063   yprof[1] = outputCabsKapton->GetY(4);
6064   xprof[2] = outputCabsKapton->GetX(3);
6065   yprof[2] = outputCabsKapton->GetY(3);
6066   xprof[3] = xprof[2] - height*SinD(kTrayAZRot);
6067   yprof[3] = yprof[2] + height*CosD(kTrayAZRot);
6068   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6069               height, xprof[4], yprof[4]);
6070   xprof[5] = xprof[0];
6071   yprof[5] = yprof[0] + height;
6072
6073   outputCabsPOLYAX->DefinePolygon(6, xprof, yprof);
6074   outputCabsPOLYAX->DefineSection(0,-kSideAOutputCablesWide/2);
6075   outputCabsPOLYAX->DefineSection(1, kSideAOutputCablesWide/2);
6076
6077   // The PCB boards: five boxes
6078   TGeoBBox *pcbBoardsCu = new TGeoBBox(kSideAPCBBoardsWide/2,
6079                      kSideAPCBBoardsCu*kSideAPCBBoardsHigh/2,
6080                                        kSideAPCBBoardsLen/2);
6081
6082   TGeoBBox *pcbBoardsEpoxy = new TGeoBBox(kSideAPCBBoardsWide/2,
6083                      kSideAPCBBoardsEpoxy*kSideAPCBBoardsHigh/2,
6084                                           kSideAPCBBoardsLen/2);
6085
6086   TGeoBBox *pcbBoardsPlast = new TGeoBBox(kSideAPCBBoardsWide/2,
6087                      kSideAPCBBoardsPlast*kSideAPCBBoardsHigh/2,
6088                                           kSideAPCBBoardsLen/2);
6089
6090   TGeoBBox *pcbBoardsSteel = new TGeoBBox(kSideAPCBBoardsWide/2,
6091                      kSideAPCBBoardsSteel*kSideAPCBBoardsHigh/2,
6092                                           kSideAPCBBoardsLen/2);
6093
6094   TGeoBBox *pcbBoardsPPS = new TGeoBBox(kSideAPCBBoardsWide/2,
6095                      kSideAPCBBoardsPPS*kSideAPCBBoardsHigh/2,
6096                                         kSideAPCBBoardsLen/2);
6097
6098
6099   // We have all shapes: now create the real volumes
6100   TGeoMedium *medAl     = mgr->GetMedium("ITS_ALUMINUM$");
6101   TGeoMedium *medAntic  = mgr->GetMedium("ITS_ANTICORODAL$");
6102   TGeoMedium *medPOM    = mgr->GetMedium("ITS_POLYOXYMETHYLENE$");
6103   TGeoMedium *medSteel  = mgr->GetMedium("ITS_INOX$");
6104   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
6105   TGeoMedium *medPUR    = mgr->GetMedium("ITS_POLYURETHANE$");
6106   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
6107   TGeoMedium *medPBT    = mgr->GetMedium("ITS_PBT$");
6108   TGeoMedium *medOptFib = mgr->GetMedium("ITS_SDD OPTICFIB$");
6109   TGeoMedium *medCu     = mgr->GetMedium("ITS_COPPER$");
6110   TGeoMedium *medKapton = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
6111   TGeoMedium *medPOLYAX = mgr->GetMedium("ITS_POLYAX$");
6112   TGeoMedium *medPPS    = mgr->GetMedium("ITS_PPS$");
6113   TGeoMedium *medEpoxy  = mgr->GetMedium("ITS_EPOXY$");
6114
6115   TGeoVolume *forwardTrayCover = new TGeoVolume("ITSsuppSDDSideAForwTrayCover",
6116                                                 forwardCover, medAl);
6117
6118   forwardTrayCover->SetVisibility(kTRUE);
6119   forwardTrayCover->SetLineColor(kMagenta+1); // Purple
6120   forwardTrayCover->SetLineWidth(1);
6121   forwardTrayCover->SetFillColor(forwardTrayCover->GetLineColor());
6122   forwardTrayCover->SetFillStyle(4000); // 0% transparent
6123
6124   TGeoVolume *externalTraySDD = new TGeoVolume("ITSsuppSDDSideAExternalTray",
6125                                                externalTray, medAl);
6126
6127   externalTraySDD->SetVisibility(kTRUE);
6128   externalTraySDD->SetLineColor(6); // Purple
6129   externalTraySDD->SetLineWidth(1);
6130   externalTraySDD->SetFillColor(externalTraySDD->GetLineColor());
6131   externalTraySDD->SetFillStyle(4000); // 0% transparent
6132
6133   TGeoVolume *externTrayCover = new TGeoVolume("ITSsuppSDDSideAExtTrayCover",
6134                                                externCover, medAntic);
6135
6136   externTrayCover->SetVisibility(kTRUE);
6137   externTrayCover->SetLineColor(kMagenta+1); // Purple
6138   externTrayCover->SetLineWidth(1);
6139   externTrayCover->SetFillColor(externTrayCover->GetLineColor());
6140   externTrayCover->SetFillStyle(4000); // 0% transparent
6141
6142   TGeoVolume *pomCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifPOM",
6143                                             coolManifPOM, medPOM);
6144
6145   pomCoolManif->SetVisibility(kTRUE);
6146   pomCoolManif->SetLineColor(kRed); // Red
6147   pomCoolManif->SetLineWidth(1);
6148   pomCoolManif->SetFillColor(pomCoolManif->GetLineColor());
6149   pomCoolManif->SetFillStyle(4000); // 0% transparent
6150
6151   TGeoVolume *steelCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifSteel",
6152                                               coolManifSteel, medSteel);
6153
6154   steelCoolManif->SetVisibility(kTRUE);
6155   steelCoolManif->SetLineColor(kBlue); // Blue
6156   steelCoolManif->SetLineWidth(1);
6157   steelCoolManif->SetFillColor(steelCoolManif->GetLineColor());
6158   steelCoolManif->SetFillStyle(4000); // 0% transparent
6159
6160   TGeoVolume *waterCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifWater",
6161                                               coolManifWater, medWater);
6162
6163   waterCoolManif->SetVisibility(kTRUE);
6164   waterCoolManif->SetLineColor(33); // Light Blue
6165   waterCoolManif->SetLineWidth(1);
6166   waterCoolManif->SetFillColor(waterCoolManif->GetLineColor());
6167   waterCoolManif->SetFillStyle(4000); // 0% transparent
6168
6169   TGeoVolume *alCoolManif = new TGeoVolume("ITSsuppSDDSideACoolManifAl",
6170                                            coolManifAl, medAl);
6171
6172   alCoolManif->SetVisibility(kTRUE);
6173   alCoolManif->SetLineColor(6); // Purple
6174   alCoolManif->SetLineWidth(1);
6175   alCoolManif->SetFillColor(alCoolManif->GetLineColor());
6176   alCoolManif->SetFillStyle(4000); // 0% transparent
6177
6178   TGeoVolume *purCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesPUR",
6179                                             coolTubesPUR, medPUR);
6180
6181   purCoolTubes->SetVisibility(kTRUE);
6182   purCoolTubes->SetLineColor(kRed); // Red
6183   purCoolTubes->SetLineWidth(1);
6184   purCoolTubes->SetFillColor(purCoolTubes->GetLineColor());
6185   purCoolTubes->SetFillStyle(4000); // 0% transparent
6186
6187   TGeoVolume *waterCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesWater",
6188                                               coolTubesWater, medWater);
6189
6190   waterCoolTubes->SetVisibility(kTRUE);
6191   waterCoolTubes->SetLineColor(33); // Light Blue
6192   waterCoolTubes->SetLineWidth(1);
6193   waterCoolTubes->SetFillColor(waterCoolTubes->GetLineColor());
6194   waterCoolTubes->SetFillStyle(4000); // 0% transparent
6195
6196   TGeoVolume *airCoolTubes = new TGeoVolume("ITSsuppSDDSideACoolTubesAir",
6197                                             coolTubesAir, medAir);
6198
6199   airCoolTubes->SetVisibility(kTRUE);
6200   airCoolTubes->SetLineColor(41);
6201   airCoolTubes->SetLineWidth(1);
6202   airCoolTubes->SetFillColor(airCoolTubes->GetLineColor());
6203   airCoolTubes->SetFillStyle(4000); // 0% transparent
6204
6205   TGeoVolume *pbtOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnPBT",
6206                                           optConnPBT, medPBT);
6207
6208   pbtOptConn->SetVisibility(kTRUE);
6209   pbtOptConn->SetLineColor(kRed); // Red
6210   pbtOptConn->SetLineWidth(1);
6211   pbtOptConn->SetFillColor(pbtOptConn->GetLineColor());
6212   pbtOptConn->SetFillStyle(4000); // 0% transparent
6213
6214   TGeoVolume *steelOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnSteel",
6215                                             optConnSteel, medSteel);
6216
6217   steelOptConn->SetVisibility(kTRUE);
6218   steelOptConn->SetLineColor(kBlue); // Blue
6219   steelOptConn->SetLineWidth(1);
6220   steelOptConn->SetFillColor(steelOptConn->GetLineColor());
6221   steelOptConn->SetFillStyle(4000); // 0% transparent
6222
6223   TGeoVolume *alOptConn = new TGeoVolume("ITSsuppSDDSideAOptConnAl",
6224                                          optConnAl, medAl);
6225
6226   alOptConn->SetVisibility(kTRUE);
6227   alOptConn->SetLineColor(6); // Purple
6228   alOptConn->SetLineWidth(1);
6229   alOptConn->SetFillColor(alOptConn->GetLineColor());
6230   alOptConn->SetFillStyle(4000); // 0% transparent
6231
6232   TGeoVolume *optFibs = new TGeoVolume("ITSsuppSDDSideAOptFibs",
6233                                        opticalFibs, medOptFib);
6234
6235   optFibs->SetVisibility(kTRUE);
6236   optFibs->SetLineColor(kOrange+2); // Orange
6237   optFibs->SetLineWidth(1);
6238   optFibs->SetFillColor(optFibs->GetLineColor());
6239   optFibs->SetFillStyle(4000); // 0% transparent
6240
6241   TGeoVolume *cuInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsCu",
6242                                            inputCabsCu, medCu);
6243
6244   cuInputCabs->SetVisibility(kTRUE);
6245   cuInputCabs->SetLineColor(kBlack); // Black
6246   cuInputCabs->SetLineWidth(1);
6247   cuInputCabs->SetFillColor(cuInputCabs->GetLineColor());
6248   cuInputCabs->SetFillStyle(4000); // 0% transparent
6249
6250   TGeoVolume *plastInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsPlast",
6251                                               inputCabsPlast, medPUR);
6252
6253   plastInputCabs->SetVisibility(kTRUE);
6254   plastInputCabs->SetLineColor(kRed); // Red
6255   plastInputCabs->SetLineWidth(1);
6256   plastInputCabs->SetFillColor(plastInputCabs->GetLineColor());
6257   plastInputCabs->SetFillStyle(4000); // 0% transparent
6258
6259   TGeoVolume *alInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsAl",
6260                                            inputCabsAl, medAl);
6261
6262   alInputCabs->SetVisibility(kTRUE);
6263   alInputCabs->SetLineColor(6); // Purple
6264   alInputCabs->SetLineWidth(1);
6265   alInputCabs->SetFillColor(alInputCabs->GetLineColor());
6266   alInputCabs->SetFillStyle(4000); // 0% transparent
6267
6268   TGeoVolume *kaptonInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsKapton",
6269                                                inputCabsKapton, medKapton);
6270
6271   kaptonInputCabs->SetVisibility(kTRUE);
6272   kaptonInputCabs->SetLineColor(14); // 
6273   kaptonInputCabs->SetLineWidth(1);
6274   kaptonInputCabs->SetFillColor(kaptonInputCabs->GetLineColor());
6275   kaptonInputCabs->SetFillStyle(4000); // 0% transparent
6276
6277   TGeoVolume *polyaxInputCabs = new TGeoVolume("ITSsuppSDDSideAInputCabsPOLYAX",
6278                                                inputCabsPOLYAX, medPOLYAX);
6279
6280   polyaxInputCabs->SetVisibility(kTRUE);
6281   polyaxInputCabs->SetLineColor(34); // 
6282   polyaxInputCabs->SetLineWidth(1);
6283   polyaxInputCabs->SetFillColor(polyaxInputCabs->GetLineColor());
6284   polyaxInputCabs->SetFillStyle(4000); // 0% transparent
6285
6286   TGeoVolume *cuOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsCu",
6287                                             outputCabsCu, medCu);
6288
6289   cuOutputCabs->SetVisibility(kTRUE);
6290   cuOutputCabs->SetLineColor(kBlack); // Black
6291   cuOutputCabs->SetLineWidth(1);
6292   cuOutputCabs->SetFillColor(cuOutputCabs->GetLineColor());
6293   cuOutputCabs->SetFillStyle(4000); // 0% transparent
6294
6295   TGeoVolume *plastOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsPlast",
6296                                                outputCabsPlast, medPUR);
6297
6298   plastOutputCabs->SetVisibility(kTRUE);
6299   plastOutputCabs->SetLineColor(kRed); // Red
6300   plastOutputCabs->SetLineWidth(1);
6301   plastOutputCabs->SetFillColor(plastOutputCabs->GetLineColor());
6302   plastOutputCabs->SetFillStyle(4000); // 0% transparent
6303
6304   TGeoVolume *alOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsAl",
6305                                             outputCabsAl, medAl);
6306
6307   alOutputCabs->SetVisibility(kTRUE);
6308   alOutputCabs->SetLineColor(6); // Purple
6309   alOutputCabs->SetLineWidth(1);
6310   alOutputCabs->SetFillColor(alOutputCabs->GetLineColor());
6311   alOutputCabs->SetFillStyle(4000); // 0% transparent
6312
6313   TGeoVolume *kaptonOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsKapton",
6314                                                 outputCabsKapton, medKapton);
6315
6316   kaptonOutputCabs->SetVisibility(kTRUE);
6317   kaptonOutputCabs->SetLineColor(14); // 
6318   kaptonOutputCabs->SetLineWidth(1);
6319   kaptonOutputCabs->SetFillColor(kaptonOutputCabs->GetLineColor());
6320   kaptonOutputCabs->SetFillStyle(4000); // 0% transparent
6321
6322   TGeoVolume *polyaxOutputCabs = new TGeoVolume("ITSsuppSDDSideAOutputCabsPOLYAX",
6323                                                 outputCabsPOLYAX, medPOLYAX);
6324
6325   polyaxOutputCabs->SetVisibility(kTRUE);
6326   polyaxOutputCabs->SetLineColor(34); // 
6327   polyaxOutputCabs->SetLineWidth(1);
6328   polyaxOutputCabs->SetFillColor(polyaxOutputCabs->GetLineColor());
6329   polyaxOutputCabs->SetFillStyle(4000); // 0% transparent
6330
6331   TGeoVolume *cuPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsCu",
6332                                            pcbBoardsCu, medCu);
6333
6334   cuPCBBoards->SetVisibility(kTRUE);
6335   cuPCBBoards->SetLineColor(kBlack); // Black
6336   cuPCBBoards->SetLineWidth(1);
6337   cuPCBBoards->SetFillColor(cuPCBBoards->GetLineColor());
6338   cuPCBBoards->SetFillStyle(4000); // 0% transparent
6339
6340   TGeoVolume *epoxyPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsEpoxy",
6341                                               pcbBoardsEpoxy, medEpoxy);
6342
6343   epoxyPCBBoards->SetVisibility(kTRUE);
6344   epoxyPCBBoards->SetLineColor(22); //
6345   epoxyPCBBoards->SetLineWidth(1);
6346   epoxyPCBBoards->SetFillColor(epoxyPCBBoards->GetLineColor());
6347   epoxyPCBBoards->SetFillStyle(4000); // 0% transparent
6348
6349   TGeoVolume *plastPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsPlast",
6350                                               pcbBoardsPlast, medPUR);
6351
6352   plastPCBBoards->SetVisibility(kTRUE);
6353   plastPCBBoards->SetLineColor(kRed); // Red
6354   plastPCBBoards->SetLineWidth(1);
6355   plastPCBBoards->SetFillColor(plastPCBBoards->GetLineColor());
6356   plastPCBBoards->SetFillStyle(4000); // 0% transparent
6357
6358   TGeoVolume *steelPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsSteel",
6359                                               pcbBoardsSteel, medSteel);
6360
6361   steelPCBBoards->SetVisibility(kTRUE);
6362   steelPCBBoards->SetLineColor(kBlue); // Blue
6363   steelPCBBoards->SetLineWidth(1);
6364   steelPCBBoards->SetFillColor(steelPCBBoards->GetLineColor());
6365   steelPCBBoards->SetFillStyle(4000); // 0% transparent
6366
6367   TGeoVolume *ppsPCBBoards = new TGeoVolume("ITSsuppSDDSideAPCBBoardsPPS",
6368                                             pcbBoardsPPS, medPPS);
6369
6370   ppsPCBBoards->SetVisibility(kTRUE);
6371   ppsPCBBoards->SetLineColor(kGreen); // Green
6372   ppsPCBBoards->SetLineWidth(1);
6373   ppsPCBBoards->SetFillColor(ppsPCBBoards->GetLineColor());
6374   ppsPCBBoards->SetFillStyle(4000); // 0% transparent
6375
6376
6377   // Now build up the tray
6378   yloc = kForwardTrayTotalHeight - forwardCover->GetY(3);
6379   zloc = kForwardTrayUpperLength - kForwardCoverLength;
6380   cableTrayA->AddNode(forwardTrayCover, 1,
6381                       new TGeoTranslation( 0, yloc, zloc) );
6382
6383   Double_t totalhi = kExternTrayTotalHeight + kExternCoverThick
6384                    - kExternCoverYTrans;
6385
6386   yloc = totalhi*(1 - CosD(kTrayAZRot)) + kExternTrayYTrans -
6387          kExternTrayTotalHeight*CosD(kTrayAZRot);
6388   zloc = kExternTrayZTrans + totalhi*SinD(kTrayAZRot);
6389   cableTrayA->AddNode(externalTraySDD, 1,
6390                       new TGeoCombiTrans( 0, yloc, zloc,
6391                       new TGeoRotation("", 0,-kTrayAZRot, 0)        ) );
6392
6393   yloc = kExternCoverThick*(1 - CosD(kTrayAZRot)) + kExternTrayYTrans -
6394          kExternCoverYTrans*CosD(kTrayAZRot)/2-0.01;
6395   zloc = kExternTrayZTrans + kExternCoverThick*SinD(kTrayAZRot);
6396   cableTrayA->AddNode(externTrayCover,1,
6397                       new TGeoCombiTrans( 0, yloc, zloc,
6398                       new TGeoRotation("", 0,-kTrayAZRot, 0)        ) );
6399
6400   yloc = kForwardTrayThick + coolManifPOM->GetDY();
6401   zloc = coolManifPOM->GetDZ();
6402   cableTrayA->AddNode(pomCoolManif, 1,
6403                       new TGeoTranslation( 0, yloc, zloc) );
6404
6405   yloc += coolManifPOM->GetDY() + coolManifSteel->GetDY();
6406   cableTrayA->AddNode(steelCoolManif, 1,
6407                       new TGeoTranslation( 0, yloc, zloc) );
6408
6409   yloc += coolManifSteel->GetDY() + coolManifWater->GetDY();
6410   cableTrayA->AddNode(waterCoolManif, 1,
6411                       new TGeoTranslation( 0, yloc, zloc) );
6412
6413   yloc += coolManifWater->GetDY() + coolManifAl->GetDY();
6414   cableTrayA->AddNode(alCoolManif, 1,
6415                       new TGeoTranslation( 0, yloc, zloc) );
6416
6417   cableTrayA->AddNode(purCoolTubes,1,
6418                       new TGeoCombiTrans( 0, 0, 0,
6419                       new TGeoRotation("",-90, 90, 90)        ) );
6420   cableTrayA->AddNode(waterCoolTubes,1,
6421                       new TGeoCombiTrans( 0, 0, 0,
6422                       new TGeoRotation("",-90, 90, 90)        ) );
6423   cableTrayA->AddNode(airCoolTubes,1,
6424                       new TGeoCombiTrans( 0, 0, 0,
6425                       new TGeoRotation("",-90, 90, 90)        ) );
6426
6427   xloc = coolManifPOM->GetDX() + optConnPBT->GetDX();
6428   yloc = kForwardTrayThick + optConnPBT->GetDY();
6429   zloc = optConnPBT->GetDZ();
6430   cableTrayA->AddNode(pbtOptConn, 1,
6431                       new TGeoTranslation( xloc, yloc, zloc) );
6432   cableTrayA->AddNode(pbtOptConn, 2,
6433                       new TGeoTranslation(-xloc, yloc, zloc) );
6434
6435   yloc += optConnPBT->GetDY() + optConnSteel->GetDY();
6436   cableTrayA->AddNode(steelOptConn, 1,
6437                       new TGeoTranslation( xloc, yloc, zloc) );
6438   cableTrayA->AddNode(steelOptConn, 2,
6439                       new TGeoTranslation(-xloc, yloc, zloc) );
6440
6441   yloc += optConnSteel->GetDY() + optConnAl->GetDY();
6442   cableTrayA->AddNode(alOptConn, 1,
6443                       new TGeoTranslation( xloc, yloc, zloc) );
6444   cableTrayA->AddNode(alOptConn, 2,
6445                       new TGeoTranslation(-xloc, yloc, zloc) );
6446
6447
6448   xloc = kSideACoolTubesWide/2 + kSideAOptFibsWide/2;
6449   cableTrayA->AddNode(optFibs,1,
6450                       new TGeoCombiTrans( xloc, 0, 0,
6451                       new TGeoRotation("",-90, 90, 90)        ) );
6452   cableTrayA->AddNode(optFibs,2,
6453                       new TGeoCombiTrans(-xloc, 0, 0,
6454                       new TGeoRotation("",-90, 90, 90)        ) );
6455
6456   yloc = kForwardTrayTotalHeight - forwardCover->GetY(3) -
6457          kSideAInputCablesYTrans - inputCabsPOLYAX->GetDY();
6458   zloc = inputCabsPOLYAX->GetDZ();
6459   cableTrayA->AddNode(polyaxInputCabs, 1,
6460                       new TGeoTranslation( 0, yloc, zloc) );
6461
6462   yloc -= (inputCabsPOLYAX->GetDY() + inputCabsKapton->GetDY());
6463   cableTrayA->AddNode(kaptonInputCabs, 1,
6464                       new TGeoTranslation( 0, yloc, zloc) );
6465
6466   yloc -= (inputCabsKapton->GetDY() + inputCabsAl->GetDY());
6467   cableTrayA->AddNode(alInputCabs, 1,
6468                       new TGeoTranslation( 0, yloc, zloc) );
6469
6470   yloc -= (inputCabsAl->GetDY() + inputCabsPlast->GetDY());
6471   cableTrayA->AddNode(plastInputCabs, 1,
6472                       new TGeoTranslation( 0, yloc, zloc) );
6473
6474   yloc -= (inputCabsPlast->GetDY() + inputCabsCu->GetDY());
6475   cableTrayA->AddNode(cuInputCabs, 1,
6476                       new TGeoTranslation( 0, yloc, zloc) );
6477
6478   yloc -= (inputCabsCu->GetDY()+pcbBoardsPPS->GetDY()+kSideAPCBBoardsYTrans);
6479   zloc += pcbBoardsPPS->GetDZ();
6480   cableTrayA->AddNode(ppsPCBBoards, 1,
6481                       new TGeoTranslation( 0, yloc, zloc) );
6482
6483   yloc -= (pcbBoardsPPS->GetDY()+pcbBoardsSteel->GetDY());
6484   cableTrayA->AddNode(steelPCBBoards, 1,
6485                       new TGeoTranslation( 0, yloc, zloc) );
6486
6487   yloc -= (pcbBoardsSteel->GetDY()+pcbBoardsPlast->GetDY());
6488   cableTrayA->AddNode(plastPCBBoards, 1,
6489                       new TGeoTranslation( 0, yloc, zloc) );
6490
6491   yloc -= (pcbBoardsPlast->GetDY()+pcbBoardsEpoxy->GetDY());
6492   cableTrayA->AddNode(epoxyPCBBoards, 1,
6493                       new TGeoTranslation( 0, yloc, zloc) );
6494
6495   yloc -= (pcbBoardsEpoxy->GetDY()+pcbBoardsCu->GetDY());
6496   cableTrayA->AddNode(cuPCBBoards, 1,
6497                       new TGeoTranslation( 0, yloc, zloc) );
6498
6499   cableTrayA->AddNode(cuOutputCabs,1,
6500                       new TGeoCombiTrans( 0, 0, 0,
6501                       new TGeoRotation("",-90, 90, 90)        ) );
6502   cableTrayA->AddNode(plastOutputCabs,1,
6503                       new TGeoCombiTrans( 0, 0, 0,
6504                       new TGeoRotation("",-90, 90, 90)        ) );
6505   cableTrayA->AddNode(alOutputCabs,1,
6506                       new TGeoCombiTrans( 0, 0, 0,
6507                       new TGeoRotation("",-90, 90, 90)        ) );
6508   cableTrayA->AddNode(kaptonOutputCabs,1,
6509                       new TGeoCombiTrans( 0, 0, 0,
6510                       new TGeoRotation("",-90, 90, 90)        ) );
6511   cableTrayA->AddNode(polyaxOutputCabs,1,
6512                       new TGeoCombiTrans( 0, 0, 0,
6513                       new TGeoRotation("",-90, 90, 90)        ) );
6514
6515
6516   // Finally put everything in the mother volume
6517   Double_t rforw = kTrayARTrans + kExternTrayTotalHeight +
6518                    kExternCoverSideThick -
6519                    kForwardTrayTailHeight;
6520
6521   alpharot = -kTrayAFirstRotAng;
6522   xloc = rforw*SinD(alpharot);
6523   yloc = rforw*CosD(alpharot);
6524   zloc = kTrayAZTrans + kTrayAZToSupportRing - kForwardTrayUpperLength;
6525
6526   moth->AddNode(cableTrayA,1,
6527                             new TGeoCombiTrans( xloc, yloc, zloc,
6528                             new TGeoRotation("",-alpharot,0,0)   )   );
6529
6530   alpharot += 180;
6531   xloc = rforw*SinD(alpharot);
6532   yloc = rforw*CosD(alpharot);
6533   moth->AddNode(cableTrayA,2,
6534                             new TGeoCombiTrans( xloc, yloc, zloc,
6535                             new TGeoRotation("",-alpharot,0,0)   )   );
6536
6537   alpharot = kTrayAFirstRotAng + 2*kTrayASecondRotAng;
6538   xloc = rforw*SinD(alpharot);
6539   yloc = rforw*CosD(alpharot);
6540   moth->AddNode(cableTrayA,3,
6541                             new TGeoCombiTrans( xloc, yloc, zloc,
6542                             new TGeoRotation("",-alpharot,0,0)   )   );
6543
6544   alpharot += 180;
6545   xloc = rforw*SinD(alpharot);
6546   yloc = rforw*CosD(alpharot);
6547   moth->AddNode(cableTrayA,4,
6548                             new TGeoCombiTrans( xloc, yloc, zloc,
6549                             new TGeoRotation("",-alpharot,0,0)   )   );
6550
6551
6552   return;
6553 }
6554
6555 //______________________________________________________________________
6556 void AliITSv11GeometrySupport::SDDCableTraysSideC(TGeoVolume *moth,
6557                                             const TGeoManager *mgr){
6558 //
6559 // Creates the SDD cable trays which are outside the ITS support cones
6560 // but still inside the TPC on Side C
6561 // (part of this code is taken or anyway inspired to ServicesCableSupport
6562 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
6563 //
6564 // Input:
6565 //         moth : the TGeoVolume owing the volume structure
6566 //         mgr  : the GeoManager (default gGeoManager)
6567 // Output:
6568 //
6569 // Created:         ???       Bjorn S. Nilsen
6570 // Updated:      17 Apr 2010  Mario Sitta
6571 //
6572 // Technical data are taken from AutoCAD drawings and other (oral)
6573 // information given by F.Tosello
6574 //
6575
6576   // Dimensions and positions of the C-Side Cable Tray
6577   // (Change accordingly to CreateSDDSSDTraysSideC !)
6578   const Int_t    kNumTraySideC           =    4;
6579
6580   const Double_t kSideCHalfThick         =    0.100   *fgkcm;
6581   const Double_t kSideCLength1           =  172.800   *fgkcm;
6582   const Double_t kSideCLength2           =  189.300   *fgkcm;
6583   const Double_t kBarCoolRmax            =    0.4     *fgkcm;
6584   const Double_t kXShiftBarCool          =   13.00    *fgkcm;
6585
6586   const Double_t kSideCFoldAngle         =    5.00 *fgkDegree;
6587
6588   // Dimensions and positions of the Cable Tray elements
6589   const Double_t kSideCCoolManifHalfX    =    4.25    *fgkcm;
6590   const Double_t kSideCCoolManifHalfY    =    4.03    *fgkcm;
6591   const Double_t kSideCCoolManifHalfZ    =    2.17    *fgkcm;
6592   const Double_t kSideCCoolManifPOMFrac  =    0.0051;
6593   const Double_t kSideCCoolManifSteelFrac=    0.8502;
6594   const Double_t kSideCCoolManifWaterFrac=    0.0868;
6595   const Double_t kSideCCoolManifAlFrac   =    0.0579;
6596
6597   const Double_t kSideCCoolTubesHigh     =    1.88    *fgkcm;
6598   const Double_t kSideCCoolTubesTrans    =    0.85    *fgkcm;
6599   const Double_t kSideCCoolTubesPURFrac  =    0.5884;
6600   const Double_t kSideCCoolTubesWaterFrac=    0.4114;
6601   const Double_t kSideCCoolTubesAirFrac  =    0.0002;
6602
6603   const Double_t kSideCOptConnHalfX      =    0.90    *fgkcm;
6604   const Double_t kSideCOptConnHalfZ      =    1.37    *fgkcm;
6605   const Double_t kSideCOptConnPBTFrac    =    0.6798;
6606   const Double_t kSideCOptConnSteelFrac  =    0.2421;
6607   const Double_t kSideCOptConnAlFrac     =    0.0781;
6608
6609   const Double_t kSideCOptFibsWide       =    0.71    *fgkcm;
6610   const Double_t kSideCOptFibsHigh       =    3.20    *fgkcm;
6611   const Double_t kSideCOptFibsTrans      =    0.20    *fgkcm;
6612
6613   const Double_t kSideCInputCablesLen    =   31.45    *fgkcm;
6614   const Double_t kSideCInputCablesWide   =   12.50    *fgkcm;
6615   const Double_t kSideCInputCablesHigh   =    0.95    *fgkcm;
6616   const Double_t kSideCInputCablesTrans  =    1.15    *fgkcm;
6617   const Double_t kSideCInputCablesCu     =    0.7405;
6618   const Double_t kSideCInputCablesPlast  =    0.1268;
6619   const Double_t kSideCInputCablesAl     =    0.0057;
6620   const Double_t kSideCInputCablesKapton =    0.0172;
6621   const Double_t kSideCInputCablesPOLYAX =    0.1098;
6622
6623   const Double_t kSideCOutputCablesX0    =   27.40    *fgkcm;
6624   const Double_t kSideCOutputCablesWide  =    8.50    *fgkcm;
6625   const Double_t kSideCOutputCablesHigh  =    1.18    *fgkcm;
6626   const Double_t kSideCOutputCablesCu    =    0.6775;
6627   const Double_t kSideCOutputCablesPlast =    0.1613;
6628   const Double_t kSideCOutputCablesAl    =    0.0078;
6629   const Double_t kSideCOutputCablesKapton=    0.0234;
6630   const Double_t kSideCOutputCablesPOLYAX=    0.1300;
6631
6632   const Double_t kSideCPCBBoardsHalfX    =    6.30    *fgkcm;
6633   const Double_t kSideCPCBBoardsHalfY    =    2.00    *fgkcm;
6634   const Double_t kSideCPCBBoardsHalfZ    =   21.93    *fgkcm;
6635   const Double_t kSideCPCBBoardsCu       =    0.3864;
6636   const Double_t kSideCPCBBoardsEpoxy    =    0.1491;
6637   const Double_t kSideCPCBBoardsPlast    =    0.0579;
6638   const Double_t kSideCPCBBoardsSteel    =    0.1517;
6639   const Double_t kSideCPCBBoardsPPS      =    0.2549;
6640
6641   // Overall position and rotation of the C-Side Cable Trays
6642   const Double_t kTraySideCRPos          =   45.30    *fgkcm;
6643   const Double_t kTraySideCZPos          = -102.40    *fgkcm;
6644   const Double_t kTraySideCAlphaRot[kNumTraySideC]  = {    -23.0,      59.0,
6645     /* from SSD tray position */                       180.-23.0, 180.+59.0};
6646
6647
6648   // Local variables
6649   Double_t xprof[6], yprof[6];
6650   Double_t height, xloc, yloc, zloc, alpharot, alphafold;
6651
6652
6653   // The assembly holding the metallic structure
6654   TGeoVolumeAssembly *trayStructure = CreateSDDSSDTraysSideC("ITSsupportSDDTrayC");
6655
6656   // Now the volumes inside it
6657   // The cooling manifold: four boxes
6658   // (X and Z are inverted on tray reference system)
6659   TGeoBBox *coolManifPOM = new TGeoBBox(kSideCCoolManifHalfZ,
6660                  kSideCCoolManifPOMFrac*kSideCCoolManifHalfY,
6661                                         kSideCCoolManifHalfX);
6662
6663   TGeoBBox *coolManifSteel = new TGeoBBox(kSideCCoolManifHalfZ,
6664                  kSideCCoolManifSteelFrac*kSideCCoolManifHalfY,
6665                                           kSideCCoolManifHalfX);
6666
6667   TGeoBBox *coolManifWater = new TGeoBBox(kSideCCoolManifHalfZ,
6668                  kSideCCoolManifWaterFrac*kSideCCoolManifHalfY,
6669                                           kSideCCoolManifHalfX);
6670
6671   TGeoBBox *coolManifAl = new TGeoBBox(kSideCCoolManifHalfZ,
6672                  kSideCCoolManifAlFrac*kSideCCoolManifHalfY,
6673                                        kSideCCoolManifHalfX);
6674
6675   // The cooling tubes: three Xtru's
6676   alpharot = kSideCFoldAngle*TMath::DegToRad();
6677
6678   TGeoXtru *coolTubesPUR = new TGeoXtru(2);
6679
6680   height = kSideCCoolTubesHigh*kSideCCoolTubesPURFrac;
6681
6682   xprof[0] = 2*kSideCCoolManifHalfZ;
6683   yprof[0] = 2*kSideCHalfThick + kSideCCoolTubesTrans;
6684   xprof[1] = kSideCLength1;
6685   yprof[1] = yprof[0];
6686   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(alpharot);
6687   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(alpharot);
6688   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6689   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6690   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6691               height, xprof[4], yprof[4]);
6692   xprof[5] = xprof[0];
6693   yprof[5] = yprof[0] + height;
6694
6695   coolTubesPUR->DefinePolygon(6, xprof, yprof);
6696   coolTubesPUR->DefineSection(0,-kSideCCoolManifHalfX);
6697   coolTubesPUR->DefineSection(1, kSideCCoolManifHalfX);
6698
6699   TGeoXtru *coolTubesWater = new TGeoXtru(2);
6700
6701   height = kSideCCoolTubesHigh*kSideCCoolTubesWaterFrac;
6702
6703   xprof[0] = coolTubesPUR->GetX(5);
6704   yprof[0] = coolTubesPUR->GetY(5);
6705   xprof[1] = coolTubesPUR->GetX(4);
6706   yprof[1] = coolTubesPUR->GetY(4);
6707   xprof[2] = coolTubesPUR->GetX(3);
6708   yprof[2] = coolTubesPUR->GetY(3);
6709   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6710   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6711   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6712               height, xprof[4], yprof[4]);
6713   xprof[5] = xprof[0];
6714   yprof[5] = yprof[0] + height;
6715
6716   coolTubesWater->DefinePolygon(6, xprof, yprof);
6717   coolTubesWater->DefineSection(0,-kSideCCoolManifHalfX);
6718   coolTubesWater->DefineSection(1, kSideCCoolManifHalfX);
6719
6720   TGeoXtru *coolTubesAir = new TGeoXtru(2);
6721
6722   height = kSideCCoolTubesHigh*kSideCCoolTubesAirFrac;
6723
6724   xprof[0] = coolTubesWater->GetX(5);
6725   yprof[0] = coolTubesWater->GetY(5);
6726   xprof[1] = coolTubesWater->GetX(4);
6727   yprof[1] = coolTubesWater->GetY(4);
6728   xprof[2] = coolTubesWater->GetX(3);
6729   yprof[2] = coolTubesWater->GetY(3);
6730   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6731   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6732   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6733               height, xprof[4], yprof[4]);
6734   xprof[5] = xprof[0];
6735   yprof[5] = yprof[0] + height;
6736
6737   coolTubesAir->DefinePolygon(6, xprof, yprof);
6738   coolTubesAir->DefineSection(0,-kSideCCoolManifHalfX);
6739   coolTubesAir->DefineSection(1, kSideCCoolManifHalfX);
6740
6741   // The optical fiber connectors: three boxes
6742   // (X and Z are inverted on tray reference system)
6743   TGeoBBox *optConnPBT = new TGeoBBox(kSideCOptConnHalfZ,
6744                  kSideCOptConnPBTFrac*kSideCCoolManifHalfY,
6745                                       kSideCOptConnHalfX);
6746
6747   TGeoBBox *optConnSteel = new TGeoBBox(kSideCOptConnHalfZ,
6748                  kSideCOptConnSteelFrac*kSideCCoolManifHalfY,
6749                                         kSideCOptConnHalfX);
6750
6751   TGeoBBox *optConnAl = new TGeoBBox(kSideCOptConnHalfZ,
6752                  kSideCOptConnAlFrac*kSideCCoolManifHalfY,
6753                                      kSideCOptConnHalfX);
6754
6755   // The optical fibers: a Xtru
6756   TGeoXtru *opticalFibs = new TGeoXtru(2);
6757
6758   xprof[0] = 2*kSideCOptConnHalfZ;
6759   yprof[0] = 2*kSideCHalfThick + kSideCOptFibsTrans;
6760   xprof[1] = kSideCLength1;
6761   yprof[1] = yprof[0];
6762   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(alpharot);
6763   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(alpharot);
6764   xprof[3] = xprof[2] - kSideCOptFibsHigh*TMath::Sin(alpharot);
6765   yprof[3] = yprof[2] + kSideCOptFibsHigh*TMath::Cos(alpharot);
6766   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6767               kSideCOptFibsHigh, xprof[4], yprof[4]);
6768   xprof[5] = xprof[0];
6769   yprof[5] = yprof[0] + kSideCOptFibsHigh;
6770
6771   opticalFibs->DefinePolygon(6, xprof, yprof);
6772   opticalFibs->DefineSection(0,-kSideCOptFibsWide/2);
6773   opticalFibs->DefineSection(1, kSideCOptFibsWide/2);
6774
6775   // The input cables: five boxes
6776   // (X and Z are inverted on tray reference system)
6777   TGeoBBox *inputCabsCu = new TGeoBBox(kSideCInputCablesLen/2,
6778                    kSideCInputCablesCu*kSideCInputCablesHigh/2,
6779                                        kSideCInputCablesWide/2);
6780
6781   TGeoBBox *inputCabsPlast = new TGeoBBox(kSideCInputCablesLen/2,
6782                    kSideCInputCablesPlast*kSideCInputCablesHigh/2,
6783                                           kSideCInputCablesWide/2);
6784
6785   TGeoBBox *inputCabsAl = new TGeoBBox(kSideCInputCablesLen/2,
6786                    kSideCInputCablesAl*kSideCInputCablesHigh/2,
6787                                        kSideCInputCablesWide/2);
6788
6789   TGeoBBox *inputCabsKapton = new TGeoBBox(kSideCInputCablesLen/2,
6790                    kSideCInputCablesKapton*kSideCInputCablesHigh/2,
6791                                            kSideCInputCablesWide/2);
6792
6793   TGeoBBox *inputCabsPOLYAX = new TGeoBBox(kSideCInputCablesLen/2,
6794                    kSideCInputCablesPOLYAX*kSideCInputCablesHigh/2,
6795                                            kSideCInputCablesWide/2);
6796
6797   // The output cables: five Xtru
6798   TGeoXtru *outputCabsCu = new TGeoXtru(2);
6799
6800   height = kSideCOutputCablesCu*kSideCOutputCablesHigh;
6801
6802   xprof[0] = coolTubesAir->GetX(5) + kSideCOutputCablesX0;
6803   yprof[0] = coolTubesAir->GetY(5);
6804   xprof[1] = coolTubesAir->GetX(4);
6805   yprof[1] = coolTubesAir->GetY(4);
6806   xprof[2] = coolTubesAir->GetX(3);
6807   yprof[2] = coolTubesAir->GetY(3);
6808   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6809   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6810   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6811               height, xprof[4], yprof[4]);
6812   xprof[5] = xprof[0];
6813   yprof[5] = yprof[0] + height;
6814
6815   outputCabsCu->DefinePolygon(6, xprof, yprof);
6816   outputCabsCu->DefineSection(0,-kSideCOutputCablesWide/2);
6817   outputCabsCu->DefineSection(1, kSideCOutputCablesWide/2);
6818
6819   TGeoXtru *outputCabsPlast = new TGeoXtru(2);
6820
6821   height = kSideCOutputCablesPlast*kSideCOutputCablesHigh;
6822
6823   xprof[0] = outputCabsCu->GetX(5);
6824   yprof[0] = outputCabsCu->GetY(5);
6825   xprof[1] = outputCabsCu->GetX(4);
6826   yprof[1] = outputCabsCu->GetY(4);
6827   xprof[2] = outputCabsCu->GetX(3);
6828   yprof[2] = outputCabsCu->GetY(3);
6829   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6830   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6831   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6832               height, xprof[4], yprof[4]);
6833   xprof[5] = xprof[0];
6834   yprof[5] = yprof[0] + height;
6835
6836   outputCabsPlast->DefinePolygon(6, xprof, yprof);
6837   outputCabsPlast->DefineSection(0,-kSideCOutputCablesWide/2);
6838   outputCabsPlast->DefineSection(1, kSideCOutputCablesWide/2);
6839
6840   TGeoXtru *outputCabsAl = new TGeoXtru(2);
6841
6842   height = kSideCOutputCablesAl*kSideCOutputCablesHigh;
6843
6844   xprof[0] = outputCabsPlast->GetX(5);
6845   yprof[0] = outputCabsPlast->GetY(5);
6846   xprof[1] = outputCabsPlast->GetX(4);
6847   yprof[1] = outputCabsPlast->GetY(4);
6848   xprof[2] = outputCabsPlast->GetX(3);
6849   yprof[2] = outputCabsPlast->GetY(3);
6850   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6851   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6852   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6853               height, xprof[4], yprof[4]);
6854   xprof[5] = xprof[0];
6855   yprof[5] = yprof[0] + height;
6856
6857   outputCabsAl->DefinePolygon(6, xprof, yprof);
6858   outputCabsAl->DefineSection(0,-kSideCOutputCablesWide/2);
6859   outputCabsAl->DefineSection(1, kSideCOutputCablesWide/2);
6860
6861   TGeoXtru *outputCabsKapton = new TGeoXtru(2);
6862
6863   height = kSideCOutputCablesKapton*kSideCOutputCablesHigh;
6864
6865   xprof[0] = outputCabsAl->GetX(5);
6866   yprof[0] = outputCabsAl->GetY(5);
6867   xprof[1] = outputCabsAl->GetX(4);
6868   yprof[1] = outputCabsAl->GetY(4);
6869   xprof[2] = outputCabsAl->GetX(3);
6870   yprof[2] = outputCabsAl->GetY(3);
6871   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6872   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6873   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6874               height, xprof[4], yprof[4]);
6875   xprof[5] = xprof[0];
6876   yprof[5] = yprof[0] + height;
6877
6878   outputCabsKapton->DefinePolygon(6, xprof, yprof);
6879   outputCabsKapton->DefineSection(0,-kSideCOutputCablesWide/2);
6880   outputCabsKapton->DefineSection(1, kSideCOutputCablesWide/2);
6881
6882   TGeoXtru *outputCabsPOLYAX = new TGeoXtru(2);
6883
6884   height = kSideCOutputCablesPOLYAX*kSideCOutputCablesHigh;
6885
6886   xprof[0] = outputCabsKapton->GetX(5);
6887   yprof[0] = outputCabsKapton->GetY(5);
6888   xprof[1] = outputCabsKapton->GetX(4);
6889   yprof[1] = outputCabsKapton->GetY(4);
6890   xprof[2] = outputCabsKapton->GetX(3);
6891   yprof[2] = outputCabsKapton->GetY(3);
6892   xprof[3] = xprof[2] - height*TMath::Sin(alpharot);
6893   yprof[3] = yprof[2] + height*TMath::Cos(alpharot);
6894   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
6895               height, xprof[4], yprof[4]);
6896   xprof[5] = xprof[0];
6897   yprof[5] = yprof[0] + height;
6898
6899   outputCabsPOLYAX->DefinePolygon(6, xprof, yprof);
6900   outputCabsPOLYAX->DefineSection(0,-kSideCOutputCablesWide/2);
6901   outputCabsPOLYAX->DefineSection(1, kSideCOutputCablesWide/2);
6902
6903   // The PCB boards: five boxes
6904   // (X and Z are inverted on tray reference system)
6905   TGeoBBox *pcbBoardsCu = new TGeoBBox(kSideCPCBBoardsHalfZ,
6906                      kSideCPCBBoardsCu*kSideCPCBBoardsHalfY,
6907                                        kSideCPCBBoardsHalfX);
6908
6909   TGeoBBox *pcbBoardsEpoxy = new TGeoBBox(kSideCPCBBoardsHalfZ,
6910                      kSideCPCBBoardsEpoxy*kSideCPCBBoardsHalfY,
6911                                           kSideCPCBBoardsHalfX);
6912
6913   TGeoBBox *pcbBoardsPlast = new TGeoBBox(kSideCPCBBoardsHalfZ,
6914                      kSideCPCBBoardsPlast*kSideCPCBBoardsHalfY,
6915                                           kSideCPCBBoardsHalfX);
6916
6917   TGeoBBox *pcbBoardsSteel = new TGeoBBox(kSideCPCBBoardsHalfZ,
6918                      kSideCPCBBoardsSteel*kSideCPCBBoardsHalfY,
6919                                           kSideCPCBBoardsHalfX);
6920
6921   TGeoBBox *pcbBoardsPPS = new TGeoBBox(kSideCPCBBoardsHalfZ,
6922                      kSideCPCBBoardsPPS*kSideCPCBBoardsHalfY,
6923                                         kSideCPCBBoardsHalfX);
6924
6925
6926   // We have all shapes: now create the real volumes
6927   TGeoMedium *medPOM    = mgr->GetMedium("ITS_POLYOXYMETHYLENE$");
6928   TGeoMedium *medSteel  = mgr->GetMedium("ITS_INOX$");
6929   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
6930   TGeoMedium *medAl     = mgr->GetMedium("ITS_ALUMINUM$");
6931   TGeoMedium *medCu     = mgr->GetMedium("ITS_COPPER$");
6932   TGeoMedium *medPUR    = mgr->GetMedium("ITS_POLYURETHANE$");
6933   TGeoMedium *medPOLYAX = mgr->GetMedium("ITS_POLYAX$");
6934   TGeoMedium *medKapton = mgr->GetMedium("ITS_SDDKAPTON (POLYCH2)$");
6935   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
6936   TGeoMedium *medPBT    = mgr->GetMedium("ITS_PBT$");
6937   TGeoMedium *medOptFib = mgr->GetMedium("ITS_SDD OPTICFIB$");
6938   TGeoMedium *medPPS    = mgr->GetMedium("ITS_PPS$");
6939   TGeoMedium *medEpoxy  = mgr->GetMedium("ITS_EPOXY$");
6940
6941   TGeoVolume *pomCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifPOM",
6942                                             coolManifPOM, medPOM);
6943
6944   pomCoolManif->SetVisibility(kTRUE);
6945   pomCoolManif->SetLineColor(kRed); // Red
6946   pomCoolManif->SetLineWidth(1);
6947   pomCoolManif->SetFillColor(pomCoolManif->GetLineColor());
6948   pomCoolManif->SetFillStyle(4000); // 0% transparent
6949
6950   TGeoVolume *steelCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifSteel",
6951                                               coolManifSteel, medSteel);
6952
6953   steelCoolManif->SetVisibility(kTRUE);
6954   steelCoolManif->SetLineColor(kBlue); // Blue
6955   steelCoolManif->SetLineWidth(1);
6956   steelCoolManif->SetFillColor(steelCoolManif->GetLineColor());
6957   steelCoolManif->SetFillStyle(4000); // 0% transparent
6958
6959   TGeoVolume *waterCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifWater",
6960                                               coolManifWater, medWater);
6961
6962   waterCoolManif->SetVisibility(kTRUE);
6963   waterCoolManif->SetLineColor(33); // Light Blue
6964   waterCoolManif->SetLineWidth(1);
6965   waterCoolManif->SetFillColor(waterCoolManif->GetLineColor());
6966   waterCoolManif->SetFillStyle(4000); // 0% transparent
6967
6968   TGeoVolume *alCoolManif = new TGeoVolume("ITSsuppSDDSideCCoolManifAl",
6969                                            coolManifAl, medAl);
6970
6971   alCoolManif->SetVisibility(kTRUE);
6972   alCoolManif->SetLineColor(6); // Purple
6973   alCoolManif->SetLineWidth(1);
6974   alCoolManif->SetFillColor(alCoolManif->GetLineColor());
6975   alCoolManif->SetFillStyle(4000); // 0% transparent
6976
6977   TGeoVolume *purCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesPUR",
6978                                             coolTubesPUR, medPUR);
6979
6980   purCoolTubes->SetVisibility(kTRUE);
6981   purCoolTubes->SetLineColor(kRed); // Red
6982   purCoolTubes->SetLineWidth(1);
6983   purCoolTubes->SetFillColor(purCoolTubes->GetLineColor());
6984   purCoolTubes->SetFillStyle(4000); // 0% transparent
6985
6986   TGeoVolume *waterCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesWater",
6987                                               coolTubesWater, medWater);
6988
6989   waterCoolTubes->SetVisibility(kTRUE);
6990   waterCoolTubes->SetLineColor(33); // Light Blue
6991   waterCoolTubes->SetLineWidth(1);
6992   waterCoolTubes->SetFillColor(waterCoolTubes->GetLineColor());
6993   waterCoolTubes->SetFillStyle(4000); // 0% transparent
6994
6995   TGeoVolume *airCoolTubes = new TGeoVolume("ITSsuppSDDSideCCoolTubesAir",
6996                                             coolTubesAir, medAir);
6997
6998   airCoolTubes->SetVisibility(kTRUE);
6999   airCoolTubes->SetLineColor(41);
7000   airCoolTubes->SetLineWidth(1);
7001   airCoolTubes->SetFillColor(airCoolTubes->GetLineColor());
7002   airCoolTubes->SetFillStyle(4000); // 0% transparent
7003
7004   TGeoVolume *pbtOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnPBT",
7005                                           optConnPBT, medPBT);
7006
7007   pbtOptConn->SetVisibility(kTRUE);
7008   pbtOptConn->SetLineColor(kRed); // Red
7009   pbtOptConn->SetLineWidth(1);
7010   pbtOptConn->SetFillColor(pbtOptConn->GetLineColor());
7011   pbtOptConn->SetFillStyle(4000); // 0% transparent
7012
7013   TGeoVolume *steelOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnSteel",
7014                                             optConnSteel, medSteel);
7015
7016   steelOptConn->SetVisibility(kTRUE);
7017   steelOptConn->SetLineColor(kBlue); // Blue
7018   steelOptConn->SetLineWidth(1);
7019   steelOptConn->SetFillColor(steelOptConn->GetLineColor());
7020   steelOptConn->SetFillStyle(4000); // 0% transparent
7021
7022   TGeoVolume *alOptConn = new TGeoVolume("ITSsuppSDDSideCOptConnAl",
7023                                          optConnAl, medAl);
7024
7025   alOptConn->SetVisibility(kTRUE);
7026   alOptConn->SetLineColor(6); // Purple
7027   alOptConn->SetLineWidth(1);
7028   alOptConn->SetFillColor(alOptConn->GetLineColor());
7029   alOptConn->SetFillStyle(4000); // 0% transparent
7030
7031   TGeoVolume *optFibs = new TGeoVolume("ITSsuppSDDSideCOptFibs",
7032                                        opticalFibs, medOptFib);
7033
7034   optFibs->SetVisibility(kTRUE);
7035   optFibs->SetLineColor(kOrange+2); // Orange
7036   optFibs->SetLineWidth(1);
7037   optFibs->SetFillColor(optFibs->GetLineColor());
7038   optFibs->SetFillStyle(4000); // 0% transparent
7039
7040   TGeoVolume *cuInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsCu",
7041                                            inputCabsCu, medCu);
7042
7043   cuInputCabs->SetVisibility(kTRUE);
7044   cuInputCabs->SetLineColor(kBlack); // Black
7045   cuInputCabs->SetLineWidth(1);
7046   cuInputCabs->SetFillColor(cuInputCabs->GetLineColor());
7047   cuInputCabs->SetFillStyle(4000); // 0% transparent
7048
7049   TGeoVolume *plastInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsPlast",
7050                                               inputCabsPlast, medPUR);
7051
7052   plastInputCabs->SetVisibility(kTRUE);
7053   plastInputCabs->SetLineColor(kRed); // Red
7054   plastInputCabs->SetLineWidth(1);
7055   plastInputCabs->SetFillColor(plastInputCabs->GetLineColor());
7056   plastInputCabs->SetFillStyle(4000); // 0% transparent
7057
7058   TGeoVolume *alInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsAl",
7059                                            inputCabsAl, medAl);
7060
7061   alInputCabs->SetVisibility(kTRUE);
7062   alInputCabs->SetLineColor(6); // Purple
7063   alInputCabs->SetLineWidth(1);
7064   alInputCabs->SetFillColor(alInputCabs->GetLineColor());
7065   alInputCabs->SetFillStyle(4000); // 0% transparent
7066
7067   TGeoVolume *kaptonInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsKapton",
7068                                                inputCabsKapton, medKapton);
7069
7070   kaptonInputCabs->SetVisibility(kTRUE);
7071   kaptonInputCabs->SetLineColor(14); // 
7072   kaptonInputCabs->SetLineWidth(1);
7073   kaptonInputCabs->SetFillColor(kaptonInputCabs->GetLineColor());
7074   kaptonInputCabs->SetFillStyle(4000); // 0% transparent
7075
7076   TGeoVolume *polyaxInputCabs = new TGeoVolume("ITSsuppSDDSideCInputCabsPOLYAX",
7077                                                inputCabsPOLYAX, medPOLYAX);
7078
7079   polyaxInputCabs->SetVisibility(kTRUE);
7080   polyaxInputCabs->SetLineColor(34); // 
7081   polyaxInputCabs->SetLineWidth(1);
7082   polyaxInputCabs->SetFillColor(polyaxInputCabs->GetLineColor());
7083   polyaxInputCabs->SetFillStyle(4000); // 0% transparent
7084
7085   TGeoVolume *cuOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsCu",
7086                                             outputCabsCu, medCu);
7087
7088   cuOutputCabs->SetVisibility(kTRUE);
7089   cuOutputCabs->SetLineColor(kBlack); // Black
7090   cuOutputCabs->SetLineWidth(1);
7091   cuOutputCabs->SetFillColor(cuOutputCabs->GetLineColor());
7092   cuOutputCabs->SetFillStyle(4000); // 0% transparent
7093
7094   TGeoVolume *plastOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsPlast",
7095                                                outputCabsPlast, medPUR);
7096
7097   plastOutputCabs->SetVisibility(kTRUE);
7098   plastOutputCabs->SetLineColor(kRed); // Red
7099   plastOutputCabs->SetLineWidth(1);
7100   plastOutputCabs->SetFillColor(plastOutputCabs->GetLineColor());
7101   plastOutputCabs->SetFillStyle(4000); // 0% transparent
7102
7103   TGeoVolume *alOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsAl",
7104                                             outputCabsAl, medAl);
7105
7106   alOutputCabs->SetVisibility(kTRUE);
7107   alOutputCabs->SetLineColor(6); // Purple
7108   alOutputCabs->SetLineWidth(1);
7109   alOutputCabs->SetFillColor(alOutputCabs->GetLineColor());
7110   alOutputCabs->SetFillStyle(4000); // 0% transparent
7111
7112   TGeoVolume *kaptonOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsKapton",
7113                                                 outputCabsKapton, medKapton);
7114
7115   kaptonOutputCabs->SetVisibility(kTRUE);
7116   kaptonOutputCabs->SetLineColor(14); // 
7117   kaptonOutputCabs->SetLineWidth(1);
7118   kaptonOutputCabs->SetFillColor(kaptonOutputCabs->GetLineColor());
7119   kaptonOutputCabs->SetFillStyle(4000); // 0% transparent
7120
7121   TGeoVolume *polyaxOutputCabs = new TGeoVolume("ITSsuppSDDSideCOutputCabsPOLYAX",
7122                                                 outputCabsPOLYAX, medPOLYAX);
7123
7124   polyaxOutputCabs->SetVisibility(kTRUE);
7125   polyaxOutputCabs->SetLineColor(34); // 
7126   polyaxOutputCabs->SetLineWidth(1);
7127   polyaxOutputCabs->SetFillColor(polyaxOutputCabs->GetLineColor());
7128   polyaxOutputCabs->SetFillStyle(4000); // 0% transparent
7129
7130   TGeoVolume *cuPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsCu",
7131                                            pcbBoardsCu, medCu);
7132
7133   cuPCBBoards->SetVisibility(kTRUE);
7134   cuPCBBoards->SetLineColor(kBlack); // Black
7135   cuPCBBoards->SetLineWidth(1);
7136   cuPCBBoards->SetFillColor(cuPCBBoards->GetLineColor());
7137   cuPCBBoards->SetFillStyle(4000); // 0% transparent
7138
7139   TGeoVolume *epoxyPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsEpoxy",
7140                                               pcbBoardsEpoxy, medEpoxy);
7141
7142   epoxyPCBBoards->SetVisibility(kTRUE);
7143   epoxyPCBBoards->SetLineColor(22); //
7144   epoxyPCBBoards->SetLineWidth(1);
7145   epoxyPCBBoards->SetFillColor(epoxyPCBBoards->GetLineColor());
7146   epoxyPCBBoards->SetFillStyle(4000); // 0% transparent
7147
7148   TGeoVolume *plastPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsPlast",
7149                                               pcbBoardsPlast, medPUR);
7150
7151   plastPCBBoards->SetVisibility(kTRUE);
7152   plastPCBBoards->SetLineColor(kRed); // Red
7153   plastPCBBoards->SetLineWidth(1);
7154   plastPCBBoards->SetFillColor(plastPCBBoards->GetLineColor());
7155   plastPCBBoards->SetFillStyle(4000); // 0% transparent
7156
7157   TGeoVolume *steelPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsSteel",
7158                                               pcbBoardsSteel, medSteel);
7159
7160   steelPCBBoards->SetVisibility(kTRUE);
7161   steelPCBBoards->SetLineColor(kBlue); // Blue
7162   steelPCBBoards->SetLineWidth(1);
7163   steelPCBBoards->SetFillColor(steelPCBBoards->GetLineColor());
7164   steelPCBBoards->SetFillStyle(4000); // 0% transparent
7165
7166   TGeoVolume *ppsPCBBoards = new TGeoVolume("ITSsuppSDDSideCPCBBoardsPPS",
7167                                             pcbBoardsPPS, medPPS);
7168
7169   ppsPCBBoards->SetVisibility(kTRUE);
7170   ppsPCBBoards->SetLineColor(kGreen); // Green
7171   ppsPCBBoards->SetLineWidth(1);
7172   ppsPCBBoards->SetFillColor(ppsPCBBoards->GetLineColor());
7173   ppsPCBBoards->SetFillStyle(4000); // 0% transparent
7174
7175
7176   // Now fill the tray
7177   xloc = coolManifPOM->GetDX();
7178   yloc = 2*kSideCHalfThick + coolManifPOM->GetDY();
7179   trayStructure->AddNode(pomCoolManif, 1,
7180                          new TGeoTranslation( xloc, yloc, 0) );
7181
7182   yloc += coolManifPOM->GetDY() + coolManifSteel->GetDY();
7183   trayStructure->AddNode(steelCoolManif, 1,
7184                          new TGeoTranslation( xloc, yloc, 0) );
7185
7186   yloc += coolManifSteel->GetDY() + coolManifWater->GetDY();
7187   trayStructure->AddNode(waterCoolManif, 1,
7188                          new TGeoTranslation( xloc, yloc, 0) );
7189
7190   yloc += coolManifWater->GetDY() + coolManifAl->GetDY();
7191   trayStructure->AddNode(alCoolManif, 1,
7192                          new TGeoTranslation( xloc, yloc, 0) );
7193
7194   xloc = inputCabsCu->GetDX();
7195   yloc += coolManifWater->GetDY() + inputCabsCu->GetDY()
7196         + kSideCInputCablesTrans;
7197   trayStructure->AddNode(cuInputCabs, 1,
7198                          new TGeoTranslation( xloc, yloc, 0) );
7199
7200   yloc += inputCabsCu->GetDY() + inputCabsPlast->GetDY();
7201   trayStructure->AddNode(plastInputCabs, 1,
7202                          new TGeoTranslation( xloc, yloc, 0) );
7203
7204   yloc += inputCabsPlast->GetDY() + inputCabsAl->GetDY();
7205   trayStructure->AddNode(alInputCabs, 1,
7206                          new TGeoTranslation( xloc, yloc, 0) );
7207
7208   yloc += inputCabsAl->GetDY() + inputCabsKapton->GetDY();
7209   trayStructure->AddNode(kaptonInputCabs, 1,
7210                          new TGeoTranslation( xloc, yloc, 0) );
7211
7212   yloc += inputCabsKapton->GetDY() + inputCabsPOLYAX->GetDY();
7213   trayStructure->AddNode(polyaxInputCabs, 1,
7214                          new TGeoTranslation( xloc, yloc, 0) );
7215
7216   trayStructure->AddNode(purCoolTubes  , 1, 0);
7217   trayStructure->AddNode(waterCoolTubes, 1, 0);
7218   trayStructure->AddNode(airCoolTubes  , 1, 0);
7219
7220   xloc = optConnPBT->GetDX();
7221   yloc = 2*kSideCHalfThick + optConnPBT->GetDY();
7222   zloc = coolManifPOM->GetDZ() + optConnPBT->GetDZ();
7223   trayStructure->AddNode(pbtOptConn, 1,
7224                          new TGeoTranslation( xloc, yloc, zloc) );
7225   trayStructure->AddNode(pbtOptConn, 2,
7226                          new TGeoTranslation( xloc, yloc,-zloc) );
7227
7228   yloc += optConnPBT->GetDY() + optConnSteel->GetDY();
7229   trayStructure->AddNode(steelOptConn, 1,
7230                          new TGeoTranslation( xloc, yloc, zloc) );
7231   trayStructure->AddNode(steelOptConn, 2,
7232                          new TGeoTranslation( xloc, yloc,-zloc) );
7233
7234   yloc += optConnSteel->GetDY() + optConnAl->GetDY();
7235   trayStructure->AddNode(alOptConn, 1,
7236                          new TGeoTranslation( xloc, yloc, zloc) );
7237   trayStructure->AddNode(alOptConn, 2,
7238                          new TGeoTranslation( xloc, yloc,-zloc) );
7239
7240   trayStructure->AddNode(optFibs, 1,
7241                          new TGeoTranslation( 0, 0, zloc) );
7242   trayStructure->AddNode(optFibs, 2,
7243                          new TGeoTranslation( 0, 0,-zloc) );
7244
7245   trayStructure->AddNode(cuOutputCabs    , 1, 0);
7246   trayStructure->AddNode(plastOutputCabs , 1, 0);
7247   trayStructure->AddNode(alOutputCabs    , 1, 0);
7248   trayStructure->AddNode(kaptonOutputCabs, 1, 0);
7249   trayStructure->AddNode(polyaxOutputCabs, 1, 0);
7250
7251   xloc = kXShiftBarCool + kBarCoolRmax + pcbBoardsCu->GetDX();
7252   yloc = outputCabsPOLYAX->GetY(5) + pcbBoardsCu->GetDY();
7253   trayStructure->AddNode(cuPCBBoards, 1,
7254                          new TGeoTranslation( xloc, yloc , 0) );
7255
7256   yloc += pcbBoardsCu->GetDY() + pcbBoardsEpoxy->GetDY();
7257   trayStructure->AddNode(epoxyPCBBoards, 1,
7258                          new TGeoTranslation( xloc, yloc , 0) );
7259
7260   yloc += pcbBoardsEpoxy->GetDY() + pcbBoardsPlast->GetDY();
7261   trayStructure->AddNode(plastPCBBoards, 1,
7262                          new TGeoTranslation( xloc, yloc , 0) );
7263
7264   yloc += pcbBoardsPlast->GetDY() + pcbBoardsSteel->GetDY();
7265   trayStructure->AddNode(steelPCBBoards, 1,
7266                          new TGeoTranslation( xloc, yloc , 0) );
7267
7268   yloc += pcbBoardsSteel->GetDY() + pcbBoardsPPS->GetDY();
7269   trayStructure->AddNode(ppsPCBBoards, 1,
7270                          new TGeoTranslation( xloc, yloc , 0) );
7271
7272
7273   // Finally put everything in the mother volume
7274   alphafold = kSideCFoldAngle;
7275
7276   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
7277     alpharot = kTraySideCAlphaRot[jt];
7278     xloc = kTraySideCRPos*SinD(alpharot);
7279     yloc = kTraySideCRPos*CosD(alpharot);
7280     moth->AddNode(trayStructure,jt+1,
7281                        new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
7282                        new TGeoRotation("",-90.+alpharot,-90.,90.+alphafold)));
7283   }
7284
7285
7286   return;
7287 }
7288
7289
7290 //______________________________________________________________________
7291 void AliITSv11GeometrySupport::SSDCableTraysSideA(TGeoVolume *moth,
7292                                             const TGeoManager *mgr){
7293 //
7294 // Creates the SSD cable trays which are outside the ITS support cones
7295 // but still inside the TPC on Side A
7296 // (part of this code is taken or anyway inspired to ServicesCableSupport
7297 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
7298 //
7299 // Input:
7300 //         moth : the TGeoVolume owing the volume structure
7301 //         mgr  : the GeoManager (default gGeoManager)
7302 // Output:
7303 //
7304 // Created:         ???       Bjorn S. Nilsen
7305 // Updated:      30 Dec 2009  Mario Sitta
7306 //
7307 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
7308 // drawings and other (oral) information given by F.Tosello and
7309 // Ton van den Brink
7310 // Cables and cooling tubes are approximated with proper materials and
7311 // rectangular cross sections, always preserving the total material budget.
7312 //
7313
7314   // Dimensions and positions of the A-Side Cable Trays
7315   // (parts of 0872/G/D)
7316   const Double_t kTrayARTrans            =  408.35 *fgkmm;
7317   const Double_t kTrayAZTrans            = 1011.00 *fgkmm;
7318   const Double_t kForwardSideYTrans      =   12.00 *fgkmm;//!!!TO BE CHECKED!!!
7319   const Double_t kCoversYTrans           =    2.00 *fgkmm;
7320   const Double_t kTrayAZRot              = (180-169.5);// Degrees
7321   const Double_t kTrayAFirstRotAng       =   22.00;    // Degrees
7322   const Double_t kTrayASecondRotAng      =   15.00;    // Degrees
7323
7324   const Double_t kTrayTotalHeight        =   52.00 *fgkmm;
7325   const Double_t kTrayHeighToBend        =   32.00 *fgkmm;
7326   const Double_t kTrayWidth              =  130.00 *fgkmm;
7327   const Double_t kTrayThick              =    2.00 *fgkmm;
7328
7329   const Double_t kTrayBendAngle          =   22.00 *TMath::DegToRad();
7330
7331   const Double_t kForwardTrayTotalLen    =  853.00 *fgkmm;
7332   const Double_t kForwardTrayFirstLen    =  350.00 *fgkmm;
7333   const Double_t kForwardTrayFirstHeight =   47.00 *fgkmm;
7334   const Double_t kForwardCoverLen        =  420.00 *fgkmm;
7335
7336   const Double_t kForwardSideLength      = kForwardTrayFirstLen;//!!!TO BE CHECKED!!!
7337   const Double_t kForwardSideHeight      =   90.00 *fgkmm;//!!!TO BE CHECKED!!!
7338   const Double_t kForwardSideThick       =    1.00 *fgkmm;//!!!TO BE CHECKED!!!
7339   const Double_t kForwardCoverHeight     =   10.00 *fgkmm;//!!!TO BE CHECKED!!!
7340
7341   const Double_t kExternalTrayTotalLen   = 1200.00 *fgkmm;
7342   const Double_t kExternalCoverLen       = kExternalTrayTotalLen;
7343   const Double_t kExternalCoverThick     =    5.00 *fgkmm;
7344
7345   const Int_t    kForwardTrayNpoints     =   16;
7346
7347   const Double_t kServicesWidth          =  100.00 *fgkmm;
7348   const Double_t kCopperHeight           =   11.20 *fgkmm;// 1120 mm^2
7349   const Double_t kCablePlasticHeight     =   11.50 *fgkmm;// 1150 mm^2
7350   const Double_t kCoolingWaterHeight     =    2.65 *fgkmm;//  265 mm^2
7351   const Double_t kPoliUrethaneHeight     =    4.62 *fgkmm;//  462 mm^2
7352
7353
7354   // Local variables
7355   Double_t xprof[kForwardTrayNpoints], yprof[kForwardTrayNpoints];
7356   Double_t xloc, yloc, zloc, alpharot, totalhi;
7357
7358
7359   // The two tray components as assemblies
7360   TGeoVolumeAssembly *cableTrayAForw =
7361     new TGeoVolumeAssembly("ITSsupportSSDTrayAForw");
7362   TGeoVolumeAssembly *cableTrayAExt =
7363     new TGeoVolumeAssembly("ITSsupportSSDTrayAExt");
7364   
7365
7366   // First create all needed shapes
7367
7368   // The first part of the forward tray (part of 0872/G/D/07): a Xtru
7369   TGeoXtru *forwTrayPart1 = new TGeoXtru(2);
7370
7371   xprof[3] = kTrayWidth/2;
7372   yprof[3] = kForwardTrayFirstHeight;
7373   xprof[2] = xprof[3] - kTrayThick;
7374   yprof[2] = yprof[3];
7375   xprof[4] = xprof[3];
7376   yprof[4] = kTrayTotalHeight - kTrayHeighToBend;
7377   xprof[5] = xprof[4] - yprof[4]*TMath::Tan(kTrayBendAngle);
7378   yprof[5] = 0;
7379
7380   InsidePoint( xprof[3], yprof[3], xprof[4], yprof[4], xprof[5], yprof[5],
7381               -kTrayThick, xprof[1], yprof[1]);
7382
7383   xprof[6] = -xprof[5];
7384   yprof[6] =  yprof[5];
7385
7386   InsidePoint( xprof[4], yprof[4], xprof[5], yprof[5], xprof[6], yprof[6],
7387               -kTrayThick, xprof[0], yprof[0]);
7388
7389   // We did the right side, now reflex on the left side
7390   for (Int_t jp = 0; jp < 6; jp++) {
7391     xprof[6+jp] = -xprof[5-jp];
7392     yprof[6+jp] =  yprof[5-jp];
7393   }
7394
7395   // And now the actual Xtru
7396   forwTrayPart1->DefinePolygon(12, xprof, yprof);
7397   forwTrayPart1->DefineSection(0, 0);
7398   forwTrayPart1->DefineSection(1, kForwardTrayFirstLen);
7399
7400   // The second part of the forward tray (part of 0872/G/D/07): a Xtru
7401   TGeoXtru *forwTrayPart2 =
7402     CreateSDDSSDTraysSideA(kForwardTrayTotalLen - kForwardTrayFirstLen,
7403                            kTrayTotalHeight);
7404
7405   // The external tray (as 0872/G/D/03): a Xtru with same profile
7406   TGeoXtru *externalTray = CreateSDDSSDTraysSideA(kExternalTrayTotalLen,
7407                                                   kTrayTotalHeight);
7408
7409   // The side wall of the forward tray: a BBox
7410   TGeoBBox *forwSide = new TGeoBBox(kForwardSideThick/2,
7411                                     kForwardSideHeight/2,
7412                                     kForwardSideLength/2);
7413
7414   // The side cover over the walls: a Xtru
7415   TGeoXtru *forwSideCover = new TGeoXtru(2);
7416   forwSideCover->SetName("ITSsuppSSDForwCover");
7417
7418   xprof[0] = kTrayWidth/2 + 2*kForwardSideThick;
7419   yprof[0] = kForwardCoverHeight;
7420   xprof[1] = xprof[0];
7421   yprof[1] = 0;
7422   xprof[2] = xprof[1] - kForwardSideThick;
7423   yprof[2] = yprof[1];
7424   xprof[3] = xprof[2];
7425   yprof[3] = yprof[0] - kForwardSideThick;
7426
7427   // We did the right side, now reflex on the left side
7428   for (Int_t jp = 0; jp < 4; jp++) {
7429     xprof[4+jp] = -xprof[3-jp];
7430     yprof[4+jp] =  yprof[3-jp];
7431   }
7432
7433   forwSideCover->DefinePolygon(8, xprof, yprof);
7434   forwSideCover->DefineSection(0, 0);
7435   forwSideCover->DefineSection(1, kForwardSideLength);
7436
7437   // The forward and external covers: two Composite Shape's
7438   TGeoCompositeShape *forwardCover = CreateTrayAForwardCover(kForwardCoverLen);
7439
7440   TGeoCompositeShape *externCover = CreateTrayAExternalCover(kExternalCoverLen);
7441
7442   // The cable copper inside the forward tray: a BBox
7443   TGeoBBox *forwCopper = new TGeoBBox(kServicesWidth/2,
7444                                       kCopperHeight/2,
7445                                       kForwardTrayTotalLen/2);
7446
7447   // The cable copper inside the forward tray: a Xtru
7448   TGeoXtru *extCopper = new TGeoXtru(2);
7449   extCopper->SetName("ITSsuppSSDExtTrayCopper");
7450
7451   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7452           - kTrayThick;
7453
7454   xprof[0] = -totalhi*TanD(kTrayAZRot);
7455   yprof[0] = kTrayThick;
7456   xprof[1] = kExternalTrayTotalLen;
7457   yprof[1] = yprof[0];
7458   xprof[2] = xprof[1];
7459   yprof[2] = yprof[1] + kCopperHeight;
7460   totalhi -= kCopperHeight;
7461   xprof[3] = -totalhi*TanD(kTrayAZRot);
7462   yprof[3] = yprof[2];
7463
7464   extCopper->DefinePolygon(4, xprof, yprof);
7465   extCopper->DefineSection(0, 0);
7466   extCopper->DefineSection(1, kServicesWidth);
7467
7468   // The cable plastic inside the forward tray: a BBox
7469   TGeoBBox *forwPlastic = new TGeoBBox(kServicesWidth/2,
7470                                        kCablePlasticHeight/2,
7471                                        kForwardTrayTotalLen/2);
7472
7473   // The cable plastic inside the forward tray: a Xtru
7474   TGeoXtru *extPlastic = new TGeoXtru(2);
7475   extPlastic->SetName("ITSsuppSSDExtTrayPlastic");
7476
7477   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7478           - kTrayThick - kCopperHeight;
7479
7480   xprof[0] = -totalhi*TanD(kTrayAZRot);
7481   yprof[0] = kTrayThick;
7482   xprof[1] = kExternalTrayTotalLen;
7483   yprof[1] = yprof[0];
7484   xprof[2] = xprof[1];
7485   yprof[2] = yprof[1] + kCablePlasticHeight;
7486   totalhi -= kCablePlasticHeight;
7487   xprof[3] = -totalhi*TanD(kTrayAZRot);
7488   yprof[3] = yprof[2];
7489
7490   extPlastic->DefinePolygon(4, xprof, yprof);
7491   extPlastic->DefineSection(0, 0);
7492   extPlastic->DefineSection(1, kServicesWidth);
7493
7494   // The cooling water inside the forward tray: a BBox
7495   TGeoBBox *forwWater = new TGeoBBox(kServicesWidth/2,
7496                                      kCoolingWaterHeight/2,
7497                                      kForwardTrayTotalLen/2);
7498
7499   // The cooling water inside the forward tray: a Xtru
7500   TGeoXtru *extWater = new TGeoXtru(2);
7501   extWater->SetName("ITSsuppSSDExtTrayWater");
7502
7503   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7504           - kTrayThick - kCopperHeight - kCablePlasticHeight;
7505
7506   xprof[0] = -totalhi*TanD(kTrayAZRot);
7507   yprof[0] = kTrayThick;
7508   xprof[1] = kExternalTrayTotalLen;
7509   yprof[1] = yprof[0];
7510   xprof[2] = xprof[1];
7511   yprof[2] = yprof[1] + kCoolingWaterHeight;
7512   totalhi -= kCoolingWaterHeight;
7513   xprof[3] = -totalhi*TanD(kTrayAZRot);
7514   yprof[3] = yprof[2];
7515
7516   extWater->DefinePolygon(4, xprof, yprof);
7517   extWater->DefineSection(0, 0);
7518   extWater->DefineSection(1, kServicesWidth);
7519
7520   // The polyurethane inside the forward tray: a BBox
7521   TGeoBBox *forwPUR = new TGeoBBox(kServicesWidth/2,
7522                                    kPoliUrethaneHeight/2,
7523                                    kForwardTrayTotalLen/2);
7524
7525   // The poliurethane inside the forward tray: a Xtru
7526   TGeoXtru *extPUR = new TGeoXtru(2);
7527   extPUR->SetName("ITSsuppSSDExtTrayPUR");
7528
7529   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans
7530           - kTrayThick - kCopperHeight - kCablePlasticHeight
7531           - kCoolingWaterHeight;
7532
7533   xprof[0] = -totalhi*TanD(kTrayAZRot);
7534   yprof[0] = kTrayThick;
7535   xprof[1] = kExternalTrayTotalLen;
7536   yprof[1] = yprof[0];
7537   xprof[2] = xprof[1];
7538   yprof[2] = yprof[1] + kPoliUrethaneHeight;
7539   totalhi -= kPoliUrethaneHeight;
7540   xprof[3] = -totalhi*TanD(kTrayAZRot);
7541   yprof[3] = yprof[2];
7542
7543   extPUR->DefinePolygon(4, xprof, yprof);
7544   extPUR->DefineSection(0, 0);
7545   extPUR->DefineSection(1, kServicesWidth);
7546
7547
7548   // We have all shapes: now create the real volumes
7549   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
7550   TGeoMedium *medAntic = mgr->GetMedium("ITS_ANTICORODAL$");
7551   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
7552   TGeoMedium *medFEP   = mgr->GetMedium("ITS_SSD FEP$");
7553   TGeoMedium *medH2O   = mgr->GetMedium("ITS_WATER$");
7554   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
7555
7556   TGeoVolume *forwTrayFirst = new TGeoVolume("ITSsuppSSDSideAForwTrayFirst",
7557                                              forwTrayPart1, medAl);
7558
7559   forwTrayFirst->SetVisibility(kTRUE);
7560   forwTrayFirst->SetLineColor(6); // Purple
7561   forwTrayFirst->SetLineWidth(1);
7562   forwTrayFirst->SetFillColor(forwTrayFirst->GetLineColor());
7563   forwTrayFirst->SetFillStyle(4000); // 0% transparent
7564
7565   TGeoVolume *forwTraySecond = new TGeoVolume("ITSsuppSSDSideAForwTraySecond",
7566                                               forwTrayPart2, medAl);
7567
7568   forwTraySecond->SetVisibility(kTRUE);
7569   forwTraySecond->SetLineColor(6); // Purple
7570   forwTraySecond->SetLineWidth(1);
7571   forwTraySecond->SetFillColor(forwTraySecond->GetLineColor());
7572   forwTraySecond->SetFillStyle(4000); // 0% transparent
7573
7574   TGeoVolume *forwTraySide = new TGeoVolume("ITSsuppSSDSideAForwTraySide",
7575                                             forwSide, medAl);
7576
7577   forwTraySide->SetVisibility(kTRUE);
7578   forwTraySide->SetLineColor(6); // Purple
7579   forwTraySide->SetLineWidth(1);
7580   forwTraySide->SetFillColor(forwTraySide->GetLineColor());
7581   forwTraySide->SetFillStyle(4000); // 0% transparent
7582
7583   TGeoVolume *forwTraySideCover = new TGeoVolume("ITSsuppSSDSideAForwTraySideCover",
7584                                             forwSideCover, medAl);
7585
7586   forwTraySideCover->SetVisibility(kTRUE);
7587   forwTraySideCover->SetLineColor(6); // Purple
7588   forwTraySideCover->SetLineWidth(1);
7589   forwTraySideCover->SetFillColor(forwTraySideCover->GetLineColor());
7590   forwTraySideCover->SetFillStyle(4000); // 0% transparent
7591
7592   TGeoVolume *externalTraySSD = new TGeoVolume("ITSsuppSSDSideAExternalTray",
7593                                                externalTray, medAl);
7594
7595   externalTraySSD->SetVisibility(kTRUE);
7596   externalTraySSD->SetLineColor(6); // Purple
7597   externalTraySSD->SetLineWidth(1);
7598   externalTraySSD->SetFillColor(externalTraySSD->GetLineColor());
7599   externalTraySSD->SetFillStyle(4000); // 0% transparent
7600
7601   TGeoVolume *forwardTrayCover = new TGeoVolume("ITSsuppSSDSideAForwTrayCover",
7602                                                 forwardCover, medAntic);
7603
7604   forwardTrayCover->SetVisibility(kTRUE);
7605   forwardTrayCover->SetLineColor(kMagenta+1); // Purple
7606   forwardTrayCover->SetLineWidth(1);
7607   forwardTrayCover->SetFillColor(forwardTrayCover->GetLineColor());
7608   forwardTrayCover->SetFillStyle(4000); // 0% transparent
7609
7610   TGeoVolume *externTrayCover = new TGeoVolume("ITSsuppSSDSideAExtTrayCover",
7611                                                externCover, medAntic);
7612
7613   externTrayCover->SetVisibility(kTRUE);
7614   externTrayCover->SetLineColor(kMagenta+1); // Purple
7615   externTrayCover->SetLineWidth(1);
7616   externTrayCover->SetFillColor(externTrayCover->GetLineColor());
7617   externTrayCover->SetFillStyle(4000); // 0% transparent
7618
7619   TGeoVolume *forwCableCu = new TGeoVolume("ITSsuppSSDSideAForwCableCu",
7620                                            forwCopper, medCu);
7621
7622   forwCableCu->SetVisibility(kTRUE);
7623   forwCableCu->SetLineColor(kRed); // Red
7624   forwCableCu->SetLineWidth(1);
7625   forwCableCu->SetFillColor(forwCableCu->GetLineColor());
7626   forwCableCu->SetFillStyle(4000); // 0% transparent
7627
7628   TGeoVolume *extCableCu = new TGeoVolume("ITSsuppSSDSideAExtCableCu",
7629                                           extCopper, medCu);
7630
7631   extCableCu->SetVisibility(kTRUE);
7632   extCableCu->SetLineColor(kRed); // Red
7633   extCableCu->SetLineWidth(1);
7634   extCableCu->SetFillColor(extCableCu->GetLineColor());
7635   extCableCu->SetFillStyle(4000); // 0% transparent
7636
7637   TGeoVolume *forwCableFEP = new TGeoVolume("ITSsuppSSDSideAForwCableFEP",
7638                                             forwPlastic, medFEP);
7639
7640   forwCableFEP->SetVisibility(kTRUE);
7641   forwCableFEP->SetLineColor(kYellow); // Yellow
7642   forwCableFEP->SetLineWidth(1);
7643   forwCableFEP->SetFillColor(forwCableFEP->GetLineColor());
7644   forwCableFEP->SetFillStyle(4000); // 0% transparent
7645
7646   TGeoVolume *extCableFEP = new TGeoVolume("ITSsuppSSDSideAExtCableFEP",
7647                                            extPlastic, medFEP);
7648
7649   extCableFEP->SetVisibility(kTRUE);
7650   extCableFEP->SetLineColor(kYellow); // Yellow
7651   extCableFEP->SetLineWidth(1);
7652   extCableFEP->SetFillColor(extCableFEP->GetLineColor());
7653   extCableFEP->SetFillStyle(4000); // 0% transparent
7654
7655   TGeoVolume *forwTrayWater = new TGeoVolume("ITSsuppSSDSideAForwTrayWater",
7656                                              forwWater, medH2O);
7657
7658   forwTrayWater->SetVisibility(kTRUE);
7659   forwTrayWater->SetLineColor(kBlue); // Blue
7660   forwTrayWater->SetLineWidth(1);
7661   forwTrayWater->SetFillColor(forwTrayWater->GetLineColor());
7662   forwTrayWater->SetFillStyle(4000); // 0% transparent
7663
7664   TGeoVolume *extTrayWater = new TGeoVolume("ITSsuppSSDSideAExtTrayWater",
7665                                             extWater, medH2O);
7666
7667   extTrayWater->SetVisibility(kTRUE);
7668   extTrayWater->SetLineColor(kBlue); // Blue
7669   extTrayWater->SetLineWidth(1);
7670   extTrayWater->SetFillColor(extTrayWater->GetLineColor());
7671   extTrayWater->SetFillStyle(4000); // 0% transparent
7672
7673   TGeoVolume *forwPolyUr = new TGeoVolume("ITSsuppSSDSideAForwPolyUr",
7674                                           forwPUR, medPUR);
7675
7676   forwPolyUr->SetVisibility(kTRUE);
7677   forwPolyUr->SetLineColor(kGray); // Gray
7678   forwPolyUr->SetLineWidth(1);
7679   forwPolyUr->SetFillColor(forwPolyUr->GetLineColor());
7680   forwPolyUr->SetFillStyle(4000); // 0% transparent
7681
7682   TGeoVolume *extPolyUr = new TGeoVolume("ITSsuppSSDSideAExtPolyUr",
7683                                          extPUR, medPUR);
7684
7685   extPolyUr->SetVisibility(kTRUE);
7686   extPolyUr->SetLineColor(kGray); // Gray
7687   extPolyUr->SetLineWidth(1);
7688   extPolyUr->SetFillColor(extPolyUr->GetLineColor());
7689   extPolyUr->SetFillStyle(4000); // 0% transparent
7690
7691
7692   // Now build up the tray
7693   cableTrayAForw->AddNode(forwTrayFirst, 1, 0);
7694
7695   cableTrayAForw->AddNode(forwTraySecond, 1,
7696                         new TGeoTranslation(0, 0, kForwardTrayFirstLen) );
7697
7698   xloc = kTrayWidth/2 + kForwardSideThick/2;
7699   yloc = kForwardTrayFirstHeight + kForwardSideHeight/2 - kForwardSideYTrans;
7700   zloc = kForwardSideLength/2;
7701   cableTrayAForw->AddNode(forwTraySide,1,
7702                         new TGeoTranslation( xloc, yloc, zloc) );
7703   cableTrayAForw->AddNode(forwTraySide,2,
7704                         new TGeoTranslation(-xloc, yloc, zloc) );
7705
7706   yloc = kForwardTrayFirstHeight + kForwardSideHeight - kForwardSideYTrans
7707        - kForwardCoverHeight;
7708   cableTrayAForw->AddNode(forwTraySideCover,1,
7709                         new TGeoTranslation(0, yloc, 0) );
7710
7711   yloc = kTrayTotalHeight - kCoversYTrans;
7712   zloc = kForwardTrayTotalLen - kForwardCoverLen;
7713   cableTrayAForw->AddNode(forwardTrayCover,1,
7714                         new TGeoTranslation(0, yloc, zloc) );
7715
7716   yloc = kTrayThick + forwCopper->GetDY();
7717   zloc = forwCopper->GetDZ();
7718   cableTrayAForw->AddNode(forwCableCu, 1,
7719                         new TGeoTranslation(0, yloc, zloc) );
7720
7721   yloc = kTrayThick + kCopperHeight + forwPlastic->GetDY();
7722   zloc = forwPlastic->GetDZ();
7723   cableTrayAForw->AddNode(forwCableFEP, 1,
7724                         new TGeoTranslation(0, yloc, zloc) );
7725
7726   yloc = kTrayThick + kCopperHeight + kCablePlasticHeight + forwWater->GetDY();
7727   zloc = forwWater->GetDZ();
7728   cableTrayAForw->AddNode(forwTrayWater, 1,
7729                         new TGeoTranslation(0, yloc, zloc) );
7730
7731   yloc = kTrayThick + kCopperHeight + kCablePlasticHeight
7732        + kCoolingWaterHeight + forwPUR->GetDY();
7733   zloc = forwPUR->GetDZ();
7734   cableTrayAForw->AddNode(forwPolyUr, 1,
7735                         new TGeoTranslation(0, yloc, zloc) );
7736
7737   // To simplify following placement in MARS, origin is on top
7738   totalhi = kTrayTotalHeight + kExternalCoverThick - kCoversYTrans;
7739
7740   yloc = -totalhi;
7741   cableTrayAExt->AddNode(externalTraySSD, 1,
7742                         new TGeoTranslation(0, yloc, 0) );
7743
7744   yloc = -totalhi + kTrayTotalHeight - kCoversYTrans;
7745   cableTrayAExt->AddNode(externTrayCover,1,
7746                         new TGeoTranslation(0, yloc, 0) );
7747
7748   xloc = extCopper->GetDZ();
7749   yloc = -totalhi;
7750   cableTrayAExt->AddNode(extCableCu,1,
7751                         new TGeoCombiTrans( xloc, yloc, 0,
7752                         new TGeoRotation("",-90, 90, 90)        ) );
7753
7754   xloc = extPlastic->GetDZ();
7755   yloc = -totalhi + kCopperHeight;
7756   cableTrayAExt->AddNode(extCableFEP,1,
7757                         new TGeoCombiTrans( xloc, yloc, 0,
7758                         new TGeoRotation("",-90, 90, 90)        ) );
7759
7760   xloc = extWater->GetDZ();
7761   yloc = -totalhi + kCopperHeight + kCablePlasticHeight;
7762   cableTrayAExt->AddNode(extTrayWater,1,
7763                         new TGeoCombiTrans( xloc, yloc, 0,
7764                         new TGeoRotation("",-90, 90, 90)        ) );
7765
7766   xloc = extPUR->GetDZ();
7767   yloc = -totalhi + kCopperHeight + kCablePlasticHeight + kCoolingWaterHeight;
7768   cableTrayAExt->AddNode(extPolyUr,1,
7769                         new TGeoCombiTrans( xloc, yloc, 0,
7770                         new TGeoRotation("",-90, 90, 90)        ) );
7771
7772
7773   // Finally put everything in the mother volume
7774   zloc = kTrayAZTrans;
7775   Double_t zlocext = zloc + kForwardTrayTotalLen;
7776   Double_t rExtTray = kTrayARTrans + kTrayTotalHeight;
7777
7778   alpharot = kTrayAFirstRotAng;
7779   xloc = kTrayARTrans*SinD(alpharot);
7780   yloc = kTrayARTrans*CosD(alpharot);
7781   moth->AddNode(cableTrayAForw,1,
7782                             new TGeoCombiTrans( xloc, yloc, zloc,
7783                             new TGeoRotation("",-alpharot,0,0)   )   );
7784   xloc = rExtTray*SinD(alpharot);
7785   yloc = rExtTray*CosD(alpharot);
7786   moth->AddNode(cableTrayAExt,1,
7787                             new TGeoCombiTrans( xloc, yloc, zlocext,
7788                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7789
7790   alpharot += 180;
7791   xloc = kTrayARTrans*SinD(alpharot);
7792   yloc = kTrayARTrans*CosD(alpharot);
7793   moth->AddNode(cableTrayAForw,2,
7794                             new TGeoCombiTrans( xloc, yloc, zloc,
7795                             new TGeoRotation("",-alpharot,0,0)   )   );
7796   xloc = rExtTray*SinD(alpharot);
7797   yloc = rExtTray*CosD(alpharot);
7798   moth->AddNode(cableTrayAExt,2,
7799                             new TGeoCombiTrans( xloc, yloc, zlocext,
7800                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7801
7802   alpharot = -kTrayAFirstRotAng - 2*kTrayASecondRotAng;
7803   xloc = kTrayARTrans*SinD(alpharot);
7804   yloc = kTrayARTrans*CosD(alpharot);
7805   moth->AddNode(cableTrayAForw,3,
7806                             new TGeoCombiTrans( xloc, yloc, zloc,
7807                             new TGeoRotation("",-alpharot,0,0)   )   );
7808   xloc = rExtTray*SinD(alpharot);
7809   yloc = rExtTray*CosD(alpharot);
7810   moth->AddNode(cableTrayAExt,3,
7811                             new TGeoCombiTrans( xloc, yloc, zlocext,
7812                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7813
7814   alpharot += 180;
7815   xloc = kTrayARTrans*SinD(alpharot);
7816   yloc = kTrayARTrans*CosD(alpharot);
7817   moth->AddNode(cableTrayAForw,4,
7818                             new TGeoCombiTrans( xloc, yloc, zloc,
7819                             new TGeoRotation("",-alpharot,0,0)   )   );
7820   xloc = rExtTray*SinD(alpharot);
7821   yloc = rExtTray*CosD(alpharot);
7822   moth->AddNode(cableTrayAExt,4,
7823                             new TGeoCombiTrans( xloc, yloc, zlocext,
7824                             new TGeoRotation("",-alpharot,-kTrayAZRot,0)  )  );
7825
7826
7827   return;
7828 }
7829
7830 //______________________________________________________________________
7831 void AliITSv11GeometrySupport::SSDCableTraysSideC(TGeoVolume *moth,
7832                                             const TGeoManager *mgr){
7833 //
7834 // Creates the SSD cable trays which are outside the ITS support cones
7835 // but still inside the TPC on Side C
7836 // (part of this code is taken or anyway inspired to ServicesCableSupport
7837 // method of AliITSv11GeometrySupport.cxx,v 1.9 2007/06/06)
7838 //
7839 // Input:
7840 //         moth : the TGeoVolume owing the volume structure
7841 //         mgr  : the GeoManager (default gGeoManager)
7842 // Output:
7843 //
7844 // Created:         ???       Bjorn S. Nilsen
7845 // Updated:      15 Apr 2010  Mario Sitta
7846 //
7847 // Technical data are taken from AutoCAD drawings and other (oral)
7848 // information given by F.Tosello
7849 //
7850
7851   // Dimensions and positions of the C-Side Cable Tray elements
7852   const Int_t    kNumTraySideC           =    4;
7853
7854   const Double_t kSideCFoldAngle         =    5.00 *fgkDegree;
7855
7856   const Double_t kServicesWidth          =  100.00 *fgkmm;
7857   const Double_t kCopperHeight           =   11.20 *fgkmm;// 1120 mm^2
7858   const Double_t kCablePlasticHeight     =   11.50 *fgkmm;// 1150 mm^2
7859   const Double_t kCoolingWaterHeight     =    2.65 *fgkmm;//  265 mm^2
7860   const Double_t kPoliUrethaneHeight     =    4.62 *fgkmm;//  462 mm^2
7861   const Double_t kCablesYtrans           =    2.50 *fgkmm;// Avoid ovlps
7862
7863   // Overall position and rotation of the C-Side Cable Trays
7864   const Double_t kTraySideCRPos          =   45.30    *fgkcm;
7865   const Double_t kTraySideCZPos          = -102.40    *fgkcm;
7866   const Double_t kTraySideCAlphaRot[kNumTraySideC]  = {     23.0,     -59.0,
7867     /* from Patch panel position */                    180.+23.0, 180.-59.0};
7868
7869
7870   // Local variables
7871   Double_t xprof[6], yprof[6];
7872   Double_t xloc, yloc, alpharot, alphafold;
7873
7874
7875   // The assembly holding the metallic structure
7876   TGeoVolumeAssembly *trayStructure =
7877                                 CreateSDDSSDTraysSideC("ITSsupportSSDTrayC");
7878
7879   // The cable copper inside the tray: a Xtru
7880   TGeoXtru *copper = new TGeoXtru(2);
7881   copper->SetName("ITSsuppSSDTrayCCopper");
7882
7883   // Copper lies on the lower plate: get position of its points
7884   TGeoXtru *lowerplate = (TGeoXtru*)(mgr->GetVolume("ITSsuppTraySideCLower")->GetShape());
7885   xprof[0] = lowerplate->GetX(5);
7886   yprof[0] = lowerplate->GetY(5) + kCablesYtrans;
7887   xprof[1] = lowerplate->GetX(4);
7888   yprof[1] = lowerplate->GetY(4) + kCablesYtrans;
7889   xprof[2] = lowerplate->GetX(3);
7890   yprof[2] = lowerplate->GetY(3) + kCablesYtrans;
7891   xprof[3] = xprof[2] - kCopperHeight*SinD(kSideCFoldAngle);
7892   yprof[3] = yprof[2] + kCopperHeight*CosD(kSideCFoldAngle);
7893   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7894               kCopperHeight , xprof[4], yprof[4]);
7895   xprof[5] = xprof[0];
7896   yprof[5] = yprof[0] + kCopperHeight;
7897
7898   copper->DefinePolygon(6, xprof, yprof);
7899   copper->DefineSection(0, -kServicesWidth/2);
7900   copper->DefineSection(1,  kServicesWidth/2);
7901
7902   // The cable plastic inside the tray: a Xtru
7903   TGeoXtru *plastic = new TGeoXtru(2);
7904   plastic->SetName("ITSsuppSSDTrayCPlastic");
7905
7906   xprof[0] = copper->GetX(5);
7907   yprof[0] = copper->GetY(5);
7908   xprof[1] = copper->GetX(4);
7909   yprof[1] = copper->GetY(4);
7910   xprof[2] = copper->GetX(3);
7911   yprof[2] = copper->GetY(3);
7912   xprof[3] = xprof[2] - kCablePlasticHeight*SinD(kSideCFoldAngle);
7913   yprof[3] = yprof[2] + kCablePlasticHeight*CosD(kSideCFoldAngle);
7914   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7915               kCablePlasticHeight , xprof[4], yprof[4]);
7916   xprof[5] = xprof[0];
7917   yprof[5] = yprof[0] + kCablePlasticHeight;
7918
7919   plastic->DefinePolygon(6, xprof, yprof);
7920   plastic->DefineSection(0, -kServicesWidth/2);
7921   plastic->DefineSection(1,  kServicesWidth/2);
7922
7923   // The cooling water inside the tray: a Xtru
7924   TGeoXtru *water = new TGeoXtru(2);
7925   water->SetName("ITSsuppSSDTrayCWater");
7926
7927   xprof[0] = plastic->GetX(5);
7928   yprof[0] = plastic->GetY(5);
7929   xprof[1] = plastic->GetX(4);
7930   yprof[1] = plastic->GetY(4);
7931   xprof[2] = plastic->GetX(3);
7932   yprof[2] = plastic->GetY(3);
7933   xprof[3] = xprof[2] - kCoolingWaterHeight*SinD(kSideCFoldAngle);
7934   yprof[3] = yprof[2] + kCoolingWaterHeight*CosD(kSideCFoldAngle);
7935   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7936               kCoolingWaterHeight , xprof[4], yprof[4]);
7937   xprof[5] = xprof[0];
7938   yprof[5] = yprof[0] + kCoolingWaterHeight;
7939
7940   water->DefinePolygon(6, xprof, yprof);
7941   water->DefineSection(0, -kServicesWidth/2);
7942   water->DefineSection(1,  kServicesWidth/2);
7943
7944   // The poliurethane inside the tray: a Xtru
7945   TGeoXtru *pur = new TGeoXtru(2);
7946   pur->SetName("ITSsuppSSDTrayCPUR");
7947   xprof[0] = water->GetX(5);
7948   yprof[0] = water->GetY(5);
7949   xprof[1] = water->GetX(4);
7950   yprof[1] = water->GetY(4);
7951   xprof[2] = water->GetX(3);
7952   yprof[2] = water->GetY(3);
7953   xprof[3] = xprof[2] - kPoliUrethaneHeight*SinD(kSideCFoldAngle);
7954   yprof[3] = yprof[2] + kPoliUrethaneHeight*CosD(kSideCFoldAngle);
7955   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
7956               kPoliUrethaneHeight , xprof[4], yprof[4]);
7957   xprof[5] = xprof[0];
7958   yprof[5] = yprof[0] + kPoliUrethaneHeight;
7959
7960   pur->DefinePolygon(6, xprof, yprof);
7961   pur->DefineSection(0, -kServicesWidth/2);
7962   pur->DefineSection(1,  kServicesWidth/2);
7963
7964
7965   // We have all shapes: now create the real volumes
7966   TGeoMedium *medCu    = mgr->GetMedium("ITS_COPPER$");
7967   TGeoMedium *medFEP   = mgr->GetMedium("ITS_SSD FEP$");
7968   TGeoMedium *medH2O   = mgr->GetMedium("ITS_WATER$");
7969   TGeoMedium *medPUR   = mgr->GetMedium("ITS_POLYURETHANE$");
7970
7971   TGeoVolume *copperCable = new TGeoVolume("ITSsuppSSDSideCCableCu",
7972                                            copper, medCu);
7973
7974   copperCable->SetVisibility(kTRUE);
7975   copperCable->SetLineColor(kRed); // Red
7976   copperCable->SetLineWidth(1);
7977   copperCable->SetFillColor(copperCable->GetLineColor());
7978   copperCable->SetFillStyle(4000); // 0% transparent
7979
7980   TGeoVolume *cableFEP = new TGeoVolume("ITSsuppSSDSideCCableFEP",
7981                                         plastic, medFEP);
7982
7983   cableFEP->SetVisibility(kTRUE);
7984   cableFEP->SetLineColor(kYellow); // Yellow
7985   cableFEP->SetLineWidth(1);
7986   cableFEP->SetFillColor(cableFEP->GetLineColor());
7987   cableFEP->SetFillStyle(4000); // 0% transparent
7988
7989   TGeoVolume *trayWater = new TGeoVolume("ITSsuppSSDSideCTrayWater",
7990                                          water, medH2O);
7991
7992   trayWater->SetVisibility(kTRUE);
7993   trayWater->SetLineColor(kBlue); // Blue
7994   trayWater->SetLineWidth(1);
7995   trayWater->SetFillColor(trayWater->GetLineColor());
7996   trayWater->SetFillStyle(4000); // 0% transparent
7997
7998   TGeoVolume *trayPolyUr = new TGeoVolume("ITSsuppSSDSideCPolyUr",
7999                                           pur, medPUR);
8000
8001   trayPolyUr->SetVisibility(kTRUE);
8002   trayPolyUr->SetLineColor(kGray); // Gray
8003   trayPolyUr->SetLineWidth(1);
8004   trayPolyUr->SetFillColor(trayPolyUr->GetLineColor());
8005   trayPolyUr->SetFillStyle(4000); // 0% transparent
8006
8007
8008   // Now fill in the tray
8009   trayStructure->AddNode(copperCable,1,0);
8010   trayStructure->AddNode(cableFEP,1,0);
8011   trayStructure->AddNode(trayWater,1,0);
8012   trayStructure->AddNode(trayPolyUr,1,0);
8013
8014
8015   // Finally put everything in the mother volume
8016   alphafold = kSideCFoldAngle;
8017
8018   for (Int_t jt = 0; jt < kNumTraySideC; jt++) {
8019     alpharot = kTraySideCAlphaRot[jt];
8020     xloc = kTraySideCRPos*SinD(alpharot);
8021     yloc = kTraySideCRPos*CosD(alpharot);
8022     moth->AddNode(trayStructure,jt+1,
8023                        new TGeoCombiTrans(-xloc, yloc, kTraySideCZPos,
8024                        new TGeoRotation("",-90.+alpharot,-90.,90.+alphafold)));
8025   }
8026
8027
8028   return;
8029 }
8030
8031 //______________________________________________________________________
8032 void AliITSv11GeometrySupport::CreateSDDForwardTraySideA(TGeoVolumeAssembly *tray,
8033                                                    const TGeoManager *mgr){
8034 //
8035 // Creates the forward SDD tray on Side A (0872/G/D/01)
8036 //
8037 // Input:
8038 //         tray : the TGeoVolumeAssembly to put the elements in
8039 //         mgr  : the GeoManager (used only to get the proper material)
8040 //
8041 // Output:
8042 //
8043 // Return:
8044 //
8045 // Created:      08 Jan 2010  Mario Sitta
8046 // Updated:      07 Sep 2010  Mario Sitta
8047 //
8048 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8049 // drawings and other (oral) information given by F.Tosello
8050 //
8051
8052   // Dimensions of the A-Side Forward Cable Tray (0872/G/D/01)
8053   const Double_t kForwardTrayThick        =    2.00 *fgkmm;
8054   const Double_t kForwardTraySideLength   =  823.00 *fgkmm;
8055   const Double_t kForwardTrayTailLength   =  212.00 *fgkmm;
8056   const Double_t kForwardTrayBaseHalfWide =   55.00 *fgkmm;
8057   const Double_t kForwardTrayNotchLength  =   47.20 *fgkmm;
8058   const Double_t kForwardTrayNotchHeight  =   25.00 *fgkmm;
8059   const Double_t kForwardTrayNotchDown    =   10.00 *fgkmm;
8060   const Double_t kForwardTraySide1Height  =   39.00 *fgkmm;
8061   const Double_t kForwardTraySide2Height  =   26.00 *fgkmm;
8062   const Double_t kForwardTraySide2Expand  =   10.50 *fgkmm;
8063   const Double_t kForwardTraySide3TailLen =  418.00 *fgkmm;
8064   const Double_t kForwardTraySide3TailHi  =   31.00 *fgkmm;
8065   const Double_t kForwardTraySide3HeadLen =  425.00 *fgkmm;
8066   const Double_t kForwardTraySide3HeadHi  =   72.00 *fgkmm;
8067   const Double_t kForwardTrayHorWingWide  =   10.50 *fgkmm;
8068   const Double_t kForwardTrayVertWingWide =   15.00 *fgkmm;
8069
8070   const Int_t    kForwardTraySideNpoints  =    9;
8071
8072
8073   // Local variables
8074   Double_t xprof[kForwardTraySideNpoints], yprof[kForwardTraySideNpoints];
8075   Double_t ylen, zlen;
8076   Double_t xloc, yloc, zloc;
8077
8078
8079   // The tray has a very complex shape, so it is made by assembling
8080   // different elements (with some small simplifications)
8081
8082   // The tray base: a BBox
8083   zlen = (kForwardTraySideLength-kForwardTrayTailLength)/2;
8084   TGeoBBox *trayBase = new TGeoBBox(kForwardTrayBaseHalfWide,
8085                                     kForwardTrayThick/2, zlen);
8086
8087   // The first part of the side wall: a Xtru
8088   TGeoXtru *traySide1 = new TGeoXtru(2);
8089
8090   xprof[0] = 0;
8091   yprof[0] = kForwardTrayThick;
8092   xprof[1] = kForwardTraySideLength-kForwardTrayTailLength;
8093   yprof[1] = yprof[0];
8094   xprof[2] = kForwardTraySideLength;
8095   yprof[2] = kForwardTraySide1Height + kForwardTrayThick;
8096   xprof[3] = 0;
8097   yprof[3] = yprof[2];
8098
8099   traySide1->DefinePolygon(4, xprof, yprof);
8100   traySide1->DefineSection(0, 0);
8101   traySide1->DefineSection(1, kForwardTrayThick);
8102
8103   // The second part of the side wall: a Xtru
8104   TGeoXtru *traySide2 = new TGeoXtru(2);
8105
8106   xprof[0] = kForwardTrayBaseHalfWide - kForwardTrayThick;
8107   yprof[0] = traySide1->GetY(2);
8108   xprof[1] = kForwardTrayBaseHalfWide;
8109   yprof[1] = yprof[0];
8110   xprof[2] = xprof[1] + kForwardTraySide2Expand;
8111   yprof[2] = yprof[1] + kForwardTraySide2Height;
8112   xprof[3] = xprof[2] - kForwardTrayThick;
8113   yprof[3] = yprof[2];
8114
8115   traySide2->DefinePolygon(4, xprof, yprof);
8116   traySide2->DefineSection(0, 0);
8117   traySide2->DefineSection(1, kForwardTraySideLength);
8118
8119   // The third part of the side wall: a Xtru
8120   TGeoXtru *traySide3 = new TGeoXtru(2);
8121
8122   xprof[0] = 0;
8123   yprof[0] = traySide2->GetY(2);
8124   xprof[1] = kForwardTraySideLength;
8125   yprof[1] = yprof[0];
8126   xprof[2] = xprof[1];
8127   yprof[2] = yprof[1] + kForwardTraySide3TailHi - kForwardTrayThick;
8128   xprof[3] = xprof[2] - kForwardTraySide3TailLen - kForwardTrayThick;
8129   yprof[3] = yprof[2];
8130   xprof[4] = xprof[3];
8131   yprof[4] = yprof[3] + kForwardTraySide3HeadHi + kForwardTrayThick;
8132   xprof[5] = xprof[4] - kForwardTraySide3HeadLen;
8133   yprof[5] = yprof[4];
8134   xprof[6] = xprof[5];
8135   yprof[6] = yprof[5] - kForwardTrayNotchHeight;
8136   xprof[7] = xprof[6] + kForwardTrayNotchLength;
8137   yprof[7] = yprof[6];
8138   xprof[8] = xprof[7];
8139   yprof[8] = yprof[7] - kForwardTrayNotchDown;
8140
8141   traySide3->DefinePolygon(9, xprof, yprof);
8142   traySide3->DefineSection(0, 0);
8143   traySide3->DefineSection(1, kForwardTrayThick);
8144
8145   // The horizontal wing: a BBox
8146   TGeoBBox *trayHorWing = new TGeoBBox(kForwardTrayHorWingWide/2,
8147                                        kForwardTrayThick/2,
8148                                        kForwardTraySide3TailLen/2);
8149
8150   // The vertical wing: a BBox
8151   ylen = (traySide3->GetY(4) - traySide3->GetY(3))/2;
8152   TGeoBBox *trayVertWing = new TGeoBBox(kForwardTrayVertWingWide/2,
8153                                         ylen, kForwardTrayThick/2);
8154
8155
8156   // We have all shapes: now create the real volumes
8157   TGeoMedium *medAl    = mgr->GetMedium("ITS_ALUMINUM$");
8158
8159   TGeoVolume *forwTrayBase = new TGeoVolume("ITSsuppSDDSideAForwTrayBase",
8160                                             trayBase, medAl);
8161
8162   forwTrayBase->SetVisibility(kTRUE);
8163   forwTrayBase->SetLineColor(6); // Purple
8164   forwTrayBase->SetLineWidth(1);
8165   forwTrayBase->SetFillColor(forwTrayBase->GetLineColor());
8166   forwTrayBase->SetFillStyle(4000); // 0% transparent
8167
8168   TGeoVolume *forwTraySide1 = new TGeoVolume("ITSsuppSDDSideAForwTraySide1",
8169                                             traySide1, medAl);
8170
8171   forwTraySide1->SetVisibility(kTRUE);
8172   forwTraySide1->SetLineColor(6); // Purple
8173   forwTraySide1->SetLineWidth(1);
8174   forwTraySide1->SetFillColor(forwTraySide1->GetLineColor());
8175   forwTraySide1->SetFillStyle(4000); // 0% transparent
8176
8177   TGeoVolume *forwTraySide2 = new TGeoVolume("ITSsuppSDDSideAForwTraySide2",
8178                                             traySide2, medAl);
8179
8180   forwTraySide2->SetVisibility(kTRUE);
8181   forwTraySide2->SetLineColor(6); // Purple
8182   forwTraySide2->SetLineWidth(1);
8183   forwTraySide2->SetFillColor(forwTraySide2->GetLineColor());
8184   forwTraySide2->SetFillStyle(4000); // 0% transparent
8185
8186   TGeoVolume *forwTraySide3 = new TGeoVolume("ITSsuppSDDSideAForwTraySide3",
8187                                             traySide3, medAl);
8188
8189   forwTraySide3->SetVisibility(kTRUE);
8190   forwTraySide3->SetLineColor(6); // Purple
8191   forwTraySide3->SetLineWidth(1);
8192   forwTraySide3->SetFillColor(forwTraySide3->GetLineColor());
8193   forwTraySide3->SetFillStyle(4000); // 0% transparent
8194
8195   TGeoVolume *forwTrayHWing = new TGeoVolume("ITSsuppSDDSideAForwTrayHorWing",
8196                                             trayHorWing, medAl);
8197
8198   forwTrayHWing->SetVisibility(kTRUE);
8199   forwTrayHWing->SetLineColor(6); // Purple
8200   forwTrayHWing->SetLineWidth(1);
8201   forwTrayHWing->SetFillColor(forwTrayHWing->GetLineColor());
8202   forwTrayHWing->SetFillStyle(4000); // 0% transparent
8203
8204   TGeoVolume *forwTrayVWing = new TGeoVolume("ITSsuppSDDSideAForwTrayVertWing",
8205                                             trayVertWing, medAl);
8206
8207   forwTrayVWing->SetVisibility(kTRUE);
8208   forwTrayVWing->SetLineColor(6); // Purple
8209   forwTrayVWing->SetLineWidth(1);
8210   forwTrayVWing->SetFillColor(forwTrayVWing->GetLineColor());
8211   forwTrayVWing->SetFillStyle(4000); // 0% transparent
8212
8213
8214   // Now build up the tray
8215   yloc = kForwardTrayThick/2;
8216   zloc = zlen;
8217   tray->AddNode(forwTrayBase, 1,
8218                 new TGeoTranslation(0, yloc, zloc) );
8219
8220   xloc = kForwardTrayBaseHalfWide;
8221   tray->AddNode(forwTraySide1, 1,
8222                 new TGeoCombiTrans(xloc, 0, 0,
8223                                    new TGeoRotation("",90,-90,-90)));
8224   xloc = -xloc + kForwardTrayThick;
8225   tray->AddNode(forwTraySide1, 2,
8226                 new TGeoCombiTrans(xloc, 0, 0,
8227                                    new TGeoRotation("",90,-90,-90)));
8228
8229   tray->AddNode(forwTraySide2, 1, 0);
8230   zloc = kForwardTraySideLength;
8231   tray->AddNode(forwTraySide2, 2,
8232                 new TGeoCombiTrans(0, 0, zloc,
8233                                    new TGeoRotation("",90,-180,-90)));
8234
8235   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand;
8236   tray->AddNode(forwTraySide3, 1,
8237                 new TGeoCombiTrans(xloc, 0, 0,
8238                                    new TGeoRotation("",90,-90,-90)));
8239   xloc = -xloc + kForwardTrayThick;
8240   tray->AddNode(forwTraySide3, 2,
8241                 new TGeoCombiTrans(xloc, 0, 0,
8242                                    new TGeoRotation("",90,-90,-90)));
8243
8244   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand
8245        - kForwardTrayHorWingWide/2;
8246   yloc = traySide3->GetY(2) + kForwardTrayThick/2;
8247   zloc = kForwardTraySideLength - trayHorWing->GetDZ();
8248   tray->AddNode(forwTrayHWing, 1,
8249                 new TGeoTranslation( xloc, yloc, zloc) );
8250   tray->AddNode(forwTrayHWing, 2,
8251                 new TGeoTranslation(-xloc, yloc, zloc) );
8252
8253   xloc = kForwardTrayBaseHalfWide + kForwardTraySide2Expand
8254        - kForwardTrayVertWingWide/2;
8255   yloc = traySide3->GetY(2) + trayVertWing->GetDY();
8256   zloc = traySide3->GetX(3) + kForwardTrayThick/2;
8257   tray->AddNode(forwTrayVWing, 1,
8258                 new TGeoTranslation( xloc, yloc, zloc) );
8259   tray->AddNode(forwTrayVWing, 2,
8260                 new TGeoTranslation(-xloc, yloc, zloc) );
8261
8262
8263   return;
8264 }
8265
8266 //______________________________________________________________________
8267 TGeoCompositeShape* AliITSv11GeometrySupport::CreateTrayAForwardCover(const Double_t coverLen){
8268 //
8269 // Creates the forward cover of the SDD and SSD cable trays on Side A
8270 // (0872/G/D/02)
8271 //
8272 // Input:
8273 //             coverLen: the total length of the cover
8274 //
8275 // Output:
8276 //
8277 // Return:     a TGeoCompositeShape for the cover
8278 //
8279 // Created:      03 Jan 2010  Mario Sitta
8280 //
8281 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8282 // drawings and other (oral) information given by F.Tosello
8283 //
8284
8285   // Dimensions and positions of the A-Side Cable Tray Forward Cover
8286   // (0872/G/D/02)
8287   const Double_t kForwardCoverWide        =  130.00 *fgkmm;
8288   const Double_t kForwardCoverSideWide    =   10.00 *fgkmm;
8289   const Double_t kForwardCoverHoleLen     =  160.00 *fgkmm;
8290   const Double_t kForwardCoverHoleWide    =   90.00 *fgkmm;
8291   const Double_t kForwardCoverHoleR10     =   10.00 *fgkmm;
8292   const Double_t kForwardCoverTotalThick  =    5.00 *fgkmm;
8293   const Double_t kForwardCoverSideThick   =    3.00 *fgkmm;
8294   const Double_t kForwardCoverInternThick =    2.00 *fgkmm;
8295
8296   const Double_t kForwardCoverHoleZTrans  =   40.00 *fgkmm;
8297
8298
8299   // Local variables
8300   Double_t xprof[16], yprof[16];
8301   Double_t yloc, zloc;
8302
8303
8304   // The main shape: a Xtru
8305   TGeoXtru *forwCoverMain = new TGeoXtru(2);
8306   forwCoverMain->SetName("ITSsuppForwCoverMain");
8307
8308   xprof[0] = kForwardCoverWide/2;
8309   yprof[0] = kForwardCoverTotalThick;
8310   xprof[1] = xprof[0];
8311   yprof[1] = yprof[0] - kForwardCoverSideThick;
8312   xprof[2] = xprof[1] - kForwardCoverSideWide;
8313   yprof[2] = yprof[1];
8314   xprof[3] = xprof[2];
8315   yprof[3] = 0;
8316
8317   // We did the right side, now reflex on the left side
8318   for (Int_t jp = 0; jp < 4; jp++) {
8319     xprof[4+jp] = -xprof[3-jp];
8320     yprof[4+jp] =  yprof[3-jp];
8321   }
8322
8323   // And now the actual Xtru
8324   forwCoverMain->DefinePolygon(8, xprof, yprof);
8325   forwCoverMain->DefineSection(0, 0);
8326   forwCoverMain->DefineSection(1, coverLen);
8327
8328   // The hole: another Xtru (rounded corners approximated with segments)
8329   TGeoXtru *forwCoverHole = new TGeoXtru(2);
8330   forwCoverHole->SetName("ITSsuppForwCoverHole");
8331
8332   CreateTrayACoverHolesShape(kForwardCoverHoleWide, kForwardCoverHoleLen,
8333                              kForwardCoverHoleR10 , xprof, yprof);
8334
8335   // And now the actual Xtru
8336   forwCoverHole->DefinePolygon(16, xprof, yprof);
8337   forwCoverHole->DefineSection(0, 0);
8338   forwCoverHole->DefineSection(1, kForwardCoverTotalThick-kForwardCoverInternThick);
8339
8340   // Now the proper rototranslation matrices for the two holes
8341   yloc = kForwardCoverTotalThick-kForwardCoverInternThick-0.01;//Precision fix
8342   zloc = kForwardCoverHoleZTrans;
8343   TGeoCombiTrans *mf1 = new TGeoCombiTrans(0, yloc, zloc,
8344                                            new TGeoRotation("", 0, 90, 0) );
8345   mf1->SetName("mf1");
8346   mf1->RegisterYourself();
8347
8348   zloc = coverLen - kForwardCoverHoleZTrans - kForwardCoverHoleLen;
8349   TGeoCombiTrans *mf2 = new TGeoCombiTrans(0, yloc, zloc,
8350                                            new TGeoRotation("", 0, 90, 0) );
8351   mf2->SetName("mf2");
8352   mf2->RegisterYourself();
8353
8354   // Finally the actual cover shape
8355   TGeoCompositeShape *cover = new TGeoCompositeShape("ITSsuppForwardCoverMain",
8356     "ITSsuppForwCoverMain-ITSsuppForwCoverHole:mf1-ITSsuppForwCoverHole:mf2");
8357
8358   return cover;
8359 }
8360
8361 //______________________________________________________________________
8362 TGeoCompositeShape* AliITSv11GeometrySupport::CreateTrayAExternalCover(const Double_t coverLen){
8363 //
8364 // Creates the external cover of the SDD and SSD cable trays on Side A
8365 // (0872/G/D/04)
8366 //
8367 // Input:
8368 //             coverLen: the total length of the cover
8369 //
8370 // Output:
8371 //
8372 // Return:     a TGeoCompositeShape for the cover
8373 //
8374 // Created:      03 Jan 2010  Mario Sitta
8375 //
8376 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8377 // drawings and other (oral) information given by F.Tosello
8378 //
8379
8380   // Dimensions and positions of the A-Side Cable Tray External Cover
8381   // (0872/G/D/04)
8382   const Double_t kExternalCoverWide        =  130.00 *fgkmm;
8383   const Double_t kExternalCoverSideWide    =   10.00 *fgkmm;
8384   const Double_t kExternalCoverHoleLen1    =  262.00 *fgkmm;
8385   const Double_t kExternalCoverHoleLen2    =  280.00 *fgkmm;
8386   const Double_t kExternalCoverHoleLen3    =  205.00 *fgkmm;
8387   const Double_t kExternalCoverHoleLen4    =   55.00 *fgkmm;
8388   const Double_t kExternalCoverHoleWide    =   90.00 *fgkmm;
8389   const Double_t kExternalCoverHoleR10     =   10.00 *fgkmm;
8390   const Double_t kExternalCoverTotalThick  =    5.00 *fgkmm;
8391   const Double_t kExternalCoverSideThick   =    3.00 *fgkmm;
8392   const Double_t kExternalCoverInternThick =    2.00 *fgkmm;
8393
8394   const Double_t kExternalCoverHole1ZTrans =   28.00 *fgkmm;
8395   const Double_t kExternalCoverHolesZTrans =   20.00 *fgkmm;
8396
8397
8398   // Local variables
8399   Double_t xprof[16], yprof[16];
8400   Double_t yloc, zloc;
8401
8402
8403   // The main shape: a Xtru
8404   TGeoXtru *externCoverMain = new TGeoXtru(2);
8405   externCoverMain->SetName("ITSsuppExternCoverMain");
8406
8407   xprof[0] = kExternalCoverWide/2;
8408   yprof[0] = kExternalCoverTotalThick;
8409   xprof[1] = xprof[0];
8410   yprof[1] = yprof[0] - kExternalCoverSideThick;
8411   xprof[2] = xprof[1] - kExternalCoverSideWide;
8412   yprof[2] = yprof[1];
8413   xprof[3] = xprof[2];
8414   yprof[3] = 0;
8415
8416   // We did the right side, now reflex on the left side
8417   for (Int_t jp = 0; jp < 4; jp++) {
8418     xprof[4+jp] = -xprof[3-jp];
8419     yprof[4+jp] =  yprof[3-jp];
8420   }
8421
8422   // And now the actual Xtru
8423   externCoverMain->DefinePolygon(8, xprof, yprof);
8424   externCoverMain->DefineSection(0, 0);
8425   externCoverMain->DefineSection(1, coverLen);
8426
8427   // The first hole: a Xtru (rounded corners approximated with segments)
8428   Double_t holethick = kExternalCoverTotalThick-kExternalCoverInternThick;
8429
8430   TGeoXtru *extCoverHole1 = new TGeoXtru(2);
8431   extCoverHole1->SetName("ITSsuppExtCoverHole1");
8432
8433   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen1,
8434                              kExternalCoverHoleR10 , xprof, yprof);
8435
8436   extCoverHole1->DefinePolygon(16, xprof, yprof);
8437   extCoverHole1->DefineSection(0, 0);
8438   extCoverHole1->DefineSection(1, holethick);
8439
8440   // The second (and third) hole: another Xtru
8441   TGeoXtru *extCoverHole2 = new TGeoXtru(2);
8442   extCoverHole2->SetName("ITSsuppExtCoverHole2");
8443
8444   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen2,
8445                              kExternalCoverHoleR10 , xprof, yprof);
8446
8447   extCoverHole2->DefinePolygon(16, xprof, yprof);
8448   extCoverHole2->DefineSection(0, 0);
8449   extCoverHole2->DefineSection(1, holethick);
8450
8451   // The fourth hole: another Xtru
8452   TGeoXtru *extCoverHole3 = new TGeoXtru(2);
8453   extCoverHole3->SetName("ITSsuppExtCoverHole3");
8454
8455   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen3,
8456                              kExternalCoverHoleR10 , xprof, yprof);
8457
8458   extCoverHole3->DefinePolygon(16, xprof, yprof);
8459   extCoverHole3->DefineSection(0, 0);
8460   extCoverHole3->DefineSection(1, holethick);
8461
8462   // The fifth and last hole: another Xtru
8463   TGeoXtru *extCoverHole4 = new TGeoXtru(2);
8464   extCoverHole4->SetName("ITSsuppExtCoverHole4");
8465
8466   CreateTrayACoverHolesShape(kExternalCoverHoleWide, kExternalCoverHoleLen4,
8467                              kExternalCoverHoleR10 , xprof, yprof);
8468
8469   extCoverHole4->DefinePolygon(16, xprof, yprof);
8470   extCoverHole4->DefineSection(0, 0);
8471   extCoverHole4->DefineSection(1, holethick);
8472
8473   // Now the proper rototranslation matrices for the holes
8474   yloc = kExternalCoverTotalThick - kExternalCoverInternThick-0.01;
8475   zloc = kExternalCoverHole1ZTrans;
8476   TGeoCombiTrans *me1 = new TGeoCombiTrans(0, yloc, zloc,
8477                                            new TGeoRotation("", 0, 90, 0) );
8478   me1->SetName("me1");
8479   me1->RegisterYourself();
8480
8481   zloc += (kExternalCoverHoleLen1 + kExternalCoverHolesZTrans);
8482   TGeoCombiTrans *me2 = new TGeoCombiTrans(0, yloc, zloc,
8483                                            new TGeoRotation("", 0, 90, 0) );
8484   me2->SetName("me2");
8485   me2->RegisterYourself();
8486
8487   zloc += (kExternalCoverHoleLen2 + kExternalCoverHolesZTrans);
8488   TGeoCombiTrans *me3 = new TGeoCombiTrans(0, yloc, zloc,
8489                                            new TGeoRotation("", 0, 90, 0) );
8490   me3->SetName("me3");
8491   me3->RegisterYourself();
8492
8493   zloc += (kExternalCoverHoleLen2 + kExternalCoverHolesZTrans);
8494   TGeoCombiTrans *me4 = new TGeoCombiTrans(0, yloc, zloc,
8495                                            new TGeoRotation("", 0, 90, 0) );
8496   me4->SetName("me4");
8497   me4->RegisterYourself();
8498
8499   zloc += (kExternalCoverHoleLen3 + kExternalCoverHolesZTrans);
8500   TGeoCombiTrans *me5 = new TGeoCombiTrans(0, yloc, zloc,
8501                                            new TGeoRotation("", 0, 90, 0) );
8502   me5->SetName("me5");
8503   me5->RegisterYourself();
8504
8505   // Finally the actual cover shape
8506   TGeoCompositeShape *cover = new TGeoCompositeShape("ITSsuppExternCoverMain",
8507     "ITSsuppExternCoverMain-ITSsuppExtCoverHole1:me1-ITSsuppExtCoverHole2:me2-ITSsuppExtCoverHole2:me3-ITSsuppExtCoverHole3:me4-ITSsuppExtCoverHole4:me5");
8508
8509   return cover;
8510 }
8511
8512 //______________________________________________________________________
8513 void AliITSv11GeometrySupport::CreateTrayACoverHolesShape(const Double_t wide,
8514                                const Double_t length, const Double_t r10,
8515                                Double_t *x, Double_t *y){
8516 //
8517 // Creates the proper sequence of X and Y coordinates to determine
8518 // the base XTru polygon for the holes in the SDD and SSD tray covers
8519 // (here the rounded corners are approximated with segments)
8520 //
8521 // Input:
8522 //        wide   : the hole wide
8523 //        length : the hole length
8524 //        r10    : the radius of the rounded corners
8525 //
8526 // Output:
8527 //        x, y : coordinate vectors [16]
8528 //
8529 // Created:      03 Jan 2010  Mario Sitta
8530 //
8531 // Caller must guarantee that x and y have the correct dimensions
8532 // (but being this a private method it's easy to tell)
8533 //
8534
8535   x[0] = wide/2 - r10;
8536   y[0] = length;
8537   x[1] = x[0] + r10*SinD(30);
8538   y[1] = y[0] - r10*(1 - CosD(30));
8539   x[2] = x[0] + r10*SinD(60);
8540   y[2] = y[0] - r10*(1 - CosD(60));
8541   x[3] = x[0] + r10;
8542   y[3] = y[0] - r10;
8543   x[4] = x[3];
8544   y[4] = r10;
8545   x[5] = x[4] - r10*(1 - CosD(30));
8546   y[5] = y[4] - r10*SinD(30);
8547   x[6] = x[4] - r10*(1 - CosD(60));
8548   y[6] = y[4] - r10*SinD(60);
8549   x[7] = x[4] - r10;
8550   y[7] = 0;
8551
8552   // We did the right side, now reflex on the left side
8553   for (Int_t jp = 0; jp < 8; jp++) {
8554     x[8+jp] = -x[7-jp];
8555     y[8+jp] =  y[7-jp];
8556   }
8557
8558   return;
8559 }
8560
8561 //______________________________________________________________________
8562 TGeoXtru* AliITSv11GeometrySupport::CreateSDDSSDTraysSideA(
8563                                               const Double_t trayLen,
8564                                               const Double_t trayHi){
8565 //
8566 // Creates parts of the SDD and SSD Trays on Side A which are identical
8567 // (0872/G/D/03, part of 0872/G/D/07, 0872/G/C/11)
8568 //
8569 // Input:
8570 //         trayLen : the length of the tray part
8571 //         trayHi  : the height of the tray part
8572 //
8573 // Output:
8574 //
8575 // Return:     a TGeoXtru
8576 //
8577 // Created:      26 Feb 2010  Mario Sitta
8578 //
8579 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
8580 // drawings and other (oral) information given by F.Tosello
8581 //
8582
8583   // Dimensions and positions of the A-Side Cable Trays
8584   // (parts of 0872/G/C)
8585   const Double_t kTrayWidth              =  130.00 *fgkmm;
8586   const Double_t kTrayWingWidth          =   10.00 *fgkmm;
8587   const Double_t kTrayHeightToBend       =   20.00 *fgkmm;
8588   const Double_t kTrayThick              =    2.00 *fgkmm;
8589
8590   const Double_t kTrayBendAngle          =   22.00 *TMath::DegToRad();
8591
8592   const Int_t    kTrayNpoints            =   16;
8593
8594   // Local variables
8595   Double_t xprof[kTrayNpoints], yprof[kTrayNpoints];
8596
8597
8598   // The tray shape: a Xtru
8599   TGeoXtru *trayPart = new TGeoXtru(2);
8600
8601   xprof[2] = kTrayWidth/2 - kTrayThick;
8602   yprof[2] = trayHi - kTrayThick;
8603   xprof[3] = kTrayWidth/2 - kTrayWingWidth;
8604   yprof[3] = yprof[2];
8605   xprof[4] = xprof[3];
8606   yprof[4] = trayHi;
8607   xprof[5] = kTrayWidth/2;
8608   yprof[5] = yprof[4];
8609   xprof[6] = xprof[5];
8610   yprof[6] = kTrayHeightToBend;
8611   xprof[7] = xprof[6] - yprof[6]*TMath::Tan(kTrayBendAngle);
8612   yprof[7] = 0;
8613
8614   InsidePoint( xprof[5], yprof[5], xprof[6], yprof[6], xprof[7], yprof[7],
8615               -kTrayThick, xprof[1], yprof[1]);
8616
8617   xprof[8] = -xprof[7];
8618   yprof[8] =  yprof[7];
8619
8620   InsidePoint( xprof[6], yprof[6], xprof[7], yprof[7], xprof[8], yprof[8],
8621               -kTrayThick, xprof[0], yprof[0]);
8622
8623   // We did the right side, now reflex on the left side
8624   for (Int_t jp = 0; jp < 8; jp++) {
8625     xprof[8+jp] = -xprof[7-jp];
8626     yprof[8+jp] =  yprof[7-jp];
8627   }
8628
8629   // And now the actual Xtru
8630   trayPart->DefinePolygon(kTrayNpoints, xprof, yprof);
8631   trayPart->DefineSection(0, 0);
8632   trayPart->DefineSection(1, trayLen);
8633
8634
8635   return trayPart;
8636 }
8637
8638 //______________________________________________________________________
8639 TGeoVolumeAssembly* AliITSv11GeometrySupport::CreateSDDSSDTraysSideC(
8640                                                        const char *trayName,
8641                                                        const TGeoManager *mgr){
8642
8643 //
8644 // Creates the SDD and SSD Trays on Side C which are supposedly identical
8645 //
8646 // Input:
8647 //         trayName : the assembly name
8648 //
8649 // Output:
8650 //
8651 // Return:     a TGeoVolumeAssembly
8652 //
8653 // Created:      16 Apr 2010  Mario Sitta
8654 //
8655 // Technical data are taken from AutoCAD drawings and other (oral)
8656 // information given by F.Tosello
8657 //
8658
8659   const Double_t kSideCHalfThick      =    0.100   *fgkcm;
8660   const Double_t kSideCFoldAngle      =    5.000   *TMath::DegToRad();
8661
8662   const Double_t kSideCLength1        =  172.800   *fgkcm;
8663   const Double_t kSideCLength2        =  189.300   *fgkcm;
8664   const Double_t kSideCHalfWide       =    6.350   *fgkcm;
8665   const Double_t kSideCHeight1        =   11.800   *fgkcm;
8666   const Double_t kSideCHeight2        =    4.300   *fgkcm;
8667   const Double_t kSideCSideLength1    =   10.800   *fgkcm;
8668   const Double_t kSideCSideLength2    =   63.800   *fgkcm;
8669   const Double_t kSideCSideHeight     =    8.800   *fgkcm;
8670   const Int_t    kNPointsLowerFace    =    6;
8671   const Int_t    kNPointsLateralFace  =    9;
8672
8673   const Double_t kSideCWingAHalfLen   =    5.000   *fgkcm;
8674   const Double_t kSideCWingBHalfLen   =   30.500   *fgkcm;
8675   const Double_t kSideCWingCHalfLen   =    2.000   *fgkcm;
8676   const Double_t kSideCWingDHalfLen   =   48.500   *fgkcm;
8677   const Double_t kSideCWingEHalfLen   =   83.000   *fgkcm;
8678   const Double_t kSideCWingsHalfWide  =    0.450   *fgkcm;
8679
8680   const Int_t    kNPointsCoverFace    =   12;
8681
8682   const Double_t kPlateHalfLen        =    6.000   *fgkcm;
8683   const Double_t kPlateThick          =    0.600   *fgkcm;
8684   const Double_t kPlateHeight         =    4.200   *fgkcm;
8685   const Int_t    kNPointsPlate        =    6;
8686
8687   const Double_t kBarCoolRmax         =    0.4     *fgkcm;
8688   const Int_t    kNumBarCool          =    2;
8689   const Double_t kXShiftBarCool[kNumBarCool] = { 8.7, 13.0 };
8690   const Double_t kYShiftBarCool[kNumBarCool] = { 8.5,  5.0 };
8691
8692
8693   // Local variables
8694   Double_t xprof[12], yprof[12];
8695   Double_t xloc, yloc, zloc, delta, alpharot;
8696
8697   // The single C-Side Cable tray as an assembly
8698   TGeoVolumeAssembly *cableTrayC = new TGeoVolumeAssembly(trayName);
8699
8700   // First create all needed shapes
8701
8702   // The Cable Tray lower face: a Xtru
8703   TGeoXtru *sideCLowerFace = new TGeoXtru(2);
8704
8705   xprof[0] = 0.;
8706   yprof[0] = 0.;
8707   xprof[1] = kSideCLength1;
8708   yprof[1] = 0.;
8709   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(kSideCFoldAngle);
8710   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(kSideCFoldAngle);
8711   xprof[3] = xprof[2] - 2*kSideCHalfThick*TMath::Sin(kSideCFoldAngle);
8712   yprof[3] = yprof[2] + 2*kSideCHalfThick*TMath::Cos(kSideCFoldAngle);
8713   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8714               2*kSideCHalfThick , xprof[4], yprof[4]);
8715   xprof[5] = 0.;
8716   yprof[5] = 2*kSideCHalfThick;
8717
8718   sideCLowerFace->DefinePolygon(kNPointsLowerFace, xprof, yprof);
8719   sideCLowerFace->DefineSection(0,-kSideCHalfWide);
8720   sideCLowerFace->DefineSection(1, kSideCHalfWide);
8721
8722   // The Cable Tray lateral face: a Xtru
8723   TGeoXtru *sideCLateralFace = new TGeoXtru(2);
8724
8725   xprof[0] = 0.;
8726   yprof[0] = 0.;
8727   xprof[1] = kSideCLength1;
8728   yprof[1] = 0.;
8729   xprof[2] = xprof[1] + kSideCLength2*TMath::Cos(kSideCFoldAngle);
8730   yprof[2] = yprof[1] + kSideCLength2*TMath::Sin(kSideCFoldAngle);
8731   xprof[3] = xprof[2] - kSideCHeight2*TMath::Sin(kSideCFoldAngle);
8732   yprof[3] = yprof[2] + kSideCHeight2*TMath::Cos(kSideCFoldAngle);
8733   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8734               kSideCHeight2, xprof[4], yprof[4]);
8735   xprof[5] = kSideCSideLength1 + kSideCSideLength2;
8736   yprof[5] = kSideCHeight2;
8737   xprof[6] = xprof[5];
8738   yprof[6] = kSideCSideHeight;
8739   xprof[7] = kSideCSideLength1;
8740   yprof[7] = kSideCHeight1;
8741   xprof[8] = 0;
8742   yprof[8] = yprof[7];
8743
8744   sideCLateralFace->DefinePolygon(kNPointsLateralFace, xprof, yprof);
8745   sideCLateralFace->DefineSection(0,-kSideCHalfThick);
8746   sideCLateralFace->DefineSection(1, kSideCHalfThick);
8747
8748   // The lateral wings: four BBox's
8749   TGeoBBox *sideCLateralWingA = new TGeoBBox(kSideCWingAHalfLen,
8750                                              kSideCHalfThick,
8751                                              kSideCWingsHalfWide);
8752
8753   TGeoBBox *sideCLateralWingB = new TGeoBBox(kSideCWingBHalfLen,
8754                                              kSideCHalfThick,
8755                                              kSideCWingsHalfWide);
8756
8757   TGeoBBox *sideCLateralWingC = new TGeoBBox(kSideCHalfThick,    // With these
8758                                              kSideCWingCHalfLen, // X,Y avoid
8759                                              kSideCWingsHalfWide);//rotations
8760
8761   TGeoBBox *sideCLateralWingD = new TGeoBBox(kSideCWingDHalfLen,
8762                                              kSideCHalfThick,
8763                                              kSideCWingsHalfWide);
8764
8765   TGeoBBox *sideCLateralWingE = new TGeoBBox(kSideCWingEHalfLen,
8766                                              kSideCHalfThick,
8767                                              kSideCWingsHalfWide);
8768
8769   // The connecting lower plate: a Xtru
8770   TGeoXtru *sideCLowerPlate =  new TGeoXtru(2);
8771
8772   xprof[0] = 0.;
8773   yprof[0] = 0.;
8774   xprof[1] = kPlateHalfLen;
8775   yprof[1] = 0.;
8776   xprof[2] = xprof[1] + kPlateHalfLen*TMath::Cos(kSideCFoldAngle);
8777   yprof[2] = kPlateHalfLen*TMath::Sin(kSideCFoldAngle);
8778   xprof[3] = xprof[2] - kPlateThick*TMath::Sin(kSideCFoldAngle);
8779   yprof[3] = yprof[2] + kPlateThick*TMath::Cos(kSideCFoldAngle);
8780   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8781               kPlateThick, xprof[4], yprof[4]);
8782   xprof[5] = 0.;
8783   yprof[5] = kPlateThick;
8784
8785   sideCLowerPlate->DefinePolygon(kNPointsPlate, xprof, yprof);
8786   Double_t zwide = kSideCHalfWide + 2*kSideCHalfThick;
8787   sideCLowerPlate->DefineSection(0,-zwide);
8788   sideCLowerPlate->DefineSection(1, zwide);
8789
8790   // The connecting side plate: a Xtru
8791   TGeoXtru *sideCLateralPlate = new TGeoXtru(2);
8792
8793   xprof[0] = 0.;
8794   yprof[0] = 0.;
8795   xprof[1] = kPlateHalfLen;
8796   yprof[1] = 0.;
8797   xprof[2] = xprof[1] + kPlateHalfLen*TMath::Cos(kSideCFoldAngle);
8798   yprof[2] = kPlateHalfLen*TMath::Sin(kSideCFoldAngle);
8799   xprof[3] = xprof[2] - kPlateHeight*TMath::Sin(kSideCFoldAngle);
8800   yprof[3] = yprof[2] + kPlateHeight*TMath::Cos(kSideCFoldAngle);
8801   InsidePoint(xprof[0], yprof[0], xprof[1], yprof[1], xprof[2], yprof[2],
8802               kPlateHeight, xprof[4], yprof[4]); // Avoid small overlap
8803   xprof[5] = 0.;
8804   yprof[5] = kPlateHeight;
8805
8806   sideCLateralPlate->DefinePolygon(kNPointsPlate, xprof, yprof);
8807   sideCLateralPlate->DefineSection(0,-kPlateThick/2);
8808   sideCLateralPlate->DefineSection(1, kPlateThick/2);
8809
8810   // The bar fixing the cooling tubes: a Tube
8811   TGeoTube *coolBar = new TGeoTube(0., kBarCoolRmax, kSideCHalfWide);
8812
8813   // The Cable Tray cover: a (complex) Xtru
8814   TGeoXtru *sideCCoverFace = new TGeoXtru(2);
8815
8816   xprof[ 0] = sideCLateralFace->GetX(8);
8817   yprof[ 0] = sideCLateralFace->GetY(8);
8818   xprof[ 1] = sideCLateralFace->GetX(7);
8819   yprof[ 1] = sideCLateralFace->GetY(7);
8820   xprof[ 2] = sideCLateralFace->GetX(6);
8821   yprof[ 2] = sideCLateralFace->GetY(6);
8822   xprof[ 3] = sideCLateralFace->GetX(5);
8823   yprof[ 3] = sideCLateralFace->GetY(5);
8824   xprof[ 4] = sideCLateralFace->GetX(4);
8825   yprof[ 4] = sideCLateralFace->GetY(4);
8826
8827   xloc = (kSideCLength1 + (kSideCSideLength1+kSideCSideLength2))/2;
8828   delta  = kSideCLength1 - (xloc + kSideCWingDHalfLen);
8829   xprof[ 5] = xprof[4]
8830             + (delta + 2*kSideCWingEHalfLen)*TMath::Cos(kSideCFoldAngle);
8831   yprof[ 5] = yprof[4]
8832             + (delta + 2*kSideCWingEHalfLen)*TMath::Sin(kSideCFoldAngle);
8833
8834   xprof[ 6] = xprof[5] - 2*kSideCHalfThick*TMath::Sin(kSideCFoldAngle);
8835   yprof[ 6] = yprof[5] + 2*kSideCHalfThick*TMath::Cos(kSideCFoldAngle);
8836   InsidePoint(xprof[3], yprof[3], xprof[4], yprof[4], xprof[5], yprof[5],
8837               2*kSideCHalfThick, xprof[7], yprof[7]);
8838   InsidePoint(xprof[2], yprof[2], xprof[3], yprof[3], xprof[4], yprof[4],
8839               2*kSideCHalfThick, xprof[8], yprof[8]);
8840   xprof[ 9] = xprof[2] + 2*kSideCHalfThick;
8841   yprof[ 9] = yprof[2] + 2*kSideCHalfThick;
8842   xprof[10] = xprof[1];
8843   yprof[10] = yprof[1] + 2*kSideCHalfThick;
8844   xprof[11] = xprof[0];
8845   yprof[11] = yprof[0] + 2*kSideCHalfThick;
8846
8847   sideCCoverFace->DefinePolygon(kNPointsCoverFace, xprof, yprof);
8848   zloc = kSideCHalfWide + 2*kSideCHalfThick + 2*kSideCWingsHalfWide;
8849   sideCCoverFace->DefineSection(0,-zloc);
8850   sideCCoverFace->DefineSection(1, zloc);
8851
8852
8853   // We have all shapes: now create the real volumes
8854   TGeoMedium *medAl      = mgr->GetMedium("ITS_ALUMINUM$");
8855
8856   TGeoVolume *traySideCLowerFace  = new TGeoVolume("ITSsuppTraySideCLower",
8857                                                    sideCLowerFace, medAl);
8858
8859   traySideCLowerFace->SetVisibility(kTRUE);
8860   traySideCLowerFace->SetLineColor(6); // Purple
8861   traySideCLowerFace->SetLineWidth(1);
8862   traySideCLowerFace->SetFillColor(traySideCLowerFace->GetLineColor());
8863   traySideCLowerFace->SetFillStyle(4000); // 0% transparent
8864
8865   TGeoVolume *traySideCLateralFace  = new TGeoVolume("ITSsuppTraySideCLateral",
8866                                                      sideCLateralFace, medAl);
8867
8868   traySideCLateralFace->SetVisibility(kTRUE);
8869   traySideCLateralFace->SetLineColor(6); // Purple
8870   traySideCLateralFace->SetLineWidth(1);
8871   traySideCLateralFace->SetFillColor(traySideCLateralFace->GetLineColor());
8872   traySideCLateralFace->SetFillStyle(4000); // 0% transparent
8873
8874   TGeoVolume *traySideCLateralWingA =
8875     new TGeoVolume("ITSsuppTraySideCLateralWingA", sideCLateralWingA,  medAl);
8876
8877   traySideCLateralWingA->SetVisibility(kTRUE);
8878   traySideCLateralWingA->SetLineColor(6); // Purple
8879   traySideCLateralWingA->SetLineWidth(1);
8880   traySideCLateralWingA->SetFillColor(traySideCLateralWingA->GetLineColor());
8881   traySideCLateralWingA->SetFillStyle(4000); // 0% transparent
8882
8883   TGeoVolume *traySideCLateralWingB =
8884     new TGeoVolume("ITSsuppTraySideCLateralWingB", sideCLateralWingB,  medAl);
8885
8886   traySideCLateralWingB->SetVisibility(kTRUE);
8887   traySideCLateralWingB->SetLineColor(6); // Purple
8888   traySideCLateralWingB->SetLineWidth(1);
8889   traySideCLateralWingB->SetFillColor(traySideCLateralWingB->GetLineColor());
8890   traySideCLateralWingB->SetFillStyle(4000); // 0% transparent
8891
8892   TGeoVolume *traySideCLateralWingC =
8893     new TGeoVolume("ITSsuppTraySideCLateralWingC", sideCLateralWingC,  medAl);
8894
8895   traySideCLateralWingC->SetVisibility(kTRUE);
8896   traySideCLateralWingC->SetLineColor(6); // Purple
8897   traySideCLateralWingC->SetLineWidth(1);
8898   traySideCLateralWingC->SetFillColor(traySideCLateralWingC->GetLineColor());
8899   traySideCLateralWingC->SetFillStyle(4000); // 0% transparent
8900
8901   TGeoVolume *traySideCLateralWingD =
8902     new TGeoVolume("ITSsuppTraySideCLateralWingD", sideCLateralWingD,  medAl);
8903
8904   traySideCLateralWingD->SetVisibility(kTRUE);
8905   traySideCLateralWingD->SetLineColor(6); // Purple
8906   traySideCLateralWingD->SetLineWidth(1);
8907   traySideCLateralWingD->SetFillColor(traySideCLateralWingD->GetLineColor());
8908   traySideCLateralWingD->SetFillStyle(4000); // 0% transparent
8909
8910   TGeoVolume *traySideCLateralWingE =
8911     new TGeoVolume("ITSsuppTraySideCLateralWingE", sideCLateralWingE,  medAl);
8912
8913   traySideCLateralWingE->SetVisibility(kTRUE);
8914   traySideCLateralWingE->SetLineColor(6); // Purple
8915   traySideCLateralWingE->SetLineWidth(1);
8916   traySideCLateralWingE->SetFillColor(traySideCLateralWingE->GetLineColor());
8917   traySideCLateralWingE->SetFillStyle(4000); // 0% transparent
8918
8919   TGeoVolume *traySideCLowerPlate =
8920     new TGeoVolume("ITSsuppTraySideCLowerPlate", sideCLowerPlate,  medAl);
8921
8922   traySideCLowerPlate->SetVisibility(kTRUE);
8923   traySideCLowerPlate->SetLineColor(6); // Purple
8924   traySideCLowerPlate->SetLineWidth(1);
8925   traySideCLowerPlate->SetFillColor(traySideCLowerPlate->GetLineColor());
8926   traySideCLowerPlate->SetFillStyle(4000); // 0% transparent
8927
8928   TGeoVolume *traySideCLateralPlate =
8929     new TGeoVolume("ITSsuppTraySideCLateralPlate", sideCLateralPlate,  medAl);
8930
8931   traySideCLateralPlate->SetVisibility(kTRUE);
8932   traySideCLateralPlate->SetLineColor(6); // Purple
8933   traySideCLateralPlate->SetLineWidth(1);
8934   traySideCLateralPlate->SetFillColor(traySideCLateralPlate->GetLineColor());
8935   traySideCLateralPlate->SetFillStyle(4000); // 0% transparent
8936
8937   TGeoVolume *traySideCCoverFace =
8938     new TGeoVolume("ITSsuppTraySideCCoverFace", sideCCoverFace,  medAl);
8939
8940   traySideCCoverFace->SetVisibility(kTRUE);
8941   traySideCCoverFace->SetLineColor(6); // Purple
8942   traySideCCoverFace->SetLineWidth(1);
8943   traySideCCoverFace->SetFillColor(traySideCCoverFace->GetLineColor());
8944   traySideCCoverFace->SetFillStyle(4000); // 0% transparent
8945
8946   TGeoVolume *coolingTubeBar = new TGeoVolume("ITSsuppTraySideCCoolBar",
8947                                               coolBar, medAl);
8948
8949   coolingTubeBar->SetVisibility(kTRUE);
8950   coolingTubeBar->SetLineColor(6); // Purple
8951   coolingTubeBar->SetLineWidth(1);
8952   coolingTubeBar->SetFillColor(coolingTubeBar->GetLineColor());
8953   coolingTubeBar->SetFillStyle(4000); // 0% transparent
8954
8955
8956   // Now build up the tray
8957   cableTrayC->AddNode(traySideCLowerFace,1,0);
8958
8959   zloc = kSideCHalfWide + kSideCHalfThick;
8960   cableTrayC->AddNode(traySideCLateralFace,1,
8961                             new TGeoTranslation(0., 0., zloc) );
8962   cableTrayC->AddNode(traySideCLateralFace,2,
8963                             new TGeoTranslation(0., 0.,-zloc) );
8964
8965   xloc = kSideCWingAHalfLen;
8966   yloc = kSideCHeight1 - kSideCHalfThick;
8967   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8968   cableTrayC->AddNode(traySideCLateralWingA,1,
8969                             new TGeoTranslation(xloc, yloc, zloc) );
8970   cableTrayC->AddNode(traySideCLateralWingA,2,
8971                             new TGeoTranslation(xloc, yloc,-zloc) );
8972
8973   xloc = kSideCSideLength1 + kSideCSideLength2/2;
8974   yloc = Yfrom2Points(kSideCSideLength1,kSideCHeight1,
8975                       kSideCSideLength1+kSideCSideLength2,kSideCSideHeight,
8976                       xloc) - kSideCHalfThick -0.0012; // Avoid small overlap
8977   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8978   alpharot = (-(kSideCHeight1 - kSideCSideHeight)/kSideCSideLength2 )*
8979                 TMath::RadToDeg();
8980   cableTrayC->AddNode(traySideCLateralWingB,1,
8981                             new TGeoCombiTrans(xloc, yloc, zloc,
8982                                         new TGeoRotation("",alpharot,0,0) ) );
8983   cableTrayC->AddNode(traySideCLateralWingB,2,
8984                             new TGeoCombiTrans(xloc, yloc,-zloc,
8985                                         new TGeoRotation("",alpharot,0,0) ) );
8986
8987   xloc = kSideCSideLength1 + kSideCSideLength2 - kSideCHalfThick;
8988   yloc = kSideCSideHeight - kSideCWingCHalfLen;
8989   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8990   cableTrayC->AddNode(traySideCLateralWingC,1,
8991                             new TGeoTranslation(xloc, yloc, zloc) );
8992   cableTrayC->AddNode(traySideCLateralWingC,2,
8993                             new TGeoTranslation(xloc, yloc,-zloc) );
8994
8995   xloc = (kSideCLength1 + (kSideCSideLength1+kSideCSideLength2))/2;
8996   yloc = kSideCHeight2 - kSideCHalfThick;
8997   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
8998   cableTrayC->AddNode(traySideCLateralWingD,1,
8999                             new TGeoTranslation(xloc, yloc, zloc) );
9000   cableTrayC->AddNode(traySideCLateralWingD,2,
9001                             new TGeoTranslation(xloc, yloc,-zloc) );
9002
9003   delta = kSideCLength1 - (xloc + kSideCWingDHalfLen);
9004   xloc = kSideCLength1 + delta + kSideCWingEHalfLen;
9005   yloc = (xloc - kSideCLength1)*TMath::Tan(kSideCFoldAngle) +
9006           kSideCHeight2*TMath::Cos(kSideCFoldAngle) - kSideCHalfThick;
9007   zloc = kSideCHalfWide + 2*kSideCHalfThick + kSideCWingsHalfWide;
9008   alpharot = kSideCFoldAngle*TMath::RadToDeg();
9009   cableTrayC->AddNode(traySideCLateralWingE,1,
9010                             new TGeoCombiTrans(xloc, yloc, zloc,
9011                                         new TGeoRotation("",alpharot,0,0) ) );
9012   cableTrayC->AddNode(traySideCLateralWingE,2,
9013                             new TGeoCombiTrans(xloc, yloc,-zloc,
9014                                         new TGeoRotation("",alpharot,0,0) ) );
9015
9016   xloc = kSideCLength1 - kPlateHalfLen;
9017   yloc = -kPlateThick -0.0025; // Avoid small overlap
9018   cableTrayC->AddNode(traySideCLowerPlate,1,
9019                             new TGeoTranslation(xloc, yloc, 0.) );
9020
9021   xloc = kSideCLength1 - kPlateHalfLen;
9022   yloc = -kPlateThick;
9023   zloc = kSideCHalfWide + 2*kSideCHalfThick + kPlateThick/2;
9024   cableTrayC->AddNode(traySideCLateralPlate,1,
9025                             new TGeoTranslation(xloc, yloc, zloc) );
9026   cableTrayC->AddNode(traySideCLateralPlate,2,
9027                             new TGeoTranslation(xloc, yloc,-zloc) );
9028
9029   for (Int_t jc = 0; jc <kNumBarCool; jc++) {
9030     xloc = kXShiftBarCool[jc];
9031     yloc = kYShiftBarCool[jc];
9032     cableTrayC->AddNode(coolingTubeBar,jc+1,
9033                               new TGeoTranslation(xloc, yloc, 0.) );
9034   }
9035
9036   cableTrayC->AddNode(traySideCCoverFace,1,0);
9037
9038
9039   // Finally return what we made up
9040
9041   return cableTrayC;
9042 }
9043
9044 //______________________________________________________________________
9045 void AliITSv11GeometrySupport::ITSTPCSupports(TGeoVolume *moth,
9046                                         const TGeoManager *mgr){
9047 //
9048 // Creates the elements suspending the ITS to the TPC and other fixed
9049 // elements used to hook the rails (0872/C and its daughters)
9050 //
9051 // Input:
9052 //         moth : the TGeoVolume owing the volume structure
9053 //         mgr  : the GeoManager (default gGeoManager)
9054 // Output:
9055 //
9056 // Return:
9057 //
9058 // Created:      28 Oct 2010  Mario Sitta
9059 // Updated:      18 Feb 2011  Mario Sitta
9060 //
9061 // Technical data are taken from AutoCAD drawings, L.Simonetti technical
9062 // drawings and other (oral) information given by F.Tosello
9063 //
9064
9065   // Dimensions and positions of the half ring C2/C3 (0872/C/04)
9066   const Double_t kRingCZPos           =   733.000*fgkmm;
9067   const Double_t kRingCZToTPC         =     5.500*fgkmm;
9068
9069   const Double_t kRingCThick          =    12.000*fgkmm;
9070   const Double_t kRingCRmin           =   565.000*fgkmm;
9071   const Double_t kRingCRmax           =   592.000*fgkmm;
9072   const Double_t kRingCHeight         =   560.000*fgkmm;
9073   const Double_t kRingCXToInsert      =   515.000*fgkmm;
9074   const Double_t kRingCYToInsert      =   113.000*fgkmm;
9075
9076   const Int_t kNumberOfRingPoints     =    23; // N.points to approximate arc
9077
9078   // Dimensions of the forward upper hook (0872/C/09)
9079   const Double_t kForwUpHookThick     =    20.000*fgkmm;
9080   const Double_t kForwUpHookRext      =   590.000*fgkmm;
9081   const Double_t kForwUpHookRint      =    20.000*fgkmm;
9082   const Double_t kForwUpHookHiTot     =    89.000*fgkmm;
9083   const Double_t kForwUpHookHiInt     =    59.000*fgkmm;
9084   const Double_t kForwUpHookWide      =    96.000*fgkmm;
9085   const Double_t kForwUpHookHalfBase  =    25.000*fgkmm;
9086   const Double_t kForwUpHookBaseCut   =    10.000*fgkmm;
9087   const Double_t kForwUpHookHoleWide  =    25.000*fgkmm;
9088   const Double_t kForwUpHookHoleHi    =    22.500*fgkmm;
9089   const Double_t kForwUpHookHoleBase  =     5.000*fgkmm;
9090   const Double_t kForwUpHookHoleR5    =     5.000*fgkmm;
9091   const Double_t kForwUpHookHoleY     =     8.000*fgkmm;
9092   const Double_t kForwUpHookHollowHi  =    35.000*fgkmm;
9093   const Double_t kForwUpHookHollowWide=     5.000*fgkmm;
9094
9095   const Int_t kNumberOfForwUpHookPts  =    11;
9096   const Int_t kNumbOfForwUpHookHolePts=     5;
9097
9098   // Dimensions of the forward lower hook (0872/C/08)
9099   const Double_t kForwLwHookThick     =    20.000*fgkmm;
9100   const Double_t kForwLwHookRext      =   590.000*fgkmm;
9101   const Double_t kForwLwHookRint      =    20.000*fgkmm;
9102   const Double_t kForwLwHookHiTot     =    88.500*fgkmm;
9103   const Double_t kForwLwHookWide      =    96.000*fgkmm;
9104   const Double_t kForwLwHookHalfBase  =    25.000*fgkmm;
9105   const Double_t kForwLwHookBaseCut   =    10.000*fgkmm;
9106   const Double_t kForwLwHookYToHollow =     3.500*fgkmm;
9107   const Double_t kForwLwHookHoleR     =     7.500*fgkmm;
9108   const Double_t kForwLwHookHoleIntHi =    35.000*fgkmm;
9109   const Double_t kForwLwHookHoleYPos  =    13.500*fgkmm;
9110   const Double_t kForwLwHookHollowHi  =    62.000*fgkmm;
9111   const Double_t kForwLwHookHollowWide=     5.000*fgkmm;
9112
9113   const Int_t kNumberOfForwLwHookPts  =    11;
9114   const Int_t kNumbOfForwLwHookHolePts=     7;
9115
9116   // Dimensions of the rear upper hook (0872/C/10)
9117   const Double_t kRearUpHookThick     =    15.000*fgkmm;
9118   const Double_t kRearUpHookRext      =   590.000*fgkmm;
9119   const Double_t kRearUpHookRint      =    20.000*fgkmm;
9120   const Double_t kRearUpHookHiTot     =    53.500*fgkmm;
9121   const Double_t kRearUpHookHiInt     =    23.500*fgkmm;
9122   const Double_t kRearUpHookWide      =    96.000*fgkmm;
9123   const Double_t kRearUpHookHalfBase  =    25.000*fgkmm;
9124   const Double_t kRearUpHookHoleWide  =    25.000*fgkmm;
9125   const Double_t kRearUpHookHoleHi    =    22.500*fgkmm;
9126   const Double_t kRearUpHookHoleBase  =     5.000*fgkmm;
9127   const Double_t kRearUpHookHoleR5    =     5.000*fgkmm;
9128   const Double_t kRearUpHookHoleY     =     8.000*fgkmm;
9129
9130   const Int_t kNumberOfRearUpHookPts  =    10;
9131   const Int_t kNumbOfRearUpHookHolePts=     5;
9132
9133   // Dimensions of the forward lower hook (0872/C/11)
9134   const Double_t kRearLwHookThick     =    20.000*fgkmm;
9135   const Double_t kRearLwHookRext      =   590.000*fgkmm;
9136   const Double_t kRearLwHookHiTot     =    30.000*fgkmm;
9137   const Double_t kRearLwHookWide      =    96.000*fgkmm;
9138
9139   const Int_t kNumberOfRearLwHookPts  =     3;
9140
9141   // Dimensions of the rear lower brackets (0872/C/16)
9142   const Double_t kRearLwBracketThick  =    15.000*fgkmm;
9143   const Double_t kRearLwBracketHi1    =    42.000*fgkmm;
9144   const Double_t kRearLwBracketHi2    =    12.000*fgkmm;
9145   const Double_t kRearLwBracketWide1  =    34.000*fgkmm;
9146   const Double_t kRearLwBracketWide2  =    10.000*fgkmm;
9147 //  const Double_t kRearLwBracketR5     =     5.000*fgkmm
9148
9149   // Dimensions of the forward webcam supports (0872/C/V/01-03-04)
9150   const Double_t kForwWebSStirrDep    =    20.000*fgkmm;
9151   const Double_t kForwWebSStirrLen1   =    15.000*fgkmm;
9152   const Double_t kForwWebSStirrLen2   =    55.000*fgkmm;
9153   const Double_t kForwWebSStirrLen3   =    10.000*fgkmm;
9154   const Double_t kForwWebSStirrWide1  =    45.000*fgkmm;
9155   const Double_t kForwWebSStirrWide2  =    38.000*fgkmm;
9156   const Double_t kForwWebSStirrWide3  =    23.000*fgkmm;
9157   const Double_t kForwWebTStirrThick  =     5.000*fgkmm;
9158   const Double_t kForwWebTStirrWide1  =    30.000*fgkmm;
9159   const Double_t kForwWebTStirrWide2  =    10.000*fgkmm;
9160   const Double_t kForwWebTStirrTotLen3=    58.500*fgkmm;
9161   const Double_t kForwWebTStirrTotLen4=    36.000*fgkmm;
9162   const Double_t kForwWebTStirrLen1   =    10.000*fgkmm;
9163
9164   // Dimensions of the forward and rear webcam clamps (0872/C/V/02)
9165   const Double_t kFRWebClampThick     =    10.000*fgkmm;
9166   const Double_t kFRWebClampExtWide   =    30.000*fgkmm;
9167   const Double_t kFRWebClampIntWide   =    18.000*fgkmm;
9168   const Double_t kFRWebClampExtHi     =    22.000*fgkmm;
9169   const Double_t kFRWebClampIntHi     =    17.000*fgkmm;
9170
9171   // Dimensions of the webcam itself
9172   const Double_t kWebcamLength        =    35.000*fgkmm;//ESTIMATED!!!
9173
9174   // Dimensions of the rear upper webcam supports (0872/C/V/05-06)
9175   const Double_t kRearUpWebStirrWide  =    76.000*fgkmm;
9176   const Double_t kRearUpWebStirrDep   =    15.000*fgkmm;
9177   const Double_t kRearUpWebStirrThick =     5.000*fgkmm;
9178   const Double_t kRearUpWebStirrH1    =    27.000*fgkmm;
9179   const Double_t kRearUpWebStirrH2    =    32.000*fgkmm;
9180   const Double_t kRearUpWebBarLen     =   130.000*fgkmm;
9181   const Double_t kRearUpWebBarHi      =    20.000*fgkmm;
9182   const Double_t kRearUpWebBarThick   =     5.000*fgkmm;
9183
9184   // Dimensions of the upper wheel slides (0872/C/Z/00-01-02)
9185   const Double_t kUpperSlideTotHeight =    93.500*fgkmm;
9186   const Double_t kUpperSlideBlockHi   =    62.500*fgkmm;
9187   const Double_t kUpperSlideWidth     =    36.000*fgkmm;
9188   const Double_t kUpperSlideTotDepth  =    51.000*fgkmm;
9189   const Double_t kUpperSlideIntDepth  =    36.000*fgkmm;
9190   const Double_t kUpperSlideStubHi    =    15.000*fgkmm;
9191   const Double_t kUpperSlideStubDep   =     8.000*fgkmm;
9192   const Double_t kUpperSlideWheelHi   =    18.500*fgkmm;
9193   const Double_t kUpperSlideHoleRout  =    11.000*fgkmm;
9194   const Double_t kUpperSlideHoleRint1 =     9.000*fgkmm;
9195   const Double_t kUpperSlideHoleRint2 =    11.500*fgkmm;
9196   const Double_t kUpperSlideHoleH1    =     7.000*fgkmm;
9197   const Double_t kUpperSlideHoleH2    =    46.000*fgkmm;
9198   const Double_t kUpperSlideHoleH3    =     1.100*fgkmm;
9199   const Double_t kUpperSlideHoleXPos  =    20.000*fgkmm;
9200   const Double_t kUpperSlidePinRmin   =     4.000*fgkmm;
9201   const Double_t kUpperSlidePinRmax   =     6.000*fgkmm;
9202   const Double_t kUpperSlidePinH1     =     7.000*fgkmm;
9203   const Double_t kUpperSlidePinH2     =    46.000*fgkmm;
9204   const Double_t kUpperSlidePinH3     =    25.500*fgkmm;
9205
9206   // Dimensions of the lower wheel slides (0872/C/W/00-01-02-03)
9207   const Double_t kLowerSlideTotHeight =    80.000*fgkmm;
9208   const Double_t kLowerSlideBlockHi   =    28.000*fgkmm;
9209   const Double_t kLowerSlideWidth     =    36.000*fgkmm;
9210   const Double_t kLowerSlideTotDepth  =    60.000*fgkmm;
9211   const Double_t kLowerSlideHoleRout  =     9.500*fgkmm;
9212   const Double_t kLowerSlideHoleRint  =     4.700*fgkmm;
9213   const Double_t kLowerSlideHoleH1    =    12.000*fgkmm;
9214   const Double_t kLowerSlideNoseBase  =    40.000*fgkmm;
9215   const Double_t kLowerSlideNoseBasHi =     6.000*fgkmm;//Computed
9216   const Double_t kLowerSlideNoseUpWid =    25.000*fgkmm;
9217   const Double_t kLowerSlideNoseDepth =    10.000*fgkmm;
9218   const Double_t kLowerSlidePinRmin   =     3.000*fgkmm;
9219   const Double_t kLowerSlidePinRmax   =     4.000*fgkmm;
9220   const Double_t kLowerSlidePinH1     =    12.000*fgkmm;
9221   const Double_t kLowerSlidePinH2     =    10.000*fgkmm;
9222
9223   // Dimensions and positions of the C1/C2 rail stirrups (0872/C/01-02)
9224   const Double_t kStirrCXPos          =   759.000*fgkmm;
9225   const Double_t kStirrCZPos          =  1867.000*fgkmm;
9226
9227   const Double_t kStirrC12Thick       =    15.000*fgkmm;
9228   const Double_t kStirrC12TotLen      =   314.000*fgkmm;
9229   const Double_t kStirrC12BodyHalfHi  =    95.000*fgkmm;
9230   const Double_t kStirrC12BodyLen     =   153.000*fgkmm;
9231   const Double_t kStirrC12HeadLen     =    50.000*fgkmm;
9232   const Double_t kStirrC12HeadHalfHi  =   165.000*fgkmm;
9233   const Double_t kStirrC12HeadIntHi   =   114.000*fgkmm;
9234   const Double_t kStirrC12HeadIntLen  =    45.000*fgkmm;
9235   const Double_t kStirrC12TailLen     =    14.000*fgkmm;
9236   const Double_t kStirrC12R100        =   100.000*fgkmm;
9237   const Double_t kStirrC12R50         =    50.000*fgkmm;
9238   const Double_t kStirrC12R10         =    10.000*fgkmm;
9239   const Double_t kStirrC12HeadAng     =    40.000; // Degree
9240
9241   const Int_t kNumberOfStirrCPoints   =    23;
9242
9243   // Dimensions and positions of the C5 rail stirrups (0872/C/05)
9244   const Double_t kStirrC5BodyLen      =   155.000*fgkmm;
9245
9246
9247   // Local variables
9248   Double_t xprof[2*kNumberOfStirrCPoints+1],yprof[2*kNumberOfStirrCPoints+1];
9249   Double_t xpos, ypos, zpos, alpha;
9250   Double_t xdummy, ydummy;
9251   
9252
9253   // First create all needed shapes
9254
9255   // The Supporting Ring (0872/C/04): a really complex Xtru
9256   // to approximate the arc with a polyline
9257   TGeoXtru *ringC2C3 = new TGeoXtru(2);
9258
9259   for (Int_t j=0; j<11; j++) { // The external arc
9260     xprof[j] = kRingCRmax*SinD(90*j/10);
9261     yprof[j] = kRingCRmax*CosD(90*j/10);
9262   }
9263
9264   xprof[11] = kRingCRmin;
9265   yprof[11] = yprof[10];
9266
9267   alpha = TMath::ASin(kRingCYToInsert/kRingCRmin); // Now the insert
9268   xprof[12] = kRingCRmin*TMath::Cos(alpha/2);
9269   yprof[12] = kRingCRmin*TMath::Sin(alpha/2);
9270   xprof[13] = kRingCRmin*TMath::Cos(alpha);
9271   yprof[13] = kRingCRmin*TMath::Sin(alpha);
9272
9273   xprof[14] = kRingCXToInsert;
9274   yprof[14] = yprof[13];
9275
9276   alpha = TMath::ACos(kRingCXToInsert/kRingCRmin); // The insert ending angle
9277   xprof[15] = kRingCRmin*TMath::Cos(alpha);
9278   yprof[15] = kRingCRmin*TMath::Sin(alpha);
9279
9280   for (Int_t j=7; j>1; j--) { // The internal arc
9281     xprof[23-j] = kRingCRmin*SinD(90*j/10);
9282     yprof[23-j] = kRingCRmin*CosD(90*j/10);
9283   }
9284
9285   alpha = TMath::ASin(kRingCHeight/kRingCRmin);    // The angle till the notch
9286   xprof[22] = kRingCRmin*TMath::Cos(alpha);
9287   yprof[22] = kRingCRmin*TMath::Sin(alpha);
9288
9289   xprof[23] = xprof[0];
9290   yprof[23] = yprof[22];
9291
9292   // We did the right side, now reflex on the left side
9293   for (Int_t jp = 0; jp < 22; jp++) {
9294     xprof[24+jp] = -xprof[23-1-jp];
9295     yprof[24+jp] =  yprof[23-1-jp];
9296   }
9297
9298   // wow! now the actual Xtru
9299   ringC2C3->DefinePolygon(2*kNumberOfRingPoints, xprof, yprof);
9300   ringC2C3->DefineSection(0, 0);
9301   ringC2C3->DefineSection(1, kRingCThick);
9302
9303   // The Forward Upper Hook (0872/C/09): a Composite Shape made of
9304   // a really complex Xtru to approximate the arc with a polyline,
9305   // another Xtru for the hole, and a BBox for the hollow
9306   // The main body
9307   TGeoXtru *forwUpHookMainBody = new TGeoXtru(2);
9308   forwUpHookMainBody->SetName("ITSforwUpHookMainBody");
9309
9310   xprof[ 0] = kForwUpHookHalfBase - kForwUpHookBaseCut;
9311   yprof[ 0] = kForwUpHookRext - kForwUpHookHiTot;
9312   xprof[ 1] = kForwUpHookHalfBase;
9313   yprof[ 1] = yprof[0] + kForwUpHookBaseCut;
9314   xprof[ 2] = xprof[1];
9315   yprof[ 2] = yprof[0] + (kForwUpHookHiInt - kForwUpHookRint);
9316   for (Int_t j=1; j<6; j++) {
9317     xprof[2+j] = xprof[2] + kForwUpHookRint*(1 - CosD(90*j/5));
9318     yprof[2+j] = yprof[2] + kForwUpHookRint*SinD(90*j/5);
9319   }
9320   xprof[ 8] = kForwUpHookWide/2;
9321   yprof[ 8] = yprof[7];
9322   xprof[ 9] = xprof[8];
9323   alpha = TMath::ASin(0.5*kForwUpHookWide/kForwUpHookRext);
9324   yprof[ 9] = kForwUpHookRext*TMath::Cos(alpha);
9325   xprof[10] = kForwUpHookRext*TMath::Sin(alpha/2);
9326   yprof[10] = kForwUpHookRext*TMath::Cos(alpha/2);
9327   xprof[11] = 0;
9328   yprof[11] = kForwUpHookRext;
9329
9330   // We did the right side, now reflex on the left side
9331   for (Int_t jp = 0; jp < kNumberOfForwUpHookPts; jp++) {
9332     xprof[12+jp] = -xprof[10-jp];
9333     yprof[12+jp] =  yprof[10-jp];
9334   }
9335
9336   // Now the actual Xtru
9337   forwUpHookMainBody->DefinePolygon(2*kNumberOfForwUpHookPts+1, xprof, yprof);
9338   forwUpHookMainBody->DefineSection(0, 0);
9339   forwUpHookMainBody->DefineSection(1, kForwUpHookThick);
9340
9341   // The hole
9342   TGeoXtru *forwUpHookHole = new TGeoXtru(2);
9343   forwUpHookHole->SetName("ITSforwUpHookHole");
9344
9345   xprof[0] = kForwUpHookHoleBase/2;
9346   yprof[0] = forwUpHookMainBody->GetY(0) + kForwUpHookHoleY;
9347   xprof[1] = kForwUpHookHoleWide/2;
9348   yprof[1] = yprof[0] + (xprof[1] - xprof[0]); // Go at 45deg
9349   xprof[2] = xprof[1];
9350   yprof[2] = yprof[0] + kForwUpHookHoleHi - kForwUpHookHoleR5;
9351   xprof[3] = xprof[2] - kForwUpHookHoleR5*(1 - CosD(45));
9352   yprof[3] = yprof[2] + kForwUpHookHoleR5*SinD(45);
9353   xprof[4] = xprof[2] - kForwUpHookHoleR5;
9354   yprof[4] = yprof[0] + kForwUpHookHoleHi;
9355
9356   // We did the right side, now reflex on the left side
9357   for (Int_t jp = 0; jp < kNumbOfForwUpHookHolePts; jp++) {
9358     xprof[5+jp] = -xprof[4-jp];
9359     yprof[5+jp] =  yprof[4-jp];
9360   }
9361
9362   // Now the actual Xtru
9363   forwUpHookHole->DefinePolygon(2*kNumbOfForwUpHookHolePts, xprof, yprof);
9364   forwUpHookHole->DefineSection(0, -0.1);
9365   forwUpHookHole->DefineSection(1, kForwUpHookThick+0.1);
9366
9367   // The hollow
9368   TGeoBBox *forwUpHookHollow = new TGeoBBox(2.1 *kForwUpHookHalfBase,
9369                                             0.55*kForwUpHookHollowHi,
9370                                             0.55*kForwUpHookHollowWide);
9371   forwUpHookHollow->SetName("ITSforwUpHookHollow");
9372
9373   TGeoTranslation *forwUpHookHollPos = new TGeoTranslation(0.,
9374                       forwUpHookMainBody->GetY(0) + 0.5*kForwUpHookHollowHi,
9375                       forwUpHookMainBody->GetZ(1) - 0.5*kForwUpHookHollowWide);
9376   forwUpHookHollPos->SetName("ITSforwUpHookHollPos");
9377   forwUpHookHollPos->RegisterYourself();
9378
9379   // Finally the actual shape: a CompositeShape
9380   TGeoCompositeShape *forwUpHookShape = new TGeoCompositeShape("ITSforwUpHookMainBody-ITSforwUpHookHole-ITSforwUpHookHollow:ITSforwUpHookHollPos");
9381
9382   // The Forward Lower Hook (0872/C/08): a Composite Shape made of
9383   // a really complex Xtru to approximate the arc with a polyline,
9384   // another Xtru for the hole, and a BBox for the hollow
9385   // The main body
9386   TGeoXtru *forwLwHookMainBody = new TGeoXtru(2);
9387   forwLwHookMainBody->SetName("ITSforwLwHookMainBody");
9388
9389   xprof[ 0] = kForwLwHookHalfBase - kForwLwHookBaseCut;
9390   yprof[ 0] = kForwLwHookRext - kForwLwHookHiTot;
9391   xprof[ 1] = kForwLwHookHalfBase;
9392   yprof[ 1] = yprof[0] + kForwLwHookBaseCut;
9393   xprof[ 2] = xprof[1];
9394   yprof[ 2] = yprof[0] + (kForwLwHookHollowHi - kForwLwHookYToHollow
9395                           - kForwLwHookRint);
9396   for (Int_t j=1; j<6; j++) {
9397     xprof[2+j] = xprof[2] + kForwLwHookRint*(1 - CosD(90*j/5));
9398     yprof[2+j] = yprof[2] + kForwLwHookRint*SinD(90*j/5);
9399   }
9400   xprof[ 8] = kForwLwHookWide/2;
9401   yprof[ 8] = yprof[7];
9402   xprof[ 9] = xprof[8];
9403   alpha = TMath::ASin(0.5*kForwLwHookWide/kForwLwHookRext);
9404   yprof[ 9] = kForwLwHookRext*TMath::Cos(alpha);
9405   xprof[10] = kForwLwHookRext*TMath::Sin(alpha/2);
9406   yprof[10] = kForwLwHookRext*TMath::Cos(alpha/2);
9407   xprof[11] = 0;
9408   yprof[11] = kForwLwHookRext;
9409
9410   // We did the right side, now reflex on the left side
9411   for (Int_t jp = 0; jp < kNumberOfForwLwHookPts; jp++) {
9412     xprof[12+jp] = -xprof[10-jp];
9413     yprof[12+jp] =  yprof[10-jp];
9414   }
9415
9416   // Now the actual Xtru
9417   forwLwHookMainBody->DefinePolygon(2*kNumberOfForwLwHookPts+1, xprof, yprof);
9418   forwLwHookMainBody->DefineSection(0, 0);
9419   forwLwHookMainBody->DefineSection(1, kForwLwHookThick);
9420
9421   // The hole
9422   TGeoXtru *forwLwHookHole = new TGeoXtru(2);
9423   forwLwHookHole->SetName("ITSforwLwHookHole");
9424
9425   xprof[0] = 0;
9426   yprof[0] = forwLwHookMainBody->GetY(0) + kForwLwHookHoleYPos
9427            - kForwLwHookHoleR;
9428   for (Int_t j=1; j<3; j++) {
9429     xprof[0+j] = xprof[0] + kForwLwHookHoleR*SinD(90*j/3);
9430     yprof[0+j] = yprof[0] + kForwLwHookHoleR*(1 - CosD(90*j/3));
9431   }
9432   xprof[3] = xprof[0] + kForwLwHookHoleR;
9433   yprof[3] = yprof[0] + kForwLwHookHoleR;
9434   xprof[4] = xprof[3];
9435   yprof[4] = yprof[3] + kForwLwHookHoleIntHi;
9436   for (Int_t j=1; j<3; j++) {
9437     xprof[4+j] = xprof[4] - kForwLwHookHoleR*(1 - CosD(90*j/3));
9438     yprof[4+j] = yprof[4] + kForwLwHookHoleR*SinD(90*j/3);
9439   }
9440   xprof[7] = xprof[0];
9441   yprof[7] = yprof[4] + kForwLwHookHoleR;
9442
9443   // We did the right side, now reflex on the left side
9444   for (Int_t jp = 0; jp < kNumbOfForwLwHookHolePts-1; jp++) {
9445     xprof[8+jp] = -xprof[6-jp];
9446     yprof[8+jp] =  yprof[6-jp];
9447   }
9448
9449   // Now the actual Xtru
9450   forwLwHookHole->DefinePolygon(2*kNumbOfForwLwHookHolePts, xprof, yprof);
9451   forwLwHookHole->DefineSection(0, -0.1);
9452   forwLwHookHole->DefineSection(1, kForwLwHookThick+0.1);
9453
9454   // The hollow
9455   TGeoBBox *forwLwHookHollow = new TGeoBBox(2.1 *kForwLwHookHalfBase,
9456                                             0.55*kForwLwHookHollowHi,
9457                                             0.55*kForwLwHookHollowWide);
9458   forwLwHookHollow->SetName("ITSforwLwHookHollow");
9459
9460   TGeoTranslation *forwLwHookHollPos = new TGeoTranslation(0.,
9461                       forwLwHookMainBody->GetY(0) + 0.5*kForwLwHookHollowHi,
9462                       forwLwHookMainBody->GetZ(1) - 0.5*kForwLwHookHollowWide);
9463   forwLwHookHollPos->SetName("ITSforwLwHookHollPos");
9464   forwLwHookHollPos->RegisterYourself();
9465
9466   // Finally the actual shape: a CompositeShape
9467   TGeoCompositeShape *forwLwHookShape = new TGeoCompositeShape("ITSforwLwHookMainBody-ITSforwLwHookHole-ITSforwLwHookHollow:ITSforwLwHookHollPos");
9468
9469   // The Rear Upper Hook (0872/C/10): a Composite Shape made of
9470   // a really complex Xtru to approximate the arc with a polyline,
9471   // and another Xtru for the hole
9472   // The main body
9473   TGeoXtru *rearUpHookMainBody = new TGeoXtru(2);
9474   rearUpHookMainBody->SetName("ITSrearUpHookMainBody");
9475
9476   xprof[0] = kRearUpHookHalfBase;
9477   yprof[0] = kRearUpHookRext - kRearUpHookHiTot;
9478   xprof[1] = xprof[0];
9479   yprof[1] = yprof[0] + (kRearUpHookHiInt - kRearUpHookRint); 
9480   for (Int_t j=1; j<6; j++) {
9481     xprof[1+j] = xprof[1] + kRearUpHookRint*(1 - CosD(90*j/5));
9482     yprof[1+j] = yprof[1] + kRearUpHookRint*SinD(90*j/5);
9483   }
9484   xprof[ 7] = kRearUpHookWide/2;
9485   yprof[ 7] = yprof[5];
9486   xprof[ 8] = xprof[7];
9487   alpha = TMath::ASin(0.5*kRearUpHookWide/kRearUpHookRext);
9488   yprof[ 8] = kRearUpHookRext*TMath::Cos(alpha);
9489   xprof[ 9] = kRearUpHookRext*TMath::Sin(alpha/2);
9490   yprof[ 9] = kRearUpHookRext*TMath::Cos(alpha/2);
9491   xprof[10] = 0;
9492   yprof[10] = kRearUpHookRext;
9493
9494   // We did the right side, now reflex on the left side
9495   for (Int_t jp = 0; jp < kNumberOfRearUpHookPts; jp++) {
9496     xprof[11+jp] = -xprof[9-jp];
9497     yprof[11+jp] =  yprof[9-jp];
9498   }
9499
9500   // Now the actual Xtru
9501   rearUpHookMainBody->DefinePolygon(2*kNumberOfRearUpHookPts+1, xprof, yprof);
9502   rearUpHookMainBody->DefineSection(0, 0);
9503   rearUpHookMainBody->DefineSection(1, kRearUpHookThick);
9504
9505   // The hole
9506   TGeoXtru *rearUpHookHole = new TGeoXtru(2);
9507   rearUpHookHole->SetName("ITSrearUpHookHole");
9508
9509   xprof[0] = kRearUpHookHoleBase/2;
9510   yprof[0] = rearUpHookMainBody->GetY(0) + kRearUpHookHoleY;
9511   xprof[1] = kRearUpHookHoleWide/2;
9512   yprof[1] = yprof[0] + (xprof[1] - xprof[0]); // Go at 45deg
9513   xprof[2] = xprof[1];
9514   yprof[2] = yprof[0] + kRearUpHookHoleHi - kRearUpHookHoleR5;
9515   xprof[3] = xprof[2] - kRearUpHookHoleR5*(1 - CosD(45));
9516   yprof[3] = yprof[2] + kRearUpHookHoleR5*SinD(45);
9517   xprof[4] = xprof[2] - kRearUpHookHoleR5;
9518   yprof[4] = yprof[0] + kRearUpHookHoleHi;
9519
9520   // We did the right side, now reflex on the left side
9521   for (Int_t jp = 0; jp < kNumbOfRearUpHookHolePts; jp++) {
9522     xprof[5+jp] = -xprof[4-jp];
9523     yprof[5+jp] =  yprof[4-jp];
9524   }
9525
9526   // Now the actual Xtru
9527   rearUpHookHole->DefinePolygon(2*kNumbOfRearUpHookHolePts, xprof, yprof);
9528   rearUpHookHole->DefineSection(0, -0.1);
9529   rearUpHookHole->DefineSection(1, kRearUpHookThick+0.1);
9530
9531   // Finally the actual shape: a CompositeShape
9532   TGeoCompositeShape *rearUpHookShape = new TGeoCompositeShape("ITSrearUpHookMainBody-ITSrearUpHookHole");
9533
9534   // The Rear Lower Hook (0872/C/11): a Xtru
9535   TGeoXtru *rearLwHookShape = new TGeoXtru(2);
9536   rearLwHookShape->SetName("ITSrearLwHookShape");
9537
9538   xprof[0] = kRearLwHookWide/2;
9539   yprof[0] = kRearLwHookRext - kRearLwHookHiTot;
9540   xprof[1] = xprof[0];
9541   alpha = TMath::ASin(0.5*kRearLwHookWide/kRearLwHookRext);
9542   yprof[1] = kRearLwHookRext*TMath::Cos(alpha);
9543   xprof[2] = kRearLwHookRext*TMath::Sin(alpha/2);
9544   yprof[2] = kRearLwHookRext*TMath::Cos(alpha/2);
9545   xprof[3] = 0;
9546   yprof[3] = kRearLwHookRext;
9547
9548   // We did the right side, now reflex on the left side
9549   for (Int_t jp = 0; jp < kNumberOfRearLwHookPts; jp++) {
9550     xprof[4+jp] = -xprof[2-jp];
9551     yprof[4+jp] =  yprof[2-jp];
9552   }
9553
9554   // Now the actual Xtru
9555   rearLwHookShape->DefinePolygon(2*kNumberOfRearLwHookPts+1, xprof, yprof);
9556   rearLwHookShape->DefineSection(0, 0);
9557   rearLwHookShape->DefineSection(1, kRearLwHookThick);
9558
9559   // The Rear Lower Bracket (0872/C/16): a Xtru
9560   TGeoXtru *rearLwBrackShape = new TGeoXtru(2);
9561   rearLwBrackShape->SetName("ITSrearLwBrackShape");
9562
9563   xprof[0] = 0;
9564   yprof[0] = 0;
9565   xprof[1] = xprof[0] + kRearLwBracketWide1 - kRearLwBracketWide2;
9566   yprof[1] = yprof[0];
9567   xprof[2] = xprof[1];
9568   yprof[2] = yprof[0] + kRearLwBracketHi2;
9569   xprof[3] = xprof[2] - kRearLwBracketWide1;
9570   yprof[3] = yprof[2];
9571   xprof[4] = xprof[3];
9572   yprof[4] = yprof[3] - kRearLwBracketHi1;
9573   xprof[5] = xprof[0];
9574   yprof[5] = yprof[4];
9575
9576   rearLwBrackShape->DefinePolygon(6, xprof, yprof);
9577   rearLwBrackShape->DefineSection(0,-kRearLwBracketThick/2);
9578   rearLwBrackShape->DefineSection(1, kRearLwBracketThick/2);
9579
9580   // The Forward S-shaped Stirrup for the webcam (0872/C/V/01): a Xtru
9581   TGeoXtru *forwWebSStirrSh = new TGeoXtru(2);
9582
9583   xprof[0] = 0;
9584   yprof[0] = 0;
9585   xprof[1] = xprof[0] + kForwWebSStirrLen1;
9586   yprof[1] = yprof[0];
9587   xprof[2] = xprof[1];
9588   yprof[2] = yprof[1] + kForwWebSStirrWide1;
9589   xprof[3] = xprof[0] - kForwWebSStirrLen2 + kForwWebSStirrLen3;
9590   yprof[3] = yprof[2];
9591   xprof[4] = xprof[3];
9592   yprof[4] = yprof[3] + kForwWebSStirrWide3;
9593   xprof[5] = xprof[4] - kForwWebSStirrLen3;
9594   yprof[5] = yprof[4];
9595   xprof[6] = xprof[5];
9596   yprof[6] = yprof[0] + kForwWebSStirrWide2;
9597   xprof[7] = xprof[0];
9598   yprof[7] = yprof[6];
9599
9600   forwWebSStirrSh->DefinePolygon(8, xprof, yprof);
9601   forwWebSStirrSh->DefineSection(0,-kForwWebSStirrDep/2);
9602   forwWebSStirrSh->DefineSection(1, kForwWebSStirrDep/2);
9603
9604   // The Forward T-shaped Stirrups for the webcam (0872/C/V/03-04): two Xtru
9605   TGeoXtru *forwWebTStirr3Sh = new TGeoXtru(2);
9606
9607   xprof[0] = -kForwWebTStirrWide2/2;
9608   yprof[0] = 0;
9609   xprof[1] = -kForwWebTStirrWide1/2;
9610   yprof[1] = yprof[0];
9611   xprof[2] = xprof[1];
9612   yprof[2] = yprof[1] - kForwWebTStirrLen1;
9613   xprof[3] =-xprof[2];
9614   yprof[3] = yprof[2];
9615   xprof[4] = xprof[3];
9616   yprof[4] = yprof[1];
9617   xprof[5] =-xprof[0];
9618   yprof[5] = yprof[4];
9619   xprof[6] = xprof[5];
9620   yprof[6] = kForwWebTStirrTotLen3 - kForwWebTStirrLen1;
9621   xprof[7] = xprof[0];
9622   yprof[7] = yprof[6];
9623
9624   forwWebTStirr3Sh->DefinePolygon(8, xprof, yprof);
9625   forwWebTStirr3Sh->DefineSection(0, 0);
9626   forwWebTStirr3Sh->DefineSection(1, kForwWebTStirrThick);
9627
9628   TGeoXtru *forwWebTStirr4Sh = new TGeoXtru(2);
9629
9630   yprof[6] = kForwWebTStirrTotLen4 - kForwWebTStirrLen1;
9631   yprof[7] = yprof[6];
9632
9633   forwWebTStirr4Sh->DefinePolygon(8, xprof, yprof);
9634   forwWebTStirr4Sh->DefineSection(0, 0);
9635   forwWebTStirr4Sh->DefineSection(1, kForwWebTStirrThick);
9636
9637   // The Forward and Rear clamp for the webcam (0872/C/V/02): a Xtru
9638   TGeoXtru *frWebClampSh = new TGeoXtru(2);
9639
9640   xprof[0] = kFRWebClampIntWide/2;
9641   yprof[0] = kFRWebClampIntHi;
9642   xprof[1] = xprof[0];
9643   yprof[1] = 0;
9644   xprof[2] = kFRWebClampExtWide/2;
9645   yprof[2] = yprof[1];
9646   xprof[3] = xprof[2];
9647   yprof[3] = kFRWebClampExtHi;
9648   for (Int_t jp = 0; jp < 4; jp++) {
9649     xprof[4+jp] = -xprof[3-jp];
9650     yprof[4+jp] =  yprof[3-jp];
9651   }
9652
9653   frWebClampSh->DefinePolygon(8, xprof, yprof);
9654   frWebClampSh->DefineSection(0,-kFRWebClampThick/2);
9655   frWebClampSh->DefineSection(1, kFRWebClampThick/2);
9656
9657   // The Rear Upper Stirrup for the webcam (0872/C/V/05): a Xtru
9658   TGeoXtru *upWebStirrSh = new TGeoXtru(2);
9659
9660   xprof[0] = 0;
9661   yprof[0] = 0;
9662   xprof[1] = xprof[0] - (kRearUpWebStirrWide - 2*kRearUpWebStirrThick);
9663   yprof[1] = yprof[0];
9664   xprof[2] = xprof[1];
9665   yprof[2] = yprof[1] + (kRearUpWebStirrH1 - kRearUpWebStirrThick);
9666   xprof[3] = xprof[2] - kRearUpWebStirrThick;
9667   yprof[3] = yprof[2];
9668   xprof[4] = xprof[3];
9669   yprof[4] = yprof[3] - kRearUpWebStirrH1;
9670   xprof[5] = xprof[4] + kRearUpWebStirrWide;
9671   yprof[5] = yprof[4];
9672   xprof[6] = xprof[5];
9673   yprof[6] = yprof[5] + kRearUpWebStirrH2;
9674   xprof[7] = xprof[0];
9675   yprof[7] = yprof[6];
9676
9677   upWebStirrSh->DefinePolygon(8, xprof, yprof);
9678   upWebStirrSh->DefineSection(0,-kRearUpWebStirrDep/2);
9679   upWebStirrSh->DefineSection(1, kRearUpWebStirrDep/2);
9680
9681   // The Rear Upper Bar for the webcam (0872/C/V/06): a BBox
9682   TGeoBBox *upRearWebBarSh = new TGeoBBox(kRearUpWebBarLen/2,
9683                                           kRearUpWebBarHi/2,
9684                                           kRearUpWebBarThick/2);
9685
9686   // The Webcam: a BBox
9687   TGeoBBox *webcamShape = new TGeoBBox(kFRWebClampIntWide/2,
9688                                        kWebcamLength/2,
9689                                        kFRWebClampIntHi/2);
9690
9691   // The Upper Wheel Slide (0872/C/Z/00-01-02)
9692   // A mother volume of air (to avoid assembly) contains the Alluminum block
9693   // (a Composite Shape: a Xtru and a Pcon for the hole) and the Steel pin
9694   // (a Pcon) (The wheels are approximated as part of the block itself)
9695   // The Air mother volume
9696   TGeoXtru *upSlideAirSh = new TGeoXtru(2);
9697   upSlideAirSh->SetName("ITSupperSlideAirShape");
9698
9699   xprof[0] = 0;
9700   yprof[0] = 0;
9701   xprof[1] = xprof[0];
9702   yprof[1] = kUpperSlideBlockHi + kUpperSlideStubHi - kUpperSlideWheelHi;
9703   xprof[2] = xprof[1] - kUpperSlideIntDepth;
9704   yprof[2] = yprof[1];
9705   xprof[3] = xprof[2];
9706   yprof[3] = yprof[2] - kUpperSlideTotHeight;
9707   xprof[4] = xprof[3] + kUpperSlideTotDepth;
9708   yprof[4] = yprof[3];
9709   xprof[5] = xprof[4];
9710   yprof[5] = yprof[0];
9711
9712   upSlideAirSh->DefinePolygon(6, xprof, yprof);
9713   upSlideAirSh->DefineSection(0,-kUpperSlideWidth/2);
9714   upSlideAirSh->DefineSection(1, kUpperSlideWidth/2);
9715
9716   // The (filled) Aluminum block: a Xtru
9717   TGeoXtru *upSlideAluSh = new TGeoXtru(2);
9718   upSlideAluSh->SetName("ITSupperSlideAluShape");
9719
9720   xprof[0] = upSlideAirSh->GetX(0);
9721   yprof[0] = upSlideAirSh->GetY(0);
9722   xprof[1] = upSlideAirSh->GetX(1);
9723   yprof[1] = upSlideAirSh->GetY(1);
9724   xprof[2] = xprof[1] - kUpperSlideStubDep;
9725   yprof[2] = yprof[1];
9726   xprof[3] = xprof[2];
9727   yprof[3] = yprof[2] - kUpperSlideStubHi;
9728   xprof[4] = upSlideAirSh->GetX(2);
9729   yprof[4] = yprof[3];
9730   xprof[5] = xprof[4];
9731   yprof[5] = yprof[4] - kUpperSlideBlockHi;
9732   xprof[6] = upSlideAirSh->GetX(5);
9733   yprof[6] = yprof[5];
9734   xprof[7] = xprof[6];
9735   yprof[7] = yprof[0];
9736
9737   upSlideAluSh->DefinePolygon(8, xprof, yprof);
9738   upSlideAluSh->DefineSection(0, upSlideAirSh->GetZ(0));
9739   upSlideAluSh->DefineSection(1, upSlideAirSh->GetZ(1));
9740
9741   // The cylindrical hole in the block; a Pcon
9742   TGeoPcon *upSlideHoleSh = new TGeoPcon(0, 360, 10);
9743   upSlideHoleSh->SetName("ITSupperSlideHoleShape");
9744
9745   zpos = upSlideAluSh->GetY(5);
9746   upSlideHoleSh->DefineSection(0, zpos-0.1, 0, kUpperSlideHoleRout);
9747   zpos += (kUpperSlideBlockHi - kUpperSlideHoleH3 - kUpperSlideHoleH2
9748         - 2*kUpperSlideHoleH1);
9749   upSlideHoleSh->DefineSection(1, zpos, 0, kUpperSlideHoleRout);
9750   upSlideHoleSh->DefineSection(2, zpos, 0, kUpperSlideHoleRint2);
9751   zpos += kUpperSlideHoleH3;
9752   upSlideHoleSh->DefineSection(3, zpos, 0, kUpperSlideHoleRint2);
9753   upSlideHoleSh->DefineSection(4, zpos, 0, kUpperSlideHoleRout);
9754   zpos += kUpperSlideHoleH1;
9755   upSlideHoleSh->DefineSection(5, zpos, 0, kUpperSlideHoleRout);
9756   upSlideHoleSh->DefineSection(6, zpos, 0, kUpperSlideHoleRint1);
9757   zpos += kUpperSlideHoleH2;
9758   upSlideHoleSh->DefineSection(7, zpos, 0, kUpperSlideHoleRint1);
9759   upSlideHoleSh->DefineSection(8, zpos, 0, kUpperSlideHoleRout);
9760   zpos += kUpperSlideHoleH1;
9761   upSlideHoleSh->DefineSection(9, zpos+0.1, 0, kUpperSlideHoleRout);
9762
9763   TGeoCombiTrans *upSlideHolePos = new TGeoCombiTrans(-kUpperSlideHoleXPos,0,0,
9764                                    new TGeoRotation("",0,-90,0) );
9765   upSlideHolePos->SetName("ITSupperSlideHolePos");
9766   upSlideHolePos->RegisterYourself();
9767
9768   // The actual block: a CompositeShape
9769   TGeoCompositeShape *upSlideBlockSh = new TGeoCompositeShape("ITSupperSlideAluShape-ITSupperSlideHoleShape:ITSupperSlideHolePos");
9770
9771   // The Steel pin in the block; a Pcon
9772   TGeoPcon *upSlidePinSh = new TGeoPcon(0, 360, 6);
9773   upSlidePinSh->SetName("ITSupperSlidePinShape");
9774
9775   zpos = upSlideAluSh->GetY(5) - (kUpperSlidePinH1 + kUpperSlidePinH2
9776        + kUpperSlidePinH3 - kUpperSlideBlockHi);
9777   upSlidePinSh->DefineSection(0, zpos, 0, kUpperSlidePinRmin);
9778   zpos += kUpperSlidePinH3;
9779   upSlidePinSh->DefineSection(1, zpos, 0, kUpperSlidePinRmin);
9780   upSlidePinSh->DefineSection(2, zpos, 0, kUpperSlidePinRmax);
9781   zpos += kUpperSlidePinH2;
9782   upSlidePinSh->DefineSection(3, zpos, 0, kUpperSlidePinRmax);
9783   upSlidePinSh->DefineSection(4, zpos, 0, kUpperSlidePinRmin);
9784   zpos += kUpperSlidePinH1;
9785   upSlidePinSh->DefineSection(5, zpos, 0, kUpperSlidePinRmin);
9786
9787   // The Lower Wheel Slide (0872/C/W/00-01-02-03)
9788   // A mother volume of air (to avoid assembly) contains the Alluminum block
9789   // (a Composite Shape: a Xtru and a Pcon for the hole), the Alluminum nose
9790   // (a Xtru) and the Steel pin (a Pcon)
9791   // (The wheels are approximated as part of the block itself)
9792   // The Air mother volume
9793   TGeoXtru *lwSlideAirSh = new TGeoXtru(2);
9794   lwSlideAirSh->SetName("ITSlowerSlideAirShape");
9795
9796   xprof[0] = 0;
9797   yprof[0] = 0;
9798   xprof[1] = xprof[0] + kLowerSlideTotDepth/2 - kLowerSlideNoseBase/2;
9799   yprof[1] = yprof[0];
9800   xprof[2] = xprof[1];
9801   yprof[2] = yprof[1] - (kLowerSlideBlockHi + kLowerSlidePinH2);
9802   xprof[3] = xprof[2] - kLowerSlideTotDepth;
9803   yprof[3] = yprof[2];
9804   xprof[4] = xprof[3];
9805   yprof[4] = yprof[3] + kLowerSlidePinH2 + kLowerSlideTotHeight;
9806   xprof[5] = xprof[0];
9807   yprof[5] = yprof[4];
9808
9809   lwSlideAirSh->DefinePolygon(6, xprof, yprof);
9810   lwSlideAirSh->DefineSection(0,-kLowerSlideWidth/2);
9811   lwSlideAirSh->DefineSection(1, kLowerSlideWidth/2);
9812
9813   // The (filled) Aluminum block: a Xtru
9814   TGeoXtru *lwSlideAluSh = new TGeoXtru(2);
9815   lwSlideAluSh->SetName("ITSlowerSlideAluShape");
9816
9817   xprof[0] = lwSlideAirSh->GetX(0);
9818   yprof[0] = lwSlideAirSh->GetY(0);
9819   xprof[1] = lwSlideAirSh->GetX(1);
9820   yprof[1] = lwSlideAirSh->GetY(1);
9821   xprof[2] = xprof[1];
9822   yprof[2] = yprof[1] - kLowerSlideBlockHi;
9823   xprof[3] = lwSlideAirSh->GetX(3);
9824   yprof[3] = yprof[2];
9825   xprof[4] = xprof[3];
9826   yprof[4] = yprof[3] + kLowerSlideBlockHi;
9827   xprof[5] = xprof[4] + kLowerSlideTotDepth/2;
9828   yprof[5] = yprof[4];
9829   xprof[6] = xprof[5];
9830   yprof[6] = lwSlideAirSh->GetY(4);
9831   xprof[7] = xprof[0];
9832   yprof[7] = yprof[6];
9833
9834   lwSlideAluSh->DefinePolygon(8, xprof, yprof);
9835   lwSlideAluSh->DefineSection(0, lwSlideAirSh->GetZ(0));
9836   lwSlideAluSh->DefineSection(1, lwSlideAirSh->GetZ(1));
9837
9838   // The cylindrical hole in the block; a Pcon
9839   TGeoPcon *lwSlideHoleSh = new TGeoPcon(0, 360, 4);
9840   lwSlideHoleSh->SetName("ITSlowerSlideHoleShape");
9841
9842   zpos = lwSlideAluSh->GetY(2);
9843   lwSlideHoleSh->DefineSection(0, zpos-0.1, 0, kLowerSlideHoleRout);
9844   zpos += kLowerSlideHoleH1;
9845   lwSlideHoleSh->DefineSection(1, zpos, 0, kLowerSlideHoleRout);
9846   lwSlideHoleSh->DefineSection(2, zpos, 0, kLowerSlideHoleRint);
9847   zpos = lwSlideAluSh->GetY(4);
9848   lwSlideHoleSh->DefineSection(3, zpos, 0, kLowerSlideHoleRint);
9849
9850   TGeoCombiTrans *lwSlideHolePos = new TGeoCombiTrans(lwSlideAluSh->GetX(5),
9851                                                       0, 0,
9852                                    new TGeoRotation("",0,-90,0) );
9853   lwSlideHolePos->SetName("ITSlowerSlideHolePos");
9854   lwSlideHolePos->RegisterYourself();
9855
9856   // The actual block: a CompositeShape
9857   TGeoCompositeShape *lwSlideBlockSh = new TGeoCompositeShape("ITSlowerSlideAluShape-ITSlowerSlideHoleShape:ITSlowerSlideHolePos");
9858
9859   // The Aluminum nose: a Xtru
9860   TGeoXtru *lwSlideNoseSh = new TGeoXtru(2);
9861   lwSlideNoseSh->SetName("ITSlowerSlideNoseShape");
9862
9863   xprof[0] = lwSlideAluSh->GetX(5);
9864   yprof[0] = lwSlideAluSh->GetY(5);
9865   xprof[1] = xprof[0] - kLowerSlideNoseBase/2;
9866   yprof[1] = yprof[0];
9867   xprof[2] = xprof[1];
9868   yprof[2] = yprof[1] + kLowerSlideNoseBasHi;
9869   xprof[3] = lwSlideAluSh->GetX(0) - kLowerSlideNoseUpWid;
9870   yprof[3] = lwSlideAluSh->GetY(6);
9871   xprof[4] = xprof[0];
9872   yprof[4] = yprof[3];
9873
9874   lwSlideNoseSh->DefinePolygon(5, xprof, yprof);
9875   lwSlideNoseSh->DefineSection(0,-kLowerSlideNoseDepth/2);
9876   lwSlideNoseSh->DefineSection(1, kLowerSlideNoseDepth/2);
9877
9878   // The Steel pin in the block; a Pcon
9879   TGeoPcon *lwSlidePinSh = new TGeoPcon(0, 360, 4);
9880   lwSlidePinSh->SetName("ITSlowerSlidePinShape");
9881
9882   zpos = lwSlideAirSh->GetY(2);
9883   lwSlidePinSh->DefineSection(0, zpos, 0, kLowerSlidePinRmax);
9884   zpos += kLowerSlidePinH2;
9885   lwSlidePinSh->DefineSection(1, zpos, 0, kLowerSlidePinRmax);
9886   lwSlidePinSh->DefineSection(2, zpos, 0, kLowerSlidePinRmin);
9887   zpos += kLowerSlidePinH1;
9888   lwSlidePinSh->DefineSection(3, zpos, 0, kLowerSlidePinRmin);
9889
9890   // The Stirrup on the Muon side (0872/C/01-02): a really complex Xtru
9891   // to approximate arcs with polylines
9892   TGeoXtru *stirrupC1C2Sh = new TGeoXtru(2);
9893
9894   for (Int_t j=0; j<11; j++) { // The internal arc
9895     xprof[j] = kStirrC12R50*(1 - CosD(90*j/10));
9896     yprof[j] = kStirrC12R50*SinD(90*j/10);
9897   }
9898
9899   xprof[11] = xprof[10] + kStirrC12TailLen;
9900   yprof[11] = yprof[10];
9901   xprof[12] = xprof[11];
9902   yprof[12] = kStirrC12BodyHalfHi;
9903   xprof[13] = xprof[12] - kStirrC12BodyLen;
9904   yprof[13] = yprof[12];
9905
9906   xprof[17] = xprof[12] - kStirrC12TotLen + kStirrC12HeadLen;
9907   yprof[17] = kStirrC12HeadHalfHi;
9908   IntersectCircle(-TanD(kStirrC12HeadAng), xprof[17], yprof[17],
9909                   kStirrC12R100, xprof[13], yprof[13]+kStirrC12R100,
9910                   xprof[16], yprof[16], xdummy, ydummy);
9911   alpha = TMath::ASin((xprof[13]-xprof[16])/kStirrC12R100);
9912   xprof[14] = xprof[13] - kStirrC12R100*TMath::Sin(alpha/3);
9913   yprof[14] = yprof[13] + kStirrC12R100*(1 - TMath::Cos(alpha/3));
9914   xprof[15] = xprof[13] - kStirrC12R100*TMath::Sin(2*alpha/3);
9915   yprof[15] = yprof[13] + kStirrC12R100*(1 - TMath::Cos(2*alpha/3));
9916
9917   xprof[18] = xprof[17] - kStirrC12HeadLen;
9918   yprof[18] = yprof[17];
9919   xprof[19] = xprof[18];
9920   yprof[19] = kStirrC12HeadIntHi;
9921   xprof[20] = xprof[19] + kStirrC12HeadIntLen - kStirrC12R10;
9922   yprof[20] = yprof[19];
9923   for (Int_t j=1; j<4; j++) {
9924     xprof[20+j] = xprof[20] + kStirrC12R10*SinD(90*j/3);
9925     yprof[20+j] = yprof[20] - kStirrC12R10*(1 - CosD(90*j/3));
9926   }
9927
9928   // We did the up side, now reflex on the bottom side
9929   for (Int_t jp = 0; jp < kNumberOfStirrCPoints; jp++) {
9930     xprof[24+jp] =  xprof[23-jp];
9931     yprof[24+jp] = -yprof[23-jp];
9932   }
9933
9934   // Now the actual Xtru
9935   stirrupC1C2Sh->DefinePolygon(2*kNumberOfStirrCPoints+1, xprof, yprof);
9936   stirrupC1C2Sh->DefineSection(0,-kStirrC12Thick/2);
9937   stirrupC1C2Sh->DefineSection(1, kStirrC12Thick/2);
9938
9939   // The first element of the Stirrup on the Forward side (0872/C/05):
9940   // a really complex Xtru (equal to part of the Muon Stirrup)
9941   // (0872/C/06 and 0872/C/07 are dismounted after positioning the TPC to I.P.)
9942   TGeoXtru *stirrupC5Sh = new TGeoXtru(2);
9943
9944   for (Int_t j=0; j<13; j++) { // The internal arc and the tail
9945     xprof[j] = stirrupC1C2Sh->GetX(j);
9946     yprof[j] = stirrupC1C2Sh->GetY(j);
9947   }
9948
9949   xprof[13] = xprof[12] - kStirrC5BodyLen;
9950   yprof[13] = yprof[12];
9951
9952   // We did the up side, now reflex on the bottom side
9953   for (Int_t jp = 0; jp < 13; jp++) {
9954     xprof[14+jp] =  xprof[13-jp];
9955     yprof[14+jp] = -yprof[13-jp];
9956   }
9957
9958   // Now the actual Xtru
9959   stirrupC5Sh->DefinePolygon(27, xprof, yprof);
9960   stirrupC5Sh->DefineSection(0,-kStirrC12Thick/2);
9961   stirrupC5Sh->DefineSection(1, kStirrC12Thick/2);
9962
9963
9964   // We have all shapes: now create the real volumes
9965   TGeoMedium *medAlcoa   = mgr->GetMedium("ITS_ALUMINUM$"); // To code!!!!!!
9966   TGeoMedium *medHokotol = mgr->GetMedium("ITS_HOKOTOL$");
9967   TGeoMedium *medAnticor = mgr->GetMedium("ITS_ANTICORODAL$");
9968   TGeoMedium *medErgal   = mgr->GetMedium("ITS_ERGAL$");
9969   TGeoMedium *medAisi    = mgr->GetMedium("ITS_AISI304L$");
9970   TGeoMedium *medAir     = mgr->GetMedium("ITS_AIR$");
9971   TGeoMedium *medPlexy   = mgr->GetMedium("ITS_PLEXYGLAS$");
9972   TGeoMedium *medPVC     = mgr->GetMedium("ITS_PVC$");
9973
9974
9975   TGeoVolume *suppRingC2C3  = new TGeoVolume("ITSTPCsupportRingC2C3",
9976                                              ringC2C3, medAlcoa);
9977
9978   suppRingC2C3->SetVisibility(kTRUE);
9979   suppRingC2C3->SetLineColor(6); // Purple
9980   suppRingC2C3->SetLineWidth(1);
9981   suppRingC2C3->SetFillColor(suppRingC2C3->GetLineColor());
9982   suppRingC2C3->SetFillStyle(4000); // 0% transparent
9983
9984   TGeoVolume *forwUpHook  = new TGeoVolume("ITSTPCsupportForwUpHook",
9985                                            forwUpHookShape, medHokotol);
9986
9987   forwUpHook->SetVisibility(kTRUE);
9988   forwUpHook->SetLineColor(6); // Purple
9989   forwUpHook->SetLineWidth(1);
9990   forwUpHook->SetFillColor(forwUpHook->GetLineColor());
9991   forwUpHook->SetFillStyle(4000); // 0% transparent
9992
9993   TGeoVolume *forwLwHook  = new TGeoVolume("ITSTPCsupportForwLwHook",
9994                                            forwLwHookShape, medHokotol);
9995
9996   forwLwHook->SetVisibility(kTRUE);
9997   forwLwHook->SetLineColor(6); // Purple
9998   forwLwHook->SetLineWidth(1);
9999   forwLwHook->SetFillColor(forwLwHook->GetLineColor());
10000   forwLwHook->SetFillStyle(4000); // 0% transparent
10001
10002   TGeoVolume *rearUpHook  = new TGeoVolume("ITSTPCsupportRearUpHook",
10003                                            rearUpHookShape, medHokotol);
10004
10005   rearUpHook->SetVisibility(kTRUE);
10006   rearUpHook->SetLineColor(6); // Purple
10007   rearUpHook->SetLineWidth(1);
10008   rearUpHook->SetFillColor(rearUpHook->GetLineColor());
10009   rearUpHook->SetFillStyle(4000); // 0% transparent
10010
10011   TGeoVolume *rearLwHook  = new TGeoVolume("ITSTPCsupportRearLwHook",
10012                                            rearLwHookShape, medAnticor);
10013
10014   rearLwHook->SetVisibility(kTRUE);
10015   rearLwHook->SetLineColor(6); // Purple
10016   rearLwHook->SetLineWidth(1);
10017   rearLwHook->SetFillColor(rearLwHook->GetLineColor());
10018   rearLwHook->SetFillStyle(4000); // 0% transparent
10019
10020   TGeoVolume *rearLwBrack  = new TGeoVolume("ITSTPCsupportRearLwBracket",
10021                                             rearLwBrackShape, medAnticor);
10022
10023   rearLwBrack->SetVisibility(kTRUE);
10024   rearLwBrack->SetLineColor(6); // Purple
10025   rearLwBrack->SetLineWidth(1);
10026   rearLwBrack->SetFillColor(rearLwBrack->GetLineColor());
10027   rearLwBrack->SetFillStyle(4000); // 0% transparent
10028
10029   TGeoVolume *forwWebSStirrup  = new TGeoVolume("ITSTPCsupportForwWebSStirrup",
10030                                                 forwWebSStirrSh, medAnticor);
10031
10032   forwWebSStirrup->SetVisibility(kTRUE);
10033   forwWebSStirrup->SetLineColor(6); // Purple
10034   forwWebSStirrup->SetLineWidth(1);
10035   forwWebSStirrup->SetFillColor(forwWebSStirrup->GetLineColor());
10036   forwWebSStirrup->SetFillStyle(4000); // 0% transparent
10037
10038   TGeoVolume *forwWebTStirr3  = new TGeoVolume("ITSTPCsupportForwWebTStirrup3",
10039                                                forwWebTStirr3Sh, medAnticor);
10040
10041   forwWebTStirr3->SetVisibility(kTRUE);
10042   forwWebTStirr3->SetLineColor(6); // Purple
10043   forwWebTStirr3->SetLineWidth(1);
10044   forwWebTStirr3->SetFillColor(forwWebTStirr3->GetLineColor());
10045   forwWebTStirr3->SetFillStyle(4000); // 0% transparent
10046
10047   TGeoVolume *forwWebTStirr4  = new TGeoVolume("ITSTPCsupportForwWebTStirrup4",
10048                                                forwWebTStirr4Sh, medAnticor);
10049
10050   forwWebTStirr4->SetVisibility(kTRUE);
10051   forwWebTStirr4->SetLineColor(6); // Purple
10052   forwWebTStirr4->SetLineWidth(1);
10053   forwWebTStirr4->SetFillColor(forwWebTStirr4->GetLineColor());
10054   forwWebTStirr4->SetFillStyle(4000); // 0% transparent
10055
10056   TGeoVolume *frWebClamp  = new TGeoVolume("ITSTPCsupportForwRearWebClamp",
10057                                            frWebClampSh, medPlexy);
10058
10059   frWebClamp->SetVisibility(kTRUE);
10060   frWebClamp->SetLineColor(kAzure);
10061   frWebClamp->SetLineWidth(1);
10062   frWebClamp->SetFillColor(frWebClamp->GetLineColor());
10063   frWebClamp->SetFillStyle(4000); // 0% transparent
10064
10065   TGeoVolume *upWebStirrup  = new TGeoVolume("ITSTPCsupportUpperWebStirrup",
10066                                              upWebStirrSh, medAnticor);
10067
10068   upWebStirrup->SetVisibility(kTRUE);
10069   upWebStirrup->SetLineColor(6); // Purple
10070   upWebStirrup->SetLineWidth(1);
10071   upWebStirrup->SetFillColor(upWebStirrup->GetLineColor());
10072   upWebStirrup->SetFillStyle(4000); // 0% transparent
10073
10074   TGeoVolume *upRearWebBar  = new TGeoVolume("ITSTPCsupportUpperRearWebBar",
10075                                              upRearWebBarSh, medPlexy);
10076
10077   upRearWebBar->SetVisibility(kTRUE);
10078   upRearWebBar->SetLineColor(kAzure);
10079   upRearWebBar->SetLineWidth(1);
10080   upRearWebBar->SetFillColor(upRearWebBar->GetLineColor());
10081   upRearWebBar->SetFillStyle(4000); // 0% transparent
10082
10083   TGeoVolume *webCam  = new TGeoVolume("ITSTPCsupportWebcam",
10084                                        webcamShape, medPVC);
10085
10086   webCam->SetVisibility(kTRUE);
10087   webCam->SetLineColor(kBlack);
10088   webCam->SetLineWidth(1);
10089   webCam->SetFillColor(webCam->GetLineColor());
10090   webCam->SetFillStyle(4000); // 0% transparent
10091
10092   TGeoVolume *upSlideVol  = new TGeoVolume("ITSTPCsupportUpperSlide",
10093                                            upSlideAirSh, medAir);
10094
10095   upSlideVol->SetVisibility(kFALSE);
10096
10097   TGeoVolume *upSlideBlock  = new TGeoVolume("ITSTPCsupportUpperSlideBlock",
10098                                              upSlideBlockSh, medAnticor);
10099
10100   upSlideBlock->SetVisibility(kTRUE);
10101   upSlideBlock->SetLineColor(6); // Purple
10102   upSlideBlock->SetLineWidth(1);
10103   upSlideBlock->SetFillColor(upSlideBlock->GetLineColor());
10104   upSlideBlock->SetFillStyle(4000); // 0% transparent
10105
10106   TGeoVolume *upSlidePin  = new TGeoVolume("ITSTPCsupportUpperSlidePin",
10107                                            upSlidePinSh, medAisi);
10108
10109   upSlidePin->SetVisibility(kTRUE);
10110   upSlidePin->SetLineColor(kGray);
10111   upSlidePin->SetLineWidth(1);
10112   upSlidePin->SetFillColor(upSlidePin->GetLineColor());
10113   upSlidePin->SetFillStyle(4000); // 0% transparent
10114
10115   TGeoVolume *lwSlideVol  = new TGeoVolume("ITSTPCsupportLowerSlide",
10116                                            lwSlideAirSh, medAir);
10117
10118   lwSlideVol->SetVisibility(kFALSE);
10119
10120   TGeoVolume *lwSlideBlock  = new TGeoVolume("ITSTPCsupportLowerSlideBlock",
10121                                              lwSlideBlockSh, medAnticor);
10122
10123   lwSlideBlock->SetVisibility(kTRUE);
10124   lwSlideBlock->SetLineColor(6); // Purple
10125   lwSlideBlock->SetLineWidth(1);
10126   lwSlideBlock->SetFillColor(lwSlideBlock->GetLineColor());
10127   lwSlideBlock->SetFillStyle(4000); // 0% transparent
10128
10129   TGeoVolume *lwSlideNose  = new TGeoVolume("ITSTPCsupportLowerSlideNose",
10130                                             lwSlideNoseSh, medAnticor);
10131
10132   lwSlideNose->SetVisibility(kTRUE);
10133   lwSlideNose->SetLineColor(6); // Purple
10134   lwSlideNose->SetLineWidth(1);
10135   lwSlideNose->SetFillColor(lwSlideNose->GetLineColor());
10136   lwSlideNose->SetFillStyle(4000); // 0% transparent
10137
10138   TGeoVolume *lwSlidePin  = new TGeoVolume("ITSTPCsupportLowerSlidePin",
10139                                            lwSlidePinSh, medAisi);
10140
10141   lwSlidePin->SetVisibility(kTRUE);
10142   lwSlidePin->SetLineColor(kGray);
10143   lwSlidePin->SetLineWidth(1);
10144   lwSlidePin->SetFillColor(lwSlidePin->GetLineColor());
10145   lwSlidePin->SetFillStyle(4000); // 0% transparent
10146
10147   TGeoVolume *stirrC1C2  = new TGeoVolume("ITSTPCsupportStirrupC1C2",
10148                                           stirrupC1C2Sh, medErgal);
10149
10150   stirrC1C2->SetVisibility(kTRUE);
10151   stirrC1C2->SetLineColor(6); // Purple
10152   stirrC1C2->SetLineWidth(1);
10153   stirrC1C2->SetFillColor(stirrC1C2->GetLineColor());
10154   stirrC1C2->SetFillStyle(4000); // 0% transparent
10155
10156   TGeoVolume *stirrC5  = new TGeoVolume("ITSTPCsupportStirrupC5",
10157                                         stirrupC5Sh, medErgal);
10158
10159   stirrC5->SetVisibility(kTRUE);
10160   stirrC5->SetLineColor(6); // Purple
10161   stirrC5->SetLineWidth(1);
10162   stirrC5->SetFillColor(stirrC5->GetLineColor());
10163   stirrC5->SetFillStyle(4000); // 0% transparent
10164
10165
10166   // Build up the wheel slides
10167   upSlideVol->AddNode(upSlideBlock,1,0);
10168   upSlideVol->AddNode(upSlidePin,  1,
10169                       new TGeoCombiTrans(-kUpperSlideHoleXPos, 0, 0,
10170                                          new TGeoRotation("",0,-90,0) ) );
10171
10172   lwSlideVol->AddNode(lwSlideBlock,1,0);
10173   lwSlideVol->AddNode(lwSlideNose ,1,0);
10174   lwSlideVol->AddNode(lwSlidePin,  1,
10175                       new TGeoCombiTrans(lwSlideAluSh->GetX(5), 0, 0,
10176                                          new TGeoRotation("",0,-90,0) ) );
10177
10178
10179   // Finally put everything in the mother volume
10180   moth->AddNode(suppRingC2C3,1,
10181                 new TGeoTranslation(0, 0, kRingCZPos+kRingCZToTPC) );
10182   moth->AddNode(suppRingC2C3,2,
10183                 new TGeoCombiTrans( 0, 0,-kRingCZPos,
10184                                    new TGeoRotation("",0.,180.,0.) ) );
10185   moth->AddNode(suppRingC2C3,3,
10186                 new TGeoCombiTrans( 0, 0, kRingCZPos+kRingCZToTPC,
10187                                    new TGeoRotation("",0.,0.,180.) ) );
10188   moth->AddNode(suppRingC2C3,4,
10189                 new TGeoCombiTrans( 0, 0,-kRingCZPos,
10190                                    new TGeoRotation("",0.,180.,180.) ) );
10191
10192   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10193   moth->AddNode(forwUpHook,1,
10194                 new TGeoTranslation( 0, 0, zpos) );
10195
10196   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10197   moth->AddNode(forwLwHook,1,
10198                 new TGeoCombiTrans( 0, 0, zpos,
10199                                    new TGeoRotation("",0.,0.,180.) ) );
10200
10201   zpos = kRingCZPos + kRingCThick + kRearUpHookThick;
10202   moth->AddNode(rearUpHook,1,
10203                 new TGeoTranslation( 0, 0,-zpos) );
10204
10205   zpos = kRingCZPos + kRingCThick + kRearLwHookThick;
10206   moth->AddNode(rearLwHook,1,
10207                 new TGeoCombiTrans( 0, 0,-zpos,
10208                                    new TGeoRotation("",0.,0.,180.) ) );
10209
10210   xpos =  kRearLwHookWide/2 + kRearLwBracketThick/2;
10211   ypos = -kRingCHeight;
10212   moth->AddNode(rearLwBrack,1,
10213                 new TGeoCombiTrans( xpos, ypos,-zpos,
10214                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10215   moth->AddNode(rearLwBrack,2,
10216                 new TGeoCombiTrans(-xpos, ypos,-zpos,
10217                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10218
10219   xpos = kForwUpHookWide/2;
10220   ypos = (forwUpHookMainBody->GetY(8) + forwUpHookMainBody->GetY(9))/2;
10221   zpos = kRingCZPos + kRingCThick + kRingCZToTPC;
10222   moth->AddNode(forwWebSStirrup,1,
10223                 new TGeoCombiTrans( xpos, ypos, zpos,
10224                                    new TGeoRotation("", 0., 90., 0.) ) );
10225   xpos = kForwLwHookWide/2;
10226   ypos = (forwLwHookMainBody->GetY(8) + forwLwHookMainBody->GetY(9))/2;
10227   moth->AddNode(forwWebSStirrup,2,
10228                 new TGeoCombiTrans( xpos,-ypos, zpos,
10229                                    new TGeoRotation("", 0., 90., 0.) ) );
10230
10231   xpos = kForwUpHookWide/2
10232         + (forwWebSStirrSh->GetX(4) + forwWebSStirrSh->GetX(5))/2;
10233   ypos = (forwUpHookMainBody->GetY(8) + forwUpHookMainBody->GetY(9))/2
10234         +  forwWebSStirrSh->GetZ(1) - forwWebTStirr3Sh->GetY(7);
10235   zpos += (forwWebSStirrSh->GetY(4) - forwWebSStirrSh->GetY(0));
10236   moth->AddNode(forwWebTStirr3,1,
10237                 new TGeoTranslation( xpos, ypos, zpos) );
10238
10239   ypos -= frWebClampSh->GetZ(1);
10240   moth->AddNode(frWebClamp,1,
10241                 new TGeoCombiTrans( xpos, ypos, zpos+forwWebTStirr3Sh->GetZ(1),
10242                                    new TGeoRotation("", 0., 90., 0.) ) );
10243
10244   ypos -= webcamShape->GetDY()/2;
10245   moth->AddNode(webCam,1,
10246                 new TGeoTranslation( xpos, ypos,
10247                      zpos+forwWebTStirr3Sh->GetZ(1)+webcamShape->GetDZ()) );
10248
10249   xpos = kForwLwHookWide/2
10250         + (forwWebSStirrSh->GetX(4) + forwWebSStirrSh->GetX(5))/2;
10251   ypos = (forwLwHookMainBody->GetY(8) + forwLwHookMainBody->GetY(9))/2
10252         +  forwWebSStirrSh->GetZ(1) - forwWebTStirr4Sh->GetY(7);
10253   moth->AddNode(forwWebTStirr4,1,
10254                 new TGeoCombiTrans( xpos,-ypos, zpos,
10255                                    new TGeoRotation("", 180., 0., 0.) ) );
10256
10257   ypos -= frWebClampSh->GetZ(1);
10258   moth->AddNode(frWebClamp,2,
10259                 new TGeoCombiTrans( xpos,-ypos, zpos+forwWebTStirr4Sh->GetZ(1),
10260                                    new TGeoRotation("", 0., 90., 0.) ) );
10261
10262   ypos -= webcamShape->GetDY()/2;
10263   moth->AddNode(webCam,2,
10264                 new TGeoTranslation( xpos,-ypos,
10265                      zpos+forwWebTStirr4Sh->GetZ(1)+webcamShape->GetDZ()) );
10266
10267   xpos = kRearUpHookWide/2 + kRearUpWebStirrDep/2;
10268   ypos = kRingCHeight;
10269   zpos = kRingCZPos + kRingCThick;
10270   moth->AddNode(upWebStirrup,1,
10271                 new TGeoCombiTrans( xpos, ypos,-zpos,
10272                                    new TGeoRotation("",-90.,-90., 90.) ) );
10273   moth->AddNode(upWebStirrup,2,
10274                 new TGeoCombiTrans(-xpos, ypos,-zpos,
10275                                    new TGeoRotation("",-90.,-90., 90.) ) );
10276
10277   ypos = kRingCHeight + upWebStirrSh->GetY(2) - upRearWebBarSh->GetDY();
10278   zpos = kRingCZPos + kRingCThick + upWebStirrSh->GetX(3)
10279        - upRearWebBarSh->GetDZ();
10280   moth->AddNode(upRearWebBar,1,
10281                 new TGeoTranslation( 0, ypos,-zpos) );
10282
10283   zpos -= upRearWebBarSh->GetDZ();
10284   moth->AddNode(frWebClamp,3,
10285                 new TGeoCombiTrans( 0, ypos,-zpos,
10286                                    new TGeoRotation("", 0., 90., 0.) ) );
10287
10288   ypos -= webcamShape->GetDY()/2;
10289   zpos -= webcamShape->GetDZ();
10290   moth->AddNode(webCam,3,
10291                 new TGeoTranslation( 0, ypos,-zpos) );
10292
10293   xpos = ringC2C3->GetX(14) + kUpperSlideWidth/2;
10294   ypos = ringC2C3->GetY(14);
10295   zpos = kRingCZPos + kRingCThick;
10296   moth->AddNode(upSlideVol,1,
10297                 new TGeoCombiTrans( xpos, ypos, zpos + kRingCZToTPC,
10298                                    new TGeoRotation("",-90.,-90., 90.) ) );
10299   moth->AddNode(upSlideVol,2,
10300                 new TGeoCombiTrans(-xpos, ypos, zpos + kRingCZToTPC,
10301                                    new TGeoRotation("",-90.,-90., 90.) ) );
10302   moth->AddNode(upSlideVol,3,
10303                 new TGeoCombiTrans( xpos, ypos, -zpos,
10304                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10305   moth->AddNode(upSlideVol,4,
10306                 new TGeoCombiTrans(-xpos, ypos, -zpos,
10307                                    new TGeoRotation("", 90.,-90.,-90.) ) );
10308
10309   moth->AddNode(lwSlideVol,1,
10310                 new TGeoCombiTrans( xpos,-ypos, zpos + kRingCZToTPC,
10311                                    new TGeoRotation("", 90.,-90., 90.) ) );
10312   moth->AddNode(lwSlideVol,2,
10313                 new TGeoCombiTrans(-xpos,-ypos, zpos + kRingCZToTPC,
10314                                    new TGeoRotation("", 90.,-90., 90.) ) );
10315   moth->AddNode(lwSlideVol,3,
10316                 new TGeoCombiTrans( xpos,-ypos,-zpos,
10317                                    new TGeoRotation("",-90.,-90.,-90.) ) );
10318   moth->AddNode(lwSlideVol,4,
10319                 new TGeoCombiTrans(-xpos,-ypos,-zpos,
10320                                    new TGeoRotation("",-90.,-90.,-90.) ) );
10321
10322   xpos = kStirrCXPos;
10323   zpos = kRingCZPos + kStirrCZPos + stirrupC1C2Sh->GetZ(1) + kRingCZToTPC;
10324   moth->AddNode(stirrC1C2,1,
10325                 new TGeoTranslation( xpos, 0, zpos) );
10326   moth->AddNode(stirrC1C2,2,
10327                 new TGeoCombiTrans(-xpos, 0, zpos,
10328                                    new TGeoRotation("", 90.,-180.,-90.) ) );
10329
10330   xpos = kStirrCXPos + stirrupC1C2Sh->GetX(18) + kUpperSlideWidth/2;
10331   ypos = ringC2C3->GetY(14); // Slides are all at the same height
10332   zpos = kRingCZPos + kStirrCZPos + kStirrC12Thick + kRingCZToTPC;
10333   moth->AddNode(upSlideVol,5,
10334                 new TGeoCombiTrans( xpos, ypos, zpos,
10335                                    new TGeoRotation("",-90.,-90., 90.) ) );
10336   moth->AddNode(upSlideVol,6,
10337                 new TGeoCombiTrans(-xpos, ypos, zpos,
10338                                    new TGeoRotation("",-90.,-90., 90.) ) );
10339   moth->AddNode(lwSlideVol,5,
10340                 new TGeoCombiTrans( xpos,-ypos, zpos,
10341                                    new TGeoRotation("", 90.,-90., 90.) ) );
10342   moth->AddNode(lwSlideVol,6,
10343                 new TGeoCombiTrans(-xpos,-ypos, zpos,
10344                                    new TGeoRotation("", 90.,-90., 90.) ) );
10345
10346   xpos = kStirrCXPos;
10347   zpos = kRingCZPos + kStirrCZPos + stirrupC5Sh->GetZ(1);
10348   moth->AddNode(stirrC5,1,
10349                 new TGeoTranslation( xpos, 0,-zpos) );
10350   moth->AddNode(stirrC5,2,
10351                 new TGeoCombiTrans(-xpos, 0,-zpos,
10352                                    new TGeoRotation("", 90.,-180.,-90.) ) );
10353
10354
10355   return;
10356 }
10357