]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
f649c7cff85017826ea2078e9e04d0c30edd18ef
[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 "TGeoTube.h"
33 #include "TGeoBBox.h"
34 #include "TGeoXtru.h"
35 #include "TGeoTorus.h"
36 #include "TGeoPgon.h"
37 #include "TGeoPcon.h"
38 #include "TRotation.h"
39 #include "AliITSv11GeometrySSD.h"
40 /////////////////////////////////////////////////////////////////////////////////
41 // Names of the Sensitive Volumes of Layer 5 and Layer 6
42 /////////////////////////////////////////////////////////////////////////////////
43 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
44 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
45 /////////////////////////////////////////////////////////////////////////////////
46 //Parameters for SSD Geometry
47 /////////////////////////////////////////////////////////////////////////////////
48 // Variable for Vertical Disalignement of Modules
49 /////////////////////////////////////////////////////////////////////////////////
50 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
51 //const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 1.*fgkmm;
52 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment2 = 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-fgkSSDModuleVerticalDisalignment2, 
178                                                                                                            5.180*fgkmm-fgkSSDModuleVerticalDisalignment2};
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                                                                   -   fgkSSDModuleVerticalDisalignment2 
211                                                                   -   fgkSSDCoolingBlockHoleCenter
212                                                                   -   fgkSSDStiffenerHeight
213                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
214                                                                           fgkSSDModuleCoolingBlockToSensor
215                                                                   -   fgkSSDModuleVerticalDisalignment2 
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::fgkCarbonFiberLowerSupportWidth             
262                                                                                                                                           =  0.950*fgkmm;
263 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
264                                                                                                                                           =  1.600*fgkmm;
265 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
266                                                                                                                                           =  0.830*fgkmm;
267 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
268                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
269 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
270                                                                         = fgkCarbonFiberJunctionWidth
271                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
272                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
273 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
274                                                                         = {fgkCarbonFiberLowerSupportWidth
275                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
276                                                                            fgkCarbonFiberLowerSupportWidth
277                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
278                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
279 /////////////////////////////////////////////////////////////////////////////////
280 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
281 /////////////////////////////////////////////////////////////////////////////////
282 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
283                                                            {0.5 * (fgkSSDLay5LadderLength
284                                                                         -  fgkSSDLay5SensorsNumber
285                                                                         *  fgkCarbonFiberJunctionWidth
286                                                                         -  fgkCarbonFiberLowerSupportWidth),
287                                                                 0.5 * (fgkSSDLay5LadderLength
288                                                                         -  fgkSSDLay5SensorsNumber
289                                                                         *  fgkCarbonFiberJunctionWidth
290                                                                         +  fgkCarbonFiberLowerSupportWidth)};
291 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
292                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
293                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
294 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
295                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
296                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
297 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
298                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
299 /////////////////////////////////////////////////////////////////////////////////
300 // Cooling Tube Support (lengths are in mm and angles in degrees)
301 /////////////////////////////////////////////////////////////////////////////////
302 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
303 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
304                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
305 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
306 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
309                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
310 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
311                                                                                                                                           11.70*fgkmm;
312 /////////////////////////////////////////////////////////////////////////////////
313 // Cooling Tube (lengths are in mm and angles in degrees)
314 /////////////////////////////////////////////////////////////////////////////////
315 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
316 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
317 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
318                                                                                                         fgkCarbonFiberJunctionWidth;
319 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
320                                                                          fgkSSDModuleSensorSupportDistance
321                                                                   +      fgkSSDCoolingBlockLength;
322 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
323 /////////////////////////////////////////////////////////////////////////////////
324 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
325 /////////////////////////////////////////////////////////////////////////////////
326 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
327                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
328 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
329                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
330 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
331                                                                                                                                           20.0*fgkmm;
332 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
333                                                                                                                                                     40.0;
334 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
335                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
336 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
337                                                                                                                                           2.5*fgkmm;
338 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
339                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
340 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
341                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
342 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
343                                                                                                                                           1.0*fgkmm;
344 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
345                                                                                                                                           6.0*fgkmm;
346 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
347                                                                                                                                           4.0*fgkmm;
348 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
349                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
350 /////////////////////////////////////////////////////////////////////////////////
351 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
352 /////////////////////////////////////////////////////////////////////////////////
353 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
354 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
355 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
356 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
357 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
358 /////////////////////////////////////////////////////////////////////////////////
359 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
360 /////////////////////////////////////////////////////////////////////////////////
361 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
362 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
363 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
364                                                                                                   -  fgkSSDMountingBlockHeight[1]
365                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
366                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
367                                                                                                   +  fgkSSDModuleVerticalDisalignment
368                                                                                                   -      fgkMountingBlockSupportDownHeight,
369                                                                                                          fgkSSDLay6RadiusMin
370                                                                                                   -  fgkSSDMountingBlockHeight[1]
371                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
372                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
373                                                                                                   +  fgkSSDModuleVerticalDisalignment
374                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
375 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
376                                                                                                     -  fgkSSDMountingBlockHeight[1]
377                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
378                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
379                                                                                                         +  fgkSSDModuleVerticalDisalignment
380                                                                                                         -  fgkMountingBlockSupportRadius[0],
381                                                                                                            fgkSSDLay6RadiusMax
382                                                                                                     -  fgkSSDMountingBlockHeight[1]
383                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
384                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
385                                                                                                         +  fgkSSDModuleVerticalDisalignment
386                                                                                                         -  fgkMountingBlockSupportRadius[1]};
387 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
388 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
390 /////////////////////////////////////////////////////////////////////////////////
391 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
392 /////////////////////////////////////////////////////////////////////////////////
393 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
397                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
398 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
399                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
400 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
401                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
402 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
408 /////////////////////////////////////////////////////////////////////////////////
409 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
410 /////////////////////////////////////////////////////////////////////////////////
411 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
412 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
414 /////////////////////////////////////////////////////////////////////////////////
415 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
416 /////////////////////////////////////////////////////////////////////////////////
417 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
418                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
419 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
422                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
423 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
424                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
425 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
426 /////////////////////////////////////////////////////////////////////////////////
427 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
428 /////////////////////////////////////////////////////////////////////////////////
429 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
430                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
431 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
432                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
433                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
434 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
435 /////////////////////////////////////////////////////////////////////////////////
436 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
437 /////////////////////////////////////////////////////////////////////////////////
438 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
439                                                                                                            {62.0*fgkmm,21.87*fgkmm};
440 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
441                                                                                                             {47.0*fgkmm,0.35*fgkmm};
442 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
443                                                                                                                                           1.0*fgkmm;
444 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
446                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
447 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
448                                                                                                                                          0.15*fgkmm;
449 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
450                                                                                                                                          19.0*fgkmm;
451 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
452                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
453 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
454                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
455 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
456                                                                                                                                           2.1*fgkmm;
457 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
458                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
459 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
460                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
461 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
462                                                                                                                                            19*fgkmm; 
463 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
464                                                                                                                                           1.0*fgkmm;
465 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
466                                                                                                                                           3.6*fgkmm;
467 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
468                                                                                                                                          61.0*fgkmm; 
469 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
470                                                                                                                                          5.97*fgkmm; 
471 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
472 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
473                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
474                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
475 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
476                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
477 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
478                                                                                                                                           1.0*fgkmm; 
479 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
480                                                                                                                                    = 0.15*fgkmm; 
481 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
482                                                                                                                                          20.0*fgkmm;
483 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
484 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
487 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
488 /////////////////////////////////////////////////////////////////////////////////
489 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
490 /////////////////////////////////////////////////////////////////////////////////
491 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
500 /////////////////////////////////////////////////////////////////////////////////
501 // SSD Cone Parameters (lengths are in mm and angles in degrees)
502 /////////////////////////////////////////////////////////////////////////////////
503 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
504 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
508 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
525 /////////////////////////////////////////////////////////////////////////////////
526 // SSD Cables Parameters (lengths are in mm and angles in degrees)
527 /////////////////////////////////////////////////////////////////////////////////
528 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
529 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
532 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
533 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
534 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
536 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
541 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
542 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
543 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
544 /////////////////////////////////////////////////////////////////////////////////
545 ClassImp(AliITSv11GeometrySSD)
546 /////////////////////////////////////////////////////////////////////////////////
547 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
548   AliITSv11Geometry(),
549   fSSDChipMedium(),
550   fSSDChipGlueMedium(),
551   fSSDStiffenerMedium(),
552   fSSDStiffenerConnectorMedium(),
553   fSSDStiffener0603CapacitorMedium(),
554   fSSDStiffener1812CapacitorMedium(),
555   fSSDStiffenerHybridWireMedium(),
556   fSSDKaptonFlexMedium(),
557   fSSDAlTraceFlexMedium(),
558   fSSDAlTraceLadderCableMedium(),
559   fSSDKaptonLadderCableMedium(),
560   fSSDKaptonChipCableMedium(),
561   fSSDAlTraceChipCableMedium(),
562   fSSDAlCoolBlockMedium(),
563   fSSDSensorMedium(),
564   fSSDSensorSupportMedium(),
565   fSSDCarbonFiberMedium(),
566   fSSDTubeHolderMedium(),
567   fSSDCoolingTubeWater(),
568   fSSDCoolingTubePhynox(),
569   fSSDSupportRingAl(),
570   fSSDMountingBlockMedium(),
571   fSSDRohaCellCone(),
572   fSSDAir(),
573   fSSDCopper(),
574   fCreateMaterials(kFALSE),
575   fTransformationMatrices(kFALSE),
576   fBasicObjects(kFALSE),
577   fcarbonfiberjunction(),
578   fcoolingtubesupport(),
579   fhybridmatrix(),
580   fssdcoolingblocksystem(),
581   fcoolingblocksystematrix(),
582   fssdstiffenerflex(),
583   fssdendflex(),
584   fendladdercoolingtubesupportmatrix(),
585   fendladdermountingblock(),
586   fendladdermountingblockclip(),
587   fSSDSensor5(),
588   fSSDSensor6(),
589   fSSDLayer5(), 
590   fSSDLayer6(),
591   fMotherVol(),
592   fLay5LadderSupportRing(),
593   fLay6LadderSupportRing(),
594   fgkEndCapSupportSystem(),
595   fSSDCone(),
596   fColorCarbonFiber(4),
597   fColorRyton(5),
598   fColorPhynox(14),
599   fColorSilicon(3),
600   fColorAl(38),
601   fColorKapton(6),
602   fColorPolyhamide(5),
603   fColorStiffener(9),
604   fColorEpoxy(30),
605   fColorWater(7),
606   fColorG10(41)
607 {
608   ////////////////////////
609   // Standard constructor
610   ////////////////////////
611 }
612 /////////////////////////////////////////////////////////////////////////////////
613 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
614   AliITSv11Geometry(s.GetDebug()),
615   fSSDChipMedium(s.fSSDChipMedium),
616   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
617   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
618   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
619   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
620   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
621   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
622   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
623   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
624   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
625   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
626   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
627   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
628   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
629   fSSDSensorMedium(s.fSSDSensorMedium),
630   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
631   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
632   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
633   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
634   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
635   fSSDSupportRingAl(s.fSSDSupportRingAl),
636   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
637   fSSDRohaCellCone(s.fSSDRohaCellCone),
638   fSSDAir(s.fSSDAir),
639   fSSDCopper(s.fSSDCopper),
640   fCreateMaterials(s.fCreateMaterials),
641   fTransformationMatrices(s.fTransformationMatrices),
642   fBasicObjects(s.fBasicObjects),
643   fcarbonfiberjunction(s.fcarbonfiberjunction),
644   fcoolingtubesupport(s.fcoolingtubesupport),
645   fhybridmatrix(s.fhybridmatrix),
646   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
647   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
648   fssdstiffenerflex(s.fssdstiffenerflex),
649   fssdendflex(s.fssdendflex),
650   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
651   fendladdermountingblock(s.fendladdermountingblock),
652   fendladdermountingblockclip(s.fendladdermountingblockclip),
653   fSSDSensor5(s.fSSDSensor5),
654   fSSDSensor6(s.fSSDSensor6),
655   fSSDLayer5(s.fSSDLayer5),     
656   fSSDLayer6(s.fSSDLayer6),
657   fMotherVol(s.fMotherVol),
658   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
659   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
660   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
661   fSSDCone(s.fSSDCone),
662   fColorCarbonFiber(s.fColorCarbonFiber),
663   fColorRyton(s.fColorRyton),
664   fColorPhynox(s.fColorPhynox),
665   fColorSilicon(s.fColorSilicon),
666   fColorAl(s.fColorAl),
667   fColorKapton(s.fColorKapton),
668   fColorPolyhamide(s.fColorPolyhamide),
669   fColorStiffener(s.fColorStiffener),
670   fColorEpoxy(s.fColorEpoxy),
671   fColorWater(s.fColorWater),
672   fColorG10(s.fColorG10)
673 {
674   ////////////////////////
675   // Copy Constructor
676   ////////////////////////
677 }
678 /////////////////////////////////////////////////////////////////////////////////
679 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
680 operator=(const AliITSv11GeometrySSD &s){
681   ////////////////////////
682   // Assignment operator
683   ////////////////////////
684   this->~AliITSv11GeometrySSD();
685   new(this) AliITSv11GeometrySSD(s); 
686   return *this;
687 /*      
688   if(&s == this) return *this;
689   fMotherVol = s.fMotherVol;
690   return *this;
691  */
692 }
693 ///////////////////////////////////////////////////////////////////////////////
694 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
695   ///////////////////////////////////////////////////////////////////////  
696   // Method generating the trasformation matrix for the whole SSD Geometry   
697   ///////////////////////////////////////////////////////////////////////  
698   // Setting some variables for Carbon Fiber Supportmatrix creation
699   //////////////////////////////////////////////////////////////////////
700   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
701                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
702   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
703                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
704                                                                  +      fgkCarbonFiberSupportWidth);
705   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
706                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
707   TGeoRotation* carbonfiberot[3];
708   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
709   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
710   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
711   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
712   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
713                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
714                                                   -  fgkCarbonFiberTriangleLength
715                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
716   ///////////////////////////////////////////
717   //Setting Local Translations and Rotations: 
718   ///////////////////////////////////////////
719   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
720   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
721                                                                          0.5*carbonfibersupportheight,NULL);    
722   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
723                                                                          2.*symmetryplaneposition+transvector[1],
724                                                                          transvector[2], carbonfiberot[2]);
725   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
726   /////////////////////////////////////////////////////////////
727   // Carbon Fiber Support Transformations
728   /////////////////////////////////////////////////////////////
729   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
730   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
731                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
732                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
733                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
734   }             
735   /////////////////////////////////////////////////////////////
736   // Carbon Fiber Junction Transformation
737   /////////////////////////////////////////////////////////////
738   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
739   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
740   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
741   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
742   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
743         localcarbonfiberjunctionmatrix[i] = 
744                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
745         localcarbonfiberjunctionrot[i] = 
746                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
747         localcarbonfiberjunctiontrans[i] = 
748                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
749   }
750   ///////////////////////
751   // Setting Translations
752   ///////////////////////
753   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
754   localcarbonfiberjunctiontrans[1][0] = 
755                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
756   localcarbonfiberjunctiontrans[2][0] = 
757                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
758                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
759                                  fgkCarbonFiberTriangleLength
760                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
761   localcarbonfiberjunctiontrans[0][1] = 
762                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
763   localcarbonfiberjunctiontrans[1][1] = 
764                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
765   localcarbonfiberjunctiontrans[2][1] = 
766                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
767   ////////////////////
768   // Setting Rotations
769   ////////////////////
770   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
771                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
772                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
773   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
774         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
775   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
776   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
777   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
778   ////////////////////////////////////////
779   // Setting Carbon Fiber Junction matrix 
780   ////////////////////////////////////////
781   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
782                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
783                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
784                         localcarbonfiberjunctionmatrix[i][j] = 
785                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
786                                                            *localcarbonfiberjunctionrot[i][j]);
787                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
788          }
789   }
790   /////////////////////////////////////////////////////////////
791   // Carbon Fiber Lower Support Transformations
792   /////////////////////////////////////////////////////////////
793   TGeoTranslation* localcarbonfiberlowersupportrans[2];
794   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
795                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
796                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
797                                                                          0.0);
798   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
799                                                                          fgkCarbonFiberJunctionWidth
800                                                                 -    fgkCarbonFiberLowerSupportWidth
801                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
802                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
803                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
804    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
805    fcarbonfiberlowersupportrans[0] = 
806                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
807    fcarbonfiberlowersupportrans[1] = 
808                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
809   /////////////////////////////////////////////////////////////
810   // SSD Sensor Support Transformations
811   /////////////////////////////////////////////////////////////
812   const Int_t kssdsensorsupportmatrixnumber = 3;
813   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
814   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
815   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
816   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
817         localssdsensorsupportmatrix[i] = 
818                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
819         localssdsensorsupportrot[i] = 
820                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
821         localssdsensorsupportrans[i] = 
822                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
823   }
824   ///////////////////////
825   // Setting Translations
826   ///////////////////////
827   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
828                                                                           0.5*fgkSSDSensorSideSupportWidth,
829                                                                           0.0);
830   localssdsensorsupportrans[1][0] = 
831                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
832   localssdsensorsupportrans[2][0] = 
833                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
834   localssdsensorsupportrans[0][1] = 
835                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
836                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
837                                                                                 0.0);
838   localssdsensorsupportrans[1][1] = 
839                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
840                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
841                                                                     -   fgkSSDModuleSensorSupportDistance,
842                                                                                 0.0);
843   localssdsensorsupportrans[2][1] = 
844                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
845                                                                         -    fgkSSDSensorCenterSupportPosition,
846                                                                                  0.5*fgkSSDSensorCenterSupportWidth
847                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
848                                                                                  fgkSSDSensorCenterSupportThickness[0]);
849   localssdsensorsupportrans[0][2] = 
850                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
851                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
852                                                                                  fgkCarbonFiberJunctionWidth
853                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
854                                                                         +    fgkSSDSensorCenterSupportLength
855                                                                         -    fgkSSDSensorCenterSupportThickness[0])
856                                                                         -    fgkSSDSensorCenterSupportPosition,
857                                                                              0.0);
858   localssdsensorsupportrans[1][2] = 
859                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
860   localssdsensorsupportrans[2][2] = 
861                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
862   ////////////////////
863   // Setting Rotations
864   ////////////////////
865   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
866                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
867                         localssdsensorsupportrot[i][j] = new TGeoRotation();
868   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
869         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
870         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
871   }
872   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
873   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
874   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
875   ////////////////////////////////////////
876   // SSD Sensor Support matrix 
877   ////////////////////////////////////////
878   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
879                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
880                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
881                         localssdsensorsupportmatrix[i][j] = 
882                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
883                                                            *localssdsensorsupportrot[i][j]);
884                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
885          }
886   }
887   /////////////////////////////////////////////////////////////
888   // SSD Cooling Tube Support Transformations
889   /////////////////////////////////////////////////////////////
890   const Int_t kcoolingtubesupportmatrixnumber = 2;
891   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
892   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
893   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
894   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
895                                                                                                         /fgkCoolingTubeSupportRmax);
896   localcoolingtubesupportrans[0] = 
897                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
898                                                 +  2.*(fgkCoolingTubeSupportLength
899                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
900                                                 +  fgkCarbonFiberTriangleLength
901                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
902   localcoolingtubesupportrans[1] = 
903                         new TGeoTranslation(fgkCarbonFiberJunctionLength
904                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
905                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
906                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
907                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
908                     -  0.5*(fgkCarbonFiberLowerSupportWidth
909                                         +          fgkSSDSensorCenterSupportLength
910                     -      fgkSSDSensorCenterSupportThickness[0])
911                                         +  0.5*fgkSSDSensorLength,
912                                         -  0.5*fgkCoolingTubeSupportHeight);  
913   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
914   localcoolingtubesupportrot[i] = new TGeoRotation();
915   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
916   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
917   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
918         localcoolingtubesupportmatrix[i] = 
919                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
920                                                    *localcoolingtubesupportrot[i]);
921   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
922   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
923                                                                 (*localcoolingtubesupportmatrix[0]));
924   /////////////////////////////////////////////////////////////
925   // End Ladder SSD Cooling Tube Support Transformations
926   /////////////////////////////////////////////////////////////
927   TGeoTranslation** localendladdercooltubetrans[2];
928   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
929   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
930   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
931   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
932                                                                                         -          (fgkCoolingTubeSupportLength
933                                                                                         -               fgkCoolingTubeSupportRmax),
934                                                                                                         fgkEndLadderMountingBlockPosition[0]
935                                                                                         -               fgkendladdercoolingsupportdistance[0]
936                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
937                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
938   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
939                                                                                         -          (fgkCoolingTubeSupportLength
940                                                                                         -               fgkCoolingTubeSupportRmax),
941                                                                                                         fgkEndLadderMountingBlockPosition[0]
942                                                                                         +               fgkendladdercoolingsupportdistance[1]
943                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
944                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
945   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
946                                                                                         -       fgkCoolingTubeSupportRmax)
947                                                                                         +               fgkCarbonFiberTriangleLength
948                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
949                                                                                                 0.0,
950                                                                                                 0.0);
951   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
952                                                                                                         fgkendladdercoolingsupportdistance[0]
953                                                                                         +               fgkendladdercoolingsupportdistance[1],
954                                                                                                         0.0);
955   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
956   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
957                                                                                         +               fgkCarbonFiberJunctionLength
958                                                                                         -               fgkCoolingTubeSupportLength,
959                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
960                                                                                         -       0.5*fgkCoolingTubeSupportWidth
961                                                                                                    -fgkendladdercoolingsupportdistance[2],
962                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
963   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
964                                                                                         +               fgkCoolingTubeSupportLength
965                                                                                         -               fgkCoolingTubeSupportRmax
966                                                                                         -               fgkCarbonFiberJunctionLength,
967                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
968                                                                                         -       0.5*fgkCoolingTubeSupportWidth
969                                                                                         -               fgkendladdercoolingsupportdistance[2],
970                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
971   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
972   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
973   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
974   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
975   (*localcoolingtubesupportrot[1]));
976   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
977   (*localcoolingtubesupportrot[1]));
978   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
979   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
980   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
981   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
982   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
983
984   fendladdercoolingtubesupportmatrix[1][0] =    
985                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
986                                                                                    *(*localcoolingtubesupportrot[1]));
987   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
988   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
989   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
990   /////////////////////////////////////////////////////////////
991   // SSD Cooling Tube Transformations
992   /////////////////////////////////////////////////////////////
993   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
994   localcoolingtuberot->SetAngles(0.,90.,0.);
995   TGeoTranslation** localcoolingtubetrans[4];
996   TVector3** localcoolingtubevect[4];
997   for(Int_t i=0; i<4; i++){
998         localcoolingtubevect[i] = new TVector3*[2];
999         localcoolingtubetrans[i] = new TGeoTranslation*[2];
1000         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
1001   }
1002   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1003                                                   -fgkCarbonFiberTriangleLength),
1004                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1005                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1006                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1007                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1008                                                   +      fgkSSDSensorCenterSupportLength
1009                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1010                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1011                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1012                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1013                                                   -  0.5*fgkCoolingTubeSupportWidth,
1014                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1015   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1016                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1017                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1018                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1019                                                   +  fgkCoolingTubeSupportWidth,
1020                                                   localcoolingtubevect[0][0]->Z());     
1021   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1022                                                          +                               fgkCarbonFiberTriangleLength,
1023                                                                                          localcoolingtubevect[0][0]->Y(),
1024                                                                                          localcoolingtubevect[0][0]->Z());
1025   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1026                                                          +                               fgkCarbonFiberTriangleLength,
1027                                                                                          localcoolingtubevect[0][1]->Y(),
1028                                                                                          localcoolingtubevect[0][1]->Z());
1029   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1030                                                   -     fgkCarbonFiberTriangleLength),
1031                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1032                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1033                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1034                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1035                                                   +      fgkSSDSensorCenterSupportLength
1036                                                   -      fgkSSDSensorCenterSupportThickness[0])
1037                                                   +  fgkSSDModuleStiffenerPosition[1]
1038                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1039                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1040   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1041                                                          +                               fgkCarbonFiberTriangleLength,
1042                                                                                          localcoolingtubevect[2][0]->Y(),
1043                                                                                          localcoolingtubevect[2][0]->Z());      
1044   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1045                                                   -     fgkCarbonFiberTriangleLength),
1046                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1047                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1048                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1049                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1050                                                   +      fgkSSDSensorCenterSupportLength
1051                                                   -      fgkSSDSensorCenterSupportThickness[0])
1052                                                   +      fgkSSDSensorLength
1053                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1054                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1055   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1056                                                   + fgkCarbonFiberTriangleLength,
1057                                                         localcoolingtubevect[3][0]->Y(),
1058                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1059   for(Int_t i=0; i<4; i++) 
1060         for(Int_t j=0; j<2; j++){
1061                 localcoolingtubetrans[i][j] = 
1062                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1063                                                                 localcoolingtubevect[i][j]->Y(),
1064                                                                 localcoolingtubevect[i][j]->Z());
1065                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1066                                                           *                                     (*localcoolingtuberot));
1067         }
1068   /////////////////////////////////////////////////////////////
1069   // SSD End Ladder Cooling Tube Transformations
1070   /////////////////////////////////////////////////////////////
1071   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1072   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1073   TGeoTranslation** localendlladdercoolingtubetrans[2];
1074   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1075   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1076   for(Int_t i=0; i<2; i++)      
1077         for(Int_t j=0; j<(i==0?6:4); j++)       
1078                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1079   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1080                                                                         -        fgkCoolingTubeSupportRmax)
1081                                                                         +        fgkCarbonFiberJunctionLength,
1082                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1083                                                                         -    fgkendladdercoolingsupportdistance[0]),
1084                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1085   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1086                                                                         -        fgkCoolingTubeSupportRmax)
1087                                                                         -        fgkCarbonFiberJunctionLength
1088                                                                         +    fgkCarbonFiberTriangleLength,
1089                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1090                                                                         -    fgkendladdercoolingsupportdistance[0]),
1091                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1092   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1093                                                                         -   fgkCoolingTubeSupportRmax)
1094                                                                         +       fgkCarbonFiberJunctionLength,
1095                                                                            fgkEndLadderMountingBlockPosition[0]
1096                                                                         -   fgkendladdercoolingsupportdistance[0]
1097                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1098                                                   +                             fgkendladdercoolingsupportdistance[1]
1099                                                   +                             fgkCoolingTubeSupportWidth),
1100                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1101   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1102                                                                         -        fgkCoolingTubeSupportRmax)
1103                                                                         -        fgkCarbonFiberJunctionLength
1104                                                                         +    fgkCarbonFiberTriangleLength,
1105                                                                            fgkEndLadderMountingBlockPosition[0]
1106                                                                         -   fgkendladdercoolingsupportdistance[0]
1107                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1108                                                   +                             fgkendladdercoolingsupportdistance[1]
1109                                                   +                             fgkCoolingTubeSupportWidth),
1110                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1111   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1112                                                                         -   fgkCoolingTubeSupportRmax)
1113                                                                         +       fgkCarbonFiberJunctionLength,
1114                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1115                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1116                                                   -                     fgkEndLadderMountingBlockPosition[0]
1117                                                   -                     fgkendladdercoolingsupportdistance[1]           
1118                                                   -                     fgkCoolingTubeSupportWidth),
1119                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1120   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1121                                                                         -        fgkCoolingTubeSupportRmax)
1122                                                                         -        fgkCarbonFiberJunctionLength
1123                                                                         +    fgkCarbonFiberTriangleLength,
1124                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1125                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1126                                                   -                     fgkEndLadderMountingBlockPosition[0]
1127                                                   -                     fgkendladdercoolingsupportdistance[1]           
1128                                                   -                     fgkCoolingTubeSupportWidth),
1129                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1130   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1131                                                                         -   fgkCoolingTubeSupportRmax)
1132                                                                         +       fgkCarbonFiberJunctionLength,
1133                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1134                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1135                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1136                                                         +                 fgkSSDSensorOverlap
1137                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1138                                                         -                 fgkendladdercoolingsupportdistance[2]
1139                                                         -                 fgkEndLadderMountingBlockPosition[1]
1140                                                         -                 fgkCoolingTubeSupportWidth)
1141                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1142                                                         -                 fgkendladdercoolingsupportdistance[2]
1143                                                         -                 fgkCoolingTubeSupportWidth,
1144                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1145   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1146                                                   -      fgkCoolingTubeSupportRmax)
1147                                                   -      fgkCarbonFiberJunctionLength
1148                                                   +    fgkCarbonFiberTriangleLength,
1149                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1150                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1151                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1152                                                         +                 fgkSSDSensorOverlap
1153                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1154                                                         -                 fgkendladdercoolingsupportdistance[2]
1155                                                         -                 fgkEndLadderMountingBlockPosition[1]
1156                                                         -                 fgkCoolingTubeSupportWidth)
1157                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1158                                                         -                 fgkendladdercoolingsupportdistance[2]
1159                                                         -                 fgkCoolingTubeSupportWidth,
1160                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1161   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1162                                                                         -   fgkCoolingTubeSupportRmax)
1163                                                                         +       fgkCarbonFiberJunctionLength,
1164                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1165                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1166                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1167   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1168                                                                         -        fgkCoolingTubeSupportRmax)
1169                                                                         -        fgkCarbonFiberJunctionLength
1170                                                                         +    fgkCarbonFiberTriangleLength,
1171                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1172                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1173                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1174   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1175   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1176   for(Int_t i=0; i<2; i++)
1177         for(Int_t j=0; j<(i==0?6:4); j++){
1178                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1179                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1180         }
1181   /////////////////////////////////////////////////////////////
1182   // SSD Hybrid Components Transformations
1183   /////////////////////////////////////////////////////////////
1184   const Int_t khybridmatrixnumber = 3;
1185   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1186   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1187                                             0.5*fgkSSDStiffenerWidth,
1188                                             0.5*fgkSSDStiffenerHeight);
1189   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1190                                             fgkSSDModuleStiffenerPosition[1],0.0);
1191
1192   localhybridtrans[2] = new TGeoTranslation(
1193                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1194                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1195                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1196                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1197                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1198                       -       fgkSSDSensorCenterSupportThickness[0]),
1199                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1200                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1201                                           -       fgkSSDModuleVerticalDisalignment2)); 
1202   fhybridmatrix = new TGeoHMatrix();
1203   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1204   /////////////////////////////////////////////////////////////
1205   // SSD Cooling Block Transformations
1206   /////////////////////////////////////////////////////////////
1207   const Int_t kcoolingblockmatrixnumber = 4;    
1208   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1209   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1210                             -  fgkCoolingTubeSupportRmin),0.0,
1211                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1212   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1213                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1214                                0.0,fgkSSDStiffenerHeight);
1215   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1216   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1217   fcoolingblocksystematrix = new TGeoHMatrix();
1218   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1219       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1220   /////////////////////////////////////////////////////////////
1221   // SSD Stiffener Flex Transformations
1222   /////////////////////////////////////////////////////////////
1223   const Int_t klocalflexmatrixnumber = 4;
1224   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1225   for(Int_t i=0; i<fgkflexnumber; i++)    
1226       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1227   for(Int_t i=0; i<fgkflexnumber; i++)
1228       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1229             localflexmatrix[i][j] = new TGeoCombiTrans();
1230   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1231                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1232                                                                   -    fgkSSDStiffenerWidth;
1233   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1234                                         +0.5*fgkSSDStiffenerLength,
1235                                          0.5*fgkSSDStiffenerWidth,
1236                                         -0.5*fgkSSDStiffenerHeight
1237                                         -0.5*fgkSSDFlexHeight[0]);
1238   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1239                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1240                                         -0.5*fgkSSDStiffenerWidth,
1241                                         -0.5*fgkSSDStiffenerHeight
1242                                         -0.5*fgkSSDFlexHeight[0]);
1243   TGeoRotation* localflexrot = new TGeoRotation();
1244   localflexrot->SetAngles(180.,0.,0.);    
1245   localflexmatrix[1][0]->SetRotation(localflexrot);
1246   for(Int_t i=0; i<fgkflexnumber; i++)
1247       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1248             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1249   for(Int_t i=0; i<fgkflexnumber; i++){
1250       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1251       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1252             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1253   }
1254   /////////////////////////////////////////////////////////////
1255   // SSD End Flex Transformations
1256   /////////////////////////////////////////////////////////////
1257   TGeoRotation* localendflexrot = new TGeoRotation();
1258   localendflexrot->SetAngles(0.0,90.0,0.0);
1259   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1260   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1261                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1262   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1263                             * TMath::DegToRad()*ssdflexradiusmax
1264                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1265                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
1266   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1267                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1268                             +      fgkSSDFlexLength[2];
1269   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1270                               0.5*fgkSSDFlexWidth[0],
1271                               2.*fgkSSDStiffenerHeight
1272                             + 0.5*fgkSSDFlexHeight[0]);      
1273   localendflexmatrix->SetRotation(localendflexrot);
1274   for(Int_t i=0; i<fgkflexnumber; i++) 
1275       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1276   /////////////////////////////////////////////////////////////
1277   // End Ladder Carbon Fiber Junction
1278   /////////////////////////////////////////////////////////////
1279   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1280   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1281   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1282   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1283       localendladdercarbonfiberjunctionmatrix[i] 
1284             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1285       localendladdercarbonfiberjunctionrot[i] 
1286             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1287       localendladdercarbonfiberjunctiontrans[i] 
1288             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1289       fendladdercarbonfiberjunctionmatrix[i]
1290             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1291   }
1292   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1293       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1294             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1295             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1296       }
1297   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1298       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1299           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1300   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1301       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1302                               0.0,0.0);
1303       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1304                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1305                 *                     SinD(fgkCarbonFiberTriangleAngle),
1306                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1307   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1308   }
1309   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1310   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1311   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1312   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1313       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1314       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1315       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1316       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1317             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1318       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1319             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1320                                *localendladdercarbonfiberjunctionglobalrot[i]);
1321   }
1322   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1323       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1324             localendladdercarbonfiberjunctionmatrix[i][j] = 
1325                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1326                                      *localendladdercarbonfiberjunctionrot[i][j]);
1327            fendladdercarbonfiberjunctionmatrix[i][j] =
1328             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1329             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1330       }  
1331   /////////////////////////////////////////////////////////////
1332   // End Ladder Carbon Fiber Support
1333   /////////////////////////////////////////////////////////////
1334   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1335   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1336       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1337       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1338             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1339       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1340   }
1341   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1342       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1343             fendladdercarbonfibermatrix[i][j] = 
1344             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1345             *(*fcarbonfibersupportmatrix[j]));
1346   /////////////////////////////////////////////////////////////
1347   // End Ladder SSD Mounting Block
1348   /////////////////////////////////////////////////////////////
1349   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1350       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1351   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1352       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1353                                 +        fgkSSDMountingBlockLength[1])
1354                                 +  0.5*fgkCarbonFiberTriangleLength,
1355                                 fgkEndLadderMountingBlockPosition[i],
1356                                 -  fgkSSDMountingBlockHeight[1]
1357                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1358   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1359   endladdermountingblockrot->SetAngles(0.,90.,0.);
1360   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1361         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1362   /////////////////////////////////////////////////////////////
1363   // End Ladder SSD Mounting Block Clip Matrix 
1364   /////////////////////////////////////////////////////////////
1365   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1366         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1367   
1368   TGeoRotation* localendladdercliprot = new TGeoRotation();
1369   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1370   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1371                                                                                   -     fgkSSDMountingBlockLength[1])
1372                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1373   localendladdercliprot->SetAngles(90.,180.,-90.);
1374   TGeoCombiTrans* localendladderclipcombitrans = 
1375                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1376   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1377         for(Int_t j=0; j<2; j++){
1378                 fendladdermountingblockclipmatrix[i][j] = 
1379                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1380                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1381         }
1382   /////////////////////////////////////////////////////////////
1383   // End Ladder Carbon Fiber Lower Support
1384   /////////////////////////////////////////////////////////////
1385   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1386       fendladderlowersupptrans[i] = 
1387             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1388                         +  0.5*fgkSSDMountingBlockWidth),
1389                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1390   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1391                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1392                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1393                                                                          0.0);
1394   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1395  /////////////////////////////////////////////////////////////
1396   // Matrix for positioning Ladder into mother volume
1397   /////////////////////////////////////////////////////////////
1398   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1399   for(Int_t i=0; i<fgkladdernumber; i++) 
1400         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1401   TGeoRotation* localladdermotherrot = new TGeoRotation();
1402   localladdermotherrot->SetAngles(0.,90.,0.);  
1403   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1404   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1405   for(Int_t i=0; i<fgkladdernumber; i++){
1406         localladdermothertrans[i] = new TGeoTranslation(0.,
1407                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1408                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1409                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1410                                                           * fgkCarbonFiberJunctionWidth,0.);
1411         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1412                                                                                                                 *localladdermotherrot);
1413         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1414         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1415   }
1416   /////////////////////////////////////////////////////////////
1417   // Ladder Cables Matrices
1418   /////////////////////////////////////////////////////////////
1419   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1420                                              + fgkSSDFlexHeight[1];  
1421   Double_t ssdladdercabletransx[3];
1422   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1423                                                   *   SinD(2.*fgkSSDFlexAngle)
1424                                                   *       CosD(2.*fgkSSDFlexAngle);
1425   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1426                                                   -     ssdladdercabletransx[0]
1427                                                   /     SinD(2.*fgkSSDFlexAngle))
1428                                                   *     CosD(fgkSSDFlexAngle);                                          
1429   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1430                                                   *       TMath::DegToRad()*ssdflexradiusmax
1431                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1432                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1433                                                   -       fgkSSDLadderCableWidth)
1434                                                   *       CosD(2.*fgkSSDFlexAngle);
1435   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1436                                                   *     TanD(2.*fgkSSDFlexAngle),
1437                                                         ssdladdercabletransx[1]
1438                                                   *     TanD(fgkSSDFlexAngle),
1439                                                         ssdladdercabletransx[2]
1440                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1441   TGeoRotation* localladdercablerot[3]; 
1442   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1443   localladdercablerot[0]->SetAngles(90.,0.,0.);
1444   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1445   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1446                                                  *                        (*localladdercablerot[0]));
1447   ////////////////////////////////////////////
1448   // LocalLadderCableCombiTransMatrix
1449   ////////////////////////////////////////////
1450   const Int_t klocalladdersidecablesnumber = 2;
1451   const Int_t klocalladdercombitransnumber = 5;
1452   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1453   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1454          localladdercablecombitransmatrix[i] = 
1455                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1456   ///////////////////////////////////////////
1457   // Left Side Ladder Cables Transformations
1458   ///////////////////////////////////////////
1459   localladdercablecombitransmatrix[0][0]  =
1460                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1461                                                 0.,0.,NULL);
1462   localladdercablecombitransmatrix[0][1] = 
1463         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1464                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1465                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1466                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1467                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1468                                            + fgkSSDSensorCenterSupportLength
1469                                            - fgkSSDSensorCenterSupportThickness[0]),
1470                                            - (fgkSSDModuleCoolingBlockToSensor
1471                                            + 0.5*fgkCoolingTubeSupportHeight
1472                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1473                                            - fgkSSDChipHeight),NULL);
1474   localladdercablecombitransmatrix[0][2] = 
1475                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1476                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1477   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1478                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1479                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1480                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1481                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1482                                                                                                 new TGeoRotation("",180.,0.,0.));
1483   localladdercablecombitransmatrix[0][4] = 
1484                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1485                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1486                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1487                                                           0.,
1488                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1489                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1490                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1491                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1492   ///////////////////////////////////////////
1493   // Rigth Side Ladder Cables Transformations
1494   ///////////////////////////////////////////
1495   TGeoCombiTrans* localladdercablessdmodulematrix = 
1496         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1497                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1498                                                                          fgkSSDStiffenerWidth,
1499                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1500   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1501    localladdercablecombitransmatrix[1][i] = 
1502                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1503                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1504   ///////////////////////////////////////////
1505   // Setting LadderCableHMatrix
1506   ///////////////////////////////////////////
1507   Int_t beamaxistrans[2][3];
1508   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1509   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1510   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1511   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1512   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1513   beamaxistrans[1][2] = beamaxistrans[1][0];
1514   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1515   TGeoRotation* laddercablerot = new TGeoRotation();
1516   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1517   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1518   Double_t* laddercabletransvector;     
1519   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1520         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1521         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1522   }
1523   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1524         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1525                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1526                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1527                         localladdercablehmatrix[i][j]->MultiplyLeft(
1528                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1529         }
1530                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1531                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1532                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1533                                                                          laddercabletransvector[1]
1534                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1535                                         *                                fgkCarbonFiberJunctionWidth,
1536                                                                          laddercabletransvector[2]);
1537                 laddercablecombitrans->SetRotation(*laddercablerot);
1538                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1539                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1540         }
1541     fladdercablematrix[i][2] = 
1542                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1543                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1544         fladdercablematrix[i][3] = 
1545                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1546                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1547   }
1548   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1549         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1550                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1551   ///////////////////////////////////////////
1552   // Setting Ladder HMatrix
1553   ///////////////////////////////////////////
1554   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1555                                                                                                 fgkSSDLay6SensorsNumber};
1556   for(Int_t i=0; i<fgkladdernumber; i++){
1557         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1558         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1559                 fladdermatrix[i][j] = new TGeoHMatrix();
1560                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1561                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1562                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1563         }
1564   }
1565   ///////////////////////////////////////////
1566   // Setting SSD Sensor Matrix 
1567   ///////////////////////////////////////////
1568   TGeoCombiTrans* localssdsensorcombitrans[2];
1569   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1570   localssdsensorrot->SetAngles(0.,90.,0.);      
1571   TGeoTranslation* localssdsensortrans[2];
1572   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1573   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1574                                           -             (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1575                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1576                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1577                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1578                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1579                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1580                                           -             fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1581                                           +    (fgkSSDSensorSideSupportHeight[1]
1582                                           -             fgkSSDSensorSideSupportHeight[0])
1583                                           +     0.5*fgkSSDModuleVerticalDisalignment2);
1584   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1585                                           -        (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1586                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1587                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1588                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1589                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1590                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1591                                                         -fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1592                                                 +       0.5*fgkSSDModuleVerticalDisalignment2);
1593   for(Int_t i=0; i<2; i++) 
1594         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1595                                                                                                          *localssdsensorrot);   
1596     for(Int_t i=0; i<fgkladdernumber; i++){
1597         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1598         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1599                 switch(i){
1600                         case 0: //Ladder of Layer5  
1601                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1602                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1603                                                                                                 *localssdsensorcombitrans[1])));
1604                         break;
1605                         case 1: //Ladder of Layer6 
1606                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1607                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1608                                                                                                 *localssdsensorcombitrans[0])));
1609                 break;
1610                 }
1611           }
1612   }     
1613   //////////////////////////
1614   // Setting SSD End Ladder  
1615   //////////////////////////
1616   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1617   for(Int_t i=0; i<2; i++){
1618         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1619         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1620         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1621         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1622         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1623         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1624         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1625         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1626    }
1627   /////////////////////////////////////////////////////
1628   // Setting the CombiTransformation to pass ITS center 
1629   /////////////////////////////////////////////////////
1630   Double_t itscentertransz[fgklayernumber];
1631   itscentertransz[0] = fgkSSDLay5LadderLength
1632                                          - fgkLay5CenterITSPosition;
1633   itscentertransz[1] = fgkSSDLay6LadderLength
1634                                          - fgkLay6CenterITSPosition;
1635   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1636                                                    + 0.5*fgkCoolingTubeSupportHeight;
1637   TGeoRotation* itscenterrot[3];
1638   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1639   itscenterrot[0]->SetAngles(90.,180.,-90.);
1640   itscenterrot[1]->SetAngles(0.,90.,0.);
1641   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1642   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1643   for(Int_t i=0; i<fgklayernumber; i++) 
1644         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1645                                                          itssensortransy,
1646                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1647                                                    - itscentertransz[i],itscenterrot[2]);
1648   TGeoRotation** locallayerrot[fgklayernumber];
1649   TGeoTranslation** locallayertrans[fgklayernumber];    
1650   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1651   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1652   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1653                                          - fgkLay5CenterITSPosition);
1654   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1655                                          - fgkLay6CenterITSPosition);
1656   const Int_t kssdlayladdernumber[fgklayernumber] = 
1657                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1658   for(Int_t i=0; i<fgklayernumber; i++){
1659     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1660     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1661         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1662         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1663   }
1664   Double_t layerladderangleposition[fgklayernumber] = 
1665                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1666   Double_t layerradius = 0.;
1667   for(Int_t i=0; i<fgklayernumber; i++){        
1668         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1669                 switch(i){
1670                         case 0: //Ladder of Layer5  
1671                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1672                         break;
1673                         case 1: //Ladder of Layer6 
1674                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1675                 break;
1676                 }
1677                 locallayerrot[i][j] = new TGeoRotation();
1678                 locallayertrans[i][j] = new TGeoTranslation();
1679                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1680                 locallayertrans[i][j]->SetTranslation(layerradius 
1681                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1682                                                             layerradius 
1683                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1684                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1685                                                                          *locallayerrot[i][j]);
1686                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1687                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1688                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1689         }
1690   }
1691   /////////////////////////////////////////////////////////////
1692   // Deallocating memory
1693   /////////////////////////////////////////////////////////////
1694   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1695         delete carbonfiberot[i];
1696         delete localcarbonfibersupportmatrix[i];
1697   }
1698   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1699      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1700        delete localcarbonfiberjunctionmatrix[i][j];
1701            delete localcarbonfiberjunctionrot[i][j];
1702            delete localcarbonfiberjunctiontrans[i][j];
1703            }
1704        delete [] localcarbonfiberjunctionmatrix[i];
1705        delete [] localcarbonfiberjunctionrot[i];
1706        delete [] localcarbonfiberjunctiontrans[i];
1707   }
1708   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1709            delete localcarbonfiberlowersupportrans[i];
1710   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1711      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1712        delete localssdsensorsupportmatrix[i][j];
1713            delete localssdsensorsupportrot[i][j];
1714            delete localssdsensorsupportrans[i][j];
1715            }
1716        delete [] localssdsensorsupportmatrix[i];
1717        delete [] localssdsensorsupportrot[i];
1718        delete [] localssdsensorsupportrans[i];
1719   }
1720   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1721         delete localcoolingtubesupportmatrix[i];
1722         delete localcoolingtubesupportrot[i];
1723         delete localcoolingtubesupportrans[i];
1724   }
1725   for(Int_t i=0; i<4; i++){
1726         for(Int_t j=0; j<2; j++){
1727                 delete localcoolingtubevect[i][j];
1728                 delete localcoolingtubetrans[i][j];
1729         }
1730         delete [] localcoolingtubevect[i];
1731         delete [] localcoolingtubetrans[i];
1732   }
1733  delete endladdermountingblockrot;
1734  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1735  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1736  for(Int_t i=0; i<fgkflexnumber; i++){
1737       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1738             delete localflexmatrix[i][j];
1739       delete [] localflexmatrix[i];
1740  }
1741  delete localendlladdercoolingtuberot;
1742  for(Int_t i=0; i<2; i++){
1743         for(Int_t j=0; j<(i==0?6:4); j++)
1744                 delete localendlladdercoolingtubetrans[i][j];
1745         delete [] localendlladdercoolingtubetrans[i];
1746   }
1747
1748  delete localflexrot;
1749  delete localendflexrot;
1750  delete localendflexmatrix;
1751  for(Int_t i=0; i<fgkladdernumber; i++){ 
1752         delete localladdermothertrans[i];
1753         delete localladdermothercombitrans[i];
1754   }
1755  delete localladdermotherrot;
1756  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1757       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1758             delete localendladdercarbonfiberjunctionmatrix[i][j];
1759             delete localendladdercarbonfiberjunctionrot[i][j];
1760             delete localendladdercarbonfiberjunctiontrans[i][j];
1761       }
1762       delete [] localendladdercarbonfiberjunctionmatrix[i];
1763       delete [] localendladdercarbonfiberjunctionrot[i];
1764       delete [] localendladdercarbonfiberjunctiontrans[i];
1765       delete localendladdercarbonfiberjunctionglobalrot[i];
1766       delete localendladdercarbonfiberjunctionglobaltrans[i];
1767       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1768  }
1769   for(Int_t i=0; i<2; i++){
1770         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1771         delete [] localendladdercooltubetrans[i];
1772   }
1773   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1774       delete localendladdercarbonfibertrans[i];
1775   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1776   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1777         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1778                 delete localladdercablecombitransmatrix[i][j];
1779                 delete []localladdercablecombitransmatrix[i];
1780   }
1781   delete localendladdercliprot;
1782   delete localendladdercliptrans;
1783   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1784         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1785                 delete localladdercablehmatrix[i][j];
1786         delete []localladdercablehmatrix[i];
1787   }
1788   delete laddercablerot;
1789   delete laddercabletrans;
1790   delete laddercablecombitrans;
1791   delete localladdercablessdmodulematrix;
1792   delete localssdsensorrot;     
1793   for(Int_t i=0; i<2; i++){
1794         delete localssdsensortrans[i];
1795         delete localssdsensorcombitrans[i];
1796   }
1797   for(Int_t i=0; i<fgklayernumber; i++){
1798         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1799                 delete locallayerrot[i][j];
1800                 delete locallayertrans[i][j];
1801                 delete locallayercombitrans[i][j];
1802     }
1803         delete [] locallayerrot[i];
1804         delete [] locallayertrans[i];
1805         delete [] locallayercombitrans[i];
1806         delete localbeamaxistrans[i];
1807   }
1808   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1809   for(Int_t i=0; i<fgkladdernumber; i++){
1810         for(Int_t j=0; j<fgkladdernumber; j++)
1811                 delete ladderglobalmatrix[i][j];
1812         delete [] ladderglobalmatrix[i];
1813   }
1814   /////////////////////////////////////////////////////////////
1815   fTransformationMatrices = kTRUE;      
1816 }
1817 ///////////////////////////////////////////////////////////////////////////////
1818 void AliITSv11GeometrySSD::CreateBasicObjects(){
1819   /////////////////////////////////////////////////////////////  
1820   // Method generating the Objects of SSD Geometry    
1821   /////////////////////////////////////////////////////////////
1822   // SSD Sensor
1823   ///////////////////////////////////
1824   SetSSDSensor();
1825   /////////////////////////////////////////////////////////////  
1826   // Carbon Fiber Support    
1827   /////////////////////////////////////////////////////////////  
1828   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1829   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1830       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1831   /////////////////////////////////////////////////////////////
1832   // Carbon Fiber Junction 
1833   /////////////////////////////////////////////////////////////
1834   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1835   /////////////////////////////////////////////////////////////
1836   // Carbon Fiber Lower Support
1837   /////////////////////////////////////////////////////////////
1838   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1839   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1840         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1841   /////////////////////////////
1842   // SSD Sensor Support
1843   /////////////////////////////
1844   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1845                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1846   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1847                                                                          fgkSSDSensorSideSupportThickness[1]};
1848   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1849         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1850                                                                                            fgkSSDSensorSideSupportHeight[i],
1851                                                                                            fgkSSDSensorSideSupportWidth,
1852                                                                                            sidesupporthickness);  
1853         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1854                                                                                            fgkSSDSensorCenterSupportHeight[i],
1855                                                                                            fgkSSDSensorCenterSupportWidth,
1856                                                                                            sidesupporthickness);
1857   }
1858   /////////////////////////////////////////////////////////////
1859   // SSD Cooling Tube Support
1860   /////////////////////////////////////////////////////////////
1861   Int_t edgesnumber = 16;
1862   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1863   /////////////////////////////////////////////////////////////
1864   // SSD Hybrid
1865   /////////////////////////////////////////////////////////////
1866   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1867   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1868         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1869   /////////////////////////////////////////////////////////////
1870   // SSD Cooling Block System
1871   /////////////////////////////////////////////////////////////
1872   fssdcoolingblocksystem = GetCoolingBlockSystem();
1873    /////////////////////////////////////////////////////////////
1874   // SSD Cooling Tube
1875   /////////////////////////////////////////////////////////////
1876   TList* coolingtubelist = GetCoolingTubeList();        
1877   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1878         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1879   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1880         fendladdercoolingtube[i] = 
1881                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1882   /////////////////////////////////////////////////////////////
1883   // SSD Flex  
1884   /////////////////////////////////////////////////////////////
1885   fssdstiffenerflex = GetSSDStiffenerFlex();
1886   fssdendflex = GetSSDEndFlex();
1887   ///////////////////////////////////
1888   // End Ladder Carbon Fiber Junction
1889   ///////////////////////////////////
1890   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1891                                                    fendladdercarbonfiberjunction[i] = 
1892                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1893   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1894     fendladdercarbonfiberjunction[i][0] = 
1895                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1896     fendladdercarbonfiberjunction[i][1] = 
1897                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1898   }
1899   ///////////////////////////////////
1900   // End Ladder Mounting Block
1901   ///////////////////////////////////
1902   fendladdermountingblock = GetSSDMountingBlock();
1903   ///////////////////////////////////
1904   // End Ladder Mounting Block
1905   ///////////////////////////////////
1906   fendladdermountingblockclip = GetMountingBlockClip();
1907   ///////////////////////////////////
1908   // Ladder Support 
1909   ///////////////////////////////////
1910   TList* laddersupportlist = GetMountingBlockSupport(20);
1911   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1912   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1913   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1914   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1915   /////////////////////////////////////////////////////////////
1916   // Deallocating memory
1917   /////////////////////////////////////////////////////////////
1918   delete carbonfibersupportlist;
1919   delete carbonfiberlowersupportlist;
1920   delete ssdhybridcomponentslist;
1921   delete laddersupportlist;
1922   /////////////////////////////////////////////////////////////
1923   fBasicObjects = kTRUE;
1924 }
1925 /////////////////////////////////////////////////////////////////////////////////
1926 void AliITSv11GeometrySSD::SetSSDSensor(){
1927   ////////////////////////////////////////////////////////////////
1928   // Method generating SSD Sensors: it sets the private variables
1929   // fSSDSensor5, fSSDSensor6  
1930   ////////////////////////////////////////////////////////////////
1931   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1932   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1933   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1934                                                 0.5*ssdsensitivewidth,
1935                                                 0.5*fgkSSDSensorHeight,
1936                                                 0.5*ssdsensitivelength);
1937   TGeoVolume* ssdsensorsensitiveLay5 = 
1938         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1939   TGeoVolume* ssdsensorsensitiveLay6 = 
1940         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1941   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1942   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1943   TGeoBBox* ssdsensorinsensitiveshape[2];
1944   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1945                                                 0.5*fgkSSDSensorInsensitiveWidth,
1946                                                 0.5*fgkSSDSensorHeight,
1947                                                 0.5*fgkSSDSensorLength);
1948   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1949                                                 0.5*ssdsensitivewidth,
1950                                                 0.5*fgkSSDSensorHeight,
1951                                                 0.5*fgkSSDSensorInsensitiveWidth);
1952   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1953                                              "SSDSensorInsensitive2"};
1954   TGeoVolume* ssdsensorinsensitive[2];
1955   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1956       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1957                      fSSDSensorMedium);
1958       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1959   }
1960   /////////////////////////////////////////////////////////////
1961   // Virtual Volume containing SSD Sensor  
1962   /////////////////////////////////////////////////////////////
1963   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1964                                                                                              0.5*fgkSSDSensorWidth,
1965                                                                                              0.5*fgkSSDSensorHeight,
1966                                                                                              0.5*fgkSSDSensorLength);
1967   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1968                                                                                  fSSDAir);      
1969   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1970                                                                                  fSSDAir);      
1971   /////////////////////////////////////////////////////////////
1972   for(Int_t i=0; i<4; i++){ 
1973             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1974             ssdsensorinsensitive[1],i<2?1:2,
1975                         new TGeoTranslation(
1976                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1977       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1978                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1979       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1980             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1981             ssdsensorinsensitive[1],i<2?1:2,
1982                         new TGeoTranslation(
1983                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1984       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1985                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1986       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1987   }
1988     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1989     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1990 }
1991 ///////////////////////////////////////////////////////////////////////////////
1992 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1993   /////////////////////////////////////////////////////////////  
1994   // Method generating the Carbon Fiber Support   
1995   /////////////////////////////////////////////////////////////  
1996   const Int_t kvertexnumber = 4;
1997   const Int_t kshapesnumber = 2;
1998   TVector3** vertexposition[kshapesnumber];
1999   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
2000   Double_t carbonfibersupportxaxisEdgeproj = 
2001                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2002         *       TMath::DegToRad());
2003   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
2004                                  /                         fgkCarbonFiberSupportXAxisLength);
2005   /////////////////////
2006   //Vertex Positioning
2007   ////////////////////
2008   vertexposition[0][0] = new TVector3();
2009   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
2010                                                                           fgkCarbonFiberSupportYAxisLength);
2011   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2012                                                                           carbonfibersupportxaxisEdgeproj
2013                                            *                      TMath::Tan(theta));
2014   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2015                                            -                      carbonfibersupportxaxisEdgeproj,
2016                                                                           fgkCarbonFiberSupportYAxisLength
2017                                            -                      vertexposition[0][2]->Y());
2018   ////////////////////////////////////////////////////
2019   //Setting the parameters for Isometry Transformation
2020   ////////////////////////////////////////////////////
2021   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2022                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2023                                                                  +      fgkCarbonFiberSupportWidth);
2024   Double_t* param = new Double_t[4]; 
2025   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2026   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2027                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2028                                                           (GetReflection(vertexposition[0][j],param))->Y());
2029   char* carbonfibersupportshapename[kshapesnumber] = 
2030                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2031   char* carbonfibersupportname[kshapesnumber] = 
2032                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2033   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2034   TGeoVolume* carbonfibersupport[kshapesnumber];
2035   TList* carbonfibersupportlist = new TList();
2036   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2037   Double_t carbonfibersupportheight = 
2038           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2039           *TMath::DegToRad());
2040   for(Int_t i = 0; i< kshapesnumber; i++){
2041    carbonfibersupportshape[i] = 
2042                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2043                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2044    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2045                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2046    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2047    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2048    }
2049   /////////////////////////////////////////////////////////////
2050   // Deallocating memory
2051   /////////////////////////////////////////////////////////////
2052   for(Int_t i=0; i< kshapesnumber; i++){
2053      for(Int_t j=0; j< kvertexnumber; j++)
2054            delete vertexposition[i][j];
2055        delete [] vertexposition[i];
2056   }
2057   delete [] param;
2058   /////////////////////////////////////////////////////////////
2059    return carbonfibersupportlist;
2060 }
2061 /////////////////////////////////////////////////////////////////////////////////
2062 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2063   /////////////////////////////////////////////////////////////
2064   // Method generating SSD Carbon Fiber Junction
2065   /////////////////////////////////////////////////////////////
2066   const Int_t kvertexnumber = 6;
2067   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2068   Double_t reflectionparam[3] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2069                                                           *  TMath::DegToRad()),-1.,0.};
2070   TVector3* vertex[kvertexnumber];
2071   vertex[0] = new TVector3();
2072   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2073                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2074                         *                         TMath::DegToRad()),
2075                                                   fgkCarbonFiberJunctionEdge[0]
2076                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2077                         *                         TMath::DegToRad()));
2078   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2079                                                    fgkCarbonFiberJunctionEdge[1]);
2080   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2081   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2082   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2083   Double_t xvertexpoints[6], yvertexpoints[6];
2084   for(Int_t i=0; i<kvertexnumber; i++) 
2085           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2086   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2087   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2088   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2089   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2090                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2091   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2092   /////////////////////////////////////////////////////////////
2093   // Deallocating memory
2094   /////////////////////////////////////////////////////////////
2095   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2096   ///////////////////////////////////////////////////////////// 
2097   return carbonfiberjunction;
2098 }
2099 ////////////////////////////////////////////////////////////////////////////////
2100 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2101   /////////////////////////////////////////////////////////////
2102   // Method generating the Carbon Fiber Lower Support   
2103   /////////////////////////////////////////////////////////////  
2104   const Int_t kvertexnumber = 4;
2105   const Int_t kshapesnumber = 2;
2106   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2107                                                                 fgkCarbonFiberLowerSupportWidth};
2108   TVector3** vertexposition[kshapesnumber];
2109   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2110                                                  new TVector3*[kvertexnumber];
2111   //First Shape Vertex Positioning
2112   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2113   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2114                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2115   vertexposition[0][2] = new TVector3();
2116   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2117   //Second Shape Vertex Positioning
2118   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2119                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2120                                  /                              fgkCarbonFiberTriangleLength);
2121   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2122                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2123                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2124   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2125                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2126                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2127   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2128   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2129                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2130   char* carbonfiberlowersupportshapename[kshapesnumber] = 
2131                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2132   char* carbonfiberlowersupportname[kshapesnumber] = 
2133                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2134   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2135   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2136   TList* carbonfiberlowersupportlist = new TList();
2137   for(Int_t i = 0; i< kshapesnumber; i++){ 
2138         carbonfiberlowersupportshape[i] = 
2139                                                                 GetArbShape(vertexposition[i],width,
2140                                                                                         fgkCarbonFiberLowerSupportHeight,
2141                                                                                         carbonfiberlowersupportshapename[i]);
2142     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2143                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2144         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2145     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2146   }
2147   /////////////////////////////////////////////////////////////
2148   // Deallocating memory
2149   /////////////////////////////////////////////////////////////
2150   for(Int_t i=0; i< kshapesnumber; i++){
2151      for(Int_t j=0; j< kvertexnumber; j++)
2152            delete vertexposition[i][j];
2153        delete [] vertexposition[i];
2154   }
2155   /////////////////////////////////////////////////////////////
2156   return carbonfiberlowersupportlist;
2157 }
2158 ///////////////////////////////////////////////////////////////////////////////
2159 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2160                                                                  Double_t width, Double_t* thickness)const{
2161   /////////////////////////////////////////////////////////////
2162   // Method generating the Sensor Support   
2163   /////////////////////////////////////////////////////////////  
2164         const Int_t kvertexnumber = 6;
2165         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2166     TVector3* vertexposition[kvertexnumber];
2167         vertexposition[0] = new TVector3();     
2168         vertexposition[1] = new TVector3(0.0,length);   
2169         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2170         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2171         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2172         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2173         Double_t xvertexpoints[6], yvertexpoints[6];
2174         for(Int_t i=0; i<kvertexnumber; i++) 
2175                 xvertexpoints[i] = vertexposition[i]->X(), 
2176                 yvertexpoints[i] = vertexposition[i]->Y();
2177     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2178     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2179     ssdsensorsupportshape->DefineSection(1,0.5*width);
2180     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2181                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2182   /////////////////////////////////////////////////////////////
2183   // Deallocating memory
2184   /////////////////////////////////////////////////////////////
2185         for (Int_t i=0; i<kvertexnumber; i++)
2186                 delete vertexposition[i];
2187   /////////////////////////////////////////////////////////////
2188     return ssdsensorsupport;
2189 }
2190 ////////////////////////////////////////////////////////////////////////////////
2191 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2192   /////////////////////////////////////////////////////////////
2193   // Method generating the Cooling Tube Support
2194   /////////////////////////////////////////////////////////////
2195   if(nedges%2!=0) nedges--;     
2196   const Int_t kvertexnumber = nedges+5;
2197   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2198                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2199   Double_t angle = 90.+phi;
2200   Double_t psi = 90.-phi;
2201   ///////////////////////////////////////
2202   // Vertex Positioning for TGeoXTru
2203   ///////////////////////////////////////
2204   TVector3** vertexposition = new TVector3*[kvertexnumber];
2205   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2206                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2207   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2208                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2209   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2210                                                                    fgkCoolingTubeSupportRmax);
2211   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2212                                                                    fgkCoolingTubeSupportRmax);
2213   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2214                                                                     vertexposition[1]->Y());
2215   for(Int_t i=0; i<nedges; i++)
2216         vertexposition[i+5] = 
2217                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2218                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2219   ///////////////////////////////////////////////////////////////////////
2220   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2221   ///////////////////////////////////////////////////////////////////////
2222   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2223   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2224   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2225   for(Int_t i=0; i<kvertexnumber; i++){
2226         xvertexpoints[i] = vertexposition[i]->X();
2227         yvertexpoints[i] = vertexposition[i]->Y();
2228   } 
2229   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2230                                                                                         yvertexpoints);
2231   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2232   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2233   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2234                                                                           coolingtubesupportarcshape,
2235                                                                                   fSSDTubeHolderMedium);
2236   coolingtubesupportarc->SetLineColor(fColorG10);
2237   //////////////////////////////////////////////////////////////////////////
2238   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2239   //////////////////////////////////////////////////////////////////////////
2240   TGeoTubeSeg* coolingtubesupportsegshape = 
2241                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2242                                                                                         fgkCoolingTubeSupportRmax,
2243                                                                                         0.5*fgkCoolingTubeSupportWidth,
2244                                                                                         phi,360-phi);
2245   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2246                                                                                         coolingtubesupportsegshape,
2247                                                                                         fSSDTubeHolderMedium);
2248   coolingtubesupportseg->SetLineColor(fColorG10);
2249   //////////////////////////////////////////////////////////////////////////
2250   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2251   //////////////////////////////////////////////////////////////////////////
2252   Double_t* boxorigin = new Double_t[3];
2253   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2254   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2255   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2256                                                                                  0.5*fgkCoolingTubeSupportHeight,
2257                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2258   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2259                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2260   coolingtubesupportbox->SetLineColor(fColorG10);
2261   //////////////////////////////////////////////////////////////////////////
2262   // Cooling Tube for Cooling Tube Support 
2263   //////////////////////////////////////////////////////////////////////////
2264   TGeoXtru* coolingtubearcshape[2];
2265   coolingtubearcshape[0] = new TGeoXtru(2);     
2266   Double_t* xvert = new Double_t[nedges+2];
2267   Double_t* yvert = new Double_t[nedges+2];
2268   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2269   ////////////////////////////////////////
2270   // Positioning the vertices for TGeoXTru
2271   ////////////////////////////////////////
2272   xvert[0] = 0., yvert[0] = 0.;
2273   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2274   for(Int_t i=0; i< nedges; i++)
2275                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2276                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2277   ////////////////////////////////////////
2278   // Defining TGeoXTru PolyGone
2279   ////////////////////////////////////////
2280   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2281   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2282   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2283   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2284                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2285   TGeoVolume* coolingtubearc[2];
2286   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2287                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2288   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2289                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2290   coolingtubearc[0]->SetLineColor(fColorWater);
2291   coolingtubearc[1]->SetLineColor(fColorPhynox);
2292   ////////////////////////////////////////////
2293   // Defining TGeoTubeSeg Part of Cooling Tube
2294   ////////////////////////////////////////////
2295   TGeoTubeSeg* coolingtubesegshape[2];
2296   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2297                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2298   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2299                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2300   TGeoVolume* coolingtubeseg[2];
2301   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2302                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2303   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2304                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2305   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2306   coolingtubeseg[1]->SetLineColor(fColorWater);
2307   /////////////////////////////////////////////////////////////
2308   // Virtual Volume containing Cooling Tube Support  
2309   /////////////////////////////////////////////////////////////
2310   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2311   const Int_t kvirtualvertexnumber = 8;
2312   TVector3* virtualvertex[kvirtualvertexnumber];
2313    ////////////////////////////////////////
2314   // Positioning the vertices for TGeoXTru
2315   ////////////////////////////////////////
2316   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2317   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2318   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2319   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2320   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2321   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2322   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2323   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2324   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2325   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2326         xmothervertex[i] = virtualvertex[i]->X(),
2327         ymothervertex[i] = virtualvertex[i]->Y();
2328   ////////////////////////////////////////
2329   // Defining TGeoXTru PolyGone
2330   ////////////////////////////////////////
2331   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2332                                                                                                                                          ymothervertex);
2333   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2334   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2335   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2336                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2337   ////////////////////////////////////////
2338   // Positioning Volumes in Virtual Volume
2339   ////////////////////////////////////////
2340   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2341   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2342   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2343   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2344   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2345   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2346   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2347   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2348   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2349   /////////////////////////////////////////////////////////////
2350   // Deallocating memory
2351   /////////////////////////////////////////////////////////////
2352   delete [] vertexposition;
2353   delete xvertexpoints;
2354   delete yvertexpoints;
2355   delete xvert;
2356   delete yvert;
2357   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2358         delete virtualvertex[i];
2359   /////////////////////////////////////////////////////////////
2360         return virtualcoolingtubesupport;
2361 }
2362 /////////////////////////////////////////////////////////////////////////////////
2363 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2364   /////////////////////////////////////////////////////////////
2365   // Method generating List containing SSD Hybrid Components   
2366   /////////////////////////////////////////////////////////////
2367   TList* ssdhybridlist = new TList();
2368   const Int_t kssdstiffenernumber = 2;
2369   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2370                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2371                                                                   -    fgkSSDStiffenerWidth;
2372   Double_t ssdchipcablesradius[kssdstiffenernumber];
2373   for(Int_t i=0; i<kssdstiffenernumber; i++)
2374           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2375                                -  fgkSSDChipCablesHeight[0]
2376                                -  fgkSSDChipCablesHeight[1]);
2377   /////////////////////////////////////////////////////////////
2378   // Mother Volumes Containers 
2379   /////////////////////////////////////////////////////////////
2380   const Int_t kmothernumber = 2;
2381   const Int_t kmothervertexnumber = 12;
2382   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2383   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2384   ///////////////////////
2385   // Setting the vertices 
2386   ///////////////////////
2387   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2388   xmothervertex[0][1]  = xmothervertex[0][0]; 
2389   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2390   xmothervertex[0][3]  = xmothervertex[0][2];
2391   xmothervertex[0][4]  = xmothervertex[0][0];
2392   xmothervertex[0][5]  = xmothervertex[0][4];
2393   xmothervertex[0][6]  = -xmothervertex[0][0];
2394   xmothervertex[0][7]  = xmothervertex[0][6];
2395   xmothervertex[0][8]  = -xmothervertex[0][2];
2396   xmothervertex[0][9]  = xmothervertex[0][8];
2397   xmothervertex[0][10] = xmothervertex[0][7];
2398   xmothervertex[0][11] = xmothervertex[0][10];
2399   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2400   for(Int_t i = 0; i<kmothernumber; i++){
2401       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2402                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2403       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2404       ymothervertex[i][2]  = ymothervertex[i][1];
2405       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2406       ymothervertex[i][4]  = ymothervertex[i][3];
2407       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2408       ymothervertex[i][6]  = ymothervertex[i][5];
2409       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2410       ymothervertex[i][8]  = ymothervertex[i][7];
2411       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2412       ymothervertex[i][10] = ymothervertex[i][9];
2413       ymothervertex[i][11] = ymothervertex[i][0];
2414   }
2415   TGeoXtru* ssdhybridmothershape[kmothernumber];
2416 //  TGeoVolume* ssdhybridmother[kmothernumber];
2417   TGeoVolumeAssembly* ssdhybridmother[kmothernumber];
2418   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2419   for(Int_t i=0; i<kmothernumber; i++){
2420       ssdhybridmothershape[i] = new TGeoXtru(2);
2421       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2422                                           ymothervertex[i]);
2423       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2424                                                -fgkSSDChipCablesHeight[i+2]);
2425       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2426 //      ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2427 //                                          fSSDAir);
2428       ssdhybridmother[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2429    }   
2430   /////////////////////////////////////////////////////////////
2431   // SSD Stiffener   
2432   /////////////////////////////////////////////////////////////
2433   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2434                                              0.5*fgkSSDStiffenerLength,
2435                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2436                                              0.5*fgkSSDStiffenerHeight);
2437   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2438                                             fSSDStiffenerMedium);  
2439   ssdstiffener->SetLineColor(fColorStiffener); 
2440   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2441   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2442       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2443   /////////////////////////////////////////////////////////////
2444   // SSD Chip System    
2445   /////////////////////////////////////////////////////////////
2446   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2447   Double_t ssdchipseparation = fgkSSDSensorLength
2448                              - 2.*fgkSSDModuleStiffenerPosition[1]
2449                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2450                              - 0.5*fgkSSDChipWidth);
2451   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2452                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2453   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2454                                       - 0.5*ssdchipsystemlength,
2455                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2456                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2457 ////////////////////////////
2458 // Capacitor 0603-2200 nF
2459 ///////////////////////////
2460   const Int_t knapacitor0603number = 5;
2461   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2462                                                                                          0.5*fgkSSDCapacitor0603Length,
2463                                                                                          0.5*(fgkSSDCapacitor0603Width-fgkSSDTolerance),
2464                                                                                          0.5*fgkSSDCapacitor0603Height);
2465   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2466                                              fSSDStiffener0603CapacitorMedium); 
2467   capacitor0603->SetLineColor(fColorAl);
2468   for(Int_t i=0; i<kmothernumber; i++){
2469       for(Int_t j=0; j<kssdstiffenernumber; j++){
2470             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2471             for(Int_t k=1; k<knapacitor0603number+1; k++){
2472 //                  ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2473   //                      new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2474  //                                          j*ssdstiffenerseparation
2475  //                       +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2476  //                       +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2477  //                       -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2478             }
2479       } 
2480       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2481       ssdhybridlist->Add(ssdhybridmother[i]);
2482   }    
2483 /////////////////////////////////////////////////////////////
2484 // Mother Volume Containing Capacitor Part 
2485 /////////////////////////////////////////////////////////////
2486   const Int_t kcapacitormothernumber = 8;
2487   Double_t xcapacitorvertex[kcapacitormothernumber];
2488   Double_t ycapacitorvertex[kcapacitormothernumber];  
2489   ///////////////////////
2490   // Setting the vertices 
2491   ///////////////////////
2492   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2493   xcapacitorvertex[1] = xcapacitorvertex[0];   
2494   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2495   xcapacitorvertex[3] = xcapacitorvertex[2];   
2496   xcapacitorvertex[4] = xcapacitorvertex[0];   
2497   xcapacitorvertex[5] = xcapacitorvertex[0];   
2498   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2499   xcapacitorvertex[7] = xcapacitorvertex[6];   
2500   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2501   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2502   ycapacitorvertex[2] = ycapacitorvertex[1];   
2503   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2504   ycapacitorvertex[4] = ycapacitorvertex[3];   
2505   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2506   ycapacitorvertex[6] = ycapacitorvertex[5];   
2507   ycapacitorvertex[7] = ycapacitorvertex[0];   
2508   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2509   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2510                                               ycapacitorvertex);
2511   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2512   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2513 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2514 //                                          fSSDAir);
2515   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2516 ////////////////////////////
2517 // Connector 
2518 ///////////////////////////
2519   const Int_t kssdconnectornumber = 2;
2520   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2521   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2522   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2523                                    +  fgkSSDConnectorAlHeight};  
2524   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2525   TGeoVolume* ssdconnector[kssdconnectornumber];
2526   for(Int_t i=0; i<kssdconnectornumber; i++){
2527       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2528                                           0.5*fgkSSDConnectorWidth,
2529                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2530                            +              i*fgkSSDConnectorNiHeight),
2531                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2532       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2533                                        i==0 ? fSSDAlTraceFlexMedium 
2534                                             : fSSDStiffenerConnectorMedium);      
2535       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2536   }
2537   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2538   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2539                        +  fgkSSDConnectorPosition[0]
2540                        -  fgkSSDConnectorSeparation
2541                        -  1.5*fgkSSDConnectorLength,
2542                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2543                        -  fgkSSDConnectorPosition[1]
2544                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2545   ssdconnectortrans[1] = new TGeoTranslation(
2546                        -  ssdstiffenershape->GetDX()
2547                        +  fgkSSDConnectorPosition[0]
2548                        -  0.5*fgkSSDConnectorLength,
2549                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2550                        -  fgkSSDConnectorPosition[1]
2551                        -  ssdconnectorshape[0]->GetDY(),0.0);
2552   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2553                        -  fgkSSDConnectorPosition[0]
2554                        +  fgkSSDConnectorSeparation
2555                        +  1.5*fgkSSDConnectorLength,
2556                           -(ssdstiffenershape->GetDY()
2557                        -  fgkSSDConnectorPosition[1]
2558                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2559   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2560                        -  fgkSSDConnectorPosition[0]
2561                        +  0.5*fgkSSDConnectorLength,
2562                           -(ssdstiffenershape->GetDY()
2563                        -  fgkSSDConnectorPosition[1]
2564                        -  ssdconnectorshape[0]->GetDY()),0.0);
2565   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2566       for(Int_t j=0; j<kssdconnectornumber; j++)
2567             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2568 ////////////////////////////
2569 // Capacitor 1812-330 nF
2570 /////////////////////////// 
2571   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2572   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2573                                                                                          0.5*fgkSSDCapacitor1812Length,
2574                                                                                          0.5*fgkSSDCapacitor1812Width,
2575                                                                                          0.5*fgkSSDCapacitor1812Height,
2576             ssdcapacitor1812origin);
2577   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2578                                              fSSDStiffener1812CapacitorMedium); 
2579   capacitor1812->SetLineColor(fColorAl);
2580   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2581                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2582                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2583   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2584 ////////////////////////////
2585 //Hybrid Wire
2586 ////////////////////////////
2587   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2588                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2589                                  - fgkSSDConnectorSeparation;
2590   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2591                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2592   Double_t ssdwireradius = TMath::Sqrt(TMath::Power(wirex,2.)
2593                                          + TMath::Power(wirey,2));
2594   Double_t wireangle = TMath::ATan(wirex/wirey);
2595   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2596                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2597   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2598                                              fSSDStiffenerHybridWireMedium); 
2599   hybridwire->SetLineColor(fColorPhynox);
2600   TGeoCombiTrans* hybridwirecombitrans[2];
2601   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2602                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2603                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2604                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2605                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2606                                    ssdstiffenershape->GetDZ()
2607                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2608                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2609   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2610                             0.0,
2611                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2612                             0.0,        
2613                             new TGeoRotation("HybridWireRot2",
2614                           - wireangle*TMath::RadToDeg(),0.,0.));
2615   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2616   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2617   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2618   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2619   ssdhybridlist->Add(ssdhybridcapacitormother);
2620   /////////////////////////////////////////////////////////////
2621   // Deallocating memory
2622   /////////////////////////////////////////////////////////////
2623   delete hybridwirecombitrans[0];
2624   delete hybridwirecombitrans[1];
2625   delete ssdchipsystemlist;
2626   return ssdhybridlist;
2627   /////////////////////////////////////////////////////////////
2628 }
2629 ///////////////////////////////////////////////////////////////////////////////
2630 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2631   /////////////////////////////////////////////////////////////
2632   // SSD Cooling Block System
2633   /////////////////////////////////////////////////////////////
2634   // SSD Cooling Block and Cooling Tube Transformations
2635   /////////////////////////////////////////////////////////////
2636   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2637   localcoolingblockrot->SetAngles(0.,90.,0.);
2638   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2639   TVector3* coolingblocktransvector;
2640   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2641                                                                 + fgkSSDCoolingBlockLength,
2642                                                                   fgkSSDSensorLength
2643                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2644                                                                 - fgkSSDCoolingBlockWidth);
2645   const Int_t kcoolingblocktransnumber = 2;
2646   const Int_t kcoolingblocknumber = 4;
2647   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2648   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2649   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2650   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2651   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2652   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2653                                         0.5*fgkSSDCoolingBlockWidth,
2654                                         fgkSSDCoolingBlockHoleCenter);
2655   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2656   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2657   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2658     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2659       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2660                                              j*coolingblocktransvector->Y(),
2661                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2662                                                     + fgkCoolingTubeRmax));
2663       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2664       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2665     }
2666   }
2667   /////////////////////////////////////////////////////////////
2668   // Virtual Volume containing CoolingBlock System   
2669   /////////////////////////////////////////////////////////////
2670   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2671   const Int_t kmothervertexnumber = 16;  
2672   Double_t xmothervertex[kmothervertexnumber];
2673   Double_t ymothervertex[kmothervertexnumber];
2674   ///////////////////////
2675   // Setting the vertices 
2676   ///////////////////////fgkCoolingTubeSupportRmax
2677   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2678   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2679                                    + fgkSSDCoolingBlockWidth;
2680   xmothervertex[2] = coolingblocktransvector->X()
2681                                    + fgkSSDCoolingBlockLength
2682                                    + 4*coolingtubedistance;
2683   ymothervertex[2] = ymothervertex[1];
2684   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2685   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2686   ymothervertex[4] = ymothervertex[0];
2687   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2688   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2689   ymothervertex[6] = ymothervertex[5]; 
2690   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2691                                    - fgkSSDCoolingBlockWidth; 
2692   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2693   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2694                                    - coolingtubedistance;
2695   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2696   ymothervertex[10] = ymothervertex[9];
2697   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2698   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2699   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2700   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2701   ymothervertex[14] = ymothervertex[13];
2702   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2703   //////////////////////////////////////////////////////////
2704   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2705                                                                         xmothervertex,ymothervertex);
2706   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2707                                                                                            + fgkCoolingTubeRmax));
2708   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2709                                                                                            + fgkCoolingTubeRmax));
2710   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2711 //  TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2712 //                                                        coolingsystemothershape,fSSDAir);
2713   /////////////////////////////////////////////////////////////
2714   // SSD Cooling Tube Part 
2715   /////////////////////////////////////////////////////////////
2716   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2717   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2718                                                                                  0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance)); 
2719   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2720                                                                          0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance));
2721   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2722   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2723                                                                         fSSDCoolingTubePhynox);
2724   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2725                                                                         fSSDCoolingTubeWater);
2726   coolingtube[0]->SetLineColor(fColorPhynox);
2727   coolingtube[1]->SetLineColor(fColorWater);
2728   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2729   /////////////////////////////////////////////////////////////
2730   // Adding Cooling block to mother volume
2731   /////////////////////////////////////////////////////////////
2732    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2733 //      coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2734         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2735         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2736   }
2737   /////////////////////////////////////////////////////////////
2738   // Deallocating memory
2739   /////////////////////////////////////////////////////////////
2740         delete coolingblocktransvector;
2741         delete localcoolingblockrot;
2742         delete localcoolingtubetrans;
2743         delete localcoolingtuberot;
2744   /////////////////////////////////////////////////////////////
2745   // Checking overlaps  
2746   /////////////////////////////////////////////////////////////
2747         //coolingsystemother->CheckOverlaps(0.01);
2748   /////////////////////////////////////////////////////////////
2749         return coolingsystemother;
2750 }
2751 /////////////////////////////////////////////////////////////////////////////////
2752 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2753   /////////////////////////////////////////////////////////////
2754   // SSD Flex
2755   /////////////////////////////////////////////////////////////
2756   const Int_t kssdflexlayernumber = 2;
2757   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2758   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2759   const Int_t kmothervertexnumber = 17; 
2760   Double_t xmothervertex[kmothervertexnumber];
2761   Double_t ymothervertex[kmothervertexnumber];
2762   /////////////////////////////////////////////
2763   // Auxiliary variables for vertex positioning
2764   /////////////////////////////////////////////
2765   const Int_t kssdflexboxnumber = 5;
2766   Double_t ssdflexboxlength[kssdflexboxnumber];
2767   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2768                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2769                                           *     fgkSSDChipSeparationLength
2770                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2771                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2772   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2773   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2774                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2775   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2776   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2777                                           -     ssdflexboxlength[1];
2778   Double_t ssdflexboxwidth[kssdflexboxnumber];
2779   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2780   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2781   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2782   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2783   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2784   ///////////////////////
2785   // Setting the vertices 
2786   ///////////////////////
2787   xmothervertex[0]  = 0.0;
2788   xmothervertex[1]  = xmothervertex[0];
2789   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2790   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2791                                         + ssdflexboxlength[4];
2792   xmothervertex[4]  = xmothervertex[3];
2793   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2794   xmothervertex[6]  = xmothervertex[5];
2795   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2796   xmothervertex[8]  = xmothervertex[7];
2797   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2798   xmothervertex[10] = xmothervertex[9]; 
2799   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2800   xmothervertex[12] = xmothervertex[11];
2801   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2802   xmothervertex[14] = xmothervertex[13];
2803   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2804   xmothervertex[16] = xmothervertex[15];
2805   ymothervertex[0]  = 0.0;
2806   ymothervertex[1]  = fgkSSDFlexWidth[1];
2807   ymothervertex[2]  = fgkSSDFlexWidth[0];
2808   ymothervertex[3]  = ymothervertex[2];
2809   ymothervertex[4]  = ymothervertex[0];
2810   ymothervertex[5]  = ymothervertex[4];
2811   ymothervertex[6]  = ssdflexboxwidth[2];
2812   ymothervertex[7]  = ymothervertex[6];
2813   ymothervertex[8]  = ymothervertex[0];
2814   ymothervertex[9]  = ymothervertex[8];
2815   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2816   ymothervertex[11] = ymothervertex[10];
2817   ymothervertex[12] = ymothervertex[0];
2818   ymothervertex[13] = ymothervertex[12];
2819   ymothervertex[14] = ymothervertex[7];
2820   ymothervertex[15] = ymothervertex[14];
2821   ymothervertex[16] = ymothervertex[0];
2822   /////////////////////////////////////////////////////////////
2823   // First Mother Volume containing SSDFlex
2824   /////////////////////////////////////////////////////////////
2825   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2826   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2827                                                                     ymothervertex);
2828   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2829   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2830   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2831 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2832 //                                                                                       fSSDAir);
2833   /////////////////////////////////////////////////////////////
2834   // SSDFlex Layer Shapes
2835   /////////////////////////////////////////////////////////////
2836   for(Int_t i=0; i<kssdflexlayernumber; i++){
2837         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2838                                                                    ymothervertex);
2839     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2840         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2841   }
2842   /////////////////////////////////////
2843   // Setting Layers into Mother Volume
2844   /////////////////////////////////////
2845   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2846   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2847                                                                                                  fSSDKaptonFlexMedium};
2848   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2849                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2850   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2851   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2852   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2853         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2854                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2855                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2856         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2857     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2858                                          +                                         fgkSSDFlexHeight[1])); 
2859     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2860   }
2861   return ssdflexmother;
2862 }
2863 /////////////////////////////////////////////////////////////////////////////////
2864 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2865   /////////////////////////////////////////////////////////////
2866   // Method generating SSD End Flex   
2867   /////////////////////////////////////////
2868   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2869                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2870   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2871                                                 * TMath::DegToRad()*ssdflexradiusmax
2872                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2873                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
2874   const Int_t knedges = 20;  
2875   const Int_t karcnumber = 2;
2876   TVector3* vertexposition[karcnumber*(knedges+1)];
2877   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2878   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2879   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2880   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2881                                                                                  - 90.0*TMath::DegToRad()};
2882   TVector3* referencetrans[karcnumber];
2883   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2884                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2885                                                                    radius[0]);
2886   referencetrans[1] = new TVector3(referencetrans[0]->X()
2887                                         +              fgkSSDFlexLength[2],
2888      -              fgkSSDStiffenerHeight);
2889 for(Int_t i=0; i<karcnumber; i++){
2890         for(Int_t j=0; j<knedges+1; j++){
2891                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2892                                                                                                radius[i]*SinD(angle[i]));
2893                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2894         }       
2895   }
2896   ///////////////////////
2897   // Setting the vertices 
2898   ///////////////////////
2899   const Int_t kendflexlayernumber = 4;
2900   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2901   TVector3** vertex[kendflexlayernumber];
2902   for(Int_t i=0; i<kendflexlayernumber; i++) 
2903                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2904   TVector3* transvector[kendflexlayernumber+1];
2905   TVector3* deltatransvector = new TVector3();  
2906   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2907   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2908                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2909   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2910         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2911                                         *                 CosD(fgkSSDFlexAngle),
2912                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2913                                         *         SinD(fgkSSDFlexAngle),0.0);   
2914         *transvector[i] = *transvector[i-1]+*deltatransvector;
2915   }
2916   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2917   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2918   for(Int_t i=0; i<karcnumber; i++){
2919         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2920                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2921                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2922                                               /radius[i];
2923         }
2924   }
2925   for(Int_t i=0; i<kendflexlayernumber; i++){
2926         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2927         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2928         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2929                 if(j<(knedges+1)){
2930                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2931                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2932                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2933                         *vertex[i][j+2] += *referencetrans[0];
2934                         vertex[i][4*(knedges+1)-j+1] = 
2935                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2936                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2937                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2938                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2939                 }
2940                 else{
2941                 
2942                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2943                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2944                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2945                         *vertex[i][j+2] += *referencetrans[1];
2946                         vertex[i][4*(knedges+1)-j+1] = 
2947                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2948                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2949                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2950                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2951            }
2952         }
2953   }
2954   /////////////////////////////////////////////////////////////
2955   // First Mother Volume containing SSDEndFlex
2956   /////////////////////////////////////////////////////////////
2957   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2958   Double_t xmothervertex[kendflexvertexnumber];
2959   Double_t ymothervertex[kendflexvertexnumber];
2960   xmothervertex[0] = vertex[0][0]->X(); 
2961   ymothervertex[0] = vertex[0][0]->Y();
2962   for(Int_t i=1; i<kendflexvertexnumber; i++){
2963         if(i<2*(knedges+1)+2){
2964                 xmothervertex[i] = vertex[3][i]->X();
2965                 ymothervertex[i] = vertex[3][i]->Y();
2966         }
2967         else{
2968                 xmothervertex[i] = vertex[0][i]->X();
2969                 ymothervertex[i] = vertex[0][i]->Y();
2970         }
2971   }
2972   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2973                                                                            xmothervertex,ymothervertex);
2974   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2975   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2976   TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2977                                                                  ssdendflexmothershape,fSSDAir);        
2978   //////////////////////////////////////
2979   // End Flex TGeoXtru Layer Definition 
2980   //////////////////////////////////////
2981   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2982   TGeoVolume* ssdendflex[kendflexlayernumber];
2983   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2984   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2985   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2986   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2987   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2988                                                                                                         fSSDKaptonFlexMedium};
2989   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2990                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2991   for(Int_t i=0; i<kendflexlayernumber; i++){
2992         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2993                 xvertex[i][j] = vertex[i][j]->X();
2994                 yvertex[i][j] = vertex[i][j]->Y();
2995         }
2996   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2997   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2998   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2999   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
3000                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
3001   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
3002   ssdendflexmother->AddNode(ssdendflex[i],1);
3003   }
3004   /////////////////////////////////////////////////////////////
3005   // Deallocating memory
3006   /////////////////////////////////////////////////////////////
3007   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
3008   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
3009   for(Int_t i=0; i<kendflexlayernumber; i++){
3010         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
3011         delete [] vertex[i];
3012   }
3013   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
3014   delete deltatransvector;
3015   /////////////////////////////////////////////////////////////
3016   //ssdendflexmother->CheckOverlaps(0.01);
3017   return ssdendflexmother;
3018 }
3019 ///////////////////////////////////////////////////////////////////////////////
3020 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3021   /////////////////////////////////////////////////////////////
3022   // Method generating the Mounting Block
3023   /////////////////////////////////////////////////////////////  
3024   const Int_t kvertexnumber = 8;
3025   Double_t xvertex[kvertexnumber];
3026   Double_t yvertex[kvertexnumber];
3027   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3028   xvertex[1] = xvertex[0];
3029   xvertex[2] = -xvertex[0];
3030   xvertex[3] = xvertex[2];
3031   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3032                          -                                 fgkSSDMountingBlockLength[2]);
3033   xvertex[5] = xvertex[4];
3034   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3035                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3036                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3037   xvertex[7] = xvertex[6];
3038   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3039                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3040                          -  fgkSSDModuleVerticalDisalignment;
3041   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3042   yvertex[2] = yvertex[1]; 
3043   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3044   yvertex[4] = yvertex[3];
3045   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3046                          - fgkSSDMountingBlockHeight[0];
3047   yvertex[6] = yvertex[5];
3048   yvertex[7] = yvertex[0];
3049   ///////////////////////////////////////////////////////////////////////
3050   // TGeoXTru Volume definition for Mounting Block Part
3051   ///////////////////////////////////////////////////////////////////////
3052   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3053   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3054   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3055   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3056   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3057                                                                           ssdmountingblockshape,
3058                                                                                   fSSDMountingBlockMedium);
3059   ssdmountingblock->SetLineColor(fColorG10);
3060   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3061   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3062   TGeoRotation* mountingblockrot = new TGeoRotation();
3063   mountingblockrot->SetAngles(90.,180.,-90.);
3064   mountingblockcombitrans->SetRotation(*mountingblockrot);
3065   /////////////////////////////////////////////////////////////
3066   // Generating the Mounting Block Screw Vertices 
3067   /////////////////////////////////////////////////////////////  
3068   const Int_t kscrewvertexnumber = 15;
3069   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3070                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3071                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3072                                  * TMath::RadToDeg();
3073   Double_t phi0 = 90.+alpha;
3074   Double_t phi = 270.-2*alpha;
3075   Double_t deltaphi = phi/kscrewvertexnumber;   
3076   TVector3* screwvertex[kscrewvertexnumber+1];
3077   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3078         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3079                                    *CosD(phi0+i*deltaphi),
3080                                    fgkSSDMountingBlockScrewHoleRadius[0]
3081                                    *SinD(phi0+i*deltaphi));
3082   Double_t xscrewvertex[kscrewvertexnumber+6];
3083   Double_t yscrewvertex[kscrewvertexnumber+6];
3084   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3085   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3086                                   -               fgkSSDMountingBlockScrewHoleEdge);
3087   xscrewvertex[1] = xscrewvertex[0];
3088   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3089   xscrewvertex[2] = screwvertex[0]->X();
3090   yscrewvertex[2] = yscrewvertex[1];
3091   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3092         xscrewvertex[i+3] = screwvertex[i]->X();        
3093         yscrewvertex[i+3] = screwvertex[i]->Y();        
3094   } 
3095   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3096   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3097   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3098   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3099   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3100   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3101   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3102   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3103                                                         +                                  fgkSSDMountingBlockHeight[2]);
3104   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3105                                                                                 ssdmountingblockscrewshape,
3106                                                                                             fSSDMountingBlockMedium);
3107   ssdmountingblockscrew->SetLineColor(fColorG10);
3108   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3109   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3110   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3111                                                                         -                                yscrewvertex[1],
3112                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3113                                                                         -                                fgkSSDMountingBlockHeight[2]
3114                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3115                                                                         +                                fgkSSDMountingBlockHeight[2]
3116                                                                         -                                yvertex[0]));
3117   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3118                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3119                                                                                                                  yscrewvertex[1]
3120                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3121                                                                                                          +fgkSSDMountingBlockHeight[2]
3122                                                                                                          -yvertex[0]));
3123   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3124                                                                                                           yscrewvertex[1],
3125                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3126                                                                         +                                 fgkSSDMountingBlockHeight[2]
3127                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3128                                                                         +                                 fgkSSDMountingBlockHeight[2]
3129                                                                         -                                 yvertex[0]));
3130   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3131                                                                                                          yscrewvertex[1],
3132                                                                         -                                yscrewvertex[1]
3133                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3134                                                                         +                                fgkSSDMountingBlockHeight[2]
3135                                                                         -                                yvertex[0]));
3136   TGeoRotation* ssdmountingblockscrewrot[4];
3137   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3138         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3139     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3140     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3141   for(Int_t i=1; i<4; i++) 
3142         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3143   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3144   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3145   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3146   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3147                                                          +                                xvertex[0],yscrewvertex[1]
3148                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3149                                                          +                                fgkSSDMountingBlockHeight[2]
3150                                                          -                                yvertex[0]),0.);      
3151   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3152   for(Int_t i=0; i<4; i++){
3153         ssdmountingblockscrewmatrix[i] = 
3154                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3155         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3156   }
3157   ///////////////////////////////////////////////////////////////////////
3158   // TGeoXtru for Mother Volume 
3159   ///////////////////////////////////////////////////////////////////////
3160   const Int_t kvertexmothernumber = 12;
3161   Double_t xmothervertex[kvertexmothernumber];
3162   Double_t ymothervertex[kvertexmothernumber];
3163   for(Int_t i=0; i<6; i++){
3164         xmothervertex[i] = xvertex[i];
3165         ymothervertex[i] = yvertex[i];
3166   } 
3167   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3168   ymothervertex[6]  = ymothervertex[5];
3169   xmothervertex[7]  = xmothervertex[6];
3170   ymothervertex[7]  = ymothervertex[4];
3171   xmothervertex[8]  = xmothervertex[7]
3172                                         + 0.5*(fgkSSDMountingBlockLength[1]
3173                                         -          fgkSSDMountingBlockLength[2]);
3174   ymothervertex[8]  = ymothervertex[4];
3175   xmothervertex[9]  = xmothervertex[8];
3176   ymothervertex[9]  = ymothervertex[2];
3177   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3178   ymothervertex[10] = ymothervertex[1];
3179   xmothervertex[11] = xmothervertex[10];
3180   ymothervertex[11] = ymothervertex[0];  
3181   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3182   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3183   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3184   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3185   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3186                                                                           ssdmountingblockmothershape,
3187                                                                                   fSSDAir);
3188   /////////////////////////////////////////////////////////////
3189   // Placing the Volumes into Mother Volume 
3190   /////////////////////////////////////////////////////////////
3191   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3192   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3193   for(Int_t i=0; i<4; i++) 
3194         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3195                                                                         ssdmountingblockscrewmatrix[i]);
3196   /////////////////////////////////////////////////////////////
3197   // Deallocating memory
3198   /////////////////////////////////////////////////////////////
3199   delete mountingblockrot;
3200   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3201   delete ssdmountingblockglobalrot; 
3202   delete ssdmountingblockglobaltrans; 
3203   /////////////////////////////////////////////////////////////
3204   return ssdmountingblockmother;
3205 }
3206 ///////////////////////////////////////////////////////////////////////////////
3207  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3208   /////////////////////////////////////////////////////////////
3209   // Method generating the Mounting Block Clip 
3210   /////////////////////////////////////////////////////////////  
3211   const Int_t kmothervertexnumber = 10;
3212   Double_t xmothervertex[kmothervertexnumber];
3213   Double_t ymothervertex[kmothervertexnumber];
3214   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3215                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3216   xmothervertex[1] = xmothervertex[0];
3217   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3218                                    - fgkMountingBlockClibScrewRadius);
3219   xmothervertex[3] = xmothervertex[2]; 
3220   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3221   xmothervertex[5] = xmothervertex[4]; 
3222   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3223   xmothervertex[7] = xmothervertex[6]; 
3224   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3225   xmothervertex[9] = xmothervertex[8]; 
3226   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3227                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3228                                    - fgkSSDModuleVerticalDisalignment;
3229   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3230   ymothervertex[2] = ymothervertex[1];
3231   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3232                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3233                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3234   ymothervertex[4] = ymothervertex[3];
3235   ymothervertex[5] = ymothervertex[2];
3236   ymothervertex[6] = ymothervertex[5];
3237   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3238   ymothervertex[8] = ymothervertex[7];
3239   ymothervertex[9] = ymothervertex[0];
3240   ///////////////////////////////////////////////////////////////////////
3241   // TGeoXTru Volume definition for Mounting Block Clip Part
3242   ///////////////////////////////////////////////////////////////////////
3243   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3244   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3245   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3246   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3247   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3248                                                                           ssdmountingblockclipshape,fSSDAir);
3249   ssdmountingblockclip->SetLineColor(4);
3250   ///////////////////////////////////////////////////////////////////////
3251   // TGeoXTru Volume definition for Clip 
3252   ///////////////////////////////////////////////////////////////////////
3253   const Int_t kclipvertexnumber = 6;
3254   Double_t xclipvertex[kclipvertexnumber];
3255   Double_t yclipvertex[kclipvertexnumber];
3256   xclipvertex[0] = xmothervertex[0];
3257   xclipvertex[1] = xclipvertex[0];
3258   xclipvertex[2] = xmothervertex[6];
3259   xclipvertex[3] = xclipvertex[2];
3260   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3261   xclipvertex[5] = xclipvertex[4];
3262   yclipvertex[0] = ymothervertex[0];
3263   yclipvertex[1] = ymothervertex[1];
3264   yclipvertex[2] = yclipvertex[1];
3265   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3266   yclipvertex[4] = yclipvertex[3];
3267   yclipvertex[5] = yclipvertex[0];
3268   TGeoXtru* clipshape = new TGeoXtru(2);
3269   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3270   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3271   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3272                                                          +   fgkMountingBlockClibWidth);
3273   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3274   clip->SetLineColor(18);
3275   ///////////////////////////////////////////////////////////////////////
3276   // Ladder Support Piece  
3277   ///////////////////////////////////////////////////////////////////////
3278   const Int_t ksupportvertexnumber = 4;
3279   Double_t xsupportvertex[ksupportvertexnumber];
3280   Double_t ysupportvertex[ksupportvertexnumber];
3281   xsupportvertex[0] = xclipvertex[5];
3282   xsupportvertex[1] = xsupportvertex[0];
3283   xsupportvertex[2] = xmothervertex[9];
3284   xsupportvertex[3] = xsupportvertex[2];
3285   ysupportvertex[0] = yclipvertex[0];
3286   ysupportvertex[1] = yclipvertex[3];
3287   ysupportvertex[2] = ysupportvertex[1];
3288   ysupportvertex[3] = ysupportvertex[0];
3289   TGeoXtru* supportshape = new TGeoXtru(2);
3290   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3291   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3292   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3293   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3294   support->SetLineColor(9);
3295   ///////////////////////////////////////////////////////////////////////
3296   // TGeoXTru Volume definition for Screw   
3297   ///////////////////////////////////////////////////////////////////////
3298   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3299                                                 0.5*fgkMountingBlockClibScrewRadius};
3300   Int_t edgesnumber[2] = {50,6};
3301   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3302                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3303   TGeoXtru* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3304   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3305   clipscrew->SetLineColor(12);
3306   TGeoRotation* screwrot = new TGeoRotation();
3307   screwrot->SetAngles(0.,90.,0.);
3308   TGeoTranslation* screwtrans = new TGeoTranslation();
3309   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3310                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3311                                                          0.5*fgkSSDMountingBlockWidth+
3312                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3313   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3314   ///////////////////////////////////////////////////////////////////////
3315   // Placing the Volumes
3316   ///////////////////////////////////////////////////////////////////////
3317   ssdmountingblockclip->AddNode(clip,1);
3318   ssdmountingblockclip->AddNode(support,1);
3319   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3320   /////////////////////////////////////////////////////////////
3321   // Deallocating memory
3322   /////////////////////////////////////////////////////////////  
3323   delete screwtrans;
3324   delete screwrot;
3325   /////////////////////////////////////////////////////////////
3326   return ssdmountingblockclip;
3327 }
3328 ///////////////////////////////////////////////////////////////////////////////
3329 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3330   /////////////////////////////////////////////////////////////
3331   // Method generating the Cooling Tube 
3332   /////////////////////////////////////////////////////////////  
3333    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3334    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3335                                                                                                 new     TGeoTube*[2];
3336    // Ladder Cooling Tubes
3337    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3338                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3339                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth));
3340    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3341                                                                                  coolingtubeshape[0][0]->GetDz());
3342    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3343                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3344                                                   -                                       fgkSSDSensorOverlap));
3345    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3346                                                                                  coolingtubeshape[1][0]->GetDz());
3347    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3348                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]));
3349    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3350                                                                                  coolingtubeshape[2][0]->GetDz());
3351    // End Ladder Cooling Tubes  
3352    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3353    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3354    endladdercoolingtubeshape[i] = new   TGeoTube*[2];
3355    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3356                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3357                                                   -                     fgkendladdercoolingsupportdistance[0]-fgkSSDTolerance));
3358    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3359                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3360    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3361                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3362                                                   +                     fgkendladdercoolingsupportdistance[1]
3363                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3364    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3365                                                                         endladdercoolingtubeshape[1][0]->GetDz());
3366    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3367                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3368                                                   -                     fgkEndLadderMountingBlockPosition[0]
3369                                                   -                     fgkendladdercoolingsupportdistance[1]           
3370                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3371    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3372                                                                         endladdercoolingtubeshape[2][0]->GetDz());
3373    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3374                                                           0.50 * (fgkMountingBlockToSensorSupport
3375                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3376                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3377                                                         +                 fgkSSDSensorOverlap
3378                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3379                                                         -                 fgkendladdercoolingsupportdistance[2]
3380                                                         -                 fgkEndLadderMountingBlockPosition[1]
3381                                                         -                 fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3382    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3383                                                                         endladdercoolingtubeshape[3][0]->GetDz());
3384    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3385                                                           0.50 * (fgkendladdercoolingsupportdistance[2]-fgkSSDTolerance));
3386    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3387                                                                         endladdercoolingtubeshape[4][0]->GetDz());
3388    // Ladder Cooling Tubes
3389    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3390    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3391                                                                                          new TGeoVolume*[2];
3392    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3393                                                                           fSSDCoolingTubePhynox);
3394    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3395                                                                           fSSDCoolingTubeWater);
3396    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3397                                                                           fSSDCoolingTubePhynox);
3398    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3399                                                                           fSSDCoolingTubeWater);
3400    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3401                                                                           fSSDCoolingTubePhynox);
3402    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3403                                                                           fSSDCoolingTubeWater);
3404    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3405         coolingtube[i][0]->SetLineColor(fColorPhynox);
3406         coolingtube[i][1]->SetLineColor(fColorWater);
3407    }
3408    // End Ladder Cooling Tubes  
3409    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3410    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3411    endladdercoolingtube[i] = new TGeoVolume*[2];
3412    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3413                                                                 endladdercoolingtubeshape[0][0],
3414                                                                 fSSDCoolingTubePhynox);
3415    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3416                                                                 endladdercoolingtubeshape[0][1],
3417                                                                 fSSDCoolingTubeWater);
3418    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3419                                                                 endladdercoolingtubeshape[1][0],
3420                                                                 fSSDCoolingTubePhynox);
3421    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3422                                                                 endladdercoolingtubeshape[1][1],
3423                                                                 fSSDCoolingTubeWater);
3424    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3425                                                                 endladdercoolingtubeshape[2][0],
3426                                                                 fSSDCoolingTubePhynox);
3427    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3428                                                                 endladdercoolingtubeshape[2][1],
3429                                                                 fSSDCoolingTubeWater);
3430    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3431                                                                 endladdercoolingtubeshape[3][0],
3432                                                                 fSSDCoolingTubePhynox);
3433    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3434                                                                 endladdercoolingtubeshape[3][1],
3435                                                                 fSSDCoolingTubeWater);
3436    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3437                                                                 endladdercoolingtubeshape[4][0],
3438                                                                 fSSDCoolingTubePhynox);
3439    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3440                                                                 endladdercoolingtubeshape[4][1],
3441                                                                 fSSDCoolingTubeWater);
3442    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3443                 endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3444                 endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3445    }
3446   /////////////////////////////////////////////////////////////
3447   // Virtual Volume containing Cooling Tubes
3448   /////////////////////////////////////////////////////////////
3449   // Ladder Cooling Tubes
3450   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3451   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3452   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3453                                                                                         coolingtubeshape[i][0]->GetRmax(),
3454                                                                                         coolingtubeshape[i][0]->GetDz());
3455   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3456   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3457                                                                           fSSDAir);
3458   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3459                                                                           fSSDAir);
3460   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3461                                                                           fSSDAir);
3462   // End Ladder Cooling Tubes
3463   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3464   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3465   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3466                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3467                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3468   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3469   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3470                                                                           endladdervirtualcoolingtubeshape[0],
3471                                                                           fSSDAir);
3472   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3473                                                                           endladdervirtualcoolingtubeshape[1],
3474                                                                           fSSDAir);
3475   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3476                                                                           endladdervirtualcoolingtubeshape[2],
3477                                                                           fSSDAir);
3478   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3479                                                                           endladdervirtualcoolingtubeshape[3],
3480                                                                           fSSDAir);
3481   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3482                                                                           endladdervirtualcoolingtubeshape[4],
3483                                                                           fSSDAir);
3484   TList* coolingtubelist = new TList();
3485   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3486         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3487         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3488     coolingtubelist->Add(virtualcoolingtube[i]);
3489   }
3490         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3491         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3492     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3493         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3494         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3495     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3496         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3497         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3498     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3499         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3500         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3501     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3502         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3503         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3504     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3505   return coolingtubelist;
3506 }
3507 ///////////////////////////////////////////////////////////////////////////////
3508 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3509   /////////////////////////////////////////////////////////////
3510   // Method generating SSD Cooling Block    
3511   /////////////////////////////////////////////////////////////
3512   const Int_t kvertexnumber = 8;
3513   ///////////////////////////////////////
3514   // Vertex Positioning for TGeoXTru
3515   ///////////////////////////////////////
3516   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3517   vertexposition[0] = new TVector3(0.0,0.0);
3518   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3519   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3520                                           vertexposition[1]->Y());
3521   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3522                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3523   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3524   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3525                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3526   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3527                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3528                                         - fgkSSDCoolingBlockHoleLength[0]
3529                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3530                                           fgkSSDCoolingBlockHeight[0]
3531                                         - fgkSSDCoolingBlockHoleRadius[1],
3532                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3533   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3534                                         - fgkSSDCoolingBlockHoleLength[0]),
3535                                           vertexposition[6]->Y());
3536   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3537                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3538   Double_t phi = 180.-alpha;
3539   Double_t psi = 180.+2.*alpha;
3540   Double_t deltapsi = psi/nedges;
3541   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3542   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3543                                                   fgkSSDCoolingBlockHoleCenter);
3544   for(Int_t i=0; i<nedges+1; i++){
3545         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3546                                                                                                radius*SinD(phi+i*deltapsi));
3547    *vertexposition[kvertexnumber+i] += (*transvector);
3548   }
3549   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3550   for(Int_t i=0; i<kvertexnumber; i++)
3551     vertexposition[kvertexnumber+nedges+1+i] = 
3552                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3553   ///////////////////////////////////////////////////////////////////////
3554   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3555   ///////////////////////////////////////////////////////////////////////
3556   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3557   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3558   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3559   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3560         xvertexpoints[i] = vertexposition[i]->X();
3561         yvertexpoints[i] = vertexposition[i]->Y();
3562   } 
3563   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3564                                                                                         yvertexpoints);
3565   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3566   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3567   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3568                                                                           ssdcoolingblockshape,
3569                                                                                   fSSDAlCoolBlockMedium);
3570   ssdcoolingblock->SetLineColor(fColorAl);
3571   /////////////////////////////////////////////////////////////
3572   // Deallocating memory
3573   /////////////////////////////////////////////////////////////
3574   delete [] vertexposition;
3575   delete xvertexpoints;
3576   delete yvertexpoints;
3577   /////////////////////////////////////////////////////////////
3578   return ssdcoolingblock;
3579 }
3580 /////////////////////////////////////////////////////////////////////////////////
3581 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3582   ///////////////////////////////////////////////////////
3583   const Int_t kssdchipcablesnumber    = 2;
3584   const Int_t kssdchipcableslaynumber = 2;
3585   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3586   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3587   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3588   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3589                                                  -  fgkSSDChipCablesHeight[0]
3590                                                  -  fgkSSDChipCablesHeight[1]);
3591   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3592   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3593   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3594                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3595                                                           - ssdchipcablesradius[0]
3596                                                           - fgkSSDChipCablesWidth[1]
3597                                                           - fgkSSDChipCablesWidth[2]);
3598   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3599                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3600                                                           +      fgkSSDChipCablesHeight[1]
3601                                                           +      fgkSSDSensorHeight);
3602   ///////////////////////////////////////////////////////
3603   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3604   ///////////////////////////////////////////////////////
3605   TVector3** vertexposition[kssdchipcableslaynumber];
3606   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3607                                                                                                   new TVector3*[4*(nedges+1)+4];
3608   Double_t ratio[4];
3609   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3610   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3611                    /  ssdchipcablesradius[0]; 
3612   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3613                    /  ssdchipcablesradius[0];
3614   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3615                    +  fgkSSDChipCablesHeight[1])
3616                    /  ssdchipcablesradius[0];
3617   Double_t phi = 180.;
3618   Double_t deltaphi = 180./nedges;
3619   Double_t angle = 0.0;
3620   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3621   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3622   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3623         xvertexpoints[i] = new Double_t[kvertexnumber];
3624         yvertexpoints[i] = new Double_t[kvertexnumber];
3625   }  
3626   TVector3* vertex = new TVector3();
3627   TVector3* transvector[kssdchipcableslaynumber];
3628   transvector[0] = new TVector3(fgkSSDChipWidth,
3629                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3630   transvector[1] = new TVector3();
3631   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3632   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3633   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3634                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3635                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3636   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3637         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3638         transvector[1]->SetY(ssdchipcablesradius[0]
3639                                  +               fgkSSDChipCablesHeight[0]
3640                                  +               fgkSSDChipCablesHeight[1]);  
3641         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3642                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3643                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3644                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3645                                                          - i*fgkSSDChipCablesHeight[0]);
3646                 vertexposition[i][2*(nedges+1)+2] = 
3647                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3648                                 +                                fgkSSDChipCablesWidth[1]
3649                                 +                                fgkSSDChipCablesWidth[2],
3650                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3651                                 +                                fgkSSDChipCablesHeight[1]));
3652         vertexposition[i][2*(nedges+1)+3] = 
3653                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3654                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3655                                 -                                fgkSSDChipCablesHeight[i]);
3656             for(Int_t j=0; j<nedges+1; j++){            
3657                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3658                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3659                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3660                         vertexposition[0][(nedges+1)*i+j+2] = 
3661                                                 new TVector3(*vertex+*transvector[i]);
3662                         vertexposition[1][(nedges+1)*i+j+2] = 
3663                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3664                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3665                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3666                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3667                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3668                                                 new TVector3(vertex->X()*ratio[2*i+1]
3669                                                         +                        transvector[i]->X(),
3670                                                                                  vertex->Y()*ratio[2*i+1]
3671                                                         +                transvector[i]->Y());
3672                 }
3673         }
3674         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3675                 for(Int_t j=0; j<kvertexnumber; j++){   
3676                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3677                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3678                 }
3679                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3680                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3681                                                                                 xvertexpoints[i],yvertexpoints[i]);
3682                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3683                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3684                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3685                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3686                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3687                                                           (kssdchipcablesnumber*k+i)%2==0?
3688                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3689                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3690         }
3691         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3692                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3693   }
3694   /////////////////////////////////////////////////////////////
3695   // Mother Volume definition 
3696   /////////////////////////////////////////////////////////////
3697   Double_t ssdchipseparation = fgkSSDSensorLength
3698                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3699                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3700                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3701   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3702   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3703                                                           +fgkSSDChipCablesWidth[1]
3704                                                           +fgkSSDChipCablesWidth[2]);
3705   Double_t dy = fgkSSDChipCablesLength[1];
3706   Double_t dz = SSDChipCablesHeigth;
3707   TGeoBBox* ssdchipcablesmotherbox = new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3708   TGeoVolumeAssembly* ssdchipcablesmother = new TGeoVolumeAssembly("SSDChipCablesMother");
3709 //  TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3710 //                        ssdchipcablesmotherbox,fSSDAir);
3711   /////////////////////////////////////////////////////////////
3712   // Rotation and Translation Definition for positioning 
3713   /////////////////////////////////////////////////////////////
3714   TGeoRotation* ssdchipcablesrot[5];
3715   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3716   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3717   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3718   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3719   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3720   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3721                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3722   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3723   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3724   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3725   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3726   /////////////////////////////////////////////////////////////
3727   // Deallocating memory
3728   /////////////////////////////////////////////////////////////
3729   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3730         delete [] xvertexpoints[i];
3731         delete [] yvertexpoints[i];
3732   }
3733   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3734   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3735   delete vertex; 
3736   delete ssdchipcablesrot[0];
3737   delete ssdchipcablesrot[1];
3738   delete ssdchipcablesrot[3];
3739   /////////////////////////////////////////////////////////////
3740   return ssdchipcablesmother;
3741 }
3742 ///////////////////////////////////////////////////////////////////////////////
3743 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3744   /////////////////////////////////////////////////////////////
3745   // SSD Chip Assembly
3746   /////////////////////////////////////////////////////////////
3747   TGeoVolume* ssdchipassembly = GetSSDChips();
3748   TList* ssdchipsystemlist = new TList();
3749 //  const Int_t knedges = 20;
3750   const Int_t knedges = 5;
3751   const Int_t kchipsystemnumber = 2;
3752   /////////////////////////////////////////////////////////////
3753   // Mother Volume containing SSDChipSystem
3754   /////////////////////////////////////////////////////////////
3755   TGeoXtru* chipsystemothershape[kchipsystemnumber];
3756   for(Int_t i=0; i<kchipsystemnumber; i++) chipsystemothershape[i] = new TGeoXtru(2);
3757   const Int_t kmothervertexnumber = 12;  
3758   Double_t xmothervertex[kchipsystemnumber][kmothervertexnumber];
3759   Double_t ymothervertex[kchipsystemnumber][kmothervertexnumber];
3760   Double_t ssdchipcablesradius[kchipsystemnumber];
3761   Double_t ssdchipseparation = fgkSSDSensorLength
3762                              - 2.*fgkSSDModuleStiffenerPosition[1]
3763                              - 2.*(fgkSSDStiffenerWidth
3764                              - fgkSSDStiffenerToChipDist-0.5*fgkSSDChipWidth);
3765   for(Int_t i=0; i<kchipsystemnumber; i++)
3766         ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
3767                                                    -  fgkSSDChipCablesHeight[0]
3768                                                    -  fgkSSDChipCablesHeight[1]);
3769   ///////////////////////
3770   // Setting the vertices 
3771   ///////////////////////
3772   xmothervertex[0][0]  = -0.5*fgkSSDChipCablesLength[1];  
3773   xmothervertex[0][1]  = xmothervertex[0][0];  
3774   xmothervertex[0][2]  = (fgkSSDChipNumber-1)*(fgkSSDChipLength
3775                                            + fgkSSDChipSeparationLength)+0.5*fgkSSDChipCablesLength[1];  
3776   xmothervertex[0][3]  = xmothervertex[0][2];  
3777   xmothervertex[0][4]  = 0.5*fgkSSDChipCablesLength[1];  
3778   xmothervertex[0][5]  = xmothervertex[0][4];  
3779   xmothervertex[0][6]  = xmothervertex[0][2]-0.5*fgkSSDChipCablesLength[1];  
3780   xmothervertex[0][7]  = xmothervertex[0][6]; 
3781   xmothervertex[0][8]  = 0.0;  
3782   xmothervertex[0][9]  = xmothervertex[0][8];  
3783   xmothervertex[0][10] = xmothervertex[0][4];  
3784   xmothervertex[0][11] = xmothervertex[0][10];  
3785   for(Int_t i=0; i<kmothervertexnumber; i++) 
3786         xmothervertex[1][i] = xmothervertex[0][i]; 
3787   for(Int_t i=0; i<kchipsystemnumber; i++){
3788         ymothervertex[i][0]  = -0.5*fgkSSDChipWidth-ssdchipcablesradius[i]
3789                                                  - fgkSSDChipCablesWidth[1]-fgkSSDChipCablesWidth[2];
3790         ymothervertex[i][1]  = ssdchipseparation-ymothervertex[i][0];
3791         ymothervertex[i][2]  = ymothervertex[i][1];
3792         ymothervertex[i][3]  = ymothervertex[i][0];
3793         ymothervertex[i][4]  = ymothervertex[i][0];
3794         ymothervertex[i][5]  = 0.5*fgkSSDChipWidth;
3795         ymothervertex[i][6]  = ymothervertex[i][5];
3796         ymothervertex[i][7]  = ssdchipseparation-0.5*fgkSSDChipWidth;
3797         ymothervertex[i][8]  = ymothervertex[i][7];
3798         ymothervertex[i][9]  = ymothervertex[i][5];
3799         ymothervertex[i][10] = ymothervertex[i][5];
3800         ymothervertex[i][11] = ymothervertex[i][4];
3801   }
3802   //////////////////////////////////////////////////////////
3803 //  TGeoVolume* chipsystemother[kchipsystemnumber];
3804   TGeoVolumeAssembly* chipsystemother[kchipsystemnumber];
3805   const char* chipsytemothername[kchipsystemnumber] = 
3806                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3807   for(Int_t i=0; i<kchipsystemnumber; i++){
3808     chipsystemothershape[i]->DefinePolygon(kmothervertexnumber,
3809                                                                         xmothervertex[i],ymothervertex[i]);
3810     chipsystemothershape[i]->DefineSection(0,-fgkSSDChipCablesHeight[i+2]
3811                                                                                   -0.5*fgkSSDChipHeight);
3812     chipsystemothershape[i]->DefineSection(1,0.5*fgkSSDChipHeight);
3813 //    chipsystemother[i] = new TGeoVolume(chipsytemothername[i],
3814 //                                                        chipsystemothershape[i],fSSDAir);
3815     chipsystemother[i] = new TGeoVolumeAssembly(chipsytemothername[i]);
3816   }
3817   /////////////////////////////////////////////////////////////
3818   // SSD Chip Cables
3819   /////////////////////////////////////////////////////////////
3820   TGeoVolume* ssdchipcables[kchipsystemnumber];
3821   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3822   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3823   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3824   //////////////////
3825   for(Int_t i=0; i<kchipsystemnumber; i++){
3826                 ssdchipcables[i] = 
3827                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3828                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3829                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3830                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3831   }
3832   for(Int_t i=0; i<kchipsystemnumber; i++){
3833         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3834                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3835                 ssdchipcablesrot[i][j] = new TGeoRotation();
3836                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3837                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3838                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3839                                                   +                fgkSSDChipSeparationLength),
3840                                                                                         0.5*fgkSSDChipWidth,
3841                                                   -                                     0.5*fgkSSDChipHeight
3842                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3843                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3844                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3845                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3846         }
3847         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3848         ssdchipsystemlist->Add(chipsystemother[i]);     
3849   }
3850   /////////////////////////////////////////////////////////////
3851   // Deallocating memory
3852   /////////////////////////////////////////////////////////////
3853   for(Int_t i=0; i<kchipsystemnumber; i++){
3854         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3855                 delete ssdchipcablesrot[i][j];
3856                 delete ssdchipcablestrans[i][j];
3857         }
3858         delete ssdchipcablesrot[i];
3859         delete ssdchipcablestrans[i];
3860   }
3861   /////////////////////////////////////////////////////////////
3862   return ssdchipsystemlist;
3863 }
3864 ///////////////////////////////////////////////////////////////////////////////
3865 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3866   /////////////////////////////////////////////////////////////
3867   // SSD Chip Assembly Generation    
3868   /////////////////////////////////////////////////////////////
3869   const Int_t kssdchiprownumber = 2;
3870   TGeoBBox* ssdchipcompshape[2];
3871   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3872                                                                                 0.5*fgkSSDChipLength,
3873                                                                                 0.5*fgkSSDChipWidth,
3874                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3875   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3876                                                                                 0.5*fgkSSDChipLength,
3877                                                                                 0.5*fgkSSDChipWidth,
3878                                                                                 0.5*fgkSSDChipGlueHeight);
3879   TGeoVolume* ssdchipcomp[2];
3880   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3881   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3882                                                                   fSSDChipGlueMedium);
3883   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3884   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3885   TGeoTranslation* ssdchipcomptrans[2];
3886   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3887   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3888   /////////////////////////////////////////////////////////////
3889   // Virtual Volume containing SSDChip   
3890   /////////////////////////////////////////////////////////////
3891   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3892                                                                                                                  0.5*fgkSSDChipWidth,
3893                                                                                                                  0.5*fgkSSDChipHeight);
3894   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3895   /////////////////////////////////////////////////////////////
3896   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3897   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3898                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3899                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3900                                    -  0.5*fgkSSDChipWidth)};
3901   /////////////////////////////////////////////////////////////
3902   // Virtual Volume containing SSDChipAssembly   
3903   /////////////////////////////////////////////////////////////
3904   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3905   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3906   Double_t xmothervertex[kssdmothervertexnumber];
3907   Double_t ymothervertex[kssdmothervertexnumber];
3908   ///////////////////////
3909   // Setting the vertices 
3910   ///////////////////////
3911   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3912   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3913                                    - ymothervertex[0];
3914   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3915   ymothervertex[2] = ymothervertex[1];
3916   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3917   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3918   ymothervertex[4] = ymothervertex[0];
3919   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3920   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3921                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3922   ymothervertex[6] = ymothervertex[5];
3923   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3924                                    - fgkSSDChipWidth;
3925   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3926   ymothervertex[8] = ymothervertex[7];
3927   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3928   ymothervertex[9] = ymothervertex[6];
3929   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3930   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3931   //////////////////////////////////////////////////////////
3932   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3933                                                                         xmothervertex,ymothervertex);
3934   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3935   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3936   TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3937                                                           ssdchipmothershape,fSSDAir);
3938    /////////////////////////////////////////////////////////////
3939   for(Int_t i=0; i<kssdchiprownumber; i++)
3940     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3941                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3942                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3943   return ssdchipmother;
3944 }
3945 /////////////////////////////////////////////////////////////////////////////////
3946 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3947   /////////////////////////////////////////////////////////////
3948   // Method returning a List containing pointers to Ladder Cable Volumes    
3949   /////////////////////////////////////////////////////////////
3950   const Int_t kladdercablesegmentnumber = 2;
3951   /////////////////////////////////////////
3952   // LadderSegmentBBox Volume
3953   /////////////////////////////////////////
3954   TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber];
3955   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3956                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3957   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3958                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3959                                                                            0.5*fgkSSDFlexWidth[0],
3960                                                                            0.5*fgkSSDLadderCableWidth,
3961                                                                            0.5*fgkSSDFlexHeight[i]); 
3962   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3963                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3964   TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3965   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3966                         laddercablesegmentbbox[i] =
3967                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3968                                                                                  laddercablesegmentbboxshape[i],
3969                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3970             fSSDKaptonLadderCableMedium));
3971                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3972                                                                                                                    fColorPolyhamide);
3973   }
3974   TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber];                                                                                
3975   laddercablesegmentbboxtrans[0] = 
3976                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3977                                                                                            0.5*fgkSSDFlexWidth[0],
3978                                                                                            0.5*fgkSSDLadderCableWidth,
3979                                                                                            0.5*fgkSSDFlexHeight[0]);
3980   laddercablesegmentbboxtrans[1] = 
3981                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3982                                                                                            0.5*fgkSSDFlexWidth[0],
3983                                                                                            0.5*fgkSSDLadderCableWidth,
3984                                                                                            fgkSSDFlexHeight[0]
3985                                                                                            +0.5*fgkSSDFlexHeight[1]);
3986   TGeoVolume* laddercablesegmentbboxassembly = 
3987                                                    new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly"); 
3988   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3989                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3990                                                                                             laddercablesegmentbboxtrans[i]);
3991 /////////////////////////////////////////
3992 // LadderSegmentArb8 Volume
3993 /////////////////////////////////////////
3994   const Int_t kvertexnumber = 4;
3995   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3996   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3997                                                                                                   new TVector3*[kvertexnumber];
3998 //Shape Vertex Positioning
3999   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4000         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
4001         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
4002                                                                                                                   i*fgkSSDFlexHeight[0]);
4003         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
4004                                                                                    +                         fgkSSDFlexHeight[1]
4005                                                                                    +                      i*fgkSSDFlexHeight[0]);
4006         laddercablesegmentvertexposition[i][3] = 
4007                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
4008                                                                                 laddercablesegmentvertexposition[i][2]->Y());
4009   }
4010   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
4011                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
4012   char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
4013                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
4014   TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
4015   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
4016                                         GetArbShape(laddercablesegmentvertexposition[i],
4017                                                                 laddercablesegmentwidth[i],
4018                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
4019                                                                 laddercablesegmentarbshapename[i]);
4020   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
4021                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
4022   TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
4023   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4024                          laddercablesegmentarb[i] =
4025                                                    new TGeoVolume(laddercablesegmentarbname[i],
4026                                                                                   laddercablesegmentarbshape[i],
4027                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
4028             fSSDKaptonLadderCableMedium)); 
4029                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
4030                                                                                                                    fColorPolyhamide);
4031 }
4032   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
4033   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
4034                                                                                                  90.,90,-90.);   
4035   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
4036                                                                                                   0.,90.,0.);    
4037   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
4038                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
4039                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
4040                                                          + fgkSSDFlexWidth[0],0.,0.,
4041                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
4042                                                      *(*laddercablesegmentarbrot[0])));
4043   TGeoVolume* laddercablesegmentarbassembly = 
4044                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
4045   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
4046   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
4047                                                                                    laddercablesegmentarbcombitrans);
4048 /////////////////////////////////////////
4049 // End Ladder Cable Volume
4050 /////////////////////////////////////////
4051   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4052   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4053                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4054   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4055                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4056                                                                            0.5*ssdendladdercablelength,
4057                                                                            0.5*fgkSSDLadderCableWidth,
4058                                                                            0.5*fgkSSDFlexHeight[i]);
4059   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4060                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4061   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4062   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4063                         ladderendcablesegmentbbox[i] =
4064                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4065                                                                                  ladderendcablesegmentbboxshape[i],
4066                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4067             fSSDKaptonLadderCableMedium));
4068                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4069                                                                                                                    fColorPolyhamide);
4070   }
4071   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4072   ladderendcablesegmentbboxtrans[0] = 
4073                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4074                                                                                            0.5*ssdendladdercablelength,
4075                                                                                            0.5*fgkSSDLadderCableWidth,
4076                                                                                            0.5*fgkSSDFlexHeight[0]);
4077   ladderendcablesegmentbboxtrans[1] = 
4078                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4079                                                                                            0.5*ssdendladdercablelength,
4080                                                                                            0.5*fgkSSDLadderCableWidth,
4081                                                                                            fgkSSDFlexHeight[0]
4082                                                                                            +0.5*fgkSSDFlexHeight[1]);
4083   TGeoVolume* ladderendcablesegmentbboxassembly = 
4084                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4085   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4086                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4087                                                                                             ladderendcablesegmentbboxtrans[i]);
4088 /////////////////////////////////////////
4089   TList* laddercablesegmentlist = new TList();
4090   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4091   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4092   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4093   return laddercablesegmentlist;
4094   }
4095 /////////////////////////////////////////////////////////////////////////////////
4096 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4097   /////////////////////////////////////////////////////////////
4098   // Method generating Ladder Cable Volumes Assemblies    
4099   /////////////////////////////////////////////////////////////
4100   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4101   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4102   for(Int_t i=0; i<n; i++){
4103          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4104                                                         i*(fgkCarbonFiberJunctionWidth),
4105                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4106                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4107     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4108         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4109   }
4110   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4111                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4112                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4113                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4114   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4115   return laddercable;
4116 }
4117 /////////////////////////////////////////////////////////////////////////////////
4118 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4119   /////////////////////////////////////////////////////////////
4120   // Method generating Ladder Cable Volumes Assembly   
4121   /////////////////////////////////////////////////////////////
4122   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4123   char laddercabletransname[30];
4124   for(Int_t i=0; i<n; i++){ 
4125         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4126     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4127         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4128   }
4129   return laddercableassembly;
4130 }
4131 /////////////////////////////////////////////////////////////////////////////////
4132 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4133   /////////////////////////////////////////////////////////////
4134   // Method generating Ladder Cable List Assemblies  
4135   /////////////////////////////////////////////////////////////  
4136   const Int_t kladdercableassemblynumber = 2;
4137   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4138   TGeoVolume* ladderCable[kladdercableassemblynumber];
4139   char laddercableassemblyname[30];
4140   TList* laddercableassemblylist = new TList();
4141   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4142         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4143         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4144         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4145                                          new TGeoCombiTrans((n-1)
4146                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4147                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4148                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4149         laddercableassemblylist->Add(ladderCable[i]);
4150 }
4151   return laddercableassemblylist;
4152 }
4153 ///////////////////////////////////////////////////////////////////////////////
4154 void AliITSv11GeometrySSD::SetLadderSegment(){
4155   /////////////////////////////////////////////////////////////
4156   // Method Generating Ladder Segment Array
4157   /////////////////////////////////////////////////////////////
4158   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4159   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4160   if(!fCreateMaterials) CreateMaterials();
4161   if(!fTransformationMatrices) CreateTransformationMatrices();
4162   if(!fBasicObjects) CreateBasicObjects();
4163   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4164   // Placing Carbon Fiber Support       
4165         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4166                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4167                                                                                         fcarbonfibersupportmatrix[j]);  
4168                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4169                                                                                         fcarbonfibersupportmatrix[j]);
4170   }
4171   // Placing Carbon Fiber Junction
4172     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4173         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4174                                                                    fcarbonfiberjunctionmatrix[j]);
4175   // Placing Carbon Fiber Lower Support
4176         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4177                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4178                                                            fcarbonfiberlowersupportrans[j]);    
4179   // Placing SSD Sensor Support
4180     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4181         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4182                                                                      fssdsensorsupport[1][i],
4183                                                            j+1,fssdsensorsupportmatrix[j]);
4184   // Placing SSD Cooling Tube Support 
4185         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4186                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4187                                                                    fcoolingtubesupportmatrix[j]);
4188   // Placing SSD Cooling Tube  
4189         for(Int_t j=0; j<2; j++)
4190                 for(Int_t k=0; k<2; k++){
4191                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4192                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4193                 }
4194   // Placing SSD Hybrid
4195     switch(i){
4196         case 0: 
4197                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4198                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4199                 break;
4200     case 1:
4201                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4202                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4203                 break;
4204         }
4205         // Placing Cooling Block System
4206     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4207         // Placing SSD Flex
4208         for(Int_t j=0; j<fgkflexnumber; j++){
4209       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4210       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4211         }
4212    }
4213 }
4214 ///////////////////////////////////////////////////////////////////////////////
4215 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4216   /////////////////////////////////////////////////////////////
4217   // Method Generating End Ladder
4218   /////////////////////////////////////////////////////////////
4219   // End Ladder Carbon Fiber Junction 
4220   /////////////////////////////////////////////////////////////
4221   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4222   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4223   if(!fCreateMaterials) CreateMaterials();
4224   if(!fTransformationMatrices) CreateTransformationMatrices();
4225   if(!fBasicObjects) CreateBasicObjects();
4226   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4227         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4228                 fendladdersegment[i]->AddNode(j==2 ? 
4229                                                         fendladdercarbonfiberjunction[i][1] : 
4230                                                         fendladdercarbonfiberjunction[i][0],
4231                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4232   }
4233   /////////////////////////////////////////////////////////////
4234   // End Ladder Carbon Fiber Support 
4235   /////////////////////////////////////////////////////////////
4236   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4237       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4238                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4239                   fendladdercarbonfibermatrix[i][j]);   
4240           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4241                   fendladdercarbonfibermatrix[i][j]);   
4242       }
4243   /////////////////////////////////////////////////////////////
4244   // End Ladder Mounting Block
4245   /////////////////////////////////////////////////////////////
4246   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4247        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4248                                      fendladdermountingblockcombitrans[i]);
4249   /////////////////////////////////////////////////////////////
4250   // End Ladder Mounting Block Clip
4251   /////////////////////////////////////////////////////////////
4252   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4253         for(Int_t j=0; j<2; j++)
4254                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4255                                               fendladdermountingblockclipmatrix[i][j]);
4256   /////////////////////////////////////////////////////////////
4257   // End Ladder Lower Supports
4258   /////////////////////////////////////////////////////////////
4259   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4260                                 fendladderlowersupptrans[0]);
4261   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4262                                 fendladderlowersupptrans[1]);
4263   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4264                                 fendladderlowersupptrans[2]);
4265   /////////////////////////////////////////////////////////////
4266   // End Ladder Cooling Tube Support
4267   /////////////////////////////////////////////////////////////
4268   for(Int_t i=0; i<2; i++) 
4269         for(Int_t j=0; j<(i==0?4:2); j++)   
4270                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4271                                               fendladdercoolingtubesupportmatrix[i][j]);
4272   /////////////////////////////////////////////////////////////
4273   // End Ladder Cooling Tube Support
4274   /////////////////////////////////////////////////////////////
4275 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                          
4276 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                          
4277   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4278   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4279   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4280   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4281   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4282   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4283   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4284   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                            
4285 }
4286 ///////////////////////////////////////////////////////////////////////////////
4287 void AliITSv11GeometrySSD::SetLadder(){
4288   /////////////////////////////////////////////////////////////
4289   // Method Generating Ladder of Layer 5 and 6
4290   /////////////////////////////////////////////////////////////  
4291   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4292                                                                                                 fgkSSDLay6SensorsNumber};
4293   /////////////////////////////////////////////////////////////////////////////                                         
4294   /// Generating Ladder Mother Volume Containing Ladder 
4295   /////////////////////////////////////////////////////////////////////////////          
4296   TGeoXtru* laddershape[fgkladdernumber];       
4297   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4298   const Int_t kmothervertexnumber = 8;  
4299   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4300   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4301   ///////////////////////
4302   // Setting the vertices 
4303   ///////////////////////
4304   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4305                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4306   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4307   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
4308                                           -  fgkSSDModuleVerticalDisalignment;
4309   xmothervertex[0][1] = xmothervertex[0][0];
4310   ymothervertex[0][1] = 0.0;
4311   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4312                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4313   ymothervertex[0][2] = ymothervertex[0][1];
4314   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4315   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4316   xmothervertex[0][4] = -xmothervertex[0][3];
4317   ymothervertex[0][4] = ymothervertex[0][3];
4318   xmothervertex[0][5] = -xmothervertex[0][2];
4319   ymothervertex[0][5] = ymothervertex[0][2];
4320   xmothervertex[0][6] = -xmothervertex[0][1];
4321   ymothervertex[0][6] = ymothervertex[0][1];
4322   xmothervertex[0][7] = -xmothervertex[0][0];
4323   ymothervertex[0][7] = ymothervertex[0][0];
4324   for(Int_t i=0; i<kmothervertexnumber; i++){
4325         xmothervertex[1][i] = xmothervertex[0][i];
4326         ymothervertex[1][i] = ymothervertex[0][i];
4327   }
4328   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4329   for(Int_t i=0; i<fgkladdernumber; i++){
4330         laddershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
4331                                                                     ymothervertex[i]);
4332     laddershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4333     laddershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4334                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4335     fladder[i] = new TGeoVolume(laddername[i],laddershape[i],fSSDAir);
4336         fladder[i]->SetLineColor(4);
4337  }
4338 ///////////////////////////////////////////////////////////////////////////
4339  if(!fCreateMaterials) CreateMaterials();
4340  if(!fTransformationMatrices) CreateTransformationMatrices();
4341  if(!fBasicObjects) CreateBasicObjects();
4342  SetLadderSegment(); 
4343  SetEndLadderSegment();
4344   for(Int_t i=0; i<fgkladdernumber; i++){
4345         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4346         //////////////////////////                                              
4347         /// Placing Ladder Segment
4348         //////////////////////////              
4349                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4350                                                                      fladdersegment[i==0 ? 1 : 0],
4351                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4352         //////////////////////////                                              
4353         /// Placing SSD Sensor
4354         //////////////////////////              
4355         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4356                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4357                                                         fssdsensormatrix[i][j]);
4358         }
4359         ///////////////////////////////                                         
4360         /// Placing End Ladder Segment
4361         ///////////////////////////////         
4362     fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4363         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4364    }
4365 /////////////////////////////////////////////////////////////////////////////                                           
4366 /// Placing Ladder Cables
4367 /////////////////////////////////////////////////////////////////////////////           
4368   Int_t sidecablenumber[2][2];
4369   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4370   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4371   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4372   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4373   Double_t carbonfibertomoduleposition[3];
4374   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4375   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4376                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4377          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4378          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4379          -            fgkSSDSensorCenterSupportThickness[0]);
4380   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4381                                                                  +   0.5*fgkCoolingTubeSupportHeight
4382          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4383   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4384   Double_t ssdendladdercablelength[4];
4385   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4386                                                          + fgkSSDSensorLength
4387                                                          - fgkSSDModuleStiffenerPosition[1]
4388                                                          - fgkSSDStiffenerWidth 
4389                                                          - fgkSSDFlexWidth[0]
4390                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4391   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4392                                                          + fgkSSDModuleStiffenerPosition[1]
4393                                                          + fgkSSDStiffenerWidth
4394                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4395   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4396                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4397                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4398                                                          - kendladdercablecorrection;
4399   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4400                                                          + carbonfibertomoduleposition[1]
4401                                                          - fgkSSDModuleStiffenerPosition[1]
4402                                                          - fgkSSDStiffenerWidth)
4403                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4404   TList* laddercableassemblylist[4];
4405   const Int_t kendladdercablesnumber = 4;
4406   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4407         for(Int_t j=0; j<kendladdercablesnumber; j++){
4408                 laddercableassemblylist[j] = 
4409                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4410                                                                    ssdendladdercablelength[j]);
4411 //          fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4412 //                                                                      j<2?1:2,fladdercablematrix[i][j]);
4413   }
4414 }
4415 ////////////////////////////////////////////////////////////////////////////////
4416 void AliITSv11GeometrySSD::SetLayer(){
4417 ////////////////////////////////////////////////////////////////////////////////
4418   // Creating Ladder of Layer 5 and Layer 6
4419   /////////////////////////////////////////////////////////////
4420   if(!fCreateMaterials) CreateMaterials();
4421   if(!fTransformationMatrices) CreateTransformationMatrices();
4422   if(!fBasicObjects) CreateBasicObjects();
4423   SetLadder(); // Generating the ladder of Layer5 and Layer6
4424   const Int_t kssdlayladdernumber[fgklayernumber] = 
4425                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4426   /////////////////////////////////////////////////////////////
4427   // Generating mother volumes for Layer5 and Layer6
4428   /////////////////////////////////////////////////////////////
4429   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4430   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4431   Int_t *ladderindex[fgklayernumber];
4432   Int_t index[fgklayernumber] = {8,9};
4433   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4434   for(Int_t i=0; i<fgklayernumber; i++) 
4435         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4436                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4437                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4438                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4439                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4440         }
4441   /////////////////////////////////////////////////////////////
4442   // Deallocating memory
4443   /////////////////////////////////////////////////////////////
4444   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4445 }
4446 ////////////////////////////////////////////////////////////////////////////////
4447 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4448   /////////////////////////////////////////////////////////////
4449   // Insert the layer 5 in the mother volume. 
4450   /////////////////////////////////////////////////////////////
4451   if (! moth) {
4452     printf("Error::AliITSv11GeometrySSD: Can't insert layer5, mother is null!\n");
4453     return;
4454   };
4455   if(!fSSDLayer5) SetLayer();
4456   fMotherVol = moth;
4457   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4458                                                                                 + fgkLay5CenterITSPosition);
4459   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4460  }
4461 ////////////////////////////////////////////////////////////////////////////////
4462 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4463   /////////////////////////////////////////////////////////////
4464   // Insert the layer 6 in the mother volume. 
4465   /////////////////////////////////////////////////////////////
4466   if (! moth) {
4467     printf("Error::AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4468     return;
4469   };
4470   if(!fSSDLayer6) SetLayer();
4471   fMotherVol = moth;
4472   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4473                                                                                 + fgkLay6CenterITSPosition);
4474   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4475  }
4476  ////////////////////////////////////////////////////////////////////////////////
4477  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4478   /////////////////////////////////////////////////////////////
4479   // Method generating the Arc structure of Ladder Support 
4480   /////////////////////////////////////////////////////////////
4481   const Int_t kssdlayladdernumber[fgklayernumber] = 
4482                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4483   Double_t mountingsupportedge[fgklayernumber];
4484   Double_t mountingblockratio[fgklayernumber];
4485   Double_t theta[fgklayernumber];
4486   Double_t phi[fgklayernumber];
4487   Double_t psi0[fgklayernumber];
4488   Double_t deltapsi[fgklayernumber];
4489   TVector3* mountingsupportedgevector[fgklayernumber];
4490   for(Int_t i=0; i<fgklayernumber; i++){
4491         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4492     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4493                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4494                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4495                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4496                                                           / kssdlayladdernumber[i])));
4497     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4498     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4499         mountingsupportedgevector[i] = new TVector3();
4500     mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4501         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(1.
4502                                                                  -TMath::Power(mountingsupportedgevector[i]->X()
4503                                                                  /                         fgkMountingBlockSupportRadius[i],2)));
4504     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4505     deltapsi[i] = (theta[i]+phi[i])/nedges;
4506   }
4507   TVector3** vertex[fgklayernumber];
4508   TList* vertexlist[fgklayernumber];
4509   Int_t indexedge[fgklayernumber] = {0,0};
4510   for(Int_t i=0; i<fgklayernumber; i++){
4511         vertex[i] = new TVector3*[nedges+1];
4512         vertexlist[i] = new TList();
4513   } 
4514   for(Int_t i=0; i<fgklayernumber; i++){
4515         for(Int_t j=0; j<nedges+1; j++){
4516                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4517                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4518                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4519                 vertexlist[i]->Add(vertex[i][j]);
4520         }
4521         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4522   }
4523   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4524   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4525   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4526   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4527   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4528   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4529   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4530   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4531   for(Int_t i=0; i<fgklayernumber; i++){
4532     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4533     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4534     xcentervertex[i] = new Double_t[indexedge[i]+3];
4535     ycentervertex[i] = new Double_t[indexedge[i]+3];
4536         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4537         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4538         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4539         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4540         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4541                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4542                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4543                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4544                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4545                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4546                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4547                 if(j<indexedge[i]+1){
4548                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4549                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4550                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4551                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4552                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4553                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4554                 }
4555         }
4556         xsidevertex[i][1] = xsidevertex[i][0]; 
4557         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4558         xsidevertex[i][2] = xsidevertex[i][3]; 
4559         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4560         xcentervertex[i][1] = xcentervertex[i][0]; 
4561         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4562         xcentervertex[i][2] = xcentervertex[i][3]; 
4563         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4564         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4565         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4566         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4567         ycenterlowervertex[i][0] = ysidevertex[i][0];
4568         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4569         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4570   }
4571   /////////////////////////////////////////////////////////////
4572   // Building the Arc Structure of Ladder Supports 
4573   /////////////////////////////////////////////////////////////
4574   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4575   TGeoXtru* centermountingsupportshape[fgklayernumber];
4576   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4577   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4578   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4579   TGeoVolume* centermountingblocksupport[fgklayernumber];
4580   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4581   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4582   char sidemountingblockname[40];
4583   char centermountingblockname[40];
4584   char sideladdersupportpiecename[40];
4585   char centerladdersupportpiecename[40];
4586   for(Int_t i=0; i<fgklayernumber; i++){ 
4587         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4588         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4589         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4590         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4591         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4592     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4593                                                                                                 xsidevertex[i],ysidevertex[i]);
4594     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4595                                                                                                          -fgkMountingBlockSupportWidth[0]);
4596     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4597     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4598                                                                           sidemountingblocksupportshape[i],
4599                                                                                   fSSDAlCoolBlockMedium);
4600         sidemountingblocksupport[i]->SetLineColor(9);
4601         centermountingsupportshape[i] = new TGeoXtru(2);
4602     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4603                                                                                                 xcentervertex[i],ycentervertex[i]);
4604         centermountingsupportshape[i]->DefineSection(0,0.);
4605     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4606                                                                                                   -fgkMountingBlockSupportWidth[0]);
4607     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4608                                                                           centermountingsupportshape[i],
4609                                                                                   fSSDAlCoolBlockMedium);
4610         centermountingblocksupport[i]->SetLineColor(9);
4611         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4612     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4613                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4614         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4615                                                                                                          -fgkMountingBlockSupportWidth[0]);
4616     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4617     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4618                                                                           sideladdersupportpieceshape[i],
4619                                                                                   fSSDCarbonFiberMedium);
4620         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4621         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4622     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4623                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4624         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4625     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4626                                                                                                   -fgkMountingBlockSupportWidth[0]);
4627     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4628                                                                           centerladdersupportpieceshape[i],
4629                                                                                   fSSDCarbonFiberMedium);
4630         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4631   }
4632   /////////////////////////////////////////////////////////////
4633   // Building the Up Structure of Ladder Supports 
4634   /////////////////////////////////////////////////////////////
4635   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4636   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4637   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4638   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4639   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4640   //////////////////////////////////////////////////////////
4641   // Setting the volume for TGeoXtru Mounting Block Piece  
4642   //////////////////////////////////////////////////////////
4643   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4644   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4645   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4646   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4647   TGeoVolume* mountingblockpieceup[fgklayernumber];
4648   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4649   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4650   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4651   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4652   char mountingblockpiecedownname[34];
4653   char mountingblockpieceupname[34];
4654   for(Int_t i=0; i<fgklayernumber; i++){
4655     ///////////////////////////
4656     // Mounting Block Down Vertex
4657     ///////////////////////////
4658         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4659     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4660         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4661         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4662                                                                                 + fgkMountingBlockSupportDownHeight;
4663         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4664         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4665                                                                                 + fgkSSDMountingBlockHeight[1]
4666                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4667                                                                                 - fgkSSDModuleCoolingBlockToSensor
4668                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4669         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4670         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4671         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4672         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4673         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4674         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4675         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4676         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4677                                                                                 + fgkSSDMountingBlockHeight[2]
4678                                                                                 - fgkSSDMountingBlockHeight[0];
4679         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4680         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4681         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4682         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4683         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4684                                                                                                          mountingblockpiecedownyvertex[i]);
4685         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4686         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4687         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4688                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4689         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4690     ///////////////////////////
4691     // Mounting Block Up Vertex
4692     ///////////////////////////
4693         mountingblockpieceupshape[i] = new TGeoXtru(2);
4694         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4695         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4696         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4697                                                                                 + fgkMountingBlockSupportUpHeight[i];
4698         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4699         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4700                                                                                 + fgkSSDMountingBlockHeight[1]
4701                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4702                                                                                 - fgkSSDModuleCoolingBlockToSensor
4703                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4704         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4705         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4706         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4707         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4708         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4709         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4710         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4711         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4712                                                                                 + fgkSSDMountingBlockHeight[2]
4713                                                                                 - fgkSSDMountingBlockHeight[0];
4714         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4715         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4716         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4717         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4718         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4719                                                                                                          mountingblockpieceupyvertex[i]);
4720         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4721         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4722         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4723                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4724         mountingblockpieceup[i]->SetLineColor(fColorG10);
4725  }
4726   ///////////////////////////////////////////////////////////////////
4727   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4728   ///////////////////////////////////////////////////////////////////
4729   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4730   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4731   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4732   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4733   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4734   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4735   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4736   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4737   char mountingblocksupportrapezoidowname[40];
4738   char mountingblocksupportrapezoidupname[40];
4739   Double_t scalefactor = 3./4.;
4740   for(Int_t i=0; i<fgklayernumber; i++){
4741   ////////////////////////////////////////////
4742   // Mounting Block Support Down Trapezoid Vertex 
4743   ////////////////////////////////////////////
4744         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4745         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4746                                                                                                  - mountingsupportedge[i];
4747         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4748         mountingblocksupportrapezoidownxvertex[i][1] = 
4749                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4750         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4751                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4752                                                                                              - mountingblockpiecedownyvertex[i][0]);
4753         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4754         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4755         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4756         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4757         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4758         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4759         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4760                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4761         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4762                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4763         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4764         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4765         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4766                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4767         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4768   ////////////////////////////////////////////
4769   // Mounting Block Support Up Trapezoid Vertex 
4770   ////////////////////////////////////////////
4771         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4772         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4773                                                                                                  - mountingsupportedge[i];
4774         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4775         mountingblocksupportrapezoidupxvertex[i][1] = 
4776                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4777         mountingblocksupportrapezoidupyvertex[i][1] = 
4778                                                                                                mountingblockpieceupyvertex[i][0]
4779                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4780                                                                                              - mountingblockpieceupyvertex[i][0]);
4781         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4782         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4783         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4784         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4785         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4786         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4787         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4788                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4789         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4790                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4791         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4792         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4793         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4794                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4795         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4796   }
4797   ///////////////////////////////////////////////////////////////////
4798   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4799   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4800   Double_t boxoriginup[fgklayernumber][2][3];
4801   Double_t boxorigindown[fgklayernumber][2][3];
4802   char mountingblocksupportboxdownname[34];
4803   char mountingblocksupportboxupname[34];
4804   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4805   mountingblocksupportrot->SetAngles(90.,180.,-90);
4806   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4807   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4808   TGeoHMatrix* laddersupportmatrix[2];
4809   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4810   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4811   /////////////////////////////////////////////////////////////
4812   // Creating Mother Volume for Containment
4813   /////////////////////////////////////////////////////////////
4814   Double_t *xmothervertex[fgklayernumber];
4815   Double_t *ymothervertex[fgklayernumber];
4816   for(Int_t i=0; i<fgklayernumber; i++){
4817         xmothervertex[i] = new Double_t[8];
4818         ymothervertex[i] = new Double_t[8];
4819   }  
4820   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4821   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4822   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4823   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4824   char upmotheladdersupportname[30];
4825   char downmotheladdersupportname[30];
4826   for(Int_t i=0; i<fgklayernumber; i++){
4827         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4828                                                     -  mountingsupportedge[i];
4829         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4830         xmothervertex[i][1] = xmothervertex[i][0];
4831         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4832                                                         + fgkMountingBlockSupportWidth[0];
4833         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4834         ymothervertex[i][2] = ymothervertex[i][1];
4835         xmothervertex[i][3] = xmothervertex[i][2];
4836         ymothervertex[i][3] = -ymothervertex[i][0];
4837         xmothervertex[i][4] = -xmothervertex[i][0];
4838         ymothervertex[i][4] = ymothervertex[i][3];
4839         xmothervertex[i][5] = xmothervertex[i][4];
4840         ymothervertex[i][5] = -ymothervertex[i][1];
4841         xmothervertex[i][6] = -xmothervertex[i][2];
4842         ymothervertex[i][6] = ymothervertex[i][5];
4843         xmothervertex[i][7] = xmothervertex[i][6];
4844         ymothervertex[i][7] = ymothervertex[i][0];
4845         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4846         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4847     downmotherladdersupportshape[i] = new TGeoXtru(2);
4848         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4849         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4850     downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4851                                                                    +                       fgkMountingBlockSupportDownHeight
4852                                                                    +                       fgkSSDMountingBlockHeight[1]
4853                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4854                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4855                                                                    -                       2.*fgkSSDModuleVerticalDisalignment);
4856     downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4857                                                                           downmotherladdersupportshape[i],fSSDAir);
4858     upmotherladdersupportshape[i] = new TGeoXtru(2);
4859         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4860         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4861     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4862                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4863                                                                    +                       fgkSSDMountingBlockHeight[1]
4864                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4865                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4866                                                                    -               2.*fgkSSDModuleVerticalDisalignment);
4867     upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4868                                                                                           upmotherladdersupportshape[i],fSSDAir);
4869   }
4870   for(Int_t i=0; i<fgklayernumber; i++){
4871         /////////////////////////
4872         // Setting the box origin
4873         /////////////////////////
4874         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4875         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4876                                                    +  0.5*fgkMountingBlockSupportDownHeight;
4877         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4878                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4879   
4880         boxorigindown[i][1][0] = 0.0;
4881         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4882         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4883                                                    -      fgkMountingBlockSupportWidth[0]);
4884                                                    
4885         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4886         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4887                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4888         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4889                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4890   
4891         boxoriginup[i][1][0] = 0.0;
4892         boxoriginup[i][1][1] = fgkMountingBlockSupportRadius[i]
4893                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4894         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4895                                                  - fgkMountingBlockSupportWidth[0]);
4896   
4897         /////////////////////////
4898     // Setting the boxes    
4899         /////////////////////////
4900         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4901                                                                                  +  fgkSSDMountingBlockLength[0]),
4902                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4903                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4904                                                                                         boxorigindown[i][0]);
4905     mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4906                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4907                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4908                                                                                  -  fgkMountingBlockSupportWidth[0]),
4909                                                                                         boxorigindown[i][1]);
4910                                                                                         
4911         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4912                                                                                  +  fgkSSDMountingBlockLength[0]),
4913                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4914                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4915                                                                                         boxoriginup[i][0]);
4916                                                                                         
4917         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4918                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4919                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4920                                                                      -  fgkMountingBlockSupportWidth[0]),
4921                                                                                         boxoriginup[i][1]);
4922         ///////////////////////////////////////
4923     // Adding the Volumes to Mother Volume    
4924         ///////////////////////////////////////
4925         for(Int_t j=0; j<2; j++){
4926                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4927                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4928                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4929                                                                                   mountingblocksupportboxdownshape[i][j],
4930                                                                                   fSSDCarbonFiberMedium);
4931                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4932                                                                                   mountingblocksupportboxupshape[i][j],
4933                                                                                   fSSDCarbonFiberMedium);
4934                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4935                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4936                 for(Int_t k=0; k<2; k++){
4937                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4938                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4939                 }
4940         }
4941         for(Int_t k=0; k<2; k++){
4942                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4943                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4944                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4945                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4946             downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4947                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4948                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4949                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4950                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4951                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4952                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4953                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4954         }
4955   }
4956   TList* laddersupportlist = new TList();
4957   laddersupportlist->Add(downmotherladdersupport[0]); 
4958   laddersupportlist->Add(upmotherladdersupport[0]); 
4959   laddersupportlist->Add(downmotherladdersupport[1]); 
4960   laddersupportlist->Add(upmotherladdersupport[1]); 
4961   /////////////////////////////////////////////////////////////
4962   // Deallocating memory
4963   /////////////////////////////////////////////////////////////
4964   for(Int_t i=0; i<fgklayernumber; i++){
4965         for(Int_t j=0; j<nedges+1; j++)
4966                 delete vertex[i][j];
4967         delete mountingsupportedgevector[i];
4968         delete [] vertex[i];
4969         delete vertexlist[i];
4970         delete [] xsidevertex[i];
4971         delete [] ysidevertex[i];
4972         delete [] xcentervertex[i];
4973         delete [] ycentervertex[i];
4974         delete [] xsidelowervertex[i];
4975         delete [] ysidelowervertex[i];
4976         delete [] xcenterlowervertex[i];
4977         delete [] ycenterlowervertex[i];
4978   }
4979   delete xsidevertex;
4980   delete ysidevertex;
4981   delete xcentervertex;
4982   delete ycentervertex;
4983   delete xsidelowervertex;
4984   delete ysidelowervertex;
4985   delete xcenterlowervertex;
4986   delete ycenterlowervertex;
4987   delete globalrefladdersupportrot;
4988   delete mountingblocksupportrot;
4989   /////////////////////
4990   return laddersupportlist;     
4991 }
4992  ////////////////////////////////////////////////////////////////////////////////
4993 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4994 //////////////////////////////////////////
4995 // Method Generating Ladder Support Ring
4996 //////////////////////////////////////////
4997   if(!fCreateMaterials) CreateMaterials();
4998   if(!fTransformationMatrices) CreateTransformationMatrices();
4999   if(!fBasicObjects) CreateBasicObjects();
5000   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
5001   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
5002     const Int_t kssdlayladdernumber[fgklayernumber] = 
5003                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
5004   Double_t mountingsupportedge[fgklayernumber];
5005   Double_t mountingblockratio[fgklayernumber];
5006   Double_t theta[fgklayernumber];
5007   Double_t phi[fgklayernumber];
5008   for(Int_t i=0; i<fgklayernumber; i++){
5009         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
5010     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
5011                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
5012                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
5013                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
5014                                                           / kssdlayladdernumber[i])));
5015     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
5016                          / fgkMountingBlockSupportRadius[i]);
5017     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
5018   }
5019   TGeoRotation* globalrot = new TGeoRotation();
5020   globalrot->SetAngles(0.,-90.,0.); 
5021   TGeoRotation** laddersupportrot[fgklayernumber];
5022   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5023   for(Int_t i=0; i<fgklayernumber; i++){                
5024         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5025         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5026         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5027                 laddersupportrot[i][j] = new TGeoRotation();
5028                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5029                 switch(i){
5030                         case 0: //Ladder of Layer5  
5031                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5032                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5033                                                                             laddersupportmatrix[i][j]); 
5034                         break;
5035                         case 1: //Ladder of Layer6 
5036                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5037                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5038                                                                               laddersupportmatrix[i][j]); 
5039                         break;
5040                 }
5041     }
5042   }
5043   /////////////////////////////////////////////////////////////
5044   // Creating Lower Ladder Support 
5045   /////////////////////////////////////////////////////////////
5046   TVector3** ringsupportvertex[fgklayernumber];         
5047   Double_t angle = 360./nedges;
5048   for(Int_t i=0; i<fgklayernumber; i++){
5049     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5050         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5051                                                         *                          TMath::Cos(theta[i]));
5052         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5053                                                         -                          mountingsupportedge[i],
5054                                                                                    ringsupportvertex[i][0]->Y());
5055         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5056                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5057     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5058         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5059            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5060            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5061            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5062            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5063         }
5064         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5065     for(Int_t j=0; j<nedges+1; j++){
5066                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5067                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5068                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5069         }
5070   }
5071   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5072   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5073   for(Int_t i=0; i<fgklayernumber; i++){
5074         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5075         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5076         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5077                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5078                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5079         }
5080   }
5081 ////////////////////////////////////////////////////////////////////////////////
5082 // Start Corrections 13/06/08
5083 ////////////////////////////////////////////////////////////////////////////////
5084   char lowerladderpconsupportname[30];
5085   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5086   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5087   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5088   Double_t lowerladderpconradiusmax[fgklayernumber];
5089   Double_t lowerladderpconradiusmin[fgklayernumber];
5090   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5091   lowerladdersupportrot->SetAngles(90.,180.,-90);
5092   for(Int_t i=0; i<fgklayernumber; i++){
5093         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5094                                                                 *                          TMath::Cos(theta[i]);
5095     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5096   } 
5097   for(Int_t i=0; i<fgklayernumber; i++){
5098 ///////////////////////////  Modified Version ?///////////////////
5099     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5100         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5101                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5102                                                          lowerladderpconradiusmax[i]);
5103         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5104         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5105     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5106         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5107         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5108  }
5109 ////////////////////////////////////////////////////////////////////////////////
5110 // End Corrections 13/06/08
5111 ////////////////////////////////////////////////////////////////////////////////
5112   /*char lowerladdersupportname[30];
5113   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5114   TGeoVolume* lowerladdersupport[fgklayernumber];
5115   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5116   lowerladdersupportrot->SetAngles(90.,180.,-90);
5117   for(Int_t i=0; i<fgklayernumber; i++){
5118         lowerladdersupportshape[i] = new TGeoXtru(2);
5119         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5120                                                                                           xmothervertex[i],ymothervertex[i]);
5121         lowerladdersupportshape[i]->DefineSection(0,0.);
5122     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5123         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5124     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5125                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5126         lowerladdersupport[i]->SetLineColor(fColorAl);
5127         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5128         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5129   }*/
5130   /////////////////////////////////////////////////////////////
5131   // Deallocating memory
5132   /////////////////////////////////////////////////////////////
5133   for(Int_t i=0; i<fgklayernumber; i++){
5134         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5135                 delete ringsupportvertex[i][j];
5136         delete [] ringsupportvertex[i];
5137   }
5138   for(Int_t i=0; i<fgklayernumber; i++){
5139         delete [] xmothervertex[i];
5140         delete [] ymothervertex[i];
5141   }
5142   delete xmothervertex;
5143   delete ymothervertex; 
5144   delete globalrot;
5145   for(Int_t i=0; i<fgklayernumber; i++){
5146         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5147                 delete laddersupportrot[i][j];
5148         delete [] laddersupportrot[i];
5149   }
5150  }  
5151  ////////////////////////////////////////////////////////////////////////////////
5152  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5153   /////////////////////////////////////////////////////////////
5154   // Method generating Endcap CoverPlate
5155   /////////////////////////////////////////////////////////////
5156   // Holes Definition 
5157   ///////////////////
5158   Int_t nendcapcoverplateholedges = 30;
5159   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5160   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5161                                                           0.5*fgkEndCapCoverPlateThickness};
5162   TGeoXtru* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5163                                                                                                               nendcapcoverplateholedges,holesection);
5164   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5165                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5166   endcapcoverplatesmallhole->SetLineColor(6);
5167   TGeoXtru* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5168                                                                                                               nendcapcoverplateholedges,holesection);
5169   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5170                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5171   endcapcoverplatebighole->SetLineColor(6);
5172   //////////////////////////
5173   // Screw Piece Definition 
5174   //////////////////////////
5175   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5176   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5177                                                                                                       CosD(0.5*smallscrewangle),
5178                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5179   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5180                                                                                                 endcapsmallscrewpieceshape,
5181                                                                                                 fSSDCoolingTubePhynox);
5182   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5183   ///////////////////
5184   // Box Definition 
5185   ///////////////////
5186   TGeoBBox* endcapcoverplateboxshape[4];
5187   TGeoVolume* endcapcoverplatebox[4];
5188   Double_t boxorigin[5][3];
5189   boxorigin[0][0] = 0.;
5190   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5191   boxorigin[0][2] = 0.;
5192
5193   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5194   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5195   boxorigin[1][2] = 0.;
5196
5197   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5198                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5199   boxorigin[2][1] = boxorigin[1][1];
5200   boxorigin[2][2] = 0.;
5201
5202   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5203                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5204   boxorigin[3][1] = boxorigin[1][1];
5205   boxorigin[3][2] = 0.;
5206
5207   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5208                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5209                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5210                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5211
5212   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5213                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5214                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5215                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5216                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5217
5218   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5219                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5220                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5221                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5222                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5223
5224   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5225                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5226                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5227                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5228                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5229   
5230   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5231                                                                            fSSDAlCoolBlockMedium);
5232   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5233                                                                            fSSDAlCoolBlockMedium);
5234   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5235                                                                            fSSDAlCoolBlockMedium);
5236   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5237                                                                            fSSDAlCoolBlockMedium);
5238   endcapcoverplatebox[0]->SetLineColor(6);
5239   endcapcoverplatebox[1]->SetLineColor(6);
5240   endcapcoverplatebox[2]->SetLineColor(6);
5241   endcapcoverplatebox[3]->SetLineColor(6);
5242   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5243   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5244                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5245                                                                                         0.5*fgkEndCapCoverPlateThickness,
5246                                                                                         endcapfillingboxorigin);
5247   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5248                                                                            fSSDAlCoolBlockMedium);
5249   endcapfillingbox->SetLineColor(6);
5250   ////////////////////////////
5251   // Contour Xtru Definition 
5252   ////////////////////////////
5253   const Int_t kcontourvertexnumber = 10;
5254   Double_t xcontourvertex[kcontourvertexnumber];
5255   Double_t ycontourvertex[kcontourvertexnumber];
5256   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5257   xcontourvertex[1] = xcontourvertex[0];
5258   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5259   xcontourvertex[3] = xcontourvertex[2];
5260   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5261   xcontourvertex[5] = xcontourvertex[4];
5262   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5263   xcontourvertex[7] = xcontourvertex[6];
5264   xcontourvertex[8] = xcontourvertex[4];
5265   xcontourvertex[9] = xcontourvertex[8];
5266   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5267                                         - (kendcapcoverplatesmallholenumber[1]-1)
5268                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5269   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5270                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5271   ycontourvertex[2] = ycontourvertex[1];
5272   ycontourvertex[3] = ycontourvertex[0];
5273   ycontourvertex[4] = ycontourvertex[3];
5274   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5275   ycontourvertex[6] = ycontourvertex[5];
5276   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5277                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5278                                         + fgkEndCapCoverPlateSmallHoleRadius;
5279   ycontourvertex[8] = ycontourvertex[7];
5280   ycontourvertex[9] = ycontourvertex[0];
5281   TGeoXtru* contourshape = new TGeoXtru(2);
5282   contourshape->DefinePolygon(kcontourvertexnumber,xcontourvertex,ycontourvertex);  
5283   contourshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5284   contourshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5285   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5286                                                                            fSSDAlCoolBlockMedium);
5287   contour->SetLineColor(6);
5288   /////////////////////////////
5289   // Hole Contour Xtru Definition 
5290   ////////////////////////////
5291   const Int_t kholecontourvertexnumber = 10;
5292   Double_t xholecontourvertex[2][kcontourvertexnumber];
5293   Double_t yholecontourvertex[2][kcontourvertexnumber];
5294   xholecontourvertex[0][0] = xcontourvertex[0];
5295   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5296   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5297   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5298   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5299                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5300                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5301   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5302   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5303                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5304   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5305   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5306   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5307   
5308   yholecontourvertex[0][0] = ycontourvertex[1];
5309   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5310   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5311   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5312   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5313   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5314                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5315   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5316   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5317   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5318   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5319
5320   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5321   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5322   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5323   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5324   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5325                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5326                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5327   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5328   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5329                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5330   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5331   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5332   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5333   
5334   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5335                                                    - fgkEndCapCoverPlateWidth[0]);
5336   yholecontourvertex[1][1] = ycontourvertex[0];
5337   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5338   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5339   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5340   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5341                                                    - fgkEndCapCoverPlateWidth[0]
5342                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5343   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5344   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5345   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5346   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5347
5348   TGeoXtru* holecontourshape[2];
5349   holecontourshape[0] = new TGeoXtru(2);
5350   holecontourshape[0]->DefinePolygon(kholecontourvertexnumber,xholecontourvertex[0],
5351                                                                   yholecontourvertex[0]);  
5352   holecontourshape[0]->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5353   holecontourshape[0]->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5354
5355   holecontourshape[1] = new TGeoXtru(2);
5356   holecontourshape[1]->DefinePolygon(kholecontourvertexnumber,xholecontourvertex[1],
5357                                                                   yholecontourvertex[1]);  
5358   holecontourshape[1]->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5359   holecontourshape[1]->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5360
5361   TGeoVolume* holecontour[2];
5362   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",holecontourshape[0],
5363                                                                   fSSDAlCoolBlockMedium);
5364   holecontour[0]->SetLineColor(6);
5365   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",holecontourshape[1],
5366                                                                   fSSDAlCoolBlockMedium);
5367   holecontour[1]->SetLineColor(6);
5368   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5369                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5370   TGeoTranslation*  bigholetrans[3];
5371   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5372                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5373   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5374                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5375                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5376   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5377                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5378   /////////////////////////////////
5379   // Mother Volume Xtru Definition 
5380   /////////////////////////////////
5381   const Int_t kmothervertexnumber = 12;
5382   Double_t xmothervertex[kmothervertexnumber];  
5383   Double_t ymothervertex[kmothervertexnumber];  
5384   xmothervertex[0]  = xcontourvertex[0];
5385   xmothervertex[1]  = xmothervertex[0];
5386   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5387   xmothervertex[3]  = xmothervertex[2];
5388   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5389   xmothervertex[5]  = xmothervertex[4];
5390   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5391   xmothervertex[7]  = xmothervertex[6];
5392   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5393                                         + fgkEndCapCoverPlateLength[2]; 
5394   xmothervertex[9]  = xmothervertex[8];
5395   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5396   xmothervertex[11] = xmothervertex[10];
5397   
5398   ymothervertex[0]  = ycontourvertex[0];
5399   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5400   ymothervertex[2]  = ymothervertex[1];
5401   ymothervertex[3]  = ycontourvertex[1];
5402   ymothervertex[4]  = ymothervertex[3];
5403   ymothervertex[5]  = ymothervertex[1];
5404   ymothervertex[6]  = ymothervertex[5];
5405   ymothervertex[7]  = ymothervertex[0];
5406   ymothervertex[8]  = ymothervertex[7];
5407   ymothervertex[9]  = ymothervertex[8]
5408                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5409   ymothervertex[10] = ymothervertex[9];
5410   ymothervertex[11] = ymothervertex[8];
5411   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5412   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5413   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5414   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5415   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5416   ////////////////////////////////////////
5417   // Adding Nodes
5418   ////////////////////////////////////////
5419 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5420   TGeoTranslation*** endcapcoverplatesmallholetrans;
5421   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5422   Double_t transx[4] = {0,
5423                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5424                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5425                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5426                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5427                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5428   Int_t index = 0;
5429   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5430         endcapcoverplatesmallholetrans[i] = 
5431                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5432     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5433                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5434             endcapcoverplatesmallholetrans[i][j] = 
5435                 new TGeoTranslation(transx[i],
5436                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5437             if(index!=10){ 
5438                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5439                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5440                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5441                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5442                 }
5443                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5444                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5445                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5446     }
5447   }
5448   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5449   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5450   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5451   mothercoverplate->AddNode(endcapfillingbox,1);
5452   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5453   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5454   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5455   mothercoverplate->AddNode(holecontour[0],1);
5456   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5457   mothercoverplate->AddNode(holecontour[1],1);  
5458   mothercoverplate->AddNode(contour,1);
5459   /////////////////////////////////
5460   return mothercoverplate;      
5461  }
5462  ////////////////////////////////////////////////////////////////////////////////
5463  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5464   /////////////////////////////////////////////////////////////
5465   // Getting EndCap Cooling Tube 
5466   /////////////////////////////////////////////////////////////
5467   TGeoTorus* endcapcoolingtubetorushape[5];
5468   TGeoVolume* endcapcoolingtubetorus[5];
5469   TGeoTube* endcapcoolingtubeshape[4];
5470   TGeoVolume* endcapcoolingtube[4];
5471   char endcapcoolingtubetorusname[30];
5472   char endcapcoolingtubename[30];
5473   TGeoTorus* endcapcoolingwatertubetorushape[5];
5474   TGeoVolume* endcapcoolingwatertubetorus[5];
5475   TGeoTube* endcapcoolingwatertubeshape[4];
5476   TGeoVolume* endcapcoolingwatertube[4];
5477   char endcapcoolingwatertubetorusname[30];
5478   char endcapcoolingwatertubename[30];
5479   for(Int_t i=0; i<5; i++){
5480         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5481         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5482         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5483         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5484         if(i==3){
5485                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5486                                                                                 fgkEndCapCoolingTubeRadiusMin,
5487                                                                                 fgkEndCapCoolingTubeRadiusMax,
5488                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5489                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5490                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5491                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5492     }
5493         else{
5494                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5495                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5496                                                                            fgkEndCapCoolingTubeRadiusMin,
5497                                                                            fgkEndCapCoolingTubeRadiusMax,
5498                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5499                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5500                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5501                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5502                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5503         }
5504         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5505                                                                                            endcapcoolingtubetorushape[i],
5506                                                                                            fSSDCoolingTubePhynox);
5507         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5508                                                                                                         endcapcoolingwatertubetorushape[i],
5509                                                                                                         fSSDCoolingTubeWater);
5510     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5511     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5512     if(i<4){
5513                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5514                                                                   fgkEndCapCoolingTubeRadiusMax,
5515                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5516                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5517                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5518         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5519                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5520         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5521                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5522                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5523                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5524         }
5525   }
5526   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5527   /////////////////////////////////////////
5528   // Transformation for Volume Positioning 
5529   /////////////////////////////////////////
5530   TGeoCombiTrans* coolingtubecombitrans[6];
5531   TGeoRotation* coolingtuberot[8];
5532   TGeoTranslation* coolingtubetrans[6];
5533   TGeoHMatrix* coolingtubematrix[4];
5534   TGeoCombiTrans* torustubecombitrans[4];
5535   TGeoRotation* torustuberot[7];
5536   TGeoTranslation* torustubetrans[4];
5537   TGeoHMatrix* torustubematrix[5];
5538   TGeoCombiTrans* coolingwatertubecombitrans[6];
5539   TGeoRotation* coolingwatertuberot[8];
5540   TGeoTranslation* coolingwatertubetrans[6];
5541   TGeoHMatrix* coolingwatertubematrix[4];
5542   TGeoCombiTrans* toruswatertubecombitrans[4];
5543   TGeoRotation* toruswatertuberot[7];
5544   TGeoTranslation* toruswatertubetrans[4];
5545   TGeoHMatrix* toruswatertubematrix[5];
5546   for(Int_t i=0; i<8; i++){
5547     if(i<6){
5548          coolingtubetrans[i] = new TGeoTranslation();
5549          coolingwatertubetrans[i] = new TGeoTranslation();
5550     }
5551     if(i<8){
5552          coolingtuberot[i] = new TGeoRotation();
5553          coolingwatertuberot[i] = new TGeoRotation();
5554     }
5555     if(i<4){
5556          torustubetrans[i] = new TGeoTranslation();
5557          toruswatertubetrans[i] = new TGeoTranslation();
5558     }
5559     if(i<7){
5560          torustuberot[i] = new TGeoRotation();
5561          toruswatertuberot[i] = new TGeoRotation();
5562         }
5563   }
5564   /////////////////////////////////////////
5565   // Transformation for Inox Volume Positioning 
5566   /////////////////////////////////////////
5567   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5568                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5569   coolingtuberot[0]->SetAngles(0.,90.,0.);
5570   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5571                                                                                                 *coolingtuberot[0]);
5572                                                                                                 
5573   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5574   coolingtuberot[1]->SetAngles(0.,90.,0.);
5575   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5576                                                                                                 *coolingtuberot[1]);
5577
5578   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5579                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5580                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5581                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5582                                                                           0.);
5583   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5584   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5585                                                                                                 *coolingtuberot[2]);
5586
5587   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5588                                            *                             (*coolingtubecombitrans[1]));
5589
5590   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5591                                                                          endcapcoolingtubeshape[1]->GetDz());
5592   torustuberot[0]->SetAngles(0.,90.,0.); 
5593   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5594
5595   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5596
5597   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5598                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5599   coolingtuberot[3]->SetAngles(0.,90.,0.);
5600   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5601                                                                                                 *coolingtuberot[3]);
5602   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5603   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5604   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5605   
5606   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5607                                                                         endcapcoolingtubeshape[2]->GetDz());
5608   torustuberot[1]->SetAngles(0.,90.,0.); 
5609   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5610   torustuberot[2]->SetAngles(180.,0.,0.); 
5611   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5612   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5613
5614   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5615                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5616   torustuberot[3]->SetAngles(0.,90.,0.); 
5617   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5618   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5619   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5620   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5621
5622   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5623                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5624   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5625   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5626                                                                                                 *coolingtuberot[5]);
5627   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5628   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5629   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5630   
5631   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5632                                                                         endcapcoolingtubeshape[0]->GetDz());
5633   torustuberot[5]->SetAngles(0.,90.,0.); 
5634   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5635   torustuberot[6]->SetAngles(-90.,0.,0.); 
5636   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5637   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5638   
5639   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5640                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5641   coolingtuberot[6]->SetAngles(0.,90.,0.);
5642   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5643                                                                                                 *coolingtuberot[6]);
5644   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5645   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5646   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5647     /////////////////////////////////////////
5648   // Transformation for Water Volume Positioning 
5649   /////////////////////////////////////////
5650   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5651                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5652   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5653   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5654                                                                                                      *coolingwatertuberot[0]);
5655
5656   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5657   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5658   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5659                                                                                                      *coolingwatertuberot[1]);
5660
5661   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5662                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5663                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5664                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5665                                                                               0.);
5666   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5667   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5668                                                                                                     *coolingwatertuberot[2]);
5669
5670   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5671                                            *                                 (*coolingwatertubecombitrans[1]));
5672                                            
5673   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5674                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5675   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5676   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5677                                                                                                    *toruswatertuberot[0]);
5678
5679   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5680                                                   *                                     (*toruswatertubecombitrans[0]));
5681
5682   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5683                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5684   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5685   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5686                                                                                                      *coolingwatertuberot[3]);
5687   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5688   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5689                                                         *                                 (*coolingwatertubecombitrans[3]));
5690   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5691
5692   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5693                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5694   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5695   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5696                                                                                                    *toruswatertuberot[1]);
5697   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5698   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5699                                                   *                 (*toruswatertubecombitrans[1]));
5700   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5701   
5702   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5703                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5704   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5705   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5706                                                                                                    *toruswatertuberot[3]);
5707   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5708   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5709                                                   *                                     (*toruswatertubecombitrans[2]));
5710   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5711
5712   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5713                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5714   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5715   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5716                                                                                                      *coolingwatertuberot[5]);
5717   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5718   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5719                                                         *                                 (*coolingwatertubecombitrans[4]));
5720   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5721   
5722   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5723                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5724   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5725   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5726                                                                                                    *toruswatertuberot[5]);
5727   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5728   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5729                                                   *                 (*toruswatertubecombitrans[3]));
5730   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5731   
5732   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5733                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5734   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5735   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5736                                                                                                      *coolingwatertuberot[6]);
5737   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5738   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5739                                                         *                                 (*coolingwatertubecombitrans[5]));
5740   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5741   /////////////////////////////////////////
5742   // Positioning Volumes
5743   /////////////////////////////////////////
5744   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5745   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5746   
5747   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5748   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5749
5750   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5751   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5752  
5753   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5754   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5755
5756   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5757   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5758
5759   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5760   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5761
5762   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5763   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5764
5765   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5766   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5767   
5768   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5769   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5770  
5771   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5772   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5773   /////////////////////////////////////////////////////////////
5774   // Deallocating memory
5775   /////////////////////////////////////////////////////////////
5776   for(Int_t i=0; i<8; i++){
5777     if(i<6){
5778          delete coolingtubetrans[i];
5779          delete coolingwatertubetrans[i];
5780          if(i!=0){
5781           delete coolingtubecombitrans[i];
5782           delete coolingwatertubecombitrans[i];
5783          }
5784         }
5785     if(i<8){
5786           delete coolingtuberot[i];
5787           delete coolingwatertuberot[i];
5788     }
5789     if(i<4){
5790                 delete torustubetrans[i];
5791                 delete toruswatertubetrans[i];
5792                 delete torustubecombitrans[i];
5793                 delete toruswatertubecombitrans[i];
5794         } 
5795     if(i<7){
5796          delete torustuberot[i];
5797          delete toruswatertuberot[i];
5798         }
5799   }
5800   /////////////////////////////////////////////////////////////
5801   return endcapcoolingtubemother;
5802  }
5803  ////////////////////////////////////////////////////////////////////////////////
5804  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5805   /////////////////////////////////////////////////////////////
5806   // Getting EndCap Cover Side 
5807   /////////////////////////////////////////////////////////////
5808   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5809   const Int_t kvertexnumber = 15; 
5810   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5811   xvertex[0]  = 0.0;
5812   xvertex[1]  = xvertex[0];
5813   xvertex[2]  = fgkEndCapSideCoverLength[0];
5814   xvertex[3]  = fgkEndCapSideCoverLength[1];
5815   xvertex[4]  = xvertex[3];
5816   xvertex[5]  = fgkEndCapSideCoverLength[2];
5817   xvertex[6]  = xvertex[5];
5818   xvertex[7]  = xvertex[2];
5819   xvertex[8]  = xvertex[7];
5820   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5821   xvertex[10] = xvertex[9];
5822   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5823                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5824                           * fgkEndCapSideCoverLength[4];
5825   xvertex[12] = xvertex[11];
5826   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5827                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5828                           * fgkEndCapSideCoverLength[4];
5829   xvertex[14] = xvertex[13];
5830   yvertex[0]  = 0.0;
5831   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5832   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5833   yvertex[3]  = yvertex[2];
5834   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5835   yvertex[5]  = yvertex[4];
5836   yvertex[6]  = yvertex[0];
5837   yvertex[7]  = yvertex[6];
5838   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5839   yvertex[9]  = yvertex[8];
5840   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5841   yvertex[11] = yvertex[10];
5842   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5843   yvertex[13] = yvertex[12];
5844   yvertex[14] = yvertex[6];
5845   TGeoXtru* endcapsidecovershape = new TGeoXtru(2);
5846   endcapsidecovershape->DefinePolygon(kvertexnumber,xvertex,yvertex); 
5847   endcapsidecovershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5848   endcapsidecovershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5849   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5850                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5851   endcapsidecover->SetLineColor(fColorPhynox);
5852   ////////////////////////////////////////////
5853   // Defininition of Mother Volume
5854   ////////////////////////////////////////////
5855   const Int_t kmothervertexnumber = 7;
5856   Double_t xmothervertex[kmothervertexnumber]; 
5857   Double_t ymothervertex[kmothervertexnumber]; 
5858   for(Int_t i=0; i<kmothervertexnumber; i++){
5859         xmothervertex[i] = xvertex[i];
5860         ymothervertex[i] = yvertex[i];
5861   }
5862   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5863   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5864   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5865   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5866   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5867                                                                 endcapsidecovermothershape,fSSDAir);
5868   ////////////////////////////////////////////
5869   endcapsidecovermother->AddNode(endcapsidecover,1);
5870   TGeoBBox* endcapsidecoverboxshape[4];
5871   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5872                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5873                                                                0.5*fgkEndCapSideCoverLength[4],
5874                                                                    0.5*fgkEndCapSideCoverThickness); 
5875   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5876                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5877                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5878                                                          -     fgkEndCapSideCoverLength[4]),
5879                                                                    0.5*fgkEndCapSideCoverThickness); 
5880   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5881                                                                0.5*fgkEndCapSideCoverLength[4],
5882                                                                    0.5*fgkEndCapSideCoverThickness); 
5883   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5884                                                                0.5*fgkEndCapSideCoverWidth[5],
5885                                                                    0.5*fgkEndCapSideCoverThickness); 
5886   TGeoVolume* endcapsidecoverbox[4];
5887   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5888   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5889   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5890   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5891   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5892 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5893   TGeoTranslation** endcapsidecoverboxtrans;
5894   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5895   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5896                                                          +                                         fgkEndCapSideCoverLength[0],
5897                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5898                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5899   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5900                                                          +                     xvertex[11],
5901                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5902                                                          +                     yvertex[12],0.);
5903   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5904                                                          +                     xvertex[11],
5905                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5906                                                          +                     yvertex[12]
5907                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5908                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5909   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5910   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5911   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5912   for(Int_t i=0; i<2; i++)
5913         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5914                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5915                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5916                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5917                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5918                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5919                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5920                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5921         }
5922   for(Int_t i=0; i<2; i++)
5923         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5924                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5925                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5926                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5927                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5928                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5929                                                         +fgkEndCapSideCoverLength[4]),0.0);
5930                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5931                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5932                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5933                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5934         }
5935         return endcapsidecovermother;
5936  } 
5937  ////////////////////////////////////////////////////////////////////////////////
5938  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5939  ////////////////////////////////////////////////////////////////////////////////
5940  // Method returning Interface Card A, Interface Card B, Supply Card 
5941  ////////////////////////////////////////////////////////////////////////////////
5942  /////////////////////
5943  // Supply Card
5944  /////////////////////
5945  // Electronic Board Back Al Plane
5946  const Int_t kelectboardbackvertexnumber = 8;
5947  Double_t xelectboardback[kelectboardbackvertexnumber];
5948  Double_t yelectboardback[kelectboardbackvertexnumber];
5949  xelectboardback[0] = 0.0;
5950  xelectboardback[1] = xelectboardback[0];
5951  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5952  xelectboardback[3] = xelectboardback[2];
5953  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5954  xelectboardback[5] = xelectboardback[4];
5955  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5956  xelectboardback[7] = xelectboardback[6];
5957  
5958  yelectboardback[0] = 0.0;
5959  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5960  yelectboardback[2] = yelectboardback[1];
5961  yelectboardback[3] = yelectboardback[0];
5962  yelectboardback[4] = yelectboardback[3];
5963  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5964  yelectboardback[6] = yelectboardback[5];
5965  yelectboardback[7] = yelectboardback[4];
5966  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5967  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5968                                                                         xelectboardback,yelectboardback); 
5969  electboardbackshape->DefineSection(0,0.0);
5970  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5971  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5972                                                                                          electboardbackshape,fSSDSupportRingAl);
5973  electboardback->SetLineColor(fColorAl);
5974  // Electronic Board Kapton Layer
5975  const Int_t kelectlayervertexnumber = 8;
5976  Double_t xelectlayer[kelectlayervertexnumber];
5977  Double_t yelectlayer[kelectlayervertexnumber];
5978  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5979  xelectlayer[1] = xelectlayer[0];
5980  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5981  xelectlayer[3] = xelectlayer[2];
5982  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5983      
5984  yelectlayer[0] = 0.0;
5985  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5986  yelectlayer[2] = yelectlayer[1];
5987  yelectlayer[3] = yelectlayer[0];
5988  yelectlayer[4] = yelectlayer[3];
5989  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5990  yelectlayer[6] = yelectlayer[5];
5991  yelectlayer[7] = yelectlayer[4];
5992  TGeoXtru* electlayershape = new TGeoXtru(2);
5993  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5994  electlayershape->DefineSection(0,0.0);
5995  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5996  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
5997                                                                                          electlayershape,fSSDKaptonFlexMedium);
5998  electlayer->SetLineColor(fColorKapton);
5999  // JMD Connector Female
6000  const Int_t kjmdconnectorvertexnumber = 6;
6001  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6002  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6003  xjmdconnectorvertex[0] = 0.0; 
6004  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
6005  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
6006  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
6007  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
6008  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
6009
6010  yjmdconnectorvertex[0] = 0.0; 
6011  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
6012  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
6013  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
6014  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
6015  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
6016  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
6017  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
6018                                                                   yjmdconnectorvertex); 
6019  jmdconnectorshape->DefineSection(0,0.0);
6020  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6021  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6022                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6023  jmdconnector->SetLineColor(fColorG10);
6024  // Top Cable Connector
6025  const Int_t kcableconnectorvertexnumber = 8;
6026  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6027  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6028  xconnectorvertex[0] = 0.0;
6029  xconnectorvertex[1] = xconnectorvertex[0];
6030  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6031  xconnectorvertex[3] = xconnectorvertex[2];
6032  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6033                                          - fgkEndCapCardCableConnectorLength[2];
6034  xconnectorvertex[5] = xconnectorvertex[4];
6035  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6036  xconnectorvertex[7] = xconnectorvertex[6];
6037
6038  yconnectorvertex[0] = 0.0;
6039  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6040  yconnectorvertex[2] = yconnectorvertex[1];
6041  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6042  yconnectorvertex[4] = yconnectorvertex[3];
6043  yconnectorvertex[5] = yconnectorvertex[1];
6044  yconnectorvertex[6] = yconnectorvertex[5];
6045  yconnectorvertex[7] = yconnectorvertex[0];
6046  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6047  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6048                                                                     yconnectorvertex); 
6049  cableconnectorshape->DefineSection(0,0.0);
6050  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6051  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6052                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6053  cableconnector->SetLineColor(fColorG10);
6054  // Strip Connection
6055  TGeoBBox* endcapstripconnectionshape = 
6056                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6057                                                                                          0.5*fgkEndCapStripConnectionThickness,
6058                                                                                          0.5*fgkEndCapStripConnectionWidth);
6059  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6060                                                                                                         endcapstripconnectionshape,
6061                                                                                                         fSSDSupportRingAl);
6062  endcapstripconnection->SetLineColor(fColorAl);
6063  // Interface Card B
6064  const Int_t kcardBvertexnumber = 12; 
6065  Double_t xcardBvertexnumber[kcardBvertexnumber];
6066  Double_t ycardBvertexnumber[kcardBvertexnumber];
6067
6068  xcardBvertexnumber[0]  = 0.0;
6069  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6070  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6071  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6072  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6073  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6074  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6075  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6076  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6077  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6078  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6079  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6080  
6081  ycardBvertexnumber[0]  = 0.0;
6082  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6083  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6084  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6085  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6086  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6087  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6088  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6089  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6090  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6091  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6092  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6093
6094  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6095  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6096  interfacecardBshape->DefineSection(0,0.);
6097  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6098  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6099                                                                                          fSSDMountingBlockMedium);
6100  interfacecardB->SetLineColor(46);
6101  // Interface Card B Electronic Board
6102  const Int_t kelectboardcardBvertexnumber = 14; 
6103  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6104  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6105
6106  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6107  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6108  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6109  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6110  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6111  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6112  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6113  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6114  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6115  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6116  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6117  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6118  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6119  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6120
6121  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6122  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6123  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6124  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6125  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6126  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6127  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6128  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6129  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6130  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6131  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6132  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6133  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6134  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6135
6136  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6137  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6138                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6139  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6140  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6141                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6142  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6143                                                                                           fSSDSupportRingAl);
6144  electboardcardB->SetLineColor(fColorAl);
6145  // Generating Stiffener 2
6146  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6147                                                                                            0.5*fgkEndCapStiffenerThickness,
6148                                                                                            0.5*fgkEndCapStiffenerLength);
6149  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6150  endcapstiffener->SetLineColor(fColorAl);   
6151  // Generating Mother Interface Card B Container
6152  const Int_t kinterfacecardBmothervertexnumber = 10;
6153  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6154  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6155
6156  xinterfacecardBmothervertex[0] = 0.0;
6157  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6158  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6159                                                                 + fgkEndCapInterfaceCardBThickness;
6160  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6161  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6162                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6163  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6164  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6165  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6166  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6167                                                                 + fgkEndCapCardJMDConnectorLength[0];
6168  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6169
6170  yinterfacecardBmothervertex[0] = 0.0;
6171  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6172                                                                 + fgkEndCapInterfaceCardBWidth[1]
6173                                                                 + fgkEndCapInterfaceCardBWidth[2];
6174  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6175  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6176  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6177  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6178  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6179  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6180                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6181                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6182  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6183  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6184  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6185  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6186                                                                                   xinterfacecardBmothervertex,
6187                                                                                   yinterfacecardBmothervertex);
6188  interfacecardBmothershape->DefineSection(0,-1.e-15);
6189  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6190  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6191                                                                                                    interfacecardBmothershape,fSSDAir);
6192  electboardcardB->SetLineColor(fColorAl);
6193  // Positioning Volumes Mother Interface Card B Container 
6194  TGeoRotation* interfacecardBrot = new TGeoRotation();
6195  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6196  interfacecardBrot->SetAngles(90.,-90.,-90.);
6197  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6198  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6199  TGeoRotation* electboardcardBrot = new TGeoRotation();
6200  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6201  electboardcardBrot->SetAngles(90.,90.,-90.);
6202  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6203  TGeoCombiTrans* electboardcardBcombitrans = 
6204                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6205  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6206  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6207  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6208  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6209  TGeoTranslation* jmdconnectorcardBtrans[3];
6210  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6211  for(Int_t i=0; i<3; i++){
6212    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6213                                                          + fgkEndCapCardJMDConnectorLength[0], 
6214                                                            fgkEndCapCardElectBoardLayerWidth[1],
6215                                                            0.5*fgkEndCapCardJMDConnectorThickness
6216                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6217                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6218                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6219    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6220                                                                                                            *jmdconnectorcardBrot);
6221    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6222  }
6223  // Mother Supply Card Container 
6224  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6225  // Interface Card Container
6226  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6227  // Placing Volumes in Mother Supply Card Container
6228  // JMD Connector Positioning
6229  TGeoTranslation* jmdconnectortrans[2];
6230  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6231  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6232                                                                                         fgkEndCapCardElectBoardBackLength[0]
6233                                           -                                             fgkEndCapCardJMDConnectorThickness
6234                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6235  TGeoRotation* jmdconnectorot = new TGeoRotation();
6236  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6237                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6238                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6239                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6240                                                                       fgkEndCapCardJMDConnectorThickness
6241                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6242  jmdconnectorot->SetAngles(90.,180.,-90);
6243  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6244                                                                                 * jmdconnectorot);
6245  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6246  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6247  // Top Cable Connector Placing
6248  TGeoRotation* cableconnectorot[2];
6249  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6250  TGeoTranslation* cableconnectortrans[3];
6251  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6252  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6253  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6254  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6255  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6256                                                                                                                            *cableconnectorot[0]);
6257  TGeoHMatrix* cableconnectormatrix[2];
6258  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6259                                                         new TGeoHMatrix((*cableconnectorot[1])
6260                                                                                    *(*cableconnectorcombitrans));
6261  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6262                                            -                               fgkEndCapCardCableConnectorThickness,
6263                                                                                 fgkEndCapCardCableConnectorLength[0]
6264                                            +                            fgkEndCapCardCableConnectorToLayer);
6265  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6266                                            -                2.*fgkEndCapCardCableConnectorThickness
6267                                            -                            fgkEndCapCardCableConnectorDistance,
6268                                                                                 fgkEndCapCardCableConnectorLength[0]
6269                                            +                            fgkEndCapCardCableConnectorToLayer);
6270  for(Int_t i=0; i<2; i++){
6271         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6272     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6273  }
6274  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6275  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6276  electboardbackrot->SetAngles(90.,-90.,-90.);
6277  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6278                                                         +                fgkEndCapCardJMDConnectorLength[0]
6279                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6280  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6281                                                                                                                            *electboardbackrot);
6282  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6283  // Electronic Board Kapton Layer Positioning
6284  TGeoRotation* electlayerrot = new TGeoRotation();
6285  TGeoTranslation* electlayertrans[2];
6286  TGeoCombiTrans* electlayercombitrans[2];
6287  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6288  electlayerrot->SetAngles(90.,-90.,-90.);
6289  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6290                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6291  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6292                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6293                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6294  for(Int_t i=0; i<2; i++){
6295         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6296         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6297  }
6298  // Placing Volumes in Mother Interface Card Container
6299  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6300  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6301  for(Int_t i=0; i<2; i++){
6302         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6303  }
6304  /////////////////////////////////////////////////////////////
6305  // Generation of Card Interface Container
6306  /////////////////////////////////////////////////////////////
6307  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6308                                                   - fgkEndCapCardJMDConnectorLength[0]
6309                                                   - fgkEndCapInterfaceCardBThickness
6310                                                   - 9.*fgkEndCapStripConnectionThickness
6311                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6312  const Int_t kcardinterfacecontainervertexnumber = 14;
6313  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6314  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6315  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6316                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6317  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6318  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6319                                                                    + fgkEndCapStripConnectionThickness
6320                                                                    - fgkEndCapCardElectBoardLayerThickness
6321                                                                    - fgkEndCapCardCableConnectorWidth[0];
6322  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6323  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6324  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6325  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6326                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6327  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6328  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6329                                                                    + fgkEndCapInterfaceCardBThickness;
6330  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6331  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6332                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6333  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6334  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6335                                    - fgkEndCapInterfaceElectBoardCardBThickness
6336                                                                    + fgkEndCapCardJMDConnectorLength[0]
6337                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6338  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6339
6340  ycardinterfacecontainervertex[0]  = 0.;
6341  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6342                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6343                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6344  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6345  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6346                                                                    - fgkEndCapStripConnectionWidth;
6347  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6348  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6349  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6350  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6351                                                                    + fgkEndCapInterfaceCardBWidth[1]
6352                                                                    + fgkEndCapInterfaceCardBWidth[2];
6353  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6354  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6355  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6356  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6357  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6358  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6359  
6360  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6361  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6362                                                                                   xcardinterfacecontainervertex,
6363                                                                                   ycardinterfacecontainervertex);
6364  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6365                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6366  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6367                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6368  TGeoVolume** cardinterfacecontainer;
6369  cardinterfacecontainer = new TGeoVolume*[4];
6370  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6371                                                                                         interfacecardmothershape,fSSDAir); 
6372  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6373                                                                                         interfacecardmothershape,fSSDAir); 
6374  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6375                                                                                         interfacecardmothershape,fSSDAir); 
6376  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6377                                                                                         interfacecardmothershape,fSSDAir); 
6378  /////////////////////////////////
6379  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6380  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6381  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6382  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6383  /////////////////////////////////
6384  TGeoRotation* endcapstripconnectionrot[2];
6385  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6386  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6387  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6388  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6389                                                                         *                                 (*endcapstripconnectionrot[0]));
6390  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6391  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6392                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6393                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6394                                                                                         -endcapstripconnectionshape->GetDZ(),
6395                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6396  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6397  TGeoTranslation* cardinterfacetrans[9];
6398  TGeoHMatrix* cardinterfacematrix[9]; 
6399  for(Int_t i=0; i<7; i++){ 
6400         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6401                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6402                                                                                                 0.0,0.0);  
6403         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6404                                                    *                             (*endcapstripconnectionmatrix));
6405  }
6406  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6407                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6408                                                                                                 0.0,0.0);  
6409  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6410                                                 *                                 (*endcapstripconnectionmatrix));
6411  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6412                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6413                                                                                                 0.0,0.0);  
6414  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6415                                                 *                                 (*endcapstripconnectionmatrix));
6416
6417  for(Int_t i=0; i<4; i++){
6418         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6419                                                                            cardinterfacematrix[7]);                             
6420         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6421                                                                            cardinterfacematrix[8]);                             
6422  }
6423  TGeoTranslation* mothersupplycardtrans = 
6424                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6425                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6426                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6427  TGeoHMatrix* mothersupplycardmatrix[7];
6428  Int_t index[4] = {1,1,1,1};
6429  for(Int_t i=0; i<7; i++){
6430         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6431                                                         *                                 (*mothersupplycardtrans));
6432         for(Int_t j=0; j<4; j++){
6433                 switch(j){
6434                         case 0: //Layer5 EndCap Left Side  
6435                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6436                                                                                                    cardinterfacematrix[i]);                             
6437                                 if(i!=0){
6438                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6439                                                                                                            mothersupplycardmatrix[i]);                  
6440                                         index[j]++;
6441
6442                                 }
6443                         break;
6444                         case 1: //Layer5 EndCap Rigth Side  
6445                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6446                                                                                                    cardinterfacematrix[i]);                     
6447                                 if(i>0&&i<6){
6448                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6449                                                                                                            mothersupplycardmatrix[i]);                  
6450                                         index[j]++;
6451                                 }
6452                         break;
6453                         case 2: //Layer6 EndCap Left Side  
6454                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6455                                                                                                    cardinterfacematrix[i]);                             
6456                                 if(i!=6){
6457                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6458                                                                                                            mothersupplycardmatrix[i]);                  
6459                                         index[j]++;
6460                                 }
6461                         break;
6462                         case 3: //Layer6 EndCap Right Side  
6463                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6464                                                                                                    cardinterfacematrix[i]);                             
6465                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6466                                                                                                    mothersupplycardmatrix[i]);                  
6467                                 index[j]++;
6468                         break;
6469                 }
6470         }
6471  }
6472  // Positioning Interface 
6473  TGeoTranslation* motherinterfacecardtrans = 
6474                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6475                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6476                                                          -fgkEndCapCardElectBoardLayerThickness
6477                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6478  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6479                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6480  // Positioning Interface Card B 
6481  TGeoTranslation* interfacecardBmothertrans = 
6482                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6483                                                                                 + 2.*fgkEndCapStripConnectionThickness
6484                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6485                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6486                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6487  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6488                                                                                                                          interfacecardBmothertrans);
6489  // Positioning Stiffener 
6490  TGeoTranslation* endcapstiffenertrans = 
6491                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6492                                                                            +    2.0*fgkEndCapStripConnectionThickness
6493                                                                            +    fgkEndCapInterfaceCardBThickness
6494                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6495                                                                            +    stiffenertransx
6496                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6497                                                                                         endcapstiffenershape->GetDZ()
6498                                                                            -    0.5*(fgkEndCapStiffenerLength
6499                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6500  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6501  /////////////////////////////////////////////////////////////
6502  // Deallocating memory
6503  /////////////////////////////////////////////////////////////
6504  delete interfacecardBrot;
6505  delete interfacecardBtrans;
6506  delete electboardcardBtrans;
6507  delete electboardcardBrot; 
6508  delete jmdconnectorcardBrot;
6509  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6510  delete jmdconnectorot;
6511  delete jmdconnectortrans[1];
6512  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6513  delete cableconnectorcombitrans;
6514  delete electboardbacktrans;
6515  delete electboardbackrot;
6516  delete electlayerrot;
6517  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6518  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6519  delete mothersupplycardtrans;
6520  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6521  /////////////////////////////////////////////////////////////
6522  return cardinterfacecontainer;
6523  }
6524  ////////////////////////////////////////////////////////////////////////////////
6525  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6526   /////////////////////////////////////////////////////////////
6527   // Method returning EndCap Mother Volume
6528   /////////////////////////////////////////////////////////////
6529   const Int_t kendcapcoverplatesmallholenumber = 9;
6530   Double_t endcapmotherorigin[3];
6531   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6532                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6533                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6534   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6535                                           -                      fgkEndCapCoverPlateWidth[2]
6536                                           -       (kendcapcoverplatesmallholenumber-1)
6537                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6538                                           +  0.5*(fgkEndCapSideCoverLength[2]
6539                                           +               fgkEndCapCoverPlateWidth[1]
6540                                           -       fgkEndCapCoverPlateWidth[0])
6541                                           -      (fgkEndCapCoverPlateWidth[1]
6542                                           -       fgkEndCapCoverPlateWidth[0]);
6543   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6544                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6545                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6546                                                 +      fgkEndCapSideCoverWidth[1]
6547                                                 +      fgkEndCapSideCoverThickness
6548                                                 +      fgkEndCapKaptonFoilThickness);
6549   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6550                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6551                                                           +              2.0* fgkEndCapSideCoverThickness),
6552                                                                          0.5* (fgkEndCapSideCoverLength[2]
6553                                                           +                    fgkEndCapCoverPlateWidth[1]
6554                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6555                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6556                                                       +                                    fgkEndCapSideCoverWidth[1]
6557                                                           +                                       fgkEndCapSideCoverThickness
6558                                                       +                                   fgkEndCapKaptonFoilThickness),
6559                                                                                          endcapmotherorigin);
6560   TGeoVolume** endcapassembly;  
6561   endcapassembly = new TGeoVolume*[4];
6562   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6563                                                                                         endcapmothershape,fSSDAir); 
6564   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6565                                                                                         endcapmothershape,fSSDAir); 
6566   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6567                                                                                         endcapmothershape,fSSDAir); 
6568   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6569                                                                                         endcapmothershape,fSSDAir); 
6570  /////////////////////////////////
6571  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6572  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6573  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6574  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6575  /////////////////////////////////
6576   /////////////////////////////////////////////////////
6577   // Placing Endcap Cover Plate
6578   /////////////////////////////////////////////////////
6579   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6580   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6581   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6582   TGeoCombiTrans* endcapcoverplatecombitrans = 
6583                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6584                                                                                          endcapcoverplaterot);
6585   TGeoTranslation* endcapcoverplatetrans = 
6586                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6587   TGeoHMatrix* endcapcoverplatematrix = 
6588                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6589                                                                           *       (*endcapcoverplatecombitrans));
6590   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6591   /////////////////////////////////////////////////////
6592   // Placing Endcap Side Cover
6593   /////////////////////////////////////////////////////
6594   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6595   TGeoRotation* endcapsidecoverot[2];
6596   TGeoCombiTrans* endcapsidecovercombitrans[3];
6597   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6598   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6599   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6600                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6601                                                                                         - fgkEndCapCoverPlateWidth[2]
6602                                                                                     - (kendcapcoverplatesmallholenumber-1)
6603                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6604                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6605                                                                                         + fgkEndCapSideCoverLength[2],
6606                                                                                           0.5*(fgkEndCapSideCoverThickness
6607                                                                                         + fgkEndCapCoverPlateThickness)
6608                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6609                                                                                           endcapsidecoverot[0]);
6610   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6611   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6612                                                                                                         0.5*fgkEndCapCoverPlateThickness
6613                                                                                                         -fgkEndCapSideCoverWidth[1],
6614                                                                                                         endcapsidecoverot[1]);
6615   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6616                                                                                                         +fgkEndCapCoverPlateLength[3]
6617                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6618                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6619                                                                                                         0.5*fgkEndCapCoverPlateThickness
6620                                                                                                         -fgkEndCapSideCoverWidth[1],
6621                                                                                                         endcapsidecoverot[1]);
6622   TGeoHMatrix* endcapsidecovermatrix[2];
6623   for(Int_t i=0; i<2; i++){
6624    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6625                                                         *                                 (*endcapsidecovercombitrans[0]));
6626         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6627                                                                                                                 endcapsidecovermatrix[i]);
6628   }
6629   /////////////////////////////////////////////////////
6630   // Placing Endcap Cooling Tube
6631   /////////////////////////////////////////////////////
6632   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6633   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6634   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6635   TGeoCombiTrans* endcapccolingtubecombitrans 
6636                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6637                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6638                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6639                                                 - fgkEndCapCoolingTubeToCoverSide,
6640                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6641                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6642   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6643                                                                                                           endcapccolingtubecombitrans);
6644   /////////////////////////////////////////////////////
6645   // Placing Screws 
6646   /////////////////////////////////////////////////////
6647   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6648                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6649   Int_t screwcoverplatedgesnumber[2] = {20,20};
6650   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6651                                                                                 fgkEndCapCoverPlateThickness
6652                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6653   TGeoXtru* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6654                                                                                                  screwcoverplatedgesnumber,
6655                                                                                                  screwcoverplatesection);
6656   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6657                                                                                            screwcoverplateshape,
6658                                                                                            fSSDCoolingTubePhynox); 
6659   screwcoverplate->SetLineColor(12);
6660   Double_t transx[4] = {0,
6661                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6662                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6663                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6664                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6665                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6666   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6667 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6668   TGeoTranslation*** endcapcoverplatescrewtrans;
6669   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6670   Int_t index = 0;
6671   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6672         endcapcoverplatescrewtrans[i] = 
6673                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6674     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6675                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6676         if(index==1||index==9||index==28||index==36){
6677                         endcapcoverplatescrewtrans[i][j] = 
6678                                 new TGeoTranslation(transx[i],
6679                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6680                                                                         fgkEndCapSideCoverThickness);
6681                 }
6682                 else{
6683                         endcapcoverplatescrewtrans[i][j] = 
6684                                 new TGeoTranslation(transx[i],
6685                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6686                                                                         0.);
6687                 }
6688             if(index!=19) 
6689                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6690                                                                                           endcapcoverplatescrewtrans[i][j]);
6691         }
6692   }
6693   /////////////////////////////////////////////////////
6694   // Placing Cover Plate Clips 
6695   /////////////////////////////////////////////////////
6696   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6697                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6698                                                                                                          0.5*fgkEndCapSideCoverThickness);
6699   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6700                                                                                                         endcapcoverplateclipshape,
6701                                                                                                         fSSDCoolingTubePhynox);
6702   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6703                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6704                                                                                                          0.5*fgkEndCapSideCoverThickness);
6705   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6706                                                                                                         endcapcoverplatedownclipshape,
6707                                                                                                         fSSDCoolingTubePhynox);
6708   TGeoTranslation* endcapcoverplatecliptrans[4];
6709   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6710                                                            -                     fgkEndCapCoverPlateLength[0]
6711                                                            -                     fgkEndCapSideCoverThickness,
6712                                                                                                          0.0,
6713                                                                                                  0.5*(fgkEndCapSideCoverThickness
6714                                                            +                                              fgkEndCapCoverPlateThickness));
6715   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6716                                                            -                     fgkEndCapCoverPlateLength[0]
6717                                                            -                     fgkEndCapSideCoverThickness,
6718                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6719                                                            *                                     fgkEndCapSideCoverWidth[5],
6720                                                                                                  0.5*(fgkEndCapSideCoverThickness
6721                                                            +                                              fgkEndCapCoverPlateThickness));
6722   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6723                                                            -                     fgkEndCapCoverPlateLength[0]
6724                                                            +                                     fgkEndCapCoverPlateLength[1]
6725                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6726                                                            -                                     fgkEndCapCoverPlateClipLength
6727                                                            +                                 fgkEndCapSideCoverThickness,
6728                                                                                                          0.0,
6729                                                                                                  0.5*(fgkEndCapSideCoverThickness
6730                                                            +                                              fgkEndCapCoverPlateThickness));
6731   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6732                                                            -                     fgkEndCapCoverPlateLength[0]
6733                                                            +                                     fgkEndCapCoverPlateLength[1]
6734                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6735                                                            -                                     fgkEndCapCoverPlateClipLength
6736                                                            +                                 fgkEndCapSideCoverThickness,
6737                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6738                                                            *                                     fgkEndCapSideCoverWidth[5],
6739                                                                                                  0.5*(fgkEndCapSideCoverThickness
6740                                                            +                                              fgkEndCapCoverPlateThickness));
6741   endcapcoverplateclip->SetLineColor(fColorPhynox);
6742   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6743   for(Int_t i=0; i<4; i++) 
6744         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6745                                                                                                    endcapcoverplatecliptrans[i]);  
6746   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6747   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6748                                                                    -                     fgkEndCapCoverPlateLength[0]
6749                                                                    -                     fgkEndCapSideCoverThickness,
6750                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6751                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6752                                                                                                         0.5*(fgkEndCapSideCoverThickness
6753                                                                +                                         fgkEndCapCoverPlateThickness)
6754                                                                    -                     fgkEndCapSideCoverWidth[1]
6755                                                                    -                                     fgkEndCapSideCoverThickness);
6756   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6757                                                                    -                     fgkEndCapCoverPlateLength[0]
6758                                                                    -                     fgkEndCapSideCoverThickness,
6759                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6760                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6761                                                                    +                            fgkEndCapSideCoverLength[2]
6762                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6763                                                                                                         0.5*(fgkEndCapSideCoverThickness
6764                                                                +                                         fgkEndCapCoverPlateThickness)
6765                                                                    -                     fgkEndCapSideCoverWidth[1]
6766                                                                    -                                     fgkEndCapSideCoverThickness);
6767   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6768                                                                    -                     fgkEndCapCoverPlateLength[0]
6769                                                                    +                     fgkEndCapSideCoverThickness
6770                                                                    +                     fgkEndCapCoverPlateLength[1]
6771                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6772                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6773                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6774                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6775                                                                                                         0.5*(fgkEndCapSideCoverThickness
6776                                                                +                                         fgkEndCapCoverPlateThickness)
6777                                                                    -                     fgkEndCapSideCoverWidth[1]
6778                                                                    -                                     fgkEndCapSideCoverThickness);
6779   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6780                                                                    -                     fgkEndCapCoverPlateLength[0]
6781                                                                    +                     fgkEndCapSideCoverThickness
6782                                                                    +                     fgkEndCapCoverPlateLength[1]
6783                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6784                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6785                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6786                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6787                                                                    +                                 fgkEndCapSideCoverLength[2]
6788                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6789                                                                                                         0.5*(fgkEndCapSideCoverThickness
6790                                                                +                                         fgkEndCapCoverPlateThickness)
6791                                                                    -                     fgkEndCapSideCoverWidth[1]
6792                                                                    -                                     fgkEndCapSideCoverThickness);
6793   for(Int_t i=0; i<4; i++)
6794         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6795                                                                                                    endcapcoverplatedowncliptrans[i]);
6796   /////////////////////////////////////////////////////
6797   // Placing Kapton Foil
6798   /////////////////////////////////////////////////////
6799   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6800                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6801                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6802   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6803                                                                                                 endcapkaptonfoilshape,
6804                                                                                                 fSSDKaptonFlexMedium);
6805   endcapkaptonfoil->SetLineColor(8);
6806   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6807                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6808                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6809                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6810                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6811                                                                              -                     fgkEndCapSideCoverWidth[1]
6812                                                                                  -                     fgkEndCapSideCoverThickness);
6813   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6814   /////////////////////////////////////////////////////////////
6815   // Placing Electronic Tubes
6816   /////////////////////////////////////////////////////////////
6817   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6818                                                                              - fgkEndCapInterfaceCardBThickness
6819                                                                              - 9.*fgkEndCapStripConnectionThickness
6820                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6821                                                                                fgkEndCapKaptonFoilWidth
6822                                                                              - fgkEndCapInterfaceCardBThickness
6823                                                                              - 9.*fgkEndCapStripConnectionThickness
6824                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6825                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6826   TGeoVolume* endcapeffectivecables[2];
6827   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6828                                                                                          fgkEndCapEffectiveCableRadiusMax,
6829                                                                                          endcapeffectivecableswidth[0],
6830                                                                                          10,"EndCapEffectiveCables1"); 
6831   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6832                                                                                          fgkEndCapEffectiveCableRadiusMax,
6833                                                                                          endcapeffectivecableswidth[1],
6834                                                                                          25,"EndCapEffectiveCables2"); 
6835   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6836   TGeoTranslation* endcapeffectivecablestrans[2];
6837   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6838                                           -                                                        0.5*endcapeffectivecableswidth[0]
6839                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6840                                           -                                                               fgkEndCapCoverPlateWidth[2]
6841                                           -                                             (kendcapcoverplatesmallholenumber-1)
6842                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6843                                           +                                             fgkEndCapSideCoverLength[2],
6844                                           -                     0.5*fgkEndCapCoverPlateThickness
6845                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6846                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6847                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6848   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6849                                           -                                                        0.5*endcapeffectivecableswidth[1]
6850                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6851                                           -                                                               fgkEndCapCoverPlateWidth[2]
6852                                           -                                             (kendcapcoverplatesmallholenumber-1)
6853                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6854                                           +                                         fgkEndCapSideCoverLength[2],
6855                                           -                     0.5*fgkEndCapCoverPlateThickness
6856                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6857                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6858                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6859   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6860   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6861   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6862                                                                                                                    *endcapeffectivecablesrot);
6863   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6864                                                                                                                    *endcapeffectivecablesrot);
6865 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6866 //                                                                                                        endcapeffectivecablescombitrans[0]);
6867   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6868                                                                                                           endcapeffectivecablescombitrans[1]);
6869   /////////////////////////////////////////////////////////////
6870   // Placing End Cap Cards
6871   /////////////////////////////////////////////////////////////
6872   TGeoVolume** endcapcards = GetEndCapCards();
6873   TGeoRotation* endcapcardsrot[2];
6874   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6875   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6876   TGeoTranslation* endcapcardstrans[2]; 
6877   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6878                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6879   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6880   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6881   TGeoHMatrix* endcapcardsmatrix[2];
6882   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6883   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6884                                                   - fgkEndCapCardJMDConnectorLength[0]
6885                                                   - fgkEndCapInterfaceCardBThickness
6886                                                   - 9.*fgkEndCapStripConnectionThickness
6887                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6888   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6889                                           -                                             fgkEndCapCoverPlateLength[0]
6890                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6891                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6892                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6893                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6894                                           -                                                               fgkEndCapInterfaceCardBThickness
6895                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6896                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6897                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6898                                           -                                                               fgkEndCapCoverPlateWidth[2]
6899                                           -                                             (kendcapcoverplatesmallholenumber-1)
6900                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6901                                           +                     fgkEndCapKaptonFoilWidth,
6902                                                                                           0.5*fgkEndCapCoverPlateThickness
6903                                           -                                                     fgkEndCapSideCoverWidth[1]);
6904   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6905   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6906    /////////////////////////////////////////////////////////////
6907   // Deallocating memory
6908   /////////////////////////////////////////////////////////////
6909   delete endcapcoverplaterot;
6910   delete endcapcoverplatecombitrans;
6911   delete endcapcoverplatetrans;
6912   for(Int_t i=0; i<3; i++){
6913    delete endcapsidecovercombitrans[i];
6914    if(i<2) delete endcapsidecoverot[i]; 
6915   }
6916   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6917   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6918   delete endcapcardsmatrix[0];
6919   return endcapassembly;
6920  } 
6921  ////////////////////////////////////////////////////////////////////////////////
6922  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6923                                                                                                                         Double_t radiusmax, 
6924                                                                                                                         Double_t width, 
6925                                                                                                                         Int_t ncables,
6926                                                                                                                         char* volname){
6927   /////////////////////////////////////////////////////////////
6928   // Generating EndCap High Voltage Tubes 
6929   /////////////////////////////////////////////////////////////
6930   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6931   Double_t effectiveouteradius = TMath::Sqrt(TMath::Power(effectiveinneradius,2.)
6932                                                            +             TMath::Power(radiusmax,2.)
6933                                -             TMath::Power(radiusmin,2.));
6934   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6935   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6936                                                                                                    effectiveouteradius,0.5*width);
6937   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6938                                                                                                 effectiveinnertubeshape,
6939                                                                                                 fSSDStiffenerConnectorMedium);
6940   effectiveinnertube->SetLineColor(41);
6941   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6942                                                                                                 effectiveoutertubeshape,
6943                                                                                                 fSSDKaptonChipCableMedium);
6944   effectiveoutertube->SetLineColor(39);
6945   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6946   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6947   effectivemothertube->AddNode(effectiveinnertube,1);
6948   effectivemothertube->AddNode(effectiveoutertube,1);
6949   return effectivemothertube;
6950  } 
6951  ////////////////////////////////////////////////////////////////////////////////
6952  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6953   /////////////////////////////////////////////////////////////
6954   // Generating EndCap Support Layer 5 and Layer 6 
6955   /////////////////////////////////////////////////////////////
6956   const Int_t knedges = 5;
6957   ///////////////////////////////////////////////
6958   // Setting the vertices for TGeoXtru Up Volume
6959   ///////////////////////////////////////////////
6960   const Int_t klayernumber = 2;
6961   Double_t xupvertex[klayernumber][knedges+3];
6962   Double_t yupvertex[klayernumber][knedges+3];
6963   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6964   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6965   Double_t middlepsi[klayernumber] = {0.0,0.0};
6966   for(Int_t i=0; i<klayernumber; i++){
6967         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6968         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6969         xupvertex[i][2] = -xupvertex[i][1];
6970         xupvertex[i][3] = -xupvertex[i][0];
6971
6972         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6973         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6974         yupvertex[i][2] =  yupvertex[i][1];
6975         yupvertex[i][3] =  yupvertex[i][0];
6976         
6977     middledgeangle[i] = upedgeangle[i]/knedges;
6978     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6979     for(Int_t j=1; j<knedges; j++){
6980                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6981                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6982         }
6983   }
6984   ////////////////////////////////////
6985   // Generating Up TGeoXtru
6986   ////////////////////////////////////
6987   TGeoXtru* upendcapsupportshape[klayernumber];
6988   TGeoVolume* upendcapsupport[klayernumber]; 
6989   char upendcapsupportname[30]; 
6990   for(Int_t i=0; i<klayernumber; i++){
6991    upendcapsupportshape[i] = new TGeoXtru(2);
6992    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
6993    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6994    upendcapsupportshape[i]->DefineSection(0,0.);
6995    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6996    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
6997                                                                         fSSDSupportRingAl);
6998    upendcapsupport[i]->SetLineColor(5);
6999   }
7000   ///////////////////////////////////////////////
7001   // Setting the vertices for TGeoXtru Down Volume
7002   ///////////////////////////////////////////////
7003   Double_t xdownvertex[klayernumber][2*(knedges+1)];
7004   Double_t ydownvertex[klayernumber][2*(knedges+1)];
7005   for(Int_t i=0; i<klayernumber; i++){
7006         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
7007         xdownvertex[i][1] =  xupvertex[i][0];
7008         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
7009         ydownvertex[i][1] =  yupvertex[i][0];
7010         for(Int_t j=0; j<knedges; j++){
7011                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
7012                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
7013         } 
7014         for(Int_t j=0; j<knedges; j++){
7015                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7016                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
7017                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7018                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7019         }
7020   }
7021   ////////////////////////////////////
7022   // Generating Down TGeoXtru
7023   ////////////////////////////////////  
7024   TGeoXtru* downendcapsupportshape[klayernumber];
7025   TGeoVolume* downendcapsupport[klayernumber]; 
7026   char downendcapsupportname[30]; 
7027   for(Int_t i=0; i<klayernumber; i++){
7028         downendcapsupportshape[i] = new TGeoXtru(2);
7029     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7030         downendcapsupportshape[i] = new TGeoXtru(2);
7031         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7032     if(i==0){
7033                 downendcapsupportshape[i]->DefineSection(0,0.);
7034                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7035     }
7036         else{
7037                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7038                                                                  -                 fgkEndCapSupportLowWidth[i]);
7039                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7040         }
7041     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7042                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7043         downendcapsupport[i]->SetLineColor(5);
7044   }
7045   ///////////////////////////////////////////////
7046   // Setting TGeoPgon Volume
7047   ///////////////////////////////////////////////
7048   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7049                                                                                                    fgkSSDLay6LadderNumber};
7050   TGeoPgon* endcapsupportmothershape[klayernumber];
7051   TGeoVolume** endcapsupportmother;
7052   endcapsupportmother = new TGeoVolume*[klayernumber];
7053   char endcapsupportmothername[30];
7054   for(Int_t i=0; i<klayernumber; i++){
7055         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7056     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7057         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7058     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7059                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7060     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7061                                                                                         fSSDAir);       
7062   }
7063   ////////////////////////////////////
7064   TGeoRotation** endcapsupportrot[klayernumber];
7065   for(Int_t i=0; i<2; i++){
7066         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7067         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7068            endcapsupportrot[i][j] = new TGeoRotation();
7069            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7070        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7071        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7072         }
7073   }
7074   return endcapsupportmother;
7075  } 
7076  ////////////////////////////////////////////////////////////////////////////////
7077  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7078   /////////////////////////////////////////////////////////////
7079   // Setting End Cap Support Layer 5 and 6. 
7080   /////////////////////////////////////////////////////////////
7081   const Int_t kendcapcoverplatesmallholenumber = 9;
7082   const Int_t klayernumber = 2;
7083   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7084                                                                                                    fgkSSDLay6LadderNumber};
7085   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7086                                                                                 360.0/kssdlayladdernumber[1]};
7087   TGeoVolume** endcapsupport = EndCapSupport();
7088   TGeoVolume** endcapassembly = GetEndCapAssembly();
7089   TGeoPgon* endcapsupportshape[klayernumber];
7090   Double_t* radiusmin[klayernumber];
7091   Double_t* radiusmax[klayernumber];
7092   for(Int_t i=0; i<klayernumber; i++){
7093     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7094         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7095         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7096   }  
7097   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7098   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7099                                                                           endcapassemblyshape->GetDY(),
7100                                                                           endcapassemblyshape->GetDZ()};
7101   ///////////////////////////////////////////////
7102   // Setting TGeoPgon Volume for Mother Container
7103   ///////////////////////////////////////////////
7104   TGeoPgon* endcapsupportsystemshape[klayernumber];
7105   char endcapsupportsystemothername[30];
7106   for(Int_t i=0; i<klayernumber; i++){
7107         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7108     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7109         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7110                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7111                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7112                                                                                            +2.*endcapassemblycenter[2])
7113                                                                                            /CosD(0.5*upedgeangle[i]));  
7114     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7115                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7116                                                                                              - fgkEndCapCoverPlateWidth[0]),
7117                                                                                            *radiusmin[i],
7118                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7119                                                                                            +2.*endcapassemblycenter[2])
7120                                                                                            /CosD(0.5*upedgeangle[i]));
7121   }
7122   fgkEndCapSupportSystem = new TGeoVolume*[4];
7123   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7124                                                                           endcapsupportsystemshape[0],fSSDAir); 
7125   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7126                                                                           endcapsupportsystemshape[0],fSSDAir); 
7127   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7128                                                                           endcapsupportsystemshape[1],fSSDAir); 
7129   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7130                                                                           endcapsupportsystemshape[1],fSSDAir); 
7131   ///////////////////////////////////////////////
7132   TGeoTranslation* endcapassemblytrans[klayernumber];
7133   for(Int_t i=0; i<klayernumber; i++)
7134         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7135                                                                            -  fgkEndCapSideCoverThickness
7136                                                                            +  endcapassemblycenter[0],
7137                                                                            -  0.5*fgkEndCapCoverPlateThickness
7138                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7139                                                                            +  2.0*endcapassemblycenter[2]
7140                                                                            +  0.5*fgkEndCapSupportLength[i]
7141                                                                            /  TanD(0.5*upedgeangle[i]),
7142                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7143                                                                            -  fgkEndCapCoverPlateWidth[2]
7144                                                                            - (kendcapcoverplatesmallholenumber-1)
7145                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7146   TGeoRotation** endcapassemblyrot[klayernumber];
7147   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7148   for(Int_t i=0; i<klayernumber; i++){
7149    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7150    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7151    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7152    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7153    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7154    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7155    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7156    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7157         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7158         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7159    }
7160   }
7161   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7162                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7163   for(Int_t i=0; i<2*klayernumber; i++){
7164         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7165                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7166                                                                                                                                            endcapassemblymatrix[1][j+2]);
7167         }
7168         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7169   }
7170    /////////////////////////////////////////////////////////////
7171   // Deallocating memory
7172   /////////////////////////////////////////////////////////////
7173   for(Int_t i=0; i<klayernumber; i++){
7174         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7175                 delete endcapassemblyrot[i][j];
7176         }
7177         delete endcapassemblyrot[i];
7178         delete endcapassemblymatrix[i][0];
7179         delete endcapassemblymatrix[i][1];
7180   }
7181   /////////////////////////////////////////////////////////////
7182   }
7183   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7184   /////////////////////////////////////////////////////////////
7185   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7186   /////////////////////////////////////////////////////////////
7187   if (! moth) {
7188     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer5, mother is null!\n");
7189     return;
7190   };
7191   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7192   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7193   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7194                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7195                                                                            +            fgkEndCapSupportCenterLay5Position
7196                                                                            -            fgkEndCapSideCoverLength[2]);
7197   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7198                                                                                                 fgkEndCapSideCoverLength[2]
7199                                                                            -        fgkEndCapSupportCenterLay5Position
7200                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7201   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7202   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7203   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7204         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7205   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7206   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7207    /////////////////////////////////////////////////////////////
7208   // Deallocating memory
7209   /////////////////////////////////////////////////////////////
7210   delete endcapsupportsystemrot;
7211   delete endcapsupportsystemITSCentertrans[1];
7212  }
7213   /////////////////////////////////////////////////////////////
7214   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7215   /////////////////////////////////////////////////////////////
7216   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7217   /////////////////////////////////////////////////////////////
7218   if (! moth) {
7219     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer6, mother is null!\n");
7220     return;
7221   };
7222   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7223   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7224   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7225                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7226                                                                            +            fgkEndCapSupportCenterLay6Position
7227                                                                            -            fgkEndCapSideCoverLength[2]);
7228   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7229                                                                                                 fgkEndCapSideCoverLength[2]
7230                                                                            -        fgkEndCapSupportCenterLay6Position
7231                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7232   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7233   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7234   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7235         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7236   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7237   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7238    /////////////////////////////////////////////////////////////
7239   // Deallocating memory
7240   /////////////////////////////////////////////////////////////
7241   delete endcapsupportsystemrot;
7242   delete endcapsupportsystemITSCentertrans[1];
7243  }
7244  ////////////////////////////////////////////////////////////////////////////////
7245  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7246   /////////////////////////////////////////////////////////////
7247   // Setting Ladder Support of Layer 5. 
7248   /////////////////////////////////////////////////////////////
7249   if (! moth) {
7250     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer5, mother is null!\n");
7251     return;
7252   };
7253   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7254   fMotherVol = moth;
7255   TGeoTranslation* centerITSRingSupportLay5trans[2];
7256   for(Int_t i=0; i<2; i++){
7257         centerITSRingSupportLay5trans[i] = 
7258                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7259     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7260   }
7261  }
7262  ////////////////////////////////////////////////////////////////////////////////
7263  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7264   /////////////////////////////////////////////////////////////
7265   // Setting Ladder Support of Layer 6. 
7266   /////////////////////////////////////////////////////////////
7267   if (! moth) {
7268     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer6, mother is null!\n");
7269     return;
7270   };
7271   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7272   fMotherVol = moth;
7273   TGeoTranslation* centerITSRingSupportLay6trans[2];
7274   for(Int_t i=0; i<2; i++){
7275         centerITSRingSupportLay6trans[i] = 
7276                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7277     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7278   }
7279  }
7280  ////////////////////////////////////////////////////////////////////////////////
7281  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7282   /////////////////////////////////////////////////////////////
7283   // Setting Ladder Support of Layer 6. 
7284   /////////////////////////////////////////////////////////////
7285   if (! moth) {
7286     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cone, mother is null!\n");
7287     return;
7288   };
7289   if(!fSSDCone) SetSSDCone();
7290   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7291                                                                 +                                         fgkSSDCentralAL3SupportLength);
7292     moth->AddNode(fSSDCone,1,ssdconetrans);
7293 }
7294  ////////////////////////////////////////////////////////////////////////////////
7295  void AliITSv11GeometrySSD::SetSSDCone(){
7296   /////////////////////////////////////////////////////////////
7297   // Method generating SSDCone 
7298   /////////////////////////////////////////////////////////////
7299   if(!fCreateMaterials) CreateMaterials();
7300   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7301   Double_t ssdpconesectionradiusmax[16];
7302   Double_t ssdpconesectionradiusmin[16];
7303   Double_t ssdpconezsection[16];
7304   TGeoPcon* ssdpconelittleholeshape[8];
7305   TGeoVolume* ssdpconelittlehole[8];
7306   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7307   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7308   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7309                                                       / SinD(fgkSSDPConeAngle)
7310                                                           + ssdpconesectionradiusmin[0];
7311   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7312                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7313                                                           / SinD(fgkSSDPConeAngle);
7314   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7315   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7316                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7317   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7318   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7319                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7320   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7321   ssdpconelittlehole[0]->SetLineColor(4);
7322   /////////////////////////////////////////////////////////////
7323   ssdpconezsection[2] = ssdpconezsection[1];  
7324   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7325   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7326   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7327                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7328                                                           / SinD(fgkSSDPConeAngle);
7329   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7330                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7331   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7332                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7333   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7334                                                                    * TMath::RadToDeg();
7335   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7336                                                                                                           60.-ssdpconelittleholeangle,2);    
7337   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7338                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7339   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7340   ssdpconelittlehole[1]->SetLineColor(4);
7341   TGeoRotation* ssdconelittleholerot[6];
7342   for(Int_t i=0; i<6; i++){
7343         ssdconelittleholerot[i] = new TGeoRotation();
7344     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7345   }
7346   /////////////////////////////////////////////////////////////
7347   ssdpconezsection[4] = ssdpconezsection[3];  
7348   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7349   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7350   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7351                                                           * CosD(fgkSSDPConeAngle)
7352                                                           / SinD(fgkSSDPConeAngle);
7353   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7354   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7355                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7356   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7357   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7358                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7359   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7360   ssdpconelittlehole[2]->SetLineColor(4);
7361   ///////////////////////////////////////////////////
7362   ssdpconezsection[6] = ssdpconezsection[5];  
7363   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7364   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7365   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7366                                                           -ssdpconezsection[0]
7367                                                           * CosD(fgkSSDPConeAngle)
7368                                                           / SinD(fgkSSDPConeAngle);
7369   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7370   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7371                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7372   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7373                                                                    * TMath::RadToDeg();
7374   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7375                                                                                                           45.-ssdpconemiddleholeangle,2);    
7376   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7377                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7378   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7379   ssdpconelittlehole[3]->SetLineColor(4);
7380   TGeoRotation* ssdconemiddleholerot[8];
7381   for(Int_t i=0; i<8; i++){
7382         ssdconemiddleholerot[i] = new TGeoRotation();
7383     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7384   }
7385   /////////////////////////////////////////////////////////////
7386   ssdpconezsection[8] = ssdpconezsection[7];  
7387   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7388   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7389   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7390                                                           * CosD(fgkSSDPConeAngle)
7391                                                           / SinD(fgkSSDPConeAngle);
7392   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7393   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7394                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7395   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7396   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7397                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7398   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7399   ssdpconelittlehole[4]->SetLineColor(4);
7400   /////////////////////////////////////////////////////////////
7401   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7402   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7403                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7404                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7405                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7406                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7407   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7408   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7409                                                                                  * TMath::RadToDeg();
7410   ssdpconezsection[10] = ssdpconezsection[9];
7411   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7412   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7413   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7414                                                           * CosD(fgkSSDPConeAngle)
7415                                                           / SinD(fgkSSDPConeAngle);
7416   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7417   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7418                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7419   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7420                                                                                         ssdpconetrapezoidsectionangle,2);    
7421   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7422                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7423   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7424   ssdpconelittlehole[5]->SetLineColor(4);
7425   TGeoRotation* ssdconeupradiusrot[8];
7426   for(Int_t i=0; i<8; i++){
7427         ssdconeupradiusrot[i] = new TGeoRotation();
7428     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7429   }
7430   /////////////////////////////////////////////////////////////
7431   ssdpconezsection[12] = ssdpconezsection[11];
7432   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7433   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7434   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7435   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7436   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7437   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7438   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7439                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7440   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7441   ssdpconelittlehole[6]->SetLineColor(4);
7442   /////////////////////////////////////////////////////////////
7443   ssdpconezsection[14] = 0.0;
7444   ssdpconezsection[15] = ssdpconezsection[0];
7445   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7446   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7447   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7448   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7449   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7450   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7451                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7452   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7453   ssdpconelittlehole[7]->SetLineColor(4);
7454   /////////////////////////////////////////////////////////////
7455   TGeoTube* ssdtubeconeshape[2];
7456   TGeoVolume* ssdtubecone[2];
7457   TGeoTranslation* ssdtubeconetrans[2];
7458   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7459                                                                            fgkSSDPConeExternalRadius,
7460                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7461   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7462                                                                            0.5*ssdpconezsection[0]); 
7463   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7464   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7465   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7466                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7467                                           + ssdpconezsection[13]);
7468   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7469   ssdtubecone[0]->SetLineColor(4);
7470   ssdtubecone[1]->SetLineColor(4);
7471   /////////////////////////////////////////////////////////////
7472   // Mother Volume Container
7473   /////////////////////////////////////////////////////////////
7474   Double_t ssdconemotherradiusmin[8];
7475   Double_t ssdconemotherradiusmax[8];
7476   Double_t ssdconemothersection[8]; 
7477   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7478   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7479   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7480   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7481   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7482   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7483   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7484   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7485   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7486   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7487   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7488   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7489   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7490   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7491   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7492   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7493   ssdconemothersection[0] = 0.0;
7494   ssdconemothersection[1] = ssdpconezsection[0];
7495   ssdconemothersection[2] = ssdpconezsection[0];
7496   ssdconemothersection[3] = ssdpconezsection[11];
7497   ssdconemothersection[4] = ssdpconezsection[11];
7498   ssdconemothersection[5] = ssdpconezsection[13];
7499   ssdconemothersection[6] = ssdpconezsection[13];
7500   ssdconemothersection[7] = fgkSSDPConeLength;
7501   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7502   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7503                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7504   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7505   /////////////////////////////////////////////////////////////
7506   //Placing the Volumes into Mother 
7507   /////////////////////////////////////////////////////////////
7508   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7509   for(Int_t i=0; i<6; i++){
7510         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7511   }
7512   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7513   for(Int_t i=0; i<8; i++){
7514     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7515   }
7516   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7517   for(Int_t i=0; i<8; i++){
7518     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7519   }
7520   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7521   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7522   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7523   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7524   /////////////////////////////////////////////////////////////
7525   // ITS General Support
7526   /////////////////////////////////////////////////////////////
7527   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7528                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7529   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7530   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7531                                                                              - fgkSSDCentralAL3SupportLength);
7532   ssdcentralsupport->SetLineColor(4);
7533   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7534   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7535                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7536   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7537   TGeoTranslation* ssdcentralal3supportrans[3]; 
7538   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7539   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7540                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7541   ssdcentralal3support->SetLineColor(4);
7542   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7543   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7544   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7545   Double_t ssdpconcentralradiusmin[2];
7546   Double_t ssdpconcentralradiusmax[2];
7547   Double_t ssdpconcentralsection[2];
7548   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7549   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7550   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7551   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7552   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7553   ssdpconcentralsection[1] = 0.;
7554   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7555                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7556   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7557   ssdpconcentralal3->SetLineColor(4);
7558   fSSDCone->AddNode(ssdpconcentralal3,1);
7559   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7560   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7561   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7562                                                                 -2.*fgkSSDCentralAL3SupportLength);
7563   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7564                                                                                                                      *ssdcentralal3supportrot);
7565   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7566   TGeoRotation* ssdconemotherot = new TGeoRotation();
7567   ssdconemotherot->SetAngles(90.,180.,-90.);
7568   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7569                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7570   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7571   fSSDCone->AddNode(ssdconemother,1);
7572   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7573   /////////////////////////////////////////////////////////////
7574   // Deallocating memory
7575   /////////////////////////////////////////////////////////////
7576   delete ssdcentralal3supportrot;
7577   delete ssdcentralal3supportrans[2];
7578   delete ssdconemotherot;
7579   delete ssdconemothertrans;
7580   /////////////////////////////////////////////////////////////
7581  }
7582  ////////////////////////////////////////////////////////////////////////////////
7583  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7584   /////////////////////////////////////////////////////////////
7585   // Setting SSD Cables
7586   /////////////////////////////////////////////////////////////
7587   if (! moth) {
7588     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cables, mother is null!\n");
7589     return;
7590   };
7591   TGeoVolume* ssdcables = SetSSDCables();
7592   moth->AddNode(ssdcables,1);
7593 }
7594  ////////////////////////////////////////////////////////////////////////////////
7595  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7596   /////////////////////////////////////////////////////////////
7597   // Method generating SSDCables
7598   /////////////////////////////////////////////////////////////
7599   // SSD Layer 5 Cables
7600   //////////////////////////////////////////////////////////////////////////////////////////////////
7601   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7602   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7603   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7604   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7605   //////////////////////////////////////////////////////////////////////////////////////////////////
7606   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7607   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7608                                                                             -  fgkSSDLowerPConeRadius)
7609                                                                             * TanD(fgkSSDPConeAngle);
7610   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7611                                                                               + fgkEndCapSupportCenterLay5Position
7612                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7613   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7614                                                                            - ssdcableslay5startconedistance; 
7615   ssdcablelay5rightsidelength *= ssdcablesfactor;
7616   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7617   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7618                                                                                                 ssdcableslay5rightsideradiusmax,
7619                                                                                                 0.5*ssdcablelay5rightsidelength); 
7620   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7621                                                                                                          ssdcablelay5rightubeshape,
7622                                                                                                          fSSDCopper);
7623   ssdcablelay5righttube->SetLineColor(9);
7624   TGeoTranslation* ssdcablelay5rightrans = 
7625                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7626                                                                                  +              fgkEndCapSupportCenterLay5Position
7627                                                                                  +      0.5*ssdcablelay5rightsidelength);
7628   ////////////////////////////////////
7629   //  Double_t cablescapacity[20];
7630   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7631   ////////////////////////////////////
7632   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7633   ////////////////////////////////////
7634   // TGeoPCone Volumes
7635   ///////////////////////////////////
7636   TGeoPcon* ssdcableslay5pconshape[3];
7637   TGeoVolume* ssdcableslay5pcon[3]; 
7638   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7639   Double_t ssdcableslay5pconzsection[6];
7640   Double_t ssdcableslay5pconrmin[6];
7641   Double_t ssdcableslay5pconrmax[6];
7642   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7643   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7644   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7645   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7646   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7647                                                            + fgkEndCapSupportCenterLay5Position
7648                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7649   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7650                                                            + fgkSSDCentralAL3SupportLength
7651                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7652                                                            * TanD(fgkSSDPConeAngle);      
7653   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7654                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7655   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7656                                                            ssdcableslay5pconshape[0],fSSDCopper);
7657   ssdcableslay5pcon[0]->SetLineColor(9);
7658   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7659 ////////////////////////////////////
7660 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7661 ////////////////////////////////////
7662   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7663   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7664                                                            + fgkSSDCentralAL3SupportLength
7665                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7666                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7667   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7668                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7669                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7670   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7671                                                                                    ssdcableangle,2);   
7672   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7673   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7674   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7675                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7676   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7677   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7678   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7679                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7680   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7681   ssdcableslay5pcon[1]->SetLineColor(9);
7682   ////////////////////////////////////
7683   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7684                                                                                    ssdcableangle,2);   
7685   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7686   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7687   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7688   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7689   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7690   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7691                                                            * TanD(fgkSSDPConeAngle)
7692                                                            + 0.5*fgkSSDCentralSupportLength
7693                                                            + fgkSSDCentralAL3SupportLength;
7694   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7695   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7696                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7697   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7698   ssdcableslay5pcon[2]->SetLineColor(9);
7699 ////////////////////////////////////
7700   TGeoRotation* ssdcableslay5pconrot[4];        
7701   for(Int_t i=0; i<4; i++){
7702    ssdcableslay5pconrot[i] = new TGeoRotation();
7703    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7704    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7705    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7706   }
7707   ////////////////////////////////////
7708   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7709   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7710   ////////////////////////////////////
7711   // Positioning Left SSD Cables Part
7712   ////////////////////////////////////
7713   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7714                                                                                                         - 0.5*ssdcablelay5rightsidelength
7715                                                                                                         - fgkEndCapSupportCenterLay5Position
7716                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7717   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7718   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7719   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7720   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7721   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7722   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7723         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7724         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7725     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7726   }
7727   ////////////////////////////////////
7728   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7729   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7730   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7731   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7732   /////////////////////////////////////////////////////////////
7733   // Water Tubes Layer 5
7734   /////////////////////////
7735   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7736                                                                                      ssdcableslay5rightsideradiusmax
7737                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7738                                                                                      0.5*ssdcablelay5rightsidelength); 
7739   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7740                                                                                                          ssdcablelay5rightubewatershape,
7741                                                                                                          fSSDCoolingTubeWater);
7742   ssdcablelay5rightwatertube->SetLineColor(7);
7743   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7744   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7745   ////////////////////////////////////
7746   // TGeoPCone Water Volumes Layer 
7747   ///////////////////////////////////
7748   TGeoPcon* ssdcableslay5pconwatershape[3];
7749   TGeoVolume* ssdcableslay5pconwater[3]; 
7750   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7751   Double_t ssdcableslay5pconwaterzsection[6];
7752   Double_t ssdcableslay5pcwateronrmin[6];
7753   Double_t ssdcableslay5pconwaterrmax[6];
7754   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7755   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7756                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7757   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7758   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7759                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7760   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7761   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7762   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7763                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7764   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7765                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7766   ssdcableslay5pconwater[0]->SetLineColor(7);
7767   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7768   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7769 ////////////////////////////////////
7770   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7771   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7772   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7773                                                                                                 ssdcableangle,2);   
7774   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7775   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7776                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7777   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7778   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7779                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7780   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7781                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7782   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7783                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7784   ssdcableslay5pconwater[1]->SetLineColor(7);
7785 ////////////////////////////////////
7786   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7787                                                                                                 ssdcableangle,2);   
7788   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7789   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7790                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7791   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7792   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7793                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7794   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7795   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7796   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7797                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7798   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7799                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7800   ssdcableslay5pconwater[2]->SetLineColor(7);
7801 ////////////////////////////////////
7802   TGeoRotation* ssdcableslay5pconwaterot[4];    
7803   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7804   for(Int_t i=0; i<4; i++){
7805    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7806    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7807    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7808         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7809         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7810         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7811         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7812         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7813   }
7814   /////////////////////////
7815   // SSD Layer 6 Cables
7816   /////////////////////////
7817   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7818   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7819   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7820   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7821                                                                                                 ssdcableslay6rightsideradiusmax,
7822                                                                                                 0.5*ssdcablelay6rightsidelength); 
7823   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7824                                                                                                          ssdcablelay6rightubeshape,
7825                                                                                                          fSSDCopper);
7826   ssdcablelay6righttube->SetLineColor(9);
7827   TGeoTranslation* ssdcablelay6rightrans = 
7828                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7829                                                                                  +              fgkEndCapSupportCenterLay6Position
7830                                                                                  +      0.5*ssdcablelay6rightsidelength);
7831   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7832                                                                                                         - 0.5*ssdcablelay6rightsidelength
7833                                                                                                         - fgkEndCapSupportCenterLay6Position
7834                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7835   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7836   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7837   ////////////////////////////////////
7838   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7839   ////////////////////////////////////
7840   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7841                                                                                    ssdcableangle,2);   
7842   TGeoVolume* ssdcableslay6pcon;
7843   Double_t ssdcableslay6pconrmin[2];
7844   Double_t ssdcableslay6pconrmax[2];
7845   Double_t ssdcableslay6pconzsection[2];
7846   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7847   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7848   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7849   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7850   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7851                                                            + fgkEndCapSupportCenterLay6Position
7852                                                            + ssdcablelay6rightsidelength;
7853   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7854   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7855                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7856   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7857                                                            ssdcableslay6pconshape,fSSDCopper);
7858   ssdcableslay6pcon->SetLineColor(9);
7859   for(Int_t i=0; i<4; i++){
7860    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7861    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7862   }
7863   ////////////////////////////////////
7864   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7865   /////////////////////////
7866   // Water Tubes Layer 6
7867   /////////////////////////
7868   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7869                                                                                                                   ssdcableslay6rightsideradiusmax
7870                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7871                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7872   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7873                                                                                                          ssdcablelay6righwatertubeshape,
7874                                                                                                          fSSDCoolingTubeWater);
7875   ssdcablelay6rightwatertube->SetLineColor(7);
7876   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7877   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7878   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7879                                                                                    ssdcableangle,2);   
7880   TGeoVolume* ssdcableslay6waterpcon;
7881   Double_t ssdcableslay6waterpconrmin[2];
7882   Double_t ssdcableslay6waterpconrmax[2];
7883   Double_t ssdcableslay6waterpconzsection[2];
7884   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7885   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7886                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7887   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7888   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7889   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7890                                                            + fgkEndCapSupportCenterLay6Position
7891                                                            + ssdcablelay6rightsidelength;
7892   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7893   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7894                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7895   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7896                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7897   ssdcableslay6waterpcon->SetLineColor(7);
7898   TGeoRotation* ssdcableslay6pconwaterot[4];    
7899   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7900   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7901   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7902   for(Int_t i=0; i<4; i++){
7903    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7904    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7905    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7906                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7907    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7908    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7909   }
7910   ////////////////////////////////////////
7911   // From ITS Ring to Patch Panel3-RB26
7912   ////////////////////////////////////////
7913   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7914   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7915   Double_t ssdcablepatchpanel3RB26zsection[2];
7916   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
7917   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7918                                                                           + fgkSSDCablesLay5RightSideHeight
7919                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7920   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7921   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7922                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7923                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7924   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7925                                                                                  + fgkSSDCentralAL3SupportLength
7926                                                                                  + fgkSSDPConeZLength[0];
7927   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7928   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7929                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7930                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7931   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7932                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7933   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7934                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7935   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7936   TGeoRotation* ssdcablepatchpanel3B26rot[3];
7937   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7938   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7939   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7940                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
7941   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7942   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7943                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
7944   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7945   ////////////////////////////////////
7946   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7947   ////////////////////////////////////////
7948   //  ITS Ring Cables RB26 Part
7949   ////////////////////////////////////////
7950   Double_t ssdcableitsring3BB26pconzsection[2];
7951   Double_t ssdcableitsring3BB26pconrmin[2];
7952   Double_t ssdcableitsring3BB26pconrmax[2];
7953   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7954                                                                           + fgkSSDCentralAL3SupportLength
7955                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7956   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7957   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
7958   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7959                                                                   + fgkSSDCablesLay5RightSideHeight
7960                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7961   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7962   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7963   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7964   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7965                                                                    -              0.5*ssdcableangle,ssdcableangle
7966                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7967                                                                    -                             fgkSSDCableAngle),2);
7968   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7969                                                                    -              0.5*ssdcableangle,ssdcableangle
7970                                                                    +                      3.0*fgkSSDCableAngle
7971                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7972   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7973                                                                    -              0.5*ssdcableangle,ssdcableangle
7974                                                                    -                      fgkSSDCableAngle
7975                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7976   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7977                                                                    -              0.5*ssdcableangle,ssdcableangle
7978                                                                    +                      3.0*fgkSSDCableAngle
7979                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7980   for(Int_t i=0;i<4;i++)
7981         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7982                                                          ssdcableitsring3BB26pconrmin[j],
7983                                                          ssdcableitsring3BB26pconrmax[j]); 
7984   TGeoVolume* ssdcableitsring3BB26pcon[4];
7985   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7986                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7987   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7988                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7989   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7990                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7991   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7992                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7993   for(Int_t i=0;i<4;i++){
7994         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7995         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
7996 }
7997   ////////////////////////////////////
7998   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
7999   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
8000   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
8001   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
8002   ////////////////////////////////////////
8003   // From ITS Ring to Patch Panel2-RB24
8004   ////////////////////////////////////////
8005   Double_t ssdcablepatchpanel3BB24radiusmin[2];
8006   Double_t ssdcablepatchpanel3BB24radiusmax[2];
8007   Double_t ssdcablepatchpanel3RB24zsection[2];
8008   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
8009   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
8010   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
8011   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
8012                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8013                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
8014                                                                           + 0.5*fgkSSDPatchPanelHeigth;
8015   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
8016                                                                          -  fgkSSDCentralAL3SupportLength
8017                                                                          -  fgkSSDPConeZLength[0];
8018   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8019   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8020                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8021                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8022   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8023                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8024   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8025                                                                                                 ssdcablepatchpanel3RB24pconshape,
8026                                                                                                 fSSDCopper);
8027   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8028   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8029   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8030   ssdcablepatchpanel3B24rot[0]->SetAngles(0.0,0.0,0.0);
8031   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8032                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8033   ssdcablepatchpanel3B24rot[2]->SetAngles(180.0,0.0,0.0);
8034   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8035                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8036   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8037   ////////////////////////////////////
8038   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8039   ////////////////////////////////////////
8040   //  ITS Ring Cables RB24 Part
8041   ////////////////////////////////////////
8042   Double_t ssdcableitsring3BB24pconzsection[2];
8043   Double_t ssdcableitsring3BB24pconrmin[2];
8044   Double_t ssdcableitsring3BB24pconrmax[2];
8045   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8046   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8047   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8048   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8049                                                                   + fgkSSDCablesLay5RightSideHeight
8050                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8051   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8052   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8053   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8054   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8055                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8056                                                                    -                             fgkSSDCableAngle),2);
8057   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8058                                                                      ssdcableangle-fgkSSDCableAngle
8059                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8060   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8061                                                                    -                      fgkSSDCableAngle
8062                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8063   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8064                                                                                                   ssdcableangle-fgkSSDCableAngle
8065                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8066   for(Int_t i=0;i<4;i++)
8067         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8068                                                          ssdcableitsring3BB24pconrmin[j],
8069                                                          ssdcableitsring3BB24pconrmax[j]); 
8070   TGeoVolume* ssdcableitsring3BB24pcon[4];
8071   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8072                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8073   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8074                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8075   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8076                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8077   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8078                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8079   for(Int_t i=0;i<4;i++){
8080         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8081         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8082 }
8083   ////////////////////////////////////
8084   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8085   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8086   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8087   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8088   ////////////////////////////////////
8089   // Volumes for Material Budget 
8090   ////////////////////////////////////
8091   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8092                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8093                                                                                                          ssdcableslay6rightsideradiusmax
8094                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8095                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8096   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8097                                                                                                          ssdcablelay6materialbudgetubeshape,
8098                                                                                                          fSSDCopper);
8099   ssdcablelay6materialbudgetube->SetLineColor(9);
8100   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8101   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8102
8103   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8104                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8105   TGeoVolume* ssdcablelay6materialbudgetpcon;
8106   Double_t ssdcablelay6materialbudgetpconrmin[2];
8107   Double_t ssdcablelay6materialbudgetpconrmax[2];
8108   Double_t ssdcablelay6materialbudgetpconzsection[2];
8109   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8110                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8111   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8112                                                                                 + fgkSSDCableMaterialBudgetHeight;
8113   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8114   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8115   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8116                                                                                         + fgkEndCapSupportCenterLay6Position
8117                                                                                         + ssdcablelay6rightsidelength;
8118   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8119   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8120                                                   ssdcablelay6materialbudgetpconzsection[i],
8121                                                   ssdcablelay6materialbudgetpconrmin[i],
8122                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8123   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8124                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8125   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8126   for(Int_t i=0; i<4; i++){
8127    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8128    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8129   }
8130 ////////////////////////////////////
8131  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8132   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8133   Double_t ssdcablesvolume = 0.0;
8134   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8135   std::cout << ssdcablesvolume << std::endl;*/
8136   return ssdcablesmother;
8137  }
8138  ////////////////////////////////////////////////////////////////////////////////
8139 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8140                                                                         Double_t height, char* shapename, Int_t isign) const{
8141   /////////////////////////////////////////////////////////////
8142   // Method generating an Arb shape 
8143   /////////////////////////////////////////////////////////////
8144   const Int_t kvertexnumber = 8;
8145   const Int_t ktransvectnumber = 2;
8146   TVector3* vertex[kvertexnumber];
8147   TVector3* transvector[2];
8148   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i] = new TVector3(0.,width[i]);
8149   /////////////////////////////////////////////////////////////
8150   //Setting the vertices for TGeoArb8
8151   /////////////////////////////////////////////////////////////
8152   vertex[0] = new TVector3(*vertexpos[0]);
8153   vertex[1] = new TVector3(*vertexpos[1]);
8154   vertex[2] = new TVector3(*vertex[1]+isign*(*transvector[0]));
8155   vertex[3] = new TVector3(*vertex[0]+isign*(*transvector[0]));
8156   vertex[4] = new TVector3(*vertexpos[2]);
8157   vertex[5] = new TVector3(*vertexpos[3]);
8158   vertex[6] = new TVector3(*vertex[5]+isign*(*transvector[1]));
8159   vertex[7] = new TVector3(*vertex[4]+isign*(*transvector[1]));
8160   /////////////////////////////////////////////////////////////
8161   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8162   for(Int_t i = 0; i<kvertexnumber;i++) 
8163                                                         arbshape->SetVertex(i,vertex[i]->X(),vertex[i]->Y());
8164   /////////////////////////////////////////////////////////////
8165   // Deallocating memory
8166   /////////////////////////////////////////////////////////////
8167   for(Int_t i=0; i< kvertexnumber; i++) delete vertex[i];  
8168   for(Int_t i=0; i< ktransvectnumber; i++) delete transvector[i];  
8169   /////////////////////////////////////////////////////////////
8170   return arbshape;
8171
8172 ///////////////////////////////////////////////////////////////////////////////
8173 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8174                                                                 Double_t rmax, Int_t nedges, Double_t height){
8175   /////////////////////////////////////////////////////////////
8176   // Method generating Arc shape 
8177   /////////////////////////////////////////////////////////////
8178         const Int_t kvertexnumber = 2*nedges+2;
8179         TGeoXtru* arcshape = new TGeoXtru(2);   
8180         TVector3** vertexposition[2];
8181         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8182         Double_t angle = 0.;
8183     for(Int_t i=0; i<nedges+1; i++){ 
8184                 angle = 90.+0.5*phi-i*(phi/nedges);
8185                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8186                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8187         }
8188         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8189         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8190         for(Int_t i=0; i<kvertexnumber; i++){ 
8191                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8192                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8193                 }
8194                 else if(i>=1&&i<nedges+2)
8195                 {
8196                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8197                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8198                 }
8199         else
8200                 {
8201                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8202                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8203                 }
8204     }
8205   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8206   arcshape->DefineSection(0,-0.5*height);
8207   arcshape->DefineSection(1,0.5*height);
8208   /////////////////////////////////////////////////////////////
8209   // Deallocating memory
8210   /////////////////////////////////////////////////////////////
8211   for(Int_t i=0; i<2; i++){
8212         for(Int_t j=0; j<nedges+1; j++)
8213                 delete vertexposition[i][j];
8214         delete [] vertexposition[i];
8215   }
8216   delete [] xvertexpoints;
8217   delete [] yvertexpoints;
8218   /////////////////////////////////////////////////////////////
8219         return arcshape;
8220 }
8221 ////////////////////////////////////////////////////////////////////////////////
8222 TGeoXtru* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8223   ///////////////////////////////////////////////////////////////////////
8224   // Method Generating the Screw Shape  
8225   // radius[0]: outer radius
8226   // radius[1]: inner radius
8227   // edgesnumber[0]: outer number of edges
8228   // edgesnumber[1]: inner number of edges
8229   // section[0]: lower section position
8230   // section[1]: higher section position
8231   ///////////////////////////////////////////////////////////////////////
8232   Double_t outradius = radius[0];
8233   Double_t inradius = radius[1];
8234   Int_t outvertexnumber = edgesnumber[0];
8235   Int_t invertexnumber = edgesnumber[1];
8236   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber+2];
8237   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber+2];
8238   for(Int_t i=0; i<outvertexnumber+1; i++){
8239         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8240         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8241   }
8242   for(Int_t i=0; i<invertexnumber+1; i++){
8243         xscrewvertex[outvertexnumber+i+1] = inradius*CosD(90.-i*360./invertexnumber);
8244         yscrewvertex[outvertexnumber+i+1] = inradius*SinD(90.-i*360./invertexnumber);
8245   }
8246   TGeoXtru* screwshape = new TGeoXtru(2);
8247   screwshape->DefinePolygon(outvertexnumber+invertexnumber+2,xscrewvertex,yscrewvertex);
8248   screwshape->DefineSection(0,section[0]);
8249   screwshape->DefineSection(1,section[1]);
8250   delete [] xscrewvertex;
8251   delete [] yscrewvertex;
8252   return screwshape;
8253 }
8254 ////////////////////////////////////////////////////////////////////////////////
8255 TGeoXtru* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8256   ///////////////////////////////////////////////////////////////////////
8257   // Method Generating the Hole Shape  
8258   // radius of the Hole
8259   // nedges: number of edges to approximate the circle
8260   ///////////////////////////////////////////////////////////////////////
8261   Int_t vertexnumber = nedges+6;
8262   Double_t* xholevertex = new Double_t[vertexnumber];
8263   Double_t* yholevertex = new Double_t[vertexnumber];
8264   xholevertex[0] = radius;
8265   xholevertex[1] = xholevertex[0];
8266   xholevertex[2] = -xholevertex[1];
8267   xholevertex[3] = xholevertex[2];
8268   xholevertex[4] = xholevertex[0];
8269   yholevertex[0] = 0.;
8270   yholevertex[1] = -radius;
8271   yholevertex[2] = yholevertex[1];
8272   yholevertex[3] = -yholevertex[1];
8273   yholevertex[4] = yholevertex[3];
8274   for(Int_t i=0; i<nedges+1; i++){
8275         xholevertex[i+5] = radius*CosD(i*360./nedges);
8276         yholevertex[i+5] = radius*SinD(i*360./nedges);
8277   }
8278   TGeoXtru* holeshape = new TGeoXtru(2);
8279   holeshape->DefinePolygon(vertexnumber,xholevertex,yholevertex);
8280   holeshape->DefineSection(0,section[0]);
8281   holeshape->DefineSection(1,section[1]);
8282   delete [] xholevertex;
8283   delete [] yholevertex;
8284   return holeshape;
8285 }
8286 ////////////////////////////////////////////////////////////////////////////////
8287 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8288   /////////////////////////////////////////////////////////////
8289   // Given an axis specified by param, it gives the reflection of the point
8290   // respect to the axis
8291   /////////////////////////////////////////////////////////////
8292   TVector3* n = new TVector3(param[0],param[1],param[2]);
8293   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8294   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8295   /////////////////////////////////////////////////////////////
8296   // Deallocating memory
8297   /////////////////////////////////////////////////////////////
8298   delete n;
8299   /////////////////////////////////////////////////////////////
8300   return reflectedvector;
8301 }
8302 ////////////////////////////////////////////////////////////////////////////////
8303 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8304                                                        Double_t dx,
8305                                                        Double_t dy,
8306                                                        Double_t dz) const{
8307   /////////////////////////////////////////////////////////////
8308   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8309   /////////////////////////////////////////////////////////////
8310   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8311   const Double_t *vect = hmatrix->GetTranslation();
8312   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8313   hmatrix->SetTranslation(newvect);
8314   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8315   delete hmatrix;
8316   return matrix;
8317 }
8318 ////////////////////////////////////////////////////////////////////////////////
8319 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8320   /////////////////////////////////////////////////////////////
8321   // Method returning the Medium type 
8322   /////////////////////////////////////////////////////////////
8323   char ch[30];
8324   sprintf(ch, "ITS_%s",mediumName);
8325   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8326   if (! medium)
8327     printf("Error(AliITSv11GeometrySSD)::medium %s not found !\n", mediumName);
8328   return medium;
8329 }
8330 ////////////////////////////////////////////////////////////////////////////////
8331 void AliITSv11GeometrySSD::CreateMaterials(){
8332 ///////////////////////////////////
8333 // This part has to be modified
8334 ///////////////////////////////////
8335   ///////////////////////////////////
8336   // Silicon for Sensor
8337   /////////////////////////////////// 
8338   fSSDSensorMedium = GetMedium("SI$");
8339   ///////////////////////////////////
8340   // Silicon Mixture for Sensor
8341   /////////////////////////////////// 
8342   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8343   fSSDChipGlueMedium = GetMedium("EPOXY$");
8344   ///////////////////////////////////
8345   // Stiffener Components Materials
8346   /////////////////////////////////// 
8347   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8348   ///////////////////////////  
8349   // Stiffener Connectors 
8350   ///////////////////////////  
8351   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8352   ////////////////////////////////  
8353   // Stiffener 0603-1812 Capacitor
8354   ////////////////////////////////  
8355   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8356   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8357   ///////////////////////////  
8358   // Stiffener Hybrid Wire 
8359   ///////////////////////////  
8360   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8361   ///////////////////////////  
8362   // Al for Cooling Block
8363   ///////////////////////////  
8364   fSSDAlCoolBlockMedium = GetMedium("AL$");
8365   //////////////////////////////////////////////////////  
8366   // Kapton and Al for Chip Cable Flex and Ladder Cables
8367   //////////////////////////////////////////////////////  
8368   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8369   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8370   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8371   fSSDAlTraceFlexMedium = GetMedium("AL$");
8372   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8373   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8374   /////////////////////////////////////////////////////////////////  
8375   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8376   //////////////////////////////////////////////////////////////////  
8377   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8378   /////////////////////////////////////////////////////////////////  
8379   // G10 for Detector Leg, TubeHolder
8380   //////////////////////////////////////////////////////////////////  
8381   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8382   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8383   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8384   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8385   /////////////////////////////////////////////////////////////////  
8386   // Water and Phynox for Cooling Tube
8387   //////////////////////////////////////////////////////////////////  
8388   fSSDCoolingTubeWater = GetMedium("WATER$");
8389   fSSDCoolingTubePhynox = GetMedium("INOX$");
8390   /////////////////////////////////////////////////////////////////////
8391   // Material for Support Rings
8392   /////////////////////////////////////////////////////////////////////
8393   fSSDSupportRingAl = GetMedium("AL$");
8394   fSSDRohaCellCone = GetMedium("ROHACELL$");
8395   /////////////////////////////////////////////////////////////////////
8396   fSSDAir = GetMedium("SDD AIR$");
8397   fSSDCopper = GetMedium("COPPER$");
8398   fCreateMaterials = kTRUE;
8399 }
8400 /////////////////////////////////////////////////////////////////////