]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Enalrged size of char arrays
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.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 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoBoolNode.h"
33 #include "TGeoTube.h"
34 #include "TGeoBBox.h"
35 #include "TGeoXtru.h"
36 #include "TGeoTorus.h"
37 #include "TGeoPgon.h"
38 #include "TGeoPcon.h"
39 #include "TRotation.h"
40 #include "AliITSv11GeometrySSD.h"
41 /////////////////////////////////////////////////////////////////////////////////
42 // Names of the Sensitive Volumes of Layer 5 and Layer 6
43 /////////////////////////////////////////////////////////////////////////////////
44 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
45 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
46 /////////////////////////////////////////////////////////////////////////////////
47 //Parameters for SSD Geometry
48 /////////////////////////////////////////////////////////////////////////////////
49 // Variable for Vertical Disalignement of Modules
50 /////////////////////////////////////////////////////////////////////////////////
51 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
52 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
54 /////////////////////////////////////////////////////////////////////////////////
55 // Layer5 (lengths are in mm and angles in degrees)
56 /////////////////////////////////////////////////////////////////////////////////
57 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
58 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
59 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
61 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
62 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
63 /////////////////////////////////////////////////////////////////////////////////
64 // Layer6 (lengths are in mm and angles in degrees)
65 /////////////////////////////////////////////////////////////////////////////////
66 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
67 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
68 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
70 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
71 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
72 /////////////////////////////////////////////////////////////////////////////////
73 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
74 /////////////////////////////////////////////////////////////////////////////////
75 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
76 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
77 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
78 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
83 /////////////////////////////////////////////////////////////////////////////////
84 // Stiffener (lengths are in mm and angles in degrees)
85 /////////////////////////////////////////////////////////////////////////////////
86 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
87 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
88 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
92 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
97 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
98 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
100                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
101 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
102 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
105                                                                                                           0.25*fgkSSDStiffenerHeight;
106 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
108 /////////////////////////////////////////////////////////////////////////////////
109 // Cooling Block (lengths are in mm and angles in degrees)
110 /////////////////////////////////////////////////////////////////////////////////
111 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
112 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
113 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
114                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
115 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
116                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
117 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
118                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
119 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
120                                                                                                                                          1.500*fgkmm;
121 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
122                                                                                                                                          0.300*fgkmm;
123 /////////////////////////////////////////////////////////////////////////////////
124 // SSD Sensor (lengths are in mm and angles in degrees)
125 /////////////////////////////////////////////////////////////////////////////////
126 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
127                                                                                                                  "SSDSensorSensitiveVol";
128 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
129 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
130 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
132                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
133 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
135 /////////////////////////////////////////////////////////////////////////////////
136 // Flex (lengths are in mm and angles in degrees)
137 /////////////////////////////////////////////////////////////////////////////////
138 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
139 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
140                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
141                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
142                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
143                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
144                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
145 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
146                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
147 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
148                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
149 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
151 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
152 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
153                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
154 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
155                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
156 /////////////////////////////////////////////////////////////////////////////////
157 // SSD Ladder Cable (lengths are in mm and angles in degrees)
158 /////////////////////////////////////////////////////////////////////////////////
159 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
160 /////////////////////////////////////////////////////////////////////////////////
161 // SSD Module (lengths are in mm and angles in degrees)
162 /////////////////////////////////////////////////////////////////////////////////
163 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
164                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
165 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
166                                                                                                                                         45.600*fgkmm;
167 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
168                                                                                                                                          5.075*fgkmm;
169 /////////////////////////////////////////////////////////////////////////////////
170 // Sensor Support (lengths are in mm and angles in degrees)
171 /////////////////////////////////////////////////////////////////////////////////
172 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
173                                                                                                                                          5.800*fgkmm;
174 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
175                                                                                                                                          2.000*fgkmm;
176 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
177                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment, 
178                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment};
179 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
180 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
181 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
182                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
183 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
184                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
185                                                             +  fgkSSDSensorSideSupportThickness[0])
186                                                                 -  fgkSSDSensorSideSupportLength;
187 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
188                                                                                                                                     5.250*fgkmm;
189 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
190                                                                                                                                         1.680*fgkmm;
191 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
192                                                                   = {fgkSSDSensorSideSupportHeight[0]
193                                                                   +  fgkSSDSensorSideSupportThickness[0],
194                                                                          fgkSSDSensorSideSupportHeight[1]
195                                                                   +  fgkSSDSensorSideSupportThickness[1]};
196 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
197                                                                   =  {fgkSSDSensorSideSupportThickness[0],
198                                                                           fgkSSDSensorSideSupportThickness[1]};
199 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
200                                                                                                                                    19.000*fgkmm;
201 /////////////////////////////////////////////////////////////////////////////////
202 // Chip Cables (lengths are in mm and angles in degrees)
203 /////////////////////////////////////////////////////////////////////////////////
204 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
205                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
206 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
207                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
208                                                                   -  (fgkSSDSensorSideSupportHeight[1]
209                                                                   -   fgkSSDSensorSideSupportHeight[0])
210                                                                   -   fgkSSDModuleVerticalDisalignment
211                                                                   -   fgkSSDCoolingBlockHoleCenter
212                                                                   -   fgkSSDStiffenerHeight
213                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
214                                                                           fgkSSDModuleCoolingBlockToSensor
215                                                                   -   fgkSSDModuleVerticalDisalignment  
216                                                                   -   fgkSSDCoolingBlockHoleCenter
217                                                                   -       fgkSSDStiffenerHeight
218                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
219 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
220                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
221 /////////////////////////////////////////////////////////////////////////////////
222 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
223 /////////////////////////////////////////////////////////////////////////////////
224 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
225                                                                                                                                         3.820*fgkmm;
226 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
227 //                                                                                                                                         3.780;
228 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
229                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
230 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
231                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
232 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
233                                                                                                                                 { 30.00, 90.00};
234 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
235                                                                                                                                          1.78*fgkmm;
236 /////////////////////////////////////////////////////////////////////////////////
237 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
238 /////////////////////////////////////////////////////////////////////////////////
239 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
240                                                                    = fgkSSDModuleSensorSupportDistance
241                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
242 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
243 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
244                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
245 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
246                                                                                                                                         1.630*fgkmm;
247 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
248 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
249                                                                         = fgkCarbonFiberTriangleLength
250                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
251                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
252                                                                         * TMath::DegToRad());
253 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
254                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
255                                                                         - fgkCarbonFiberSupportWidth)
256                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
257                                                                         - fgkCarbonFiberSupportWidth;
258 /////////////////////////////////////////////////////////////////////////////////
259 // Carbon Fiber Lower Support Parameters (lengths are in mm)
260 /////////////////////////////////////////////////////////////////////////////////
261 const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
262 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
263                                                                                                                                           =  0.950*fgkmm;
264 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
265                                                                                                                                           =  1.600*fgkmm;
266 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
267                                                                                                                                           =  0.830*fgkmm;
268 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
269                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
270 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
271                                                                         = fgkCarbonFiberJunctionWidth
272                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
273                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
274 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
275                                                                         = {fgkCarbonFiberLowerSupportWidth
276                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
277                                                                            fgkCarbonFiberLowerSupportWidth
278                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
279                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
280 /////////////////////////////////////////////////////////////////////////////////
281 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
282 /////////////////////////////////////////////////////////////////////////////////
283 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
284                                                            {0.5 * (fgkSSDLay5LadderLength
285                                                                         -  fgkSSDLay5SensorsNumber
286                                                                         *  fgkCarbonFiberJunctionWidth
287                                                                         -  fgkCarbonFiberLowerSupportWidth),
288                                                                 0.5 * (fgkSSDLay5LadderLength
289                                                                         -  fgkSSDLay5SensorsNumber
290                                                                         *  fgkCarbonFiberJunctionWidth
291                                                                         +  fgkCarbonFiberLowerSupportWidth)};
292 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
293                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
294                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
295 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
296                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
297                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
298 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
299                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
300 /////////////////////////////////////////////////////////////////////////////////
301 // Cooling Tube Support (lengths are in mm and angles in degrees)
302 /////////////////////////////////////////////////////////////////////////////////
303 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
304 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
305                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
306 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
309 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
310                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
312                                                                                                                                           11.70*fgkmm;
313 /////////////////////////////////////////////////////////////////////////////////
314 // Cooling Tube (lengths are in mm and angles in degrees)
315 /////////////////////////////////////////////////////////////////////////////////
316 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
317 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
318 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
319                                                                                                         fgkCarbonFiberJunctionWidth;
320 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
321                                                                          fgkSSDModuleSensorSupportDistance
322                                                                   +      fgkSSDCoolingBlockLength;
323 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
324 /////////////////////////////////////////////////////////////////////////////////
325 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
326 /////////////////////////////////////////////////////////////////////////////////
327 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
328                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
329 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
330                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
331 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
332                                                                                                                                           20.0*fgkmm;
333 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
334                                                                                                                                                     40.0;
335 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
336                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
337 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
338                                                                                                                                           2.5*fgkmm;
339 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
340                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
341 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
342                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
343 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
344                                                                                                                                           1.0*fgkmm;
345 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
346                                                                                                                                           6.0*fgkmm;
347 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
348                                                                                                                                           4.0*fgkmm;
349 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
350                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
351 /////////////////////////////////////////////////////////////////////////////////
352 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
353 /////////////////////////////////////////////////////////////////////////////////
354 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
355 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
356 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
357 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
359 /////////////////////////////////////////////////////////////////////////////////
360 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
361 /////////////////////////////////////////////////////////////////////////////////
362 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
363 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
364 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
365                                                                                                   -  fgkSSDMountingBlockHeight[1]
366                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
367                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
368                                                                                                   -      fgkMountingBlockSupportDownHeight,
369                                                                                                          fgkSSDLay6RadiusMin
370                                                                                                   -  fgkSSDMountingBlockHeight[1]
371                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
372                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
373                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
374 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
375                                                                                                     -  fgkSSDMountingBlockHeight[1]
376                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
377                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
378                                                                                                         -  fgkMountingBlockSupportRadius[0],
379                                                                                                            fgkSSDLay6RadiusMax
380                                                                                                     -  fgkSSDMountingBlockHeight[1]
381                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
382                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
383                                                                                                         -  fgkMountingBlockSupportRadius[1]};
384 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
385 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
386 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
387 /////////////////////////////////////////////////////////////////////////////////
388 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
389 /////////////////////////////////////////////////////////////////////////////////
390 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
391 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
392 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
393 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
394                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
396                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
398                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
399 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
400 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
401 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
402 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
405 /////////////////////////////////////////////////////////////////////////////////
406 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
407 /////////////////////////////////////////////////////////////////////////////////
408 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
409 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
410 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
411 /////////////////////////////////////////////////////////////////////////////////
412 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
413 /////////////////////////////////////////////////////////////////////////////////
414 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
415                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
416 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
417 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
418 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
419                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
421                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
422 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
423 /////////////////////////////////////////////////////////////////////////////////
424 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
425 /////////////////////////////////////////////////////////////////////////////////
426 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
427                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
428 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
429                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
430                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
431 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
432 /////////////////////////////////////////////////////////////////////////////////
433 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
434 /////////////////////////////////////////////////////////////////////////////////
435 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
436                                                                                                            {62.0*fgkmm,21.87*fgkmm};
437 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
438                                                                                                             {47.0*fgkmm,0.35*fgkmm};
439 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
440                                                                                                                                           1.0*fgkmm;
441 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
442 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
443                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
444 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
445                                                                                                                                          0.15*fgkmm;
446 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
447                                                                                                                                          19.0*fgkmm;
448 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
449                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
450 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
451                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
452 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
453                                                                                                                                           2.1*fgkmm;
454 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
455                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
456 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
457                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
458 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
459                                                                                                                                            19*fgkmm; 
460 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
461                                                                                                                                           1.0*fgkmm;
462 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
463                                                                                                                                           3.6*fgkmm;
464 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
465                                                                                                                                          61.0*fgkmm; 
466 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
467                                                                                                                                          5.97*fgkmm; 
468 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
469 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
470                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
471                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
472 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
473                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
474 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
475                                                                                                                                           1.0*fgkmm; 
476 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
477                                                                                                                                    = 0.15*fgkmm; 
478 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
479                                                                                                                                          20.0*fgkmm;
480 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
481 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
482 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
483 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
484 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
485 /////////////////////////////////////////////////////////////////////////////////
486 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
487 /////////////////////////////////////////////////////////////////////////////////
488 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
489 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
490 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
491 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
497 /////////////////////////////////////////////////////////////////////////////////
498 // SSD Cone Parameters (lengths are in mm and angles in degrees)
499 /////////////////////////////////////////////////////////////////////////////////
500 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
501 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
502 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
503 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
504 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
505 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
517 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
519 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
522 /////////////////////////////////////////////////////////////////////////////////
523 // SSD Cables Parameters (lengths are in mm and angles in degrees)
524 /////////////////////////////////////////////////////////////////////////////////
525 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
526 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
527 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
528 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
529 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
532 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
533 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
534 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
535 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
536 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
539 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
540 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
541 /////////////////////////////////////////////////////////////////////////////////
542 ClassImp(AliITSv11GeometrySSD)
543 /////////////////////////////////////////////////////////////////////////////////
544 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
545   AliITSv11Geometry(),
546   fSSDChipMedium(),
547   fSSDChipGlueMedium(),
548   fSSDStiffenerMedium(),
549   fSSDStiffenerConnectorMedium(),
550   fSSDStiffener0603CapacitorMedium(),
551   fSSDStiffener1812CapacitorMedium(),
552   fSSDStiffenerHybridWireMedium(),
553   fSSDKaptonFlexMedium(),
554   fSSDAlTraceFlexMedium(),
555   fSSDAlTraceLadderCableMedium(),
556   fSSDKaptonLadderCableMedium(),
557   fSSDKaptonChipCableMedium(),
558   fSSDAlTraceChipCableMedium(),
559   fSSDAlCoolBlockMedium(),
560   fSSDSensorMedium(),
561   fSSDSensorSupportMedium(),
562   fSSDCarbonFiberMedium(),
563   fSSDTubeHolderMedium(),
564   fSSDCoolingTubeWater(),
565   fSSDCoolingTubePhynox(),
566   fSSDSupportRingAl(),
567   fSSDMountingBlockMedium(),
568   fSSDRohaCellCone(),
569   fSSDAir(),
570   fSSDCopper(),
571   fCreateMaterials(kFALSE),
572   fTransformationMatrices(kFALSE),
573   fBasicObjects(kFALSE),
574   fcarbonfiberjunction(),
575   fcoolingtubesupport(),
576   fhybridmatrix(),
577   fssdcoolingblocksystem(),
578   fcoolingblocksystematrix(),
579   fssdstiffenerflex(),
580   fssdendflex(),
581   fendladdercoolingtubesupportmatrix(),
582   fendladdermountingblock(),
583   fendladdermountingblockclip(),
584   fSSDSensor5(),
585   fSSDSensor6(),
586   fSSDLayer5(), 
587   fSSDLayer6(),
588   fMotherVol(),
589   fLay5LadderSupportRing(),
590   fLay6LadderSupportRing(),
591   fgkEndCapSupportSystem(),
592   fSSDCone(),
593   fColorCarbonFiber(4),
594   fColorRyton(5),
595   fColorPhynox(14),
596   fColorSilicon(3),
597   fColorAl(38),
598   fColorKapton(6),
599   fColorPolyhamide(5),
600   fColorStiffener(9),
601   fColorEpoxy(30),
602   fColorWater(7),
603   fColorG10(41)
604 {
605   ////////////////////////
606   // Standard constructor
607   ////////////////////////
608 }
609 /////////////////////////////////////////////////////////////////////////////////
610 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
611   AliITSv11Geometry(s.GetDebug()),
612   fSSDChipMedium(s.fSSDChipMedium),
613   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
614   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
615   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
616   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
617   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
618   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
619   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
620   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
621   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
622   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
623   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
624   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
625   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
626   fSSDSensorMedium(s.fSSDSensorMedium),
627   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
628   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
629   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
630   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
631   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
632   fSSDSupportRingAl(s.fSSDSupportRingAl),
633   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
634   fSSDRohaCellCone(s.fSSDRohaCellCone),
635   fSSDAir(s.fSSDAir),
636   fSSDCopper(s.fSSDCopper),
637   fCreateMaterials(s.fCreateMaterials),
638   fTransformationMatrices(s.fTransformationMatrices),
639   fBasicObjects(s.fBasicObjects),
640   fcarbonfiberjunction(s.fcarbonfiberjunction),
641   fcoolingtubesupport(s.fcoolingtubesupport),
642   fhybridmatrix(s.fhybridmatrix),
643   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
644   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
645   fssdstiffenerflex(s.fssdstiffenerflex),
646   fssdendflex(s.fssdendflex),
647   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
648   fendladdermountingblock(s.fendladdermountingblock),
649   fendladdermountingblockclip(s.fendladdermountingblockclip),
650   fSSDSensor5(s.fSSDSensor5),
651   fSSDSensor6(s.fSSDSensor6),
652   fSSDLayer5(s.fSSDLayer5),     
653   fSSDLayer6(s.fSSDLayer6),
654   fMotherVol(s.fMotherVol),
655   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
656   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
657   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
658   fSSDCone(s.fSSDCone),
659   fColorCarbonFiber(s.fColorCarbonFiber),
660   fColorRyton(s.fColorRyton),
661   fColorPhynox(s.fColorPhynox),
662   fColorSilicon(s.fColorSilicon),
663   fColorAl(s.fColorAl),
664   fColorKapton(s.fColorKapton),
665   fColorPolyhamide(s.fColorPolyhamide),
666   fColorStiffener(s.fColorStiffener),
667   fColorEpoxy(s.fColorEpoxy),
668   fColorWater(s.fColorWater),
669   fColorG10(s.fColorG10)
670 {
671   ////////////////////////
672   // Copy Constructor
673   ////////////////////////
674 }
675 /////////////////////////////////////////////////////////////////////////////////
676 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
677 operator=(const AliITSv11GeometrySSD &s){
678   ////////////////////////
679   // Assignment operator
680   ////////////////////////
681   this->~AliITSv11GeometrySSD();
682   new(this) AliITSv11GeometrySSD(s); 
683   return *this;
684 /*      
685   if(&s == this) return *this;
686   fMotherVol = s.fMotherVol;
687   return *this;
688  */
689 }
690 ///////////////////////////////////////////////////////////////////////////////
691 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
692   ///////////////////////////////////////////////////////////////////////  
693   // Method generating the trasformation matrix for the whole SSD Geometry   
694   ///////////////////////////////////////////////////////////////////////  
695   // Setting some variables for Carbon Fiber Supportmatrix creation
696   //////////////////////////////////////////////////////////////////////
697   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
698                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
699   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
700                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
701                                                                  +      fgkCarbonFiberSupportWidth);
702   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
703                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
704   TGeoRotation* carbonfiberot[3];
705   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
706   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
707   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
708   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
709   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
710                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
711                                                   -  fgkCarbonFiberTriangleLength
712                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
713   ///////////////////////////////////////////
714   //Setting Local Translations and Rotations: 
715   ///////////////////////////////////////////
716   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
717   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
718                                                                          0.5*carbonfibersupportheight,NULL);    
719   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
720                                                                          2.*symmetryplaneposition+transvector[1],
721                                                                          transvector[2], carbonfiberot[2]);
722   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
723   /////////////////////////////////////////////////////////////
724   // Carbon Fiber Support Transformations
725   /////////////////////////////////////////////////////////////
726   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
727   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
728                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
729                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
730                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
731   }             
732   /////////////////////////////////////////////////////////////
733   // Carbon Fiber Junction Transformation
734   /////////////////////////////////////////////////////////////
735   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
736   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
737   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
738   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
739   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
740         localcarbonfiberjunctionmatrix[i] = 
741                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
742         localcarbonfiberjunctionrot[i] = 
743                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
744         localcarbonfiberjunctiontrans[i] = 
745                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
746   }
747   ///////////////////////
748   // Setting Translations
749   ///////////////////////
750   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
751   localcarbonfiberjunctiontrans[1][0] = 
752                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
753   localcarbonfiberjunctiontrans[2][0] = 
754                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
755                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
756                                  fgkCarbonFiberTriangleLength
757                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
758   localcarbonfiberjunctiontrans[0][1] = 
759                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
760   localcarbonfiberjunctiontrans[1][1] = 
761                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
762   localcarbonfiberjunctiontrans[2][1] = 
763                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
764   ////////////////////
765   // Setting Rotations
766   ////////////////////
767   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
768                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
769                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
770   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
771         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
772   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
773   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
774   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
775   ////////////////////////////////////////
776   // Setting Carbon Fiber Junction matrix 
777   ////////////////////////////////////////
778   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
779                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
780                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
781                         localcarbonfiberjunctionmatrix[i][j] = 
782                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
783                                                            *localcarbonfiberjunctionrot[i][j]);
784                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
785          }
786   }
787   /////////////////////////////////////////////////////////////
788   // Carbon Fiber Lower Support Transformations
789   /////////////////////////////////////////////////////////////
790   TGeoTranslation* localcarbonfiberlowersupportrans[2];
791   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
792                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
793                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
794                                                                          0.0);
795   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
796                                                                          fgkCarbonFiberJunctionWidth
797                                                                 -    fgkCarbonFiberLowerSupportWidth
798                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
799                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
800                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
801    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
802    fcarbonfiberlowersupportrans[0] = 
803                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
804    fcarbonfiberlowersupportrans[1] = 
805                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
806   /////////////////////////////////////////////////////////////
807   // SSD Sensor Support Transformations
808   /////////////////////////////////////////////////////////////
809   const Int_t kssdsensorsupportmatrixnumber = 3;
810   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
811   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
812   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
813   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
814         localssdsensorsupportmatrix[i] = 
815                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
816         localssdsensorsupportrot[i] = 
817                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
818         localssdsensorsupportrans[i] = 
819                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
820   }
821   ///////////////////////
822   // Setting Translations
823   ///////////////////////
824   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
825                                                                           0.5*fgkSSDSensorSideSupportWidth,
826                                                                           0.0);
827   localssdsensorsupportrans[1][0] = 
828                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
829   localssdsensorsupportrans[2][0] = 
830                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
831   localssdsensorsupportrans[0][1] = 
832                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
833                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
834                                                                                 0.0);
835   localssdsensorsupportrans[1][1] = 
836                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
837                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
838                                                                     -   fgkSSDModuleSensorSupportDistance,
839                                                                                 0.0);
840   localssdsensorsupportrans[2][1] = 
841                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
842                                                                         -    fgkSSDSensorCenterSupportPosition,
843                                                                                  0.5*fgkSSDSensorCenterSupportWidth
844                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
845                                                                                  fgkSSDSensorCenterSupportThickness[0]);
846   localssdsensorsupportrans[0][2] = 
847                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
848                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
849                                                                                  fgkCarbonFiberJunctionWidth
850                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
851                                                                         +    fgkSSDSensorCenterSupportLength
852                                                                         -    fgkSSDSensorCenterSupportThickness[0])
853                                                                         -    fgkSSDSensorCenterSupportPosition,
854                                                                              0.0);
855   localssdsensorsupportrans[1][2] = 
856                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
857   localssdsensorsupportrans[2][2] = 
858                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
859   ////////////////////
860   // Setting Rotations
861   ////////////////////
862   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
863                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
864                         localssdsensorsupportrot[i][j] = new TGeoRotation();
865   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
866         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
867         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
868   }
869   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
870   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
871   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
872   ////////////////////////////////////////
873   // SSD Sensor Support matrix 
874   ////////////////////////////////////////
875   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
876                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
877                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
878                         localssdsensorsupportmatrix[i][j] = 
879                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
880                                                            *localssdsensorsupportrot[i][j]);
881                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
882          }
883   }
884   /////////////////////////////////////////////////////////////
885   // SSD Cooling Tube Support Transformations
886   /////////////////////////////////////////////////////////////
887   const Int_t kcoolingtubesupportmatrixnumber = 2;
888   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
889   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
890   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
891   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
892                                                                                                         /fgkCoolingTubeSupportRmax);
893   localcoolingtubesupportrans[0] = 
894                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
895                                                 +  2.*(fgkCoolingTubeSupportLength
896                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
897                                                 +  fgkCarbonFiberTriangleLength
898                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
899   localcoolingtubesupportrans[1] = 
900                         new TGeoTranslation(fgkCarbonFiberJunctionLength
901                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
902                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
903                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
904                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
905                     -  0.5*(fgkCarbonFiberLowerSupportWidth
906                                         +          fgkSSDSensorCenterSupportLength
907                     -      fgkSSDSensorCenterSupportThickness[0])
908                                         +  0.5*fgkSSDSensorLength,
909                                         -  0.5*fgkCoolingTubeSupportHeight);  
910   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
911   localcoolingtubesupportrot[i] = new TGeoRotation();
912   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
913   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
914   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
915         localcoolingtubesupportmatrix[i] = 
916                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
917                                                    *localcoolingtubesupportrot[i]);
918   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
919   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
920                                                                 (*localcoolingtubesupportmatrix[0]));
921   /////////////////////////////////////////////////////////////
922   // End Ladder SSD Cooling Tube Support Transformations
923   /////////////////////////////////////////////////////////////
924   TGeoTranslation** localendladdercooltubetrans[2];
925   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
926   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
927   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
928   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
929                                                                                         -          (fgkCoolingTubeSupportLength
930                                                                                         -               fgkCoolingTubeSupportRmax),
931                                                                                                         fgkEndLadderMountingBlockPosition[0]
932                                                                                         -               fgkendladdercoolingsupportdistance[0]
933                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
934                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
935   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
936                                                                                         -          (fgkCoolingTubeSupportLength
937                                                                                         -               fgkCoolingTubeSupportRmax),
938                                                                                                         fgkEndLadderMountingBlockPosition[0]
939                                                                                         +               fgkendladdercoolingsupportdistance[1]
940                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
941                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
942   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
943                                                                                         -       fgkCoolingTubeSupportRmax)
944                                                                                         +               fgkCarbonFiberTriangleLength
945                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
946                                                                                                 0.0,
947                                                                                                 0.0);
948   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
949                                                                                                         fgkendladdercoolingsupportdistance[0]
950                                                                                         +               fgkendladdercoolingsupportdistance[1],
951                                                                                                         0.0);
952   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
953   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
954                                                                                         +               fgkCarbonFiberJunctionLength
955                                                                                         -               fgkCoolingTubeSupportLength,
956                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
957                                                                                         -       0.5*fgkCoolingTubeSupportWidth
958                                                                                                    -fgkendladdercoolingsupportdistance[2],
959                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
960   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
961                                                                                         +               fgkCoolingTubeSupportLength
962                                                                                         -               fgkCoolingTubeSupportRmax
963                                                                                         -               fgkCarbonFiberJunctionLength,
964                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
965                                                                                         -       0.5*fgkCoolingTubeSupportWidth
966                                                                                         -               fgkendladdercoolingsupportdistance[2],
967                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
968   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
969   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
970   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
971   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
972   (*localcoolingtubesupportrot[1]));
973   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
974   (*localcoolingtubesupportrot[1]));
975   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
976   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
977   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
978   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
979   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
980
981   fendladdercoolingtubesupportmatrix[1][0] =    
982                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
983                                                                                    *(*localcoolingtubesupportrot[1]));
984   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
985   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
986   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
987   /////////////////////////////////////////////////////////////
988   // SSD Cooling Tube Transformations
989   /////////////////////////////////////////////////////////////
990   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
991   localcoolingtuberot->SetAngles(0.,90.,0.);
992   TGeoTranslation** localcoolingtubetrans[4];
993   TVector3** localcoolingtubevect[4];
994   for(Int_t i=0; i<4; i++){
995         localcoolingtubevect[i] = new TVector3*[2];
996         localcoolingtubetrans[i] = new TGeoTranslation*[2];
997         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
998   }
999   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1000                                                   -fgkCarbonFiberTriangleLength),
1001                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1002                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1003                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1004                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1005                                                   +      fgkSSDSensorCenterSupportLength
1006                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1007                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1008                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1009                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1010                                                   -  0.5*fgkCoolingTubeSupportWidth,
1011                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1012   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1013                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1014                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1015                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1016                                                   +  fgkCoolingTubeSupportWidth,
1017                                                   localcoolingtubevect[0][0]->Z());     
1018   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1019                                                          +                               fgkCarbonFiberTriangleLength,
1020                                                                                          localcoolingtubevect[0][0]->Y(),
1021                                                                                          localcoolingtubevect[0][0]->Z());
1022   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1023                                                          +                               fgkCarbonFiberTriangleLength,
1024                                                                                          localcoolingtubevect[0][1]->Y(),
1025                                                                                          localcoolingtubevect[0][1]->Z());
1026   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1027                                                   -     fgkCarbonFiberTriangleLength),
1028                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1029                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1030                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1031                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1032                                                   +      fgkSSDSensorCenterSupportLength
1033                                                   -      fgkSSDSensorCenterSupportThickness[0])
1034                                                   +  fgkSSDModuleStiffenerPosition[1]
1035                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1036                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1037   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1038                                                          +                               fgkCarbonFiberTriangleLength,
1039                                                                                          localcoolingtubevect[2][0]->Y(),
1040                                                                                          localcoolingtubevect[2][0]->Z());      
1041   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1042                                                   -     fgkCarbonFiberTriangleLength),
1043                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1044                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1045                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1046                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1047                                                   +      fgkSSDSensorCenterSupportLength
1048                                                   -      fgkSSDSensorCenterSupportThickness[0])
1049                                                   +      fgkSSDSensorLength
1050                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1051                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1052   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1053                                                   + fgkCarbonFiberTriangleLength,
1054                                                         localcoolingtubevect[3][0]->Y(),
1055                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1056   for(Int_t i=0; i<4; i++) 
1057         for(Int_t j=0; j<2; j++){
1058                 localcoolingtubetrans[i][j] = 
1059                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1060                                                                 localcoolingtubevect[i][j]->Y(),
1061                                                                 localcoolingtubevect[i][j]->Z());
1062                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1063                                                           *                                     (*localcoolingtuberot));
1064         }
1065   /////////////////////////////////////////////////////////////
1066   // SSD End Ladder Cooling Tube Transformations
1067   /////////////////////////////////////////////////////////////
1068   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1069   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1070   TGeoTranslation** localendlladdercoolingtubetrans[2];
1071   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1072   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1073   for(Int_t i=0; i<2; i++)      
1074         for(Int_t j=0; j<(i==0?6:4); j++)       
1075                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1076   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1077                                                                         -        fgkCoolingTubeSupportRmax)
1078                                                                         +        fgkCarbonFiberJunctionLength,
1079                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1080                                                                         -    fgkendladdercoolingsupportdistance[0]),
1081                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1082   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1083                                                                         -        fgkCoolingTubeSupportRmax)
1084                                                                         -        fgkCarbonFiberJunctionLength
1085                                                                         +    fgkCarbonFiberTriangleLength,
1086                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1087                                                                         -    fgkendladdercoolingsupportdistance[0]),
1088                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1089   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1090                                                                         -   fgkCoolingTubeSupportRmax)
1091                                                                         +       fgkCarbonFiberJunctionLength,
1092                                                                            fgkEndLadderMountingBlockPosition[0]
1093                                                                         -   fgkendladdercoolingsupportdistance[0]
1094                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1095                                                   +                             fgkendladdercoolingsupportdistance[1]
1096                                                   +                             fgkCoolingTubeSupportWidth),
1097                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1098   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1099                                                                         -        fgkCoolingTubeSupportRmax)
1100                                                                         -        fgkCarbonFiberJunctionLength
1101                                                                         +    fgkCarbonFiberTriangleLength,
1102                                                                            fgkEndLadderMountingBlockPosition[0]
1103                                                                         -   fgkendladdercoolingsupportdistance[0]
1104                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1105                                                   +                             fgkendladdercoolingsupportdistance[1]
1106                                                   +                             fgkCoolingTubeSupportWidth),
1107                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1108   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1109                                                                         -   fgkCoolingTubeSupportRmax)
1110                                                                         +       fgkCarbonFiberJunctionLength,
1111                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1112                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1113                                                   -                     fgkEndLadderMountingBlockPosition[0]
1114                                                   -                     fgkendladdercoolingsupportdistance[1]           
1115                                                   -                     fgkCoolingTubeSupportWidth),
1116                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1117   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1118                                                                         -        fgkCoolingTubeSupportRmax)
1119                                                                         -        fgkCarbonFiberJunctionLength
1120                                                                         +    fgkCarbonFiberTriangleLength,
1121                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1122                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1123                                                   -                     fgkEndLadderMountingBlockPosition[0]
1124                                                   -                     fgkendladdercoolingsupportdistance[1]           
1125                                                   -                     fgkCoolingTubeSupportWidth),
1126                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1127   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1128                                                                         -   fgkCoolingTubeSupportRmax)
1129                                                                         +       fgkCarbonFiberJunctionLength,
1130                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1131                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1132                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1133                                                         +                 fgkSSDSensorOverlap
1134                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1135                                                         -                 fgkendladdercoolingsupportdistance[2]
1136                                                         -                 fgkEndLadderMountingBlockPosition[1]
1137                                                         -                 fgkCoolingTubeSupportWidth)
1138                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1139                                                         -                 fgkendladdercoolingsupportdistance[2]
1140                                                         -                 fgkCoolingTubeSupportWidth,
1141                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1142   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1143                                                   -      fgkCoolingTubeSupportRmax)
1144                                                   -      fgkCarbonFiberJunctionLength
1145                                                   +    fgkCarbonFiberTriangleLength,
1146                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1147                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1148                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1149                                                         +                 fgkSSDSensorOverlap
1150                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1151                                                         -                 fgkendladdercoolingsupportdistance[2]
1152                                                         -                 fgkEndLadderMountingBlockPosition[1]
1153                                                         -                 fgkCoolingTubeSupportWidth)
1154                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1155                                                         -                 fgkendladdercoolingsupportdistance[2]
1156                                                         -                 fgkCoolingTubeSupportWidth,
1157                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1158   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1159                                                                         -   fgkCoolingTubeSupportRmax)
1160                                                                         +       fgkCarbonFiberJunctionLength,
1161                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1162                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1163                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1164   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1165                                                                         -        fgkCoolingTubeSupportRmax)
1166                                                                         -        fgkCarbonFiberJunctionLength
1167                                                                         +    fgkCarbonFiberTriangleLength,
1168                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1169                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1170                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1171   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1172   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1173   for(Int_t i=0; i<2; i++)
1174         for(Int_t j=0; j<(i==0?6:4); j++){
1175                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1176                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1177         }
1178   /////////////////////////////////////////////////////////////
1179   // SSD Hybrid Components Transformations
1180   /////////////////////////////////////////////////////////////
1181   const Int_t khybridmatrixnumber = 3;
1182   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1183   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1184                                             0.5*fgkSSDStiffenerWidth,
1185                                             0.5*fgkSSDStiffenerHeight);
1186   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1187                                             fgkSSDModuleStiffenerPosition[1],0.0);
1188
1189   localhybridtrans[2] = new TGeoTranslation(
1190                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1191                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1192                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1193                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1194                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1195                       -       fgkSSDSensorCenterSupportThickness[0]),
1196                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1197                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1198                                           -       fgkSSDModuleVerticalDisalignment)); 
1199   fhybridmatrix = new TGeoHMatrix();
1200   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1201   /////////////////////////////////////////////////////////////
1202   // SSD Cooling Block Transformations
1203   /////////////////////////////////////////////////////////////
1204   const Int_t kcoolingblockmatrixnumber = 4;    
1205   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1206   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1207                             -  fgkCoolingTubeSupportRmin),0.0,
1208                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1209   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1210                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1211                                0.0,fgkSSDStiffenerHeight);
1212   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1213   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1214   fcoolingblocksystematrix = new TGeoHMatrix();
1215   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1216       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1217   /////////////////////////////////////////////////////////////
1218   // SSD Stiffener Flex Transformations
1219   /////////////////////////////////////////////////////////////
1220   const Int_t klocalflexmatrixnumber = 4;
1221   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1222   for(Int_t i=0; i<fgkflexnumber; i++)    
1223       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1224   for(Int_t i=0; i<fgkflexnumber; i++)
1225       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1226             localflexmatrix[i][j] = new TGeoCombiTrans();
1227   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1228                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1229                                                                   -    fgkSSDStiffenerWidth;
1230   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1231                                         +0.5*fgkSSDStiffenerLength,
1232                                          0.5*fgkSSDStiffenerWidth,
1233                                         -0.5*fgkSSDStiffenerHeight
1234                                         -0.5*fgkSSDFlexHeight[0]);
1235   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1236                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1237                                         -0.5*fgkSSDStiffenerWidth,
1238                                         -0.5*fgkSSDStiffenerHeight
1239                                         -0.5*fgkSSDFlexHeight[0]);
1240   TGeoRotation* localflexrot = new TGeoRotation();
1241   localflexrot->SetAngles(180.,0.,0.);    
1242   localflexmatrix[1][0]->SetRotation(localflexrot);
1243   for(Int_t i=0; i<fgkflexnumber; i++)
1244       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1245             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1246   for(Int_t i=0; i<fgkflexnumber; i++){
1247       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1248       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1249             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1250   }
1251   /////////////////////////////////////////////////////////////
1252   // SSD End Flex Transformations
1253   /////////////////////////////////////////////////////////////
1254   TGeoRotation* localendflexrot = new TGeoRotation();
1255   localendflexrot->SetAngles(0.0,90.0,0.0);
1256   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1257   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1258                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1259   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1260                             * TMath::DegToRad()*ssdflexradiusmax
1261                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1262                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1263                                                                                    - 0.1*fgkSSDFlexFullLength;
1264   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1265                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1266                             +      fgkSSDFlexLength[2];
1267   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1268                               0.5*fgkSSDFlexWidth[0],
1269                               2.*fgkSSDStiffenerHeight
1270                             + 0.5*fgkSSDFlexHeight[0]);      
1271   localendflexmatrix->SetRotation(localendflexrot);
1272   for(Int_t i=0; i<fgkflexnumber; i++) 
1273       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1274   /////////////////////////////////////////////////////////////
1275   // End Ladder Carbon Fiber Junction
1276   /////////////////////////////////////////////////////////////
1277   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1278   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1279   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1280   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1281       localendladdercarbonfiberjunctionmatrix[i] 
1282             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1283       localendladdercarbonfiberjunctionrot[i] 
1284             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1285       localendladdercarbonfiberjunctiontrans[i] 
1286             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1287       fendladdercarbonfiberjunctionmatrix[i]
1288             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1289   }
1290   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1291       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1292             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1293             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1294       }
1295   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1296       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1297           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1298   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1299       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1300                               0.0,0.0);
1301       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1302                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1303                 *                     SinD(fgkCarbonFiberTriangleAngle),
1304                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1305   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1306   }
1307   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1308   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1309   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1310   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1311       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1312       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1313       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1314       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1315             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1316       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1317             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1318                                *localendladdercarbonfiberjunctionglobalrot[i]);
1319   }
1320   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1321       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1322             localendladdercarbonfiberjunctionmatrix[i][j] = 
1323                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1324                                      *localendladdercarbonfiberjunctionrot[i][j]);
1325            fendladdercarbonfiberjunctionmatrix[i][j] =
1326             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1327             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1328       }  
1329   /////////////////////////////////////////////////////////////
1330   // End Ladder Carbon Fiber Support
1331   /////////////////////////////////////////////////////////////
1332   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1333   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1334       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1335       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1336             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1337       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1338   }
1339   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1340       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1341             fendladdercarbonfibermatrix[i][j] = 
1342             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1343             *(*fcarbonfibersupportmatrix[j]));
1344   /////////////////////////////////////////////////////////////
1345   // End Ladder SSD Mounting Block
1346   /////////////////////////////////////////////////////////////
1347   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1348       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1349   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1350       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1351                                 +        fgkSSDMountingBlockLength[1])
1352                                 +  0.5*fgkCarbonFiberTriangleLength,
1353                                 fgkEndLadderMountingBlockPosition[i],
1354                                 -  fgkSSDMountingBlockHeight[1]
1355                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1356   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1357   endladdermountingblockrot->SetAngles(0.,90.,0.);
1358   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1359         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1360   /////////////////////////////////////////////////////////////
1361   // End Ladder SSD Mounting Block Clip Matrix 
1362   /////////////////////////////////////////////////////////////
1363   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1364         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1365   
1366   TGeoRotation* localendladdercliprot = new TGeoRotation();
1367   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1368   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1369                                                                                   -     fgkSSDMountingBlockLength[1])
1370                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1371   localendladdercliprot->SetAngles(90.,180.,-90.);
1372   TGeoCombiTrans* localendladderclipcombitrans = 
1373                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1374   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1375         for(Int_t j=0; j<2; j++){
1376                 fendladdermountingblockclipmatrix[i][j] = 
1377                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1378                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1379         }
1380   /////////////////////////////////////////////////////////////
1381   // End Ladder Carbon Fiber Lower Support
1382   /////////////////////////////////////////////////////////////
1383   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1384       fendladderlowersupptrans[i] = 
1385             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1386                         +  0.5*fgkSSDMountingBlockWidth),
1387                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1388   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1389                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1390                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1391                                                                          0.0);
1392   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1393  /////////////////////////////////////////////////////////////
1394   // Matrix for positioning Ladder into mother volume
1395   /////////////////////////////////////////////////////////////
1396   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1397   for(Int_t i=0; i<fgkladdernumber; i++) 
1398         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1399   TGeoRotation* localladdermotherrot = new TGeoRotation();
1400   localladdermotherrot->SetAngles(0.,90.,0.);  
1401   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1402   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1403   for(Int_t i=0; i<fgkladdernumber; i++){
1404         localladdermothertrans[i] = new TGeoTranslation(0.,
1405                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1406                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1407                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1408                                                           * fgkCarbonFiberJunctionWidth,0.);
1409         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1410                                                                                                                 *localladdermotherrot);
1411         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1412         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1413   }
1414   /////////////////////////////////////////////////////////////
1415   // Ladder Cables Matrices
1416   /////////////////////////////////////////////////////////////
1417   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1418                                              + fgkSSDFlexHeight[1];  
1419   Double_t ssdladdercabletransx[3];
1420   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1421                                                   *   SinD(2.*fgkSSDFlexAngle)
1422                                                   *       CosD(2.*fgkSSDFlexAngle);
1423   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1424                                                   -     ssdladdercabletransx[0]
1425                                                   /     SinD(2.*fgkSSDFlexAngle))
1426                                                   *     CosD(fgkSSDFlexAngle);                                          
1427   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1428                                                   *       TMath::DegToRad()*ssdflexradiusmax
1429                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1430                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1431                                                   -       fgkSSDLadderCableWidth)
1432                                                   *       CosD(2.*fgkSSDFlexAngle);
1433   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1434                                                   *     TanD(2.*fgkSSDFlexAngle),
1435                                                         ssdladdercabletransx[1]
1436                                                   *     TanD(fgkSSDFlexAngle),
1437                                                         ssdladdercabletransx[2]
1438                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1439   TGeoRotation* localladdercablerot[3]; 
1440   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1441   localladdercablerot[0]->SetAngles(90.,0.,0.);
1442   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1443   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1444                                                  *                        (*localladdercablerot[0]));
1445   ////////////////////////////////////////////
1446   // LocalLadderCableCombiTransMatrix
1447   ////////////////////////////////////////////
1448   const Int_t klocalladdersidecablesnumber = 2;
1449   const Int_t klocalladdercombitransnumber = 5;
1450   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1451   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1452          localladdercablecombitransmatrix[i] = 
1453                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1454   ///////////////////////////////////////////
1455   // Left Side Ladder Cables Transformations
1456   ///////////////////////////////////////////
1457   localladdercablecombitransmatrix[0][0]  =
1458                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1459                                                 0.,0.,NULL);
1460   localladdercablecombitransmatrix[0][1] = 
1461         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1462                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1463                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1464                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1465                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1466                                            + fgkSSDSensorCenterSupportLength
1467                                            - fgkSSDSensorCenterSupportThickness[0]),
1468                                            - (fgkSSDModuleCoolingBlockToSensor
1469                                            + 0.5*fgkCoolingTubeSupportHeight
1470                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1471                                            - fgkSSDChipHeight),NULL);
1472   localladdercablecombitransmatrix[0][2] = 
1473                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1474                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1475   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1476                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1477                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1478                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1479                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1480                                                                                                 new TGeoRotation("",180.,0.,0.));
1481   localladdercablecombitransmatrix[0][4] = 
1482                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1483                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1484                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1485                                                           0.,
1486                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1487                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1488                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1489                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1490   ///////////////////////////////////////////
1491   // Rigth Side Ladder Cables Transformations
1492   ///////////////////////////////////////////
1493   TGeoCombiTrans* localladdercablessdmodulematrix = 
1494         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1495                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1496                                                                          fgkSSDStiffenerWidth,
1497                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1498   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1499    localladdercablecombitransmatrix[1][i] = 
1500                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1501                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1502   ///////////////////////////////////////////
1503   // Setting LadderCableHMatrix
1504   ///////////////////////////////////////////
1505   Int_t beamaxistrans[2][3];
1506   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1507   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1508   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1509   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1510   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1511   beamaxistrans[1][2] = beamaxistrans[1][0];
1512   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1513   TGeoRotation* laddercablerot = new TGeoRotation();
1514   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1515   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1516   Double_t* laddercabletransvector;     
1517   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1518         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1519         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1520   }
1521   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1522         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1523                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1524                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1525                         localladdercablehmatrix[i][j]->MultiplyLeft(
1526                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1527         }
1528                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1529                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1530                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1531                                                                          laddercabletransvector[1]
1532                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1533                                         *                                fgkCarbonFiberJunctionWidth,
1534                                                                          laddercabletransvector[2]);
1535                 laddercablecombitrans->SetRotation(*laddercablerot);
1536                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1537                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1538         }
1539     fladdercablematrix[i][2] = 
1540                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1541                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1542         fladdercablematrix[i][3] = 
1543                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1544                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1545   }
1546   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1547         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1548                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1549   ///////////////////////////////////////////
1550   // Setting Ladder HMatrix
1551   ///////////////////////////////////////////
1552   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1553                                                                                                 fgkSSDLay6SensorsNumber};
1554   for(Int_t i=0; i<fgkladdernumber; i++){
1555         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1556         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1557                 fladdermatrix[i][j] = new TGeoHMatrix();
1558                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1559                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1560                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1561         }
1562   }
1563   ///////////////////////////////////////////
1564   // Setting SSD Sensor Matrix 
1565   ///////////////////////////////////////////
1566   TGeoCombiTrans* localssdsensorcombitrans[2];
1567   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1568   localssdsensorrot->SetAngles(0.,90.,0.);      
1569   TGeoTranslation* localssdsensortrans[2];
1570   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1571   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1572                                          fgkCarbonFiberJunctionWidth 
1573                                          - fgkCarbonFiberLowerSupportWidth 
1574                                          - fgkLowerSupportToSensorZ,
1575                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1576                                           -             fgkSSDModuleCoolingBlockToSensor
1577                                           +    (fgkSSDSensorSideSupportHeight[1]
1578                                           -             fgkSSDSensorSideSupportHeight[0]));
1579   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1580                                          fgkCarbonFiberJunctionWidth 
1581                                          - fgkCarbonFiberLowerSupportWidth 
1582                                          - fgkLowerSupportToSensorZ,
1583                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1584                                                         -fgkSSDModuleCoolingBlockToSensor);
1585   for(Int_t i=0; i<2; i++) 
1586         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1587                                                                                                          *localssdsensorrot);   
1588     for(Int_t i=0; i<fgkladdernumber; i++){
1589         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1590         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1591                 switch(i){
1592                         case 0: //Ladder of Layer5  
1593                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1594                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1595                                                                                                 *localssdsensorcombitrans[1])));
1596                         break;
1597                         case 1: //Ladder of Layer6 
1598                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1599                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1600                                                                                                 *localssdsensorcombitrans[0])));
1601                 break;
1602                 }
1603           }
1604   }     
1605   //////////////////////////
1606   // Setting SSD End Ladder  
1607   //////////////////////////
1608   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1609   for(Int_t i=0; i<2; i++){
1610         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1611         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1612         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1613         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1614         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1615         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1616         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1617         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1618    }
1619   /////////////////////////////////////////////////////
1620   // Setting the CombiTransformation to pass ITS center 
1621   /////////////////////////////////////////////////////
1622   Double_t itscentertransz[fgklayernumber];
1623   itscentertransz[0] = fgkSSDLay5LadderLength
1624                                          - fgkLay5CenterITSPosition;
1625   itscentertransz[1] = fgkSSDLay6LadderLength
1626                                          - fgkLay6CenterITSPosition;
1627   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1628                                                    + 0.5*fgkCoolingTubeSupportHeight;
1629   TGeoRotation* itscenterrot[3];
1630   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1631   itscenterrot[0]->SetAngles(90.,180.,-90.);
1632   itscenterrot[1]->SetAngles(0.,90.,0.);
1633   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1634   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1635   for(Int_t i=0; i<fgklayernumber; i++) 
1636         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1637                                                          itssensortransy,
1638                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1639                                                    - itscentertransz[i],itscenterrot[2]);
1640   TGeoRotation** locallayerrot[fgklayernumber];
1641   TGeoTranslation** locallayertrans[fgklayernumber];    
1642   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1643   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1644   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1645                                          - fgkLay5CenterITSPosition);
1646   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1647                                          - fgkLay6CenterITSPosition);
1648   const Int_t kssdlayladdernumber[fgklayernumber] = 
1649                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1650   for(Int_t i=0; i<fgklayernumber; i++){
1651     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1652     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1653         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1654         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1655   }
1656   Double_t layerladderangleposition[fgklayernumber] = 
1657                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1658   Double_t layerradius = 0.;
1659   for(Int_t i=0; i<fgklayernumber; i++){        
1660         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1661                 switch(i){
1662                         case 0: //Ladder of Layer5  
1663                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1664                         break;
1665                         case 1: //Ladder of Layer6 
1666                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1667                 break;
1668                 }
1669                 locallayerrot[i][j] = new TGeoRotation();
1670                 locallayertrans[i][j] = new TGeoTranslation();
1671                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1672                 locallayertrans[i][j]->SetTranslation(layerradius 
1673                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1674                                                             layerradius 
1675                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1676                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1677                                                                          *locallayerrot[i][j]);
1678                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1679                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1680                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1681         }
1682   }
1683   /////////////////////////////////////////////////////////////
1684   // Deallocating memory
1685   /////////////////////////////////////////////////////////////
1686   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1687         delete carbonfiberot[i];
1688         delete localcarbonfibersupportmatrix[i];
1689   }
1690   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1691      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1692        delete localcarbonfiberjunctionmatrix[i][j];
1693            delete localcarbonfiberjunctionrot[i][j];
1694            delete localcarbonfiberjunctiontrans[i][j];
1695            }
1696        delete [] localcarbonfiberjunctionmatrix[i];
1697        delete [] localcarbonfiberjunctionrot[i];
1698        delete [] localcarbonfiberjunctiontrans[i];
1699   }
1700   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1701            delete localcarbonfiberlowersupportrans[i];
1702   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1703      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1704        delete localssdsensorsupportmatrix[i][j];
1705            delete localssdsensorsupportrot[i][j];
1706            delete localssdsensorsupportrans[i][j];
1707            }
1708        delete [] localssdsensorsupportmatrix[i];
1709        delete [] localssdsensorsupportrot[i];
1710        delete [] localssdsensorsupportrans[i];
1711   }
1712   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1713         delete localcoolingtubesupportmatrix[i];
1714         delete localcoolingtubesupportrot[i];
1715         delete localcoolingtubesupportrans[i];
1716   }
1717   for(Int_t i=0; i<4; i++){
1718         for(Int_t j=0; j<2; j++){
1719                 delete localcoolingtubevect[i][j];
1720                 delete localcoolingtubetrans[i][j];
1721         }
1722         delete [] localcoolingtubevect[i];
1723         delete [] localcoolingtubetrans[i];
1724   }
1725  delete endladdermountingblockrot;
1726  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1727  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1728  for(Int_t i=0; i<fgkflexnumber; i++){
1729       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1730             delete localflexmatrix[i][j];
1731       delete [] localflexmatrix[i];
1732  }
1733  delete localendlladdercoolingtuberot;
1734  for(Int_t i=0; i<2; i++){
1735         for(Int_t j=0; j<(i==0?6:4); j++)
1736                 delete localendlladdercoolingtubetrans[i][j];
1737         delete [] localendlladdercoolingtubetrans[i];
1738   }
1739
1740  delete localflexrot;
1741  delete localendflexrot;
1742  delete localendflexmatrix;
1743  for(Int_t i=0; i<fgkladdernumber; i++){ 
1744         delete localladdermothertrans[i];
1745         delete localladdermothercombitrans[i];
1746   }
1747  delete localladdermotherrot;
1748  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1749       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1750             delete localendladdercarbonfiberjunctionmatrix[i][j];
1751             delete localendladdercarbonfiberjunctionrot[i][j];
1752             delete localendladdercarbonfiberjunctiontrans[i][j];
1753       }
1754       delete [] localendladdercarbonfiberjunctionmatrix[i];
1755       delete [] localendladdercarbonfiberjunctionrot[i];
1756       delete [] localendladdercarbonfiberjunctiontrans[i];
1757       delete localendladdercarbonfiberjunctionglobalrot[i];
1758       delete localendladdercarbonfiberjunctionglobaltrans[i];
1759       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1760  }
1761   for(Int_t i=0; i<2; i++){
1762         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1763         delete [] localendladdercooltubetrans[i];
1764   }
1765   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1766       delete localendladdercarbonfibertrans[i];
1767   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1768   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1769         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1770                 delete localladdercablecombitransmatrix[i][j];
1771                 delete []localladdercablecombitransmatrix[i];
1772   }
1773   delete localendladdercliprot;
1774   delete localendladdercliptrans;
1775   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1776         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1777                 delete localladdercablehmatrix[i][j];
1778         delete []localladdercablehmatrix[i];
1779   }
1780   delete laddercablerot;
1781   delete laddercabletrans;
1782   delete laddercablecombitrans;
1783   delete localladdercablessdmodulematrix;
1784   delete localssdsensorrot;     
1785   for(Int_t i=0; i<2; i++){
1786         delete localssdsensortrans[i];
1787         delete localssdsensorcombitrans[i];
1788   }
1789   for(Int_t i=0; i<fgklayernumber; i++){
1790         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1791                 delete locallayerrot[i][j];
1792                 delete locallayertrans[i][j];
1793                 delete locallayercombitrans[i][j];
1794     }
1795         delete [] locallayerrot[i];
1796         delete [] locallayertrans[i];
1797         delete [] locallayercombitrans[i];
1798         delete localbeamaxistrans[i];
1799   }
1800   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1801   for(Int_t i=0; i<fgkladdernumber; i++){
1802         for(Int_t j=0; j<fgkladdernumber; j++)
1803                 delete ladderglobalmatrix[i][j];
1804         delete [] ladderglobalmatrix[i];
1805   }
1806   /////////////////////////////////////////////////////////////
1807   fTransformationMatrices = kTRUE;      
1808 }
1809 ///////////////////////////////////////////////////////////////////////////////
1810 void AliITSv11GeometrySSD::CreateBasicObjects(){
1811   /////////////////////////////////////////////////////////////  
1812   // Method generating the Objects of SSD Geometry    
1813   /////////////////////////////////////////////////////////////
1814   // SSD Sensor
1815   ///////////////////////////////////
1816   SetSSDSensor();
1817   /////////////////////////////////////////////////////////////  
1818   // Carbon Fiber Support    
1819   /////////////////////////////////////////////////////////////  
1820   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1821   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1822       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1823   /////////////////////////////////////////////////////////////
1824   // Carbon Fiber Junction 
1825   /////////////////////////////////////////////////////////////
1826   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1827   /////////////////////////////////////////////////////////////
1828   // Carbon Fiber Lower Support
1829   /////////////////////////////////////////////////////////////
1830   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1831   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1832         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1833   /////////////////////////////
1834   // SSD Sensor Support
1835   /////////////////////////////
1836   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1837                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1838   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1839                                                                          fgkSSDSensorSideSupportThickness[1]};
1840   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1841         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1842                                                                                            fgkSSDSensorSideSupportHeight[i],
1843                                                                                            fgkSSDSensorSideSupportWidth,
1844                                                                                            sidesupporthickness);  
1845         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1846                                                                                            fgkSSDSensorCenterSupportHeight[i],
1847                                                                                            fgkSSDSensorCenterSupportWidth,
1848                                                                                            sidesupporthickness);
1849   }
1850   /////////////////////////////////////////////////////////////
1851   // SSD Cooling Tube Support
1852   /////////////////////////////////////////////////////////////
1853   Int_t edgesnumber = 16;
1854   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1855   /////////////////////////////////////////////////////////////
1856   // SSD Hybrid
1857   /////////////////////////////////////////////////////////////
1858   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1859   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1860         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1861   /////////////////////////////////////////////////////////////
1862   // SSD Cooling Block System
1863   /////////////////////////////////////////////////////////////
1864   fssdcoolingblocksystem = GetCoolingBlockSystem();
1865    /////////////////////////////////////////////////////////////
1866   // SSD Cooling Tube
1867   /////////////////////////////////////////////////////////////
1868   TList* coolingtubelist = GetCoolingTubeList();        
1869   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1870         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1871   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1872         fendladdercoolingtube[i] = 
1873                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1874   /////////////////////////////////////////////////////////////
1875   // SSD Flex  
1876   /////////////////////////////////////////////////////////////
1877   fssdstiffenerflex = GetSSDStiffenerFlex();
1878   fssdendflex = GetSSDEndFlex();
1879   ///////////////////////////////////
1880   // End Ladder Carbon Fiber Junction
1881   ///////////////////////////////////
1882   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1883                                                    fendladdercarbonfiberjunction[i] = 
1884                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1885   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1886     fendladdercarbonfiberjunction[i][0] = 
1887                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1888     fendladdercarbonfiberjunction[i][1] = 
1889                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1890   }
1891   ///////////////////////////////////
1892   // End Ladder Mounting Block
1893   ///////////////////////////////////
1894   fendladdermountingblock = GetSSDMountingBlock();
1895   ///////////////////////////////////
1896   // End Ladder Mounting Block
1897   ///////////////////////////////////
1898   fendladdermountingblockclip = GetMountingBlockClip();
1899   ///////////////////////////////////
1900   // Ladder Support 
1901   ///////////////////////////////////
1902   TList* laddersupportlist = GetMountingBlockSupport(20);
1903   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1904   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1905   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1906   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1907   /////////////////////////////////////////////////////////////
1908   // Deallocating memory
1909   /////////////////////////////////////////////////////////////
1910   delete carbonfibersupportlist;
1911   delete carbonfiberlowersupportlist;
1912   delete ssdhybridcomponentslist;
1913   delete laddersupportlist;
1914   /////////////////////////////////////////////////////////////
1915   fBasicObjects = kTRUE;
1916 }
1917 /////////////////////////////////////////////////////////////////////////////////
1918 void AliITSv11GeometrySSD::SetSSDSensor(){
1919   ////////////////////////////////////////////////////////////////
1920   // Method generating SSD Sensors: it sets the private variables
1921   // fSSDSensor5, fSSDSensor6  
1922   ////////////////////////////////////////////////////////////////
1923   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1924   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1925   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1926                                                 0.5*ssdsensitivewidth,
1927                                                 0.5*fgkSSDSensorHeight,
1928                                                 0.5*ssdsensitivelength);
1929   TGeoVolume* ssdsensorsensitiveLay5 = 
1930         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1931   TGeoVolume* ssdsensorsensitiveLay6 = 
1932         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1933   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1934   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1935   TGeoBBox* ssdsensorinsensitiveshape[2];
1936   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1937                                                 0.5*fgkSSDSensorInsensitiveWidth,
1938                                                 0.5*fgkSSDSensorHeight,
1939                                                 0.5*fgkSSDSensorLength);
1940   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1941                                                 0.5*ssdsensitivewidth,
1942                                                 0.5*fgkSSDSensorHeight,
1943                                                 0.5*fgkSSDSensorInsensitiveWidth);
1944   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1945                                              "SSDSensorInsensitive2"};
1946   TGeoVolume* ssdsensorinsensitive[2];
1947   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1948       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1949                      fSSDSensorMedium);
1950       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1951   }
1952   /////////////////////////////////////////////////////////////
1953   // Virtual Volume containing SSD Sensor  
1954   /////////////////////////////////////////////////////////////
1955   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1956                                                                                              0.5*fgkSSDSensorWidth,
1957                                                                                              0.5*fgkSSDSensorHeight,
1958                                                                                              0.5*fgkSSDSensorLength);
1959   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1960                                                                                  fSSDAir);      
1961   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1962                                                                                  fSSDAir);      
1963   /////////////////////////////////////////////////////////////
1964   for(Int_t i=0; i<4; i++){ 
1965             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1966             ssdsensorinsensitive[1],i<2?1:2,
1967                         new TGeoTranslation(
1968                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1969       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1970                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1971       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1972             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1973             ssdsensorinsensitive[1],i<2?1:2,
1974                         new TGeoTranslation(
1975                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1976       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1977                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1978       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1979   }
1980     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1981     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1982 }
1983 ///////////////////////////////////////////////////////////////////////////////
1984 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1985   /////////////////////////////////////////////////////////////  
1986   // Method generating the Carbon Fiber Support   
1987   /////////////////////////////////////////////////////////////  
1988   const Int_t kvertexnumber = 4;
1989   const Int_t kshapesnumber = 2;
1990   TVector3** vertexposition[kshapesnumber];
1991   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1992   Double_t carbonfibersupportxaxisEdgeproj = 
1993                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1994         *       TMath::DegToRad());
1995   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1996                                  /                         fgkCarbonFiberSupportXAxisLength);
1997   /////////////////////
1998   //Vertex Positioning
1999   ////////////////////
2000   vertexposition[0][0] = new TVector3();
2001   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
2002                                                                           fgkCarbonFiberSupportYAxisLength);
2003   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2004                                                                           carbonfibersupportxaxisEdgeproj
2005                                            *                      TMath::Tan(theta));
2006   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2007                                            -                      carbonfibersupportxaxisEdgeproj,
2008                                                                           fgkCarbonFiberSupportYAxisLength
2009                                            -                      vertexposition[0][2]->Y());
2010   ////////////////////////////////////////////////////
2011   //Setting the parameters for Isometry Transformation
2012   ////////////////////////////////////////////////////
2013   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2014                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2015                                                                  +      fgkCarbonFiberSupportWidth);
2016   Double_t* param = new Double_t[4]; 
2017   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2018   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2019                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2020                                                           (GetReflection(vertexposition[0][j],param))->Y());
2021   const char* carbonfibersupportshapename[kshapesnumber] = 
2022                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2023   const char* carbonfibersupportname[kshapesnumber] = 
2024                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2025   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2026   TGeoVolume* carbonfibersupport[kshapesnumber];
2027   TList* carbonfibersupportlist = new TList();
2028   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2029   Double_t carbonfibersupportheight = 
2030           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2031           *TMath::DegToRad());
2032   for(Int_t i = 0; i< kshapesnumber; i++){
2033    carbonfibersupportshape[i] = 
2034                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2035                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2036    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2037                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2038    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2039    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2040    }
2041   /////////////////////////////////////////////////////////////
2042   // Deallocating memory
2043   /////////////////////////////////////////////////////////////
2044   for(Int_t i=0; i< kshapesnumber; i++){
2045      for(Int_t j=0; j< kvertexnumber; j++)
2046            delete vertexposition[i][j];
2047        delete [] vertexposition[i];
2048   }
2049   delete [] param;
2050   /////////////////////////////////////////////////////////////
2051    return carbonfibersupportlist;
2052 }
2053 /////////////////////////////////////////////////////////////////////////////////
2054 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2055   /////////////////////////////////////////////////////////////
2056   // Method generating SSD Carbon Fiber Junction
2057   /////////////////////////////////////////////////////////////
2058   const Int_t kvertexnumber = 6;
2059   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2060   Double_t reflectionparam[3] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2061                                                           *  TMath::DegToRad()),-1.,0.};
2062   TVector3* vertex[kvertexnumber];
2063   vertex[0] = new TVector3();
2064   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2065                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2066                         *                         TMath::DegToRad()),
2067                                                   fgkCarbonFiberJunctionEdge[0]
2068                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2069                         *                         TMath::DegToRad()));
2070   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2071                                                    fgkCarbonFiberJunctionEdge[1]);
2072   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2073   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2074   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2075   Double_t xvertexpoints[6], yvertexpoints[6];
2076   for(Int_t i=0; i<kvertexnumber; i++) 
2077           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2078   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2079   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2080   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2081   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2082                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2083   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2084   /////////////////////////////////////////////////////////////
2085   // Deallocating memory
2086   /////////////////////////////////////////////////////////////
2087   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2088   ///////////////////////////////////////////////////////////// 
2089   return carbonfiberjunction;
2090 }
2091 ////////////////////////////////////////////////////////////////////////////////
2092 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2093   /////////////////////////////////////////////////////////////
2094   // Method generating the Carbon Fiber Lower Support   
2095   /////////////////////////////////////////////////////////////  
2096   const Int_t kvertexnumber = 4;
2097   const Int_t kshapesnumber = 2;
2098   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2099                                                                 fgkCarbonFiberLowerSupportWidth};
2100   TVector3** vertexposition[kshapesnumber];
2101   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2102                                                  new TVector3*[kvertexnumber];
2103   //First Shape Vertex Positioning
2104   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2105   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2106                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2107   vertexposition[0][2] = new TVector3();
2108   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2109   //Second Shape Vertex Positioning
2110   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2111                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2112                                  /                              fgkCarbonFiberTriangleLength);
2113   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2114                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2115                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2116   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2117                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2118                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2119   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2120   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2121                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2122   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
2123                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2124   const char* carbonfiberlowersupportname[kshapesnumber] = 
2125                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2126   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2127   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2128   TList* carbonfiberlowersupportlist = new TList();
2129   for(Int_t i = 0; i< kshapesnumber; i++){ 
2130         carbonfiberlowersupportshape[i] = 
2131                                                                 GetArbShape(vertexposition[i],width,
2132                                                                                         fgkCarbonFiberLowerSupportHeight,
2133                                                                                         carbonfiberlowersupportshapename[i]);
2134     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2135                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2136         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2137     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2138   }
2139   /////////////////////////////////////////////////////////////
2140   // Deallocating memory
2141   /////////////////////////////////////////////////////////////
2142   for(Int_t i=0; i< kshapesnumber; i++){
2143      for(Int_t j=0; j< kvertexnumber; j++)
2144            delete vertexposition[i][j];
2145        delete [] vertexposition[i];
2146   }
2147   /////////////////////////////////////////////////////////////
2148   return carbonfiberlowersupportlist;
2149 }
2150 ///////////////////////////////////////////////////////////////////////////////
2151 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2152                                                                  Double_t width, Double_t* thickness)const{
2153   /////////////////////////////////////////////////////////////
2154   // Method generating the Sensor Support   
2155   /////////////////////////////////////////////////////////////  
2156         const Int_t kvertexnumber = 6;
2157         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2158     TVector3* vertexposition[kvertexnumber];
2159         vertexposition[0] = new TVector3();     
2160         vertexposition[1] = new TVector3(0.0,length);   
2161         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2162         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2163         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2164         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2165         Double_t xvertexpoints[6], yvertexpoints[6];
2166         for(Int_t i=0; i<kvertexnumber; i++) 
2167                 xvertexpoints[i] = vertexposition[i]->X(), 
2168                 yvertexpoints[i] = vertexposition[i]->Y();
2169     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2170     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2171     ssdsensorsupportshape->DefineSection(1,0.5*width);
2172     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2173                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2174   /////////////////////////////////////////////////////////////
2175   // Deallocating memory
2176   /////////////////////////////////////////////////////////////
2177         for (Int_t i=0; i<kvertexnumber; i++)
2178                 delete vertexposition[i];
2179   /////////////////////////////////////////////////////////////
2180     return ssdsensorsupport;
2181 }
2182 ////////////////////////////////////////////////////////////////////////////////
2183 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2184   /////////////////////////////////////////////////////////////
2185   // Method generating the Cooling Tube Support
2186   /////////////////////////////////////////////////////////////
2187   if(nedges%2!=0) nedges--;     
2188   const Int_t kvertexnumber = nedges+5;
2189   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2190                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2191   Double_t angle = 90.+phi;
2192   Double_t psi = 90.-phi;
2193   ///////////////////////////////////////
2194   // Vertex Positioning for TGeoXTru
2195   ///////////////////////////////////////
2196   TVector3** vertexposition = new TVector3*[kvertexnumber];
2197   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2198                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2199   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2200                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2201   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2202                                                                    fgkCoolingTubeSupportRmax);
2203   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2204                                                                    fgkCoolingTubeSupportRmax);
2205   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2206                                                                     vertexposition[1]->Y());
2207   for(Int_t i=0; i<nedges; i++)
2208         vertexposition[i+5] = 
2209                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2210                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2211   ///////////////////////////////////////////////////////////////////////
2212   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2213   ///////////////////////////////////////////////////////////////////////
2214   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2215   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2216   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2217   for(Int_t i=0; i<kvertexnumber; i++){
2218         xvertexpoints[i] = vertexposition[i]->X();
2219         yvertexpoints[i] = vertexposition[i]->Y();
2220   } 
2221   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2222                                                                                         yvertexpoints);
2223   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2224   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2225   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2226                                                                           coolingtubesupportarcshape,
2227                                                                                   fSSDTubeHolderMedium);
2228   coolingtubesupportarc->SetLineColor(fColorG10);
2229   //////////////////////////////////////////////////////////////////////////
2230   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2231   //////////////////////////////////////////////////////////////////////////
2232   TGeoTubeSeg* coolingtubesupportsegshape = 
2233                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2234                                                                                         fgkCoolingTubeSupportRmax,
2235                                                                                         0.5*fgkCoolingTubeSupportWidth,
2236                                                                                         phi,360-phi);
2237   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2238                                                                                         coolingtubesupportsegshape,
2239                                                                                         fSSDTubeHolderMedium);
2240   coolingtubesupportseg->SetLineColor(fColorG10);
2241   //////////////////////////////////////////////////////////////////////////
2242   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2243   //////////////////////////////////////////////////////////////////////////
2244   Double_t* boxorigin = new Double_t[3];
2245   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2246   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2247   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2248                                                                                  0.5*fgkCoolingTubeSupportHeight,
2249                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2250   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2251                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2252   coolingtubesupportbox->SetLineColor(fColorG10);
2253   //////////////////////////////////////////////////////////////////////////
2254   // Cooling Tube for Cooling Tube Support 
2255   //////////////////////////////////////////////////////////////////////////
2256   TGeoXtru* coolingtubearcshape[2];
2257   coolingtubearcshape[0] = new TGeoXtru(2);     
2258   Double_t* xvert = new Double_t[nedges+2];
2259   Double_t* yvert = new Double_t[nedges+2];
2260   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2261   ////////////////////////////////////////
2262   // Positioning the vertices for TGeoXTru
2263   ////////////////////////////////////////
2264   xvert[0] = 0., yvert[0] = 0.;
2265   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2266   for(Int_t i=0; i< nedges; i++)
2267                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2268                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2269   ////////////////////////////////////////
2270   // Defining TGeoXTru PolyGone
2271   ////////////////////////////////////////
2272   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2273   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2274   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2275   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2276                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2277   TGeoVolume* coolingtubearc[2];
2278   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2279                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2280   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2281                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2282   coolingtubearc[0]->SetLineColor(fColorWater);
2283   coolingtubearc[1]->SetLineColor(fColorPhynox);
2284   ////////////////////////////////////////////
2285   // Defining TGeoTubeSeg Part of Cooling Tube
2286   ////////////////////////////////////////////
2287   TGeoTubeSeg* coolingtubesegshape[2];
2288   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2289                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2290   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2291                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2292   TGeoVolume* coolingtubeseg[2];
2293   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2294                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2295   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2296                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2297   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2298   coolingtubeseg[1]->SetLineColor(fColorWater);
2299   /////////////////////////////////////////////////////////////
2300   // Virtual Volume containing Cooling Tube Support  
2301   /////////////////////////////////////////////////////////////
2302   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2303   const Int_t kvirtualvertexnumber = 8;
2304   TVector3* virtualvertex[kvirtualvertexnumber];
2305    ////////////////////////////////////////
2306   // Positioning the vertices for TGeoXTru
2307   ////////////////////////////////////////
2308   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2309   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2310   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2311   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2312   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2313   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2314   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2315   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2316   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2317   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2318         xmothervertex[i] = virtualvertex[i]->X(),
2319         ymothervertex[i] = virtualvertex[i]->Y();
2320   ////////////////////////////////////////
2321   // Defining TGeoXTru PolyGone
2322   ////////////////////////////////////////
2323   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2324                                                                                                                                          ymothervertex);
2325   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2326   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2327   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2328                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2329   ////////////////////////////////////////
2330   // Positioning Volumes in Virtual Volume
2331   ////////////////////////////////////////
2332   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2333   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2334   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2335   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2336   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2337   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2338   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2339   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2340   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2341   /////////////////////////////////////////////////////////////
2342   // Deallocating memory
2343   /////////////////////////////////////////////////////////////
2344   delete [] vertexposition;
2345   delete xvertexpoints;
2346   delete yvertexpoints;
2347   delete xvert;
2348   delete yvert;
2349   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2350         delete virtualvertex[i];
2351   /////////////////////////////////////////////////////////////
2352         return virtualcoolingtubesupport;
2353 }
2354 /////////////////////////////////////////////////////////////////////////////////
2355 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2356   /////////////////////////////////////////////////////////////
2357   // Method generating List containing SSD Hybrid Components   
2358   /////////////////////////////////////////////////////////////
2359   TList* ssdhybridlist = new TList();
2360   const Int_t kssdstiffenernumber = 2;
2361   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2362                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2363                                                                   -    fgkSSDStiffenerWidth;
2364   Double_t ssdchipcablesradius[kssdstiffenernumber];
2365   for(Int_t i=0; i<kssdstiffenernumber; i++)
2366           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2367                                -  fgkSSDChipCablesHeight[0]
2368                                -  fgkSSDChipCablesHeight[1]);
2369   /////////////////////////////////////////////////////////////
2370   // Mother Volumes Containers 
2371   /////////////////////////////////////////////////////////////
2372   const Int_t kmothernumber = 2;
2373   const Int_t kmothervertexnumber = 12;
2374   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2375   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2376   ///////////////////////
2377   // Setting the vertices 
2378   ///////////////////////
2379   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2380   xmothervertex[0][1]  = xmothervertex[0][0]; 
2381   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2382   xmothervertex[0][3]  = xmothervertex[0][2];
2383   xmothervertex[0][4]  = xmothervertex[0][0];
2384   xmothervertex[0][5]  = xmothervertex[0][4];
2385   xmothervertex[0][6]  = -xmothervertex[0][0];
2386   xmothervertex[0][7]  = xmothervertex[0][6];
2387   xmothervertex[0][8]  = -xmothervertex[0][2];
2388   xmothervertex[0][9]  = xmothervertex[0][8];
2389   xmothervertex[0][10] = xmothervertex[0][7];
2390   xmothervertex[0][11] = xmothervertex[0][10];
2391   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2392   for(Int_t i = 0; i<kmothernumber; i++){
2393       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2394                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2395       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2396       ymothervertex[i][2]  = ymothervertex[i][1];
2397       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2398       ymothervertex[i][4]  = ymothervertex[i][3];
2399       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2400       ymothervertex[i][6]  = ymothervertex[i][5];
2401       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2402       ymothervertex[i][8]  = ymothervertex[i][7];
2403       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2404       ymothervertex[i][10] = ymothervertex[i][9];
2405       ymothervertex[i][11] = ymothervertex[i][0];
2406   }
2407   TGeoXtru* ssdhybridmothershape[kmothernumber];
2408 //  TGeoVolume* ssdhybridmother[kmothernumber];
2409   TGeoVolumeAssembly* ssdhybridmother[kmothernumber];
2410   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2411   for(Int_t i=0; i<kmothernumber; i++){
2412       ssdhybridmothershape[i] = new TGeoXtru(2);
2413       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2414                                           ymothervertex[i]);
2415       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2416                                                -fgkSSDChipCablesHeight[i+2]);
2417       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2418 //      ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2419 //                                          fSSDAir);
2420       ssdhybridmother[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2421    }   
2422   /////////////////////////////////////////////////////////////
2423   // SSD Stiffener   
2424   /////////////////////////////////////////////////////////////
2425   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2426                                              0.5*fgkSSDStiffenerLength,
2427                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2428                                              0.5*fgkSSDStiffenerHeight);
2429   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2430                                             fSSDStiffenerMedium);  
2431   ssdstiffener->SetLineColor(fColorStiffener); 
2432   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2433   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2434       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2435   /////////////////////////////////////////////////////////////
2436   // SSD Chip System    
2437   /////////////////////////////////////////////////////////////
2438   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2439   Double_t ssdchipseparation = fgkSSDSensorLength
2440                              - 2.*fgkSSDModuleStiffenerPosition[1]
2441                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2442                              - 0.5*fgkSSDChipWidth);
2443   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2444                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2445   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2446                                       - 0.5*ssdchipsystemlength,
2447                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2448                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2449 ////////////////////////////
2450 // Capacitor 0603-2200 nF
2451 ///////////////////////////
2452   const Int_t knapacitor0603number = 5;
2453   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2454                                                                                          0.5*fgkSSDCapacitor0603Length,
2455                                                                                          0.5*(fgkSSDCapacitor0603Width),
2456                                                                                          0.5*fgkSSDCapacitor0603Height);
2457   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2458                                              fSSDStiffener0603CapacitorMedium); 
2459   capacitor0603->SetLineColor(fColorAl);
2460   for(Int_t i=0; i<kmothernumber; i++){
2461       for(Int_t j=0; j<kssdstiffenernumber; j++){
2462             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2463             for(Int_t k=1; k<knapacitor0603number+1; k++){
2464                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2465                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2466                                            j*ssdstiffenerseparation
2467                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2468                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2469                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2470             }
2471       } 
2472       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2473       ssdhybridlist->Add(ssdhybridmother[i]);
2474   }    
2475 /////////////////////////////////////////////////////////////
2476 // Mother Volume Containing Capacitor Part 
2477 /////////////////////////////////////////////////////////////
2478   const Int_t kcapacitormothernumber = 8;
2479   Double_t xcapacitorvertex[kcapacitormothernumber];
2480   Double_t ycapacitorvertex[kcapacitormothernumber];  
2481   ///////////////////////
2482   // Setting the vertices 
2483   ///////////////////////
2484   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2485   xcapacitorvertex[1] = xcapacitorvertex[0];   
2486   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2487   xcapacitorvertex[3] = xcapacitorvertex[2];   
2488   xcapacitorvertex[4] = xcapacitorvertex[0];   
2489   xcapacitorvertex[5] = xcapacitorvertex[0];   
2490   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2491   xcapacitorvertex[7] = xcapacitorvertex[6];   
2492   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2493   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2494   ycapacitorvertex[2] = ycapacitorvertex[1];   
2495   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2496   ycapacitorvertex[4] = ycapacitorvertex[3];   
2497   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2498   ycapacitorvertex[6] = ycapacitorvertex[5];   
2499   ycapacitorvertex[7] = ycapacitorvertex[0];   
2500   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2501   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2502                                               ycapacitorvertex);
2503   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2504   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2505 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2506 //                                          fSSDAir);
2507   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2508 ////////////////////////////
2509 // Connector 
2510 ///////////////////////////
2511   const Int_t kssdconnectornumber = 2;
2512   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2513   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2514   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2515                                    +  fgkSSDConnectorAlHeight};  
2516   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2517   TGeoVolume* ssdconnector[kssdconnectornumber];
2518   for(Int_t i=0; i<kssdconnectornumber; i++){
2519       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2520                                           0.5*fgkSSDConnectorWidth,
2521                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2522                            +              i*fgkSSDConnectorNiHeight),
2523                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2524       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2525                                        i==0 ? fSSDAlTraceFlexMedium 
2526                                             : fSSDStiffenerConnectorMedium);      
2527       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2528   }
2529   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2530   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2531                        +  fgkSSDConnectorPosition[0]
2532                        -  fgkSSDConnectorSeparation
2533                        -  1.5*fgkSSDConnectorLength,
2534                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2535                        -  fgkSSDConnectorPosition[1]
2536                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2537   ssdconnectortrans[1] = new TGeoTranslation(
2538                        -  ssdstiffenershape->GetDX()
2539                        +  fgkSSDConnectorPosition[0]
2540                        -  0.5*fgkSSDConnectorLength,
2541                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2542                        -  fgkSSDConnectorPosition[1]
2543                        -  ssdconnectorshape[0]->GetDY(),0.0);
2544   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2545                        -  fgkSSDConnectorPosition[0]
2546                        +  fgkSSDConnectorSeparation
2547                        +  1.5*fgkSSDConnectorLength,
2548                           -(ssdstiffenershape->GetDY()
2549                        -  fgkSSDConnectorPosition[1]
2550                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2551   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2552                        -  fgkSSDConnectorPosition[0]
2553                        +  0.5*fgkSSDConnectorLength,
2554                           -(ssdstiffenershape->GetDY()
2555                        -  fgkSSDConnectorPosition[1]
2556                        -  ssdconnectorshape[0]->GetDY()),0.0);
2557   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2558       for(Int_t j=0; j<kssdconnectornumber; j++)
2559             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2560 ////////////////////////////
2561 // Capacitor 1812-330 nF
2562 /////////////////////////// 
2563   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2564   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2565                                                                                          0.5*fgkSSDCapacitor1812Length,
2566                                                                                          0.5*fgkSSDCapacitor1812Width,
2567                                                                                          0.5*fgkSSDCapacitor1812Height,
2568             ssdcapacitor1812origin);
2569   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2570                                              fSSDStiffener1812CapacitorMedium); 
2571   capacitor1812->SetLineColor(fColorAl);
2572   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2573                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2574                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2575   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2576 ////////////////////////////
2577 //Hybrid Wire
2578 ////////////////////////////
2579   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2580                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2581                                  - fgkSSDConnectorSeparation;
2582   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2583                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2584   Double_t ssdwireradius = TMath::Sqrt(TMath::Power(wirex,2.)
2585                                          + TMath::Power(wirey,2));
2586   Double_t wireangle = TMath::ATan(wirex/wirey);
2587   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2588                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2589   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2590                                              fSSDStiffenerHybridWireMedium); 
2591   hybridwire->SetLineColor(fColorPhynox);
2592   TGeoCombiTrans* hybridwirecombitrans[2];
2593   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2594                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2595                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2596                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2597                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2598                                    ssdstiffenershape->GetDZ()
2599                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2600                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2601   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2602                             0.0,
2603                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2604                             0.0,        
2605                             new TGeoRotation("HybridWireRot2",
2606                           - wireangle*TMath::RadToDeg(),0.,0.));
2607   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2608   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2609   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2610   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2611   ssdhybridlist->Add(ssdhybridcapacitormother);
2612   /////////////////////////////////////////////////////////////
2613   // Deallocating memory
2614   /////////////////////////////////////////////////////////////
2615   delete hybridwirecombitrans[0];
2616   delete hybridwirecombitrans[1];
2617   delete ssdchipsystemlist;
2618   return ssdhybridlist;
2619   /////////////////////////////////////////////////////////////
2620 }
2621 ///////////////////////////////////////////////////////////////////////////////
2622 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2623   /////////////////////////////////////////////////////////////
2624   // SSD Cooling Block System
2625   /////////////////////////////////////////////////////////////
2626   // SSD Cooling Block and Cooling Tube Transformations
2627   /////////////////////////////////////////////////////////////
2628   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2629   localcoolingblockrot->SetAngles(0.,90.,0.);
2630   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2631   TVector3* coolingblocktransvector;
2632   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2633                                                                 + fgkSSDCoolingBlockLength,
2634                                                                   fgkSSDSensorLength
2635                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2636                                                                 - fgkSSDCoolingBlockWidth);
2637   const Int_t kcoolingblocktransnumber = 2;
2638   const Int_t kcoolingblocknumber = 4;
2639   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2640   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2641   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2642   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2643   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2644   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2645                                         0.5*fgkSSDCoolingBlockWidth,
2646                                         fgkSSDCoolingBlockHoleCenter);
2647   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2648   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2649   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2650     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2651       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2652                                              j*coolingblocktransvector->Y(),
2653                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2654                                                     + fgkCoolingTubeRmax));
2655       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2656       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2657     }
2658   }
2659   /////////////////////////////////////////////////////////////
2660   // Virtual Volume containing CoolingBlock System   
2661   /////////////////////////////////////////////////////////////
2662   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2663   const Int_t kmothervertexnumber = 16;  
2664   Double_t xmothervertex[kmothervertexnumber];
2665   Double_t ymothervertex[kmothervertexnumber];
2666   ///////////////////////
2667   // Setting the vertices 
2668   ///////////////////////fgkCoolingTubeSupportRmax
2669   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2670   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2671                                    + fgkSSDCoolingBlockWidth;
2672   xmothervertex[2] = coolingblocktransvector->X()
2673                                    + fgkSSDCoolingBlockLength
2674                                    + 4*coolingtubedistance;
2675   ymothervertex[2] = ymothervertex[1];
2676   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2677   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2678   ymothervertex[4] = ymothervertex[0];
2679   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2680   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2681   ymothervertex[6] = ymothervertex[5]; 
2682   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2683                                    - fgkSSDCoolingBlockWidth; 
2684   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2685   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2686                                    - coolingtubedistance;
2687   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2688   ymothervertex[10] = ymothervertex[9];
2689   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2690   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2691   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2692   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2693   ymothervertex[14] = ymothervertex[13];
2694   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2695   //////////////////////////////////////////////////////////
2696   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2697                                                                         xmothervertex,ymothervertex);
2698   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2699                                                                                            + fgkCoolingTubeRmax));
2700   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2701                                                                                            + fgkCoolingTubeRmax));
2702   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2703 //  TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2704 //                                                        coolingsystemothershape,fSSDAir);
2705   /////////////////////////////////////////////////////////////
2706   // SSD Cooling Tube Part 
2707   /////////////////////////////////////////////////////////////
2708   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2709   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2710                                                                                  0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance)); 
2711   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2712                                                                          0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance));
2713   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2714   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2715                                                                         fSSDCoolingTubePhynox);
2716   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2717                                                                         fSSDCoolingTubeWater);
2718   coolingtube[0]->SetLineColor(fColorPhynox);
2719   coolingtube[1]->SetLineColor(fColorWater);
2720   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2721   /////////////////////////////////////////////////////////////
2722   // Adding Cooling block to mother volume
2723   /////////////////////////////////////////////////////////////
2724    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2725         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2726         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2727         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2728   }
2729   /////////////////////////////////////////////////////////////
2730   // Deallocating memory
2731   /////////////////////////////////////////////////////////////
2732         delete coolingblocktransvector;
2733         delete localcoolingblockrot;
2734         delete localcoolingtubetrans;
2735         delete localcoolingtuberot;
2736   /////////////////////////////////////////////////////////////
2737   // Checking overlaps  
2738   /////////////////////////////////////////////////////////////
2739         //coolingsystemother->CheckOverlaps(0.01);
2740   /////////////////////////////////////////////////////////////
2741         return coolingsystemother;
2742 }
2743 /////////////////////////////////////////////////////////////////////////////////
2744 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2745   /////////////////////////////////////////////////////////////
2746   // SSD Flex
2747   /////////////////////////////////////////////////////////////
2748   const Int_t kssdflexlayernumber = 2;
2749   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2750   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2751   const Int_t kmothervertexnumber = 17; 
2752   Double_t xmothervertex[kmothervertexnumber];
2753   Double_t ymothervertex[kmothervertexnumber];
2754   /////////////////////////////////////////////
2755   // Auxiliary variables for vertex positioning
2756   /////////////////////////////////////////////
2757   const Int_t kssdflexboxnumber = 5;
2758   Double_t ssdflexboxlength[kssdflexboxnumber];
2759   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2760                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2761                                           *     fgkSSDChipSeparationLength
2762                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2763                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2764   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2765   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2766                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2767   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2768   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2769                                           -     ssdflexboxlength[1];
2770   Double_t ssdflexboxwidth[kssdflexboxnumber];
2771   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2772   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2773   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2774   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2775   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2776   ///////////////////////
2777   // Setting the vertices 
2778   ///////////////////////
2779   xmothervertex[0]  = 0.0;
2780   xmothervertex[1]  = xmothervertex[0];
2781   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2782   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2783                                         + ssdflexboxlength[4];
2784   xmothervertex[4]  = xmothervertex[3];
2785   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2786   xmothervertex[6]  = xmothervertex[5];
2787   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2788   xmothervertex[8]  = xmothervertex[7];
2789   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2790   xmothervertex[10] = xmothervertex[9]; 
2791   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2792   xmothervertex[12] = xmothervertex[11];
2793   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2794   xmothervertex[14] = xmothervertex[13];
2795   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2796   xmothervertex[16] = xmothervertex[15];
2797   ymothervertex[0]  = 0.0;
2798   ymothervertex[1]  = fgkSSDFlexWidth[1];
2799   ymothervertex[2]  = fgkSSDFlexWidth[0];
2800   ymothervertex[3]  = ymothervertex[2];
2801   ymothervertex[4]  = ymothervertex[0];
2802   ymothervertex[5]  = ymothervertex[4];
2803   ymothervertex[6]  = ssdflexboxwidth[2];
2804   ymothervertex[7]  = ymothervertex[6];
2805   ymothervertex[8]  = ymothervertex[0];
2806   ymothervertex[9]  = ymothervertex[8];
2807   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2808   ymothervertex[11] = ymothervertex[10];
2809   ymothervertex[12] = ymothervertex[0];
2810   ymothervertex[13] = ymothervertex[12];
2811   ymothervertex[14] = ymothervertex[7];
2812   ymothervertex[15] = ymothervertex[14];
2813   ymothervertex[16] = ymothervertex[0];
2814   /////////////////////////////////////////////////////////////
2815   // First Mother Volume containing SSDFlex
2816   /////////////////////////////////////////////////////////////
2817   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2818   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2819                                                                     ymothervertex);
2820   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2821   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2822   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2823 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2824 //                                                                                       fSSDAir);
2825   /////////////////////////////////////////////////////////////
2826   // SSDFlex Layer Shapes
2827   /////////////////////////////////////////////////////////////
2828   for(Int_t i=0; i<kssdflexlayernumber; i++){
2829         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2830                                                                    ymothervertex);
2831     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2832         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2833   }
2834   /////////////////////////////////////
2835   // Setting Layers into Mother Volume
2836   /////////////////////////////////////
2837   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2838   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2839                                                                                                  fSSDKaptonFlexMedium};
2840   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2841                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2842   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2843   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2844   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2845         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2846                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2847                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2848         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2849     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2850                                          +                                         fgkSSDFlexHeight[1])); 
2851     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2852   }
2853   return ssdflexmother;
2854 }
2855 /////////////////////////////////////////////////////////////////////////////////
2856 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2857   /////////////////////////////////////////////////////////////
2858   // Method generating SSD End Flex   
2859   /////////////////////////////////////////
2860   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2861                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2862   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2863                                                 * TMath::DegToRad()*ssdflexradiusmax
2864                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2865                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2866                                                         - 0.1*fgkSSDFlexFullLength;
2867   const Int_t knedges = 20;  
2868   const Int_t karcnumber = 2;
2869   TVector3* vertexposition[karcnumber*(knedges+1)];
2870   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2871   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2872   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2873   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2874                                                                                  - 90.0*TMath::DegToRad()};
2875   TVector3* referencetrans[karcnumber];
2876   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2877                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2878                                                                    radius[0]);
2879   referencetrans[1] = new TVector3(referencetrans[0]->X()
2880                                         +              fgkSSDFlexLength[2],
2881      -              fgkSSDStiffenerHeight);
2882 for(Int_t i=0; i<karcnumber; i++){
2883         for(Int_t j=0; j<knedges+1; j++){
2884                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2885                                                                                                radius[i]*SinD(angle[i]));
2886                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2887         }       
2888   }
2889   ///////////////////////
2890   // Setting the vertices 
2891   ///////////////////////
2892   const Int_t kendflexlayernumber = 4;
2893   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2894   TVector3** vertex[kendflexlayernumber];
2895   for(Int_t i=0; i<kendflexlayernumber; i++) 
2896                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2897   TVector3* transvector[kendflexlayernumber+1];
2898   TVector3* deltatransvector = new TVector3();  
2899   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2900   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2901                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2902   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2903         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2904                                         *                 CosD(fgkSSDFlexAngle),
2905                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2906                                         *         SinD(fgkSSDFlexAngle),0.0);   
2907         *transvector[i] = *transvector[i-1]+*deltatransvector;
2908   }
2909   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2910   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2911   for(Int_t i=0; i<karcnumber; i++){
2912         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2913                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2914                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2915                                               /radius[i];
2916         }
2917   }
2918   for(Int_t i=0; i<kendflexlayernumber; i++){
2919         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2920         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2921         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2922                 if(j<(knedges+1)){
2923                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2924                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2925                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2926                         *vertex[i][j+2] += *referencetrans[0];
2927                         vertex[i][4*(knedges+1)-j+1] = 
2928                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2929                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2930                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2931                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2932                 }
2933                 else{
2934                 
2935                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2936                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2937                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2938                         *vertex[i][j+2] += *referencetrans[1];
2939                         vertex[i][4*(knedges+1)-j+1] = 
2940                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2941                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2942                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2943                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2944            }
2945         }
2946   }
2947   /////////////////////////////////////////////////////////////
2948   // First Mother Volume containing SSDEndFlex
2949   /////////////////////////////////////////////////////////////
2950   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2951   Double_t xmothervertex[kendflexvertexnumber];
2952   Double_t ymothervertex[kendflexvertexnumber];
2953   xmothervertex[0] = vertex[0][0]->X(); 
2954   ymothervertex[0] = vertex[0][0]->Y();
2955   for(Int_t i=1; i<kendflexvertexnumber; i++){
2956         if(i<2*(knedges+1)+2){
2957                 xmothervertex[i] = vertex[3][i]->X();
2958                 ymothervertex[i] = vertex[3][i]->Y();
2959         }
2960         else{
2961                 xmothervertex[i] = vertex[0][i]->X();
2962                 ymothervertex[i] = vertex[0][i]->Y();
2963         }
2964   }
2965   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2966                                                                            xmothervertex,ymothervertex);
2967   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2968   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2969 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2970 //                                                               ssdendflexmothershape,fSSDAir);        
2971   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2972   //////////////////////////////////////
2973   // End Flex TGeoXtru Layer Definition 
2974   //////////////////////////////////////
2975   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2976   TGeoVolume* ssdendflex[kendflexlayernumber];
2977   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2978   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2979   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2980   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2981   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2982                                                                                                         fSSDKaptonFlexMedium};
2983   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2984                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2985   for(Int_t i=0; i<kendflexlayernumber; i++){
2986         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2987                 xvertex[i][j] = vertex[i][j]->X();
2988                 yvertex[i][j] = vertex[i][j]->Y();
2989         }
2990   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2991   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2992   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2993   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2994                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2995   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2996   ssdendflexmother->AddNode(ssdendflex[i],1);
2997   }
2998   /////////////////////////////////////////////////////////////
2999   // Deallocating memory
3000   /////////////////////////////////////////////////////////////
3001   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
3002   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
3003   for(Int_t i=0; i<kendflexlayernumber; i++){
3004         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
3005         delete [] vertex[i];
3006   }
3007   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
3008   delete deltatransvector;
3009   /////////////////////////////////////////////////////////////
3010   //ssdendflexmother->CheckOverlaps(0.01);
3011   return ssdendflexmother;
3012 }
3013 ///////////////////////////////////////////////////////////////////////////////
3014 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3015   /////////////////////////////////////////////////////////////
3016   // Method generating the Mounting Block
3017   /////////////////////////////////////////////////////////////  
3018   const Int_t kvertexnumber = 8;
3019   Double_t xvertex[kvertexnumber];
3020   Double_t yvertex[kvertexnumber];
3021   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3022   xvertex[1] = xvertex[0];
3023   xvertex[2] = -xvertex[0];
3024   xvertex[3] = xvertex[2];
3025   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3026                          -                                 fgkSSDMountingBlockLength[2]);
3027   xvertex[5] = xvertex[4];
3028   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3029                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3030                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3031   xvertex[7] = xvertex[6];
3032   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3033                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3034   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3035   yvertex[2] = yvertex[1]; 
3036   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3037   yvertex[4] = yvertex[3];
3038   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3039                          - fgkSSDMountingBlockHeight[0];
3040   yvertex[6] = yvertex[5];
3041   yvertex[7] = yvertex[0];
3042   ///////////////////////////////////////////////////////////////////////
3043   // TGeoXTru Volume definition for Mounting Block Part
3044   ///////////////////////////////////////////////////////////////////////
3045   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3046   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3047   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3048   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3049   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3050                                                                           ssdmountingblockshape,
3051                                                                                   fSSDMountingBlockMedium);
3052   ssdmountingblock->SetLineColor(fColorG10);
3053   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3054   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3055   TGeoRotation* mountingblockrot = new TGeoRotation();
3056   mountingblockrot->SetAngles(90.,180.,-90.);
3057   mountingblockcombitrans->SetRotation(*mountingblockrot);
3058   /////////////////////////////////////////////////////////////
3059   // Generating the Mounting Block Screw Vertices 
3060   /////////////////////////////////////////////////////////////  
3061   const Int_t kscrewvertexnumber = 15;
3062   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3063                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3064                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3065                                  * TMath::RadToDeg();
3066   Double_t phi0 = 90.+alpha;
3067   Double_t phi = 270.-2*alpha;
3068   Double_t deltaphi = phi/kscrewvertexnumber;   
3069   TVector3* screwvertex[kscrewvertexnumber+1];
3070   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3071         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3072                                    *CosD(phi0+i*deltaphi),
3073                                    fgkSSDMountingBlockScrewHoleRadius[0]
3074                                    *SinD(phi0+i*deltaphi));
3075   Double_t xscrewvertex[kscrewvertexnumber+6];
3076   Double_t yscrewvertex[kscrewvertexnumber+6];
3077   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3078   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3079                                   -               fgkSSDMountingBlockScrewHoleEdge);
3080   xscrewvertex[1] = xscrewvertex[0];
3081   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3082   xscrewvertex[2] = screwvertex[0]->X();
3083   yscrewvertex[2] = yscrewvertex[1];
3084   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3085         xscrewvertex[i+3] = screwvertex[i]->X();        
3086         yscrewvertex[i+3] = screwvertex[i]->Y();        
3087   } 
3088   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3089   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3090   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3091   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3092   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3093   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3094   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3095   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3096                                                         +                                  fgkSSDMountingBlockHeight[2]);
3097   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3098                                                                                 ssdmountingblockscrewshape,
3099                                                                                             fSSDMountingBlockMedium);
3100   ssdmountingblockscrew->SetLineColor(fColorG10);
3101   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3102   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3103   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3104                                                                         -                                yscrewvertex[1],
3105                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3106                                                                         -                                fgkSSDMountingBlockHeight[2]
3107                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3108                                                                         +                                fgkSSDMountingBlockHeight[2]
3109                                                                         -                                yvertex[0]));
3110   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3111                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3112                                                                                                                  yscrewvertex[1]
3113                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3114                                                                                                          +fgkSSDMountingBlockHeight[2]
3115                                                                                                          -yvertex[0]));
3116   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3117                                                                                                           yscrewvertex[1],
3118                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3119                                                                         +                                 fgkSSDMountingBlockHeight[2]
3120                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3121                                                                         +                                 fgkSSDMountingBlockHeight[2]
3122                                                                         -                                 yvertex[0]));
3123   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3124                                                                                                          yscrewvertex[1],
3125                                                                         -                                yscrewvertex[1]
3126                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3127                                                                         +                                fgkSSDMountingBlockHeight[2]
3128                                                                         -                                yvertex[0]));
3129   TGeoRotation* ssdmountingblockscrewrot[4];
3130   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3131         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3132     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3133     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3134   for(Int_t i=1; i<4; i++) 
3135         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3136   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3137   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3138   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3139   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3140                                                          +                                xvertex[0],yscrewvertex[1]
3141                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3142                                                          +                                fgkSSDMountingBlockHeight[2]
3143                                                          -                                yvertex[0]),0.);      
3144   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3145   for(Int_t i=0; i<4; i++){
3146         ssdmountingblockscrewmatrix[i] = 
3147                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3148         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3149   }
3150   ///////////////////////////////////////////////////////////////////////
3151   // TGeoXtru for Mother Volume 
3152   ///////////////////////////////////////////////////////////////////////
3153   const Int_t kvertexmothernumber = 12;
3154   Double_t xmothervertex[kvertexmothernumber];
3155   Double_t ymothervertex[kvertexmothernumber];
3156   for(Int_t i=0; i<6; i++){
3157         xmothervertex[i] = xvertex[i];
3158         ymothervertex[i] = yvertex[i];
3159   } 
3160   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3161   ymothervertex[6]  = ymothervertex[5];
3162   xmothervertex[7]  = xmothervertex[6];
3163   ymothervertex[7]  = ymothervertex[4];
3164   xmothervertex[8]  = xmothervertex[7]
3165                                         + 0.5*(fgkSSDMountingBlockLength[1]
3166                                         -          fgkSSDMountingBlockLength[2]);
3167   ymothervertex[8]  = ymothervertex[4];
3168   xmothervertex[9]  = xmothervertex[8];
3169   ymothervertex[9]  = ymothervertex[2];
3170   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3171   ymothervertex[10] = ymothervertex[1];
3172   xmothervertex[11] = xmothervertex[10];
3173   ymothervertex[11] = ymothervertex[0];  
3174   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3175   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3176   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3177   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3178   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3179                                                                           ssdmountingblockmothershape,
3180                                                                                   fSSDAir);
3181   /////////////////////////////////////////////////////////////
3182   // Placing the Volumes into Mother Volume 
3183   /////////////////////////////////////////////////////////////
3184   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3185   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3186   for(Int_t i=0; i<4; i++) 
3187         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3188                                                                         ssdmountingblockscrewmatrix[i]);
3189   /////////////////////////////////////////////////////////////
3190   // Deallocating memory
3191   /////////////////////////////////////////////////////////////
3192   delete mountingblockrot;
3193   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3194   delete ssdmountingblockglobalrot; 
3195   delete ssdmountingblockglobaltrans; 
3196   /////////////////////////////////////////////////////////////
3197   return ssdmountingblockmother;
3198 }
3199 ///////////////////////////////////////////////////////////////////////////////
3200  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3201   /////////////////////////////////////////////////////////////
3202   // Method generating the Mounting Block Clip 
3203   /////////////////////////////////////////////////////////////  
3204   const Int_t kmothervertexnumber = 10;
3205   Double_t xmothervertex[kmothervertexnumber];
3206   Double_t ymothervertex[kmothervertexnumber];
3207   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3208                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3209   xmothervertex[1] = xmothervertex[0];
3210   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3211                                    - fgkMountingBlockClibScrewRadius);
3212   xmothervertex[3] = xmothervertex[2]; 
3213   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3214   xmothervertex[5] = xmothervertex[4]; 
3215   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3216   xmothervertex[7] = xmothervertex[6]; 
3217   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3218   xmothervertex[9] = xmothervertex[8]; 
3219   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3220                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3221   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3222   ymothervertex[2] = ymothervertex[1];
3223   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3224                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3225                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3226   ymothervertex[4] = ymothervertex[3];
3227   ymothervertex[5] = ymothervertex[2];
3228   ymothervertex[6] = ymothervertex[5];
3229   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3230   ymothervertex[8] = ymothervertex[7];
3231   ymothervertex[9] = ymothervertex[0];
3232   ///////////////////////////////////////////////////////////////////////
3233   // TGeoXTru Volume definition for Mounting Block Clip Part
3234   ///////////////////////////////////////////////////////////////////////
3235   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3236   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3237   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3238   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3239   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3240                                                                           ssdmountingblockclipshape,fSSDAir);
3241   ssdmountingblockclip->SetLineColor(4);
3242   ///////////////////////////////////////////////////////////////////////
3243   // TGeoXTru Volume definition for Clip 
3244   ///////////////////////////////////////////////////////////////////////
3245   const Int_t kclipvertexnumber = 6;
3246   Double_t xclipvertex[kclipvertexnumber];
3247   Double_t yclipvertex[kclipvertexnumber];
3248   xclipvertex[0] = xmothervertex[0];
3249   xclipvertex[1] = xclipvertex[0];
3250   xclipvertex[2] = xmothervertex[6];
3251   xclipvertex[3] = xclipvertex[2];
3252   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3253   xclipvertex[5] = xclipvertex[4];
3254   yclipvertex[0] = ymothervertex[0];
3255   yclipvertex[1] = ymothervertex[1];
3256   yclipvertex[2] = yclipvertex[1];
3257   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3258   yclipvertex[4] = yclipvertex[3];
3259   yclipvertex[5] = yclipvertex[0];
3260   TGeoXtru* clipshape = new TGeoXtru(2);
3261   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3262   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3263   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3264                                                          +   fgkMountingBlockClibWidth);
3265   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3266   clip->SetLineColor(18);
3267   ///////////////////////////////////////////////////////////////////////
3268   // Ladder Support Piece  
3269   ///////////////////////////////////////////////////////////////////////
3270   const Int_t ksupportvertexnumber = 4;
3271   Double_t xsupportvertex[ksupportvertexnumber];
3272   Double_t ysupportvertex[ksupportvertexnumber];
3273   xsupportvertex[0] = xclipvertex[5];
3274   xsupportvertex[1] = xsupportvertex[0];
3275   xsupportvertex[2] = xmothervertex[9];
3276   xsupportvertex[3] = xsupportvertex[2];
3277   ysupportvertex[0] = yclipvertex[0];
3278   ysupportvertex[1] = yclipvertex[3];
3279   ysupportvertex[2] = ysupportvertex[1];
3280   ysupportvertex[3] = ysupportvertex[0];
3281   TGeoXtru* supportshape = new TGeoXtru(2);
3282   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3283   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3284   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3285   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3286   support->SetLineColor(9);
3287   ///////////////////////////////////////////////////////////////////////
3288   // TGeoXTru Volume definition for Screw   
3289   ///////////////////////////////////////////////////////////////////////
3290   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3291                                                 0.5*fgkMountingBlockClibScrewRadius};
3292   Int_t edgesnumber[2] = {50,6};
3293   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3294                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3295   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3296   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3297   clipscrew->SetLineColor(12);
3298   TGeoRotation* screwrot = new TGeoRotation();
3299   screwrot->SetAngles(0.,90.,0.);
3300   TGeoTranslation* screwtrans = new TGeoTranslation();
3301   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3302                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3303                                                          0.5*fgkSSDMountingBlockWidth+
3304                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3305   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3306   ///////////////////////////////////////////////////////////////////////
3307   // Placing the Volumes
3308   ///////////////////////////////////////////////////////////////////////
3309   ssdmountingblockclip->AddNode(clip,1);
3310   ssdmountingblockclip->AddNode(support,1);
3311   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3312   /////////////////////////////////////////////////////////////
3313   // Deallocating memory
3314   /////////////////////////////////////////////////////////////  
3315   delete screwtrans;
3316   delete screwrot;
3317   /////////////////////////////////////////////////////////////
3318   return ssdmountingblockclip;
3319 }
3320 ///////////////////////////////////////////////////////////////////////////////
3321 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3322   /////////////////////////////////////////////////////////////
3323   // Method generating the Cooling Tube 
3324   /////////////////////////////////////////////////////////////  
3325    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3326    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3327                                                                                                 new     TGeoTube*[2];
3328    // Ladder Cooling Tubes
3329    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3330                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3331                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
3332                                                   -0.5*fgkSSDTolerance);
3333    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3334                                                                                  coolingtubeshape[0][0]->GetDz());
3335    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3336                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3337                                                   -                                       fgkSSDSensorOverlap-fgkSSDTolerance));
3338    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3339                                                                                  coolingtubeshape[1][0]->GetDz());
3340    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3341                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDTolerance));
3342    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3343                                                                                  coolingtubeshape[2][0]->GetDz()-0.5*fgkSSDTolerance);
3344    // End Ladder Cooling Tubes  
3345    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3346    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3347    endladdercoolingtubeshape[i] = new   TGeoTube*[2];
3348    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3349                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3350                                                   -                     fgkendladdercoolingsupportdistance[0]-fgkSSDTolerance));
3351    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3352                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3353    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3354                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3355                                                   +                     fgkendladdercoolingsupportdistance[1]
3356                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3357    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3358                                                                         endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3359    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3360                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3361                                                   -                     fgkEndLadderMountingBlockPosition[0]
3362                                                   -                     fgkendladdercoolingsupportdistance[1]           
3363                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3364    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3365                                                                         endladdercoolingtubeshape[2][0]->GetDz()-0.5*fgkSSDTolerance);
3366    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3367                                                           0.50 * (fgkMountingBlockToSensorSupport
3368                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3369                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3370                                                         +                 fgkSSDSensorOverlap
3371                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3372                                                         -                 fgkendladdercoolingsupportdistance[2]
3373                                                         -                 fgkEndLadderMountingBlockPosition[1]
3374                                                         -                 fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3375    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3376                                                                         endladdercoolingtubeshape[3][0]->GetDz()-0.5*fgkSSDTolerance);
3377    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3378                                                           0.50 * (fgkendladdercoolingsupportdistance[2]-fgkSSDTolerance));
3379    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3380                                                                         endladdercoolingtubeshape[4][0]->GetDz()-0.5*fgkSSDTolerance);
3381    // Ladder Cooling Tubes
3382    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3383    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3384                                                                                          new TGeoVolume*[2];
3385    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3386                                                                           fSSDCoolingTubePhynox);
3387    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3388                                                                           fSSDCoolingTubeWater);
3389    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3390                                                                           fSSDCoolingTubePhynox);
3391    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3392                                                                           fSSDCoolingTubeWater);
3393    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3394                                                                           fSSDCoolingTubePhynox);
3395    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3396                                                                           fSSDCoolingTubeWater);
3397    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3398         coolingtube[i][0]->SetLineColor(fColorPhynox);
3399         coolingtube[i][1]->SetLineColor(fColorWater);
3400    }
3401    // End Ladder Cooling Tubes  
3402    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3403    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3404    endladdercoolingtube[i] = new TGeoVolume*[2];
3405    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3406                                                                 endladdercoolingtubeshape[0][0],
3407                                                                 fSSDCoolingTubePhynox);
3408    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3409                                                                 endladdercoolingtubeshape[0][1],
3410                                                                 fSSDCoolingTubeWater);
3411    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3412                                                                 endladdercoolingtubeshape[1][0],
3413                                                                 fSSDCoolingTubePhynox);
3414    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3415                                                                 endladdercoolingtubeshape[1][1],
3416                                                                 fSSDCoolingTubeWater);
3417    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3418                                                                 endladdercoolingtubeshape[2][0],
3419                                                                 fSSDCoolingTubePhynox);
3420    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3421                                                                 endladdercoolingtubeshape[2][1],
3422                                                                 fSSDCoolingTubeWater);
3423    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3424                                                                 endladdercoolingtubeshape[3][0],
3425                                                                 fSSDCoolingTubePhynox);
3426    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3427                                                                 endladdercoolingtubeshape[3][1],
3428                                                                 fSSDCoolingTubeWater);
3429    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3430                                                                 endladdercoolingtubeshape[4][0],
3431                                                                 fSSDCoolingTubePhynox);
3432    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3433                                                                 endladdercoolingtubeshape[4][1],
3434                                                                 fSSDCoolingTubeWater);
3435    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3436                 endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3437                 endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3438    }
3439   
3440   /////////////////////////////////////////////////////////////
3441   // Virtual Volume containing Cooling Tubes
3442   /////////////////////////////////////////////////////////////
3443   // Ladder Cooling Tubes
3444   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3445   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3446   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3447                                                                                         coolingtubeshape[i][0]->GetRmax(),
3448                                                                                         coolingtubeshape[i][0]->GetDz());
3449   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3450   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3451                                                                           fSSDAir);
3452   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3453                                                                           fSSDAir);
3454   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3455                                                                           fSSDAir);
3456   // End Ladder Cooling Tubes
3457   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3458   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3459   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3460                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3461                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3462   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3463   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3464                                                                           endladdervirtualcoolingtubeshape[0],
3465                                                                           fSSDAir);
3466   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3467                                                                           endladdervirtualcoolingtubeshape[1],
3468                                                                           fSSDAir);
3469   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3470                                                                           endladdervirtualcoolingtubeshape[2],
3471                                                                           fSSDAir);
3472   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3473                                                                           endladdervirtualcoolingtubeshape[3],
3474                                                                           fSSDAir);
3475   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3476                                                                           endladdervirtualcoolingtubeshape[4],
3477                                                                           fSSDAir);
3478   TList* coolingtubelist = new TList();
3479   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3480         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3481         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3482     coolingtubelist->Add(virtualcoolingtube[i]);
3483   }
3484         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3485         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3486     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3487         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3488         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3489     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3490         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3491         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3492     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3493         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3494         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3495     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3496         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3497         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3498     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3499   return coolingtubelist;
3500 }
3501 ///////////////////////////////////////////////////////////////////////////////
3502 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3503   /////////////////////////////////////////////////////////////
3504   // Method generating SSD Cooling Block    
3505   /////////////////////////////////////////////////////////////
3506   const Int_t kvertexnumber = 8;
3507   ///////////////////////////////////////
3508   // Vertex Positioning for TGeoXTru
3509   ///////////////////////////////////////
3510   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3511   vertexposition[0] = new TVector3(0.0,0.0);
3512   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3513   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3514                                           vertexposition[1]->Y());
3515   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3516                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3517   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3518   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3519                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3520   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3521                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3522                                         - fgkSSDCoolingBlockHoleLength[0]
3523                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3524                                           fgkSSDCoolingBlockHeight[0]
3525                                         - fgkSSDCoolingBlockHoleRadius[1],
3526                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3527   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3528                                         - fgkSSDCoolingBlockHoleLength[0]),
3529                                           vertexposition[6]->Y());
3530   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3531                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3532   Double_t phi = 180.-alpha;
3533   Double_t psi = 180.+2.*alpha;
3534   Double_t deltapsi = psi/nedges;
3535   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3536   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3537                                                   fgkSSDCoolingBlockHoleCenter);
3538   for(Int_t i=0; i<nedges+1; i++){
3539         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3540                                                                                                radius*SinD(phi+i*deltapsi));
3541    *vertexposition[kvertexnumber+i] += (*transvector);
3542   }
3543   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3544   for(Int_t i=0; i<kvertexnumber; i++)
3545     vertexposition[kvertexnumber+nedges+1+i] = 
3546                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3547   ///////////////////////////////////////////////////////////////////////
3548   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3549   ///////////////////////////////////////////////////////////////////////
3550   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3551   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3552   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3553   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3554         xvertexpoints[i] = vertexposition[i]->X();
3555         yvertexpoints[i] = vertexposition[i]->Y();
3556   } 
3557   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3558                                                                                         yvertexpoints);
3559   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3560   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3561   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3562                                                                           ssdcoolingblockshape,
3563                                                                                   fSSDAlCoolBlockMedium);
3564   ssdcoolingblock->SetLineColor(fColorAl);
3565   /////////////////////////////////////////////////////////////
3566   // Deallocating memory
3567   /////////////////////////////////////////////////////////////
3568   delete [] vertexposition;
3569   delete xvertexpoints;
3570   delete yvertexpoints;
3571   /////////////////////////////////////////////////////////////
3572   return ssdcoolingblock;
3573 }
3574 /////////////////////////////////////////////////////////////////////////////////
3575 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3576   ///////////////////////////////////////////////////////
3577   const Int_t kssdchipcablesnumber    = 2;
3578   const Int_t kssdchipcableslaynumber = 2;
3579   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3580   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3581   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3582   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3583                                                  -  fgkSSDChipCablesHeight[0]
3584                                                  -  fgkSSDChipCablesHeight[1]);
3585   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3586   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3587   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3588                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3589                                                           - ssdchipcablesradius[0]
3590                                                           - fgkSSDChipCablesWidth[1]
3591                                                           - fgkSSDChipCablesWidth[2]);
3592   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3593                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3594                                                           +      fgkSSDChipCablesHeight[1]
3595                                                           +      fgkSSDSensorHeight);
3596   ///////////////////////////////////////////////////////
3597   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3598   ///////////////////////////////////////////////////////
3599   TVector3** vertexposition[kssdchipcableslaynumber];
3600   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3601                                                                                                   new TVector3*[4*(nedges+1)+4];
3602   Double_t ratio[4];
3603   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3604   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3605                    /  ssdchipcablesradius[0]; 
3606   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3607                    /  ssdchipcablesradius[0];
3608   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3609                    +  fgkSSDChipCablesHeight[1])
3610                    /  ssdchipcablesradius[0];
3611   Double_t phi = 180.;
3612   Double_t deltaphi = 180./nedges;
3613   Double_t angle = 0.0;
3614   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3615   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3616   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3617         xvertexpoints[i] = new Double_t[kvertexnumber];
3618         yvertexpoints[i] = new Double_t[kvertexnumber];
3619   }  
3620   TVector3* vertex = new TVector3();
3621   TVector3* transvector[kssdchipcableslaynumber];
3622   transvector[0] = new TVector3(fgkSSDChipWidth,
3623                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3624   transvector[1] = new TVector3();
3625   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3626   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3627   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3628                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3629                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3630   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3631         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3632         transvector[1]->SetY(ssdchipcablesradius[0]
3633                                  +               fgkSSDChipCablesHeight[0]
3634                                  +               fgkSSDChipCablesHeight[1]);  
3635         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3636                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3637                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3638                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3639                                                          - i*fgkSSDChipCablesHeight[0]);
3640                 vertexposition[i][2*(nedges+1)+2] = 
3641                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3642                                 +                                fgkSSDChipCablesWidth[1]
3643                                 +                                fgkSSDChipCablesWidth[2],
3644                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3645                                 +                                fgkSSDChipCablesHeight[1]));
3646         vertexposition[i][2*(nedges+1)+3] = 
3647                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3648                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3649                                 -                                fgkSSDChipCablesHeight[i]);
3650             for(Int_t j=0; j<nedges+1; j++){            
3651                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3652                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3653                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3654                         vertexposition[0][(nedges+1)*i+j+2] = 
3655                                                 new TVector3(*vertex+*transvector[i]);
3656                         vertexposition[1][(nedges+1)*i+j+2] = 
3657                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3658                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3659                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3660                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3661                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3662                                                 new TVector3(vertex->X()*ratio[2*i+1]
3663                                                         +                        transvector[i]->X(),
3664                                                                                  vertex->Y()*ratio[2*i+1]
3665                                                         +                transvector[i]->Y());
3666                 }
3667         }
3668         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3669                 for(Int_t j=0; j<kvertexnumber; j++){   
3670                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3671                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3672                 }
3673                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3674                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3675                                                                                 xvertexpoints[i],yvertexpoints[i]);
3676                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3677                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3678                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3679                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3680                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3681                                                           (kssdchipcablesnumber*k+i)%2==0?
3682                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3683                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3684         }
3685         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3686                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3687   }
3688   /////////////////////////////////////////////////////////////
3689   // Mother Volume definition 
3690   /////////////////////////////////////////////////////////////
3691   Double_t ssdchipseparation = fgkSSDSensorLength
3692                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3693                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3694                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3695   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3696   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3697                                                           +fgkSSDChipCablesWidth[1]
3698                                                           +fgkSSDChipCablesWidth[2]);
3699   Double_t dy = fgkSSDChipCablesLength[1];
3700   Double_t dz = SSDChipCablesHeigth;
3701   new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3702   TGeoVolumeAssembly* ssdchipcablesmother = new TGeoVolumeAssembly("SSDChipCablesMother");
3703 //  TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3704 //                        ssdchipcablesmotherbox,fSSDAir);
3705   /////////////////////////////////////////////////////////////
3706   // Rotation and Translation Definition for positioning 
3707   /////////////////////////////////////////////////////////////
3708   TGeoRotation* ssdchipcablesrot[5];
3709   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3710   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3711   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3712   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3713   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3714   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3715                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3716   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3717   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3718   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3719   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3720   /////////////////////////////////////////////////////////////
3721   // Deallocating memory
3722   /////////////////////////////////////////////////////////////
3723   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3724         delete [] xvertexpoints[i];
3725         delete [] yvertexpoints[i];
3726   }
3727   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3728   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3729   delete vertex; 
3730   delete ssdchipcablesrot[0];
3731   delete ssdchipcablesrot[1];
3732   delete ssdchipcablesrot[3];
3733   /////////////////////////////////////////////////////////////
3734   return ssdchipcablesmother;
3735 }
3736 ///////////////////////////////////////////////////////////////////////////////
3737 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3738   /////////////////////////////////////////////////////////////
3739   // SSD Chip Assembly
3740   /////////////////////////////////////////////////////////////
3741   TGeoVolume* ssdchipassembly = GetSSDChips();
3742   TList* ssdchipsystemlist = new TList();
3743 //  const Int_t knedges = 20;
3744   const Int_t knedges = 5;
3745   const Int_t kchipsystemnumber = 2;
3746   /////////////////////////////////////////////////////////////
3747   // Mother Volume containing SSDChipSystem
3748   /////////////////////////////////////////////////////////////
3749   TGeoXtru* chipsystemothershape[kchipsystemnumber];
3750   for(Int_t i=0; i<kchipsystemnumber; i++) chipsystemothershape[i] = new TGeoXtru(2);
3751   const Int_t kmothervertexnumber = 12;  
3752   Double_t xmothervertex[kchipsystemnumber][kmothervertexnumber];
3753   Double_t ymothervertex[kchipsystemnumber][kmothervertexnumber];
3754   Double_t ssdchipcablesradius[kchipsystemnumber];
3755   Double_t ssdchipseparation = fgkSSDSensorLength
3756                              - 2.*fgkSSDModuleStiffenerPosition[1]
3757                              - 2.*(fgkSSDStiffenerWidth
3758                              - fgkSSDStiffenerToChipDist-0.5*fgkSSDChipWidth);
3759   for(Int_t i=0; i<kchipsystemnumber; i++)
3760         ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
3761                                                    -  fgkSSDChipCablesHeight[0]
3762                                                    -  fgkSSDChipCablesHeight[1]);
3763   ///////////////////////
3764   // Setting the vertices 
3765   ///////////////////////
3766   xmothervertex[0][0]  = -0.5*fgkSSDChipCablesLength[1];  
3767   xmothervertex[0][1]  = xmothervertex[0][0];  
3768   xmothervertex[0][2]  = (fgkSSDChipNumber-1)*(fgkSSDChipLength
3769                                            + fgkSSDChipSeparationLength)+0.5*fgkSSDChipCablesLength[1];  
3770   xmothervertex[0][3]  = xmothervertex[0][2];  
3771   xmothervertex[0][4]  = 0.5*fgkSSDChipCablesLength[1];  
3772   xmothervertex[0][5]  = xmothervertex[0][4];  
3773   xmothervertex[0][6]  = xmothervertex[0][2]-0.5*fgkSSDChipCablesLength[1];  
3774   xmothervertex[0][7]  = xmothervertex[0][6]; 
3775   xmothervertex[0][8]  = 0.0;  
3776   xmothervertex[0][9]  = xmothervertex[0][8];  
3777   xmothervertex[0][10] = xmothervertex[0][4];  
3778   xmothervertex[0][11] = xmothervertex[0][10];  
3779   for(Int_t i=0; i<kmothervertexnumber; i++) 
3780         xmothervertex[1][i] = xmothervertex[0][i]; 
3781   for(Int_t i=0; i<kchipsystemnumber; i++){
3782         ymothervertex[i][0]  = -0.5*fgkSSDChipWidth-ssdchipcablesradius[i]
3783                                                  - fgkSSDChipCablesWidth[1]-fgkSSDChipCablesWidth[2];
3784         ymothervertex[i][1]  = ssdchipseparation-ymothervertex[i][0];
3785         ymothervertex[i][2]  = ymothervertex[i][1];
3786         ymothervertex[i][3]  = ymothervertex[i][0];
3787         ymothervertex[i][4]  = ymothervertex[i][0];
3788         ymothervertex[i][5]  = 0.5*fgkSSDChipWidth;
3789         ymothervertex[i][6]  = ymothervertex[i][5];
3790         ymothervertex[i][7]  = ssdchipseparation-0.5*fgkSSDChipWidth;
3791         ymothervertex[i][8]  = ymothervertex[i][7];
3792         ymothervertex[i][9]  = ymothervertex[i][5];
3793         ymothervertex[i][10] = ymothervertex[i][5];
3794         ymothervertex[i][11] = ymothervertex[i][4];
3795   }
3796   //////////////////////////////////////////////////////////
3797 //  TGeoVolume* chipsystemother[kchipsystemnumber];
3798   TGeoVolumeAssembly* chipsystemother[kchipsystemnumber];
3799   const char* chipsytemothername[kchipsystemnumber] = 
3800                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3801   for(Int_t i=0; i<kchipsystemnumber; i++){
3802     chipsystemothershape[i]->DefinePolygon(kmothervertexnumber,
3803                                                                         xmothervertex[i],ymothervertex[i]);
3804     chipsystemothershape[i]->DefineSection(0,-fgkSSDChipCablesHeight[i+2]
3805                                                                                   -0.5*fgkSSDChipHeight);
3806     chipsystemothershape[i]->DefineSection(1,0.5*fgkSSDChipHeight);
3807 //    chipsystemother[i] = new TGeoVolume(chipsytemothername[i],
3808 //                                                        chipsystemothershape[i],fSSDAir);
3809     chipsystemother[i] = new TGeoVolumeAssembly(chipsytemothername[i]);
3810   }
3811   /////////////////////////////////////////////////////////////
3812   // SSD Chip Cables
3813   /////////////////////////////////////////////////////////////
3814   TGeoVolume* ssdchipcables[kchipsystemnumber];
3815   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3816   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3817   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3818   //////////////////
3819   for(Int_t i=0; i<kchipsystemnumber; i++){
3820                 ssdchipcables[i] = 
3821                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3822                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3823                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3824                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3825   }
3826   for(Int_t i=0; i<kchipsystemnumber; i++){
3827         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3828                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3829                 ssdchipcablesrot[i][j] = new TGeoRotation();
3830                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3831                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3832                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3833                                                   +                fgkSSDChipSeparationLength),
3834                                                                                         0.5*fgkSSDChipWidth,
3835                                                   -                                     0.5*fgkSSDChipHeight
3836                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3837                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3838                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3839                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3840         }
3841         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3842         ssdchipsystemlist->Add(chipsystemother[i]);     
3843   }
3844   /////////////////////////////////////////////////////////////
3845   // Deallocating memory
3846   /////////////////////////////////////////////////////////////
3847   for(Int_t i=0; i<kchipsystemnumber; i++){
3848         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3849                 delete ssdchipcablesrot[i][j];
3850                 delete ssdchipcablestrans[i][j];
3851         }
3852         delete ssdchipcablesrot[i];
3853         delete ssdchipcablestrans[i];
3854   }
3855   /////////////////////////////////////////////////////////////
3856   return ssdchipsystemlist;
3857 }
3858 ///////////////////////////////////////////////////////////////////////////////
3859 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3860   /////////////////////////////////////////////////////////////
3861   // SSD Chip Assembly Generation    
3862   /////////////////////////////////////////////////////////////
3863   const Int_t kssdchiprownumber = 2;
3864   TGeoBBox* ssdchipcompshape[2];
3865   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3866                                                                                 0.5*fgkSSDChipLength,
3867                                                                                 0.5*fgkSSDChipWidth,
3868                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3869   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3870                                                                                 0.5*fgkSSDChipLength,
3871                                                                                 0.5*fgkSSDChipWidth,
3872                                                                                 0.5*fgkSSDChipGlueHeight);
3873   TGeoVolume* ssdchipcomp[2];
3874   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3875   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3876                                                                   fSSDChipGlueMedium);
3877   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3878   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3879   TGeoTranslation* ssdchipcomptrans[2];
3880   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3881   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3882   /////////////////////////////////////////////////////////////
3883   // Virtual Volume containing SSDChip   
3884   /////////////////////////////////////////////////////////////
3885   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3886                                                                                                                  0.5*fgkSSDChipWidth,
3887                                                                                                                  0.5*fgkSSDChipHeight);
3888   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3889   /////////////////////////////////////////////////////////////
3890   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3891   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3892                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3893                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3894                                    -  0.5*fgkSSDChipWidth)};
3895   /////////////////////////////////////////////////////////////
3896   // Virtual Volume containing SSDChipAssembly   
3897   /////////////////////////////////////////////////////////////
3898   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3899   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3900   Double_t xmothervertex[kssdmothervertexnumber];
3901   Double_t ymothervertex[kssdmothervertexnumber];
3902   ///////////////////////
3903   // Setting the vertices 
3904   ///////////////////////
3905   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3906   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3907                                    - ymothervertex[0];
3908   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3909   ymothervertex[2] = ymothervertex[1];
3910   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3911   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3912   ymothervertex[4] = ymothervertex[0];
3913   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3914   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3915                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3916   ymothervertex[6] = ymothervertex[5];
3917   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3918                                    - fgkSSDChipWidth;
3919   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3920   ymothervertex[8] = ymothervertex[7];
3921   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3922   ymothervertex[9] = ymothervertex[6];
3923   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3924   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3925   //////////////////////////////////////////////////////////
3926   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3927                                                                         xmothervertex,ymothervertex);
3928   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3929   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3930 //  TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3931 //                                                        ssdchipmothershape,fSSDAir);
3932   TGeoVolumeAssembly* ssdchipmother = new TGeoVolumeAssembly("SSDChipContainer");
3933    /////////////////////////////////////////////////////////////
3934   for(Int_t i=0; i<kssdchiprownumber; i++)
3935     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3936                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3937                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3938   return ssdchipmother;
3939 }
3940 /////////////////////////////////////////////////////////////////////////////////
3941 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3942   /////////////////////////////////////////////////////////////
3943   // Method returning a List containing pointers to Ladder Cable Volumes    
3944   /////////////////////////////////////////////////////////////
3945   const Int_t kladdercablesegmentnumber = 2;
3946   /////////////////////////////////////////
3947   // LadderSegmentBBox Volume
3948   /////////////////////////////////////////
3949   TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber];
3950   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3951                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3952   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3953                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3954                                                                            0.5*fgkSSDFlexWidth[0],
3955                                                                            0.5*fgkSSDLadderCableWidth,
3956                                                                            0.5*fgkSSDFlexHeight[i]); 
3957   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3958                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3959   TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3960   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3961                         laddercablesegmentbbox[i] =
3962                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3963                                                                                  laddercablesegmentbboxshape[i],
3964                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3965             fSSDKaptonLadderCableMedium));
3966                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3967                                                                                                                    fColorPolyhamide);
3968   }
3969   TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber];                                                                                
3970   laddercablesegmentbboxtrans[0] = 
3971                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3972                                                                                            0.5*fgkSSDFlexWidth[0],
3973                                                                                            0.5*fgkSSDLadderCableWidth,
3974                                                                                            0.5*fgkSSDFlexHeight[0]);
3975   laddercablesegmentbboxtrans[1] = 
3976                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3977                                                                                            0.5*fgkSSDFlexWidth[0],
3978                                                                                            0.5*fgkSSDLadderCableWidth,
3979                                                                                            fgkSSDFlexHeight[0]
3980                                                                                            +0.5*fgkSSDFlexHeight[1]);
3981   TGeoVolume* laddercablesegmentbboxassembly = 
3982                                                    new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly"); 
3983   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3984                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3985                                                                                             laddercablesegmentbboxtrans[i]);
3986 /////////////////////////////////////////
3987 // LadderSegmentArb8 Volume
3988 /////////////////////////////////////////
3989   const Int_t kvertexnumber = 4;
3990   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3991   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3992                                                                                                   new TVector3*[kvertexnumber];
3993 //Shape Vertex Positioning
3994   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3995         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3996         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3997                                                                                                                   i*fgkSSDFlexHeight[0]);
3998         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3999                                                                                    +                         fgkSSDFlexHeight[1]
4000                                                                                    +                      i*fgkSSDFlexHeight[0]);
4001         laddercablesegmentvertexposition[i][3] = 
4002                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
4003                                                                                 laddercablesegmentvertexposition[i][2]->Y());
4004   }
4005   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
4006                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
4007   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
4008                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
4009   TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
4010   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
4011                                         GetArbShape(laddercablesegmentvertexposition[i],
4012                                                                 laddercablesegmentwidth[i],
4013                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
4014                                                                 laddercablesegmentarbshapename[i]);
4015   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
4016                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
4017   TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
4018   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4019                          laddercablesegmentarb[i] =
4020                                                    new TGeoVolume(laddercablesegmentarbname[i],
4021                                                                                   laddercablesegmentarbshape[i],
4022                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
4023             fSSDKaptonLadderCableMedium)); 
4024                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
4025                                                                                                                    fColorPolyhamide);
4026 }
4027   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
4028   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
4029                                                                                                  90.,90,-90.);   
4030   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
4031                                                                                                   0.,90.,0.);    
4032   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
4033                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
4034                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
4035                                                          + fgkSSDFlexWidth[0],0.,0.,
4036                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
4037                                                      *(*laddercablesegmentarbrot[0])));
4038   TGeoVolume* laddercablesegmentarbassembly = 
4039                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
4040   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
4041   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
4042                                                                                    laddercablesegmentarbcombitrans);
4043 /////////////////////////////////////////
4044 // End Ladder Cable Volume
4045 /////////////////////////////////////////
4046   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4047   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4048                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4049   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4050                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4051                                                                            0.5*ssdendladdercablelength,
4052                                                                            0.5*fgkSSDLadderCableWidth,
4053                                                                            0.5*fgkSSDFlexHeight[i]);
4054   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4055                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4056   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4057   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4058                         ladderendcablesegmentbbox[i] =
4059                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4060                                                                                  ladderendcablesegmentbboxshape[i],
4061                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4062             fSSDKaptonLadderCableMedium));
4063                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4064                                                                                                                    fColorPolyhamide);
4065   }
4066   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4067   ladderendcablesegmentbboxtrans[0] = 
4068                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4069                                                                                            0.5*ssdendladdercablelength,
4070                                                                                            0.5*fgkSSDLadderCableWidth,
4071                                                                                            0.5*fgkSSDFlexHeight[0]);
4072   ladderendcablesegmentbboxtrans[1] = 
4073                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4074                                                                                            0.5*ssdendladdercablelength,
4075                                                                                            0.5*fgkSSDLadderCableWidth,
4076                                                                                            fgkSSDFlexHeight[0]
4077                                                                                            +0.5*fgkSSDFlexHeight[1]);
4078   TGeoVolume* ladderendcablesegmentbboxassembly = 
4079                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4080   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4081                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4082                                                                                             ladderendcablesegmentbboxtrans[i]);
4083 /////////////////////////////////////////
4084   TList* laddercablesegmentlist = new TList();
4085   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4086   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4087   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4088   return laddercablesegmentlist;
4089   }
4090 /////////////////////////////////////////////////////////////////////////////////
4091 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4092   /////////////////////////////////////////////////////////////
4093   // Method generating Ladder Cable Volumes Assemblies    
4094   /////////////////////////////////////////////////////////////
4095   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4096   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4097   for(Int_t i=0; i<n; i++){
4098          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4099                                                         i*(fgkCarbonFiberJunctionWidth),
4100                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4101                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4102     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4103         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4104   }
4105   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4106                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4107                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4108                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4109   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4110   return laddercable;
4111 }
4112 /////////////////////////////////////////////////////////////////////////////////
4113 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4114   /////////////////////////////////////////////////////////////
4115   // Method generating Ladder Cable Volumes Assembly   
4116   /////////////////////////////////////////////////////////////
4117   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4118   char laddercabletransname[100];
4119   for(Int_t i=0; i<n; i++){ 
4120         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4121     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4122         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4123   }
4124   return laddercableassembly;
4125 }
4126 /////////////////////////////////////////////////////////////////////////////////
4127 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4128   /////////////////////////////////////////////////////////////
4129   // Method generating Ladder Cable List Assemblies  
4130   /////////////////////////////////////////////////////////////  
4131   const Int_t kladdercableassemblynumber = 2;
4132   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4133   TGeoVolume* ladderCable[kladdercableassemblynumber];
4134   char laddercableassemblyname[100];
4135   TList* laddercableassemblylist = new TList();
4136   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4137         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4138         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4139         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4140                                          new TGeoCombiTrans((n-1)
4141                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4142                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4143                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4144         laddercableassemblylist->Add(ladderCable[i]);
4145 }
4146   return laddercableassemblylist;
4147 }
4148 ///////////////////////////////////////////////////////////////////////////////
4149 void AliITSv11GeometrySSD::SetLadderSegment(){
4150   /////////////////////////////////////////////////////////////
4151   // Method Generating Ladder Segment Array
4152   /////////////////////////////////////////////////////////////
4153   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4154   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4155   if(!fCreateMaterials) CreateMaterials();
4156   if(!fTransformationMatrices) CreateTransformationMatrices();
4157   if(!fBasicObjects) CreateBasicObjects();
4158   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4159   // Placing Carbon Fiber Support       
4160         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4161                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4162                                                                                         fcarbonfibersupportmatrix[j]);  
4163                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4164                                                                                         fcarbonfibersupportmatrix[j]);
4165   }
4166   // Placing Carbon Fiber Junction
4167     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4168         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4169                                                                    fcarbonfiberjunctionmatrix[j]);
4170   // Placing Carbon Fiber Lower Support
4171         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4172                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4173                                                            fcarbonfiberlowersupportrans[j]);    
4174   // Placing SSD Sensor Support
4175     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4176         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4177                                                                      fssdsensorsupport[1][i],
4178                                                            j+1,fssdsensorsupportmatrix[j]);
4179   // Placing SSD Cooling Tube Support 
4180         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4181                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4182                                                                    fcoolingtubesupportmatrix[j]);
4183   // Placing SSD Cooling Tube  
4184         for(Int_t j=0; j<2; j++)
4185                 for(Int_t k=0; k<2; k++){
4186                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4187                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4188                 }
4189   // Placing SSD Hybrid
4190     switch(i){
4191         case 0: 
4192                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4193                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4194                 break;
4195     case 1:
4196                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4197                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4198                 break;
4199         }
4200         // Placing Cooling Block System
4201     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4202         // Placing SSD Flex
4203         for(Int_t j=0; j<fgkflexnumber; j++){
4204       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4205       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4206         }
4207    }
4208 }
4209 ///////////////////////////////////////////////////////////////////////////////
4210 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4211   /////////////////////////////////////////////////////////////
4212   // Method Generating End Ladder
4213   /////////////////////////////////////////////////////////////
4214   // End Ladder Carbon Fiber Junction 
4215   /////////////////////////////////////////////////////////////
4216   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4217   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4218   if(!fCreateMaterials) CreateMaterials();
4219   if(!fTransformationMatrices) CreateTransformationMatrices();
4220   if(!fBasicObjects) CreateBasicObjects();
4221   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4222         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4223                 fendladdersegment[i]->AddNode(j==2 ? 
4224                                                         fendladdercarbonfiberjunction[i][1] : 
4225                                                         fendladdercarbonfiberjunction[i][0],
4226                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4227   }
4228   /////////////////////////////////////////////////////////////
4229   // End Ladder Carbon Fiber Support 
4230   /////////////////////////////////////////////////////////////
4231   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4232       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4233                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4234                   fendladdercarbonfibermatrix[i][j]);   
4235           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4236                   fendladdercarbonfibermatrix[i][j]);   
4237       }
4238   /////////////////////////////////////////////////////////////
4239   // End Ladder Mounting Block
4240   /////////////////////////////////////////////////////////////
4241   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4242        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4243                                      fendladdermountingblockcombitrans[i]);
4244   /////////////////////////////////////////////////////////////
4245   // End Ladder Mounting Block Clip
4246   /////////////////////////////////////////////////////////////
4247   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4248         for(Int_t j=0; j<2; j++)
4249                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4250                                               fendladdermountingblockclipmatrix[i][j]);
4251   /////////////////////////////////////////////////////////////
4252   // End Ladder Lower Supports
4253   /////////////////////////////////////////////////////////////
4254   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4255                                 fendladderlowersupptrans[0]);
4256   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4257                                 fendladderlowersupptrans[1]);
4258   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4259                                 fendladderlowersupptrans[2]);
4260   /////////////////////////////////////////////////////////////
4261   // End Ladder Cooling Tube Support
4262   /////////////////////////////////////////////////////////////
4263   for(Int_t i=0; i<2; i++) 
4264         for(Int_t j=0; j<(i==0?4:2); j++)   
4265                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4266                                               fendladdercoolingtubesupportmatrix[i][j]);
4267   /////////////////////////////////////////////////////////////
4268   // End Ladder Cooling Tube Support
4269   /////////////////////////////////////////////////////////////
4270 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                          
4271 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                          
4272   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4273   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4274   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4275   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4276   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4277   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4278   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4279   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                            
4280 }
4281 ///////////////////////////////////////////////////////////////////////////////
4282 void AliITSv11GeometrySSD::SetLadder(){
4283   /////////////////////////////////////////////////////////////
4284   // Method Generating Ladder of Layer 5 and 6
4285   /////////////////////////////////////////////////////////////  
4286   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4287                                                                                                 fgkSSDLay6SensorsNumber};
4288   /////////////////////////////////////////////////////////////////////////////                                         
4289   /// Generating Ladder Mother Volume Containing Ladder 
4290   /////////////////////////////////////////////////////////////////////////////          
4291   TGeoXtru* laddershape[fgkladdernumber];       
4292   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4293   const Int_t kmothervertexnumber = 8;  
4294   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4295   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4296   ///////////////////////
4297   // Setting the vertices 
4298   ///////////////////////
4299   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4300                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4301   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4302   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
4303   xmothervertex[0][1] = xmothervertex[0][0];
4304   ymothervertex[0][1] = 0.0;
4305   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4306                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4307   ymothervertex[0][2] = ymothervertex[0][1];
4308   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4309   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4310   xmothervertex[0][4] = -xmothervertex[0][3];
4311   ymothervertex[0][4] = ymothervertex[0][3];
4312   xmothervertex[0][5] = -xmothervertex[0][2];
4313   ymothervertex[0][5] = ymothervertex[0][2];
4314   xmothervertex[0][6] = -xmothervertex[0][1];
4315   ymothervertex[0][6] = ymothervertex[0][1];
4316   xmothervertex[0][7] = -xmothervertex[0][0];
4317   ymothervertex[0][7] = ymothervertex[0][0];
4318   for(Int_t i=0; i<kmothervertexnumber; i++){
4319         xmothervertex[1][i] = xmothervertex[0][i];
4320         ymothervertex[1][i] = ymothervertex[0][i];
4321   }
4322 ///////////////////////////////////////////////////////////////////////////
4323 // Disalignement Mother Volume corrections 25/08/08
4324 ///////////////////////////////////////////////////////////////////////////
4325   TGeoXtru* leftladdershape[fgkladdernumber];   
4326   TGeoXtru* centersensorladdershape[fgkladdernumber];   
4327   TGeoXtru* rightladdershape[fgkladdernumber];  
4328   for(Int_t i=0; i<fgkladdernumber; i++){
4329    leftladdershape[i] = new TGeoXtru(2);
4330    centersensorladdershape[i] = new TGeoXtru(2);
4331    rightladdershape[i] = new TGeoXtru(2);
4332    }
4333   //////////////////////////////////////
4334    // Setting the names for shapes  
4335   //////////////////////////////////////
4336   leftladdershape[0]->SetName("Lay5LeftLadderSegmentContainer");
4337   leftladdershape[1]->SetName("Lay6LeftLadderSegmentContainer");
4338   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
4339   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
4340   rightladdershape[0]->SetName("Lay5RightLadderSegmentContainer");
4341   rightladdershape[1]->SetName("Lay6RightLadderSegmentContainer");
4342   //////////////////////////////////////
4343   Double_t xleftladdervertex[fgkladdernumber][kmothervertexnumber];
4344   Double_t yleftladdervertex[fgkladdernumber][kmothervertexnumber];
4345   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
4346   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
4347   Double_t xrightladdervertex[fgkladdernumber][kmothervertexnumber];
4348   Double_t yrightladdervertex[fgkladdernumber][kmothervertexnumber];
4349   for(Int_t i=0; i<fgkladdernumber; i++)
4350         for(Int_t j=0; j<kmothervertexnumber; j++){
4351                 xleftladdervertex[i][j] = xmothervertex[i][j];
4352                 yleftladdervertex[i][j] = ymothervertex[i][j];
4353                 xcentersensorvertex[i][j] = xmothervertex[i][j];
4354                 ycentersensorvertex[i][j] = ymothervertex[i][j];
4355                 xrightladdervertex[i][j] = xmothervertex[i][j];
4356                 yrightladdervertex[i][j] = ymothervertex[i][j];
4357         }
4358         xcentersensorvertex[0][0] -= fgkSSDModuleSideDisalignment;      
4359         xcentersensorvertex[0][1] =  xcentersensorvertex[0][0];
4360         xcentersensorvertex[0][6] = -xcentersensorvertex[0][1];
4361         xcentersensorvertex[0][7] = -xcentersensorvertex[0][0];
4362
4363         xcentersensorvertex[1][0] = xcentersensorvertex[0][0];  
4364         xcentersensorvertex[1][1] = xcentersensorvertex[0][1];
4365         xcentersensorvertex[1][6] = xcentersensorvertex[0][6];
4366         xcentersensorvertex[1][7] = xcentersensorvertex[0][7];
4367
4368         ycentersensorvertex[0][0] -= fgkSSDModuleVerticalDisalignment;  
4369         ycentersensorvertex[0][7] = ycentersensorvertex[0][0];
4370
4371         ycentersensorvertex[1][0] = ycentersensorvertex[0][0];  
4372         ycentersensorvertex[1][7] = ycentersensorvertex[0][7];
4373         for(Int_t i=0; i<fgkladdernumber; i++){
4374                 // Left Ladder Piece
4375                 leftladdershape[i]->DefinePolygon(kmothervertexnumber,xleftladdervertex[i],
4376                                                                                   yleftladdervertex[i]);
4377                 leftladdershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4378                 leftladdershape[i]->DefineSection(1,-fgkEndLadderCarbonFiberLowerJunctionLength[1]
4379                                                                                         +1.45*fgkSSDMountingBlockWidth);
4380                 // Center Ladder Piece
4381                 centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
4382                                                                           ycentersensorvertex[i]);
4383                 centersensorladdershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]
4384                                                                                                         + 1.45*fgkSSDMountingBlockWidth);
4385                 centersensorladdershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4386                                                                                         +               fgkEndLadderCarbonFiberLowerJunctionLength[0]
4387                                                                                         -               2.4*fgkSSDMountingBlockWidth);
4388                 // Right Ladder Piece
4389                 rightladdershape[i]->DefinePolygon(kmothervertexnumber,xrightladdervertex[i],
4390                                                                                   yrightladdervertex[i]);
4391                 rightladdershape[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4392                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4393                                                                                         -2.4*fgkSSDMountingBlockWidth);
4394                 rightladdershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4395                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4396         }
4397         TGeoCompositeShape* laddershapecontainer[2];
4398         laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4399                                                           "Lay5LeftLadderSegmentContainer+Lay5CenterSensorContainer+Lay5RightLadderSegmentContainer");
4400         laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4401                                                           "Lay6LeftLadderSegmentContainer+Lay6CenterSensorContainer+Lay6RightLadderSegmentContainer");
4402         const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4403     for(Int_t i=0; i<fgkladdernumber; i++){
4404                 fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4405                 fladder[i]->SetLineColor(4);
4406         }
4407 ///////////////////////////////////////////////////////////////////////////
4408  if(!fCreateMaterials) CreateMaterials();
4409  if(!fTransformationMatrices) CreateTransformationMatrices();
4410  if(!fBasicObjects) CreateBasicObjects();
4411  SetLadderSegment(); 
4412  SetEndLadderSegment();
4413   for(Int_t i=0; i<fgkladdernumber; i++){
4414         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4415         //////////////////////////                                              
4416         /// Placing Ladder Segment
4417         //////////////////////////              
4418                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4419                                                                      fladdersegment[i==0 ? 1 : 0],
4420                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4421         //////////////////////////                                              
4422         /// Placing SSD Sensor
4423         //////////////////////////              
4424         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4425                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4426                                                         fssdsensormatrix[i][j]);
4427         }
4428         ///////////////////////////////                                         
4429         /// Placing End Ladder Segment
4430         ///////////////////////////////         
4431     fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4432         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4433    }
4434 /////////////////////////////////////////////////////////////////////////////                                           
4435 /// Placing Ladder Cables
4436 /////////////////////////////////////////////////////////////////////////////           
4437   Int_t sidecablenumber[2][2];
4438   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4439   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4440   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4441   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4442   Double_t carbonfibertomoduleposition[3];
4443   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4444   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4445                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4446          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4447          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4448          -            fgkSSDSensorCenterSupportThickness[0]);
4449   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4450                                                                  +   0.5*fgkCoolingTubeSupportHeight
4451          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4452   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4453   Double_t ssdendladdercablelength[4];
4454   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4455                                                          + fgkSSDSensorLength
4456                                                          - fgkSSDModuleStiffenerPosition[1]
4457                                                          - fgkSSDStiffenerWidth 
4458                                                          - fgkSSDFlexWidth[0]
4459                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4460   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4461                                                          + fgkSSDModuleStiffenerPosition[1]
4462                                                          + fgkSSDStiffenerWidth
4463                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4464   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4465                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4466                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4467                                                          - kendladdercablecorrection;
4468   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4469                                                          + carbonfibertomoduleposition[1]
4470                                                          - fgkSSDModuleStiffenerPosition[1]
4471                                                          - fgkSSDStiffenerWidth)
4472                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4473   TList* laddercableassemblylist[4];
4474   const Int_t kendladdercablesnumber = 4;
4475   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4476         for(Int_t j=0; j<kendladdercablesnumber; j++){
4477                 laddercableassemblylist[j] = 
4478                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4479                                                                    ssdendladdercablelength[j]);
4480                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4481                                                                         j<2?1:2,fladdercablematrix[i][j]);
4482   }
4483 }
4484 ////////////////////////////////////////////////////////////////////////////////
4485 void AliITSv11GeometrySSD::SetLayer(){
4486 ////////////////////////////////////////////////////////////////////////////////
4487   // Creating Ladder of Layer 5 and Layer 6
4488   /////////////////////////////////////////////////////////////
4489   if(!fCreateMaterials) CreateMaterials();
4490   if(!fTransformationMatrices) CreateTransformationMatrices();
4491   if(!fBasicObjects) CreateBasicObjects();
4492   SetLadder(); // Generating the ladder of Layer5 and Layer6
4493   const Int_t kssdlayladdernumber[fgklayernumber] = 
4494                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4495   /////////////////////////////////////////////////////////////
4496   // Generating mother volumes for Layer5 and Layer6
4497   /////////////////////////////////////////////////////////////
4498   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4499   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4500   Int_t *ladderindex[fgklayernumber];
4501   Int_t index[fgklayernumber] = {8,9};
4502   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4503   for(Int_t i=0; i<fgklayernumber; i++) 
4504         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4505                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4506                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4507                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4508                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4509         }
4510   /////////////////////////////////////////////////////////////
4511   // Deallocating memory
4512   /////////////////////////////////////////////////////////////
4513   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4514 }
4515 ////////////////////////////////////////////////////////////////////////////////
4516 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4517   /////////////////////////////////////////////////////////////
4518   // Insert the layer 5 in the mother volume. 
4519   /////////////////////////////////////////////////////////////
4520   if (! moth) {
4521     printf("Error::AliITSv11GeometrySSD: Can't insert layer5, mother is null!\n");
4522     return;
4523   };
4524   if(!fSSDLayer5) SetLayer();
4525   fMotherVol = moth;
4526   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4527                                                                                 + fgkLay5CenterITSPosition);
4528   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4529  }
4530 ////////////////////////////////////////////////////////////////////////////////
4531 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4532   /////////////////////////////////////////////////////////////
4533   // Insert the layer 6 in the mother volume. 
4534   /////////////////////////////////////////////////////////////
4535   if (! moth) {
4536     printf("Error::AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4537     return;
4538   };
4539   if(!fSSDLayer6) SetLayer();
4540   fMotherVol = moth;
4541   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4542                                                                                 + fgkLay6CenterITSPosition);
4543   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4544  }
4545  ////////////////////////////////////////////////////////////////////////////////
4546  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4547   /////////////////////////////////////////////////////////////
4548   // Method generating the Arc structure of Ladder Support 
4549   /////////////////////////////////////////////////////////////
4550   const Int_t kssdlayladdernumber[fgklayernumber] = 
4551                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4552   Double_t mountingsupportedge[fgklayernumber];
4553   Double_t mountingblockratio[fgklayernumber];
4554   Double_t theta[fgklayernumber];
4555   Double_t phi[fgklayernumber];
4556   Double_t psi0[fgklayernumber];
4557   Double_t deltapsi[fgklayernumber];
4558   TVector3* mountingsupportedgevector[fgklayernumber];
4559   for(Int_t i=0; i<fgklayernumber; i++){
4560         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4561     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4562                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4563                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4564                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4565                                                           / kssdlayladdernumber[i])));
4566     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4567     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4568         mountingsupportedgevector[i] = new TVector3();
4569     mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4570         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(1.
4571                                                                  -TMath::Power(mountingsupportedgevector[i]->X()
4572                                                                  /                         fgkMountingBlockSupportRadius[i],2)));
4573     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4574     deltapsi[i] = (theta[i]+phi[i])/nedges;
4575   }
4576   TVector3** vertex[fgklayernumber];
4577   TList* vertexlist[fgklayernumber];
4578   Int_t indexedge[fgklayernumber] = {0,0};
4579   for(Int_t i=0; i<fgklayernumber; i++){
4580         vertex[i] = new TVector3*[nedges+1];
4581         vertexlist[i] = new TList();
4582   } 
4583   for(Int_t i=0; i<fgklayernumber; i++){
4584         for(Int_t j=0; j<nedges+1; j++){
4585                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4586                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4587                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4588                 vertexlist[i]->Add(vertex[i][j]);
4589         }
4590         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4591   }
4592   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4593   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4594   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4595   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4596   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4597   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4598   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4599   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4600   for(Int_t i=0; i<fgklayernumber; i++){
4601     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4602     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4603     xcentervertex[i] = new Double_t[indexedge[i]+3];
4604     ycentervertex[i] = new Double_t[indexedge[i]+3];
4605         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4606         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4607         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4608         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4609         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4610                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4611                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4612                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4613                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4614                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4615                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4616                 if(j<indexedge[i]+1){
4617                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4618                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4619                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4620                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4621                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4622                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4623                 }
4624         }
4625         xsidevertex[i][1] = xsidevertex[i][0]; 
4626         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4627         xsidevertex[i][2] = xsidevertex[i][3]; 
4628         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4629         xcentervertex[i][1] = xcentervertex[i][0]; 
4630         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4631         xcentervertex[i][2] = xcentervertex[i][3]; 
4632         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4633         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4634         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4635         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4636         ycenterlowervertex[i][0] = ysidevertex[i][0];
4637         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4638         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4639   }
4640   /////////////////////////////////////////////////////////////
4641   // Building the Arc Structure of Ladder Supports 
4642   /////////////////////////////////////////////////////////////
4643   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4644   TGeoXtru* centermountingsupportshape[fgklayernumber];
4645   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4646   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4647   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4648   TGeoVolume* centermountingblocksupport[fgklayernumber];
4649   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4650   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4651   char sidemountingblockname[100];
4652   char centermountingblockname[100];
4653   char sideladdersupportpiecename[100];
4654   char centerladdersupportpiecename[100];
4655   for(Int_t i=0; i<fgklayernumber; i++){ 
4656         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4657         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4658         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4659         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4660         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4661     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4662                                                                                                 xsidevertex[i],ysidevertex[i]);
4663     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4664                                                                                                          -fgkMountingBlockSupportWidth[0]);
4665     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4666     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4667                                                                           sidemountingblocksupportshape[i],
4668                                                                                   fSSDAlCoolBlockMedium);
4669         sidemountingblocksupport[i]->SetLineColor(9);
4670         centermountingsupportshape[i] = new TGeoXtru(2);
4671     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4672                                                                                                 xcentervertex[i],ycentervertex[i]);
4673         centermountingsupportshape[i]->DefineSection(0,0.);
4674     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4675                                                                                                   -fgkMountingBlockSupportWidth[0]);
4676     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4677                                                                           centermountingsupportshape[i],
4678                                                                                   fSSDAlCoolBlockMedium);
4679         centermountingblocksupport[i]->SetLineColor(9);
4680         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4681     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4682                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4683         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4684                                                                                                          -fgkMountingBlockSupportWidth[0]);
4685     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4686     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4687                                                                           sideladdersupportpieceshape[i],
4688                                                                                   fSSDCarbonFiberMedium);
4689         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4690         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4691     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4692                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4693         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4694     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4695                                                                                                   -fgkMountingBlockSupportWidth[0]);
4696     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4697                                                                           centerladdersupportpieceshape[i],
4698                                                                                   fSSDCarbonFiberMedium);
4699         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4700   }
4701   /////////////////////////////////////////////////////////////
4702   // Building the Up Structure of Ladder Supports 
4703   /////////////////////////////////////////////////////////////
4704   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4705   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4706   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4707   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4708   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4709   //////////////////////////////////////////////////////////
4710   // Setting the volume for TGeoXtru Mounting Block Piece  
4711   //////////////////////////////////////////////////////////
4712   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4713   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4714   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4715   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4716   TGeoVolume* mountingblockpieceup[fgklayernumber];
4717   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4718   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4719   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4720   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4721   char mountingblockpiecedownname[100];
4722   char mountingblockpieceupname[100];
4723   for(Int_t i=0; i<fgklayernumber; i++){
4724     ///////////////////////////
4725     // Mounting Block Down Vertex
4726     ///////////////////////////
4727         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4728     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4729         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4730         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4731                                                                                 + fgkMountingBlockSupportDownHeight;
4732         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4733         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4734                                                                                 + fgkSSDMountingBlockHeight[1]
4735                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4736                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4737         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4738         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4739         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4740         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4741         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4742         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4743         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4744         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4745                                                                                 + fgkSSDMountingBlockHeight[2]
4746                                                                                 - fgkSSDMountingBlockHeight[0];
4747         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4748         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4749         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4750         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4751         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4752                                                                                                          mountingblockpiecedownyvertex[i]);
4753         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4754         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4755         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4756                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4757         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4758     ///////////////////////////
4759     // Mounting Block Up Vertex
4760     ///////////////////////////
4761         mountingblockpieceupshape[i] = new TGeoXtru(2);
4762         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4763         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4764         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4765                                                                                 + fgkMountingBlockSupportUpHeight[i];
4766         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4767         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4768                                                                                 + fgkSSDMountingBlockHeight[1]
4769                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4770                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4771         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4772         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4773         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4774         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4775         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4776         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4777         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4778         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4779                                                                                 + fgkSSDMountingBlockHeight[2]
4780                                                                                 - fgkSSDMountingBlockHeight[0];
4781         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4782         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4783         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4784         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4785         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4786                                                                                                          mountingblockpieceupyvertex[i]);
4787         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4788         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4789         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4790                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4791         mountingblockpieceup[i]->SetLineColor(fColorG10);
4792  }
4793   ///////////////////////////////////////////////////////////////////
4794   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4795   ///////////////////////////////////////////////////////////////////
4796   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4797   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4798   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4799   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4800   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4801   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4802   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4803   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4804   char mountingblocksupportrapezoidowname[100];
4805   char mountingblocksupportrapezoidupname[100];
4806   Double_t scalefactor = 3./4.;
4807   for(Int_t i=0; i<fgklayernumber; i++){
4808   ////////////////////////////////////////////
4809   // Mounting Block Support Down Trapezoid Vertex 
4810   ////////////////////////////////////////////
4811         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4812         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4813                                                                                                  - mountingsupportedge[i];
4814         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4815         mountingblocksupportrapezoidownxvertex[i][1] = 
4816                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4817         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4818                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4819                                                                                              - mountingblockpiecedownyvertex[i][0]);
4820         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4821         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4822         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4823         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4824         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4825         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4826         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4827                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4828         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4829                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4830         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4831         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4832         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4833                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4834         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4835   ////////////////////////////////////////////
4836   // Mounting Block Support Up Trapezoid Vertex 
4837   ////////////////////////////////////////////
4838         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4839         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4840                                                                                                  - mountingsupportedge[i];
4841         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4842         mountingblocksupportrapezoidupxvertex[i][1] = 
4843                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4844         mountingblocksupportrapezoidupyvertex[i][1] = 
4845                                                                                                mountingblockpieceupyvertex[i][0]
4846                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4847                                                                                              - mountingblockpieceupyvertex[i][0]);
4848         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4849         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4850         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4851         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4852         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4853         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4854         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4855                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4856         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4857                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4858         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4859         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4860         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4861                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4862         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4863   }
4864   ///////////////////////////////////////////////////////////////////
4865   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4866   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4867   Double_t boxoriginup[fgklayernumber][2][3];
4868   Double_t boxorigindown[fgklayernumber][2][3];
4869   char mountingblocksupportboxdownname[100];
4870   char mountingblocksupportboxupname[100];
4871   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4872   mountingblocksupportrot->SetAngles(90.,180.,-90);
4873   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4874   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4875   TGeoHMatrix* laddersupportmatrix[2];
4876   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4877   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4878   /////////////////////////////////////////////////////////////
4879   // Creating Mother Volume for Containment
4880   /////////////////////////////////////////////////////////////
4881   Double_t *xmothervertex[fgklayernumber];
4882   Double_t *ymothervertex[fgklayernumber];
4883   for(Int_t i=0; i<fgklayernumber; i++){
4884         xmothervertex[i] = new Double_t[8];
4885         ymothervertex[i] = new Double_t[8];
4886   }  
4887   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4888   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4889   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4890 //  TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4891   TGeoVolumeAssembly* upmotherladdersupport[fgklayernumber];   
4892   char upmotheladdersupportname[100];
4893   char downmotheladdersupportname[100];
4894   for(Int_t i=0; i<fgklayernumber; i++){
4895         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4896                                                     -  mountingsupportedge[i];
4897         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4898         xmothervertex[i][1] = xmothervertex[i][0];
4899         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4900                                                         + fgkMountingBlockSupportWidth[0];
4901         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4902         ymothervertex[i][2] = ymothervertex[i][1];
4903         xmothervertex[i][3] = xmothervertex[i][2];
4904         ymothervertex[i][3] = -ymothervertex[i][0];
4905         xmothervertex[i][4] = -xmothervertex[i][0];
4906         ymothervertex[i][4] = ymothervertex[i][3];
4907         xmothervertex[i][5] = xmothervertex[i][4];
4908         ymothervertex[i][5] = -ymothervertex[i][1];
4909         xmothervertex[i][6] = -xmothervertex[i][2];
4910         ymothervertex[i][6] = ymothervertex[i][5];
4911         xmothervertex[i][7] = xmothervertex[i][6];
4912         ymothervertex[i][7] = ymothervertex[i][0];
4913         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4914         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4915     downmotherladdersupportshape[i] = new TGeoXtru(2);
4916         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4917         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4918     downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4919                                                                    +                       fgkMountingBlockSupportDownHeight
4920                                                                    +                       fgkSSDMountingBlockHeight[1]
4921                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4922                                                                    -                       fgkSSDModuleCoolingBlockToSensor);
4923     downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4924                                                                           downmotherladdersupportshape[i],fSSDAir);
4925     upmotherladdersupportshape[i] = new TGeoXtru(2);
4926         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4927         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4928     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4929                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4930                                                                    +                       fgkSSDMountingBlockHeight[1]
4931                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4932                                                                    -                       fgkSSDModuleCoolingBlockToSensor);
4933         upmotherladdersupport[i] = new TGeoVolumeAssembly(upmotheladdersupportname);
4934 //    upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4935 //                                                                                        upmotherladdersupportshape[i],fSSDAir);
4936   }
4937   for(Int_t i=0; i<fgklayernumber; i++){
4938         /////////////////////////
4939         // Setting the box origin
4940         /////////////////////////
4941         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4942         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4943                                                    +  0.5*fgkMountingBlockSupportDownHeight;
4944         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4945                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4946   
4947         boxorigindown[i][1][0] = 0.0;
4948         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4949         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4950                                                    -      fgkMountingBlockSupportWidth[0]);
4951                                                    
4952         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4953         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4954                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4955         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4956                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4957   
4958         boxoriginup[i][1][0] = 0.0;
4959         boxoriginup[i][1][1] = fgkMountingBlockSupportRadius[i]
4960                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4961         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4962                                                  - fgkMountingBlockSupportWidth[0]);
4963   
4964         /////////////////////////
4965     // Setting the boxes    
4966         /////////////////////////
4967         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4968                                                                                  +  fgkSSDMountingBlockLength[0]),
4969                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4970                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4971                                                                                         boxorigindown[i][0]);
4972     mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4973                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4974                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4975                                                                                  -  fgkMountingBlockSupportWidth[0]),
4976                                                                                         boxorigindown[i][1]);
4977                                                                                         
4978         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4979                                                                                  +  fgkSSDMountingBlockLength[0]),
4980                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4981                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4982                                                                                         boxoriginup[i][0]);
4983                                                                                         
4984         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4985                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4986                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4987                                                                      -  fgkMountingBlockSupportWidth[0]),
4988                                                                                         boxoriginup[i][1]);
4989         ///////////////////////////////////////
4990     // Adding the Volumes to Mother Volume    
4991         ///////////////////////////////////////
4992         for(Int_t j=0; j<2; j++){
4993                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4994                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4995                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4996                                                                                   mountingblocksupportboxdownshape[i][j],
4997                                                                                   fSSDCarbonFiberMedium);
4998                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4999                                                                                   mountingblocksupportboxupshape[i][j],
5000                                                                                   fSSDCarbonFiberMedium);
5001                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
5002                 mountingblocksupportboxup[i][j]->SetLineColor(9);
5003                 for(Int_t k=0; k<2; k++){
5004                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
5005 //                      upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
5006                 }
5007         }
5008         for(Int_t k=0; k<2; k++){
5009                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
5010                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
5011                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5012                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5013             downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
5014                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
5015                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
5016 //              upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
5017 //              upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5018 //              upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5019 //              upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
5020 //              upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
5021         }
5022   }
5023   TList* laddersupportlist = new TList();
5024   laddersupportlist->Add(downmotherladdersupport[0]); 
5025   laddersupportlist->Add(upmotherladdersupport[0]); 
5026   laddersupportlist->Add(downmotherladdersupport[1]); 
5027   laddersupportlist->Add(upmotherladdersupport[1]); 
5028   /////////////////////////////////////////////////////////////
5029   // Deallocating memory
5030   /////////////////////////////////////////////////////////////
5031   for(Int_t i=0; i<fgklayernumber; i++){
5032         for(Int_t j=0; j<nedges+1; j++)
5033                 delete vertex[i][j];
5034         delete mountingsupportedgevector[i];
5035         delete [] vertex[i];
5036         delete vertexlist[i];
5037         delete [] xsidevertex[i];
5038         delete [] ysidevertex[i];
5039         delete [] xcentervertex[i];
5040         delete [] ycentervertex[i];
5041         delete [] xsidelowervertex[i];
5042         delete [] ysidelowervertex[i];
5043         delete [] xcenterlowervertex[i];
5044         delete [] ycenterlowervertex[i];
5045   }
5046   delete xsidevertex;
5047   delete ysidevertex;
5048   delete xcentervertex;
5049   delete ycentervertex;
5050   delete xsidelowervertex;
5051   delete ysidelowervertex;
5052   delete xcenterlowervertex;
5053   delete ycenterlowervertex;
5054   delete globalrefladdersupportrot;
5055   delete mountingblocksupportrot;
5056   /////////////////////
5057   return laddersupportlist;     
5058 }
5059  ////////////////////////////////////////////////////////////////////////////////
5060 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
5061 //////////////////////////////////////////
5062 // Method Generating Ladder Support Ring
5063 //////////////////////////////////////////
5064   if(!fCreateMaterials) CreateMaterials();
5065   if(!fTransformationMatrices) CreateTransformationMatrices();
5066   if(!fBasicObjects) CreateBasicObjects();
5067   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
5068   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
5069     const Int_t kssdlayladdernumber[fgklayernumber] = 
5070                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
5071   Double_t mountingsupportedge[fgklayernumber];
5072   Double_t mountingblockratio[fgklayernumber];
5073   Double_t theta[fgklayernumber];
5074   Double_t phi[fgklayernumber];
5075   for(Int_t i=0; i<fgklayernumber; i++){
5076         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
5077     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
5078                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
5079                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
5080                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
5081                                                           / kssdlayladdernumber[i])));
5082     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
5083                          / fgkMountingBlockSupportRadius[i]);
5084     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
5085   }
5086   TGeoRotation* globalrot = new TGeoRotation();
5087   globalrot->SetAngles(0.,-90.,0.); 
5088   TGeoRotation** laddersupportrot[fgklayernumber];
5089   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5090   for(Int_t i=0; i<fgklayernumber; i++){                
5091         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5092         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5093         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5094                 laddersupportrot[i][j] = new TGeoRotation();
5095                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5096                 switch(i){
5097                         case 0: //Ladder of Layer5  
5098                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5099                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5100                                                                             laddersupportmatrix[i][j]); 
5101                         break;
5102                         case 1: //Ladder of Layer6 
5103                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5104                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5105                                                                               laddersupportmatrix[i][j]); 
5106                         break;
5107                 }
5108     }
5109   }
5110   /////////////////////////////////////////////////////////////
5111   // Creating Lower Ladder Support 
5112   /////////////////////////////////////////////////////////////
5113   TVector3** ringsupportvertex[fgklayernumber];         
5114   Double_t angle = 360./nedges;
5115   for(Int_t i=0; i<fgklayernumber; i++){
5116     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5117         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5118                                                         *                          TMath::Cos(theta[i]));
5119         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5120                                                         -                          mountingsupportedge[i],
5121                                                                                    ringsupportvertex[i][0]->Y());
5122         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5123                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5124     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5125         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5126            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5127            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5128            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5129            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5130         }
5131         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5132     for(Int_t j=0; j<nedges+1; j++){
5133                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5134                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5135                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5136         }
5137   }
5138   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5139   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5140   for(Int_t i=0; i<fgklayernumber; i++){
5141         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5142         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5143         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5144                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5145                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5146         }
5147   }
5148 ////////////////////////////////////////////////////////////////////////////////
5149 // Start Corrections 13/06/08
5150 ////////////////////////////////////////////////////////////////////////////////
5151   char lowerladderpconsupportname[100];
5152   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5153   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5154   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5155   Double_t lowerladderpconradiusmax[fgklayernumber];
5156   Double_t lowerladderpconradiusmin[fgklayernumber];
5157   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5158   lowerladdersupportrot->SetAngles(90.,180.,-90);
5159   for(Int_t i=0; i<fgklayernumber; i++){
5160         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5161                                                                 *                          TMath::Cos(theta[i]);
5162     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5163   } 
5164   for(Int_t i=0; i<fgklayernumber; i++){
5165 ///////////////////////////  Modified Version ?///////////////////
5166     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5167         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5168                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5169                                                          lowerladderpconradiusmax[i]);
5170         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5171         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5172     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5173         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5174         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5175  }
5176 ////////////////////////////////////////////////////////////////////////////////
5177 // End Corrections 13/06/08
5178 ////////////////////////////////////////////////////////////////////////////////
5179   /*char lowerladdersupportname[30];
5180   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5181   TGeoVolume* lowerladdersupport[fgklayernumber];
5182   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5183   lowerladdersupportrot->SetAngles(90.,180.,-90);
5184   for(Int_t i=0; i<fgklayernumber; i++){
5185         lowerladdersupportshape[i] = new TGeoXtru(2);
5186         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5187                                                                                           xmothervertex[i],ymothervertex[i]);
5188         lowerladdersupportshape[i]->DefineSection(0,0.);
5189     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5190         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5191     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5192                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5193         lowerladdersupport[i]->SetLineColor(fColorAl);
5194         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5195         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5196   }*/
5197   /////////////////////////////////////////////////////////////
5198   // Deallocating memory
5199   /////////////////////////////////////////////////////////////
5200   for(Int_t i=0; i<fgklayernumber; i++){
5201         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5202                 delete ringsupportvertex[i][j];
5203         delete [] ringsupportvertex[i];
5204   }
5205   for(Int_t i=0; i<fgklayernumber; i++){
5206         delete [] xmothervertex[i];
5207         delete [] ymothervertex[i];
5208   }
5209   delete xmothervertex;
5210   delete ymothervertex; 
5211   delete globalrot;
5212   for(Int_t i=0; i<fgklayernumber; i++){
5213         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5214                 delete laddersupportrot[i][j];
5215         delete [] laddersupportrot[i];
5216   }
5217  }  
5218  ////////////////////////////////////////////////////////////////////////////////
5219  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5220   /////////////////////////////////////////////////////////////
5221   // Method generating Endcap CoverPlate
5222   /////////////////////////////////////////////////////////////
5223   // Holes Definition 
5224   ///////////////////
5225   Int_t nendcapcoverplateholedges = 30;
5226   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5227   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5228                                                           0.5*fgkEndCapCoverPlateThickness};
5229   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5230                                                                                                               nendcapcoverplateholedges,holesection);
5231   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5232                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5233   endcapcoverplatesmallhole->SetLineColor(6);
5234   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5235                                                                                                               nendcapcoverplateholedges,holesection);
5236   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5237                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5238   endcapcoverplatebighole->SetLineColor(6);
5239   //////////////////////////
5240   // Screw Piece Definition 
5241   //////////////////////////
5242   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5243   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5244                                                                                                       CosD(0.5*smallscrewangle),
5245                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5246   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5247                                                                                                 endcapsmallscrewpieceshape,
5248                                                                                                 fSSDCoolingTubePhynox);
5249   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5250   ///////////////////
5251   // Box Definition 
5252   ///////////////////
5253   TGeoBBox* endcapcoverplateboxshape[4];
5254   TGeoVolume* endcapcoverplatebox[4];
5255   Double_t boxorigin[5][3];
5256   boxorigin[0][0] = 0.;
5257   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5258   boxorigin[0][2] = 0.;
5259
5260   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5261   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5262   boxorigin[1][2] = 0.;
5263
5264   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5265                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5266   boxorigin[2][1] = boxorigin[1][1];
5267   boxorigin[2][2] = 0.;
5268
5269   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5270                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5271   boxorigin[3][1] = boxorigin[1][1];
5272   boxorigin[3][2] = 0.;
5273
5274   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5275                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5276                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5277                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5278
5279   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5280                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5281                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5282                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5283                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5284
5285   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5286                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5287                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5288                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5289                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5290
5291   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5292                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5293                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5294                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5295                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5296   
5297   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5298                                                                            fSSDAlCoolBlockMedium);
5299   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5300                                                                            fSSDAlCoolBlockMedium);
5301   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5302                                                                            fSSDAlCoolBlockMedium);
5303   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5304                                                                            fSSDAlCoolBlockMedium);
5305   endcapcoverplatebox[0]->SetLineColor(6);
5306   endcapcoverplatebox[1]->SetLineColor(6);
5307   endcapcoverplatebox[2]->SetLineColor(6);
5308   endcapcoverplatebox[3]->SetLineColor(6);
5309   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5310   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5311                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5312                                                                                         0.5*fgkEndCapCoverPlateThickness,
5313                                                                                         endcapfillingboxorigin);
5314   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5315                                                                            fSSDAlCoolBlockMedium);
5316   endcapfillingbox->SetLineColor(6);
5317   ////////////////////////////
5318   // Contour shape Definition 
5319   ////////////////////////////
5320   const Int_t kcontourvertexnumber = 10;
5321   Double_t xcontourvertex[kcontourvertexnumber];
5322   Double_t ycontourvertex[kcontourvertexnumber];
5323   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5324   xcontourvertex[1] = xcontourvertex[0];
5325   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5326   xcontourvertex[3] = xcontourvertex[2];
5327   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5328   xcontourvertex[5] = xcontourvertex[4];
5329   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5330   xcontourvertex[7] = xcontourvertex[6];
5331   xcontourvertex[8] = xcontourvertex[4];
5332   xcontourvertex[9] = xcontourvertex[8];
5333   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5334                                         - (kendcapcoverplatesmallholenumber[1]-1)
5335                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5336   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5337                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5338   ycontourvertex[2] = ycontourvertex[1];
5339   ycontourvertex[3] = ycontourvertex[0];
5340   ycontourvertex[4] = ycontourvertex[3];
5341   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5342   ycontourvertex[6] = ycontourvertex[5];
5343   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5344                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5345                                         + fgkEndCapCoverPlateSmallHoleRadius;
5346   ycontourvertex[8] = ycontourvertex[7];
5347   ycontourvertex[9] = ycontourvertex[0];
5348
5349   Double_t xboxin, dxboxin, yboxin, dyboxin;
5350   Double_t xboxout, dxboxout, yboxout, dyboxout;
5351   Double_t coordmin, coordmax;
5352   coordmin = -fgkEndCapCoverPlateLength[0];
5353   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5354   xboxout = 0.5*(coordmin+coordmax);
5355   dxboxout = 0.5*(coordmax-coordmin);
5356   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5357                                         - (kendcapcoverplatesmallholenumber[1]-1)
5358                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5359   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5360                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5361   yboxout = 0.5*(coordmin+coordmax);
5362   dyboxout = 0.5*(coordmax-coordmin);
5363   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5364   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5365   xboxin = 0.5*(coordmin+coordmax);
5366   dxboxin = 0.5*(coordmax-coordmin);
5367   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5368   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5369                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5370                                         + fgkEndCapCoverPlateSmallHoleRadius;
5371   yboxin = 0.5*(coordmin+coordmax);
5372   dyboxin = 0.5*(coordmax-coordmin);
5373   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5374   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5375                                                          xboxout, yboxout, 0.);
5376   trendCapCoverPlateContourboxout->RegisterYourself();
5377   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5378   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5379                                                          xboxin, yboxin, 0.);
5380   trendCapCoverPlateContourboxin->RegisterYourself();
5381   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5382         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5383
5384   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5385                                                                            fSSDAlCoolBlockMedium);
5386   contour->SetLineColor(6);
5387   /////////////////////////////
5388   // Hole Contour Shape Definition 
5389   ////////////////////////////
5390   coordmin = xcontourvertex[0];
5391   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5392   xboxout = 0.5*(coordmin+coordmax);
5393   dxboxout = 0.5*(coordmax-coordmin);
5394   coordmin = ycontourvertex[1];
5395   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5396   yboxout = 0.5*(coordmin+coordmax);
5397   dyboxout = 0.5*(coordmax-coordmin);
5398   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5399                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5400   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5401   xboxin = 0.5*(coordmin+coordmax);
5402   dxboxin = 0.5*(coordmax-coordmin);
5403   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5404                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5405   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5406   yboxin = 0.5*(coordmin+coordmax);
5407   dyboxin = 0.5*(coordmax-coordmin);
5408   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5409   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5410                                                          xboxout, yboxout, 0.);
5411   trendCapCoverPlateContourboxout1->RegisterYourself();
5412   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5413   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5414                                                          xboxin, yboxin, 0.);
5415   trendCapCoverPlateContourboxin1->RegisterYourself();
5416   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5417         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5418
5419
5420   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5421   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5422   xboxout = 0.5*(coordmin+coordmax);
5423   dxboxout = 0.5*(coordmax-coordmin);
5424   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5425                                                    - fgkEndCapCoverPlateWidth[0]);
5426   coordmax = ycontourvertex[0];
5427   yboxout = 0.5*(coordmin+coordmax);
5428   dyboxout = 0.5*(coordmax-coordmin);
5429   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5430                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5431   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5432   xboxin = 0.5*(coordmin+coordmax);
5433   dxboxin = 0.5*(coordmax-coordmin);
5434   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5435                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5436                                                    - fgkEndCapCoverPlateWidth[0]
5437                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5438   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5439   yboxin = 0.5*(coordmin+coordmax);
5440   dyboxin = 0.5*(coordmax-coordmin);
5441   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5442   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5443                                                          xboxout, yboxout, 0.);
5444   trendCapCoverPlateContourboxout2->RegisterYourself();
5445   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5446   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5447                                                          xboxin, yboxin, 0.);
5448   trendCapCoverPlateContourboxin2->RegisterYourself();
5449   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5450         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5451   
5452 //  const Int_t kholecontourvertexnumber = 10;
5453
5454   Double_t xholecontourvertex[2][kcontourvertexnumber];
5455   Double_t yholecontourvertex[2][kcontourvertexnumber];
5456   xholecontourvertex[0][0] = xcontourvertex[0];
5457   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5458   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5459   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5460   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5461                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5462                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5463   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5464   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5465                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5466   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5467   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5468   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5469   
5470   yholecontourvertex[0][0] = ycontourvertex[1];
5471   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5472   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5473   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5474   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5475   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5476                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5477   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5478   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5479   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5480   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5481
5482   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5483   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5484   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5485   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5486   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5487                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5488                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5489   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5490   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5491                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5492   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5493   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5494   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5495   
5496   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5497                                                    - fgkEndCapCoverPlateWidth[0]);
5498   yholecontourvertex[1][1] = ycontourvertex[0];
5499   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5500   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5501   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5502   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5503                                                    - fgkEndCapCoverPlateWidth[0]
5504                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5505   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5506   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5507   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5508   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5509
5510   TGeoVolume* holecontour[2];
5511   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5512                                                                   fSSDAlCoolBlockMedium);
5513   holecontour[0]->SetLineColor(6);
5514   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5515                                                                   fSSDAlCoolBlockMedium);
5516   holecontour[1]->SetLineColor(6);
5517   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5518                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5519   TGeoTranslation*  bigholetrans[3];
5520   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5521                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5522   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5523                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5524                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5525   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5526                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5527   /////////////////////////////////
5528   // Mother Volume Xtru Definition 
5529   /////////////////////////////////
5530   const Int_t kmothervertexnumber = 12;
5531   Double_t xmothervertex[kmothervertexnumber];  
5532   Double_t ymothervertex[kmothervertexnumber];  
5533   xmothervertex[0]  = xcontourvertex[0];
5534   xmothervertex[1]  = xmothervertex[0];
5535   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5536   xmothervertex[3]  = xmothervertex[2];
5537   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5538   xmothervertex[5]  = xmothervertex[4];
5539   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5540   xmothervertex[7]  = xmothervertex[6];
5541   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5542                                         + fgkEndCapCoverPlateLength[2]; 
5543   xmothervertex[9]  = xmothervertex[8];
5544   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5545   xmothervertex[11] = xmothervertex[10];
5546   
5547   ymothervertex[0]  = ycontourvertex[0];
5548   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5549   ymothervertex[2]  = ymothervertex[1];
5550   ymothervertex[3]  = ycontourvertex[1];
5551   ymothervertex[4]  = ymothervertex[3];
5552   ymothervertex[5]  = ymothervertex[1];
5553   ymothervertex[6]  = ymothervertex[5];
5554   ymothervertex[7]  = ymothervertex[0];
5555   ymothervertex[8]  = ymothervertex[7];
5556   ymothervertex[9]  = ymothervertex[8]
5557                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5558   ymothervertex[10] = ymothervertex[9];
5559   ymothervertex[11] = ymothervertex[8];
5560   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5561   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5562   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5563   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5564   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5565   ////////////////////////////////////////
5566   // Adding Nodes
5567   ////////////////////////////////////////
5568 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5569   TGeoTranslation*** endcapcoverplatesmallholetrans;
5570   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5571   Double_t transx[4] = {0,
5572                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5573                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5574                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5575                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5576                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5577   Int_t index = 0;
5578   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5579         endcapcoverplatesmallholetrans[i] = 
5580                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5581     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5582                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5583             endcapcoverplatesmallholetrans[i][j] = 
5584                 new TGeoTranslation(transx[i],
5585                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5586             if(index!=10){ 
5587                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5588                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5589                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5590                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5591                 }
5592                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5593                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5594                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5595     }
5596   }
5597   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5598   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5599   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5600   mothercoverplate->AddNode(endcapfillingbox,1);
5601   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5602   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5603   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5604   mothercoverplate->AddNode(holecontour[0],1);
5605   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5606   mothercoverplate->AddNode(holecontour[1],1);  
5607   mothercoverplate->AddNode(contour,1);
5608   /////////////////////////////////
5609   return mothercoverplate;      
5610  }
5611  ////////////////////////////////////////////////////////////////////////////////
5612  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5613   /////////////////////////////////////////////////////////////
5614   // Getting EndCap Cooling Tube 
5615   /////////////////////////////////////////////////////////////
5616   TGeoTorus* endcapcoolingtubetorushape[5];
5617   TGeoVolume* endcapcoolingtubetorus[5];
5618   TGeoTube* endcapcoolingtubeshape[4];
5619   TGeoVolume* endcapcoolingtube[4];
5620   char endcapcoolingtubetorusname[100];
5621   char endcapcoolingtubename[100];
5622   TGeoTorus* endcapcoolingwatertubetorushape[5];
5623   TGeoVolume* endcapcoolingwatertubetorus[5];
5624   TGeoTube* endcapcoolingwatertubeshape[4];
5625   TGeoVolume* endcapcoolingwatertube[4];
5626   char endcapcoolingwatertubetorusname[100];
5627   char endcapcoolingwatertubename[100];
5628   for(Int_t i=0; i<5; i++){
5629         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5630         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5631         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5632         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5633         if(i==3){
5634                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5635                                                                                 fgkEndCapCoolingTubeRadiusMin,
5636                                                                                 fgkEndCapCoolingTubeRadiusMax,
5637                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5638                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5639                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5640                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5641     }
5642         else{
5643                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5644                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5645                                                                            fgkEndCapCoolingTubeRadiusMin,
5646                                                                            fgkEndCapCoolingTubeRadiusMax,
5647                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5648                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5649                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5650                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5651                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5652         }
5653         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5654                                                                                            endcapcoolingtubetorushape[i],
5655                                                                                            fSSDCoolingTubePhynox);
5656         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5657                                                                                                         endcapcoolingwatertubetorushape[i],
5658                                                                                                         fSSDCoolingTubeWater);
5659     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5660     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5661     if(i<4){
5662                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5663                                                                   fgkEndCapCoolingTubeRadiusMax,
5664                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5665                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5666                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5667         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5668                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5669         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5670                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5671                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5672                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5673         }
5674   }
5675   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5676   /////////////////////////////////////////
5677   // Transformation for Volume Positioning 
5678   /////////////////////////////////////////
5679   TGeoCombiTrans* coolingtubecombitrans[6];
5680   TGeoRotation* coolingtuberot[8];
5681   TGeoTranslation* coolingtubetrans[6];
5682   TGeoHMatrix* coolingtubematrix[4];
5683   TGeoCombiTrans* torustubecombitrans[4];
5684   TGeoRotation* torustuberot[7];
5685   TGeoTranslation* torustubetrans[4];
5686   TGeoHMatrix* torustubematrix[5];
5687   TGeoCombiTrans* coolingwatertubecombitrans[6];
5688   TGeoRotation* coolingwatertuberot[8];
5689   TGeoTranslation* coolingwatertubetrans[6];
5690   TGeoHMatrix* coolingwatertubematrix[4];
5691   TGeoCombiTrans* toruswatertubecombitrans[4];
5692   TGeoRotation* toruswatertuberot[7];
5693   TGeoTranslation* toruswatertubetrans[4];
5694   TGeoHMatrix* toruswatertubematrix[5];
5695   for(Int_t i=0; i<8; i++){
5696     if(i<6){
5697          coolingtubetrans[i] = new TGeoTranslation();
5698          coolingwatertubetrans[i] = new TGeoTranslation();
5699     }
5700     if(i<8){
5701          coolingtuberot[i] = new TGeoRotation();
5702          coolingwatertuberot[i] = new TGeoRotation();
5703     }
5704     if(i<4){
5705          torustubetrans[i] = new TGeoTranslation();
5706          toruswatertubetrans[i] = new TGeoTranslation();
5707     }
5708     if(i<7){
5709          torustuberot[i] = new TGeoRotation();
5710          toruswatertuberot[i] = new TGeoRotation();
5711         }
5712   }
5713   /////////////////////////////////////////
5714   // Transformation for Inox Volume Positioning 
5715   /////////////////////////////////////////
5716   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5717                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5718   coolingtuberot[0]->SetAngles(0.,90.,0.);
5719   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5720                                                                                                 *coolingtuberot[0]);
5721                                                                                                 
5722   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5723   coolingtuberot[1]->SetAngles(0.,90.,0.);
5724   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5725                                                                                                 *coolingtuberot[1]);
5726
5727   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5728                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5729                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5730                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5731                                                                           0.);
5732   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5733   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5734                                                                                                 *coolingtuberot[2]);
5735
5736   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5737                                            *                             (*coolingtubecombitrans[1]));
5738
5739   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5740                                                                          endcapcoolingtubeshape[1]->GetDz());
5741   torustuberot[0]->SetAngles(0.,90.,0.); 
5742   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5743
5744   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5745
5746   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5747                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5748   coolingtuberot[3]->SetAngles(0.,90.,0.);
5749   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5750                                                                                                 *coolingtuberot[3]);
5751   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5752   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5753   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5754   
5755   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5756                                                                         endcapcoolingtubeshape[2]->GetDz());
5757   torustuberot[1]->SetAngles(0.,90.,0.); 
5758   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5759   torustuberot[2]->SetAngles(180.,0.,0.); 
5760   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5761   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5762
5763   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5764                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5765   torustuberot[3]->SetAngles(0.,90.,0.); 
5766   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5767   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5768   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5769   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5770
5771   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5772                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5773   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5774   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5775                                                                                                 *coolingtuberot[5]);
5776   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5777   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5778   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5779   
5780   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5781                                                                         endcapcoolingtubeshape[0]->GetDz());
5782   torustuberot[5]->SetAngles(0.,90.,0.); 
5783   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5784   torustuberot[6]->SetAngles(-90.,0.,0.); 
5785   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5786   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5787   
5788   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5789                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5790   coolingtuberot[6]->SetAngles(0.,90.,0.);
5791   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5792                                                                                                 *coolingtuberot[6]);
5793   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5794   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5795   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5796     /////////////////////////////////////////
5797   // Transformation for Water Volume Positioning 
5798   /////////////////////////////////////////
5799   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5800                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5801   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5802   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5803                                                                                                      *coolingwatertuberot[0]);
5804
5805   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5806   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5807   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5808                                                                                                      *coolingwatertuberot[1]);
5809
5810   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5811                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5812                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5813                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5814                                                                               0.);
5815   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5816   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5817                                                                                                     *coolingwatertuberot[2]);
5818
5819   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5820                                            *                                 (*coolingwatertubecombitrans[1]));
5821                                            
5822   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5823                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5824   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5825   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5826                                                                                                    *toruswatertuberot[0]);
5827
5828   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5829                                                   *                                     (*toruswatertubecombitrans[0]));
5830
5831   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5832                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5833   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5834   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5835                                                                                                      *coolingwatertuberot[3]);
5836   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5837   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5838                                                         *                                 (*coolingwatertubecombitrans[3]));
5839   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5840
5841   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5842                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5843   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5844   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5845                                                                                                    *toruswatertuberot[1]);
5846   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5847   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5848                                                   *                 (*toruswatertubecombitrans[1]));
5849   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5850   
5851   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5852                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5853   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5854   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5855                                                                                                    *toruswatertuberot[3]);
5856   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5857   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5858                                                   *                                     (*toruswatertubecombitrans[2]));
5859   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5860
5861   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5862                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5863   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5864   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5865                                                                                                      *coolingwatertuberot[5]);
5866   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5867   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5868                                                         *                                 (*coolingwatertubecombitrans[4]));
5869   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5870   
5871   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5872                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5873   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5874   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5875                                                                                                    *toruswatertuberot[5]);
5876   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5877   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5878                                                   *                 (*toruswatertubecombitrans[3]));
5879   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5880   
5881   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5882                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5883   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5884   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5885                                                                                                      *coolingwatertuberot[6]);
5886   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5887   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5888                                                         *                                 (*coolingwatertubecombitrans[5]));
5889   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5890   /////////////////////////////////////////
5891   // Positioning Volumes
5892   /////////////////////////////////////////
5893   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5894   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5895   
5896   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5897   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5898
5899   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5900   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5901  
5902   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5903   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5904
5905   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5906   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5907
5908   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5909   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5910
5911   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5912   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5913
5914   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5915   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5916   
5917   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5918   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5919  
5920   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5921   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5922   /////////////////////////////////////////////////////////////
5923   // Deallocating memory
5924   /////////////////////////////////////////////////////////////
5925   for(Int_t i=0; i<8; i++){
5926     if(i<6){
5927          delete coolingtubetrans[i];
5928          delete coolingwatertubetrans[i];
5929          if(i!=0){
5930           delete coolingtubecombitrans[i];
5931           delete coolingwatertubecombitrans[i];
5932          }
5933         }
5934     if(i<8){
5935           delete coolingtuberot[i];
5936           delete coolingwatertuberot[i];
5937     }
5938     if(i<4){
5939                 delete torustubetrans[i];
5940                 delete toruswatertubetrans[i];
5941                 delete torustubecombitrans[i];
5942                 delete toruswatertubecombitrans[i];
5943         } 
5944     if(i<7){
5945          delete torustuberot[i];
5946          delete toruswatertuberot[i];
5947         }
5948   }
5949   /////////////////////////////////////////////////////////////
5950   return endcapcoolingtubemother;
5951  }
5952  ////////////////////////////////////////////////////////////////////////////////
5953  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5954   /////////////////////////////////////////////////////////////
5955   // Getting EndCap Cover Side 
5956   /////////////////////////////////////////////////////////////
5957   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5958   const Int_t kvertexnumber = 15; 
5959   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5960   xvertex[0]  = 0.0;
5961   xvertex[1]  = xvertex[0];
5962   xvertex[2]  = fgkEndCapSideCoverLength[0];
5963   xvertex[3]  = fgkEndCapSideCoverLength[1];
5964   xvertex[4]  = xvertex[3];
5965   xvertex[5]  = fgkEndCapSideCoverLength[2];
5966   xvertex[6]  = xvertex[5];
5967   xvertex[7]  = xvertex[2];
5968   xvertex[8]  = xvertex[7];
5969   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5970   xvertex[10] = xvertex[9];
5971   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5972                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5973                           * fgkEndCapSideCoverLength[4];
5974   xvertex[12] = xvertex[11];
5975   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5976                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5977                           * fgkEndCapSideCoverLength[4];
5978   xvertex[14] = xvertex[13];
5979   yvertex[0]  = 0.0;
5980   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5981   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5982   yvertex[3]  = yvertex[2];
5983   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5984   yvertex[5]  = yvertex[4];
5985   yvertex[6]  = yvertex[0];
5986   yvertex[7]  = yvertex[6];
5987   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5988   yvertex[9]  = yvertex[8];
5989   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5990   yvertex[11] = yvertex[10];
5991   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5992   yvertex[13] = yvertex[12];
5993   yvertex[14] = yvertex[6];
5994   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5995   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5996   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5997   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5998   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5999   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
6000   endcapsidecovershapein->SetName("endcapsidecovershapein");
6001   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
6002   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
6003   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
6004
6005
6006   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
6007   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
6008                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
6009   endcapsidecover->SetLineColor(fColorPhynox);
6010   ////////////////////////////////////////////
6011   // Defininition of Mother Volume
6012   ////////////////////////////////////////////
6013   const Int_t kmothervertexnumber = 7;
6014   Double_t xmothervertex[kmothervertexnumber]; 
6015   Double_t ymothervertex[kmothervertexnumber]; 
6016   for(Int_t i=0; i<kmothervertexnumber; i++){
6017         xmothervertex[i] = xvertex[i];
6018         ymothervertex[i] = yvertex[i];
6019   }
6020   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
6021   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
6022   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
6023   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
6024   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
6025                                                                 endcapsidecovermothershape,fSSDAir);
6026   ////////////////////////////////////////////
6027   endcapsidecovermother->AddNode(endcapsidecover,1);
6028   TGeoBBox* endcapsidecoverboxshape[4];
6029   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
6030                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
6031                                                                0.5*fgkEndCapSideCoverLength[4],
6032                                                                    0.5*fgkEndCapSideCoverThickness); 
6033   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
6034                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
6035                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
6036                                                          -     fgkEndCapSideCoverLength[4]),
6037                                                                    0.5*fgkEndCapSideCoverThickness); 
6038   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
6039                                                                0.5*fgkEndCapSideCoverLength[4],
6040                                                                    0.5*fgkEndCapSideCoverThickness); 
6041   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
6042                                                                0.5*fgkEndCapSideCoverWidth[5],
6043                                                                    0.5*fgkEndCapSideCoverThickness); 
6044   TGeoVolume* endcapsidecoverbox[4];
6045   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
6046   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
6047   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
6048   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
6049   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
6050 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
6051   TGeoTranslation** endcapsidecoverboxtrans;
6052   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
6053   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
6054                                                          +                                         fgkEndCapSideCoverLength[0],
6055                                                                                                    endcapsidecoverboxshape[0]->GetDY()
6056                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
6057   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
6058                                                          +                     xvertex[11],
6059                                                                                                    endcapsidecoverboxshape[1]->GetDY()
6060                                                          +                     yvertex[12],0.);
6061   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
6062                                                          +                     xvertex[11],
6063                                                                                                    endcapsidecoverboxshape[2]->GetDY()
6064                                                          +                     yvertex[12]
6065                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
6066                                                          +                     fgkEndCapSideCoverWidth[5],0.);
6067   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
6068   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
6069   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
6070   for(Int_t i=0; i<2; i++)
6071         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
6072                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
6073                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
6074                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6075                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6076                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
6077                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
6078                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
6079         }
6080   for(Int_t i=0; i<2; i++)
6081         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
6082                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
6083                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
6084                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6085                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6086                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
6087                                                         +fgkEndCapSideCoverLength[4]),0.0);
6088                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
6089                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
6090                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
6091                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
6092         }
6093         return endcapsidecovermother;
6094  } 
6095  ////////////////////////////////////////////////////////////////////////////////
6096  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
6097  ////////////////////////////////////////////////////////////////////////////////
6098  // Method returning Interface Card A, Interface Card B, Supply Card 
6099  ////////////////////////////////////////////////////////////////////////////////
6100  /////////////////////
6101  // Supply Card
6102  /////////////////////
6103  // Electronic Board Back Al Plane
6104  const Int_t kelectboardbackvertexnumber = 8;
6105  Double_t xelectboardback[kelectboardbackvertexnumber];
6106  Double_t yelectboardback[kelectboardbackvertexnumber];
6107  xelectboardback[0] = 0.0;
6108  xelectboardback[1] = xelectboardback[0];
6109  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
6110  xelectboardback[3] = xelectboardback[2];
6111  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
6112  xelectboardback[5] = xelectboardback[4];
6113  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
6114  xelectboardback[7] = xelectboardback[6];
6115  
6116  yelectboardback[0] = 0.0;
6117  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
6118  yelectboardback[2] = yelectboardback[1];
6119  yelectboardback[3] = yelectboardback[0];
6120  yelectboardback[4] = yelectboardback[3];
6121  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
6122  yelectboardback[6] = yelectboardback[5];
6123  yelectboardback[7] = yelectboardback[4];
6124  TGeoXtru* electboardbackshape = new TGeoXtru(2);
6125  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
6126                                                                         xelectboardback,yelectboardback); 
6127  electboardbackshape->DefineSection(0,0.0);
6128  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
6129  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
6130                                                                                          electboardbackshape,fSSDSupportRingAl);
6131  electboardback->SetLineColor(fColorAl);
6132  // Electronic Board Kapton Layer
6133  const Int_t kelectlayervertexnumber = 8;
6134  Double_t xelectlayer[kelectlayervertexnumber];
6135  Double_t yelectlayer[kelectlayervertexnumber];
6136  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
6137  xelectlayer[1] = xelectlayer[0];
6138  xelectlayer[2] = fgkEndCapCardElectBoardLength;
6139  xelectlayer[3] = xelectlayer[2];
6140  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
6141      
6142  yelectlayer[0] = 0.0;
6143  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
6144  yelectlayer[2] = yelectlayer[1];
6145  yelectlayer[3] = yelectlayer[0];
6146  yelectlayer[4] = yelectlayer[3];
6147  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
6148  yelectlayer[6] = yelectlayer[5];
6149  yelectlayer[7] = yelectlayer[4];
6150  TGeoXtru* electlayershape = new TGeoXtru(2);
6151  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
6152  electlayershape->DefineSection(0,0.0);
6153  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
6154  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
6155                                                                                          electlayershape,fSSDKaptonFlexMedium);
6156  electlayer->SetLineColor(fColorKapton);
6157  // JMD Connector Female
6158  const Int_t kjmdconnectorvertexnumber = 6;
6159  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6160  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6161  xjmdconnectorvertex[0] = 0.0; 
6162  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
6163  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
6164  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
6165  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
6166  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
6167
6168  yjmdconnectorvertex[0] = 0.0; 
6169  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
6170  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
6171  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
6172  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
6173  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
6174  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
6175  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
6176                                                                   yjmdconnectorvertex); 
6177  jmdconnectorshape->DefineSection(0,0.0);
6178  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6179  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6180                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6181  jmdconnector->SetLineColor(fColorG10);
6182  // Top Cable Connector
6183  const Int_t kcableconnectorvertexnumber = 8;
6184  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6185  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6186  xconnectorvertex[0] = 0.0;
6187  xconnectorvertex[1] = xconnectorvertex[0];
6188  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6189  xconnectorvertex[3] = xconnectorvertex[2];
6190  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6191                                          - fgkEndCapCardCableConnectorLength[2];
6192  xconnectorvertex[5] = xconnectorvertex[4];
6193  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6194  xconnectorvertex[7] = xconnectorvertex[6];
6195
6196  yconnectorvertex[0] = 0.0;
6197  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6198  yconnectorvertex[2] = yconnectorvertex[1];
6199  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6200  yconnectorvertex[4] = yconnectorvertex[3];
6201  yconnectorvertex[5] = yconnectorvertex[1];
6202  yconnectorvertex[6] = yconnectorvertex[5];
6203  yconnectorvertex[7] = yconnectorvertex[0];
6204  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6205  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6206                                                                     yconnectorvertex); 
6207  cableconnectorshape->DefineSection(0,0.0);
6208  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6209  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6210                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6211  cableconnector->SetLineColor(fColorG10);
6212  // Strip Connection
6213  TGeoBBox* endcapstripconnectionshape = 
6214                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6215                                                                                          0.5*fgkEndCapStripConnectionThickness,
6216                                                                                          0.5*fgkEndCapStripConnectionWidth);
6217  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6218                                                                                                         endcapstripconnectionshape,
6219                                                                                                         fSSDSupportRingAl);
6220  endcapstripconnection->SetLineColor(fColorAl);
6221  // Interface Card B
6222  const Int_t kcardBvertexnumber = 12; 
6223  Double_t xcardBvertexnumber[kcardBvertexnumber];
6224  Double_t ycardBvertexnumber[kcardBvertexnumber];
6225
6226  xcardBvertexnumber[0]  = 0.0;
6227  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6228  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6229  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6230  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6231  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6232  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6233  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6234  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6235  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6236  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6237  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6238  
6239  ycardBvertexnumber[0]  = 0.0;
6240  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6241  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6242  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6243  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6244  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6245  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6246  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6247  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6248  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6249  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6250  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6251
6252  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6253  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6254  interfacecardBshape->DefineSection(0,0.);
6255  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6256  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6257                                                                                          fSSDMountingBlockMedium);
6258  interfacecardB->SetLineColor(46);
6259  // Interface Card B Electronic Board
6260  const Int_t kelectboardcardBvertexnumber = 14; 
6261  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6262  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6263
6264  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6265  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6266  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6267  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6268  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6269  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6270  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6271  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6272  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6273  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6274  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6275  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6276  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6277  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6278
6279  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6280  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6281  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6282  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6283  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6284  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6285  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6286  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6287  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6288  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6289  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6290  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6291  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6292  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6293
6294  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6295  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6296                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6297  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6298  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6299                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6300  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6301                                                                                           fSSDSupportRingAl);
6302  electboardcardB->SetLineColor(fColorAl);
6303  // Generating Stiffener 2
6304  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6305                                                                                            0.5*fgkEndCapStiffenerThickness,
6306                                                                                            0.5*fgkEndCapStiffenerLength);
6307  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6308  endcapstiffener->SetLineColor(fColorAl);   
6309  // Generating Mother Interface Card B Container
6310  const Int_t kinterfacecardBmothervertexnumber = 10;
6311  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6312  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6313
6314  xinterfacecardBmothervertex[0] = 0.0;
6315  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6316  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6317                                                                 + fgkEndCapInterfaceCardBThickness;
6318  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6319  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6320                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6321  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6322  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6323  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6324  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6325                                                                 + fgkEndCapCardJMDConnectorLength[0];
6326  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6327
6328  yinterfacecardBmothervertex[0] = 0.0;
6329  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6330                                                                 + fgkEndCapInterfaceCardBWidth[1]
6331                                                                 + fgkEndCapInterfaceCardBWidth[2];
6332  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6333  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6334  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6335  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6336  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6337  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6338                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6339                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6340  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6341  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6342  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6343  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6344                                                                                   xinterfacecardBmothervertex,
6345                                                                                   yinterfacecardBmothervertex);
6346  interfacecardBmothershape->DefineSection(0,-1.e-15);
6347  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6348  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6349                                                                                                    interfacecardBmothershape,fSSDAir);
6350  electboardcardB->SetLineColor(fColorAl);
6351  // Positioning Volumes Mother Interface Card B Container 
6352  TGeoRotation* interfacecardBrot = new TGeoRotation();
6353  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6354  interfacecardBrot->SetAngles(90.,-90.,-90.);
6355  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6356  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6357  TGeoRotation* electboardcardBrot = new TGeoRotation();
6358  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6359  electboardcardBrot->SetAngles(90.,90.,-90.);
6360  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6361  TGeoCombiTrans* electboardcardBcombitrans = 
6362                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6363  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6364  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6365  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6366  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6367  TGeoTranslation* jmdconnectorcardBtrans[3];
6368  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6369  for(Int_t i=0; i<3; i++){
6370    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6371                                                          + fgkEndCapCardJMDConnectorLength[0], 
6372                                                            fgkEndCapCardElectBoardLayerWidth[1],
6373                                                            0.5*fgkEndCapCardJMDConnectorThickness
6374                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6375                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6376                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6377    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6378                                                                                                            *jmdconnectorcardBrot);
6379    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6380  }
6381  // Mother Supply Card Container 
6382  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6383  // Interface Card Container
6384  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6385  // Placing Volumes in Mother Supply Card Container
6386  // JMD Connector Positioning
6387  TGeoTranslation* jmdconnectortrans[2];
6388  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6389  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6390                                                                                         fgkEndCapCardElectBoardBackLength[0]
6391                                           -                                             fgkEndCapCardJMDConnectorThickness
6392                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6393  TGeoRotation* jmdconnectorot = new TGeoRotation();
6394  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6395                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6396                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6397                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6398                                                                       fgkEndCapCardJMDConnectorThickness
6399                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6400  jmdconnectorot->SetAngles(90.,180.,-90);
6401  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6402                                                                                 * jmdconnectorot);
6403  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6404  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6405  // Top Cable Connector Placing
6406  TGeoRotation* cableconnectorot[2];
6407  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6408  TGeoTranslation* cableconnectortrans[3];
6409  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6410  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6411  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6412  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6413  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6414                                                                                                                            *cableconnectorot[0]);
6415  TGeoHMatrix* cableconnectormatrix[2];
6416  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6417                                                         new TGeoHMatrix((*cableconnectorot[1])
6418                                                                                    *(*cableconnectorcombitrans));
6419  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6420                                            -                               fgkEndCapCardCableConnectorThickness,
6421                                                                                 fgkEndCapCardCableConnectorLength[0]
6422                                            +                            fgkEndCapCardCableConnectorToLayer);
6423  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6424                                            -                2.*fgkEndCapCardCableConnectorThickness
6425                                            -                            fgkEndCapCardCableConnectorDistance,
6426                                                                                 fgkEndCapCardCableConnectorLength[0]
6427                                            +                            fgkEndCapCardCableConnectorToLayer);
6428  for(Int_t i=0; i<2; i++){
6429         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6430     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6431  }
6432  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6433  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6434  electboardbackrot->SetAngles(90.,-90.,-90.);
6435  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6436                                                         +                fgkEndCapCardJMDConnectorLength[0]
6437                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6438  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6439                                                                                                                            *electboardbackrot);
6440  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6441  // Electronic Board Kapton Layer Positioning
6442  TGeoRotation* electlayerrot = new TGeoRotation();
6443  TGeoTranslation* electlayertrans[2];
6444  TGeoCombiTrans* electlayercombitrans[2];
6445  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6446  electlayerrot->SetAngles(90.,-90.,-90.);
6447  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6448                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6449  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6450                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6451                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6452  for(Int_t i=0; i<2; i++){
6453         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6454         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6455  }
6456  // Placing Volumes in Mother Interface Card Container
6457  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6458  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6459  for(Int_t i=0; i<2; i++){
6460         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6461  }
6462  /////////////////////////////////////////////////////////////
6463  // Generation of Card Interface Container
6464  /////////////////////////////////////////////////////////////
6465  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6466                                                   - fgkEndCapCardJMDConnectorLength[0]
6467                                                   - fgkEndCapInterfaceCardBThickness
6468                                                   - 9.*fgkEndCapStripConnectionThickness
6469                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6470  const Int_t kcardinterfacecontainervertexnumber = 14;
6471  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6472  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6473  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6474                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6475  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6476  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6477                                                                    + fgkEndCapStripConnectionThickness
6478                                                                    - fgkEndCapCardElectBoardLayerThickness
6479                                                                    - fgkEndCapCardCableConnectorWidth[0];
6480  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6481  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6482  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6483  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6484                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6485  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6486  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6487                                                                    + fgkEndCapInterfaceCardBThickness;
6488  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6489  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6490                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6491  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6492  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6493                                    - fgkEndCapInterfaceElectBoardCardBThickness
6494                                                                    + fgkEndCapCardJMDConnectorLength[0]
6495                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6496  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6497
6498  ycardinterfacecontainervertex[0]  = 0.;
6499  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6500                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6501                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6502  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6503  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6504                                                                    - fgkEndCapStripConnectionWidth;
6505  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6506  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6507  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6508  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6509                                                                    + fgkEndCapInterfaceCardBWidth[1]
6510                                                                    + fgkEndCapInterfaceCardBWidth[2];
6511  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6512  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6513  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6514  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6515  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6516  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6517  
6518  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6519  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6520                                                                                   xcardinterfacecontainervertex,
6521                                                                                   ycardinterfacecontainervertex);
6522  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6523                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6524  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6525                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6526  TGeoVolume** cardinterfacecontainer;
6527  cardinterfacecontainer = new TGeoVolume*[4];
6528  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6529                                                                                         interfacecardmothershape,fSSDAir); 
6530  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6531                                                                                         interfacecardmothershape,fSSDAir); 
6532  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6533                                                                                         interfacecardmothershape,fSSDAir); 
6534  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6535                                                                                         interfacecardmothershape,fSSDAir); 
6536  /////////////////////////////////
6537  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6538  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6539  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6540  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6541  /////////////////////////////////
6542  TGeoRotation* endcapstripconnectionrot[2];
6543  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6544  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6545  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6546  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6547                                                                         *                                 (*endcapstripconnectionrot[0]));
6548  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6549  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6550                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6551                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6552                                                                                         -endcapstripconnectionshape->GetDZ(),
6553                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6554  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6555  TGeoTranslation* cardinterfacetrans[9];
6556  TGeoHMatrix* cardinterfacematrix[9]; 
6557  for(Int_t i=0; i<7; i++){ 
6558         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6559                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6560                                                                                                 0.0,0.0);  
6561         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6562                                                    *                             (*endcapstripconnectionmatrix));
6563  }
6564  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6565                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6566                                                                                                 0.0,0.0);  
6567  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6568                                                 *                                 (*endcapstripconnectionmatrix));
6569  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6570                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6571                                                                                                 0.0,0.0);  
6572  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6573                                                 *                                 (*endcapstripconnectionmatrix));
6574
6575  for(Int_t i=0; i<4; i++){
6576         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6577                                                                            cardinterfacematrix[7]);                             
6578         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6579                                                                            cardinterfacematrix[8]);                             
6580  }
6581  TGeoTranslation* mothersupplycardtrans = 
6582                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6583                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6584                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6585  TGeoHMatrix* mothersupplycardmatrix[7];
6586  Int_t index[4] = {1,1,1,1};
6587  for(Int_t i=0; i<7; i++){
6588         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6589                                                         *                                 (*mothersupplycardtrans));
6590         for(Int_t j=0; j<4; j++){
6591                 switch(j){
6592                         case 0: //Layer5 EndCap Left Side  
6593                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6594                                                                                                    cardinterfacematrix[i]);                             
6595                                 if(i!=0){
6596                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6597                                                                                                            mothersupplycardmatrix[i]);                  
6598                                         index[j]++;
6599
6600                                 }
6601                         break;
6602                         case 1: //Layer5 EndCap Rigth Side  
6603                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6604                                                                                                    cardinterfacematrix[i]);                     
6605                                 if(i>0&&i<6){
6606                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6607                                                                                                            mothersupplycardmatrix[i]);                  
6608                                         index[j]++;
6609                                 }
6610                         break;
6611                         case 2: //Layer6 EndCap Left Side  
6612                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6613                                                                                                    cardinterfacematrix[i]);                             
6614                                 if(i!=6){
6615                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6616                                                                                                            mothersupplycardmatrix[i]);                  
6617                                         index[j]++;
6618                                 }
6619                         break;
6620                         case 3: //Layer6 EndCap Right Side  
6621                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6622                                                                                                    cardinterfacematrix[i]);                             
6623                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6624                                                                                                    mothersupplycardmatrix[i]);                  
6625                                 index[j]++;
6626                         break;
6627                 }
6628         }
6629  }
6630  // Positioning Interface 
6631  TGeoTranslation* motherinterfacecardtrans = 
6632                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6633                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6634                                                          -fgkEndCapCardElectBoardLayerThickness
6635                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6636  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6637                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6638  // Positioning Interface Card B 
6639  TGeoTranslation* interfacecardBmothertrans = 
6640                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6641                                                                                 + 2.*fgkEndCapStripConnectionThickness
6642                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6643                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6644                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6645  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6646                                                                                                                          interfacecardBmothertrans);
6647  // Positioning Stiffener 
6648  TGeoTranslation* endcapstiffenertrans = 
6649                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6650                                                                            +    2.0*fgkEndCapStripConnectionThickness
6651                                                                            +    fgkEndCapInterfaceCardBThickness
6652                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6653                                                                            +    stiffenertransx
6654                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6655                                                                                         endcapstiffenershape->GetDZ()
6656                                                                            -    0.5*(fgkEndCapStiffenerLength
6657                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6658  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6659  /////////////////////////////////////////////////////////////
6660  // Deallocating memory
6661  /////////////////////////////////////////////////////////////
6662  delete interfacecardBrot;
6663  delete interfacecardBtrans;
6664  delete electboardcardBtrans;
6665  delete electboardcardBrot; 
6666  delete jmdconnectorcardBrot;
6667  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6668  delete jmdconnectorot;
6669  delete jmdconnectortrans[1];
6670  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6671  delete cableconnectorcombitrans;
6672  delete electboardbacktrans;
6673  delete electboardbackrot;
6674  delete electlayerrot;
6675  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6676  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6677  delete mothersupplycardtrans;
6678  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6679  /////////////////////////////////////////////////////////////
6680  return cardinterfacecontainer;
6681  }
6682  ////////////////////////////////////////////////////////////////////////////////
6683  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6684   /////////////////////////////////////////////////////////////
6685   // Method returning EndCap Mother Volume
6686   /////////////////////////////////////////////////////////////
6687   const Int_t kendcapcoverplatesmallholenumber = 9;
6688   Double_t endcapmotherorigin[3];
6689   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6690                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6691                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6692   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6693                                           -                      fgkEndCapCoverPlateWidth[2]
6694                                           -       (kendcapcoverplatesmallholenumber-1)
6695                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6696                                           +  0.5*(fgkEndCapSideCoverLength[2]
6697                                           +               fgkEndCapCoverPlateWidth[1]
6698                                           -       fgkEndCapCoverPlateWidth[0])
6699                                           -      (fgkEndCapCoverPlateWidth[1]
6700                                           -       fgkEndCapCoverPlateWidth[0]);
6701   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6702                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6703                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6704                                                 +      fgkEndCapSideCoverWidth[1]
6705                                                 +      fgkEndCapSideCoverThickness
6706                                                 +      fgkEndCapKaptonFoilThickness);
6707   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6708                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6709                                                           +              2.0* fgkEndCapSideCoverThickness),
6710                                                                          0.5* (fgkEndCapSideCoverLength[2]
6711                                                           +                    fgkEndCapCoverPlateWidth[1]
6712                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6713                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6714                                                       +                                    fgkEndCapSideCoverWidth[1]
6715                                                           +                                       fgkEndCapSideCoverThickness
6716                                                       +                                   fgkEndCapKaptonFoilThickness),
6717                                                                                          endcapmotherorigin);
6718   TGeoVolume** endcapassembly;  
6719   endcapassembly = new TGeoVolume*[4];
6720   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6721                                                                                         endcapmothershape,fSSDAir); 
6722   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6723                                                                                         endcapmothershape,fSSDAir); 
6724   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6725                                                                                         endcapmothershape,fSSDAir); 
6726   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6727                                                                                         endcapmothershape,fSSDAir); 
6728  /////////////////////////////////
6729  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6730  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6731  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6732  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6733  /////////////////////////////////
6734   /////////////////////////////////////////////////////
6735   // Placing Endcap Cover Plate
6736   /////////////////////////////////////////////////////
6737   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6738   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6739   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6740   TGeoCombiTrans* endcapcoverplatecombitrans = 
6741                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6742                                                                                          endcapcoverplaterot);
6743   TGeoTranslation* endcapcoverplatetrans = 
6744                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6745   TGeoHMatrix* endcapcoverplatematrix = 
6746                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6747                                                                           *       (*endcapcoverplatecombitrans));
6748   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6749   /////////////////////////////////////////////////////
6750   // Placing Endcap Side Cover
6751   /////////////////////////////////////////////////////
6752   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6753   TGeoRotation* endcapsidecoverot[2];
6754   TGeoCombiTrans* endcapsidecovercombitrans[3];
6755   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6756   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6757   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6758                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6759                                                                                         - fgkEndCapCoverPlateWidth[2]
6760                                                                                     - (kendcapcoverplatesmallholenumber-1)
6761                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6762                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6763                                                                                         + fgkEndCapSideCoverLength[2],
6764                                                                                           0.5*(fgkEndCapSideCoverThickness
6765                                                                                         + fgkEndCapCoverPlateThickness)
6766                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6767                                                                                           endcapsidecoverot[0]);
6768   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6769   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6770                                                                                                         0.5*fgkEndCapCoverPlateThickness
6771                                                                                                         -fgkEndCapSideCoverWidth[1],
6772                                                                                                         endcapsidecoverot[1]);
6773   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6774                                                                                                         +fgkEndCapCoverPlateLength[3]
6775                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6776                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6777                                                                                                         0.5*fgkEndCapCoverPlateThickness
6778                                                                                                         -fgkEndCapSideCoverWidth[1],
6779                                                                                                         endcapsidecoverot[1]);
6780   TGeoHMatrix* endcapsidecovermatrix[2];
6781   for(Int_t i=0; i<2; i++){
6782    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6783                                                         *                                 (*endcapsidecovercombitrans[0]));
6784         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6785                                                                                                                 endcapsidecovermatrix[i]);
6786   }
6787   /////////////////////////////////////////////////////
6788   // Placing Endcap Cooling Tube
6789   /////////////////////////////////////////////////////
6790   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6791   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6792   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6793   TGeoCombiTrans* endcapccolingtubecombitrans 
6794                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6795                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6796                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6797                                                 - fgkEndCapCoolingTubeToCoverSide,
6798                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6799                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6800   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6801                                                                                                           endcapccolingtubecombitrans);
6802   /////////////////////////////////////////////////////
6803   // Placing Screws 
6804   /////////////////////////////////////////////////////
6805   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6806                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6807   Int_t screwcoverplatedgesnumber[2] = {20,20};
6808   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6809                                                                                 fgkEndCapCoverPlateThickness
6810                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6811   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6812                                                                                                  screwcoverplatedgesnumber,
6813                                                                                                  screwcoverplatesection);
6814   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6815                                                                                            screwcoverplateshape,
6816                                                                                            fSSDCoolingTubePhynox); 
6817   screwcoverplate->SetLineColor(12);
6818   Double_t transx[4] = {0,
6819                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6820                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6821                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6822                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6823                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6824   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6825 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6826   TGeoTranslation*** endcapcoverplatescrewtrans;
6827   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6828   Int_t index = 0;
6829   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6830         endcapcoverplatescrewtrans[i] = 
6831                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6832     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6833                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6834         if(index==1||index==9||index==28||index==36){
6835                         endcapcoverplatescrewtrans[i][j] = 
6836                                 new TGeoTranslation(transx[i],
6837                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6838                                                                         fgkEndCapSideCoverThickness);
6839                 }
6840                 else{
6841                         endcapcoverplatescrewtrans[i][j] = 
6842                                 new TGeoTranslation(transx[i],
6843                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6844                                                                         0.);
6845                 }
6846             if(index!=19) 
6847                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6848                                                                                           endcapcoverplatescrewtrans[i][j]);
6849         }
6850   }
6851   /////////////////////////////////////////////////////
6852   // Placing Cover Plate Clips 
6853   /////////////////////////////////////////////////////
6854   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6855                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6856                                                                                                          0.5*fgkEndCapSideCoverThickness);
6857   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6858                                                                                                         endcapcoverplateclipshape,
6859                                                                                                         fSSDCoolingTubePhynox);
6860   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6861                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6862                                                                                                          0.5*fgkEndCapSideCoverThickness);
6863   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6864                                                                                                         endcapcoverplatedownclipshape,
6865                                                                                                         fSSDCoolingTubePhynox);
6866   TGeoTranslation* endcapcoverplatecliptrans[4];
6867   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6868                                                            -                     fgkEndCapCoverPlateLength[0]
6869                                                            -                     fgkEndCapSideCoverThickness,
6870                                                                                                          0.0,
6871                                                                                                  0.5*(fgkEndCapSideCoverThickness
6872                                                            +                                              fgkEndCapCoverPlateThickness));
6873   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6874                                                            -                     fgkEndCapCoverPlateLength[0]
6875                                                            -                     fgkEndCapSideCoverThickness,
6876                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6877                                                            *                                     fgkEndCapSideCoverWidth[5],
6878                                                                                                  0.5*(fgkEndCapSideCoverThickness
6879                                                            +                                              fgkEndCapCoverPlateThickness));
6880   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6881                                                            -                     fgkEndCapCoverPlateLength[0]
6882                                                            +                                     fgkEndCapCoverPlateLength[1]
6883                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6884                                                            -                                     fgkEndCapCoverPlateClipLength
6885                                                            +                                 fgkEndCapSideCoverThickness,
6886                                                                                                          0.0,
6887                                                                                                  0.5*(fgkEndCapSideCoverThickness
6888                                                            +                                              fgkEndCapCoverPlateThickness));
6889   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6890                                                            -                     fgkEndCapCoverPlateLength[0]
6891                                                            +                                     fgkEndCapCoverPlateLength[1]
6892                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6893                                                            -                                     fgkEndCapCoverPlateClipLength
6894                                                            +                                 fgkEndCapSideCoverThickness,
6895                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6896                                                            *                                     fgkEndCapSideCoverWidth[5],
6897                                                                                                  0.5*(fgkEndCapSideCoverThickness
6898                                                            +                                              fgkEndCapCoverPlateThickness));
6899   endcapcoverplateclip->SetLineColor(fColorPhynox);
6900   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6901   for(Int_t i=0; i<4; i++) 
6902         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6903                                                                                                    endcapcoverplatecliptrans[i]);  
6904   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6905   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6906                                                                    -                     fgkEndCapCoverPlateLength[0]
6907                                                                    -                     fgkEndCapSideCoverThickness,
6908                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6909                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6910                                                                                                         0.5*(fgkEndCapSideCoverThickness
6911                                                                +                                         fgkEndCapCoverPlateThickness)
6912                                                                    -                     fgkEndCapSideCoverWidth[1]
6913                                                                    -                                     fgkEndCapSideCoverThickness);
6914   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6915                                                                    -                     fgkEndCapCoverPlateLength[0]
6916                                                                    -                     fgkEndCapSideCoverThickness,
6917                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6918                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6919                                                                    +                            fgkEndCapSideCoverLength[2]
6920                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6921                                                                                                         0.5*(fgkEndCapSideCoverThickness
6922                                                                +                                         fgkEndCapCoverPlateThickness)
6923                                                                    -                     fgkEndCapSideCoverWidth[1]
6924                                                                    -                                     fgkEndCapSideCoverThickness);
6925   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6926                                                                    -                     fgkEndCapCoverPlateLength[0]
6927                                                                    +                     fgkEndCapSideCoverThickness
6928                                                                    +                     fgkEndCapCoverPlateLength[1]
6929                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6930                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6931                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6932                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6933                                                                                                         0.5*(fgkEndCapSideCoverThickness
6934                                                                +                                         fgkEndCapCoverPlateThickness)
6935                                                                    -                     fgkEndCapSideCoverWidth[1]
6936                                                                    -                                     fgkEndCapSideCoverThickness);
6937   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6938                                                                    -                     fgkEndCapCoverPlateLength[0]
6939                                                                    +                     fgkEndCapSideCoverThickness
6940                                                                    +                     fgkEndCapCoverPlateLength[1]
6941                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6942                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6943                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6944                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6945                                                                    +                                 fgkEndCapSideCoverLength[2]
6946                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6947                                                                                                         0.5*(fgkEndCapSideCoverThickness
6948                                                                +                                         fgkEndCapCoverPlateThickness)
6949                                                                    -                     fgkEndCapSideCoverWidth[1]
6950                                                                    -                                     fgkEndCapSideCoverThickness);
6951   for(Int_t i=0; i<4; i++)
6952         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6953                                                                                                    endcapcoverplatedowncliptrans[i]);
6954   /////////////////////////////////////////////////////
6955   // Placing Kapton Foil
6956   /////////////////////////////////////////////////////
6957   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6958                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6959                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6960   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6961                                                                                                 endcapkaptonfoilshape,
6962                                                                                                 fSSDKaptonFlexMedium);
6963   endcapkaptonfoil->SetLineColor(8);
6964   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6965                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6966                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6967                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6968                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6969                                                                              -                     fgkEndCapSideCoverWidth[1]
6970                                                                                  -                     fgkEndCapSideCoverThickness);
6971   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6972   /////////////////////////////////////////////////////////////
6973   // Placing Electronic Tubes
6974   /////////////////////////////////////////////////////////////
6975   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6976                                                                              - fgkEndCapInterfaceCardBThickness
6977                                                                              - 9.*fgkEndCapStripConnectionThickness
6978                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6979                                                                                fgkEndCapKaptonFoilWidth
6980                                                                              - fgkEndCapInterfaceCardBThickness
6981                                                                              - 9.*fgkEndCapStripConnectionThickness
6982                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6983                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6984   TGeoVolume* endcapeffectivecables[2];
6985   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6986                                                                                          fgkEndCapEffectiveCableRadiusMax,
6987                                                                                          endcapeffectivecableswidth[0],
6988                                                                                          10,"EndCapEffectiveCables1"); 
6989   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6990                                                                                          fgkEndCapEffectiveCableRadiusMax,
6991                                                                                          endcapeffectivecableswidth[1],
6992                                                                                          25,"EndCapEffectiveCables2"); 
6993   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6994   TGeoTranslation* endcapeffectivecablestrans[2];
6995   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6996                                           -                                                        0.5*endcapeffectivecableswidth[0]
6997                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6998                                           -                                                               fgkEndCapCoverPlateWidth[2]
6999                                           -                                             (kendcapcoverplatesmallholenumber-1)
7000                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7001                                           +                                             fgkEndCapSideCoverLength[2],
7002                                           -                     0.5*fgkEndCapCoverPlateThickness
7003                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
7004                                           -                                              fgkEndCapInterfaceCardBWidth[0]
7005                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
7006   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
7007                                           -                                                        0.5*endcapeffectivecableswidth[1]
7008                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
7009                                           -                                                               fgkEndCapCoverPlateWidth[2]
7010                                           -                                             (kendcapcoverplatesmallholenumber-1)
7011                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7012                                           +                                         fgkEndCapSideCoverLength[2],
7013                                           -                     0.5*fgkEndCapCoverPlateThickness
7014                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
7015                                           -                                              fgkEndCapInterfaceCardBWidth[0])
7016                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
7017   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
7018   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
7019   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
7020                                                                                                                    *endcapeffectivecablesrot);
7021   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
7022                                                                                                                    *endcapeffectivecablesrot);
7023 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
7024 //                                                                                                        endcapeffectivecablescombitrans[0]);
7025   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
7026                                                                                                           endcapeffectivecablescombitrans[1]);
7027   /////////////////////////////////////////////////////////////
7028   // Placing End Cap Cards
7029   /////////////////////////////////////////////////////////////
7030   TGeoVolume** endcapcards = GetEndCapCards();
7031   TGeoRotation* endcapcardsrot[2];
7032   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
7033   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
7034   TGeoTranslation* endcapcardstrans[2]; 
7035   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
7036                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
7037   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
7038   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
7039   TGeoHMatrix* endcapcardsmatrix[2];
7040   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
7041   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
7042                                                   - fgkEndCapCardJMDConnectorLength[0]
7043                                                   - fgkEndCapInterfaceCardBThickness
7044                                                   - 9.*fgkEndCapStripConnectionThickness
7045                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
7046   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
7047                                           -                                             fgkEndCapCoverPlateLength[0]
7048                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
7049                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
7050                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
7051                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
7052                                           -                                                               fgkEndCapInterfaceCardBThickness
7053                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
7054                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
7055                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
7056                                           -                                                               fgkEndCapCoverPlateWidth[2]
7057                                           -                                             (kendcapcoverplatesmallholenumber-1)
7058                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7059                                           +                     fgkEndCapKaptonFoilWidth,
7060                                                                                           0.5*fgkEndCapCoverPlateThickness
7061                                           -                                                     fgkEndCapSideCoverWidth[1]);
7062   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
7063   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
7064    /////////////////////////////////////////////////////////////
7065   // Deallocating memory
7066   /////////////////////////////////////////////////////////////
7067   delete endcapcoverplaterot;
7068   delete endcapcoverplatecombitrans;
7069   delete endcapcoverplatetrans;
7070   for(Int_t i=0; i<3; i++){
7071    delete endcapsidecovercombitrans[i];
7072    if(i<2) delete endcapsidecoverot[i]; 
7073   }
7074   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
7075   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
7076   delete endcapcardsmatrix[0];
7077   return endcapassembly;
7078  } 
7079  ////////////////////////////////////////////////////////////////////////////////
7080  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
7081                                                                                                                         Double_t radiusmax, 
7082                                                                                                                         Double_t width, 
7083                                                                                                                         Int_t ncables,
7084                                                                                                                         const char* volname){
7085   /////////////////////////////////////////////////////////////
7086   // Generating EndCap High Voltage Tubes 
7087   /////////////////////////////////////////////////////////////
7088   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
7089   Double_t effectiveouteradius = TMath::Sqrt(TMath::Power(effectiveinneradius,2.)
7090                                                            +             TMath::Power(radiusmax,2.)
7091                                -             TMath::Power(radiusmin,2.));
7092   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
7093   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
7094                                                                                                    effectiveouteradius,0.5*width);
7095   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
7096                                                                                                 effectiveinnertubeshape,
7097                                                                                                 fSSDStiffenerConnectorMedium);
7098   effectiveinnertube->SetLineColor(41);
7099   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
7100                                                                                                 effectiveoutertubeshape,
7101                                                                                                 fSSDKaptonChipCableMedium);
7102   effectiveoutertube->SetLineColor(39);
7103   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
7104   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
7105   effectivemothertube->AddNode(effectiveinnertube,1);
7106   effectivemothertube->AddNode(effectiveoutertube,1);
7107   return effectivemothertube;
7108  } 
7109  ////////////////////////////////////////////////////////////////////////////////
7110  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
7111   /////////////////////////////////////////////////////////////
7112   // Generating EndCap Support Layer 5 and Layer 6 
7113   /////////////////////////////////////////////////////////////
7114   const Int_t knedges = 5;
7115   ///////////////////////////////////////////////
7116   // Setting the vertices for TGeoXtru Up Volume
7117   ///////////////////////////////////////////////
7118   const Int_t klayernumber = 2;
7119   Double_t xupvertex[klayernumber][knedges+3];
7120   Double_t yupvertex[klayernumber][knedges+3];
7121   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
7122   Double_t middledgeangle[klayernumber] = {0.0,0.0};
7123   Double_t middlepsi[klayernumber] = {0.0,0.0};
7124   for(Int_t i=0; i<klayernumber; i++){
7125         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
7126         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
7127         xupvertex[i][2] = -xupvertex[i][1];
7128         xupvertex[i][3] = -xupvertex[i][0];
7129
7130         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
7131         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
7132         yupvertex[i][2] =  yupvertex[i][1];
7133         yupvertex[i][3] =  yupvertex[i][0];
7134         
7135     middledgeangle[i] = upedgeangle[i]/knedges;
7136     middlepsi[i] = 90.0-0.5*upedgeangle[i];
7137     for(Int_t j=1; j<knedges; j++){
7138                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
7139                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
7140         }
7141   }
7142   ////////////////////////////////////
7143   // Generating Up TGeoXtru
7144   ////////////////////////////////////
7145   TGeoXtru* upendcapsupportshape[klayernumber];
7146   TGeoVolume* upendcapsupport[klayernumber]; 
7147   char upendcapsupportname[100]; 
7148   for(Int_t i=0; i<klayernumber; i++){
7149    upendcapsupportshape[i] = new TGeoXtru(2);
7150    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
7151    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
7152    upendcapsupportshape[i]->DefineSection(0,0.);
7153    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7154    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
7155                                                                         fSSDSupportRingAl);
7156    upendcapsupport[i]->SetLineColor(5);
7157   }
7158   ///////////////////////////////////////////////
7159   // Setting the vertices for TGeoXtru Down Volume
7160   ///////////////////////////////////////////////
7161   Double_t xdownvertex[klayernumber][2*(knedges+1)];
7162   Double_t ydownvertex[klayernumber][2*(knedges+1)];
7163   for(Int_t i=0; i<klayernumber; i++){
7164         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
7165         xdownvertex[i][1] =  xupvertex[i][0];
7166         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
7167         ydownvertex[i][1] =  yupvertex[i][0];
7168         for(Int_t j=0; j<knedges; j++){
7169                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
7170                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
7171         } 
7172         for(Int_t j=0; j<knedges; j++){
7173                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7174                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
7175                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7176                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7177         }
7178   }
7179   ////////////////////////////////////
7180   // Generating Down TGeoXtru
7181   ////////////////////////////////////  
7182   TGeoXtru* downendcapsupportshape[klayernumber];
7183   TGeoVolume* downendcapsupport[klayernumber]; 
7184   char downendcapsupportname[100]; 
7185   for(Int_t i=0; i<klayernumber; i++){
7186         downendcapsupportshape[i] = new TGeoXtru(2);
7187     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7188         downendcapsupportshape[i] = new TGeoXtru(2);
7189         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7190     if(i==0){
7191                 downendcapsupportshape[i]->DefineSection(0,0.);
7192                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7193     }
7194         else{
7195                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7196                                                                  -                 fgkEndCapSupportLowWidth[i]);
7197                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7198         }
7199     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7200                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7201         downendcapsupport[i]->SetLineColor(5);
7202   }
7203   ///////////////////////////////////////////////
7204   // Setting TGeoPgon Volume
7205   ///////////////////////////////////////////////
7206   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7207                                                                                                    fgkSSDLay6LadderNumber};
7208   TGeoPgon* endcapsupportmothershape[klayernumber];
7209   TGeoVolume** endcapsupportmother;
7210   endcapsupportmother = new TGeoVolume*[klayernumber];
7211   char endcapsupportmothername[100];
7212   for(Int_t i=0; i<klayernumber; i++){
7213         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7214     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7215         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7216     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7217                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7218     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7219                                                                                         fSSDAir);       
7220   }
7221   ////////////////////////////////////
7222   TGeoRotation** endcapsupportrot[klayernumber];
7223   for(Int_t i=0; i<2; i++){
7224         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7225         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7226            endcapsupportrot[i][j] = new TGeoRotation();
7227            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7228        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7229        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7230         }
7231   }
7232   return endcapsupportmother;
7233  } 
7234  ////////////////////////////////////////////////////////////////////////////////
7235  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7236   /////////////////////////////////////////////////////////////
7237   // Setting End Cap Support Layer 5 and 6. 
7238   /////////////////////////////////////////////////////////////
7239   const Int_t kendcapcoverplatesmallholenumber = 9;
7240   const Int_t klayernumber = 2;
7241   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7242                                                                                                    fgkSSDLay6LadderNumber};
7243   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7244                                                                                 360.0/kssdlayladdernumber[1]};
7245   TGeoVolume** endcapsupport = EndCapSupport();
7246   TGeoVolume** endcapassembly = GetEndCapAssembly();
7247   TGeoPgon* endcapsupportshape[klayernumber];
7248   Double_t* radiusmin[klayernumber];
7249   Double_t* radiusmax[klayernumber];
7250   for(Int_t i=0; i<klayernumber; i++){
7251     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7252         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7253         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7254   }  
7255   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7256   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7257                                                                           endcapassemblyshape->GetDY(),
7258                                                                           endcapassemblyshape->GetDZ()};
7259   ///////////////////////////////////////////////
7260   // Setting TGeoPgon Volume for Mother Container
7261   ///////////////////////////////////////////////
7262   TGeoPgon* endcapsupportsystemshape[klayernumber];
7263   char endcapsupportsystemothername[100];
7264   for(Int_t i=0; i<klayernumber; i++){
7265         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7266     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7267         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7268                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7269                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7270                                                                                            +2.*endcapassemblycenter[2])
7271                                                                                            /CosD(0.5*upedgeangle[i]));  
7272     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7273                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7274                                                                                              - fgkEndCapCoverPlateWidth[0]),
7275                                                                                            *radiusmin[i],
7276                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7277                                                                                            +2.*endcapassemblycenter[2])
7278                                                                                            /CosD(0.5*upedgeangle[i]));
7279   }
7280   fgkEndCapSupportSystem = new TGeoVolume*[4];
7281   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7282                                                                           endcapsupportsystemshape[0],fSSDAir); 
7283   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7284                                                                           endcapsupportsystemshape[0],fSSDAir); 
7285   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7286                                                                           endcapsupportsystemshape[1],fSSDAir); 
7287   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7288                                                                           endcapsupportsystemshape[1],fSSDAir); 
7289   ///////////////////////////////////////////////
7290   TGeoTranslation* endcapassemblytrans[klayernumber];
7291   for(Int_t i=0; i<klayernumber; i++)
7292         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7293                                                                            -  fgkEndCapSideCoverThickness
7294                                                                            +  endcapassemblycenter[0],
7295                                                                            -  0.5*fgkEndCapCoverPlateThickness
7296                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7297                                                                            +  2.0*endcapassemblycenter[2]
7298                                                                            +  0.5*fgkEndCapSupportLength[i]
7299                                                                            /  TanD(0.5*upedgeangle[i]),
7300                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7301                                                                            -  fgkEndCapCoverPlateWidth[2]
7302                                                                            - (kendcapcoverplatesmallholenumber-1)
7303                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7304   TGeoRotation** endcapassemblyrot[klayernumber];
7305   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7306   for(Int_t i=0; i<klayernumber; i++){
7307    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7308    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7309    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7310    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7311    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7312    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7313    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7314    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7315         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7316         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7317    }
7318   }
7319   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7320                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7321   for(Int_t i=0; i<2*klayernumber; i++){
7322         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7323                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7324                                                                                                                                            endcapassemblymatrix[1][j+2]);
7325         }
7326         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7327   }
7328    /////////////////////////////////////////////////////////////
7329   // Deallocating memory
7330   /////////////////////////////////////////////////////////////
7331   for(Int_t i=0; i<klayernumber; i++){
7332         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7333                 delete endcapassemblyrot[i][j];
7334         }
7335         delete endcapassemblyrot[i];
7336         delete endcapassemblymatrix[i][0];
7337         delete endcapassemblymatrix[i][1];
7338   }
7339   /////////////////////////////////////////////////////////////
7340   }
7341   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7342   /////////////////////////////////////////////////////////////
7343   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7344   /////////////////////////////////////////////////////////////
7345   if (! moth) {
7346     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer5, mother is null!\n");
7347     return;
7348   };
7349   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7350   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7351   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7352                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7353                                                                            +            fgkEndCapSupportCenterLay5Position
7354                                                                            -            fgkEndCapSideCoverLength[2]);
7355   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7356                                                                                                 fgkEndCapSideCoverLength[2]
7357                                                                            -        fgkEndCapSupportCenterLay5Position
7358                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7359   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7360   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7361   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7362         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7363   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7364   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7365    /////////////////////////////////////////////////////////////
7366   // Deallocating memory
7367   /////////////////////////////////////////////////////////////
7368   delete endcapsupportsystemrot;
7369   delete endcapsupportsystemITSCentertrans[1];
7370  }
7371   /////////////////////////////////////////////////////////////
7372   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7373   /////////////////////////////////////////////////////////////
7374   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7375   /////////////////////////////////////////////////////////////
7376   if (! moth) {
7377     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer6, mother is null!\n");
7378     return;
7379   };
7380   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7381   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7382   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7383                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7384                                                                            +            fgkEndCapSupportCenterLay6Position
7385                                                                            -            fgkEndCapSideCoverLength[2]);
7386   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7387                                                                                                 fgkEndCapSideCoverLength[2]
7388                                                                            -        fgkEndCapSupportCenterLay6Position
7389                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7390   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7391   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7392   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7393         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7394   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7395   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7396    /////////////////////////////////////////////////////////////
7397   // Deallocating memory
7398   /////////////////////////////////////////////////////////////
7399   delete endcapsupportsystemrot;
7400   delete endcapsupportsystemITSCentertrans[1];
7401  }
7402  ////////////////////////////////////////////////////////////////////////////////
7403  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7404   /////////////////////////////////////////////////////////////
7405   // Setting Ladder Support of Layer 5. 
7406   /////////////////////////////////////////////////////////////
7407   if (! moth) {
7408     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer5, mother is null!\n");
7409     return;
7410   };
7411   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7412   fMotherVol = moth;
7413   TGeoTranslation* centerITSRingSupportLay5trans[2];
7414   for(Int_t i=0; i<2; i++){
7415         centerITSRingSupportLay5trans[i] = 
7416                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7417     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7418   }
7419  }
7420  ////////////////////////////////////////////////////////////////////////////////
7421  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7422   /////////////////////////////////////////////////////////////
7423   // Setting Ladder Support of Layer 6. 
7424   /////////////////////////////////////////////////////////////
7425   if (! moth) {
7426     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer6, mother is null!\n");
7427     return;
7428   };
7429   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7430   fMotherVol = moth;
7431   TGeoTranslation* centerITSRingSupportLay6trans[2];
7432   for(Int_t i=0; i<2; i++){
7433         centerITSRingSupportLay6trans[i] = 
7434                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7435     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7436   }
7437  }
7438  ////////////////////////////////////////////////////////////////////////////////
7439  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7440   /////////////////////////////////////////////////////////////
7441   // Setting Ladder Support of Layer 6. 
7442   /////////////////////////////////////////////////////////////
7443   if (! moth) {
7444     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cone, mother is null!\n");
7445     return;
7446   };
7447   if(!fSSDCone) SetSSDCone();
7448   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7449                                                                 +                                         fgkSSDCentralAL3SupportLength);
7450     moth->AddNode(fSSDCone,1,ssdconetrans);
7451 }
7452  ////////////////////////////////////////////////////////////////////////////////
7453  void AliITSv11GeometrySSD::SetSSDCone(){
7454   /////////////////////////////////////////////////////////////
7455   // Method generating SSDCone 
7456   /////////////////////////////////////////////////////////////
7457   if(!fCreateMaterials) CreateMaterials();
7458   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7459   Double_t ssdpconesectionradiusmax[16];
7460   Double_t ssdpconesectionradiusmin[16];
7461   Double_t ssdpconezsection[16];
7462   TGeoPcon* ssdpconelittleholeshape[8];
7463   TGeoVolume* ssdpconelittlehole[8];
7464   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7465   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7466   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7467                                                       / SinD(fgkSSDPConeAngle)
7468                                                           + ssdpconesectionradiusmin[0];
7469   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7470                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7471                                                           / SinD(fgkSSDPConeAngle);
7472   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7473   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7474                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7475   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7476   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7477                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7478   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7479   ssdpconelittlehole[0]->SetLineColor(4);
7480   /////////////////////////////////////////////////////////////
7481   ssdpconezsection[2] = ssdpconezsection[1];  
7482   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7483   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7484   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7485                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7486                                                           / SinD(fgkSSDPConeAngle);
7487   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7488                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7489   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7490                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7491   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7492                                                                    * TMath::RadToDeg();
7493   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7494                                                                                                           60.-ssdpconelittleholeangle,2);    
7495   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7496                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7497   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7498   ssdpconelittlehole[1]->SetLineColor(4);
7499   TGeoRotation* ssdconelittleholerot[6];
7500   for(Int_t i=0; i<6; i++){
7501         ssdconelittleholerot[i] = new TGeoRotation();
7502     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7503   }
7504   /////////////////////////////////////////////////////////////
7505   ssdpconezsection[4] = ssdpconezsection[3];  
7506   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7507   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7508   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7509                                                           * CosD(fgkSSDPConeAngle)
7510                                                           / SinD(fgkSSDPConeAngle);
7511   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7512   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7513                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7514   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7515   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7516                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7517   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7518   ssdpconelittlehole[2]->SetLineColor(4);
7519   ///////////////////////////////////////////////////
7520   ssdpconezsection[6] = ssdpconezsection[5];  
7521   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7522   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7523   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7524                                                           -ssdpconezsection[0]
7525                                                           * CosD(fgkSSDPConeAngle)
7526                                                           / SinD(fgkSSDPConeAngle);
7527   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7528   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7529                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7530   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7531                                                                    * TMath::RadToDeg();
7532   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7533                                                                                                           45.-ssdpconemiddleholeangle,2);    
7534   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7535                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7536   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7537   ssdpconelittlehole[3]->SetLineColor(4);
7538   TGeoRotation* ssdconemiddleholerot[8];
7539   for(Int_t i=0; i<8; i++){
7540         ssdconemiddleholerot[i] = new TGeoRotation();
7541     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7542   }
7543   /////////////////////////////////////////////////////////////
7544   ssdpconezsection[8] = ssdpconezsection[7];  
7545   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7546   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7547   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7548                                                           * CosD(fgkSSDPConeAngle)
7549                                                           / SinD(fgkSSDPConeAngle);
7550   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7551   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7552                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7553   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7554   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7555                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7556   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7557   ssdpconelittlehole[4]->SetLineColor(4);
7558   /////////////////////////////////////////////////////////////
7559   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7560   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7561                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7562                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7563                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7564                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7565   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7566   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7567                                                                                  * TMath::RadToDeg();
7568   ssdpconezsection[10] = ssdpconezsection[9];
7569   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7570   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7571   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7572                                                           * CosD(fgkSSDPConeAngle)
7573                                                           / SinD(fgkSSDPConeAngle);
7574   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7575   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7576                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7577   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7578                                                                                         ssdpconetrapezoidsectionangle,2);    
7579   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7580                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7581   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7582   ssdpconelittlehole[5]->SetLineColor(4);
7583   TGeoRotation* ssdconeupradiusrot[8];
7584   for(Int_t i=0; i<8; i++){
7585         ssdconeupradiusrot[i] = new TGeoRotation();
7586     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7587   }
7588   /////////////////////////////////////////////////////////////
7589   ssdpconezsection[12] = ssdpconezsection[11];
7590   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7591   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7592   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7593   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7594   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7595   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7596   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7597                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7598   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7599   ssdpconelittlehole[6]->SetLineColor(4);
7600   /////////////////////////////////////////////////////////////
7601   ssdpconezsection[14] = 0.0;
7602   ssdpconezsection[15] = ssdpconezsection[0];
7603   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7604   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7605   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7606   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7607   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7608   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7609                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7610   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7611   ssdpconelittlehole[7]->SetLineColor(4);
7612   /////////////////////////////////////////////////////////////
7613   TGeoTube* ssdtubeconeshape[2];
7614   TGeoVolume* ssdtubecone[2];
7615   TGeoTranslation* ssdtubeconetrans[2];
7616   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7617                                                                            fgkSSDPConeExternalRadius,
7618                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7619   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7620                                                                            0.5*ssdpconezsection[0]); 
7621   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7622   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7623   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7624                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7625                                           + ssdpconezsection[13]);
7626   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7627   ssdtubecone[0]->SetLineColor(4);
7628   ssdtubecone[1]->SetLineColor(4);
7629   /////////////////////////////////////////////////////////////
7630   // Mother Volume Container
7631   /////////////////////////////////////////////////////////////
7632   Double_t ssdconemotherradiusmin[8];
7633   Double_t ssdconemotherradiusmax[8];
7634   Double_t ssdconemothersection[8]; 
7635   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7636   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7637   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7638   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7639   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7640   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7641   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7642   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7643   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7644   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7645   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7646   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7647   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7648   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7649   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7650   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7651   ssdconemothersection[0] = 0.0;
7652   ssdconemothersection[1] = ssdpconezsection[0];
7653   ssdconemothersection[2] = ssdpconezsection[0];
7654   ssdconemothersection[3] = ssdpconezsection[11];
7655   ssdconemothersection[4] = ssdpconezsection[11];
7656   ssdconemothersection[5] = ssdpconezsection[13];
7657   ssdconemothersection[6] = ssdpconezsection[13];
7658   ssdconemothersection[7] = fgkSSDPConeLength;
7659   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7660   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7661                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7662   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7663   /////////////////////////////////////////////////////////////
7664   //Placing the Volumes into Mother 
7665   /////////////////////////////////////////////////////////////
7666   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7667   for(Int_t i=0; i<6; i++){
7668         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7669   }
7670   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7671   for(Int_t i=0; i<8; i++){
7672     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7673   }
7674   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7675   for(Int_t i=0; i<8; i++){
7676     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7677   }
7678   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7679   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7680   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7681   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7682   /////////////////////////////////////////////////////////////
7683   // ITS General Support
7684   /////////////////////////////////////////////////////////////
7685   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7686                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7687   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7688   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7689                                                                              - fgkSSDCentralAL3SupportLength);
7690   ssdcentralsupport->SetLineColor(4);
7691   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7692   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7693                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7694   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7695   TGeoTranslation* ssdcentralal3supportrans[3]; 
7696   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7697   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7698                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7699   ssdcentralal3support->SetLineColor(4);
7700   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7701   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7702   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7703   Double_t ssdpconcentralradiusmin[2];
7704   Double_t ssdpconcentralradiusmax[2];
7705   Double_t ssdpconcentralsection[2];
7706   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7707   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7708   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7709   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7710   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7711   ssdpconcentralsection[1] = 0.;
7712   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7713                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7714   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7715   ssdpconcentralal3->SetLineColor(4);
7716   fSSDCone->AddNode(ssdpconcentralal3,1);
7717   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7718   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7719   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7720                                                                 -2.*fgkSSDCentralAL3SupportLength);
7721   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7722                                                                                                                      *ssdcentralal3supportrot);
7723   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7724   TGeoRotation* ssdconemotherot = new TGeoRotation();
7725   ssdconemotherot->SetAngles(90.,180.,-90.);
7726   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7727                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7728   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7729   fSSDCone->AddNode(ssdconemother,1);
7730   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7731   /////////////////////////////////////////////////////////////
7732   // Deallocating memory
7733   /////////////////////////////////////////////////////////////
7734   delete ssdcentralal3supportrot;
7735   delete ssdcentralal3supportrans[2];
7736   delete ssdconemotherot;
7737   delete ssdconemothertrans;
7738   /////////////////////////////////////////////////////////////
7739  }
7740  ////////////////////////////////////////////////////////////////////////////////
7741  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7742   /////////////////////////////////////////////////////////////
7743   // Setting SSD Cables
7744   /////////////////////////////////////////////////////////////
7745   if (! moth) {
7746     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cables, mother is null!\n");
7747     return;
7748   };
7749   TGeoVolume* ssdcables = SetSSDCables();
7750   moth->AddNode(ssdcables,1);
7751 }
7752  ////////////////////////////////////////////////////////////////////////////////
7753  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7754   /////////////////////////////////////////////////////////////
7755   // Method generating SSDCables
7756   /////////////////////////////////////////////////////////////
7757   // SSD Layer 5 Cables
7758   //////////////////////////////////////////////////////////////////////////////////////////////////
7759   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7760   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7761   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7762   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7763   //////////////////////////////////////////////////////////////////////////////////////////////////
7764   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7765   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7766                                                                             -  fgkSSDLowerPConeRadius)
7767                                                                             * TanD(fgkSSDPConeAngle);
7768   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7769                                                                               + fgkEndCapSupportCenterLay5Position
7770                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7771   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7772                                                                            - ssdcableslay5startconedistance; 
7773   ssdcablelay5rightsidelength *= ssdcablesfactor;
7774   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7775   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7776                                                                                                 ssdcableslay5rightsideradiusmax,
7777                                                                                                 0.5*ssdcablelay5rightsidelength); 
7778   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7779                                                                                                          ssdcablelay5rightubeshape,
7780                                                                                                          fSSDCopper);
7781   ssdcablelay5righttube->SetLineColor(9);
7782   TGeoTranslation* ssdcablelay5rightrans = 
7783                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7784                                                                                  +              fgkEndCapSupportCenterLay5Position
7785                                                                                  +      0.5*ssdcablelay5rightsidelength);
7786   ////////////////////////////////////
7787   //  Double_t cablescapacity[20];
7788   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7789   ////////////////////////////////////
7790   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7791   ////////////////////////////////////
7792   // TGeoPCone Volumes
7793   ///////////////////////////////////
7794   TGeoPcon* ssdcableslay5pconshape[3];
7795   TGeoVolume* ssdcableslay5pcon[3]; 
7796   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7797   Double_t ssdcableslay5pconzsection[6];
7798   Double_t ssdcableslay5pconrmin[6];
7799   Double_t ssdcableslay5pconrmax[6];
7800   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7801   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7802   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7803   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7804   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7805                                                            + fgkEndCapSupportCenterLay5Position
7806                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7807   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7808                                                            + fgkSSDCentralAL3SupportLength
7809                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7810                                                            * TanD(fgkSSDPConeAngle);      
7811   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7812                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7813   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7814                                                            ssdcableslay5pconshape[0],fSSDCopper);
7815   ssdcableslay5pcon[0]->SetLineColor(9);
7816   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7817 ////////////////////////////////////
7818 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7819 ////////////////////////////////////
7820   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7821   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7822                                                            + fgkSSDCentralAL3SupportLength
7823                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7824                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7825   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7826                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7827                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7828   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7829                                                                                    ssdcableangle,2);   
7830   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7831   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7832   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7833                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7834   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7835   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7836   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7837                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7838   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7839   ssdcableslay5pcon[1]->SetLineColor(9);
7840   ////////////////////////////////////
7841   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7842                                                                                    ssdcableangle,2);   
7843   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7844   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7845   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7846   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7847   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7848   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7849                                                            * TanD(fgkSSDPConeAngle)
7850                                                            + 0.5*fgkSSDCentralSupportLength
7851                                                            + fgkSSDCentralAL3SupportLength;
7852   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7853   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7854                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7855   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7856   ssdcableslay5pcon[2]->SetLineColor(9);
7857 ////////////////////////////////////
7858   TGeoRotation* ssdcableslay5pconrot[4];        
7859   for(Int_t i=0; i<4; i++){
7860    ssdcableslay5pconrot[i] = new TGeoRotation();
7861    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7862    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7863    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7864   }
7865   ////////////////////////////////////
7866   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7867   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7868   ////////////////////////////////////
7869   // Positioning Left SSD Cables Part
7870   ////////////////////////////////////
7871   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7872                                                                                                         - 0.5*ssdcablelay5rightsidelength
7873                                                                                                         - fgkEndCapSupportCenterLay5Position
7874                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7875   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7876   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7877   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7878   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7879   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7880   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7881         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7882         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7883     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7884   }
7885   ////////////////////////////////////
7886   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7887   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7888   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7889   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7890   /////////////////////////////////////////////////////////////
7891   // Water Tubes Layer 5
7892   /////////////////////////
7893   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7894                                                                                      ssdcableslay5rightsideradiusmax
7895                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7896                                                                                      0.5*ssdcablelay5rightsidelength); 
7897   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7898                                                                                                          ssdcablelay5rightubewatershape,
7899                                                                                                          fSSDCoolingTubeWater);
7900   ssdcablelay5rightwatertube->SetLineColor(7);
7901   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7902   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7903   ////////////////////////////////////
7904   // TGeoPCone Water Volumes Layer 
7905   ///////////////////////////////////
7906   TGeoPcon* ssdcableslay5pconwatershape[3];
7907   TGeoVolume* ssdcableslay5pconwater[3]; 
7908   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7909   Double_t ssdcableslay5pconwaterzsection[6];
7910   Double_t ssdcableslay5pcwateronrmin[6];
7911   Double_t ssdcableslay5pconwaterrmax[6];
7912   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7913   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7914                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7915   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7916   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7917                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7918   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7919   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7920   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7921                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7922   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7923                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7924   ssdcableslay5pconwater[0]->SetLineColor(7);
7925   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7926   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7927 ////////////////////////////////////
7928   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7929   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7930   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7931                                                                                                 ssdcableangle,2);   
7932   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7933   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7934                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7935   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7936   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7937                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7938   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7939                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7940   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7941                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7942   ssdcableslay5pconwater[1]->SetLineColor(7);
7943 ////////////////////////////////////
7944   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7945                                                                                                 ssdcableangle,2);   
7946   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7947   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7948                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7949   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7950   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7951                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7952   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7953   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7954   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7955                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7956   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7957                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7958   ssdcableslay5pconwater[2]->SetLineColor(7);
7959 ////////////////////////////////////
7960   TGeoRotation* ssdcableslay5pconwaterot[4];    
7961   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7962   for(Int_t i=0; i<4; i++){
7963    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7964    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7965    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7966         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7967         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7968         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7969         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7970         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7971   }
7972   /////////////////////////
7973   // SSD Layer 6 Cables
7974   /////////////////////////
7975   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7976   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7977   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7978   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7979                                                                                                 ssdcableslay6rightsideradiusmax,
7980                                                                                                 0.5*ssdcablelay6rightsidelength); 
7981   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7982                                                                                                          ssdcablelay6rightubeshape,
7983                                                                                                          fSSDCopper);
7984   ssdcablelay6righttube->SetLineColor(9);
7985   TGeoTranslation* ssdcablelay6rightrans = 
7986                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7987                                                                                  +              fgkEndCapSupportCenterLay6Position
7988                                                                                  +      0.5*ssdcablelay6rightsidelength);
7989   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7990                                                                                                         - 0.5*ssdcablelay6rightsidelength
7991                                                                                                         - fgkEndCapSupportCenterLay6Position
7992                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7993   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7994   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7995   ////////////////////////////////////
7996   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7997   ////////////////////////////////////
7998   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7999                                                                                    ssdcableangle,2);   
8000   TGeoVolume* ssdcableslay6pcon;
8001   Double_t ssdcableslay6pconrmin[2];
8002   Double_t ssdcableslay6pconrmax[2];
8003   Double_t ssdcableslay6pconzsection[2];
8004   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
8005   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
8006   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
8007   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
8008   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8009                                                            + fgkEndCapSupportCenterLay6Position
8010                                                            + ssdcablelay6rightsidelength;
8011   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
8012   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
8013                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
8014   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
8015                                                            ssdcableslay6pconshape,fSSDCopper);
8016   ssdcableslay6pcon->SetLineColor(9);
8017   for(Int_t i=0; i<4; i++){
8018    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
8019    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8020   }
8021   ////////////////////////////////////
8022   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
8023   /////////////////////////
8024   // Water Tubes Layer 6
8025   /////////////////////////
8026   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
8027                                                                                                                   ssdcableslay6rightsideradiusmax
8028                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
8029                                                                                                                   0.5*ssdcablelay6rightsidelength); 
8030   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
8031                                                                                                          ssdcablelay6righwatertubeshape,
8032                                                                                                          fSSDCoolingTubeWater);
8033   ssdcablelay6rightwatertube->SetLineColor(7);
8034   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
8035   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
8036   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
8037                                                                                    ssdcableangle,2);   
8038   TGeoVolume* ssdcableslay6waterpcon;
8039   Double_t ssdcableslay6waterpconrmin[2];
8040   Double_t ssdcableslay6waterpconrmax[2];
8041   Double_t ssdcableslay6waterpconzsection[2];
8042   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
8043   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
8044                                                             + fgkSSDCablesLay5RightSideWaterHeight;
8045   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
8046   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
8047   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8048                                                            + fgkEndCapSupportCenterLay6Position
8049                                                            + ssdcablelay6rightsidelength;
8050   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8051   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
8052                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
8053   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
8054                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
8055   ssdcableslay6waterpcon->SetLineColor(7);
8056   TGeoRotation* ssdcableslay6pconwaterot[4];    
8057   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
8058   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
8059   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
8060   for(Int_t i=0; i<4; i++){
8061    ssdcableslay6pconwaterot[i] = new TGeoRotation();
8062    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
8063    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
8064                                                                                  * (*ssdcableslay6pconwaterot[i]));   
8065    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
8066    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
8067   }
8068   ////////////////////////////////////////
8069   // From ITS Ring to Patch Panel3-RB26
8070   ////////////////////////////////////////
8071   Double_t ssdcablepatchpanel3BB26radiusmin[2];
8072   Double_t ssdcablepatchpanel3BB26radiusmax[2];
8073   Double_t ssdcablepatchpanel3RB26zsection[2];
8074   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
8075   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
8076                                                                           + fgkSSDCablesLay5RightSideHeight
8077                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8078   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
8079   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
8080                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8081                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8082   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
8083                                                                                  + fgkSSDCentralAL3SupportLength
8084                                                                                  + fgkSSDPConeZLength[0];
8085   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
8086   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
8087                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8088                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8089   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
8090                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
8091   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
8092                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
8093   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
8094   TGeoRotation* ssdcablepatchpanel3B26rot[3];
8095   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
8096   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
8097   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
8098                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
8099   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
8100   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
8101                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
8102   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
8103   ////////////////////////////////////
8104   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
8105   ////////////////////////////////////////
8106   //  ITS Ring Cables RB26 Part
8107   ////////////////////////////////////////
8108   Double_t ssdcableitsring3BB26pconzsection[2];
8109   Double_t ssdcableitsring3BB26pconrmin[2];
8110   Double_t ssdcableitsring3BB26pconrmax[2];
8111   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
8112                                                                           + fgkSSDCentralAL3SupportLength
8113                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
8114   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
8115   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8116   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
8117                                                                   + fgkSSDCablesLay5RightSideHeight
8118                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8119   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
8120   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
8121   TGeoPcon* ssdcableitsring3BB26pconshape[4];
8122   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8123                                                                    -              0.5*ssdcableangle,ssdcableangle
8124                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
8125                                                                    -                             fgkSSDCableAngle),2);
8126   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8127                                                                    -              0.5*ssdcableangle,ssdcableangle
8128                                                                    +                      3.0*fgkSSDCableAngle
8129                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8130   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
8131                                                                    -              0.5*ssdcableangle,ssdcableangle
8132                                                                    -                      fgkSSDCableAngle
8133                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
8134   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8135                                                                    -              0.5*ssdcableangle,ssdcableangle
8136                                                                    +                      3.0*fgkSSDCableAngle
8137                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8138   for(Int_t i=0;i<4;i++)
8139         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
8140                                                          ssdcableitsring3BB26pconrmin[j],
8141                                                          ssdcableitsring3BB26pconrmax[j]); 
8142   TGeoVolume* ssdcableitsring3BB26pcon[4];
8143   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
8144                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
8145   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
8146                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
8147   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
8148                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
8149   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
8150                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
8151   for(Int_t i=0;i<4;i++){
8152         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
8153         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
8154 }
8155   ////////////////////////////////////
8156   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
8157   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
8158   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
8159   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
8160   ////////////////////////////////////////
8161   // From ITS Ring to Patch Panel2-RB24
8162   ////////////////////////////////////////
8163   Double_t ssdcablepatchpanel3BB24radiusmin[2];
8164   Double_t ssdcablepatchpanel3BB24radiusmax[2];
8165   Double_t ssdcablepatchpanel3RB24zsection[2];
8166   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
8167   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
8168   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
8169   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
8170                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8171                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
8172                                                                           + 0.5*fgkSSDPatchPanelHeigth;
8173   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
8174                                                                          -  fgkSSDCentralAL3SupportLength
8175                                                                          -  fgkSSDPConeZLength[0];
8176   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8177   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8178                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8179                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8180   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8181                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8182   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8183                                                                                                 ssdcablepatchpanel3RB24pconshape,
8184                                                                                                 fSSDCopper);
8185   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8186   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8187   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8188   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
8189   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8190                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8191   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
8192   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8193                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8194   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8195   ////////////////////////////////////
8196   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8197   ////////////////////////////////////////
8198   //  ITS Ring Cables RB24 Part
8199   ////////////////////////////////////////
8200   Double_t ssdcableitsring3BB24pconzsection[2];
8201   Double_t ssdcableitsring3BB24pconrmin[2];
8202   Double_t ssdcableitsring3BB24pconrmax[2];
8203   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8204   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8205   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8206   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8207                                                                   + fgkSSDCablesLay5RightSideHeight
8208                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8209   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8210   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8211   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8212   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8213                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8214                                                                    -                             fgkSSDCableAngle),2);
8215   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8216                                                                      ssdcableangle-fgkSSDCableAngle
8217                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8218   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8219                                                                    -                      fgkSSDCableAngle
8220                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8221   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8222                                                                                                   ssdcableangle-fgkSSDCableAngle
8223                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8224   for(Int_t i=0;i<4;i++)
8225         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8226                                                          ssdcableitsring3BB24pconrmin[j],
8227                                                          ssdcableitsring3BB24pconrmax[j]); 
8228   TGeoVolume* ssdcableitsring3BB24pcon[4];
8229   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8230                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8231   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8232                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8233   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8234                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8235   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8236                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8237   for(Int_t i=0;i<4;i++){
8238         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8239         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8240 }
8241   ////////////////////////////////////
8242   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8243   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8244   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8245   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8246   ////////////////////////////////////
8247   // Volumes for Material Budget 
8248   ////////////////////////////////////
8249   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8250                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8251                                                                                                          ssdcableslay6rightsideradiusmax
8252                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8253                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8254   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8255                                                                                                          ssdcablelay6materialbudgetubeshape,
8256                                                                                                          fSSDCopper);
8257   ssdcablelay6materialbudgetube->SetLineColor(9);
8258   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8259   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8260
8261   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8262                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8263   TGeoVolume* ssdcablelay6materialbudgetpcon;
8264   Double_t ssdcablelay6materialbudgetpconrmin[2];
8265   Double_t ssdcablelay6materialbudgetpconrmax[2];
8266   Double_t ssdcablelay6materialbudgetpconzsection[2];
8267   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8268                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8269   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8270                                                                                 + fgkSSDCableMaterialBudgetHeight;
8271   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8272   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8273   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8274                                                                                         + fgkEndCapSupportCenterLay6Position
8275                                                                                         + ssdcablelay6rightsidelength;
8276   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8277   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8278                                                   ssdcablelay6materialbudgetpconzsection[i],
8279                                                   ssdcablelay6materialbudgetpconrmin[i],
8280                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8281   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8282                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8283   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8284   for(Int_t i=0; i<4; i++){
8285    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8286    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8287   }
8288 ////////////////////////////////////
8289  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8290   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8291   Double_t ssdcablesvolume = 0.0;
8292   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8293   std::cout << ssdcablesvolume << std::endl;*/
8294   return ssdcablesmother;
8295  }
8296  ////////////////////////////////////////////////////////////////////////////////
8297 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8298                                                                         Double_t height, const char* shapename, Int_t isign) const{
8299   /////////////////////////////////////////////////////////////
8300   // Method generating an Arb shape 
8301   /////////////////////////////////////////////////////////////
8302   const Int_t kvertexnumber = 8;
8303   const Int_t ktransvectnumber = 2;
8304   TVector3* vertex[kvertexnumber];
8305   TVector3* transvector[2];
8306   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i] = new TVector3(0.,width[i]);
8307   /////////////////////////////////////////////////////////////
8308   //Setting the vertices for TGeoArb8
8309   /////////////////////////////////////////////////////////////
8310   vertex[0] = new TVector3(*vertexpos[0]);
8311   vertex[1] = new TVector3(*vertexpos[1]);
8312   vertex[2] = new TVector3(*vertex[1]+isign*(*transvector[0]));
8313   vertex[3] = new TVector3(*vertex[0]+isign*(*transvector[0]));
8314   vertex[4] = new TVector3(*vertexpos[2]);
8315   vertex[5] = new TVector3(*vertexpos[3]);
8316   vertex[6] = new TVector3(*vertex[5]+isign*(*transvector[1]));
8317   vertex[7] = new TVector3(*vertex[4]+isign*(*transvector[1]));
8318   /////////////////////////////////////////////////////////////
8319   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8320   for(Int_t i = 0; i<kvertexnumber;i++) 
8321                                                         arbshape->SetVertex(i,vertex[i]->X(),vertex[i]->Y());
8322   /////////////////////////////////////////////////////////////
8323   // Deallocating memory
8324   /////////////////////////////////////////////////////////////
8325   for(Int_t i=0; i< kvertexnumber; i++) delete vertex[i];  
8326   for(Int_t i=0; i< ktransvectnumber; i++) delete transvector[i];  
8327   /////////////////////////////////////////////////////////////
8328   return arbshape;
8329
8330 ///////////////////////////////////////////////////////////////////////////////
8331 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8332                                                                 Double_t rmax, Int_t nedges, Double_t height){
8333   /////////////////////////////////////////////////////////////
8334   // Method generating Arc shape 
8335   /////////////////////////////////////////////////////////////
8336         const Int_t kvertexnumber = 2*nedges+2;
8337         TGeoXtru* arcshape = new TGeoXtru(2);   
8338         TVector3** vertexposition[2];
8339         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8340         Double_t angle = 0.;
8341     for(Int_t i=0; i<nedges+1; i++){ 
8342                 angle = 90.+0.5*phi-i*(phi/nedges);
8343                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8344                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8345         }
8346         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8347         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8348         for(Int_t i=0; i<kvertexnumber; i++){ 
8349                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8350                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8351                 }
8352                 else if(i>=1&&i<nedges+2)
8353                 {
8354                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8355                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8356                 }
8357         else
8358                 {
8359                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8360                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8361                 }
8362     }
8363   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8364   arcshape->DefineSection(0,-0.5*height);
8365   arcshape->DefineSection(1,0.5*height);
8366   /////////////////////////////////////////////////////////////
8367   // Deallocating memory
8368   /////////////////////////////////////////////////////////////
8369   for(Int_t i=0; i<2; i++){
8370         for(Int_t j=0; j<nedges+1; j++)
8371                 delete vertexposition[i][j];
8372         delete [] vertexposition[i];
8373   }
8374   delete [] xvertexpoints;
8375   delete [] yvertexpoints;
8376   /////////////////////////////////////////////////////////////
8377         return arcshape;
8378 }
8379 ////////////////////////////////////////////////////////////////////////////////
8380 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8381   ///////////////////////////////////////////////////////////////////////
8382   // Method Generating the Screw Shape  
8383   // radius[0]: outer radius
8384   // radius[1]: inner radius
8385   // edgesnumber[0]: outer number of edges
8386   // edgesnumber[1]: inner number of edges
8387   // section[0]: lower section position
8388   // section[1]: higher section position
8389   ///////////////////////////////////////////////////////////////////////
8390   Double_t outradius = radius[0];
8391   Double_t inradius = radius[1];
8392   Int_t outvertexnumber = edgesnumber[0];
8393   Int_t invertexnumber = edgesnumber[1];
8394   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8395   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8396   for(Int_t i=0; i<outvertexnumber; i++){
8397         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8398         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8399   }
8400   for(Int_t i=0; i<invertexnumber; i++){
8401         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8402         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8403   }
8404   TGeoXtru* screwshapeout = new TGeoXtru(2);
8405   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8406   screwshapeout->DefineSection(0,section[0]);
8407   screwshapeout->DefineSection(1,section[1]);
8408   TGeoXtru* screwshapein = new TGeoXtru(2);
8409   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8410   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8411   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8412   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8413   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8414   
8415   delete [] xscrewvertex;
8416   delete [] yscrewvertex;
8417   return screwshape;
8418 }
8419 ////////////////////////////////////////////////////////////////////////////////
8420 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8421   ///////////////////////////////////////////////////////////////////////
8422   // Method Generating the Hole Shape  
8423   // radius of the Hole
8424   // nedges: number of edges to approximate the circle
8425   ///////////////////////////////////////////////////////////////////////
8426   Double_t* xholevertex = new Double_t[nedges];
8427   Double_t* yholevertex = new Double_t[nedges];
8428   Double_t z  = 0.5*(section[0]+section[1]);
8429   Double_t dz = 0.5*(section[1]-section[0]);
8430   TGeoTranslation *tr = 0;
8431   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8432      tr = new TGeoTranslation(0.,0.,z);
8433      tr->RegisterYourself();
8434   }   
8435   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8436   for(Int_t i=0; i<nedges; i++){
8437         xholevertex[i] = radius*CosD(i*360./nedges);
8438         yholevertex[i] = radius*SinD(i*360./nedges);
8439   }
8440   TGeoXtru* holeshapeout = new TGeoXtru(2);
8441   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8442   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8443   holeshapeout->DefineSection(1,section[1]+0.01);
8444   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8445   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8446   
8447   delete [] xholevertex;
8448   delete [] yholevertex;
8449   return holeshape;
8450 }
8451 ////////////////////////////////////////////////////////////////////////////////
8452 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8453   /////////////////////////////////////////////////////////////
8454   // Given an axis specified by param, it gives the reflection of the point
8455   // respect to the axis
8456   /////////////////////////////////////////////////////////////
8457   TVector3* n = new TVector3(param[0],param[1],param[2]);
8458   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8459   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8460   /////////////////////////////////////////////////////////////
8461   // Deallocating memory
8462   /////////////////////////////////////////////////////////////
8463   delete n;
8464   /////////////////////////////////////////////////////////////
8465   return reflectedvector;
8466 }
8467 ////////////////////////////////////////////////////////////////////////////////
8468 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8469                                                        Double_t dx,
8470                                                        Double_t dy,
8471                                                        Double_t dz) const{
8472   /////////////////////////////////////////////////////////////
8473   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8474   /////////////////////////////////////////////////////////////
8475   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8476   const Double_t *vect = hmatrix->GetTranslation();
8477   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8478   hmatrix->SetTranslation(newvect);
8479   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8480   delete hmatrix;
8481   return matrix;
8482 }
8483 ////////////////////////////////////////////////////////////////////////////////
8484 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8485   /////////////////////////////////////////////////////////////
8486   // Method returning the Medium type 
8487   /////////////////////////////////////////////////////////////
8488   char ch[100];
8489   sprintf(ch, "ITS_%s",mediumName);
8490   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8491   if (! medium)
8492     printf("Error(AliITSv11GeometrySSD)::medium %s not found !\n", mediumName);
8493   return medium;
8494 }
8495 ////////////////////////////////////////////////////////////////////////////////
8496 void AliITSv11GeometrySSD::CreateMaterials(){
8497 ///////////////////////////////////
8498 // This part has to be modified
8499 ///////////////////////////////////
8500   ///////////////////////////////////
8501   // Silicon for Sensor
8502   /////////////////////////////////// 
8503   fSSDSensorMedium = GetMedium("SI$");
8504   ///////////////////////////////////
8505   // Silicon Mixture for Sensor
8506   /////////////////////////////////// 
8507   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8508   fSSDChipGlueMedium = GetMedium("EPOXY$");
8509   ///////////////////////////////////
8510   // Stiffener Components Materials
8511   /////////////////////////////////// 
8512   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8513   ///////////////////////////  
8514   // Stiffener Connectors 
8515   ///////////////////////////  
8516   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8517   ////////////////////////////////  
8518   // Stiffener 0603-1812 Capacitor
8519   ////////////////////////////////  
8520   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8521   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8522   ///////////////////////////  
8523   // Stiffener Hybrid Wire 
8524   ///////////////////////////  
8525   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8526   ///////////////////////////  
8527   // Al for Cooling Block
8528   ///////////////////////////  
8529   fSSDAlCoolBlockMedium = GetMedium("AL$");
8530   //////////////////////////////////////////////////////  
8531   // Kapton and Al for Chip Cable Flex and Ladder Cables
8532   //////////////////////////////////////////////////////  
8533   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8534   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8535   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8536   fSSDAlTraceFlexMedium = GetMedium("AL$");
8537   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8538   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8539   /////////////////////////////////////////////////////////////////  
8540   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8541   //////////////////////////////////////////////////////////////////  
8542   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8543   /////////////////////////////////////////////////////////////////  
8544   // G10 for Detector Leg, TubeHolder
8545   //////////////////////////////////////////////////////////////////  
8546   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8547   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8548   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8549   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8550   /////////////////////////////////////////////////////////////////  
8551   // Water and Phynox for Cooling Tube
8552   //////////////////////////////////////////////////////////////////  
8553   fSSDCoolingTubeWater = GetMedium("WATER$");
8554   fSSDCoolingTubePhynox = GetMedium("INOX$");
8555   /////////////////////////////////////////////////////////////////////
8556   // Material for Support Rings
8557   /////////////////////////////////////////////////////////////////////
8558   fSSDSupportRingAl = GetMedium("AL$");
8559   fSSDRohaCellCone = GetMedium("ROHACELL$");
8560   /////////////////////////////////////////////////////////////////////
8561   fSSDAir = GetMedium("SDD AIR$");
8562   fSSDCopper = GetMedium("COPPER$");
8563   fCreateMaterials = kTRUE;
8564 }
8565 /////////////////////////////////////////////////////////////////////