]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
added skeleton for HLTpendolino library
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoBoolNode.h"
33 #include "TGeoTube.h"
34 #include "TGeoBBox.h"
35 #include "TGeoXtru.h"
36 #include "TGeoTorus.h"
37 #include "TGeoPgon.h"
38 #include "TGeoPcon.h"
39 #include "TRotation.h"
40 #include "AliITSv11GeometrySSD.h"
41 /////////////////////////////////////////////////////////////////////////////////
42 // Names of the Sensitive Volumes of Layer 5 and Layer 6
43 /////////////////////////////////////////////////////////////////////////////////
44 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
45 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
46 /////////////////////////////////////////////////////////////////////////////////
47 //Parameters for SSD Geometry
48 /////////////////////////////////////////////////////////////////////////////////
49 // Variable for Vertical Disalignement of Modules
50 /////////////////////////////////////////////////////////////////////////////////
51 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
52 //const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 1.*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.*fgkmm;
54 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment2 = 0.2*fgkmm;
55 /////////////////////////////////////////////////////////////////////////////////
56 // Layer5 (lengths are in mm and angles in degrees)
57 /////////////////////////////////////////////////////////////////////////////////
58 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
59 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
60 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
61 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
62 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
63 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
64 /////////////////////////////////////////////////////////////////////////////////
65 // Layer6 (lengths are in mm and angles in degrees)
66 /////////////////////////////////////////////////////////////////////////////////
67 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
68 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
69 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
70 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
71 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
72 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
73 /////////////////////////////////////////////////////////////////////////////////
74 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
75 /////////////////////////////////////////////////////////////////////////////////
76 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
77 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
78 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
83 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
84 /////////////////////////////////////////////////////////////////////////////////
85 // Stiffener (lengths are in mm and angles in degrees)
86 /////////////////////////////////////////////////////////////////////////////////
87 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
88 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
89 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
92 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
97 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
98 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
100 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
101                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
102 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
105 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
106                                                                                                           0.25*fgkSSDStiffenerHeight;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
108 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
109 /////////////////////////////////////////////////////////////////////////////////
110 // Cooling Block (lengths are in mm and angles in degrees)
111 /////////////////////////////////////////////////////////////////////////////////
112 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
113 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
114 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
115                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
116 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
117                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
118 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
119                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
120 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
121                                                                                                                                          1.500*fgkmm;
122 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
123                                                                                                                                          0.300*fgkmm;
124 /////////////////////////////////////////////////////////////////////////////////
125 // SSD Sensor (lengths are in mm and angles in degrees)
126 /////////////////////////////////////////////////////////////////////////////////
127 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
128                                                                                                                  "SSDSensorSensitiveVol";
129 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
130 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
132 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
133                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
135 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
136 /////////////////////////////////////////////////////////////////////////////////
137 // Flex (lengths are in mm and angles in degrees)
138 /////////////////////////////////////////////////////////////////////////////////
139 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
140 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
141                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
142                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
143                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
144                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
145                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
146 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
147                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
148 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
149                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
151 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
152 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
153 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
154                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
155 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
156                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
157 /////////////////////////////////////////////////////////////////////////////////
158 // SSD Ladder Cable (lengths are in mm and angles in degrees)
159 /////////////////////////////////////////////////////////////////////////////////
160 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
161 /////////////////////////////////////////////////////////////////////////////////
162 // SSD Module (lengths are in mm and angles in degrees)
163 /////////////////////////////////////////////////////////////////////////////////
164 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
165                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
166 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
167                                                                                                                                         45.600*fgkmm;
168 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
169                                                                                                                                          5.075*fgkmm;
170 /////////////////////////////////////////////////////////////////////////////////
171 // Sensor Support (lengths are in mm and angles in degrees)
172 /////////////////////////////////////////////////////////////////////////////////
173 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
174                                                                                                                                          5.800*fgkmm;
175 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
176                                                                                                                                          2.000*fgkmm;
177 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
178                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment2, 
179                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment2};
180 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
181 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
182 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
183                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
184 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
185                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
186                                                             +  fgkSSDSensorSideSupportThickness[0])
187                                                                 -  fgkSSDSensorSideSupportLength;
188 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
189                                                                                                                                     5.250*fgkmm;
190 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
191                                                                                                                                         1.680*fgkmm;
192 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
193                                                                   = {fgkSSDSensorSideSupportHeight[0]
194                                                                   +  fgkSSDSensorSideSupportThickness[0],
195                                                                          fgkSSDSensorSideSupportHeight[1]
196                                                                   +  fgkSSDSensorSideSupportThickness[1]};
197 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
198                                                                   =  {fgkSSDSensorSideSupportThickness[0],
199                                                                           fgkSSDSensorSideSupportThickness[1]};
200 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
201                                                                                                                                    19.000*fgkmm;
202 /////////////////////////////////////////////////////////////////////////////////
203 // Chip Cables (lengths are in mm and angles in degrees)
204 /////////////////////////////////////////////////////////////////////////////////
205 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
206                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
207 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
208                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
209                                                                   -  (fgkSSDSensorSideSupportHeight[1]
210                                                                   -   fgkSSDSensorSideSupportHeight[0])
211                                                                   -   fgkSSDModuleVerticalDisalignment2 
212                                                                   -   fgkSSDCoolingBlockHoleCenter
213                                                                   -   fgkSSDStiffenerHeight
214                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
215                                                                           fgkSSDModuleCoolingBlockToSensor
216                                                                   -   fgkSSDModuleVerticalDisalignment2 
217                                                                   -   fgkSSDCoolingBlockHoleCenter
218                                                                   -       fgkSSDStiffenerHeight
219                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
220 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
221                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
222 /////////////////////////////////////////////////////////////////////////////////
223 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
224 /////////////////////////////////////////////////////////////////////////////////
225 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
226                                                                                                                                         3.820*fgkmm;
227 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
228 //                                                                                                                                         3.780;
229 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
230                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
231 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
232                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
233 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
234                                                                                                                                 { 30.00, 90.00};
235 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
236                                                                                                                                          1.78*fgkmm;
237 /////////////////////////////////////////////////////////////////////////////////
238 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
239 /////////////////////////////////////////////////////////////////////////////////
240 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
241                                                                    = fgkSSDModuleSensorSupportDistance
242                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
243 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
244 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
245                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
246 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
247                                                                                                                                         1.630*fgkmm;
248 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
249 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
250                                                                         = fgkCarbonFiberTriangleLength
251                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
252                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
253                                                                         * TMath::DegToRad());
254 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
255                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
256                                                                         - fgkCarbonFiberSupportWidth)
257                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
258                                                                         - fgkCarbonFiberSupportWidth;
259 /////////////////////////////////////////////////////////////////////////////////
260 // Carbon Fiber Lower Support Parameters (lengths are in mm)
261 /////////////////////////////////////////////////////////////////////////////////
262 const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
263 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
264                                                                                                                                           =  0.950*fgkmm;
265 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
266                                                                                                                                           =  1.600*fgkmm;
267 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
268                                                                                                                                           =  0.830*fgkmm;
269 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
270                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
271 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
272                                                                         = fgkCarbonFiberJunctionWidth
273                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
274                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
275 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
276                                                                         = {fgkCarbonFiberLowerSupportWidth
277                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
278                                                                            fgkCarbonFiberLowerSupportWidth
279                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
280                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
281 /////////////////////////////////////////////////////////////////////////////////
282 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
283 /////////////////////////////////////////////////////////////////////////////////
284 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
285                                                            {0.5 * (fgkSSDLay5LadderLength
286                                                                         -  fgkSSDLay5SensorsNumber
287                                                                         *  fgkCarbonFiberJunctionWidth
288                                                                         -  fgkCarbonFiberLowerSupportWidth),
289                                                                 0.5 * (fgkSSDLay5LadderLength
290                                                                         -  fgkSSDLay5SensorsNumber
291                                                                         *  fgkCarbonFiberJunctionWidth
292                                                                         +  fgkCarbonFiberLowerSupportWidth)};
293 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
294                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
295                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
296 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
297                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
298                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
299 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
300                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
301 /////////////////////////////////////////////////////////////////////////////////
302 // Cooling Tube Support (lengths are in mm and angles in degrees)
303 /////////////////////////////////////////////////////////////////////////////////
304 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
305 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
306                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
309 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
310 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
311                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
312 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
313                                                                                                                                           11.70*fgkmm;
314 /////////////////////////////////////////////////////////////////////////////////
315 // Cooling Tube (lengths are in mm and angles in degrees)
316 /////////////////////////////////////////////////////////////////////////////////
317 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
318 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
319 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
320                                                                                                         fgkCarbonFiberJunctionWidth;
321 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
322                                                                          fgkSSDModuleSensorSupportDistance
323                                                                   +      fgkSSDCoolingBlockLength;
324 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
325 /////////////////////////////////////////////////////////////////////////////////
326 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
327 /////////////////////////////////////////////////////////////////////////////////
328 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
329                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
330 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
331                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
332 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
333                                                                                                                                           20.0*fgkmm;
334 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
335                                                                                                                                                     40.0;
336 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
337                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
338 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
339                                                                                                                                           2.5*fgkmm;
340 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
341                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
342 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
343                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
344 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
345                                                                                                                                           1.0*fgkmm;
346 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
347                                                                                                                                           6.0*fgkmm;
348 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
349                                                                                                                                           4.0*fgkmm;
350 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
351                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
352 /////////////////////////////////////////////////////////////////////////////////
353 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
354 /////////////////////////////////////////////////////////////////////////////////
355 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
356 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
357 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
359 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
360 /////////////////////////////////////////////////////////////////////////////////
361 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
362 /////////////////////////////////////////////////////////////////////////////////
363 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
364 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
365 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
366                                                                                                   -  fgkSSDMountingBlockHeight[1]
367                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
368                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
369                                                                                                   +  fgkSSDModuleVerticalDisalignment
370                                                                                                   -      fgkMountingBlockSupportDownHeight,
371                                                                                                          fgkSSDLay6RadiusMin
372                                                                                                   -  fgkSSDMountingBlockHeight[1]
373                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
374                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
375                                                                                                   +  fgkSSDModuleVerticalDisalignment
376                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
377 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
378                                                                                                     -  fgkSSDMountingBlockHeight[1]
379                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
380                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
381                                                                                                         +  fgkSSDModuleVerticalDisalignment
382                                                                                                         -  fgkMountingBlockSupportRadius[0],
383                                                                                                            fgkSSDLay6RadiusMax
384                                                                                                     -  fgkSSDMountingBlockHeight[1]
385                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
386                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
387                                                                                                         +  fgkSSDModuleVerticalDisalignment
388                                                                                                         -  fgkMountingBlockSupportRadius[1]};
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
390 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
391 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
392 /////////////////////////////////////////////////////////////////////////////////
393 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
394 /////////////////////////////////////////////////////////////////////////////////
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
398 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
399                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
400 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
401                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
402 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
403                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
408 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
409 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
410 /////////////////////////////////////////////////////////////////////////////////
411 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
412 /////////////////////////////////////////////////////////////////////////////////
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
414 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
415 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
416 /////////////////////////////////////////////////////////////////////////////////
417 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
418 /////////////////////////////////////////////////////////////////////////////////
419 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
420                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
422 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
423 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
424                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
425 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
426                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
427 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
428 /////////////////////////////////////////////////////////////////////////////////
429 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
430 /////////////////////////////////////////////////////////////////////////////////
431 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
432                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
433 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
434                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
435                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
436 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
437 /////////////////////////////////////////////////////////////////////////////////
438 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
439 /////////////////////////////////////////////////////////////////////////////////
440 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
441                                                                                                            {62.0*fgkmm,21.87*fgkmm};
442 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
443                                                                                                             {47.0*fgkmm,0.35*fgkmm};
444 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
445                                                                                                                                           1.0*fgkmm;
446 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
447 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
448                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
449 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
450                                                                                                                                          0.15*fgkmm;
451 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
452                                                                                                                                          19.0*fgkmm;
453 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
454                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
455 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
456                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
457 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
458                                                                                                                                           2.1*fgkmm;
459 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
460                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
461 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
462                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
463 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
464                                                                                                                                            19*fgkmm; 
465 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
466                                                                                                                                           1.0*fgkmm;
467 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
468                                                                                                                                           3.6*fgkmm;
469 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
470                                                                                                                                          61.0*fgkmm; 
471 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
472                                                                                                                                          5.97*fgkmm; 
473 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
474 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
475                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
476                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
477 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
478                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
479 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
480                                                                                                                                           1.0*fgkmm; 
481 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
482                                                                                                                                    = 0.15*fgkmm; 
483 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
484                                                                                                                                          20.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
487 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
488 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
489 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
490 /////////////////////////////////////////////////////////////////////////////////
491 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
492 /////////////////////////////////////////////////////////////////////////////////
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
500 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
501 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
502 /////////////////////////////////////////////////////////////////////////////////
503 // SSD Cone Parameters (lengths are in mm and angles in degrees)
504 /////////////////////////////////////////////////////////////////////////////////
505 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
510 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
525 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
526 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
527 /////////////////////////////////////////////////////////////////////////////////
528 // SSD Cables Parameters (lengths are in mm and angles in degrees)
529 /////////////////////////////////////////////////////////////////////////////////
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
532 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
533 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
534 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
536 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
537 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
541 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
542 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
543 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
544 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
545 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
546 /////////////////////////////////////////////////////////////////////////////////
547 ClassImp(AliITSv11GeometrySSD)
548 /////////////////////////////////////////////////////////////////////////////////
549 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
550   AliITSv11Geometry(),
551   fSSDChipMedium(),
552   fSSDChipGlueMedium(),
553   fSSDStiffenerMedium(),
554   fSSDStiffenerConnectorMedium(),
555   fSSDStiffener0603CapacitorMedium(),
556   fSSDStiffener1812CapacitorMedium(),
557   fSSDStiffenerHybridWireMedium(),
558   fSSDKaptonFlexMedium(),
559   fSSDAlTraceFlexMedium(),
560   fSSDAlTraceLadderCableMedium(),
561   fSSDKaptonLadderCableMedium(),
562   fSSDKaptonChipCableMedium(),
563   fSSDAlTraceChipCableMedium(),
564   fSSDAlCoolBlockMedium(),
565   fSSDSensorMedium(),
566   fSSDSensorSupportMedium(),
567   fSSDCarbonFiberMedium(),
568   fSSDTubeHolderMedium(),
569   fSSDCoolingTubeWater(),
570   fSSDCoolingTubePhynox(),
571   fSSDSupportRingAl(),
572   fSSDMountingBlockMedium(),
573   fSSDRohaCellCone(),
574   fSSDAir(),
575   fSSDCopper(),
576   fCreateMaterials(kFALSE),
577   fTransformationMatrices(kFALSE),
578   fBasicObjects(kFALSE),
579   fcarbonfiberjunction(),
580   fcoolingtubesupport(),
581   fhybridmatrix(),
582   fssdcoolingblocksystem(),
583   fcoolingblocksystematrix(),
584   fssdstiffenerflex(),
585   fssdendflex(),
586   fendladdercoolingtubesupportmatrix(),
587   fendladdermountingblock(),
588   fendladdermountingblockclip(),
589   fSSDSensor5(),
590   fSSDSensor6(),
591   fSSDLayer5(), 
592   fSSDLayer6(),
593   fMotherVol(),
594   fLay5LadderSupportRing(),
595   fLay6LadderSupportRing(),
596   fgkEndCapSupportSystem(),
597   fSSDCone(),
598   fColorCarbonFiber(4),
599   fColorRyton(5),
600   fColorPhynox(14),
601   fColorSilicon(3),
602   fColorAl(38),
603   fColorKapton(6),
604   fColorPolyhamide(5),
605   fColorStiffener(9),
606   fColorEpoxy(30),
607   fColorWater(7),
608   fColorG10(41)
609 {
610   ////////////////////////
611   // Standard constructor
612   ////////////////////////
613 }
614 /////////////////////////////////////////////////////////////////////////////////
615 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
616   AliITSv11Geometry(s.GetDebug()),
617   fSSDChipMedium(s.fSSDChipMedium),
618   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
619   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
620   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
621   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
622   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
623   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
624   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
625   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
626   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
627   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
628   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
629   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
630   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
631   fSSDSensorMedium(s.fSSDSensorMedium),
632   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
633   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
634   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
635   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
636   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
637   fSSDSupportRingAl(s.fSSDSupportRingAl),
638   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
639   fSSDRohaCellCone(s.fSSDRohaCellCone),
640   fSSDAir(s.fSSDAir),
641   fSSDCopper(s.fSSDCopper),
642   fCreateMaterials(s.fCreateMaterials),
643   fTransformationMatrices(s.fTransformationMatrices),
644   fBasicObjects(s.fBasicObjects),
645   fcarbonfiberjunction(s.fcarbonfiberjunction),
646   fcoolingtubesupport(s.fcoolingtubesupport),
647   fhybridmatrix(s.fhybridmatrix),
648   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
649   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
650   fssdstiffenerflex(s.fssdstiffenerflex),
651   fssdendflex(s.fssdendflex),
652   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
653   fendladdermountingblock(s.fendladdermountingblock),
654   fendladdermountingblockclip(s.fendladdermountingblockclip),
655   fSSDSensor5(s.fSSDSensor5),
656   fSSDSensor6(s.fSSDSensor6),
657   fSSDLayer5(s.fSSDLayer5),     
658   fSSDLayer6(s.fSSDLayer6),
659   fMotherVol(s.fMotherVol),
660   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
661   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
662   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
663   fSSDCone(s.fSSDCone),
664   fColorCarbonFiber(s.fColorCarbonFiber),
665   fColorRyton(s.fColorRyton),
666   fColorPhynox(s.fColorPhynox),
667   fColorSilicon(s.fColorSilicon),
668   fColorAl(s.fColorAl),
669   fColorKapton(s.fColorKapton),
670   fColorPolyhamide(s.fColorPolyhamide),
671   fColorStiffener(s.fColorStiffener),
672   fColorEpoxy(s.fColorEpoxy),
673   fColorWater(s.fColorWater),
674   fColorG10(s.fColorG10)
675 {
676   ////////////////////////
677   // Copy Constructor
678   ////////////////////////
679 }
680 /////////////////////////////////////////////////////////////////////////////////
681 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
682 operator=(const AliITSv11GeometrySSD &s){
683   ////////////////////////
684   // Assignment operator
685   ////////////////////////
686   this->~AliITSv11GeometrySSD();
687   new(this) AliITSv11GeometrySSD(s); 
688   return *this;
689 /*      
690   if(&s == this) return *this;
691   fMotherVol = s.fMotherVol;
692   return *this;
693  */
694 }
695 ///////////////////////////////////////////////////////////////////////////////
696 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
697   ///////////////////////////////////////////////////////////////////////  
698   // Method generating the trasformation matrix for the whole SSD Geometry   
699   ///////////////////////////////////////////////////////////////////////  
700   // Setting some variables for Carbon Fiber Supportmatrix creation
701   //////////////////////////////////////////////////////////////////////
702   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
703                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
704   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
705                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
706                                                                  +      fgkCarbonFiberSupportWidth);
707   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
708                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
709   TGeoRotation* carbonfiberot[3];
710   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
711   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
712   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
713   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
714   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
715                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
716                                                   -  fgkCarbonFiberTriangleLength
717                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
718   ///////////////////////////////////////////
719   //Setting Local Translations and Rotations: 
720   ///////////////////////////////////////////
721   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
722   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
723                                                                          0.5*carbonfibersupportheight,NULL);    
724   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
725                                                                          2.*symmetryplaneposition+transvector[1],
726                                                                          transvector[2], carbonfiberot[2]);
727   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
728   /////////////////////////////////////////////////////////////
729   // Carbon Fiber Support Transformations
730   /////////////////////////////////////////////////////////////
731   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
732   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
733                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
734                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
735                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
736   }             
737   /////////////////////////////////////////////////////////////
738   // Carbon Fiber Junction Transformation
739   /////////////////////////////////////////////////////////////
740   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
741   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
742   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
743   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
744   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
745         localcarbonfiberjunctionmatrix[i] = 
746                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
747         localcarbonfiberjunctionrot[i] = 
748                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
749         localcarbonfiberjunctiontrans[i] = 
750                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
751   }
752   ///////////////////////
753   // Setting Translations
754   ///////////////////////
755   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
756   localcarbonfiberjunctiontrans[1][0] = 
757                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
758   localcarbonfiberjunctiontrans[2][0] = 
759                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
760                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
761                                  fgkCarbonFiberTriangleLength
762                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
763   localcarbonfiberjunctiontrans[0][1] = 
764                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
765   localcarbonfiberjunctiontrans[1][1] = 
766                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
767   localcarbonfiberjunctiontrans[2][1] = 
768                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
769   ////////////////////
770   // Setting Rotations
771   ////////////////////
772   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
773                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
774                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
775   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
776         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
777   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
778   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
779   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
780   ////////////////////////////////////////
781   // Setting Carbon Fiber Junction matrix 
782   ////////////////////////////////////////
783   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
784                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
785                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
786                         localcarbonfiberjunctionmatrix[i][j] = 
787                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
788                                                            *localcarbonfiberjunctionrot[i][j]);
789                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
790          }
791   }
792   /////////////////////////////////////////////////////////////
793   // Carbon Fiber Lower Support Transformations
794   /////////////////////////////////////////////////////////////
795   TGeoTranslation* localcarbonfiberlowersupportrans[2];
796   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
797                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
798                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
799                                                                          0.0);
800   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
801                                                                          fgkCarbonFiberJunctionWidth
802                                                                 -    fgkCarbonFiberLowerSupportWidth
803                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
804                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
805                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
806    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
807    fcarbonfiberlowersupportrans[0] = 
808                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
809    fcarbonfiberlowersupportrans[1] = 
810                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
811   /////////////////////////////////////////////////////////////
812   // SSD Sensor Support Transformations
813   /////////////////////////////////////////////////////////////
814   const Int_t kssdsensorsupportmatrixnumber = 3;
815   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
816   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
817   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
818   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
819         localssdsensorsupportmatrix[i] = 
820                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
821         localssdsensorsupportrot[i] = 
822                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
823         localssdsensorsupportrans[i] = 
824                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
825   }
826   ///////////////////////
827   // Setting Translations
828   ///////////////////////
829   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
830                                                                           0.5*fgkSSDSensorSideSupportWidth,
831                                                                           0.0);
832   localssdsensorsupportrans[1][0] = 
833                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
834   localssdsensorsupportrans[2][0] = 
835                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
836   localssdsensorsupportrans[0][1] = 
837                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
838                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
839                                                                                 0.0);
840   localssdsensorsupportrans[1][1] = 
841                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
842                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
843                                                                     -   fgkSSDModuleSensorSupportDistance,
844                                                                                 0.0);
845   localssdsensorsupportrans[2][1] = 
846                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
847                                                                         -    fgkSSDSensorCenterSupportPosition,
848                                                                                  0.5*fgkSSDSensorCenterSupportWidth
849                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
850                                                                                  fgkSSDSensorCenterSupportThickness[0]);
851   localssdsensorsupportrans[0][2] = 
852                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
853                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
854                                                                                  fgkCarbonFiberJunctionWidth
855                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
856                                                                         +    fgkSSDSensorCenterSupportLength
857                                                                         -    fgkSSDSensorCenterSupportThickness[0])
858                                                                         -    fgkSSDSensorCenterSupportPosition,
859                                                                              0.0);
860   localssdsensorsupportrans[1][2] = 
861                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
862   localssdsensorsupportrans[2][2] = 
863                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
864   ////////////////////
865   // Setting Rotations
866   ////////////////////
867   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
868                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
869                         localssdsensorsupportrot[i][j] = new TGeoRotation();
870   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
871         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
872         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
873   }
874   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
875   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
876   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
877   ////////////////////////////////////////
878   // SSD Sensor Support matrix 
879   ////////////////////////////////////////
880   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
881                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
882                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
883                         localssdsensorsupportmatrix[i][j] = 
884                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
885                                                            *localssdsensorsupportrot[i][j]);
886                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
887          }
888   }
889   /////////////////////////////////////////////////////////////
890   // SSD Cooling Tube Support Transformations
891   /////////////////////////////////////////////////////////////
892   const Int_t kcoolingtubesupportmatrixnumber = 2;
893   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
894   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
895   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
896   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
897                                                                                                         /fgkCoolingTubeSupportRmax);
898   localcoolingtubesupportrans[0] = 
899                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
900                                                 +  2.*(fgkCoolingTubeSupportLength
901                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
902                                                 +  fgkCarbonFiberTriangleLength
903                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
904   localcoolingtubesupportrans[1] = 
905                         new TGeoTranslation(fgkCarbonFiberJunctionLength
906                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
907                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
908                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
909                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
910                     -  0.5*(fgkCarbonFiberLowerSupportWidth
911                                         +          fgkSSDSensorCenterSupportLength
912                     -      fgkSSDSensorCenterSupportThickness[0])
913                                         +  0.5*fgkSSDSensorLength,
914                                         -  0.5*fgkCoolingTubeSupportHeight);  
915   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
916   localcoolingtubesupportrot[i] = new TGeoRotation();
917   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
918   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
919   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
920         localcoolingtubesupportmatrix[i] = 
921                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
922                                                    *localcoolingtubesupportrot[i]);
923   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
924   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
925                                                                 (*localcoolingtubesupportmatrix[0]));
926   /////////////////////////////////////////////////////////////
927   // End Ladder SSD Cooling Tube Support Transformations
928   /////////////////////////////////////////////////////////////
929   TGeoTranslation** localendladdercooltubetrans[2];
930   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
931   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
932   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
933   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
934                                                                                         -          (fgkCoolingTubeSupportLength
935                                                                                         -               fgkCoolingTubeSupportRmax),
936                                                                                                         fgkEndLadderMountingBlockPosition[0]
937                                                                                         -               fgkendladdercoolingsupportdistance[0]
938                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
939                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
940   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
941                                                                                         -          (fgkCoolingTubeSupportLength
942                                                                                         -               fgkCoolingTubeSupportRmax),
943                                                                                                         fgkEndLadderMountingBlockPosition[0]
944                                                                                         +               fgkendladdercoolingsupportdistance[1]
945                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
946                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
947   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
948                                                                                         -       fgkCoolingTubeSupportRmax)
949                                                                                         +               fgkCarbonFiberTriangleLength
950                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
951                                                                                                 0.0,
952                                                                                                 0.0);
953   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
954                                                                                                         fgkendladdercoolingsupportdistance[0]
955                                                                                         +               fgkendladdercoolingsupportdistance[1],
956                                                                                                         0.0);
957   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
958   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
959                                                                                         +               fgkCarbonFiberJunctionLength
960                                                                                         -               fgkCoolingTubeSupportLength,
961                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
962                                                                                         -       0.5*fgkCoolingTubeSupportWidth
963                                                                                                    -fgkendladdercoolingsupportdistance[2],
964                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
965   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
966                                                                                         +               fgkCoolingTubeSupportLength
967                                                                                         -               fgkCoolingTubeSupportRmax
968                                                                                         -               fgkCarbonFiberJunctionLength,
969                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
970                                                                                         -       0.5*fgkCoolingTubeSupportWidth
971                                                                                         -               fgkendladdercoolingsupportdistance[2],
972                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
973   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
974   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
975   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
976   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
977   (*localcoolingtubesupportrot[1]));
978   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
979   (*localcoolingtubesupportrot[1]));
980   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
981   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
982   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
983   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
984   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
985
986   fendladdercoolingtubesupportmatrix[1][0] =    
987                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
988                                                                                    *(*localcoolingtubesupportrot[1]));
989   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
990   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
991   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
992   /////////////////////////////////////////////////////////////
993   // SSD Cooling Tube Transformations
994   /////////////////////////////////////////////////////////////
995   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
996   localcoolingtuberot->SetAngles(0.,90.,0.);
997   TGeoTranslation** localcoolingtubetrans[4];
998   TVector3** localcoolingtubevect[4];
999   for(Int_t i=0; i<4; i++){
1000         localcoolingtubevect[i] = new TVector3*[2];
1001         localcoolingtubetrans[i] = new TGeoTranslation*[2];
1002         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
1003   }
1004   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1005                                                   -fgkCarbonFiberTriangleLength),
1006                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1007                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1008                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1009                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1010                                                   +      fgkSSDSensorCenterSupportLength
1011                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1012                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1013                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1014                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1015                                                   -  0.5*fgkCoolingTubeSupportWidth,
1016                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1017   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1018                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1019                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1020                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1021                                                   +  fgkCoolingTubeSupportWidth,
1022                                                   localcoolingtubevect[0][0]->Z());     
1023   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1024                                                          +                               fgkCarbonFiberTriangleLength,
1025                                                                                          localcoolingtubevect[0][0]->Y(),
1026                                                                                          localcoolingtubevect[0][0]->Z());
1027   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1028                                                          +                               fgkCarbonFiberTriangleLength,
1029                                                                                          localcoolingtubevect[0][1]->Y(),
1030                                                                                          localcoolingtubevect[0][1]->Z());
1031   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1032                                                   -     fgkCarbonFiberTriangleLength),
1033                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1034                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1035                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1036                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1037                                                   +      fgkSSDSensorCenterSupportLength
1038                                                   -      fgkSSDSensorCenterSupportThickness[0])
1039                                                   +  fgkSSDModuleStiffenerPosition[1]
1040                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1041                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1042   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1043                                                          +                               fgkCarbonFiberTriangleLength,
1044                                                                                          localcoolingtubevect[2][0]->Y(),
1045                                                                                          localcoolingtubevect[2][0]->Z());      
1046   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1047                                                   -     fgkCarbonFiberTriangleLength),
1048                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1049                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1050                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1051                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1052                                                   +      fgkSSDSensorCenterSupportLength
1053                                                   -      fgkSSDSensorCenterSupportThickness[0])
1054                                                   +      fgkSSDSensorLength
1055                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1056                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1057   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1058                                                   + fgkCarbonFiberTriangleLength,
1059                                                         localcoolingtubevect[3][0]->Y(),
1060                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1061   for(Int_t i=0; i<4; i++) 
1062         for(Int_t j=0; j<2; j++){
1063                 localcoolingtubetrans[i][j] = 
1064                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1065                                                                 localcoolingtubevect[i][j]->Y(),
1066                                                                 localcoolingtubevect[i][j]->Z());
1067                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1068                                                           *                                     (*localcoolingtuberot));
1069         }
1070   /////////////////////////////////////////////////////////////
1071   // SSD End Ladder Cooling Tube Transformations
1072   /////////////////////////////////////////////////////////////
1073   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1074   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1075   TGeoTranslation** localendlladdercoolingtubetrans[2];
1076   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1077   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1078   for(Int_t i=0; i<2; i++)      
1079         for(Int_t j=0; j<(i==0?6:4); j++)       
1080                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1081   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1082                                                                         -        fgkCoolingTubeSupportRmax)
1083                                                                         +        fgkCarbonFiberJunctionLength,
1084                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1085                                                                         -    fgkendladdercoolingsupportdistance[0]),
1086                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1087   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1088                                                                         -        fgkCoolingTubeSupportRmax)
1089                                                                         -        fgkCarbonFiberJunctionLength
1090                                                                         +    fgkCarbonFiberTriangleLength,
1091                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1092                                                                         -    fgkendladdercoolingsupportdistance[0]),
1093                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1094   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1095                                                                         -   fgkCoolingTubeSupportRmax)
1096                                                                         +       fgkCarbonFiberJunctionLength,
1097                                                                            fgkEndLadderMountingBlockPosition[0]
1098                                                                         -   fgkendladdercoolingsupportdistance[0]
1099                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1100                                                   +                             fgkendladdercoolingsupportdistance[1]
1101                                                   +                             fgkCoolingTubeSupportWidth),
1102                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1103   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1104                                                                         -        fgkCoolingTubeSupportRmax)
1105                                                                         -        fgkCarbonFiberJunctionLength
1106                                                                         +    fgkCarbonFiberTriangleLength,
1107                                                                            fgkEndLadderMountingBlockPosition[0]
1108                                                                         -   fgkendladdercoolingsupportdistance[0]
1109                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1110                                                   +                             fgkendladdercoolingsupportdistance[1]
1111                                                   +                             fgkCoolingTubeSupportWidth),
1112                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1113   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1114                                                                         -   fgkCoolingTubeSupportRmax)
1115                                                                         +       fgkCarbonFiberJunctionLength,
1116                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1117                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1118                                                   -                     fgkEndLadderMountingBlockPosition[0]
1119                                                   -                     fgkendladdercoolingsupportdistance[1]           
1120                                                   -                     fgkCoolingTubeSupportWidth),
1121                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1122   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1123                                                                         -        fgkCoolingTubeSupportRmax)
1124                                                                         -        fgkCarbonFiberJunctionLength
1125                                                                         +    fgkCarbonFiberTriangleLength,
1126                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1127                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1128                                                   -                     fgkEndLadderMountingBlockPosition[0]
1129                                                   -                     fgkendladdercoolingsupportdistance[1]           
1130                                                   -                     fgkCoolingTubeSupportWidth),
1131                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1132   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1133                                                                         -   fgkCoolingTubeSupportRmax)
1134                                                                         +       fgkCarbonFiberJunctionLength,
1135                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1136                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1137                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1138                                                         +                 fgkSSDSensorOverlap
1139                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1140                                                         -                 fgkendladdercoolingsupportdistance[2]
1141                                                         -                 fgkEndLadderMountingBlockPosition[1]
1142                                                         -                 fgkCoolingTubeSupportWidth)
1143                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1144                                                         -                 fgkendladdercoolingsupportdistance[2]
1145                                                         -                 fgkCoolingTubeSupportWidth,
1146                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1147   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1148                                                   -      fgkCoolingTubeSupportRmax)
1149                                                   -      fgkCarbonFiberJunctionLength
1150                                                   +    fgkCarbonFiberTriangleLength,
1151                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1152                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1153                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1154                                                         +                 fgkSSDSensorOverlap
1155                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1156                                                         -                 fgkendladdercoolingsupportdistance[2]
1157                                                         -                 fgkEndLadderMountingBlockPosition[1]
1158                                                         -                 fgkCoolingTubeSupportWidth)
1159                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1160                                                         -                 fgkendladdercoolingsupportdistance[2]
1161                                                         -                 fgkCoolingTubeSupportWidth,
1162                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1163   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1164                                                                         -   fgkCoolingTubeSupportRmax)
1165                                                                         +       fgkCarbonFiberJunctionLength,
1166                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1167                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1168                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1169   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1170                                                                         -        fgkCoolingTubeSupportRmax)
1171                                                                         -        fgkCarbonFiberJunctionLength
1172                                                                         +    fgkCarbonFiberTriangleLength,
1173                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1174                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1175                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1176   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1177   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1178   for(Int_t i=0; i<2; i++)
1179         for(Int_t j=0; j<(i==0?6:4); j++){
1180                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1181                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1182         }
1183   /////////////////////////////////////////////////////////////
1184   // SSD Hybrid Components Transformations
1185   /////////////////////////////////////////////////////////////
1186   const Int_t khybridmatrixnumber = 3;
1187   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1188   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1189                                             0.5*fgkSSDStiffenerWidth,
1190                                             0.5*fgkSSDStiffenerHeight);
1191   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1192                                             fgkSSDModuleStiffenerPosition[1],0.0);
1193
1194   localhybridtrans[2] = new TGeoTranslation(
1195                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1196                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1197                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1198                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1199                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1200                       -       fgkSSDSensorCenterSupportThickness[0]),
1201                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1202                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1203                                           -       fgkSSDModuleVerticalDisalignment2)); 
1204   fhybridmatrix = new TGeoHMatrix();
1205   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1206   /////////////////////////////////////////////////////////////
1207   // SSD Cooling Block Transformations
1208   /////////////////////////////////////////////////////////////
1209   const Int_t kcoolingblockmatrixnumber = 4;    
1210   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1211   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1212                             -  fgkCoolingTubeSupportRmin),0.0,
1213                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1214   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1215                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1216                                0.0,fgkSSDStiffenerHeight);
1217   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1218   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1219   fcoolingblocksystematrix = new TGeoHMatrix();
1220   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1221       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1222   /////////////////////////////////////////////////////////////
1223   // SSD Stiffener Flex Transformations
1224   /////////////////////////////////////////////////////////////
1225   const Int_t klocalflexmatrixnumber = 4;
1226   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1227   for(Int_t i=0; i<fgkflexnumber; i++)    
1228       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1229   for(Int_t i=0; i<fgkflexnumber; i++)
1230       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1231             localflexmatrix[i][j] = new TGeoCombiTrans();
1232   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1233                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1234                                                                   -    fgkSSDStiffenerWidth;
1235   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1236                                         +0.5*fgkSSDStiffenerLength,
1237                                          0.5*fgkSSDStiffenerWidth,
1238                                         -0.5*fgkSSDStiffenerHeight
1239                                         -0.5*fgkSSDFlexHeight[0]);
1240   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1241                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1242                                         -0.5*fgkSSDStiffenerWidth,
1243                                         -0.5*fgkSSDStiffenerHeight
1244                                         -0.5*fgkSSDFlexHeight[0]);
1245   TGeoRotation* localflexrot = new TGeoRotation();
1246   localflexrot->SetAngles(180.,0.,0.);    
1247   localflexmatrix[1][0]->SetRotation(localflexrot);
1248   for(Int_t i=0; i<fgkflexnumber; i++)
1249       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1250             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1251   for(Int_t i=0; i<fgkflexnumber; i++){
1252       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1253       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1254             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1255   }
1256   /////////////////////////////////////////////////////////////
1257   // SSD End Flex Transformations
1258   /////////////////////////////////////////////////////////////
1259   TGeoRotation* localendflexrot = new TGeoRotation();
1260   localendflexrot->SetAngles(0.0,90.0,0.0);
1261   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1262   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1263                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1264   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1265                             * TMath::DegToRad()*ssdflexradiusmax
1266                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1267                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
1268   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1269                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1270                             +      fgkSSDFlexLength[2];
1271   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1272                               0.5*fgkSSDFlexWidth[0],
1273                               2.*fgkSSDStiffenerHeight
1274                             + 0.5*fgkSSDFlexHeight[0]);      
1275   localendflexmatrix->SetRotation(localendflexrot);
1276   for(Int_t i=0; i<fgkflexnumber; i++) 
1277       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1278   /////////////////////////////////////////////////////////////
1279   // End Ladder Carbon Fiber Junction
1280   /////////////////////////////////////////////////////////////
1281   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1282   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1283   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1284   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1285       localendladdercarbonfiberjunctionmatrix[i] 
1286             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1287       localendladdercarbonfiberjunctionrot[i] 
1288             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1289       localendladdercarbonfiberjunctiontrans[i] 
1290             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1291       fendladdercarbonfiberjunctionmatrix[i]
1292             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1293   }
1294   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1295       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1296             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1297             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1298       }
1299   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1300       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1301           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1302   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1303       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1304                               0.0,0.0);
1305       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1306                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1307                 *                     SinD(fgkCarbonFiberTriangleAngle),
1308                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1309   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1310   }
1311   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1312   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1313   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1314   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1315       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1316       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1317       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1318       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1319             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1320       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1321             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1322                                *localendladdercarbonfiberjunctionglobalrot[i]);
1323   }
1324   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1325       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1326             localendladdercarbonfiberjunctionmatrix[i][j] = 
1327                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1328                                      *localendladdercarbonfiberjunctionrot[i][j]);
1329            fendladdercarbonfiberjunctionmatrix[i][j] =
1330             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1331             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1332       }  
1333   /////////////////////////////////////////////////////////////
1334   // End Ladder Carbon Fiber Support
1335   /////////////////////////////////////////////////////////////
1336   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1337   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1338       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1339       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1340             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1341       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1342   }
1343   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1344       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1345             fendladdercarbonfibermatrix[i][j] = 
1346             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1347             *(*fcarbonfibersupportmatrix[j]));
1348   /////////////////////////////////////////////////////////////
1349   // End Ladder SSD Mounting Block
1350   /////////////////////////////////////////////////////////////
1351   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1352       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1353   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1354       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1355                                 +        fgkSSDMountingBlockLength[1])
1356                                 +  0.5*fgkCarbonFiberTriangleLength,
1357                                 fgkEndLadderMountingBlockPosition[i],
1358                                 -  fgkSSDMountingBlockHeight[1]
1359                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1360   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1361   endladdermountingblockrot->SetAngles(0.,90.,0.);
1362   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1363         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1364   /////////////////////////////////////////////////////////////
1365   // End Ladder SSD Mounting Block Clip Matrix 
1366   /////////////////////////////////////////////////////////////
1367   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1368         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1369   
1370   TGeoRotation* localendladdercliprot = new TGeoRotation();
1371   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1372   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1373                                                                                   -     fgkSSDMountingBlockLength[1])
1374                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1375   localendladdercliprot->SetAngles(90.,180.,-90.);
1376   TGeoCombiTrans* localendladderclipcombitrans = 
1377                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1378   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1379         for(Int_t j=0; j<2; j++){
1380                 fendladdermountingblockclipmatrix[i][j] = 
1381                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1382                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1383         }
1384   /////////////////////////////////////////////////////////////
1385   // End Ladder Carbon Fiber Lower Support
1386   /////////////////////////////////////////////////////////////
1387   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1388       fendladderlowersupptrans[i] = 
1389             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1390                         +  0.5*fgkSSDMountingBlockWidth),
1391                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1392   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1393                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1394                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1395                                                                          0.0);
1396   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1397  /////////////////////////////////////////////////////////////
1398   // Matrix for positioning Ladder into mother volume
1399   /////////////////////////////////////////////////////////////
1400   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1401   for(Int_t i=0; i<fgkladdernumber; i++) 
1402         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1403   TGeoRotation* localladdermotherrot = new TGeoRotation();
1404   localladdermotherrot->SetAngles(0.,90.,0.);  
1405   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1406   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1407   for(Int_t i=0; i<fgkladdernumber; i++){
1408         localladdermothertrans[i] = new TGeoTranslation(0.,
1409                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1410                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1411                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1412                                                           * fgkCarbonFiberJunctionWidth,0.);
1413         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1414                                                                                                                 *localladdermotherrot);
1415         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1416         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1417   }
1418   /////////////////////////////////////////////////////////////
1419   // Ladder Cables Matrices
1420   /////////////////////////////////////////////////////////////
1421   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1422                                              + fgkSSDFlexHeight[1];  
1423   Double_t ssdladdercabletransx[3];
1424   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1425                                                   *   SinD(2.*fgkSSDFlexAngle)
1426                                                   *       CosD(2.*fgkSSDFlexAngle);
1427   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1428                                                   -     ssdladdercabletransx[0]
1429                                                   /     SinD(2.*fgkSSDFlexAngle))
1430                                                   *     CosD(fgkSSDFlexAngle);                                          
1431   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1432                                                   *       TMath::DegToRad()*ssdflexradiusmax
1433                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1434                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1435                                                   -       fgkSSDLadderCableWidth)
1436                                                   *       CosD(2.*fgkSSDFlexAngle);
1437   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1438                                                   *     TanD(2.*fgkSSDFlexAngle),
1439                                                         ssdladdercabletransx[1]
1440                                                   *     TanD(fgkSSDFlexAngle),
1441                                                         ssdladdercabletransx[2]
1442                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1443   TGeoRotation* localladdercablerot[3]; 
1444   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1445   localladdercablerot[0]->SetAngles(90.,0.,0.);
1446   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1447   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1448                                                  *                        (*localladdercablerot[0]));
1449   ////////////////////////////////////////////
1450   // LocalLadderCableCombiTransMatrix
1451   ////////////////////////////////////////////
1452   const Int_t klocalladdersidecablesnumber = 2;
1453   const Int_t klocalladdercombitransnumber = 5;
1454   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1455   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1456          localladdercablecombitransmatrix[i] = 
1457                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1458   ///////////////////////////////////////////
1459   // Left Side Ladder Cables Transformations
1460   ///////////////////////////////////////////
1461   localladdercablecombitransmatrix[0][0]  =
1462                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1463                                                 0.,0.,NULL);
1464   localladdercablecombitransmatrix[0][1] = 
1465         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1466                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1467                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1468                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1469                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1470                                            + fgkSSDSensorCenterSupportLength
1471                                            - fgkSSDSensorCenterSupportThickness[0]),
1472                                            - (fgkSSDModuleCoolingBlockToSensor
1473                                            + 0.5*fgkCoolingTubeSupportHeight
1474                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1475                                            - fgkSSDChipHeight),NULL);
1476   localladdercablecombitransmatrix[0][2] = 
1477                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1478                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1479   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1480                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1481                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1482                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1483                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1484                                                                                                 new TGeoRotation("",180.,0.,0.));
1485   localladdercablecombitransmatrix[0][4] = 
1486                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1487                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1488                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1489                                                           0.,
1490                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1491                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1492                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1493                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1494   ///////////////////////////////////////////
1495   // Rigth Side Ladder Cables Transformations
1496   ///////////////////////////////////////////
1497   TGeoCombiTrans* localladdercablessdmodulematrix = 
1498         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1499                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1500                                                                          fgkSSDStiffenerWidth,
1501                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1502   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1503    localladdercablecombitransmatrix[1][i] = 
1504                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1505                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1506   ///////////////////////////////////////////
1507   // Setting LadderCableHMatrix
1508   ///////////////////////////////////////////
1509   Int_t beamaxistrans[2][3];
1510   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1511   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1512   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1513   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1514   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1515   beamaxistrans[1][2] = beamaxistrans[1][0];
1516   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1517   TGeoRotation* laddercablerot = new TGeoRotation();
1518   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1519   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1520   Double_t* laddercabletransvector;     
1521   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1522         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1523         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1524   }
1525   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1526         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1527                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1528                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1529                         localladdercablehmatrix[i][j]->MultiplyLeft(
1530                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1531         }
1532                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1533                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1534                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1535                                                                          laddercabletransvector[1]
1536                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1537                                         *                                fgkCarbonFiberJunctionWidth,
1538                                                                          laddercabletransvector[2]);
1539                 laddercablecombitrans->SetRotation(*laddercablerot);
1540                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1541                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1542         }
1543     fladdercablematrix[i][2] = 
1544                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1545                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1546         fladdercablematrix[i][3] = 
1547                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1548                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1549   }
1550   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1551         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1552                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1553   ///////////////////////////////////////////
1554   // Setting Ladder HMatrix
1555   ///////////////////////////////////////////
1556   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1557                                                                                                 fgkSSDLay6SensorsNumber};
1558   for(Int_t i=0; i<fgkladdernumber; i++){
1559         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1560         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1561                 fladdermatrix[i][j] = new TGeoHMatrix();
1562                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1563                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1564                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1565         }
1566   }
1567   ///////////////////////////////////////////
1568   // Setting SSD Sensor Matrix 
1569   ///////////////////////////////////////////
1570   TGeoCombiTrans* localssdsensorcombitrans[2];
1571   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1572   localssdsensorrot->SetAngles(0.,90.,0.);      
1573   TGeoTranslation* localssdsensortrans[2];
1574   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1575   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1576                                          fgkCarbonFiberJunctionWidth 
1577                                          - fgkCarbonFiberLowerSupportWidth 
1578                                          - fgkLowerSupportToSensorZ,
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                                          fgkCarbonFiberJunctionWidth 
1586                                          - fgkCarbonFiberLowerSupportWidth 
1587                                          - fgkLowerSupportToSensorZ,
1588                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1589                                                         -fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1590                                                 +       0.5*fgkSSDModuleVerticalDisalignment2);
1591   for(Int_t i=0; i<2; i++) 
1592         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1593                                                                                                          *localssdsensorrot);   
1594     for(Int_t i=0; i<fgkladdernumber; i++){
1595         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1596         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1597                 switch(i){
1598                         case 0: //Ladder of Layer5  
1599                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1600                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1601                                                                                                 *localssdsensorcombitrans[1])));
1602                         break;
1603                         case 1: //Ladder of Layer6 
1604                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1605                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1606                                                                                                 *localssdsensorcombitrans[0])));
1607                 break;
1608                 }
1609           }
1610   }     
1611   //////////////////////////
1612   // Setting SSD End Ladder  
1613   //////////////////////////
1614   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1615   for(Int_t i=0; i<2; i++){
1616         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1617         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1618         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1619         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1620         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1621         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1622         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1623         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1624    }
1625   /////////////////////////////////////////////////////
1626   // Setting the CombiTransformation to pass ITS center 
1627   /////////////////////////////////////////////////////
1628   Double_t itscentertransz[fgklayernumber];
1629   itscentertransz[0] = fgkSSDLay5LadderLength
1630                                          - fgkLay5CenterITSPosition;
1631   itscentertransz[1] = fgkSSDLay6LadderLength
1632                                          - fgkLay6CenterITSPosition;
1633   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1634                                                    + 0.5*fgkCoolingTubeSupportHeight;
1635   TGeoRotation* itscenterrot[3];
1636   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1637   itscenterrot[0]->SetAngles(90.,180.,-90.);
1638   itscenterrot[1]->SetAngles(0.,90.,0.);
1639   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1640   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1641   for(Int_t i=0; i<fgklayernumber; i++) 
1642         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1643                                                          itssensortransy,
1644                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1645                                                    - itscentertransz[i],itscenterrot[2]);
1646   TGeoRotation** locallayerrot[fgklayernumber];
1647   TGeoTranslation** locallayertrans[fgklayernumber];    
1648   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1649   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1650   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1651                                          - fgkLay5CenterITSPosition);
1652   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1653                                          - fgkLay6CenterITSPosition);
1654   const Int_t kssdlayladdernumber[fgklayernumber] = 
1655                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1656   for(Int_t i=0; i<fgklayernumber; i++){
1657     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1658     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1659         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1660         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1661   }
1662   Double_t layerladderangleposition[fgklayernumber] = 
1663                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1664   Double_t layerradius = 0.;
1665   for(Int_t i=0; i<fgklayernumber; i++){        
1666         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1667                 switch(i){
1668                         case 0: //Ladder of Layer5  
1669                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1670                         break;
1671                         case 1: //Ladder of Layer6 
1672                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1673                 break;
1674                 }
1675                 locallayerrot[i][j] = new TGeoRotation();
1676                 locallayertrans[i][j] = new TGeoTranslation();
1677                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1678                 locallayertrans[i][j]->SetTranslation(layerradius 
1679                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1680                                                             layerradius 
1681                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1682                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1683                                                                          *locallayerrot[i][j]);
1684                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1685                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1686                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1687         }
1688   }
1689   /////////////////////////////////////////////////////////////
1690   // Deallocating memory
1691   /////////////////////////////////////////////////////////////
1692   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1693         delete carbonfiberot[i];
1694         delete localcarbonfibersupportmatrix[i];
1695   }
1696   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1697      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1698        delete localcarbonfiberjunctionmatrix[i][j];
1699            delete localcarbonfiberjunctionrot[i][j];
1700            delete localcarbonfiberjunctiontrans[i][j];
1701            }
1702        delete [] localcarbonfiberjunctionmatrix[i];
1703        delete [] localcarbonfiberjunctionrot[i];
1704        delete [] localcarbonfiberjunctiontrans[i];
1705   }
1706   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1707            delete localcarbonfiberlowersupportrans[i];
1708   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1709      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1710        delete localssdsensorsupportmatrix[i][j];
1711            delete localssdsensorsupportrot[i][j];
1712            delete localssdsensorsupportrans[i][j];
1713            }
1714        delete [] localssdsensorsupportmatrix[i];
1715        delete [] localssdsensorsupportrot[i];
1716        delete [] localssdsensorsupportrans[i];
1717   }
1718   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1719         delete localcoolingtubesupportmatrix[i];
1720         delete localcoolingtubesupportrot[i];
1721         delete localcoolingtubesupportrans[i];
1722   }
1723   for(Int_t i=0; i<4; i++){
1724         for(Int_t j=0; j<2; j++){
1725                 delete localcoolingtubevect[i][j];
1726                 delete localcoolingtubetrans[i][j];
1727         }
1728         delete [] localcoolingtubevect[i];
1729         delete [] localcoolingtubetrans[i];
1730   }
1731  delete endladdermountingblockrot;
1732  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1733  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1734  for(Int_t i=0; i<fgkflexnumber; i++){
1735       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1736             delete localflexmatrix[i][j];
1737       delete [] localflexmatrix[i];
1738  }
1739  delete localendlladdercoolingtuberot;
1740  for(Int_t i=0; i<2; i++){
1741         for(Int_t j=0; j<(i==0?6:4); j++)
1742                 delete localendlladdercoolingtubetrans[i][j];
1743         delete [] localendlladdercoolingtubetrans[i];
1744   }
1745
1746  delete localflexrot;
1747  delete localendflexrot;
1748  delete localendflexmatrix;
1749  for(Int_t i=0; i<fgkladdernumber; i++){ 
1750         delete localladdermothertrans[i];
1751         delete localladdermothercombitrans[i];
1752   }
1753  delete localladdermotherrot;
1754  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1755       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1756             delete localendladdercarbonfiberjunctionmatrix[i][j];
1757             delete localendladdercarbonfiberjunctionrot[i][j];
1758             delete localendladdercarbonfiberjunctiontrans[i][j];
1759       }
1760       delete [] localendladdercarbonfiberjunctionmatrix[i];
1761       delete [] localendladdercarbonfiberjunctionrot[i];
1762       delete [] localendladdercarbonfiberjunctiontrans[i];
1763       delete localendladdercarbonfiberjunctionglobalrot[i];
1764       delete localendladdercarbonfiberjunctionglobaltrans[i];
1765       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1766  }
1767   for(Int_t i=0; i<2; i++){
1768         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1769         delete [] localendladdercooltubetrans[i];
1770   }
1771   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1772       delete localendladdercarbonfibertrans[i];
1773   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1774   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1775         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1776                 delete localladdercablecombitransmatrix[i][j];
1777                 delete []localladdercablecombitransmatrix[i];
1778   }
1779   delete localendladdercliprot;
1780   delete localendladdercliptrans;
1781   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1782         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1783                 delete localladdercablehmatrix[i][j];
1784         delete []localladdercablehmatrix[i];
1785   }
1786   delete laddercablerot;
1787   delete laddercabletrans;
1788   delete laddercablecombitrans;
1789   delete localladdercablessdmodulematrix;
1790   delete localssdsensorrot;     
1791   for(Int_t i=0; i<2; i++){
1792         delete localssdsensortrans[i];
1793         delete localssdsensorcombitrans[i];
1794   }
1795   for(Int_t i=0; i<fgklayernumber; i++){
1796         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1797                 delete locallayerrot[i][j];
1798                 delete locallayertrans[i][j];
1799                 delete locallayercombitrans[i][j];
1800     }
1801         delete [] locallayerrot[i];
1802         delete [] locallayertrans[i];
1803         delete [] locallayercombitrans[i];
1804         delete localbeamaxistrans[i];
1805   }
1806   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1807   for(Int_t i=0; i<fgkladdernumber; i++){
1808         for(Int_t j=0; j<fgkladdernumber; j++)
1809                 delete ladderglobalmatrix[i][j];
1810         delete [] ladderglobalmatrix[i];
1811   }
1812   /////////////////////////////////////////////////////////////
1813   fTransformationMatrices = kTRUE;      
1814 }
1815 ///////////////////////////////////////////////////////////////////////////////
1816 void AliITSv11GeometrySSD::CreateBasicObjects(){
1817   /////////////////////////////////////////////////////////////  
1818   // Method generating the Objects of SSD Geometry    
1819   /////////////////////////////////////////////////////////////
1820   // SSD Sensor
1821   ///////////////////////////////////
1822   SetSSDSensor();
1823   /////////////////////////////////////////////////////////////  
1824   // Carbon Fiber Support    
1825   /////////////////////////////////////////////////////////////  
1826   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1827   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1828       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1829   /////////////////////////////////////////////////////////////
1830   // Carbon Fiber Junction 
1831   /////////////////////////////////////////////////////////////
1832   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1833   /////////////////////////////////////////////////////////////
1834   // Carbon Fiber Lower Support
1835   /////////////////////////////////////////////////////////////
1836   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1837   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1838         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1839   /////////////////////////////
1840   // SSD Sensor Support
1841   /////////////////////////////
1842   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1843                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1844   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1845                                                                          fgkSSDSensorSideSupportThickness[1]};
1846   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1847         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1848                                                                                            fgkSSDSensorSideSupportHeight[i],
1849                                                                                            fgkSSDSensorSideSupportWidth,
1850                                                                                            sidesupporthickness);  
1851         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1852                                                                                            fgkSSDSensorCenterSupportHeight[i],
1853                                                                                            fgkSSDSensorCenterSupportWidth,
1854                                                                                            sidesupporthickness);
1855   }
1856   /////////////////////////////////////////////////////////////
1857   // SSD Cooling Tube Support
1858   /////////////////////////////////////////////////////////////
1859   Int_t edgesnumber = 16;
1860   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1861   /////////////////////////////////////////////////////////////
1862   // SSD Hybrid
1863   /////////////////////////////////////////////////////////////
1864   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1865   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1866         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1867   /////////////////////////////////////////////////////////////
1868   // SSD Cooling Block System
1869   /////////////////////////////////////////////////////////////
1870   fssdcoolingblocksystem = GetCoolingBlockSystem();
1871    /////////////////////////////////////////////////////////////
1872   // SSD Cooling Tube
1873   /////////////////////////////////////////////////////////////
1874   TList* coolingtubelist = GetCoolingTubeList();        
1875   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1876         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1877   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1878         fendladdercoolingtube[i] = 
1879                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1880   /////////////////////////////////////////////////////////////
1881   // SSD Flex  
1882   /////////////////////////////////////////////////////////////
1883   fssdstiffenerflex = GetSSDStiffenerFlex();
1884   fssdendflex = GetSSDEndFlex();
1885   ///////////////////////////////////
1886   // End Ladder Carbon Fiber Junction
1887   ///////////////////////////////////
1888   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1889                                                    fendladdercarbonfiberjunction[i] = 
1890                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1891   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1892     fendladdercarbonfiberjunction[i][0] = 
1893                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1894     fendladdercarbonfiberjunction[i][1] = 
1895                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1896   }
1897   ///////////////////////////////////
1898   // End Ladder Mounting Block
1899   ///////////////////////////////////
1900   fendladdermountingblock = GetSSDMountingBlock();
1901   ///////////////////////////////////
1902   // End Ladder Mounting Block
1903   ///////////////////////////////////
1904   fendladdermountingblockclip = GetMountingBlockClip();
1905   ///////////////////////////////////
1906   // Ladder Support 
1907   ///////////////////////////////////
1908   TList* laddersupportlist = GetMountingBlockSupport(20);
1909   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1910   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1911   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1912   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1913   /////////////////////////////////////////////////////////////
1914   // Deallocating memory
1915   /////////////////////////////////////////////////////////////
1916   delete carbonfibersupportlist;
1917   delete carbonfiberlowersupportlist;
1918   delete ssdhybridcomponentslist;
1919   delete laddersupportlist;
1920   /////////////////////////////////////////////////////////////
1921   fBasicObjects = kTRUE;
1922 }
1923 /////////////////////////////////////////////////////////////////////////////////
1924 void AliITSv11GeometrySSD::SetSSDSensor(){
1925   ////////////////////////////////////////////////////////////////
1926   // Method generating SSD Sensors: it sets the private variables
1927   // fSSDSensor5, fSSDSensor6  
1928   ////////////////////////////////////////////////////////////////
1929   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1930   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1931   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1932                                                 0.5*ssdsensitivewidth,
1933                                                 0.5*fgkSSDSensorHeight,
1934                                                 0.5*ssdsensitivelength);
1935   TGeoVolume* ssdsensorsensitiveLay5 = 
1936         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1937   TGeoVolume* ssdsensorsensitiveLay6 = 
1938         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1939   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1940   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1941   TGeoBBox* ssdsensorinsensitiveshape[2];
1942   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1943                                                 0.5*fgkSSDSensorInsensitiveWidth,
1944                                                 0.5*fgkSSDSensorHeight,
1945                                                 0.5*fgkSSDSensorLength);
1946   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1947                                                 0.5*ssdsensitivewidth,
1948                                                 0.5*fgkSSDSensorHeight,
1949                                                 0.5*fgkSSDSensorInsensitiveWidth);
1950   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1951                                              "SSDSensorInsensitive2"};
1952   TGeoVolume* ssdsensorinsensitive[2];
1953   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1954       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1955                      fSSDSensorMedium);
1956       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1957   }
1958   /////////////////////////////////////////////////////////////
1959   // Virtual Volume containing SSD Sensor  
1960   /////////////////////////////////////////////////////////////
1961   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1962                                                                                              0.5*fgkSSDSensorWidth,
1963                                                                                              0.5*fgkSSDSensorHeight,
1964                                                                                              0.5*fgkSSDSensorLength);
1965   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1966                                                                                  fSSDAir);      
1967   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1968                                                                                  fSSDAir);      
1969   /////////////////////////////////////////////////////////////
1970   for(Int_t i=0; i<4; i++){ 
1971             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1972             ssdsensorinsensitive[1],i<2?1:2,
1973                         new TGeoTranslation(
1974                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1975       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1976                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1977       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1978             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1979             ssdsensorinsensitive[1],i<2?1:2,
1980                         new TGeoTranslation(
1981                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1982       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1983                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1984       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1985   }
1986     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1987     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1988 }
1989 ///////////////////////////////////////////////////////////////////////////////
1990 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1991   /////////////////////////////////////////////////////////////  
1992   // Method generating the Carbon Fiber Support   
1993   /////////////////////////////////////////////////////////////  
1994   const Int_t kvertexnumber = 4;
1995   const Int_t kshapesnumber = 2;
1996   TVector3** vertexposition[kshapesnumber];
1997   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1998   Double_t carbonfibersupportxaxisEdgeproj = 
1999                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2000         *       TMath::DegToRad());
2001   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
2002                                  /                         fgkCarbonFiberSupportXAxisLength);
2003   /////////////////////
2004   //Vertex Positioning
2005   ////////////////////
2006   vertexposition[0][0] = new TVector3();
2007   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
2008                                                                           fgkCarbonFiberSupportYAxisLength);
2009   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2010                                                                           carbonfibersupportxaxisEdgeproj
2011                                            *                      TMath::Tan(theta));
2012   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2013                                            -                      carbonfibersupportxaxisEdgeproj,
2014                                                                           fgkCarbonFiberSupportYAxisLength
2015                                            -                      vertexposition[0][2]->Y());
2016   ////////////////////////////////////////////////////
2017   //Setting the parameters for Isometry Transformation
2018   ////////////////////////////////////////////////////
2019   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2020                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2021                                                                  +      fgkCarbonFiberSupportWidth);
2022   Double_t* param = new Double_t[4]; 
2023   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2024   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2025                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2026                                                           (GetReflection(vertexposition[0][j],param))->Y());
2027   char* carbonfibersupportshapename[kshapesnumber] = 
2028                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2029   char* carbonfibersupportname[kshapesnumber] = 
2030                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2031   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2032   TGeoVolume* carbonfibersupport[kshapesnumber];
2033   TList* carbonfibersupportlist = new TList();
2034   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2035   Double_t carbonfibersupportheight = 
2036           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2037           *TMath::DegToRad());
2038   for(Int_t i = 0; i< kshapesnumber; i++){
2039    carbonfibersupportshape[i] = 
2040                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2041                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2042    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2043                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2044    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2045    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2046    }
2047   /////////////////////////////////////////////////////////////
2048   // Deallocating memory
2049   /////////////////////////////////////////////////////////////
2050   for(Int_t i=0; i< kshapesnumber; i++){
2051      for(Int_t j=0; j< kvertexnumber; j++)
2052            delete vertexposition[i][j];
2053        delete [] vertexposition[i];
2054   }
2055   delete [] param;
2056   /////////////////////////////////////////////////////////////
2057    return carbonfibersupportlist;
2058 }
2059 /////////////////////////////////////////////////////////////////////////////////
2060 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2061   /////////////////////////////////////////////////////////////
2062   // Method generating SSD Carbon Fiber Junction
2063   /////////////////////////////////////////////////////////////
2064   const Int_t kvertexnumber = 6;
2065   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2066   Double_t reflectionparam[3] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2067                                                           *  TMath::DegToRad()),-1.,0.};
2068   TVector3* vertex[kvertexnumber];
2069   vertex[0] = new TVector3();
2070   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2071                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2072                         *                         TMath::DegToRad()),
2073                                                   fgkCarbonFiberJunctionEdge[0]
2074                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2075                         *                         TMath::DegToRad()));
2076   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2077                                                    fgkCarbonFiberJunctionEdge[1]);
2078   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2079   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2080   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2081   Double_t xvertexpoints[6], yvertexpoints[6];
2082   for(Int_t i=0; i<kvertexnumber; i++) 
2083           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2084   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2085   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2086   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2087   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2088                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2089   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2090   /////////////////////////////////////////////////////////////
2091   // Deallocating memory
2092   /////////////////////////////////////////////////////////////
2093   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2094   ///////////////////////////////////////////////////////////// 
2095   return carbonfiberjunction;
2096 }
2097 ////////////////////////////////////////////////////////////////////////////////
2098 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2099   /////////////////////////////////////////////////////////////
2100   // Method generating the Carbon Fiber Lower Support   
2101   /////////////////////////////////////////////////////////////  
2102   const Int_t kvertexnumber = 4;
2103   const Int_t kshapesnumber = 2;
2104   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2105                                                                 fgkCarbonFiberLowerSupportWidth};
2106   TVector3** vertexposition[kshapesnumber];
2107   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2108                                                  new TVector3*[kvertexnumber];
2109   //First Shape Vertex Positioning
2110   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2111   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2112                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2113   vertexposition[0][2] = new TVector3();
2114   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2115   //Second Shape Vertex Positioning
2116   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2117                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2118                                  /                              fgkCarbonFiberTriangleLength);
2119   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2120                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2121                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2122   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2123                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2124                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2125   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2126   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2127                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2128   char* carbonfiberlowersupportshapename[kshapesnumber] = 
2129                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2130   char* carbonfiberlowersupportname[kshapesnumber] = 
2131                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2132   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2133   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2134   TList* carbonfiberlowersupportlist = new TList();
2135   for(Int_t i = 0; i< kshapesnumber; i++){ 
2136         carbonfiberlowersupportshape[i] = 
2137                                                                 GetArbShape(vertexposition[i],width,
2138                                                                                         fgkCarbonFiberLowerSupportHeight,
2139                                                                                         carbonfiberlowersupportshapename[i]);
2140     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2141                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2142         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2143     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2144   }
2145   /////////////////////////////////////////////////////////////
2146   // Deallocating memory
2147   /////////////////////////////////////////////////////////////
2148   for(Int_t i=0; i< kshapesnumber; i++){
2149      for(Int_t j=0; j< kvertexnumber; j++)
2150            delete vertexposition[i][j];
2151        delete [] vertexposition[i];
2152   }
2153   /////////////////////////////////////////////////////////////
2154   return carbonfiberlowersupportlist;
2155 }
2156 ///////////////////////////////////////////////////////////////////////////////
2157 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2158                                                                  Double_t width, Double_t* thickness)const{
2159   /////////////////////////////////////////////////////////////
2160   // Method generating the Sensor Support   
2161   /////////////////////////////////////////////////////////////  
2162         const Int_t kvertexnumber = 6;
2163         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2164     TVector3* vertexposition[kvertexnumber];
2165         vertexposition[0] = new TVector3();     
2166         vertexposition[1] = new TVector3(0.0,length);   
2167         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2168         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2169         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2170         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2171         Double_t xvertexpoints[6], yvertexpoints[6];
2172         for(Int_t i=0; i<kvertexnumber; i++) 
2173                 xvertexpoints[i] = vertexposition[i]->X(), 
2174                 yvertexpoints[i] = vertexposition[i]->Y();
2175     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2176     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2177     ssdsensorsupportshape->DefineSection(1,0.5*width);
2178     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2179                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2180   /////////////////////////////////////////////////////////////
2181   // Deallocating memory
2182   /////////////////////////////////////////////////////////////
2183         for (Int_t i=0; i<kvertexnumber; i++)
2184                 delete vertexposition[i];
2185   /////////////////////////////////////////////////////////////
2186     return ssdsensorsupport;
2187 }
2188 ////////////////////////////////////////////////////////////////////////////////
2189 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2190   /////////////////////////////////////////////////////////////
2191   // Method generating the Cooling Tube Support
2192   /////////////////////////////////////////////////////////////
2193   if(nedges%2!=0) nedges--;     
2194   const Int_t kvertexnumber = nedges+5;
2195   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2196                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2197   Double_t angle = 90.+phi;
2198   Double_t psi = 90.-phi;
2199   ///////////////////////////////////////
2200   // Vertex Positioning for TGeoXTru
2201   ///////////////////////////////////////
2202   TVector3** vertexposition = new TVector3*[kvertexnumber];
2203   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2204                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2205   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2206                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2207   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2208                                                                    fgkCoolingTubeSupportRmax);
2209   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2210                                                                    fgkCoolingTubeSupportRmax);
2211   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2212                                                                     vertexposition[1]->Y());
2213   for(Int_t i=0; i<nedges; i++)
2214         vertexposition[i+5] = 
2215                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2216                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2217   ///////////////////////////////////////////////////////////////////////
2218   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2219   ///////////////////////////////////////////////////////////////////////
2220   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2221   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2222   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2223   for(Int_t i=0; i<kvertexnumber; i++){
2224         xvertexpoints[i] = vertexposition[i]->X();
2225         yvertexpoints[i] = vertexposition[i]->Y();
2226   } 
2227   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2228                                                                                         yvertexpoints);
2229   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2230   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2231   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2232                                                                           coolingtubesupportarcshape,
2233                                                                                   fSSDTubeHolderMedium);
2234   coolingtubesupportarc->SetLineColor(fColorG10);
2235   //////////////////////////////////////////////////////////////////////////
2236   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2237   //////////////////////////////////////////////////////////////////////////
2238   TGeoTubeSeg* coolingtubesupportsegshape = 
2239                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2240                                                                                         fgkCoolingTubeSupportRmax,
2241                                                                                         0.5*fgkCoolingTubeSupportWidth,
2242                                                                                         phi,360-phi);
2243   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2244                                                                                         coolingtubesupportsegshape,
2245                                                                                         fSSDTubeHolderMedium);
2246   coolingtubesupportseg->SetLineColor(fColorG10);
2247   //////////////////////////////////////////////////////////////////////////
2248   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2249   //////////////////////////////////////////////////////////////////////////
2250   Double_t* boxorigin = new Double_t[3];
2251   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2252   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2253   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2254                                                                                  0.5*fgkCoolingTubeSupportHeight,
2255                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2256   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2257                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2258   coolingtubesupportbox->SetLineColor(fColorG10);
2259   //////////////////////////////////////////////////////////////////////////
2260   // Cooling Tube for Cooling Tube Support 
2261   //////////////////////////////////////////////////////////////////////////
2262   TGeoXtru* coolingtubearcshape[2];
2263   coolingtubearcshape[0] = new TGeoXtru(2);     
2264   Double_t* xvert = new Double_t[nedges+2];
2265   Double_t* yvert = new Double_t[nedges+2];
2266   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2267   ////////////////////////////////////////
2268   // Positioning the vertices for TGeoXTru
2269   ////////////////////////////////////////
2270   xvert[0] = 0., yvert[0] = 0.;
2271   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2272   for(Int_t i=0; i< nedges; i++)
2273                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2274                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2275   ////////////////////////////////////////
2276   // Defining TGeoXTru PolyGone
2277   ////////////////////////////////////////
2278   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2279   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2280   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2281   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2282                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2283   TGeoVolume* coolingtubearc[2];
2284   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2285                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2286   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2287                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2288   coolingtubearc[0]->SetLineColor(fColorWater);
2289   coolingtubearc[1]->SetLineColor(fColorPhynox);
2290   ////////////////////////////////////////////
2291   // Defining TGeoTubeSeg Part of Cooling Tube
2292   ////////////////////////////////////////////
2293   TGeoTubeSeg* coolingtubesegshape[2];
2294   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2295                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2296   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2297                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2298   TGeoVolume* coolingtubeseg[2];
2299   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2300                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2301   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2302                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2303   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2304   coolingtubeseg[1]->SetLineColor(fColorWater);
2305   /////////////////////////////////////////////////////////////
2306   // Virtual Volume containing Cooling Tube Support  
2307   /////////////////////////////////////////////////////////////
2308   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2309   const Int_t kvirtualvertexnumber = 8;
2310   TVector3* virtualvertex[kvirtualvertexnumber];
2311    ////////////////////////////////////////
2312   // Positioning the vertices for TGeoXTru
2313   ////////////////////////////////////////
2314   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2315   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2316   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2317   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2318   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2319   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2320   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2321   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2322   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2323   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2324         xmothervertex[i] = virtualvertex[i]->X(),
2325         ymothervertex[i] = virtualvertex[i]->Y();
2326   ////////////////////////////////////////
2327   // Defining TGeoXTru PolyGone
2328   ////////////////////////////////////////
2329   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2330                                                                                                                                          ymothervertex);
2331   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2332   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2333   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2334                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2335   ////////////////////////////////////////
2336   // Positioning Volumes in Virtual Volume
2337   ////////////////////////////////////////
2338   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2339   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2340   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2341   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2342   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2343   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2344   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2345   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2346   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2347   /////////////////////////////////////////////////////////////
2348   // Deallocating memory
2349   /////////////////////////////////////////////////////////////
2350   delete [] vertexposition;
2351   delete xvertexpoints;
2352   delete yvertexpoints;
2353   delete xvert;
2354   delete yvert;
2355   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2356         delete virtualvertex[i];
2357   /////////////////////////////////////////////////////////////
2358         return virtualcoolingtubesupport;
2359 }
2360 /////////////////////////////////////////////////////////////////////////////////
2361 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2362   /////////////////////////////////////////////////////////////
2363   // Method generating List containing SSD Hybrid Components   
2364   /////////////////////////////////////////////////////////////
2365   TList* ssdhybridlist = new TList();
2366   const Int_t kssdstiffenernumber = 2;
2367   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2368                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2369                                                                   -    fgkSSDStiffenerWidth;
2370   Double_t ssdchipcablesradius[kssdstiffenernumber];
2371   for(Int_t i=0; i<kssdstiffenernumber; i++)
2372           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2373                                -  fgkSSDChipCablesHeight[0]
2374                                -  fgkSSDChipCablesHeight[1]);
2375   /////////////////////////////////////////////////////////////
2376   // Mother Volumes Containers 
2377   /////////////////////////////////////////////////////////////
2378   const Int_t kmothernumber = 2;
2379   const Int_t kmothervertexnumber = 12;
2380   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2381   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2382   ///////////////////////
2383   // Setting the vertices 
2384   ///////////////////////
2385   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2386   xmothervertex[0][1]  = xmothervertex[0][0]; 
2387   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2388   xmothervertex[0][3]  = xmothervertex[0][2];
2389   xmothervertex[0][4]  = xmothervertex[0][0];
2390   xmothervertex[0][5]  = xmothervertex[0][4];
2391   xmothervertex[0][6]  = -xmothervertex[0][0];
2392   xmothervertex[0][7]  = xmothervertex[0][6];
2393   xmothervertex[0][8]  = -xmothervertex[0][2];
2394   xmothervertex[0][9]  = xmothervertex[0][8];
2395   xmothervertex[0][10] = xmothervertex[0][7];
2396   xmothervertex[0][11] = xmothervertex[0][10];
2397   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2398   for(Int_t i = 0; i<kmothernumber; i++){
2399       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2400                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2401       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2402       ymothervertex[i][2]  = ymothervertex[i][1];
2403       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2404       ymothervertex[i][4]  = ymothervertex[i][3];
2405       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2406       ymothervertex[i][6]  = ymothervertex[i][5];
2407       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2408       ymothervertex[i][8]  = ymothervertex[i][7];
2409       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2410       ymothervertex[i][10] = ymothervertex[i][9];
2411       ymothervertex[i][11] = ymothervertex[i][0];
2412   }
2413   TGeoXtru* ssdhybridmothershape[kmothernumber];
2414 //  TGeoVolume* ssdhybridmother[kmothernumber];
2415   TGeoVolumeAssembly* ssdhybridmother[kmothernumber];
2416   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2417   for(Int_t i=0; i<kmothernumber; i++){
2418       ssdhybridmothershape[i] = new TGeoXtru(2);
2419       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2420                                           ymothervertex[i]);
2421       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2422                                                -fgkSSDChipCablesHeight[i+2]);
2423       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2424 //      ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2425 //                                          fSSDAir);
2426       ssdhybridmother[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2427    }   
2428   /////////////////////////////////////////////////////////////
2429   // SSD Stiffener   
2430   /////////////////////////////////////////////////////////////
2431   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2432                                              0.5*fgkSSDStiffenerLength,
2433                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2434                                              0.5*fgkSSDStiffenerHeight);
2435   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2436                                             fSSDStiffenerMedium);  
2437   ssdstiffener->SetLineColor(fColorStiffener); 
2438   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2439   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2440       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2441   /////////////////////////////////////////////////////////////
2442   // SSD Chip System    
2443   /////////////////////////////////////////////////////////////
2444   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2445   Double_t ssdchipseparation = fgkSSDSensorLength
2446                              - 2.*fgkSSDModuleStiffenerPosition[1]
2447                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2448                              - 0.5*fgkSSDChipWidth);
2449   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2450                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2451   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2452                                       - 0.5*ssdchipsystemlength,
2453                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2454                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2455 ////////////////////////////
2456 // Capacitor 0603-2200 nF
2457 ///////////////////////////
2458   const Int_t knapacitor0603number = 5;
2459   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2460                                                                                          0.5*fgkSSDCapacitor0603Length,
2461                                                                                          0.5*(fgkSSDCapacitor0603Width),
2462                                                                                          0.5*fgkSSDCapacitor0603Height);
2463   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2464                                              fSSDStiffener0603CapacitorMedium); 
2465   capacitor0603->SetLineColor(fColorAl);
2466   for(Int_t i=0; i<kmothernumber; i++){
2467       for(Int_t j=0; j<kssdstiffenernumber; j++){
2468             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2469             for(Int_t k=1; k<knapacitor0603number+1; k++){
2470                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2471                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2472                                            j*ssdstiffenerseparation
2473                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2474                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2475                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2476             }
2477       } 
2478       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2479       ssdhybridlist->Add(ssdhybridmother[i]);
2480   }    
2481 /////////////////////////////////////////////////////////////
2482 // Mother Volume Containing Capacitor Part 
2483 /////////////////////////////////////////////////////////////
2484   const Int_t kcapacitormothernumber = 8;
2485   Double_t xcapacitorvertex[kcapacitormothernumber];
2486   Double_t ycapacitorvertex[kcapacitormothernumber];  
2487   ///////////////////////
2488   // Setting the vertices 
2489   ///////////////////////
2490   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2491   xcapacitorvertex[1] = xcapacitorvertex[0];   
2492   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2493   xcapacitorvertex[3] = xcapacitorvertex[2];   
2494   xcapacitorvertex[4] = xcapacitorvertex[0];   
2495   xcapacitorvertex[5] = xcapacitorvertex[0];   
2496   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2497   xcapacitorvertex[7] = xcapacitorvertex[6];   
2498   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2499   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2500   ycapacitorvertex[2] = ycapacitorvertex[1];   
2501   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2502   ycapacitorvertex[4] = ycapacitorvertex[3];   
2503   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2504   ycapacitorvertex[6] = ycapacitorvertex[5];   
2505   ycapacitorvertex[7] = ycapacitorvertex[0];   
2506   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2507   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2508                                               ycapacitorvertex);
2509   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2510   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2511 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2512 //                                          fSSDAir);
2513   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2514 ////////////////////////////
2515 // Connector 
2516 ///////////////////////////
2517   const Int_t kssdconnectornumber = 2;
2518   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2519   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2520   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2521                                    +  fgkSSDConnectorAlHeight};  
2522   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2523   TGeoVolume* ssdconnector[kssdconnectornumber];
2524   for(Int_t i=0; i<kssdconnectornumber; i++){
2525       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2526                                           0.5*fgkSSDConnectorWidth,
2527                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2528                            +              i*fgkSSDConnectorNiHeight),
2529                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2530       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2531                                        i==0 ? fSSDAlTraceFlexMedium 
2532                                             : fSSDStiffenerConnectorMedium);      
2533       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2534   }
2535   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2536   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2537                        +  fgkSSDConnectorPosition[0]
2538                        -  fgkSSDConnectorSeparation
2539                        -  1.5*fgkSSDConnectorLength,
2540                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2541                        -  fgkSSDConnectorPosition[1]
2542                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2543   ssdconnectortrans[1] = new TGeoTranslation(
2544                        -  ssdstiffenershape->GetDX()
2545                        +  fgkSSDConnectorPosition[0]
2546                        -  0.5*fgkSSDConnectorLength,
2547                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2548                        -  fgkSSDConnectorPosition[1]
2549                        -  ssdconnectorshape[0]->GetDY(),0.0);
2550   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2551                        -  fgkSSDConnectorPosition[0]
2552                        +  fgkSSDConnectorSeparation
2553                        +  1.5*fgkSSDConnectorLength,
2554                           -(ssdstiffenershape->GetDY()
2555                        -  fgkSSDConnectorPosition[1]
2556                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2557   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2558                        -  fgkSSDConnectorPosition[0]
2559                        +  0.5*fgkSSDConnectorLength,
2560                           -(ssdstiffenershape->GetDY()
2561                        -  fgkSSDConnectorPosition[1]
2562                        -  ssdconnectorshape[0]->GetDY()),0.0);
2563   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2564       for(Int_t j=0; j<kssdconnectornumber; j++)
2565             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2566 ////////////////////////////
2567 // Capacitor 1812-330 nF
2568 /////////////////////////// 
2569   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2570   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2571                                                                                          0.5*fgkSSDCapacitor1812Length,
2572                                                                                          0.5*fgkSSDCapacitor1812Width,
2573                                                                                          0.5*fgkSSDCapacitor1812Height,
2574             ssdcapacitor1812origin);
2575   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2576                                              fSSDStiffener1812CapacitorMedium); 
2577   capacitor1812->SetLineColor(fColorAl);
2578   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2579                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2580                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2581   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2582 ////////////////////////////
2583 //Hybrid Wire
2584 ////////////////////////////
2585   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2586                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2587                                  - fgkSSDConnectorSeparation;
2588   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2589                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2590   Double_t ssdwireradius = TMath::Sqrt(TMath::Power(wirex,2.)
2591                                          + TMath::Power(wirey,2));
2592   Double_t wireangle = TMath::ATan(wirex/wirey);
2593   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2594                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2595   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2596                                              fSSDStiffenerHybridWireMedium); 
2597   hybridwire->SetLineColor(fColorPhynox);
2598   TGeoCombiTrans* hybridwirecombitrans[2];
2599   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2600                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2601                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2602                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2603                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2604                                    ssdstiffenershape->GetDZ()
2605                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2606                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2607   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2608                             0.0,
2609                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2610                             0.0,        
2611                             new TGeoRotation("HybridWireRot2",
2612                           - wireangle*TMath::RadToDeg(),0.,0.));
2613   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2614   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2615   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2616   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2617   ssdhybridlist->Add(ssdhybridcapacitormother);
2618   /////////////////////////////////////////////////////////////
2619   // Deallocating memory
2620   /////////////////////////////////////////////////////////////
2621   delete hybridwirecombitrans[0];
2622   delete hybridwirecombitrans[1];
2623   delete ssdchipsystemlist;
2624   return ssdhybridlist;
2625   /////////////////////////////////////////////////////////////
2626 }
2627 ///////////////////////////////////////////////////////////////////////////////
2628 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2629   /////////////////////////////////////////////////////////////
2630   // SSD Cooling Block System
2631   /////////////////////////////////////////////////////////////
2632   // SSD Cooling Block and Cooling Tube Transformations
2633   /////////////////////////////////////////////////////////////
2634   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2635   localcoolingblockrot->SetAngles(0.,90.,0.);
2636   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2637   TVector3* coolingblocktransvector;
2638   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2639                                                                 + fgkSSDCoolingBlockLength,
2640                                                                   fgkSSDSensorLength
2641                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2642                                                                 - fgkSSDCoolingBlockWidth);
2643   const Int_t kcoolingblocktransnumber = 2;
2644   const Int_t kcoolingblocknumber = 4;
2645   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2646   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2647   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2648   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2649   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2650   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2651                                         0.5*fgkSSDCoolingBlockWidth,
2652                                         fgkSSDCoolingBlockHoleCenter);
2653   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2654   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2655   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2656     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2657       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2658                                              j*coolingblocktransvector->Y(),
2659                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2660                                                     + fgkCoolingTubeRmax));
2661       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2662       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2663     }
2664   }
2665   /////////////////////////////////////////////////////////////
2666   // Virtual Volume containing CoolingBlock System   
2667   /////////////////////////////////////////////////////////////
2668   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2669   const Int_t kmothervertexnumber = 16;  
2670   Double_t xmothervertex[kmothervertexnumber];
2671   Double_t ymothervertex[kmothervertexnumber];
2672   ///////////////////////
2673   // Setting the vertices 
2674   ///////////////////////fgkCoolingTubeSupportRmax
2675   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2676   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2677                                    + fgkSSDCoolingBlockWidth;
2678   xmothervertex[2] = coolingblocktransvector->X()
2679                                    + fgkSSDCoolingBlockLength
2680                                    + 4*coolingtubedistance;
2681   ymothervertex[2] = ymothervertex[1];
2682   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2683   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2684   ymothervertex[4] = ymothervertex[0];
2685   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2686   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2687   ymothervertex[6] = ymothervertex[5]; 
2688   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2689                                    - fgkSSDCoolingBlockWidth; 
2690   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2691   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2692                                    - coolingtubedistance;
2693   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2694   ymothervertex[10] = ymothervertex[9];
2695   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2696   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2697   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2698   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2699   ymothervertex[14] = ymothervertex[13];
2700   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2701   //////////////////////////////////////////////////////////
2702   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2703                                                                         xmothervertex,ymothervertex);
2704   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2705                                                                                            + fgkCoolingTubeRmax));
2706   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2707                                                                                            + fgkCoolingTubeRmax));
2708   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2709 //  TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2710 //                                                        coolingsystemothershape,fSSDAir);
2711   /////////////////////////////////////////////////////////////
2712   // SSD Cooling Tube Part 
2713   /////////////////////////////////////////////////////////////
2714   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2715   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2716                                                                                  0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance)); 
2717   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2718                                                                          0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance));
2719   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2720   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2721                                                                         fSSDCoolingTubePhynox);
2722   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2723                                                                         fSSDCoolingTubeWater);
2724   coolingtube[0]->SetLineColor(fColorPhynox);
2725   coolingtube[1]->SetLineColor(fColorWater);
2726   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2727   /////////////////////////////////////////////////////////////
2728   // Adding Cooling block to mother volume
2729   /////////////////////////////////////////////////////////////
2730    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2731         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2732         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2733         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2734   }
2735   /////////////////////////////////////////////////////////////
2736   // Deallocating memory
2737   /////////////////////////////////////////////////////////////
2738         delete coolingblocktransvector;
2739         delete localcoolingblockrot;
2740         delete localcoolingtubetrans;
2741         delete localcoolingtuberot;
2742   /////////////////////////////////////////////////////////////
2743   // Checking overlaps  
2744   /////////////////////////////////////////////////////////////
2745         //coolingsystemother->CheckOverlaps(0.01);
2746   /////////////////////////////////////////////////////////////
2747         return coolingsystemother;
2748 }
2749 /////////////////////////////////////////////////////////////////////////////////
2750 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2751   /////////////////////////////////////////////////////////////
2752   // SSD Flex
2753   /////////////////////////////////////////////////////////////
2754   const Int_t kssdflexlayernumber = 2;
2755   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2756   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2757   const Int_t kmothervertexnumber = 17; 
2758   Double_t xmothervertex[kmothervertexnumber];
2759   Double_t ymothervertex[kmothervertexnumber];
2760   /////////////////////////////////////////////
2761   // Auxiliary variables for vertex positioning
2762   /////////////////////////////////////////////
2763   const Int_t kssdflexboxnumber = 5;
2764   Double_t ssdflexboxlength[kssdflexboxnumber];
2765   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2766                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2767                                           *     fgkSSDChipSeparationLength
2768                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2769                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2770   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2771   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2772                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2773   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2774   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2775                                           -     ssdflexboxlength[1];
2776   Double_t ssdflexboxwidth[kssdflexboxnumber];
2777   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2778   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2779   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2780   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2781   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2782   ///////////////////////
2783   // Setting the vertices 
2784   ///////////////////////
2785   xmothervertex[0]  = 0.0;
2786   xmothervertex[1]  = xmothervertex[0];
2787   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2788   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2789                                         + ssdflexboxlength[4];
2790   xmothervertex[4]  = xmothervertex[3];
2791   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2792   xmothervertex[6]  = xmothervertex[5];
2793   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2794   xmothervertex[8]  = xmothervertex[7];
2795   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2796   xmothervertex[10] = xmothervertex[9]; 
2797   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2798   xmothervertex[12] = xmothervertex[11];
2799   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2800   xmothervertex[14] = xmothervertex[13];
2801   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2802   xmothervertex[16] = xmothervertex[15];
2803   ymothervertex[0]  = 0.0;
2804   ymothervertex[1]  = fgkSSDFlexWidth[1];
2805   ymothervertex[2]  = fgkSSDFlexWidth[0];
2806   ymothervertex[3]  = ymothervertex[2];
2807   ymothervertex[4]  = ymothervertex[0];
2808   ymothervertex[5]  = ymothervertex[4];
2809   ymothervertex[6]  = ssdflexboxwidth[2];
2810   ymothervertex[7]  = ymothervertex[6];
2811   ymothervertex[8]  = ymothervertex[0];
2812   ymothervertex[9]  = ymothervertex[8];
2813   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2814   ymothervertex[11] = ymothervertex[10];
2815   ymothervertex[12] = ymothervertex[0];
2816   ymothervertex[13] = ymothervertex[12];
2817   ymothervertex[14] = ymothervertex[7];
2818   ymothervertex[15] = ymothervertex[14];
2819   ymothervertex[16] = ymothervertex[0];
2820   /////////////////////////////////////////////////////////////
2821   // First Mother Volume containing SSDFlex
2822   /////////////////////////////////////////////////////////////
2823   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2824   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2825                                                                     ymothervertex);
2826   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2827   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2828   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2829 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2830 //                                                                                       fSSDAir);
2831   /////////////////////////////////////////////////////////////
2832   // SSDFlex Layer Shapes
2833   /////////////////////////////////////////////////////////////
2834   for(Int_t i=0; i<kssdflexlayernumber; i++){
2835         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2836                                                                    ymothervertex);
2837     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2838         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2839   }
2840   /////////////////////////////////////
2841   // Setting Layers into Mother Volume
2842   /////////////////////////////////////
2843   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2844   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2845                                                                                                  fSSDKaptonFlexMedium};
2846   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2847                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2848   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2849   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2850   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2851         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2852                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2853                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2854         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2855     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2856                                          +                                         fgkSSDFlexHeight[1])); 
2857     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2858   }
2859   return ssdflexmother;
2860 }
2861 /////////////////////////////////////////////////////////////////////////////////
2862 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2863   /////////////////////////////////////////////////////////////
2864   // Method generating SSD End Flex   
2865   /////////////////////////////////////////
2866   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2867                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2868   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2869                                                 * TMath::DegToRad()*ssdflexradiusmax
2870                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2871                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
2872   const Int_t knedges = 20;  
2873   const Int_t karcnumber = 2;
2874   TVector3* vertexposition[karcnumber*(knedges+1)];
2875   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2876   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2877   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2878   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2879                                                                                  - 90.0*TMath::DegToRad()};
2880   TVector3* referencetrans[karcnumber];
2881   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2882                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2883                                                                    radius[0]);
2884   referencetrans[1] = new TVector3(referencetrans[0]->X()
2885                                         +              fgkSSDFlexLength[2],
2886      -              fgkSSDStiffenerHeight);
2887 for(Int_t i=0; i<karcnumber; i++){
2888         for(Int_t j=0; j<knedges+1; j++){
2889                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2890                                                                                                radius[i]*SinD(angle[i]));
2891                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2892         }       
2893   }
2894   ///////////////////////
2895   // Setting the vertices 
2896   ///////////////////////
2897   const Int_t kendflexlayernumber = 4;
2898   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2899   TVector3** vertex[kendflexlayernumber];
2900   for(Int_t i=0; i<kendflexlayernumber; i++) 
2901                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2902   TVector3* transvector[kendflexlayernumber+1];
2903   TVector3* deltatransvector = new TVector3();  
2904   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2905   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2906                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2907   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2908         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2909                                         *                 CosD(fgkSSDFlexAngle),
2910                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2911                                         *         SinD(fgkSSDFlexAngle),0.0);   
2912         *transvector[i] = *transvector[i-1]+*deltatransvector;
2913   }
2914   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2915   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2916   for(Int_t i=0; i<karcnumber; i++){
2917         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2918                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2919                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2920                                               /radius[i];
2921         }
2922   }
2923   for(Int_t i=0; i<kendflexlayernumber; i++){
2924         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2925         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2926         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2927                 if(j<(knedges+1)){
2928                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2929                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2930                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2931                         *vertex[i][j+2] += *referencetrans[0];
2932                         vertex[i][4*(knedges+1)-j+1] = 
2933                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2934                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2935                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2936                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2937                 }
2938                 else{
2939                 
2940                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2941                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2942                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2943                         *vertex[i][j+2] += *referencetrans[1];
2944                         vertex[i][4*(knedges+1)-j+1] = 
2945                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2946                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2947                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2948                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2949            }
2950         }
2951   }
2952   /////////////////////////////////////////////////////////////
2953   // First Mother Volume containing SSDEndFlex
2954   /////////////////////////////////////////////////////////////
2955   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2956   Double_t xmothervertex[kendflexvertexnumber];
2957   Double_t ymothervertex[kendflexvertexnumber];
2958   xmothervertex[0] = vertex[0][0]->X(); 
2959   ymothervertex[0] = vertex[0][0]->Y();
2960   for(Int_t i=1; i<kendflexvertexnumber; i++){
2961         if(i<2*(knedges+1)+2){
2962                 xmothervertex[i] = vertex[3][i]->X();
2963                 ymothervertex[i] = vertex[3][i]->Y();
2964         }
2965         else{
2966                 xmothervertex[i] = vertex[0][i]->X();
2967                 ymothervertex[i] = vertex[0][i]->Y();
2968         }
2969   }
2970   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2971                                                                            xmothervertex,ymothervertex);
2972   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2973   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2974   TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2975                                                                  ssdendflexmothershape,fSSDAir);        
2976   //////////////////////////////////////
2977   // End Flex TGeoXtru Layer Definition 
2978   //////////////////////////////////////
2979   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2980   TGeoVolume* ssdendflex[kendflexlayernumber];
2981   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2982   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2983   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2984   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2985   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2986                                                                                                         fSSDKaptonFlexMedium};
2987   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2988                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2989   for(Int_t i=0; i<kendflexlayernumber; i++){
2990         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2991                 xvertex[i][j] = vertex[i][j]->X();
2992                 yvertex[i][j] = vertex[i][j]->Y();
2993         }
2994   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2995   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2996   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2997   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2998                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2999   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
3000   ssdendflexmother->AddNode(ssdendflex[i],1);
3001   }
3002   /////////////////////////////////////////////////////////////
3003   // Deallocating memory
3004   /////////////////////////////////////////////////////////////
3005   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
3006   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
3007   for(Int_t i=0; i<kendflexlayernumber; i++){
3008         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
3009         delete [] vertex[i];
3010   }
3011   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
3012   delete deltatransvector;
3013   /////////////////////////////////////////////////////////////
3014   //ssdendflexmother->CheckOverlaps(0.01);
3015   return ssdendflexmother;
3016 }
3017 ///////////////////////////////////////////////////////////////////////////////
3018 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3019   /////////////////////////////////////////////////////////////
3020   // Method generating the Mounting Block
3021   /////////////////////////////////////////////////////////////  
3022   const Int_t kvertexnumber = 8;
3023   Double_t xvertex[kvertexnumber];
3024   Double_t yvertex[kvertexnumber];
3025   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3026   xvertex[1] = xvertex[0];
3027   xvertex[2] = -xvertex[0];
3028   xvertex[3] = xvertex[2];
3029   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3030                          -                                 fgkSSDMountingBlockLength[2]);
3031   xvertex[5] = xvertex[4];
3032   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3033                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3034                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3035   xvertex[7] = xvertex[6];
3036   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3037                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3038                          -  fgkSSDModuleVerticalDisalignment;
3039   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3040   yvertex[2] = yvertex[1]; 
3041   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3042   yvertex[4] = yvertex[3];
3043   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3044                          - fgkSSDMountingBlockHeight[0];
3045   yvertex[6] = yvertex[5];
3046   yvertex[7] = yvertex[0];
3047   ///////////////////////////////////////////////////////////////////////
3048   // TGeoXTru Volume definition for Mounting Block Part
3049   ///////////////////////////////////////////////////////////////////////
3050   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3051   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3052   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3053   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3054   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3055                                                                           ssdmountingblockshape,
3056                                                                                   fSSDMountingBlockMedium);
3057   ssdmountingblock->SetLineColor(fColorG10);
3058   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3059   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3060   TGeoRotation* mountingblockrot = new TGeoRotation();
3061   mountingblockrot->SetAngles(90.,180.,-90.);
3062   mountingblockcombitrans->SetRotation(*mountingblockrot);
3063   /////////////////////////////////////////////////////////////
3064   // Generating the Mounting Block Screw Vertices 
3065   /////////////////////////////////////////////////////////////  
3066   const Int_t kscrewvertexnumber = 15;
3067   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3068                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3069                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3070                                  * TMath::RadToDeg();
3071   Double_t phi0 = 90.+alpha;
3072   Double_t phi = 270.-2*alpha;
3073   Double_t deltaphi = phi/kscrewvertexnumber;   
3074   TVector3* screwvertex[kscrewvertexnumber+1];
3075   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3076         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3077                                    *CosD(phi0+i*deltaphi),
3078                                    fgkSSDMountingBlockScrewHoleRadius[0]
3079                                    *SinD(phi0+i*deltaphi));
3080   Double_t xscrewvertex[kscrewvertexnumber+6];
3081   Double_t yscrewvertex[kscrewvertexnumber+6];
3082   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3083   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3084                                   -               fgkSSDMountingBlockScrewHoleEdge);
3085   xscrewvertex[1] = xscrewvertex[0];
3086   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3087   xscrewvertex[2] = screwvertex[0]->X();
3088   yscrewvertex[2] = yscrewvertex[1];
3089   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3090         xscrewvertex[i+3] = screwvertex[i]->X();        
3091         yscrewvertex[i+3] = screwvertex[i]->Y();        
3092   } 
3093   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3094   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3095   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3096   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3097   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3098   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3099   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3100   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3101                                                         +                                  fgkSSDMountingBlockHeight[2]);
3102   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3103                                                                                 ssdmountingblockscrewshape,
3104                                                                                             fSSDMountingBlockMedium);
3105   ssdmountingblockscrew->SetLineColor(fColorG10);
3106   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3107   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3108   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3109                                                                         -                                yscrewvertex[1],
3110                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3111                                                                         -                                fgkSSDMountingBlockHeight[2]
3112                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3113                                                                         +                                fgkSSDMountingBlockHeight[2]
3114                                                                         -                                yvertex[0]));
3115   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3116                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3117                                                                                                                  yscrewvertex[1]
3118                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3119                                                                                                          +fgkSSDMountingBlockHeight[2]
3120                                                                                                          -yvertex[0]));
3121   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3122                                                                                                           yscrewvertex[1],
3123                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3124                                                                         +                                 fgkSSDMountingBlockHeight[2]
3125                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3126                                                                         +                                 fgkSSDMountingBlockHeight[2]
3127                                                                         -                                 yvertex[0]));
3128   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3129                                                                                                          yscrewvertex[1],
3130                                                                         -                                yscrewvertex[1]
3131                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3132                                                                         +                                fgkSSDMountingBlockHeight[2]
3133                                                                         -                                yvertex[0]));
3134   TGeoRotation* ssdmountingblockscrewrot[4];
3135   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3136         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3137     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3138     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3139   for(Int_t i=1; i<4; i++) 
3140         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3141   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3142   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3143   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3144   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3145                                                          +                                xvertex[0],yscrewvertex[1]
3146                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3147                                                          +                                fgkSSDMountingBlockHeight[2]
3148                                                          -                                yvertex[0]),0.);      
3149   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3150   for(Int_t i=0; i<4; i++){
3151         ssdmountingblockscrewmatrix[i] = 
3152                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3153         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3154   }
3155   ///////////////////////////////////////////////////////////////////////
3156   // TGeoXtru for Mother Volume 
3157   ///////////////////////////////////////////////////////////////////////
3158   const Int_t kvertexmothernumber = 12;
3159   Double_t xmothervertex[kvertexmothernumber];
3160   Double_t ymothervertex[kvertexmothernumber];
3161   for(Int_t i=0; i<6; i++){
3162         xmothervertex[i] = xvertex[i];
3163         ymothervertex[i] = yvertex[i];
3164   } 
3165   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3166   ymothervertex[6]  = ymothervertex[5];
3167   xmothervertex[7]  = xmothervertex[6];
3168   ymothervertex[7]  = ymothervertex[4];
3169   xmothervertex[8]  = xmothervertex[7]
3170                                         + 0.5*(fgkSSDMountingBlockLength[1]
3171                                         -          fgkSSDMountingBlockLength[2]);
3172   ymothervertex[8]  = ymothervertex[4];
3173   xmothervertex[9]  = xmothervertex[8];
3174   ymothervertex[9]  = ymothervertex[2];
3175   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3176   ymothervertex[10] = ymothervertex[1];
3177   xmothervertex[11] = xmothervertex[10];
3178   ymothervertex[11] = ymothervertex[0];  
3179   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3180   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3181   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3182   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3183   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3184                                                                           ssdmountingblockmothershape,
3185                                                                                   fSSDAir);
3186   /////////////////////////////////////////////////////////////
3187   // Placing the Volumes into Mother Volume 
3188   /////////////////////////////////////////////////////////////
3189   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3190   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3191   for(Int_t i=0; i<4; i++) 
3192         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3193                                                                         ssdmountingblockscrewmatrix[i]);
3194   /////////////////////////////////////////////////////////////
3195   // Deallocating memory
3196   /////////////////////////////////////////////////////////////
3197   delete mountingblockrot;
3198   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3199   delete ssdmountingblockglobalrot; 
3200   delete ssdmountingblockglobaltrans; 
3201   /////////////////////////////////////////////////////////////
3202   return ssdmountingblockmother;
3203 }
3204 ///////////////////////////////////////////////////////////////////////////////
3205  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3206   /////////////////////////////////////////////////////////////
3207   // Method generating the Mounting Block Clip 
3208   /////////////////////////////////////////////////////////////  
3209   const Int_t kmothervertexnumber = 10;
3210   Double_t xmothervertex[kmothervertexnumber];
3211   Double_t ymothervertex[kmothervertexnumber];
3212   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3213                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3214   xmothervertex[1] = xmothervertex[0];
3215   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3216                                    - fgkMountingBlockClibScrewRadius);
3217   xmothervertex[3] = xmothervertex[2]; 
3218   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3219   xmothervertex[5] = xmothervertex[4]; 
3220   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3221   xmothervertex[7] = xmothervertex[6]; 
3222   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3223   xmothervertex[9] = xmothervertex[8]; 
3224   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3225                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3226                                    - fgkSSDModuleVerticalDisalignment;
3227   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3228   ymothervertex[2] = ymothervertex[1];
3229   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3230                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3231                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3232   ymothervertex[4] = ymothervertex[3];
3233   ymothervertex[5] = ymothervertex[2];
3234   ymothervertex[6] = ymothervertex[5];
3235   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3236   ymothervertex[8] = ymothervertex[7];
3237   ymothervertex[9] = ymothervertex[0];
3238   ///////////////////////////////////////////////////////////////////////
3239   // TGeoXTru Volume definition for Mounting Block Clip Part
3240   ///////////////////////////////////////////////////////////////////////
3241   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3242   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3243   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3244   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3245   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3246                                                                           ssdmountingblockclipshape,fSSDAir);
3247   ssdmountingblockclip->SetLineColor(4);
3248   ///////////////////////////////////////////////////////////////////////
3249   // TGeoXTru Volume definition for Clip 
3250   ///////////////////////////////////////////////////////////////////////
3251   const Int_t kclipvertexnumber = 6;
3252   Double_t xclipvertex[kclipvertexnumber];
3253   Double_t yclipvertex[kclipvertexnumber];
3254   xclipvertex[0] = xmothervertex[0];
3255   xclipvertex[1] = xclipvertex[0];
3256   xclipvertex[2] = xmothervertex[6];
3257   xclipvertex[3] = xclipvertex[2];
3258   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3259   xclipvertex[5] = xclipvertex[4];
3260   yclipvertex[0] = ymothervertex[0];
3261   yclipvertex[1] = ymothervertex[1];
3262   yclipvertex[2] = yclipvertex[1];
3263   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3264   yclipvertex[4] = yclipvertex[3];
3265   yclipvertex[5] = yclipvertex[0];
3266   TGeoXtru* clipshape = new TGeoXtru(2);
3267   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3268   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3269   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3270                                                          +   fgkMountingBlockClibWidth);
3271   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3272   clip->SetLineColor(18);
3273   ///////////////////////////////////////////////////////////////////////
3274   // Ladder Support Piece  
3275   ///////////////////////////////////////////////////////////////////////
3276   const Int_t ksupportvertexnumber = 4;
3277   Double_t xsupportvertex[ksupportvertexnumber];
3278   Double_t ysupportvertex[ksupportvertexnumber];
3279   xsupportvertex[0] = xclipvertex[5];
3280   xsupportvertex[1] = xsupportvertex[0];
3281   xsupportvertex[2] = xmothervertex[9];
3282   xsupportvertex[3] = xsupportvertex[2];
3283   ysupportvertex[0] = yclipvertex[0];
3284   ysupportvertex[1] = yclipvertex[3];
3285   ysupportvertex[2] = ysupportvertex[1];
3286   ysupportvertex[3] = ysupportvertex[0];
3287   TGeoXtru* supportshape = new TGeoXtru(2);
3288   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3289   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3290   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3291   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3292   support->SetLineColor(9);
3293   ///////////////////////////////////////////////////////////////////////
3294   // TGeoXTru Volume definition for Screw   
3295   ///////////////////////////////////////////////////////////////////////
3296   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3297                                                 0.5*fgkMountingBlockClibScrewRadius};
3298   Int_t edgesnumber[2] = {50,6};
3299   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3300                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3301   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3302   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3303   clipscrew->SetLineColor(12);
3304   TGeoRotation* screwrot = new TGeoRotation();
3305   screwrot->SetAngles(0.,90.,0.);
3306   TGeoTranslation* screwtrans = new TGeoTranslation();
3307   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3308                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3309                                                          0.5*fgkSSDMountingBlockWidth+
3310                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3311   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3312   ///////////////////////////////////////////////////////////////////////
3313   // Placing the Volumes
3314   ///////////////////////////////////////////////////////////////////////
3315   ssdmountingblockclip->AddNode(clip,1);
3316   ssdmountingblockclip->AddNode(support,1);
3317   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3318   /////////////////////////////////////////////////////////////
3319   // Deallocating memory
3320   /////////////////////////////////////////////////////////////  
3321   delete screwtrans;
3322   delete screwrot;
3323   /////////////////////////////////////////////////////////////
3324   return ssdmountingblockclip;
3325 }
3326 ///////////////////////////////////////////////////////////////////////////////
3327 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3328   /////////////////////////////////////////////////////////////
3329   // Method generating the Cooling Tube 
3330   /////////////////////////////////////////////////////////////  
3331    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3332    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3333                                                                                                 new     TGeoTube*[2];
3334    // Ladder Cooling Tubes
3335    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3336                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3337                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth));
3338    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3339                                                                                  coolingtubeshape[0][0]->GetDz());
3340    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3341                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3342                                                   -                                       fgkSSDSensorOverlap));
3343    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3344                                                                                  coolingtubeshape[1][0]->GetDz());
3345    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3346                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]));
3347    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3348                                                                                  coolingtubeshape[2][0]->GetDz());
3349    // End Ladder Cooling Tubes  
3350    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3351    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3352    endladdercoolingtubeshape[i] = new   TGeoTube*[2];
3353    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3354                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3355                                                   -                     fgkendladdercoolingsupportdistance[0]-fgkSSDTolerance));
3356    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3357                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3358    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3359                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3360                                                   +                     fgkendladdercoolingsupportdistance[1]
3361                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3362    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3363                                                                         endladdercoolingtubeshape[1][0]->GetDz());
3364    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3365                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3366                                                   -                     fgkEndLadderMountingBlockPosition[0]
3367                                                   -                     fgkendladdercoolingsupportdistance[1]           
3368                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3369    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3370                                                                         endladdercoolingtubeshape[2][0]->GetDz());
3371    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3372                                                           0.50 * (fgkMountingBlockToSensorSupport
3373                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3374                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3375                                                         +                 fgkSSDSensorOverlap
3376                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3377                                                         -                 fgkendladdercoolingsupportdistance[2]
3378                                                         -                 fgkEndLadderMountingBlockPosition[1]
3379                                                         -                 fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3380    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3381                                                                         endladdercoolingtubeshape[3][0]->GetDz());
3382    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3383                                                           0.50 * (fgkendladdercoolingsupportdistance[2]-fgkSSDTolerance));
3384    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3385                                                                         endladdercoolingtubeshape[4][0]->GetDz());
3386    // Ladder Cooling Tubes
3387    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3388    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3389                                                                                          new TGeoVolume*[2];
3390    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3391                                                                           fSSDCoolingTubePhynox);
3392    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3393                                                                           fSSDCoolingTubeWater);
3394    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3395                                                                           fSSDCoolingTubePhynox);
3396    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3397                                                                           fSSDCoolingTubeWater);
3398    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3399                                                                           fSSDCoolingTubePhynox);
3400    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3401                                                                           fSSDCoolingTubeWater);
3402    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3403         coolingtube[i][0]->SetLineColor(fColorPhynox);
3404         coolingtube[i][1]->SetLineColor(fColorWater);
3405    }
3406    // End Ladder Cooling Tubes  
3407    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3408    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3409    endladdercoolingtube[i] = new TGeoVolume*[2];
3410    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3411                                                                 endladdercoolingtubeshape[0][0],
3412                                                                 fSSDCoolingTubePhynox);
3413    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3414                                                                 endladdercoolingtubeshape[0][1],
3415                                                                 fSSDCoolingTubeWater);
3416    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3417                                                                 endladdercoolingtubeshape[1][0],
3418                                                                 fSSDCoolingTubePhynox);
3419    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3420                                                                 endladdercoolingtubeshape[1][1],
3421                                                                 fSSDCoolingTubeWater);
3422    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3423                                                                 endladdercoolingtubeshape[2][0],
3424                                                                 fSSDCoolingTubePhynox);
3425    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3426                                                                 endladdercoolingtubeshape[2][1],
3427                                                                 fSSDCoolingTubeWater);
3428    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3429                                                                 endladdercoolingtubeshape[3][0],
3430                                                                 fSSDCoolingTubePhynox);
3431    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3432                                                                 endladdercoolingtubeshape[3][1],
3433                                                                 fSSDCoolingTubeWater);
3434    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3435                                                                 endladdercoolingtubeshape[4][0],
3436                                                                 fSSDCoolingTubePhynox);
3437    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3438                                                                 endladdercoolingtubeshape[4][1],
3439                                                                 fSSDCoolingTubeWater);
3440    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3441                 endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3442                 endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3443    }
3444   /////////////////////////////////////////////////////////////
3445   // Virtual Volume containing Cooling Tubes
3446   /////////////////////////////////////////////////////////////
3447   // Ladder Cooling Tubes
3448   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3449   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3450   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3451                                                                                         coolingtubeshape[i][0]->GetRmax(),
3452                                                                                         coolingtubeshape[i][0]->GetDz());
3453   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3454   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3455                                                                           fSSDAir);
3456   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3457                                                                           fSSDAir);
3458   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3459                                                                           fSSDAir);
3460   // End Ladder Cooling Tubes
3461   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3462   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3463   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3464                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3465                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3466   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3467   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3468                                                                           endladdervirtualcoolingtubeshape[0],
3469                                                                           fSSDAir);
3470   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3471                                                                           endladdervirtualcoolingtubeshape[1],
3472                                                                           fSSDAir);
3473   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3474                                                                           endladdervirtualcoolingtubeshape[2],
3475                                                                           fSSDAir);
3476   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3477                                                                           endladdervirtualcoolingtubeshape[3],
3478                                                                           fSSDAir);
3479   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3480                                                                           endladdervirtualcoolingtubeshape[4],
3481                                                                           fSSDAir);
3482   TList* coolingtubelist = new TList();
3483   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3484         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3485         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3486     coolingtubelist->Add(virtualcoolingtube[i]);
3487   }
3488         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3489         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3490     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3491         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3492         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3493     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3494         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3495         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3496     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3497         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3498         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3499     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3500         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3501         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3502     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3503   return coolingtubelist;
3504 }
3505 ///////////////////////////////////////////////////////////////////////////////
3506 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3507   /////////////////////////////////////////////////////////////
3508   // Method generating SSD Cooling Block    
3509   /////////////////////////////////////////////////////////////
3510   const Int_t kvertexnumber = 8;
3511   ///////////////////////////////////////
3512   // Vertex Positioning for TGeoXTru
3513   ///////////////////////////////////////
3514   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3515   vertexposition[0] = new TVector3(0.0,0.0);
3516   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3517   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3518                                           vertexposition[1]->Y());
3519   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3520                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3521   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3522   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3523                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3524   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3525                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3526                                         - fgkSSDCoolingBlockHoleLength[0]
3527                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3528                                           fgkSSDCoolingBlockHeight[0]
3529                                         - fgkSSDCoolingBlockHoleRadius[1],
3530                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3531   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3532                                         - fgkSSDCoolingBlockHoleLength[0]),
3533                                           vertexposition[6]->Y());
3534   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3535                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3536   Double_t phi = 180.-alpha;
3537   Double_t psi = 180.+2.*alpha;
3538   Double_t deltapsi = psi/nedges;
3539   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3540   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3541                                                   fgkSSDCoolingBlockHoleCenter);
3542   for(Int_t i=0; i<nedges+1; i++){
3543         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3544                                                                                                radius*SinD(phi+i*deltapsi));
3545    *vertexposition[kvertexnumber+i] += (*transvector);
3546   }
3547   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3548   for(Int_t i=0; i<kvertexnumber; i++)
3549     vertexposition[kvertexnumber+nedges+1+i] = 
3550                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3551   ///////////////////////////////////////////////////////////////////////
3552   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3553   ///////////////////////////////////////////////////////////////////////
3554   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3555   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3556   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3557   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3558         xvertexpoints[i] = vertexposition[i]->X();
3559         yvertexpoints[i] = vertexposition[i]->Y();
3560   } 
3561   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3562                                                                                         yvertexpoints);
3563   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3564   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3565   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3566                                                                           ssdcoolingblockshape,
3567                                                                                   fSSDAlCoolBlockMedium);
3568   ssdcoolingblock->SetLineColor(fColorAl);
3569   /////////////////////////////////////////////////////////////
3570   // Deallocating memory
3571   /////////////////////////////////////////////////////////////
3572   delete [] vertexposition;
3573   delete xvertexpoints;
3574   delete yvertexpoints;
3575   /////////////////////////////////////////////////////////////
3576   return ssdcoolingblock;
3577 }
3578 /////////////////////////////////////////////////////////////////////////////////
3579 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3580   ///////////////////////////////////////////////////////
3581   const Int_t kssdchipcablesnumber    = 2;
3582   const Int_t kssdchipcableslaynumber = 2;
3583   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3584   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3585   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3586   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3587                                                  -  fgkSSDChipCablesHeight[0]
3588                                                  -  fgkSSDChipCablesHeight[1]);
3589   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3590   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3591   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3592                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3593                                                           - ssdchipcablesradius[0]
3594                                                           - fgkSSDChipCablesWidth[1]
3595                                                           - fgkSSDChipCablesWidth[2]);
3596   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3597                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3598                                                           +      fgkSSDChipCablesHeight[1]
3599                                                           +      fgkSSDSensorHeight);
3600   ///////////////////////////////////////////////////////
3601   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3602   ///////////////////////////////////////////////////////
3603   TVector3** vertexposition[kssdchipcableslaynumber];
3604   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3605                                                                                                   new TVector3*[4*(nedges+1)+4];
3606   Double_t ratio[4];
3607   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3608   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3609                    /  ssdchipcablesradius[0]; 
3610   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3611                    /  ssdchipcablesradius[0];
3612   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3613                    +  fgkSSDChipCablesHeight[1])
3614                    /  ssdchipcablesradius[0];
3615   Double_t phi = 180.;
3616   Double_t deltaphi = 180./nedges;
3617   Double_t angle = 0.0;
3618   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3619   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3620   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3621         xvertexpoints[i] = new Double_t[kvertexnumber];
3622         yvertexpoints[i] = new Double_t[kvertexnumber];
3623   }  
3624   TVector3* vertex = new TVector3();
3625   TVector3* transvector[kssdchipcableslaynumber];
3626   transvector[0] = new TVector3(fgkSSDChipWidth,
3627                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3628   transvector[1] = new TVector3();
3629   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3630   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3631   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3632                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3633                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3634   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3635         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3636         transvector[1]->SetY(ssdchipcablesradius[0]
3637                                  +               fgkSSDChipCablesHeight[0]
3638                                  +               fgkSSDChipCablesHeight[1]);  
3639         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3640                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3641                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3642                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3643                                                          - i*fgkSSDChipCablesHeight[0]);
3644                 vertexposition[i][2*(nedges+1)+2] = 
3645                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3646                                 +                                fgkSSDChipCablesWidth[1]
3647                                 +                                fgkSSDChipCablesWidth[2],
3648                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3649                                 +                                fgkSSDChipCablesHeight[1]));
3650         vertexposition[i][2*(nedges+1)+3] = 
3651                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3652                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3653                                 -                                fgkSSDChipCablesHeight[i]);
3654             for(Int_t j=0; j<nedges+1; j++){            
3655                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3656                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3657                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3658                         vertexposition[0][(nedges+1)*i+j+2] = 
3659                                                 new TVector3(*vertex+*transvector[i]);
3660                         vertexposition[1][(nedges+1)*i+j+2] = 
3661                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3662                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3663                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3664                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3665                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3666                                                 new TVector3(vertex->X()*ratio[2*i+1]
3667                                                         +                        transvector[i]->X(),
3668                                                                                  vertex->Y()*ratio[2*i+1]
3669                                                         +                transvector[i]->Y());
3670                 }
3671         }
3672         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3673                 for(Int_t j=0; j<kvertexnumber; j++){   
3674                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3675                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3676                 }
3677                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3678                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3679                                                                                 xvertexpoints[i],yvertexpoints[i]);
3680                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3681                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3682                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3683                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3684                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3685                                                           (kssdchipcablesnumber*k+i)%2==0?
3686                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3687                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3688         }
3689         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3690                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3691   }
3692   /////////////////////////////////////////////////////////////
3693   // Mother Volume definition 
3694   /////////////////////////////////////////////////////////////
3695   Double_t ssdchipseparation = fgkSSDSensorLength
3696                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3697                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3698                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3699   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3700   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3701                                                           +fgkSSDChipCablesWidth[1]
3702                                                           +fgkSSDChipCablesWidth[2]);
3703   Double_t dy = fgkSSDChipCablesLength[1];
3704   Double_t dz = SSDChipCablesHeigth;
3705   new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3706   TGeoVolumeAssembly* ssdchipcablesmother = new TGeoVolumeAssembly("SSDChipCablesMother");
3707 //  TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3708 //                        ssdchipcablesmotherbox,fSSDAir);
3709   /////////////////////////////////////////////////////////////
3710   // Rotation and Translation Definition for positioning 
3711   /////////////////////////////////////////////////////////////
3712   TGeoRotation* ssdchipcablesrot[5];
3713   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3714   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3715   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3716   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3717   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3718   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3719                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3720   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3721   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3722   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3723   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3724   /////////////////////////////////////////////////////////////
3725   // Deallocating memory
3726   /////////////////////////////////////////////////////////////
3727   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3728         delete [] xvertexpoints[i];
3729         delete [] yvertexpoints[i];
3730   }
3731   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3732   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3733   delete vertex; 
3734   delete ssdchipcablesrot[0];
3735   delete ssdchipcablesrot[1];
3736   delete ssdchipcablesrot[3];
3737   /////////////////////////////////////////////////////////////
3738   return ssdchipcablesmother;
3739 }
3740 ///////////////////////////////////////////////////////////////////////////////
3741 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3742   /////////////////////////////////////////////////////////////
3743   // SSD Chip Assembly
3744   /////////////////////////////////////////////////////////////
3745   TGeoVolume* ssdchipassembly = GetSSDChips();
3746   TList* ssdchipsystemlist = new TList();
3747 //  const Int_t knedges = 20;
3748   const Int_t knedges = 5;
3749   const Int_t kchipsystemnumber = 2;
3750   /////////////////////////////////////////////////////////////
3751   // Mother Volume containing SSDChipSystem
3752   /////////////////////////////////////////////////////////////
3753   TGeoXtru* chipsystemothershape[kchipsystemnumber];
3754   for(Int_t i=0; i<kchipsystemnumber; i++) chipsystemothershape[i] = new TGeoXtru(2);
3755   const Int_t kmothervertexnumber = 12;  
3756   Double_t xmothervertex[kchipsystemnumber][kmothervertexnumber];
3757   Double_t ymothervertex[kchipsystemnumber][kmothervertexnumber];
3758   Double_t ssdchipcablesradius[kchipsystemnumber];
3759   Double_t ssdchipseparation = fgkSSDSensorLength
3760                              - 2.*fgkSSDModuleStiffenerPosition[1]
3761                              - 2.*(fgkSSDStiffenerWidth
3762                              - fgkSSDStiffenerToChipDist-0.5*fgkSSDChipWidth);
3763   for(Int_t i=0; i<kchipsystemnumber; i++)
3764         ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
3765                                                    -  fgkSSDChipCablesHeight[0]
3766                                                    -  fgkSSDChipCablesHeight[1]);
3767   ///////////////////////
3768   // Setting the vertices 
3769   ///////////////////////
3770   xmothervertex[0][0]  = -0.5*fgkSSDChipCablesLength[1];  
3771   xmothervertex[0][1]  = xmothervertex[0][0];  
3772   xmothervertex[0][2]  = (fgkSSDChipNumber-1)*(fgkSSDChipLength
3773                                            + fgkSSDChipSeparationLength)+0.5*fgkSSDChipCablesLength[1];  
3774   xmothervertex[0][3]  = xmothervertex[0][2];  
3775   xmothervertex[0][4]  = 0.5*fgkSSDChipCablesLength[1];  
3776   xmothervertex[0][5]  = xmothervertex[0][4];  
3777   xmothervertex[0][6]  = xmothervertex[0][2]-0.5*fgkSSDChipCablesLength[1];  
3778   xmothervertex[0][7]  = xmothervertex[0][6]; 
3779   xmothervertex[0][8]  = 0.0;  
3780   xmothervertex[0][9]  = xmothervertex[0][8];  
3781   xmothervertex[0][10] = xmothervertex[0][4];  
3782   xmothervertex[0][11] = xmothervertex[0][10];  
3783   for(Int_t i=0; i<kmothervertexnumber; i++) 
3784         xmothervertex[1][i] = xmothervertex[0][i]; 
3785   for(Int_t i=0; i<kchipsystemnumber; i++){
3786         ymothervertex[i][0]  = -0.5*fgkSSDChipWidth-ssdchipcablesradius[i]
3787                                                  - fgkSSDChipCablesWidth[1]-fgkSSDChipCablesWidth[2];
3788         ymothervertex[i][1]  = ssdchipseparation-ymothervertex[i][0];
3789         ymothervertex[i][2]  = ymothervertex[i][1];
3790         ymothervertex[i][3]  = ymothervertex[i][0];
3791         ymothervertex[i][4]  = ymothervertex[i][0];
3792         ymothervertex[i][5]  = 0.5*fgkSSDChipWidth;
3793         ymothervertex[i][6]  = ymothervertex[i][5];
3794         ymothervertex[i][7]  = ssdchipseparation-0.5*fgkSSDChipWidth;
3795         ymothervertex[i][8]  = ymothervertex[i][7];
3796         ymothervertex[i][9]  = ymothervertex[i][5];
3797         ymothervertex[i][10] = ymothervertex[i][5];
3798         ymothervertex[i][11] = ymothervertex[i][4];
3799   }
3800   //////////////////////////////////////////////////////////
3801 //  TGeoVolume* chipsystemother[kchipsystemnumber];
3802   TGeoVolumeAssembly* chipsystemother[kchipsystemnumber];
3803   const char* chipsytemothername[kchipsystemnumber] = 
3804                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3805   for(Int_t i=0; i<kchipsystemnumber; i++){
3806     chipsystemothershape[i]->DefinePolygon(kmothervertexnumber,
3807                                                                         xmothervertex[i],ymothervertex[i]);
3808     chipsystemothershape[i]->DefineSection(0,-fgkSSDChipCablesHeight[i+2]
3809                                                                                   -0.5*fgkSSDChipHeight);
3810     chipsystemothershape[i]->DefineSection(1,0.5*fgkSSDChipHeight);
3811 //    chipsystemother[i] = new TGeoVolume(chipsytemothername[i],
3812 //                                                        chipsystemothershape[i],fSSDAir);
3813     chipsystemother[i] = new TGeoVolumeAssembly(chipsytemothername[i]);
3814   }
3815   /////////////////////////////////////////////////////////////
3816   // SSD Chip Cables
3817   /////////////////////////////////////////////////////////////
3818   TGeoVolume* ssdchipcables[kchipsystemnumber];
3819   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3820   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3821   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3822   //////////////////
3823   for(Int_t i=0; i<kchipsystemnumber; i++){
3824                 ssdchipcables[i] = 
3825                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3826                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3827                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3828                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3829   }
3830   for(Int_t i=0; i<kchipsystemnumber; i++){
3831         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3832                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3833                 ssdchipcablesrot[i][j] = new TGeoRotation();
3834                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3835                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3836                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3837                                                   +                fgkSSDChipSeparationLength),
3838                                                                                         0.5*fgkSSDChipWidth,
3839                                                   -                                     0.5*fgkSSDChipHeight
3840                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3841                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3842                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3843                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3844         }
3845         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3846         ssdchipsystemlist->Add(chipsystemother[i]);     
3847   }
3848   /////////////////////////////////////////////////////////////
3849   // Deallocating memory
3850   /////////////////////////////////////////////////////////////
3851   for(Int_t i=0; i<kchipsystemnumber; i++){
3852         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3853                 delete ssdchipcablesrot[i][j];
3854                 delete ssdchipcablestrans[i][j];
3855         }
3856         delete ssdchipcablesrot[i];
3857         delete ssdchipcablestrans[i];
3858   }
3859   /////////////////////////////////////////////////////////////
3860   return ssdchipsystemlist;
3861 }
3862 ///////////////////////////////////////////////////////////////////////////////
3863 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3864   /////////////////////////////////////////////////////////////
3865   // SSD Chip Assembly Generation    
3866   /////////////////////////////////////////////////////////////
3867   const Int_t kssdchiprownumber = 2;
3868   TGeoBBox* ssdchipcompshape[2];
3869   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3870                                                                                 0.5*fgkSSDChipLength,
3871                                                                                 0.5*fgkSSDChipWidth,
3872                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3873   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3874                                                                                 0.5*fgkSSDChipLength,
3875                                                                                 0.5*fgkSSDChipWidth,
3876                                                                                 0.5*fgkSSDChipGlueHeight);
3877   TGeoVolume* ssdchipcomp[2];
3878   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3879   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3880                                                                   fSSDChipGlueMedium);
3881   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3882   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3883   TGeoTranslation* ssdchipcomptrans[2];
3884   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3885   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3886   /////////////////////////////////////////////////////////////
3887   // Virtual Volume containing SSDChip   
3888   /////////////////////////////////////////////////////////////
3889   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3890                                                                                                                  0.5*fgkSSDChipWidth,
3891                                                                                                                  0.5*fgkSSDChipHeight);
3892   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3893   /////////////////////////////////////////////////////////////
3894   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3895   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3896                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3897                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3898                                    -  0.5*fgkSSDChipWidth)};
3899   /////////////////////////////////////////////////////////////
3900   // Virtual Volume containing SSDChipAssembly   
3901   /////////////////////////////////////////////////////////////
3902   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3903   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3904   Double_t xmothervertex[kssdmothervertexnumber];
3905   Double_t ymothervertex[kssdmothervertexnumber];
3906   ///////////////////////
3907   // Setting the vertices 
3908   ///////////////////////
3909   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3910   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3911                                    - ymothervertex[0];
3912   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3913   ymothervertex[2] = ymothervertex[1];
3914   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3915   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3916   ymothervertex[4] = ymothervertex[0];
3917   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3918   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3919                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3920   ymothervertex[6] = ymothervertex[5];
3921   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3922                                    - fgkSSDChipWidth;
3923   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3924   ymothervertex[8] = ymothervertex[7];
3925   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3926   ymothervertex[9] = ymothervertex[6];
3927   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3928   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3929   //////////////////////////////////////////////////////////
3930   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3931                                                                         xmothervertex,ymothervertex);
3932   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3933   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3934 //  TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3935 //                                                        ssdchipmothershape,fSSDAir);
3936   TGeoVolumeAssembly* ssdchipmother = new TGeoVolumeAssembly("SSDChipContainer");
3937    /////////////////////////////////////////////////////////////
3938   for(Int_t i=0; i<kssdchiprownumber; i++)
3939     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3940                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3941                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3942   return ssdchipmother;
3943 }
3944 /////////////////////////////////////////////////////////////////////////////////
3945 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3946   /////////////////////////////////////////////////////////////
3947   // Method returning a List containing pointers to Ladder Cable Volumes    
3948   /////////////////////////////////////////////////////////////
3949   const Int_t kladdercablesegmentnumber = 2;
3950   /////////////////////////////////////////
3951   // LadderSegmentBBox Volume
3952   /////////////////////////////////////////
3953   TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber];
3954   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3955                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3956   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3957                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3958                                                                            0.5*fgkSSDFlexWidth[0],
3959                                                                            0.5*fgkSSDLadderCableWidth,
3960                                                                            0.5*fgkSSDFlexHeight[i]); 
3961   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3962                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3963   TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3964   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3965                         laddercablesegmentbbox[i] =
3966                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3967                                                                                  laddercablesegmentbboxshape[i],
3968                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3969             fSSDKaptonLadderCableMedium));
3970                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3971                                                                                                                    fColorPolyhamide);
3972   }
3973   TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber];                                                                                
3974   laddercablesegmentbboxtrans[0] = 
3975                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3976                                                                                            0.5*fgkSSDFlexWidth[0],
3977                                                                                            0.5*fgkSSDLadderCableWidth,
3978                                                                                            0.5*fgkSSDFlexHeight[0]);
3979   laddercablesegmentbboxtrans[1] = 
3980                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3981                                                                                            0.5*fgkSSDFlexWidth[0],
3982                                                                                            0.5*fgkSSDLadderCableWidth,
3983                                                                                            fgkSSDFlexHeight[0]
3984                                                                                            +0.5*fgkSSDFlexHeight[1]);
3985   TGeoVolume* laddercablesegmentbboxassembly = 
3986                                                    new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly"); 
3987   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3988                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3989                                                                                             laddercablesegmentbboxtrans[i]);
3990 /////////////////////////////////////////
3991 // LadderSegmentArb8 Volume
3992 /////////////////////////////////////////
3993   const Int_t kvertexnumber = 4;
3994   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3995   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3996                                                                                                   new TVector3*[kvertexnumber];
3997 //Shape Vertex Positioning
3998   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3999         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
4000         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
4001                                                                                                                   i*fgkSSDFlexHeight[0]);
4002         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
4003                                                                                    +                         fgkSSDFlexHeight[1]
4004                                                                                    +                      i*fgkSSDFlexHeight[0]);
4005         laddercablesegmentvertexposition[i][3] = 
4006                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
4007                                                                                 laddercablesegmentvertexposition[i][2]->Y());
4008   }
4009   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
4010                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
4011   char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
4012                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
4013   TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
4014   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
4015                                         GetArbShape(laddercablesegmentvertexposition[i],
4016                                                                 laddercablesegmentwidth[i],
4017                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
4018                                                                 laddercablesegmentarbshapename[i]);
4019   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
4020                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
4021   TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
4022   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4023                          laddercablesegmentarb[i] =
4024                                                    new TGeoVolume(laddercablesegmentarbname[i],
4025                                                                                   laddercablesegmentarbshape[i],
4026                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
4027             fSSDKaptonLadderCableMedium)); 
4028                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
4029                                                                                                                    fColorPolyhamide);
4030 }
4031   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
4032   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
4033                                                                                                  90.,90,-90.);   
4034   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
4035                                                                                                   0.,90.,0.);    
4036   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
4037                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
4038                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
4039                                                          + fgkSSDFlexWidth[0],0.,0.,
4040                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
4041                                                      *(*laddercablesegmentarbrot[0])));
4042   TGeoVolume* laddercablesegmentarbassembly = 
4043                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
4044   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
4045   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
4046                                                                                    laddercablesegmentarbcombitrans);
4047 /////////////////////////////////////////
4048 // End Ladder Cable Volume
4049 /////////////////////////////////////////
4050   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4051   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4052                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4053   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4054                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4055                                                                            0.5*ssdendladdercablelength,
4056                                                                            0.5*fgkSSDLadderCableWidth,
4057                                                                            0.5*fgkSSDFlexHeight[i]);
4058   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4059                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4060   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4061   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4062                         ladderendcablesegmentbbox[i] =
4063                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4064                                                                                  ladderendcablesegmentbboxshape[i],
4065                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4066             fSSDKaptonLadderCableMedium));
4067                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4068                                                                                                                    fColorPolyhamide);
4069   }
4070   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4071   ladderendcablesegmentbboxtrans[0] = 
4072                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4073                                                                                            0.5*ssdendladdercablelength,
4074                                                                                            0.5*fgkSSDLadderCableWidth,
4075                                                                                            0.5*fgkSSDFlexHeight[0]);
4076   ladderendcablesegmentbboxtrans[1] = 
4077                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4078                                                                                            0.5*ssdendladdercablelength,
4079                                                                                            0.5*fgkSSDLadderCableWidth,
4080                                                                                            fgkSSDFlexHeight[0]
4081                                                                                            +0.5*fgkSSDFlexHeight[1]);
4082   TGeoVolume* ladderendcablesegmentbboxassembly = 
4083                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4084   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4085                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4086                                                                                             ladderendcablesegmentbboxtrans[i]);
4087 /////////////////////////////////////////
4088   TList* laddercablesegmentlist = new TList();
4089   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4090   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4091   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4092   return laddercablesegmentlist;
4093   }
4094 /////////////////////////////////////////////////////////////////////////////////
4095 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4096   /////////////////////////////////////////////////////////////
4097   // Method generating Ladder Cable Volumes Assemblies    
4098   /////////////////////////////////////////////////////////////
4099   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4100   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4101   for(Int_t i=0; i<n; i++){
4102          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4103                                                         i*(fgkCarbonFiberJunctionWidth),
4104                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4105                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4106     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4107         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4108   }
4109   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4110                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4111                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4112                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4113   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4114   return laddercable;
4115 }
4116 /////////////////////////////////////////////////////////////////////////////////
4117 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4118   /////////////////////////////////////////////////////////////
4119   // Method generating Ladder Cable Volumes Assembly   
4120   /////////////////////////////////////////////////////////////
4121   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4122   char laddercabletransname[30];
4123   for(Int_t i=0; i<n; i++){ 
4124         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4125     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4126         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4127   }
4128   return laddercableassembly;
4129 }
4130 /////////////////////////////////////////////////////////////////////////////////
4131 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4132   /////////////////////////////////////////////////////////////
4133   // Method generating Ladder Cable List Assemblies  
4134   /////////////////////////////////////////////////////////////  
4135   const Int_t kladdercableassemblynumber = 2;
4136   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4137   TGeoVolume* ladderCable[kladdercableassemblynumber];
4138   char laddercableassemblyname[30];
4139   TList* laddercableassemblylist = new TList();
4140   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4141         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4142         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4143         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4144                                          new TGeoCombiTrans((n-1)
4145                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4146                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4147                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4148         laddercableassemblylist->Add(ladderCable[i]);
4149 }
4150   return laddercableassemblylist;
4151 }
4152 ///////////////////////////////////////////////////////////////////////////////
4153 void AliITSv11GeometrySSD::SetLadderSegment(){
4154   /////////////////////////////////////////////////////////////
4155   // Method Generating Ladder Segment Array
4156   /////////////////////////////////////////////////////////////
4157   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4158   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4159   if(!fCreateMaterials) CreateMaterials();
4160   if(!fTransformationMatrices) CreateTransformationMatrices();
4161   if(!fBasicObjects) CreateBasicObjects();
4162   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4163   // Placing Carbon Fiber Support       
4164         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4165                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4166                                                                                         fcarbonfibersupportmatrix[j]);  
4167                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4168                                                                                         fcarbonfibersupportmatrix[j]);
4169   }
4170   // Placing Carbon Fiber Junction
4171     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4172         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4173                                                                    fcarbonfiberjunctionmatrix[j]);
4174   // Placing Carbon Fiber Lower Support
4175         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4176                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4177                                                            fcarbonfiberlowersupportrans[j]);    
4178   // Placing SSD Sensor Support
4179     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4180         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4181                                                                      fssdsensorsupport[1][i],
4182                                                            j+1,fssdsensorsupportmatrix[j]);
4183   // Placing SSD Cooling Tube Support 
4184         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4185                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4186                                                                    fcoolingtubesupportmatrix[j]);
4187   // Placing SSD Cooling Tube  
4188         for(Int_t j=0; j<2; j++)
4189                 for(Int_t k=0; k<2; k++){
4190                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4191                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4192                 }
4193   // Placing SSD Hybrid
4194     switch(i){
4195         case 0: 
4196                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4197                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4198                 break;
4199     case 1:
4200                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4201                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4202                 break;
4203         }
4204         // Placing Cooling Block System
4205     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4206         // Placing SSD Flex
4207         for(Int_t j=0; j<fgkflexnumber; j++){
4208       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4209       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4210         }
4211    }
4212 }
4213 ///////////////////////////////////////////////////////////////////////////////
4214 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4215   /////////////////////////////////////////////////////////////
4216   // Method Generating End Ladder
4217   /////////////////////////////////////////////////////////////
4218   // End Ladder Carbon Fiber Junction 
4219   /////////////////////////////////////////////////////////////
4220   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4221   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4222   if(!fCreateMaterials) CreateMaterials();
4223   if(!fTransformationMatrices) CreateTransformationMatrices();
4224   if(!fBasicObjects) CreateBasicObjects();
4225   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4226         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4227                 fendladdersegment[i]->AddNode(j==2 ? 
4228                                                         fendladdercarbonfiberjunction[i][1] : 
4229                                                         fendladdercarbonfiberjunction[i][0],
4230                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4231   }
4232   /////////////////////////////////////////////////////////////
4233   // End Ladder Carbon Fiber Support 
4234   /////////////////////////////////////////////////////////////
4235   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4236       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4237                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4238                   fendladdercarbonfibermatrix[i][j]);   
4239           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4240                   fendladdercarbonfibermatrix[i][j]);   
4241       }
4242   /////////////////////////////////////////////////////////////
4243   // End Ladder Mounting Block
4244   /////////////////////////////////////////////////////////////
4245   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4246        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4247                                      fendladdermountingblockcombitrans[i]);
4248   /////////////////////////////////////////////////////////////
4249   // End Ladder Mounting Block Clip
4250   /////////////////////////////////////////////////////////////
4251   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4252         for(Int_t j=0; j<2; j++)
4253                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4254                                               fendladdermountingblockclipmatrix[i][j]);
4255   /////////////////////////////////////////////////////////////
4256   // End Ladder Lower Supports
4257   /////////////////////////////////////////////////////////////
4258   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4259                                 fendladderlowersupptrans[0]);
4260   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4261                                 fendladderlowersupptrans[1]);
4262   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4263                                 fendladderlowersupptrans[2]);
4264   /////////////////////////////////////////////////////////////
4265   // End Ladder Cooling Tube Support
4266   /////////////////////////////////////////////////////////////
4267   for(Int_t i=0; i<2; i++) 
4268         for(Int_t j=0; j<(i==0?4:2); j++)   
4269                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4270                                               fendladdercoolingtubesupportmatrix[i][j]);
4271   /////////////////////////////////////////////////////////////
4272   // End Ladder Cooling Tube Support
4273   /////////////////////////////////////////////////////////////
4274 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                          
4275 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                          
4276   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4277   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4278   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4279   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4280   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4281   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4282   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4283   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                            
4284 }
4285 ///////////////////////////////////////////////////////////////////////////////
4286 void AliITSv11GeometrySSD::SetLadder(){
4287   /////////////////////////////////////////////////////////////
4288   // Method Generating Ladder of Layer 5 and 6
4289   /////////////////////////////////////////////////////////////  
4290   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4291                                                                                                 fgkSSDLay6SensorsNumber};
4292   /////////////////////////////////////////////////////////////////////////////                                         
4293   /// Generating Ladder Mother Volume Containing Ladder 
4294   /////////////////////////////////////////////////////////////////////////////          
4295   TGeoXtru* laddershape[fgkladdernumber];       
4296   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4297   const Int_t kmothervertexnumber = 8;  
4298   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4299   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4300   ///////////////////////
4301   // Setting the vertices 
4302   ///////////////////////
4303   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4304                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4305   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4306   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
4307                                           -  fgkSSDModuleVerticalDisalignment;
4308   xmothervertex[0][1] = xmothervertex[0][0];
4309   ymothervertex[0][1] = 0.0;
4310   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4311                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4312   ymothervertex[0][2] = ymothervertex[0][1];
4313   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4314   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4315   xmothervertex[0][4] = -xmothervertex[0][3];
4316   ymothervertex[0][4] = ymothervertex[0][3];
4317   xmothervertex[0][5] = -xmothervertex[0][2];
4318   ymothervertex[0][5] = ymothervertex[0][2];
4319   xmothervertex[0][6] = -xmothervertex[0][1];
4320   ymothervertex[0][6] = ymothervertex[0][1];
4321   xmothervertex[0][7] = -xmothervertex[0][0];
4322   ymothervertex[0][7] = ymothervertex[0][0];
4323   for(Int_t i=0; i<kmothervertexnumber; i++){
4324         xmothervertex[1][i] = xmothervertex[0][i];
4325         ymothervertex[1][i] = ymothervertex[0][i];
4326   }
4327   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4328   for(Int_t i=0; i<fgkladdernumber; i++){
4329         laddershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
4330                                                                     ymothervertex[i]);
4331     laddershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4332     laddershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4333                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4334     fladder[i] = new TGeoVolume(laddername[i],laddershape[i],fSSDAir);
4335         fladder[i]->SetLineColor(4);
4336  }
4337 ///////////////////////////////////////////////////////////////////////////
4338  if(!fCreateMaterials) CreateMaterials();
4339  if(!fTransformationMatrices) CreateTransformationMatrices();
4340  if(!fBasicObjects) CreateBasicObjects();
4341  SetLadderSegment(); 
4342  SetEndLadderSegment();
4343   for(Int_t i=0; i<fgkladdernumber; i++){
4344         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4345         //////////////////////////                                              
4346         /// Placing Ladder Segment
4347         //////////////////////////              
4348                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4349                                                                      fladdersegment[i==0 ? 1 : 0],
4350                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4351         //////////////////////////                                              
4352         /// Placing SSD Sensor
4353         //////////////////////////              
4354         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4355                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4356                                                         fssdsensormatrix[i][j]);
4357         }
4358         ///////////////////////////////                                         
4359         /// Placing End Ladder Segment
4360         ///////////////////////////////         
4361     fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4362         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4363    }
4364 /////////////////////////////////////////////////////////////////////////////                                           
4365 /// Placing Ladder Cables
4366 /////////////////////////////////////////////////////////////////////////////           
4367   Int_t sidecablenumber[2][2];
4368   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4369   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4370   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4371   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4372   Double_t carbonfibertomoduleposition[3];
4373   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4374   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4375                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4376          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4377          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4378          -            fgkSSDSensorCenterSupportThickness[0]);
4379   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4380                                                                  +   0.5*fgkCoolingTubeSupportHeight
4381          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4382   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4383   Double_t ssdendladdercablelength[4];
4384   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4385                                                          + fgkSSDSensorLength
4386                                                          - fgkSSDModuleStiffenerPosition[1]
4387                                                          - fgkSSDStiffenerWidth 
4388                                                          - fgkSSDFlexWidth[0]
4389                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4390   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4391                                                          + fgkSSDModuleStiffenerPosition[1]
4392                                                          + fgkSSDStiffenerWidth
4393                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4394   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4395                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4396                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4397                                                          - kendladdercablecorrection;
4398   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4399                                                          + carbonfibertomoduleposition[1]
4400                                                          - fgkSSDModuleStiffenerPosition[1]
4401                                                          - fgkSSDStiffenerWidth)
4402                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4403   TList* laddercableassemblylist[4];
4404   const Int_t kendladdercablesnumber = 4;
4405   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4406         for(Int_t j=0; j<kendladdercablesnumber; j++){
4407                 laddercableassemblylist[j] = 
4408                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4409                                                                    ssdendladdercablelength[j]);
4410 //          fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4411 //                                                                      j<2?1:2,fladdercablematrix[i][j]);
4412   }
4413 }
4414 ////////////////////////////////////////////////////////////////////////////////
4415 void AliITSv11GeometrySSD::SetLayer(){
4416 ////////////////////////////////////////////////////////////////////////////////
4417   // Creating Ladder of Layer 5 and Layer 6
4418   /////////////////////////////////////////////////////////////
4419   if(!fCreateMaterials) CreateMaterials();
4420   if(!fTransformationMatrices) CreateTransformationMatrices();
4421   if(!fBasicObjects) CreateBasicObjects();
4422   SetLadder(); // Generating the ladder of Layer5 and Layer6
4423   const Int_t kssdlayladdernumber[fgklayernumber] = 
4424                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4425   /////////////////////////////////////////////////////////////
4426   // Generating mother volumes for Layer5 and Layer6
4427   /////////////////////////////////////////////////////////////
4428   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4429   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4430   Int_t *ladderindex[fgklayernumber];
4431   Int_t index[fgklayernumber] = {8,9};
4432   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4433   for(Int_t i=0; i<fgklayernumber; i++) 
4434         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4435                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4436                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4437                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4438                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4439         }
4440   /////////////////////////////////////////////////////////////
4441   // Deallocating memory
4442   /////////////////////////////////////////////////////////////
4443   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4444 }
4445 ////////////////////////////////////////////////////////////////////////////////
4446 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4447   /////////////////////////////////////////////////////////////
4448   // Insert the layer 5 in the mother volume. 
4449   /////////////////////////////////////////////////////////////
4450   if (! moth) {
4451     printf("Error::AliITSv11GeometrySSD: Can't insert layer5, mother is null!\n");
4452     return;
4453   };
4454   if(!fSSDLayer5) SetLayer();
4455   fMotherVol = moth;
4456   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4457                                                                                 + fgkLay5CenterITSPosition);
4458   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4459  }
4460 ////////////////////////////////////////////////////////////////////////////////
4461 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4462   /////////////////////////////////////////////////////////////
4463   // Insert the layer 6 in the mother volume. 
4464   /////////////////////////////////////////////////////////////
4465   if (! moth) {
4466     printf("Error::AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4467     return;
4468   };
4469   if(!fSSDLayer6) SetLayer();
4470   fMotherVol = moth;
4471   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4472                                                                                 + fgkLay6CenterITSPosition);
4473   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4474  }
4475  ////////////////////////////////////////////////////////////////////////////////
4476  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4477   /////////////////////////////////////////////////////////////
4478   // Method generating the Arc structure of Ladder Support 
4479   /////////////////////////////////////////////////////////////
4480   const Int_t kssdlayladdernumber[fgklayernumber] = 
4481                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4482   Double_t mountingsupportedge[fgklayernumber];
4483   Double_t mountingblockratio[fgklayernumber];
4484   Double_t theta[fgklayernumber];
4485   Double_t phi[fgklayernumber];
4486   Double_t psi0[fgklayernumber];
4487   Double_t deltapsi[fgklayernumber];
4488   TVector3* mountingsupportedgevector[fgklayernumber];
4489   for(Int_t i=0; i<fgklayernumber; i++){
4490         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4491     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4492                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4493                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4494                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4495                                                           / kssdlayladdernumber[i])));
4496     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4497     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4498         mountingsupportedgevector[i] = new TVector3();
4499     mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4500         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(1.
4501                                                                  -TMath::Power(mountingsupportedgevector[i]->X()
4502                                                                  /                         fgkMountingBlockSupportRadius[i],2)));
4503     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4504     deltapsi[i] = (theta[i]+phi[i])/nedges;
4505   }
4506   TVector3** vertex[fgklayernumber];
4507   TList* vertexlist[fgklayernumber];
4508   Int_t indexedge[fgklayernumber] = {0,0};
4509   for(Int_t i=0; i<fgklayernumber; i++){
4510         vertex[i] = new TVector3*[nedges+1];
4511         vertexlist[i] = new TList();
4512   } 
4513   for(Int_t i=0; i<fgklayernumber; i++){
4514         for(Int_t j=0; j<nedges+1; j++){
4515                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4516                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4517                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4518                 vertexlist[i]->Add(vertex[i][j]);
4519         }
4520         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4521   }
4522   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4523   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4524   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4525   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4526   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4527   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4528   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4529   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4530   for(Int_t i=0; i<fgklayernumber; i++){
4531     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4532     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4533     xcentervertex[i] = new Double_t[indexedge[i]+3];
4534     ycentervertex[i] = new Double_t[indexedge[i]+3];
4535         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4536         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4537         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4538         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4539         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4540                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4541                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4542                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4543                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4544                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4545                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4546                 if(j<indexedge[i]+1){
4547                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4548                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4549                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4550                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4551                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4552                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4553                 }
4554         }
4555         xsidevertex[i][1] = xsidevertex[i][0]; 
4556         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4557         xsidevertex[i][2] = xsidevertex[i][3]; 
4558         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4559         xcentervertex[i][1] = xcentervertex[i][0]; 
4560         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4561         xcentervertex[i][2] = xcentervertex[i][3]; 
4562         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4563         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4564         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4565         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4566         ycenterlowervertex[i][0] = ysidevertex[i][0];
4567         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4568         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4569   }
4570   /////////////////////////////////////////////////////////////
4571   // Building the Arc Structure of Ladder Supports 
4572   /////////////////////////////////////////////////////////////
4573   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4574   TGeoXtru* centermountingsupportshape[fgklayernumber];
4575   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4576   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4577   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4578   TGeoVolume* centermountingblocksupport[fgklayernumber];
4579   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4580   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4581   char sidemountingblockname[40];
4582   char centermountingblockname[40];
4583   char sideladdersupportpiecename[40];
4584   char centerladdersupportpiecename[40];
4585   for(Int_t i=0; i<fgklayernumber; i++){ 
4586         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4587         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4588         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4589         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4590         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4591     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4592                                                                                                 xsidevertex[i],ysidevertex[i]);
4593     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4594                                                                                                          -fgkMountingBlockSupportWidth[0]);
4595     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4596     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4597                                                                           sidemountingblocksupportshape[i],
4598                                                                                   fSSDAlCoolBlockMedium);
4599         sidemountingblocksupport[i]->SetLineColor(9);
4600         centermountingsupportshape[i] = new TGeoXtru(2);
4601     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4602                                                                                                 xcentervertex[i],ycentervertex[i]);
4603         centermountingsupportshape[i]->DefineSection(0,0.);
4604     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4605                                                                                                   -fgkMountingBlockSupportWidth[0]);
4606     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4607                                                                           centermountingsupportshape[i],
4608                                                                                   fSSDAlCoolBlockMedium);
4609         centermountingblocksupport[i]->SetLineColor(9);
4610         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4611     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4612                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4613         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4614                                                                                                          -fgkMountingBlockSupportWidth[0]);
4615     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4616     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4617                                                                           sideladdersupportpieceshape[i],
4618                                                                                   fSSDCarbonFiberMedium);
4619         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4620         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4621     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4622                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4623         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4624     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4625                                                                                                   -fgkMountingBlockSupportWidth[0]);
4626     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4627                                                                           centerladdersupportpieceshape[i],
4628                                                                                   fSSDCarbonFiberMedium);
4629         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4630   }
4631   /////////////////////////////////////////////////////////////
4632   // Building the Up Structure of Ladder Supports 
4633   /////////////////////////////////////////////////////////////
4634   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4635   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4636   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4637   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4638   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4639   //////////////////////////////////////////////////////////
4640   // Setting the volume for TGeoXtru Mounting Block Piece  
4641   //////////////////////////////////////////////////////////
4642   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4643   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4644   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4645   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4646   TGeoVolume* mountingblockpieceup[fgklayernumber];
4647   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4648   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4649   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4650   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4651   char mountingblockpiecedownname[34];
4652   char mountingblockpieceupname[34];
4653   for(Int_t i=0; i<fgklayernumber; i++){
4654     ///////////////////////////
4655     // Mounting Block Down Vertex
4656     ///////////////////////////
4657         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4658     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4659         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4660         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4661                                                                                 + fgkMountingBlockSupportDownHeight;
4662         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4663         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4664                                                                                 + fgkSSDMountingBlockHeight[1]
4665                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4666                                                                                 - fgkSSDModuleCoolingBlockToSensor
4667                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4668         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4669         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4670         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4671         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4672         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4673         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4674         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4675         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4676                                                                                 + fgkSSDMountingBlockHeight[2]
4677                                                                                 - fgkSSDMountingBlockHeight[0];
4678         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4679         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4680         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4681         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4682         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4683                                                                                                          mountingblockpiecedownyvertex[i]);
4684         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4685         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4686         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4687                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4688         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4689     ///////////////////////////
4690     // Mounting Block Up Vertex
4691     ///////////////////////////
4692         mountingblockpieceupshape[i] = new TGeoXtru(2);
4693         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4694         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4695         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4696                                                                                 + fgkMountingBlockSupportUpHeight[i];
4697         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4698         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4699                                                                                 + fgkSSDMountingBlockHeight[1]
4700                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4701                                                                                 - fgkSSDModuleCoolingBlockToSensor
4702                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4703         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4704         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4705         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4706         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4707         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4708         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4709         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4710         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4711                                                                                 + fgkSSDMountingBlockHeight[2]
4712                                                                                 - fgkSSDMountingBlockHeight[0];
4713         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4714         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4715         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4716         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4717         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4718                                                                                                          mountingblockpieceupyvertex[i]);
4719         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4720         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4721         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4722                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4723         mountingblockpieceup[i]->SetLineColor(fColorG10);
4724  }
4725   ///////////////////////////////////////////////////////////////////
4726   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4727   ///////////////////////////////////////////////////////////////////
4728   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4729   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4730   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4731   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4732   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4733   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4734   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4735   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4736   char mountingblocksupportrapezoidowname[40];
4737   char mountingblocksupportrapezoidupname[40];
4738   Double_t scalefactor = 3./4.;
4739   for(Int_t i=0; i<fgklayernumber; i++){
4740   ////////////////////////////////////////////
4741   // Mounting Block Support Down Trapezoid Vertex 
4742   ////////////////////////////////////////////
4743         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4744         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4745                                                                                                  - mountingsupportedge[i];
4746         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4747         mountingblocksupportrapezoidownxvertex[i][1] = 
4748                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4749         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4750                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4751                                                                                              - mountingblockpiecedownyvertex[i][0]);
4752         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4753         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4754         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4755         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4756         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4757         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4758         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4759                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4760         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4761                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4762         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4763         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4764         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4765                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4766         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4767   ////////////////////////////////////////////
4768   // Mounting Block Support Up Trapezoid Vertex 
4769   ////////////////////////////////////////////
4770         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4771         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4772                                                                                                  - mountingsupportedge[i];
4773         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4774         mountingblocksupportrapezoidupxvertex[i][1] = 
4775                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4776         mountingblocksupportrapezoidupyvertex[i][1] = 
4777                                                                                                mountingblockpieceupyvertex[i][0]
4778                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4779                                                                                              - mountingblockpieceupyvertex[i][0]);
4780         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4781         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4782         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4783         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4784         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4785         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4786         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4787                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4788         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4789                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4790         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4791         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4792         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4793                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4794         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4795   }
4796   ///////////////////////////////////////////////////////////////////
4797   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4798   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4799   Double_t boxoriginup[fgklayernumber][2][3];
4800   Double_t boxorigindown[fgklayernumber][2][3];
4801   char mountingblocksupportboxdownname[34];
4802   char mountingblocksupportboxupname[34];
4803   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4804   mountingblocksupportrot->SetAngles(90.,180.,-90);
4805   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4806   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4807   TGeoHMatrix* laddersupportmatrix[2];
4808   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4809   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4810   /////////////////////////////////////////////////////////////
4811   // Creating Mother Volume for Containment
4812   /////////////////////////////////////////////////////////////
4813   Double_t *xmothervertex[fgklayernumber];
4814   Double_t *ymothervertex[fgklayernumber];
4815   for(Int_t i=0; i<fgklayernumber; i++){
4816         xmothervertex[i] = new Double_t[8];
4817         ymothervertex[i] = new Double_t[8];
4818   }  
4819   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4820   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4821   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4822 //  TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4823   TGeoVolumeAssembly* 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 TGeoVolumeAssembly(upmotheladdersupportname);
4868 //    upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4869 //                                                                                        upmotherladdersupportshape[i],fSSDAir);
4870   }
4871   for(Int_t i=0; i<fgklayernumber; i++){
4872         /////////////////////////
4873         // Setting the box origin
4874         /////////////////////////
4875         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4876         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4877                                                    +  0.5*fgkMountingBlockSupportDownHeight;
4878         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4879                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4880   
4881         boxorigindown[i][1][0] = 0.0;
4882         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4883         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4884                                                    -      fgkMountingBlockSupportWidth[0]);
4885                                                    
4886         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4887         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4888                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4889         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4890                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4891   
4892         boxoriginup[i][1][0] = 0.0;
4893         boxoriginup[i][1][1] = fgkMountingBlockSupportRadius[i]
4894                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4895         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4896                                                  - fgkMountingBlockSupportWidth[0]);
4897   
4898         /////////////////////////
4899     // Setting the boxes    
4900         /////////////////////////
4901         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4902                                                                                  +  fgkSSDMountingBlockLength[0]),
4903                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4904                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4905                                                                                         boxorigindown[i][0]);
4906     mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4907                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4908                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4909                                                                                  -  fgkMountingBlockSupportWidth[0]),
4910                                                                                         boxorigindown[i][1]);
4911                                                                                         
4912         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4913                                                                                  +  fgkSSDMountingBlockLength[0]),
4914                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4915                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4916                                                                                         boxoriginup[i][0]);
4917                                                                                         
4918         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4919                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4920                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4921                                                                      -  fgkMountingBlockSupportWidth[0]),
4922                                                                                         boxoriginup[i][1]);
4923         ///////////////////////////////////////
4924     // Adding the Volumes to Mother Volume    
4925         ///////////////////////////////////////
4926         for(Int_t j=0; j<2; j++){
4927                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4928                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4929                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4930                                                                                   mountingblocksupportboxdownshape[i][j],
4931                                                                                   fSSDCarbonFiberMedium);
4932                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4933                                                                                   mountingblocksupportboxupshape[i][j],
4934                                                                                   fSSDCarbonFiberMedium);
4935                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4936                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4937                 for(Int_t k=0; k<2; k++){
4938                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4939 //                      upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4940                 }
4941         }
4942         for(Int_t k=0; k<2; k++){
4943                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4944                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4945                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4946                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4947             downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4948                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4949                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4950 //              upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4951 //              upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4952 //              upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4953 //              upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4954 //              upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4955         }
4956   }
4957   TList* laddersupportlist = new TList();
4958   laddersupportlist->Add(downmotherladdersupport[0]); 
4959   laddersupportlist->Add(upmotherladdersupport[0]); 
4960   laddersupportlist->Add(downmotherladdersupport[1]); 
4961   laddersupportlist->Add(upmotherladdersupport[1]); 
4962   /////////////////////////////////////////////////////////////
4963   // Deallocating memory
4964   /////////////////////////////////////////////////////////////
4965   for(Int_t i=0; i<fgklayernumber; i++){
4966         for(Int_t j=0; j<nedges+1; j++)
4967                 delete vertex[i][j];
4968         delete mountingsupportedgevector[i];
4969         delete [] vertex[i];
4970         delete vertexlist[i];
4971         delete [] xsidevertex[i];
4972         delete [] ysidevertex[i];
4973         delete [] xcentervertex[i];
4974         delete [] ycentervertex[i];
4975         delete [] xsidelowervertex[i];
4976         delete [] ysidelowervertex[i];
4977         delete [] xcenterlowervertex[i];
4978         delete [] ycenterlowervertex[i];
4979   }
4980   delete xsidevertex;
4981   delete ysidevertex;
4982   delete xcentervertex;
4983   delete ycentervertex;
4984   delete xsidelowervertex;
4985   delete ysidelowervertex;
4986   delete xcenterlowervertex;
4987   delete ycenterlowervertex;
4988   delete globalrefladdersupportrot;
4989   delete mountingblocksupportrot;
4990   /////////////////////
4991   return laddersupportlist;     
4992 }
4993  ////////////////////////////////////////////////////////////////////////////////
4994 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4995 //////////////////////////////////////////
4996 // Method Generating Ladder Support Ring
4997 //////////////////////////////////////////
4998   if(!fCreateMaterials) CreateMaterials();
4999   if(!fTransformationMatrices) CreateTransformationMatrices();
5000   if(!fBasicObjects) CreateBasicObjects();
5001   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
5002   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
5003     const Int_t kssdlayladdernumber[fgklayernumber] = 
5004                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
5005   Double_t mountingsupportedge[fgklayernumber];
5006   Double_t mountingblockratio[fgklayernumber];
5007   Double_t theta[fgklayernumber];
5008   Double_t phi[fgklayernumber];
5009   for(Int_t i=0; i<fgklayernumber; i++){
5010         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
5011     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
5012                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
5013                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
5014                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
5015                                                           / kssdlayladdernumber[i])));
5016     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
5017                          / fgkMountingBlockSupportRadius[i]);
5018     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
5019   }
5020   TGeoRotation* globalrot = new TGeoRotation();
5021   globalrot->SetAngles(0.,-90.,0.); 
5022   TGeoRotation** laddersupportrot[fgklayernumber];
5023   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5024   for(Int_t i=0; i<fgklayernumber; i++){                
5025         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5026         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5027         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5028                 laddersupportrot[i][j] = new TGeoRotation();
5029                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5030                 switch(i){
5031                         case 0: //Ladder of Layer5  
5032                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5033                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5034                                                                             laddersupportmatrix[i][j]); 
5035                         break;
5036                         case 1: //Ladder of Layer6 
5037                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5038                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5039                                                                               laddersupportmatrix[i][j]); 
5040                         break;
5041                 }
5042     }
5043   }
5044   /////////////////////////////////////////////////////////////
5045   // Creating Lower Ladder Support 
5046   /////////////////////////////////////////////////////////////
5047   TVector3** ringsupportvertex[fgklayernumber];         
5048   Double_t angle = 360./nedges;
5049   for(Int_t i=0; i<fgklayernumber; i++){
5050     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5051         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5052                                                         *                          TMath::Cos(theta[i]));
5053         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5054                                                         -                          mountingsupportedge[i],
5055                                                                                    ringsupportvertex[i][0]->Y());
5056         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5057                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5058     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5059         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5060            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5061            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5062            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5063            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5064         }
5065         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5066     for(Int_t j=0; j<nedges+1; j++){
5067                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5068                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5069                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5070         }
5071   }
5072   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5073   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5074   for(Int_t i=0; i<fgklayernumber; i++){
5075         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5076         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5077         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5078                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5079                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5080         }
5081   }
5082 ////////////////////////////////////////////////////////////////////////////////
5083 // Start Corrections 13/06/08
5084 ////////////////////////////////////////////////////////////////////////////////
5085   char lowerladderpconsupportname[30];
5086   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5087   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5088   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5089   Double_t lowerladderpconradiusmax[fgklayernumber];
5090   Double_t lowerladderpconradiusmin[fgklayernumber];
5091   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5092   lowerladdersupportrot->SetAngles(90.,180.,-90);
5093   for(Int_t i=0; i<fgklayernumber; i++){
5094         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5095                                                                 *                          TMath::Cos(theta[i]);
5096     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5097   } 
5098   for(Int_t i=0; i<fgklayernumber; i++){
5099 ///////////////////////////  Modified Version ?///////////////////
5100     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5101         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5102                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5103                                                          lowerladderpconradiusmax[i]);
5104         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5105         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5106     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5107         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5108         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5109  }
5110 ////////////////////////////////////////////////////////////////////////////////
5111 // End Corrections 13/06/08
5112 ////////////////////////////////////////////////////////////////////////////////
5113   /*char lowerladdersupportname[30];
5114   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5115   TGeoVolume* lowerladdersupport[fgklayernumber];
5116   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5117   lowerladdersupportrot->SetAngles(90.,180.,-90);
5118   for(Int_t i=0; i<fgklayernumber; i++){
5119         lowerladdersupportshape[i] = new TGeoXtru(2);
5120         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5121                                                                                           xmothervertex[i],ymothervertex[i]);
5122         lowerladdersupportshape[i]->DefineSection(0,0.);
5123     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5124         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5125     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5126                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5127         lowerladdersupport[i]->SetLineColor(fColorAl);
5128         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5129         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5130   }*/
5131   /////////////////////////////////////////////////////////////
5132   // Deallocating memory
5133   /////////////////////////////////////////////////////////////
5134   for(Int_t i=0; i<fgklayernumber; i++){
5135         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5136                 delete ringsupportvertex[i][j];
5137         delete [] ringsupportvertex[i];
5138   }
5139   for(Int_t i=0; i<fgklayernumber; i++){
5140         delete [] xmothervertex[i];
5141         delete [] ymothervertex[i];
5142   }
5143   delete xmothervertex;
5144   delete ymothervertex; 
5145   delete globalrot;
5146   for(Int_t i=0; i<fgklayernumber; i++){
5147         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5148                 delete laddersupportrot[i][j];
5149         delete [] laddersupportrot[i];
5150   }
5151  }  
5152  ////////////////////////////////////////////////////////////////////////////////
5153  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5154   /////////////////////////////////////////////////////////////
5155   // Method generating Endcap CoverPlate
5156   /////////////////////////////////////////////////////////////
5157   // Holes Definition 
5158   ///////////////////
5159   Int_t nendcapcoverplateholedges = 30;
5160   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5161   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5162                                                           0.5*fgkEndCapCoverPlateThickness};
5163   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5164                                                                                                               nendcapcoverplateholedges,holesection);
5165   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5166                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5167   endcapcoverplatesmallhole->SetLineColor(6);
5168   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5169                                                                                                               nendcapcoverplateholedges,holesection);
5170   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5171                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5172   endcapcoverplatebighole->SetLineColor(6);
5173   //////////////////////////
5174   // Screw Piece Definition 
5175   //////////////////////////
5176   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5177   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5178                                                                                                       CosD(0.5*smallscrewangle),
5179                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5180   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5181                                                                                                 endcapsmallscrewpieceshape,
5182                                                                                                 fSSDCoolingTubePhynox);
5183   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5184   ///////////////////
5185   // Box Definition 
5186   ///////////////////
5187   TGeoBBox* endcapcoverplateboxshape[4];
5188   TGeoVolume* endcapcoverplatebox[4];
5189   Double_t boxorigin[5][3];
5190   boxorigin[0][0] = 0.;
5191   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5192   boxorigin[0][2] = 0.;
5193
5194   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5195   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5196   boxorigin[1][2] = 0.;
5197
5198   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5199                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5200   boxorigin[2][1] = boxorigin[1][1];
5201   boxorigin[2][2] = 0.;
5202
5203   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5204                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5205   boxorigin[3][1] = boxorigin[1][1];
5206   boxorigin[3][2] = 0.;
5207
5208   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5209                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5210                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5211                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5212
5213   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5214                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5215                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5216                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5217                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5218
5219   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5220                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5221                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5222                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5223                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5224
5225   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5226                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5227                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5228                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5229                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5230   
5231   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5232                                                                            fSSDAlCoolBlockMedium);
5233   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5234                                                                            fSSDAlCoolBlockMedium);
5235   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5236                                                                            fSSDAlCoolBlockMedium);
5237   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5238                                                                            fSSDAlCoolBlockMedium);
5239   endcapcoverplatebox[0]->SetLineColor(6);
5240   endcapcoverplatebox[1]->SetLineColor(6);
5241   endcapcoverplatebox[2]->SetLineColor(6);
5242   endcapcoverplatebox[3]->SetLineColor(6);
5243   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5244   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5245                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5246                                                                                         0.5*fgkEndCapCoverPlateThickness,
5247                                                                                         endcapfillingboxorigin);
5248   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5249                                                                            fSSDAlCoolBlockMedium);
5250   endcapfillingbox->SetLineColor(6);
5251   ////////////////////////////
5252   // Contour shape Definition 
5253   ////////////////////////////
5254   const Int_t kcontourvertexnumber = 10;
5255   Double_t xcontourvertex[kcontourvertexnumber];
5256   Double_t ycontourvertex[kcontourvertexnumber];
5257   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5258   xcontourvertex[1] = xcontourvertex[0];
5259   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5260   xcontourvertex[3] = xcontourvertex[2];
5261   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5262   xcontourvertex[5] = xcontourvertex[4];
5263   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5264   xcontourvertex[7] = xcontourvertex[6];
5265   xcontourvertex[8] = xcontourvertex[4];
5266   xcontourvertex[9] = xcontourvertex[8];
5267   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5268                                         - (kendcapcoverplatesmallholenumber[1]-1)
5269                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5270   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5271                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5272   ycontourvertex[2] = ycontourvertex[1];
5273   ycontourvertex[3] = ycontourvertex[0];
5274   ycontourvertex[4] = ycontourvertex[3];
5275   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5276   ycontourvertex[6] = ycontourvertex[5];
5277   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5278                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5279                                         + fgkEndCapCoverPlateSmallHoleRadius;
5280   ycontourvertex[8] = ycontourvertex[7];
5281   ycontourvertex[9] = ycontourvertex[0];
5282
5283   Double_t xboxin, dxboxin, yboxin, dyboxin;
5284   Double_t xboxout, dxboxout, yboxout, dyboxout;
5285   Double_t coordmin, coordmax;
5286   coordmin = -fgkEndCapCoverPlateLength[0];
5287   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5288   xboxout = 0.5*(coordmin+coordmax);
5289   dxboxout = 0.5*(coordmax-coordmin);
5290   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5291                                         - (kendcapcoverplatesmallholenumber[1]-1)
5292                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5293   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5294                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5295   yboxout = 0.5*(coordmin+coordmax);
5296   dyboxout = 0.5*(coordmax-coordmin);
5297   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5298   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5299   xboxin = 0.5*(coordmin+coordmax);
5300   dxboxin = 0.5*(coordmax-coordmin);
5301   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5302   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5303                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5304                                         + fgkEndCapCoverPlateSmallHoleRadius;
5305   yboxin = 0.5*(coordmin+coordmax);
5306   dyboxin = 0.5*(coordmax-coordmin);
5307   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5308   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5309                                                          xboxout, yboxout, 0.);
5310   trendCapCoverPlateContourboxout->RegisterYourself();
5311   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5312   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5313                                                          xboxin, yboxin, 0.);
5314   trendCapCoverPlateContourboxin->RegisterYourself();
5315   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5316         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5317
5318   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5319                                                                            fSSDAlCoolBlockMedium);
5320   contour->SetLineColor(6);
5321   /////////////////////////////
5322   // Hole Contour Shape Definition 
5323   ////////////////////////////
5324   coordmin = xcontourvertex[0];
5325   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5326   xboxout = 0.5*(coordmin+coordmax);
5327   dxboxout = 0.5*(coordmax-coordmin);
5328   coordmin = ycontourvertex[1];
5329   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5330   yboxout = 0.5*(coordmin+coordmax);
5331   dyboxout = 0.5*(coordmax-coordmin);
5332   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5333                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5334   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5335   xboxin = 0.5*(coordmin+coordmax);
5336   dxboxin = 0.5*(coordmax-coordmin);
5337   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5338                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5339   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5340   yboxin = 0.5*(coordmin+coordmax);
5341   dyboxin = 0.5*(coordmax-coordmin);
5342   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5343   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5344                                                          xboxout, yboxout, 0.);
5345   trendCapCoverPlateContourboxout1->RegisterYourself();
5346   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5347   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5348                                                          xboxin, yboxin, 0.);
5349   trendCapCoverPlateContourboxin1->RegisterYourself();
5350   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5351         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5352
5353
5354   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5355   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5356   xboxout = 0.5*(coordmin+coordmax);
5357   dxboxout = 0.5*(coordmax-coordmin);
5358   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5359                                                    - fgkEndCapCoverPlateWidth[0]);
5360   coordmax = ycontourvertex[0];
5361   yboxout = 0.5*(coordmin+coordmax);
5362   dyboxout = 0.5*(coordmax-coordmin);
5363   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5364                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5365   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5366   xboxin = 0.5*(coordmin+coordmax);
5367   dxboxin = 0.5*(coordmax-coordmin);
5368   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5369                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5370                                                    - fgkEndCapCoverPlateWidth[0]
5371                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5372   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5373   yboxin = 0.5*(coordmin+coordmax);
5374   dyboxin = 0.5*(coordmax-coordmin);
5375   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5376   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5377                                                          xboxout, yboxout, 0.);
5378   trendCapCoverPlateContourboxout2->RegisterYourself();
5379   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5380   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5381                                                          xboxin, yboxin, 0.);
5382   trendCapCoverPlateContourboxin2->RegisterYourself();
5383   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5384         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5385   
5386 //  const Int_t kholecontourvertexnumber = 10;
5387
5388   Double_t xholecontourvertex[2][kcontourvertexnumber];
5389   Double_t yholecontourvertex[2][kcontourvertexnumber];
5390   xholecontourvertex[0][0] = xcontourvertex[0];
5391   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5392   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5393   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5394   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5395                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5396                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5397   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5398   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5399                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5400   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5401   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5402   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5403   
5404   yholecontourvertex[0][0] = ycontourvertex[1];
5405   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5406   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5407   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5408   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5409   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5410                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5411   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5412   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5413   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5414   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5415
5416   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5417   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5418   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5419   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5420   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5421                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5422                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5423   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5424   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5425                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5426   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5427   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5428   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5429   
5430   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5431                                                    - fgkEndCapCoverPlateWidth[0]);
5432   yholecontourvertex[1][1] = ycontourvertex[0];
5433   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5434   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5435   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5436   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5437                                                    - fgkEndCapCoverPlateWidth[0]
5438                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5439   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5440   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5441   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5442   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5443
5444   TGeoVolume* holecontour[2];
5445   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5446                                                                   fSSDAlCoolBlockMedium);
5447   holecontour[0]->SetLineColor(6);
5448   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5449                                                                   fSSDAlCoolBlockMedium);
5450   holecontour[1]->SetLineColor(6);
5451   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5452                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5453   TGeoTranslation*  bigholetrans[3];
5454   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5455                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5456   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5457                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5458                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5459   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5460                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5461   /////////////////////////////////
5462   // Mother Volume Xtru Definition 
5463   /////////////////////////////////
5464   const Int_t kmothervertexnumber = 12;
5465   Double_t xmothervertex[kmothervertexnumber];  
5466   Double_t ymothervertex[kmothervertexnumber];  
5467   xmothervertex[0]  = xcontourvertex[0];
5468   xmothervertex[1]  = xmothervertex[0];
5469   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5470   xmothervertex[3]  = xmothervertex[2];
5471   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5472   xmothervertex[5]  = xmothervertex[4];
5473   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5474   xmothervertex[7]  = xmothervertex[6];
5475   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5476                                         + fgkEndCapCoverPlateLength[2]; 
5477   xmothervertex[9]  = xmothervertex[8];
5478   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5479   xmothervertex[11] = xmothervertex[10];
5480   
5481   ymothervertex[0]  = ycontourvertex[0];
5482   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5483   ymothervertex[2]  = ymothervertex[1];
5484   ymothervertex[3]  = ycontourvertex[1];
5485   ymothervertex[4]  = ymothervertex[3];
5486   ymothervertex[5]  = ymothervertex[1];
5487   ymothervertex[6]  = ymothervertex[5];
5488   ymothervertex[7]  = ymothervertex[0];
5489   ymothervertex[8]  = ymothervertex[7];
5490   ymothervertex[9]  = ymothervertex[8]
5491                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5492   ymothervertex[10] = ymothervertex[9];
5493   ymothervertex[11] = ymothervertex[8];
5494   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5495   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5496   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5497   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5498   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5499   ////////////////////////////////////////
5500   // Adding Nodes
5501   ////////////////////////////////////////
5502 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5503   TGeoTranslation*** endcapcoverplatesmallholetrans;
5504   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5505   Double_t transx[4] = {0,
5506                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5507                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5508                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5509                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5510                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5511   Int_t index = 0;
5512   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5513         endcapcoverplatesmallholetrans[i] = 
5514                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5515     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5516                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5517             endcapcoverplatesmallholetrans[i][j] = 
5518                 new TGeoTranslation(transx[i],
5519                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5520             if(index!=10){ 
5521                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5522                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5523                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5524                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5525                 }
5526                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5527                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5528                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5529     }
5530   }
5531   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5532   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5533   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5534   mothercoverplate->AddNode(endcapfillingbox,1);
5535   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5536   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5537   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5538   mothercoverplate->AddNode(holecontour[0],1);
5539   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5540   mothercoverplate->AddNode(holecontour[1],1);  
5541   mothercoverplate->AddNode(contour,1);
5542   /////////////////////////////////
5543   return mothercoverplate;      
5544  }
5545  ////////////////////////////////////////////////////////////////////////////////
5546  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5547   /////////////////////////////////////////////////////////////
5548   // Getting EndCap Cooling Tube 
5549   /////////////////////////////////////////////////////////////
5550   TGeoTorus* endcapcoolingtubetorushape[5];
5551   TGeoVolume* endcapcoolingtubetorus[5];
5552   TGeoTube* endcapcoolingtubeshape[4];
5553   TGeoVolume* endcapcoolingtube[4];
5554   char endcapcoolingtubetorusname[30];
5555   char endcapcoolingtubename[30];
5556   TGeoTorus* endcapcoolingwatertubetorushape[5];
5557   TGeoVolume* endcapcoolingwatertubetorus[5];
5558   TGeoTube* endcapcoolingwatertubeshape[4];
5559   TGeoVolume* endcapcoolingwatertube[4];
5560   char endcapcoolingwatertubetorusname[30];
5561   char endcapcoolingwatertubename[30];
5562   for(Int_t i=0; i<5; i++){
5563         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5564         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5565         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5566         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5567         if(i==3){
5568                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5569                                                                                 fgkEndCapCoolingTubeRadiusMin,
5570                                                                                 fgkEndCapCoolingTubeRadiusMax,
5571                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5572                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5573                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5574                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5575     }
5576         else{
5577                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5578                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5579                                                                            fgkEndCapCoolingTubeRadiusMin,
5580                                                                            fgkEndCapCoolingTubeRadiusMax,
5581                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5582                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5583                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5584                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5585                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5586         }
5587         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5588                                                                                            endcapcoolingtubetorushape[i],
5589                                                                                            fSSDCoolingTubePhynox);
5590         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5591                                                                                                         endcapcoolingwatertubetorushape[i],
5592                                                                                                         fSSDCoolingTubeWater);
5593     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5594     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5595     if(i<4){
5596                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5597                                                                   fgkEndCapCoolingTubeRadiusMax,
5598                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5599                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5600                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5601         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5602                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5603         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5604                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5605                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5606                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5607         }
5608   }
5609   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5610   /////////////////////////////////////////
5611   // Transformation for Volume Positioning 
5612   /////////////////////////////////////////
5613   TGeoCombiTrans* coolingtubecombitrans[6];
5614   TGeoRotation* coolingtuberot[8];
5615   TGeoTranslation* coolingtubetrans[6];
5616   TGeoHMatrix* coolingtubematrix[4];
5617   TGeoCombiTrans* torustubecombitrans[4];
5618   TGeoRotation* torustuberot[7];
5619   TGeoTranslation* torustubetrans[4];
5620   TGeoHMatrix* torustubematrix[5];
5621   TGeoCombiTrans* coolingwatertubecombitrans[6];
5622   TGeoRotation* coolingwatertuberot[8];
5623   TGeoTranslation* coolingwatertubetrans[6];
5624   TGeoHMatrix* coolingwatertubematrix[4];
5625   TGeoCombiTrans* toruswatertubecombitrans[4];
5626   TGeoRotation* toruswatertuberot[7];
5627   TGeoTranslation* toruswatertubetrans[4];
5628   TGeoHMatrix* toruswatertubematrix[5];
5629   for(Int_t i=0; i<8; i++){
5630     if(i<6){
5631          coolingtubetrans[i] = new TGeoTranslation();
5632          coolingwatertubetrans[i] = new TGeoTranslation();
5633     }
5634     if(i<8){
5635          coolingtuberot[i] = new TGeoRotation();
5636          coolingwatertuberot[i] = new TGeoRotation();
5637     }
5638     if(i<4){
5639          torustubetrans[i] = new TGeoTranslation();
5640          toruswatertubetrans[i] = new TGeoTranslation();
5641     }
5642     if(i<7){
5643          torustuberot[i] = new TGeoRotation();
5644          toruswatertuberot[i] = new TGeoRotation();
5645         }
5646   }
5647   /////////////////////////////////////////
5648   // Transformation for Inox Volume Positioning 
5649   /////////////////////////////////////////
5650   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5651                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5652   coolingtuberot[0]->SetAngles(0.,90.,0.);
5653   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5654                                                                                                 *coolingtuberot[0]);
5655                                                                                                 
5656   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5657   coolingtuberot[1]->SetAngles(0.,90.,0.);
5658   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5659                                                                                                 *coolingtuberot[1]);
5660
5661   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5662                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5663                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5664                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5665                                                                           0.);
5666   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5667   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5668                                                                                                 *coolingtuberot[2]);
5669
5670   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5671                                            *                             (*coolingtubecombitrans[1]));
5672
5673   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5674                                                                          endcapcoolingtubeshape[1]->GetDz());
5675   torustuberot[0]->SetAngles(0.,90.,0.); 
5676   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5677
5678   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5679
5680   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5681                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5682   coolingtuberot[3]->SetAngles(0.,90.,0.);
5683   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5684                                                                                                 *coolingtuberot[3]);
5685   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5686   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5687   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5688   
5689   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5690                                                                         endcapcoolingtubeshape[2]->GetDz());
5691   torustuberot[1]->SetAngles(0.,90.,0.); 
5692   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5693   torustuberot[2]->SetAngles(180.,0.,0.); 
5694   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5695   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5696
5697   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5698                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5699   torustuberot[3]->SetAngles(0.,90.,0.); 
5700   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5701   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5702   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5703   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5704
5705   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5706                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5707   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5708   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5709                                                                                                 *coolingtuberot[5]);
5710   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5711   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5712   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5713   
5714   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5715                                                                         endcapcoolingtubeshape[0]->GetDz());
5716   torustuberot[5]->SetAngles(0.,90.,0.); 
5717   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5718   torustuberot[6]->SetAngles(-90.,0.,0.); 
5719   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5720   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5721   
5722   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5723                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5724   coolingtuberot[6]->SetAngles(0.,90.,0.);
5725   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5726                                                                                                 *coolingtuberot[6]);
5727   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5728   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5729   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5730     /////////////////////////////////////////
5731   // Transformation for Water Volume Positioning 
5732   /////////////////////////////////////////
5733   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5734                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5735   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5736   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5737                                                                                                      *coolingwatertuberot[0]);
5738
5739   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5740   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5741   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5742                                                                                                      *coolingwatertuberot[1]);
5743
5744   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5745                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5746                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5747                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5748                                                                               0.);
5749   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5750   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5751                                                                                                     *coolingwatertuberot[2]);
5752
5753   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5754                                            *                                 (*coolingwatertubecombitrans[1]));
5755                                            
5756   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5757                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5758   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5759   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5760                                                                                                    *toruswatertuberot[0]);
5761
5762   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5763                                                   *                                     (*toruswatertubecombitrans[0]));
5764
5765   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5766                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5767   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5768   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5769                                                                                                      *coolingwatertuberot[3]);
5770   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5771   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5772                                                         *                                 (*coolingwatertubecombitrans[3]));
5773   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5774
5775   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5776                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5777   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5778   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5779                                                                                                    *toruswatertuberot[1]);
5780   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5781   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5782                                                   *                 (*toruswatertubecombitrans[1]));
5783   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5784   
5785   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5786                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5787   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5788   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5789                                                                                                    *toruswatertuberot[3]);
5790   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5791   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5792                                                   *                                     (*toruswatertubecombitrans[2]));
5793   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5794
5795   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5796                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5797   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5798   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5799                                                                                                      *coolingwatertuberot[5]);
5800   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5801   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5802                                                         *                                 (*coolingwatertubecombitrans[4]));
5803   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5804   
5805   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5806                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5807   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5808   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5809                                                                                                    *toruswatertuberot[5]);
5810   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5811   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5812                                                   *                 (*toruswatertubecombitrans[3]));
5813   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5814   
5815   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5816                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5817   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5818   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5819                                                                                                      *coolingwatertuberot[6]);
5820   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5821   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5822                                                         *                                 (*coolingwatertubecombitrans[5]));
5823   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5824   /////////////////////////////////////////
5825   // Positioning Volumes
5826   /////////////////////////////////////////
5827   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5828   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5829   
5830   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5831   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5832
5833   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5834   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5835  
5836   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5837   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5838
5839   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5840   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5841
5842   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5843   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5844
5845   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5846   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5847
5848   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5849   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5850   
5851   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5852   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5853  
5854   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5855   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5856   /////////////////////////////////////////////////////////////
5857   // Deallocating memory
5858   /////////////////////////////////////////////////////////////
5859   for(Int_t i=0; i<8; i++){
5860     if(i<6){
5861          delete coolingtubetrans[i];
5862          delete coolingwatertubetrans[i];
5863          if(i!=0){
5864           delete coolingtubecombitrans[i];
5865           delete coolingwatertubecombitrans[i];
5866          }
5867         }
5868     if(i<8){
5869           delete coolingtuberot[i];
5870           delete coolingwatertuberot[i];
5871     }
5872     if(i<4){
5873                 delete torustubetrans[i];
5874                 delete toruswatertubetrans[i];
5875                 delete torustubecombitrans[i];
5876                 delete toruswatertubecombitrans[i];
5877         } 
5878     if(i<7){
5879          delete torustuberot[i];
5880          delete toruswatertuberot[i];
5881         }
5882   }
5883   /////////////////////////////////////////////////////////////
5884   return endcapcoolingtubemother;
5885  }
5886  ////////////////////////////////////////////////////////////////////////////////
5887  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5888   /////////////////////////////////////////////////////////////
5889   // Getting EndCap Cover Side 
5890   /////////////////////////////////////////////////////////////
5891   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5892   const Int_t kvertexnumber = 15; 
5893   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5894   xvertex[0]  = 0.0;
5895   xvertex[1]  = xvertex[0];
5896   xvertex[2]  = fgkEndCapSideCoverLength[0];
5897   xvertex[3]  = fgkEndCapSideCoverLength[1];
5898   xvertex[4]  = xvertex[3];
5899   xvertex[5]  = fgkEndCapSideCoverLength[2];
5900   xvertex[6]  = xvertex[5];
5901   xvertex[7]  = xvertex[2];
5902   xvertex[8]  = xvertex[7];
5903   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5904   xvertex[10] = xvertex[9];
5905   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5906                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5907                           * fgkEndCapSideCoverLength[4];
5908   xvertex[12] = xvertex[11];
5909   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5910                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5911                           * fgkEndCapSideCoverLength[4];
5912   xvertex[14] = xvertex[13];
5913   yvertex[0]  = 0.0;
5914   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5915   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5916   yvertex[3]  = yvertex[2];
5917   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5918   yvertex[5]  = yvertex[4];
5919   yvertex[6]  = yvertex[0];
5920   yvertex[7]  = yvertex[6];
5921   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5922   yvertex[9]  = yvertex[8];
5923   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5924   yvertex[11] = yvertex[10];
5925   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5926   yvertex[13] = yvertex[12];
5927   yvertex[14] = yvertex[6];
5928   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5929   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5930   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5931   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5932   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5933   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
5934   endcapsidecovershapein->SetName("endcapsidecovershapein");
5935   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
5936   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
5937   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
5938
5939
5940   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
5941   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5942                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5943   endcapsidecover->SetLineColor(fColorPhynox);
5944   ////////////////////////////////////////////
5945   // Defininition of Mother Volume
5946   ////////////////////////////////////////////
5947   const Int_t kmothervertexnumber = 7;
5948   Double_t xmothervertex[kmothervertexnumber]; 
5949   Double_t ymothervertex[kmothervertexnumber]; 
5950   for(Int_t i=0; i<kmothervertexnumber; i++){
5951         xmothervertex[i] = xvertex[i];
5952         ymothervertex[i] = yvertex[i];
5953   }
5954   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5955   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5956   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5957   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5958   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5959                                                                 endcapsidecovermothershape,fSSDAir);
5960   ////////////////////////////////////////////
5961   endcapsidecovermother->AddNode(endcapsidecover,1);
5962   TGeoBBox* endcapsidecoverboxshape[4];
5963   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5964                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5965                                                                0.5*fgkEndCapSideCoverLength[4],
5966                                                                    0.5*fgkEndCapSideCoverThickness); 
5967   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5968                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5969                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5970                                                          -     fgkEndCapSideCoverLength[4]),
5971                                                                    0.5*fgkEndCapSideCoverThickness); 
5972   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5973                                                                0.5*fgkEndCapSideCoverLength[4],
5974                                                                    0.5*fgkEndCapSideCoverThickness); 
5975   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5976                                                                0.5*fgkEndCapSideCoverWidth[5],
5977                                                                    0.5*fgkEndCapSideCoverThickness); 
5978   TGeoVolume* endcapsidecoverbox[4];
5979   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5980   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5981   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5982   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5983   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5984 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5985   TGeoTranslation** endcapsidecoverboxtrans;
5986   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5987   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5988                                                          +                                         fgkEndCapSideCoverLength[0],
5989                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5990                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5991   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5992                                                          +                     xvertex[11],
5993                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5994                                                          +                     yvertex[12],0.);
5995   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5996                                                          +                     xvertex[11],
5997                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5998                                                          +                     yvertex[12]
5999                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
6000                                                          +                     fgkEndCapSideCoverWidth[5],0.);
6001   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
6002   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
6003   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
6004   for(Int_t i=0; i<2; i++)
6005         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
6006                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
6007                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
6008                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6009                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6010                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
6011                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
6012                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
6013         }
6014   for(Int_t i=0; i<2; i++)
6015         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
6016                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
6017                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
6018                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6019                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6020                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
6021                                                         +fgkEndCapSideCoverLength[4]),0.0);
6022                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
6023                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
6024                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
6025                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
6026         }
6027         return endcapsidecovermother;
6028  } 
6029  ////////////////////////////////////////////////////////////////////////////////
6030  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
6031  ////////////////////////////////////////////////////////////////////////////////
6032  // Method returning Interface Card A, Interface Card B, Supply Card 
6033  ////////////////////////////////////////////////////////////////////////////////
6034  /////////////////////
6035  // Supply Card
6036  /////////////////////
6037  // Electronic Board Back Al Plane
6038  const Int_t kelectboardbackvertexnumber = 8;
6039  Double_t xelectboardback[kelectboardbackvertexnumber];
6040  Double_t yelectboardback[kelectboardbackvertexnumber];
6041  xelectboardback[0] = 0.0;
6042  xelectboardback[1] = xelectboardback[0];
6043  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
6044  xelectboardback[3] = xelectboardback[2];
6045  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
6046  xelectboardback[5] = xelectboardback[4];
6047  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
6048  xelectboardback[7] = xelectboardback[6];
6049  
6050  yelectboardback[0] = 0.0;
6051  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
6052  yelectboardback[2] = yelectboardback[1];
6053  yelectboardback[3] = yelectboardback[0];
6054  yelectboardback[4] = yelectboardback[3];
6055  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
6056  yelectboardback[6] = yelectboardback[5];
6057  yelectboardback[7] = yelectboardback[4];
6058  TGeoXtru* electboardbackshape = new TGeoXtru(2);
6059  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
6060                                                                         xelectboardback,yelectboardback); 
6061  electboardbackshape->DefineSection(0,0.0);
6062  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
6063  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
6064                                                                                          electboardbackshape,fSSDSupportRingAl);
6065  electboardback->SetLineColor(fColorAl);
6066  // Electronic Board Kapton Layer
6067  const Int_t kelectlayervertexnumber = 8;
6068  Double_t xelectlayer[kelectlayervertexnumber];
6069  Double_t yelectlayer[kelectlayervertexnumber];
6070  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
6071  xelectlayer[1] = xelectlayer[0];
6072  xelectlayer[2] = fgkEndCapCardElectBoardLength;
6073  xelectlayer[3] = xelectlayer[2];
6074  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
6075      
6076  yelectlayer[0] = 0.0;
6077  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
6078  yelectlayer[2] = yelectlayer[1];
6079  yelectlayer[3] = yelectlayer[0];
6080  yelectlayer[4] = yelectlayer[3];
6081  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
6082  yelectlayer[6] = yelectlayer[5];
6083  yelectlayer[7] = yelectlayer[4];
6084  TGeoXtru* electlayershape = new TGeoXtru(2);
6085  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
6086  electlayershape->DefineSection(0,0.0);
6087  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
6088  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
6089                                                                                          electlayershape,fSSDKaptonFlexMedium);
6090  electlayer->SetLineColor(fColorKapton);
6091  // JMD Connector Female
6092  const Int_t kjmdconnectorvertexnumber = 6;
6093  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6094  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6095  xjmdconnectorvertex[0] = 0.0; 
6096  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
6097  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
6098  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
6099  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
6100  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
6101
6102  yjmdconnectorvertex[0] = 0.0; 
6103  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
6104  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
6105  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
6106  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
6107  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
6108  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
6109  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
6110                                                                   yjmdconnectorvertex); 
6111  jmdconnectorshape->DefineSection(0,0.0);
6112  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6113  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6114                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6115  jmdconnector->SetLineColor(fColorG10);
6116  // Top Cable Connector
6117  const Int_t kcableconnectorvertexnumber = 8;
6118  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6119  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6120  xconnectorvertex[0] = 0.0;
6121  xconnectorvertex[1] = xconnectorvertex[0];
6122  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6123  xconnectorvertex[3] = xconnectorvertex[2];
6124  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6125                                          - fgkEndCapCardCableConnectorLength[2];
6126  xconnectorvertex[5] = xconnectorvertex[4];
6127  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6128  xconnectorvertex[7] = xconnectorvertex[6];
6129
6130  yconnectorvertex[0] = 0.0;
6131  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6132  yconnectorvertex[2] = yconnectorvertex[1];
6133  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6134  yconnectorvertex[4] = yconnectorvertex[3];
6135  yconnectorvertex[5] = yconnectorvertex[1];
6136  yconnectorvertex[6] = yconnectorvertex[5];
6137  yconnectorvertex[7] = yconnectorvertex[0];
6138  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6139  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6140                                                                     yconnectorvertex); 
6141  cableconnectorshape->DefineSection(0,0.0);
6142  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6143  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6144                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6145  cableconnector->SetLineColor(fColorG10);
6146  // Strip Connection
6147  TGeoBBox* endcapstripconnectionshape = 
6148                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6149                                                                                          0.5*fgkEndCapStripConnectionThickness,
6150                                                                                          0.5*fgkEndCapStripConnectionWidth);
6151  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6152                                                                                                         endcapstripconnectionshape,
6153                                                                                                         fSSDSupportRingAl);
6154  endcapstripconnection->SetLineColor(fColorAl);
6155  // Interface Card B
6156  const Int_t kcardBvertexnumber = 12; 
6157  Double_t xcardBvertexnumber[kcardBvertexnumber];
6158  Double_t ycardBvertexnumber[kcardBvertexnumber];
6159
6160  xcardBvertexnumber[0]  = 0.0;
6161  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6162  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6163  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6164  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6165  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6166  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6167  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6168  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6169  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6170  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6171  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6172  
6173  ycardBvertexnumber[0]  = 0.0;
6174  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6175  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6176  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6177  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6178  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6179  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6180  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6181  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6182  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6183  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6184  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6185
6186  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6187  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6188  interfacecardBshape->DefineSection(0,0.);
6189  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6190  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6191                                                                                          fSSDMountingBlockMedium);
6192  interfacecardB->SetLineColor(46);
6193  // Interface Card B Electronic Board
6194  const Int_t kelectboardcardBvertexnumber = 14; 
6195  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6196  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6197
6198  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6199  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6200  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6201  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6202  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6203  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6204  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6205  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6206  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6207  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6208  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6209  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6210  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6211  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6212
6213  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6214  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6215  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6216  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6217  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6218  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6219  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6220  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6221  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6222  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6223  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6224  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6225  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6226  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6227
6228  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6229  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6230                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6231  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6232  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6233                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6234  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6235                                                                                           fSSDSupportRingAl);
6236  electboardcardB->SetLineColor(fColorAl);
6237  // Generating Stiffener 2
6238  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6239                                                                                            0.5*fgkEndCapStiffenerThickness,
6240                                                                                            0.5*fgkEndCapStiffenerLength);
6241  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6242  endcapstiffener->SetLineColor(fColorAl);   
6243  // Generating Mother Interface Card B Container
6244  const Int_t kinterfacecardBmothervertexnumber = 10;
6245  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6246  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6247
6248  xinterfacecardBmothervertex[0] = 0.0;
6249  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6250  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6251                                                                 + fgkEndCapInterfaceCardBThickness;
6252  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6253  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6254                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6255  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6256  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6257  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6258  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6259                                                                 + fgkEndCapCardJMDConnectorLength[0];
6260  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6261
6262  yinterfacecardBmothervertex[0] = 0.0;
6263  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6264                                                                 + fgkEndCapInterfaceCardBWidth[1]
6265                                                                 + fgkEndCapInterfaceCardBWidth[2];
6266  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6267  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6268  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6269  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6270  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6271  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6272                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6273                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6274  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6275  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6276  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6277  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6278                                                                                   xinterfacecardBmothervertex,
6279                                                                                   yinterfacecardBmothervertex);
6280  interfacecardBmothershape->DefineSection(0,-1.e-15);
6281  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6282  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6283                                                                                                    interfacecardBmothershape,fSSDAir);
6284  electboardcardB->SetLineColor(fColorAl);
6285  // Positioning Volumes Mother Interface Card B Container 
6286  TGeoRotation* interfacecardBrot = new TGeoRotation();
6287  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6288  interfacecardBrot->SetAngles(90.,-90.,-90.);
6289  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6290  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6291  TGeoRotation* electboardcardBrot = new TGeoRotation();
6292  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6293  electboardcardBrot->SetAngles(90.,90.,-90.);
6294  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6295  TGeoCombiTrans* electboardcardBcombitrans = 
6296                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6297  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6298  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6299  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6300  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6301  TGeoTranslation* jmdconnectorcardBtrans[3];
6302  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6303  for(Int_t i=0; i<3; i++){
6304    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6305                                                          + fgkEndCapCardJMDConnectorLength[0], 
6306                                                            fgkEndCapCardElectBoardLayerWidth[1],
6307                                                            0.5*fgkEndCapCardJMDConnectorThickness
6308                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6309                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6310                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6311    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6312                                                                                                            *jmdconnectorcardBrot);
6313    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6314  }
6315  // Mother Supply Card Container 
6316  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6317  // Interface Card Container
6318  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6319  // Placing Volumes in Mother Supply Card Container
6320  // JMD Connector Positioning
6321  TGeoTranslation* jmdconnectortrans[2];
6322  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6323  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6324                                                                                         fgkEndCapCardElectBoardBackLength[0]
6325                                           -                                             fgkEndCapCardJMDConnectorThickness
6326                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6327  TGeoRotation* jmdconnectorot = new TGeoRotation();
6328  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6329                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6330                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6331                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6332                                                                       fgkEndCapCardJMDConnectorThickness
6333                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6334  jmdconnectorot->SetAngles(90.,180.,-90);
6335  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6336                                                                                 * jmdconnectorot);
6337  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6338  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6339  // Top Cable Connector Placing
6340  TGeoRotation* cableconnectorot[2];
6341  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6342  TGeoTranslation* cableconnectortrans[3];
6343  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6344  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6345  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6346  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6347  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6348                                                                                                                            *cableconnectorot[0]);
6349  TGeoHMatrix* cableconnectormatrix[2];
6350  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6351                                                         new TGeoHMatrix((*cableconnectorot[1])
6352                                                                                    *(*cableconnectorcombitrans));
6353  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6354                                            -                               fgkEndCapCardCableConnectorThickness,
6355                                                                                 fgkEndCapCardCableConnectorLength[0]
6356                                            +                            fgkEndCapCardCableConnectorToLayer);
6357  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6358                                            -                2.*fgkEndCapCardCableConnectorThickness
6359                                            -                            fgkEndCapCardCableConnectorDistance,
6360                                                                                 fgkEndCapCardCableConnectorLength[0]
6361                                            +                            fgkEndCapCardCableConnectorToLayer);
6362  for(Int_t i=0; i<2; i++){
6363         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6364     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6365  }
6366  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6367  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6368  electboardbackrot->SetAngles(90.,-90.,-90.);
6369  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6370                                                         +                fgkEndCapCardJMDConnectorLength[0]
6371                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6372  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6373                                                                                                                            *electboardbackrot);
6374  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6375  // Electronic Board Kapton Layer Positioning
6376  TGeoRotation* electlayerrot = new TGeoRotation();
6377  TGeoTranslation* electlayertrans[2];
6378  TGeoCombiTrans* electlayercombitrans[2];
6379  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6380  electlayerrot->SetAngles(90.,-90.,-90.);
6381  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6382                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6383  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6384                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6385                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6386  for(Int_t i=0; i<2; i++){
6387         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6388         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6389  }
6390  // Placing Volumes in Mother Interface Card Container
6391  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6392  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6393  for(Int_t i=0; i<2; i++){
6394         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6395  }
6396  /////////////////////////////////////////////////////////////
6397  // Generation of Card Interface Container
6398  /////////////////////////////////////////////////////////////
6399  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6400                                                   - fgkEndCapCardJMDConnectorLength[0]
6401                                                   - fgkEndCapInterfaceCardBThickness
6402                                                   - 9.*fgkEndCapStripConnectionThickness
6403                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6404  const Int_t kcardinterfacecontainervertexnumber = 14;
6405  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6406  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6407  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6408                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6409  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6410  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6411                                                                    + fgkEndCapStripConnectionThickness
6412                                                                    - fgkEndCapCardElectBoardLayerThickness
6413                                                                    - fgkEndCapCardCableConnectorWidth[0];
6414  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6415  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6416  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6417  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6418                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6419  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6420  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6421                                                                    + fgkEndCapInterfaceCardBThickness;
6422  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6423  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6424                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6425  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6426  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6427                                    - fgkEndCapInterfaceElectBoardCardBThickness
6428                                                                    + fgkEndCapCardJMDConnectorLength[0]
6429                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6430  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6431
6432  ycardinterfacecontainervertex[0]  = 0.;
6433  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6434                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6435                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6436  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6437  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6438                                                                    - fgkEndCapStripConnectionWidth;
6439  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6440  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6441  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6442  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6443                                                                    + fgkEndCapInterfaceCardBWidth[1]
6444                                                                    + fgkEndCapInterfaceCardBWidth[2];
6445  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6446  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6447  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6448  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6449  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6450  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6451  
6452  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6453  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6454                                                                                   xcardinterfacecontainervertex,
6455                                                                                   ycardinterfacecontainervertex);
6456  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6457                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6458  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6459                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6460  TGeoVolume** cardinterfacecontainer;
6461  cardinterfacecontainer = new TGeoVolume*[4];
6462  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6463                                                                                         interfacecardmothershape,fSSDAir); 
6464  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6465                                                                                         interfacecardmothershape,fSSDAir); 
6466  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6467                                                                                         interfacecardmothershape,fSSDAir); 
6468  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6469                                                                                         interfacecardmothershape,fSSDAir); 
6470  /////////////////////////////////
6471  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6472  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6473  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6474  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6475  /////////////////////////////////
6476  TGeoRotation* endcapstripconnectionrot[2];
6477  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6478  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6479  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6480  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6481                                                                         *                                 (*endcapstripconnectionrot[0]));
6482  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6483  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6484                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6485                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6486                                                                                         -endcapstripconnectionshape->GetDZ(),
6487                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6488  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6489  TGeoTranslation* cardinterfacetrans[9];
6490  TGeoHMatrix* cardinterfacematrix[9]; 
6491  for(Int_t i=0; i<7; i++){ 
6492         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6493                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6494                                                                                                 0.0,0.0);  
6495         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6496                                                    *                             (*endcapstripconnectionmatrix));
6497  }
6498  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6499                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6500                                                                                                 0.0,0.0);  
6501  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6502                                                 *                                 (*endcapstripconnectionmatrix));
6503  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6504                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6505                                                                                                 0.0,0.0);  
6506  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6507                                                 *                                 (*endcapstripconnectionmatrix));
6508
6509  for(Int_t i=0; i<4; i++){
6510         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6511                                                                            cardinterfacematrix[7]);                             
6512         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6513                                                                            cardinterfacematrix[8]);                             
6514  }
6515  TGeoTranslation* mothersupplycardtrans = 
6516                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6517                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6518                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6519  TGeoHMatrix* mothersupplycardmatrix[7];
6520  Int_t index[4] = {1,1,1,1};
6521  for(Int_t i=0; i<7; i++){
6522         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6523                                                         *                                 (*mothersupplycardtrans));
6524         for(Int_t j=0; j<4; j++){
6525                 switch(j){
6526                         case 0: //Layer5 EndCap Left Side  
6527                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6528                                                                                                    cardinterfacematrix[i]);                             
6529                                 if(i!=0){
6530                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6531                                                                                                            mothersupplycardmatrix[i]);                  
6532                                         index[j]++;
6533
6534                                 }
6535                         break;
6536                         case 1: //Layer5 EndCap Rigth Side  
6537                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6538                                                                                                    cardinterfacematrix[i]);                     
6539                                 if(i>0&&i<6){
6540                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6541                                                                                                            mothersupplycardmatrix[i]);                  
6542                                         index[j]++;
6543                                 }
6544                         break;
6545                         case 2: //Layer6 EndCap Left Side  
6546                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6547                                                                                                    cardinterfacematrix[i]);                             
6548                                 if(i!=6){
6549                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6550                                                                                                            mothersupplycardmatrix[i]);                  
6551                                         index[j]++;
6552                                 }
6553                         break;
6554                         case 3: //Layer6 EndCap Right Side  
6555                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6556                                                                                                    cardinterfacematrix[i]);                             
6557                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6558                                                                                                    mothersupplycardmatrix[i]);                  
6559                                 index[j]++;
6560                         break;
6561                 }
6562         }
6563  }
6564  // Positioning Interface 
6565  TGeoTranslation* motherinterfacecardtrans = 
6566                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6567                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6568                                                          -fgkEndCapCardElectBoardLayerThickness
6569                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6570  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6571                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6572  // Positioning Interface Card B 
6573  TGeoTranslation* interfacecardBmothertrans = 
6574                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6575                                                                                 + 2.*fgkEndCapStripConnectionThickness
6576                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6577                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6578                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6579  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6580                                                                                                                          interfacecardBmothertrans);
6581  // Positioning Stiffener 
6582  TGeoTranslation* endcapstiffenertrans = 
6583                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6584                                                                            +    2.0*fgkEndCapStripConnectionThickness
6585                                                                            +    fgkEndCapInterfaceCardBThickness
6586                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6587                                                                            +    stiffenertransx
6588                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6589                                                                                         endcapstiffenershape->GetDZ()
6590                                                                            -    0.5*(fgkEndCapStiffenerLength
6591                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6592  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6593  /////////////////////////////////////////////////////////////
6594  // Deallocating memory
6595  /////////////////////////////////////////////////////////////
6596  delete interfacecardBrot;
6597  delete interfacecardBtrans;
6598  delete electboardcardBtrans;
6599  delete electboardcardBrot; 
6600  delete jmdconnectorcardBrot;
6601  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6602  delete jmdconnectorot;
6603  delete jmdconnectortrans[1];
6604  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6605  delete cableconnectorcombitrans;
6606  delete electboardbacktrans;
6607  delete electboardbackrot;
6608  delete electlayerrot;
6609  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6610  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6611  delete mothersupplycardtrans;
6612  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6613  /////////////////////////////////////////////////////////////
6614  return cardinterfacecontainer;
6615  }
6616  ////////////////////////////////////////////////////////////////////////////////
6617  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6618   /////////////////////////////////////////////////////////////
6619   // Method returning EndCap Mother Volume
6620   /////////////////////////////////////////////////////////////
6621   const Int_t kendcapcoverplatesmallholenumber = 9;
6622   Double_t endcapmotherorigin[3];
6623   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6624                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6625                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6626   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6627                                           -                      fgkEndCapCoverPlateWidth[2]
6628                                           -       (kendcapcoverplatesmallholenumber-1)
6629                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6630                                           +  0.5*(fgkEndCapSideCoverLength[2]
6631                                           +               fgkEndCapCoverPlateWidth[1]
6632                                           -       fgkEndCapCoverPlateWidth[0])
6633                                           -      (fgkEndCapCoverPlateWidth[1]
6634                                           -       fgkEndCapCoverPlateWidth[0]);
6635   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6636                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6637                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6638                                                 +      fgkEndCapSideCoverWidth[1]
6639                                                 +      fgkEndCapSideCoverThickness
6640                                                 +      fgkEndCapKaptonFoilThickness);
6641   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6642                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6643                                                           +              2.0* fgkEndCapSideCoverThickness),
6644                                                                          0.5* (fgkEndCapSideCoverLength[2]
6645                                                           +                    fgkEndCapCoverPlateWidth[1]
6646                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6647                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6648                                                       +                                    fgkEndCapSideCoverWidth[1]
6649                                                           +                                       fgkEndCapSideCoverThickness
6650                                                       +                                   fgkEndCapKaptonFoilThickness),
6651                                                                                          endcapmotherorigin);
6652   TGeoVolume** endcapassembly;  
6653   endcapassembly = new TGeoVolume*[4];
6654   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6655                                                                                         endcapmothershape,fSSDAir); 
6656   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6657                                                                                         endcapmothershape,fSSDAir); 
6658   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6659                                                                                         endcapmothershape,fSSDAir); 
6660   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6661                                                                                         endcapmothershape,fSSDAir); 
6662  /////////////////////////////////
6663  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6664  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6665  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6666  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6667  /////////////////////////////////
6668   /////////////////////////////////////////////////////
6669   // Placing Endcap Cover Plate
6670   /////////////////////////////////////////////////////
6671   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6672   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6673   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6674   TGeoCombiTrans* endcapcoverplatecombitrans = 
6675                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6676                                                                                          endcapcoverplaterot);
6677   TGeoTranslation* endcapcoverplatetrans = 
6678                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6679   TGeoHMatrix* endcapcoverplatematrix = 
6680                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6681                                                                           *       (*endcapcoverplatecombitrans));
6682   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6683   /////////////////////////////////////////////////////
6684   // Placing Endcap Side Cover
6685   /////////////////////////////////////////////////////
6686   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6687   TGeoRotation* endcapsidecoverot[2];
6688   TGeoCombiTrans* endcapsidecovercombitrans[3];
6689   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6690   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6691   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6692                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6693                                                                                         - fgkEndCapCoverPlateWidth[2]
6694                                                                                     - (kendcapcoverplatesmallholenumber-1)
6695                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6696                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6697                                                                                         + fgkEndCapSideCoverLength[2],
6698                                                                                           0.5*(fgkEndCapSideCoverThickness
6699                                                                                         + fgkEndCapCoverPlateThickness)
6700                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6701                                                                                           endcapsidecoverot[0]);
6702   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6703   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6704                                                                                                         0.5*fgkEndCapCoverPlateThickness
6705                                                                                                         -fgkEndCapSideCoverWidth[1],
6706                                                                                                         endcapsidecoverot[1]);
6707   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6708                                                                                                         +fgkEndCapCoverPlateLength[3]
6709                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6710                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6711                                                                                                         0.5*fgkEndCapCoverPlateThickness
6712                                                                                                         -fgkEndCapSideCoverWidth[1],
6713                                                                                                         endcapsidecoverot[1]);
6714   TGeoHMatrix* endcapsidecovermatrix[2];
6715   for(Int_t i=0; i<2; i++){
6716    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6717                                                         *                                 (*endcapsidecovercombitrans[0]));
6718         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6719                                                                                                                 endcapsidecovermatrix[i]);
6720   }
6721   /////////////////////////////////////////////////////
6722   // Placing Endcap Cooling Tube
6723   /////////////////////////////////////////////////////
6724   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6725   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6726   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6727   TGeoCombiTrans* endcapccolingtubecombitrans 
6728                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6729                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6730                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6731                                                 - fgkEndCapCoolingTubeToCoverSide,
6732                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6733                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6734   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6735                                                                                                           endcapccolingtubecombitrans);
6736   /////////////////////////////////////////////////////
6737   // Placing Screws 
6738   /////////////////////////////////////////////////////
6739   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6740                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6741   Int_t screwcoverplatedgesnumber[2] = {20,20};
6742   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6743                                                                                 fgkEndCapCoverPlateThickness
6744                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6745   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6746                                                                                                  screwcoverplatedgesnumber,
6747                                                                                                  screwcoverplatesection);
6748   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6749                                                                                            screwcoverplateshape,
6750                                                                                            fSSDCoolingTubePhynox); 
6751   screwcoverplate->SetLineColor(12);
6752   Double_t transx[4] = {0,
6753                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6754                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6755                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6756                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6757                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6758   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6759 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6760   TGeoTranslation*** endcapcoverplatescrewtrans;
6761   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6762   Int_t index = 0;
6763   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6764         endcapcoverplatescrewtrans[i] = 
6765                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6766     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6767                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6768         if(index==1||index==9||index==28||index==36){
6769                         endcapcoverplatescrewtrans[i][j] = 
6770                                 new TGeoTranslation(transx[i],
6771                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6772                                                                         fgkEndCapSideCoverThickness);
6773                 }
6774                 else{
6775                         endcapcoverplatescrewtrans[i][j] = 
6776                                 new TGeoTranslation(transx[i],
6777                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6778                                                                         0.);
6779                 }
6780             if(index!=19) 
6781                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6782                                                                                           endcapcoverplatescrewtrans[i][j]);
6783         }
6784   }
6785   /////////////////////////////////////////////////////
6786   // Placing Cover Plate Clips 
6787   /////////////////////////////////////////////////////
6788   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6789                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6790                                                                                                          0.5*fgkEndCapSideCoverThickness);
6791   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6792                                                                                                         endcapcoverplateclipshape,
6793                                                                                                         fSSDCoolingTubePhynox);
6794   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6795                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6796                                                                                                          0.5*fgkEndCapSideCoverThickness);
6797   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6798                                                                                                         endcapcoverplatedownclipshape,
6799                                                                                                         fSSDCoolingTubePhynox);
6800   TGeoTranslation* endcapcoverplatecliptrans[4];
6801   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6802                                                            -                     fgkEndCapCoverPlateLength[0]
6803                                                            -                     fgkEndCapSideCoverThickness,
6804                                                                                                          0.0,
6805                                                                                                  0.5*(fgkEndCapSideCoverThickness
6806                                                            +                                              fgkEndCapCoverPlateThickness));
6807   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6808                                                            -                     fgkEndCapCoverPlateLength[0]
6809                                                            -                     fgkEndCapSideCoverThickness,
6810                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6811                                                            *                                     fgkEndCapSideCoverWidth[5],
6812                                                                                                  0.5*(fgkEndCapSideCoverThickness
6813                                                            +                                              fgkEndCapCoverPlateThickness));
6814   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6815                                                            -                     fgkEndCapCoverPlateLength[0]
6816                                                            +                                     fgkEndCapCoverPlateLength[1]
6817                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6818                                                            -                                     fgkEndCapCoverPlateClipLength
6819                                                            +                                 fgkEndCapSideCoverThickness,
6820                                                                                                          0.0,
6821                                                                                                  0.5*(fgkEndCapSideCoverThickness
6822                                                            +                                              fgkEndCapCoverPlateThickness));
6823   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6824                                                            -                     fgkEndCapCoverPlateLength[0]
6825                                                            +                                     fgkEndCapCoverPlateLength[1]
6826                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6827                                                            -                                     fgkEndCapCoverPlateClipLength
6828                                                            +                                 fgkEndCapSideCoverThickness,
6829                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6830                                                            *                                     fgkEndCapSideCoverWidth[5],
6831                                                                                                  0.5*(fgkEndCapSideCoverThickness
6832                                                            +                                              fgkEndCapCoverPlateThickness));
6833   endcapcoverplateclip->SetLineColor(fColorPhynox);
6834   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6835   for(Int_t i=0; i<4; i++) 
6836         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6837                                                                                                    endcapcoverplatecliptrans[i]);  
6838   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6839   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6840                                                                    -                     fgkEndCapCoverPlateLength[0]
6841                                                                    -                     fgkEndCapSideCoverThickness,
6842                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6843                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6844                                                                                                         0.5*(fgkEndCapSideCoverThickness
6845                                                                +                                         fgkEndCapCoverPlateThickness)
6846                                                                    -                     fgkEndCapSideCoverWidth[1]
6847                                                                    -                                     fgkEndCapSideCoverThickness);
6848   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6849                                                                    -                     fgkEndCapCoverPlateLength[0]
6850                                                                    -                     fgkEndCapSideCoverThickness,
6851                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6852                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6853                                                                    +                            fgkEndCapSideCoverLength[2]
6854                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6855                                                                                                         0.5*(fgkEndCapSideCoverThickness
6856                                                                +                                         fgkEndCapCoverPlateThickness)
6857                                                                    -                     fgkEndCapSideCoverWidth[1]
6858                                                                    -                                     fgkEndCapSideCoverThickness);
6859   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6860                                                                    -                     fgkEndCapCoverPlateLength[0]
6861                                                                    +                     fgkEndCapSideCoverThickness
6862                                                                    +                     fgkEndCapCoverPlateLength[1]
6863                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6864                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6865                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6866                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6867                                                                                                         0.5*(fgkEndCapSideCoverThickness
6868                                                                +                                         fgkEndCapCoverPlateThickness)
6869                                                                    -                     fgkEndCapSideCoverWidth[1]
6870                                                                    -                                     fgkEndCapSideCoverThickness);
6871   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6872                                                                    -                     fgkEndCapCoverPlateLength[0]
6873                                                                    +                     fgkEndCapSideCoverThickness
6874                                                                    +                     fgkEndCapCoverPlateLength[1]
6875                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6876                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6877                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6878                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6879                                                                    +                                 fgkEndCapSideCoverLength[2]
6880                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6881                                                                                                         0.5*(fgkEndCapSideCoverThickness
6882                                                                +                                         fgkEndCapCoverPlateThickness)
6883                                                                    -                     fgkEndCapSideCoverWidth[1]
6884                                                                    -                                     fgkEndCapSideCoverThickness);
6885   for(Int_t i=0; i<4; i++)
6886         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6887                                                                                                    endcapcoverplatedowncliptrans[i]);
6888   /////////////////////////////////////////////////////
6889   // Placing Kapton Foil
6890   /////////////////////////////////////////////////////
6891   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6892                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6893                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6894   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6895                                                                                                 endcapkaptonfoilshape,
6896                                                                                                 fSSDKaptonFlexMedium);
6897   endcapkaptonfoil->SetLineColor(8);
6898   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6899                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6900                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6901                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6902                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6903                                                                              -                     fgkEndCapSideCoverWidth[1]
6904                                                                                  -                     fgkEndCapSideCoverThickness);
6905   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6906   /////////////////////////////////////////////////////////////
6907   // Placing Electronic Tubes
6908   /////////////////////////////////////////////////////////////
6909   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6910                                                                              - fgkEndCapInterfaceCardBThickness
6911                                                                              - 9.*fgkEndCapStripConnectionThickness
6912                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6913                                                                                fgkEndCapKaptonFoilWidth
6914                                                                              - fgkEndCapInterfaceCardBThickness
6915                                                                              - 9.*fgkEndCapStripConnectionThickness
6916                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6917                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6918   TGeoVolume* endcapeffectivecables[2];
6919   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6920                                                                                          fgkEndCapEffectiveCableRadiusMax,
6921                                                                                          endcapeffectivecableswidth[0],
6922                                                                                          10,"EndCapEffectiveCables1"); 
6923   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6924                                                                                          fgkEndCapEffectiveCableRadiusMax,
6925                                                                                          endcapeffectivecableswidth[1],
6926                                                                                          25,"EndCapEffectiveCables2"); 
6927   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6928   TGeoTranslation* endcapeffectivecablestrans[2];
6929   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6930                                           -                                                        0.5*endcapeffectivecableswidth[0]
6931                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6932                                           -                                                               fgkEndCapCoverPlateWidth[2]
6933                                           -                                             (kendcapcoverplatesmallholenumber-1)
6934                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6935                                           +                                             fgkEndCapSideCoverLength[2],
6936                                           -                     0.5*fgkEndCapCoverPlateThickness
6937                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6938                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6939                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6940   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6941                                           -                                                        0.5*endcapeffectivecableswidth[1]
6942                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6943                                           -                                                               fgkEndCapCoverPlateWidth[2]
6944                                           -                                             (kendcapcoverplatesmallholenumber-1)
6945                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6946                                           +                                         fgkEndCapSideCoverLength[2],
6947                                           -                     0.5*fgkEndCapCoverPlateThickness
6948                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6949                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6950                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6951   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6952   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6953   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6954                                                                                                                    *endcapeffectivecablesrot);
6955   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6956                                                                                                                    *endcapeffectivecablesrot);
6957 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6958 //                                                                                                        endcapeffectivecablescombitrans[0]);
6959   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6960                                                                                                           endcapeffectivecablescombitrans[1]);
6961   /////////////////////////////////////////////////////////////
6962   // Placing End Cap Cards
6963   /////////////////////////////////////////////////////////////
6964   TGeoVolume** endcapcards = GetEndCapCards();
6965   TGeoRotation* endcapcardsrot[2];
6966   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6967   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6968   TGeoTranslation* endcapcardstrans[2]; 
6969   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6970                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6971   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6972   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6973   TGeoHMatrix* endcapcardsmatrix[2];
6974   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6975   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6976                                                   - fgkEndCapCardJMDConnectorLength[0]
6977                                                   - fgkEndCapInterfaceCardBThickness
6978                                                   - 9.*fgkEndCapStripConnectionThickness
6979                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6980   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6981                                           -                                             fgkEndCapCoverPlateLength[0]
6982                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6983                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6984                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6985                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6986                                           -                                                               fgkEndCapInterfaceCardBThickness
6987                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6988                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6989                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6990                                           -                                                               fgkEndCapCoverPlateWidth[2]
6991                                           -                                             (kendcapcoverplatesmallholenumber-1)
6992                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6993                                           +                     fgkEndCapKaptonFoilWidth,
6994                                                                                           0.5*fgkEndCapCoverPlateThickness
6995                                           -                                                     fgkEndCapSideCoverWidth[1]);
6996   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6997   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6998    /////////////////////////////////////////////////////////////
6999   // Deallocating memory
7000   /////////////////////////////////////////////////////////////
7001   delete endcapcoverplaterot;
7002   delete endcapcoverplatecombitrans;
7003   delete endcapcoverplatetrans;
7004   for(Int_t i=0; i<3; i++){
7005    delete endcapsidecovercombitrans[i];
7006    if(i<2) delete endcapsidecoverot[i]; 
7007   }
7008   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
7009   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
7010   delete endcapcardsmatrix[0];
7011   return endcapassembly;
7012  } 
7013  ////////////////////////////////////////////////////////////////////////////////
7014  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
7015                                                                                                                         Double_t radiusmax, 
7016                                                                                                                         Double_t width, 
7017                                                                                                                         Int_t ncables,
7018                                                                                                                         char* volname){
7019   /////////////////////////////////////////////////////////////
7020   // Generating EndCap High Voltage Tubes 
7021   /////////////////////////////////////////////////////////////
7022   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
7023   Double_t effectiveouteradius = TMath::Sqrt(TMath::Power(effectiveinneradius,2.)
7024                                                            +             TMath::Power(radiusmax,2.)
7025                                -             TMath::Power(radiusmin,2.));
7026   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
7027   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
7028                                                                                                    effectiveouteradius,0.5*width);
7029   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
7030                                                                                                 effectiveinnertubeshape,
7031                                                                                                 fSSDStiffenerConnectorMedium);
7032   effectiveinnertube->SetLineColor(41);
7033   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
7034                                                                                                 effectiveoutertubeshape,
7035                                                                                                 fSSDKaptonChipCableMedium);
7036   effectiveoutertube->SetLineColor(39);
7037   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
7038   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
7039   effectivemothertube->AddNode(effectiveinnertube,1);
7040   effectivemothertube->AddNode(effectiveoutertube,1);
7041   return effectivemothertube;
7042  } 
7043  ////////////////////////////////////////////////////////////////////////////////
7044  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
7045   /////////////////////////////////////////////////////////////
7046   // Generating EndCap Support Layer 5 and Layer 6 
7047   /////////////////////////////////////////////////////////////
7048   const Int_t knedges = 5;
7049   ///////////////////////////////////////////////
7050   // Setting the vertices for TGeoXtru Up Volume
7051   ///////////////////////////////////////////////
7052   const Int_t klayernumber = 2;
7053   Double_t xupvertex[klayernumber][knedges+3];
7054   Double_t yupvertex[klayernumber][knedges+3];
7055   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
7056   Double_t middledgeangle[klayernumber] = {0.0,0.0};
7057   Double_t middlepsi[klayernumber] = {0.0,0.0};
7058   for(Int_t i=0; i<klayernumber; i++){
7059         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
7060         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
7061         xupvertex[i][2] = -xupvertex[i][1];
7062         xupvertex[i][3] = -xupvertex[i][0];
7063
7064         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
7065         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
7066         yupvertex[i][2] =  yupvertex[i][1];
7067         yupvertex[i][3] =  yupvertex[i][0];
7068         
7069     middledgeangle[i] = upedgeangle[i]/knedges;
7070     middlepsi[i] = 90.0-0.5*upedgeangle[i];
7071     for(Int_t j=1; j<knedges; j++){
7072                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
7073                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
7074         }
7075   }
7076   ////////////////////////////////////
7077   // Generating Up TGeoXtru
7078   ////////////////////////////////////
7079   TGeoXtru* upendcapsupportshape[klayernumber];
7080   TGeoVolume* upendcapsupport[klayernumber]; 
7081   char upendcapsupportname[30]; 
7082   for(Int_t i=0; i<klayernumber; i++){
7083    upendcapsupportshape[i] = new TGeoXtru(2);
7084    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
7085    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
7086    upendcapsupportshape[i]->DefineSection(0,0.);
7087    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7088    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
7089                                                                         fSSDSupportRingAl);
7090    upendcapsupport[i]->SetLineColor(5);
7091   }
7092   ///////////////////////////////////////////////
7093   // Setting the vertices for TGeoXtru Down Volume
7094   ///////////////////////////////////////////////
7095   Double_t xdownvertex[klayernumber][2*(knedges+1)];
7096   Double_t ydownvertex[klayernumber][2*(knedges+1)];
7097   for(Int_t i=0; i<klayernumber; i++){
7098         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
7099         xdownvertex[i][1] =  xupvertex[i][0];
7100         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
7101         ydownvertex[i][1] =  yupvertex[i][0];
7102         for(Int_t j=0; j<knedges; j++){
7103                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
7104                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
7105         } 
7106         for(Int_t j=0; j<knedges; j++){
7107                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7108                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
7109                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7110                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7111         }
7112   }
7113   ////////////////////////////////////
7114   // Generating Down TGeoXtru
7115   ////////////////////////////////////  
7116   TGeoXtru* downendcapsupportshape[klayernumber];
7117   TGeoVolume* downendcapsupport[klayernumber]; 
7118   char downendcapsupportname[30]; 
7119   for(Int_t i=0; i<klayernumber; i++){
7120         downendcapsupportshape[i] = new TGeoXtru(2);
7121     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7122         downendcapsupportshape[i] = new TGeoXtru(2);
7123         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7124     if(i==0){
7125                 downendcapsupportshape[i]->DefineSection(0,0.);
7126                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7127     }
7128         else{
7129                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7130                                                                  -                 fgkEndCapSupportLowWidth[i]);
7131                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7132         }
7133     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7134                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7135         downendcapsupport[i]->SetLineColor(5);
7136   }
7137   ///////////////////////////////////////////////
7138   // Setting TGeoPgon Volume
7139   ///////////////////////////////////////////////
7140   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7141                                                                                                    fgkSSDLay6LadderNumber};
7142   TGeoPgon* endcapsupportmothershape[klayernumber];
7143   TGeoVolume** endcapsupportmother;
7144   endcapsupportmother = new TGeoVolume*[klayernumber];
7145   char endcapsupportmothername[30];
7146   for(Int_t i=0; i<klayernumber; i++){
7147         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7148     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7149         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7150     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7151                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7152     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7153                                                                                         fSSDAir);       
7154   }
7155   ////////////////////////////////////
7156   TGeoRotation** endcapsupportrot[klayernumber];
7157   for(Int_t i=0; i<2; i++){
7158         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7159         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7160            endcapsupportrot[i][j] = new TGeoRotation();
7161            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7162        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7163        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7164         }
7165   }
7166   return endcapsupportmother;
7167  } 
7168  ////////////////////////////////////////////////////////////////////////////////
7169  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7170   /////////////////////////////////////////////////////////////
7171   // Setting End Cap Support Layer 5 and 6. 
7172   /////////////////////////////////////////////////////////////
7173   const Int_t kendcapcoverplatesmallholenumber = 9;
7174   const Int_t klayernumber = 2;
7175   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7176                                                                                                    fgkSSDLay6LadderNumber};
7177   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7178                                                                                 360.0/kssdlayladdernumber[1]};
7179   TGeoVolume** endcapsupport = EndCapSupport();
7180   TGeoVolume** endcapassembly = GetEndCapAssembly();
7181   TGeoPgon* endcapsupportshape[klayernumber];
7182   Double_t* radiusmin[klayernumber];
7183   Double_t* radiusmax[klayernumber];
7184   for(Int_t i=0; i<klayernumber; i++){
7185     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7186         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7187         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7188   }  
7189   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7190   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7191                                                                           endcapassemblyshape->GetDY(),
7192                                                                           endcapassemblyshape->GetDZ()};
7193   ///////////////////////////////////////////////
7194   // Setting TGeoPgon Volume for Mother Container
7195   ///////////////////////////////////////////////
7196   TGeoPgon* endcapsupportsystemshape[klayernumber];
7197   char endcapsupportsystemothername[30];
7198   for(Int_t i=0; i<klayernumber; i++){
7199         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7200     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7201         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7202                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7203                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7204                                                                                            +2.*endcapassemblycenter[2])
7205                                                                                            /CosD(0.5*upedgeangle[i]));  
7206     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7207                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7208                                                                                              - fgkEndCapCoverPlateWidth[0]),
7209                                                                                            *radiusmin[i],
7210                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7211                                                                                            +2.*endcapassemblycenter[2])
7212                                                                                            /CosD(0.5*upedgeangle[i]));
7213   }
7214   fgkEndCapSupportSystem = new TGeoVolume*[4];
7215   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7216                                                                           endcapsupportsystemshape[0],fSSDAir); 
7217   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7218                                                                           endcapsupportsystemshape[0],fSSDAir); 
7219   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7220                                                                           endcapsupportsystemshape[1],fSSDAir); 
7221   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7222                                                                           endcapsupportsystemshape[1],fSSDAir); 
7223   ///////////////////////////////////////////////
7224   TGeoTranslation* endcapassemblytrans[klayernumber];
7225   for(Int_t i=0; i<klayernumber; i++)
7226         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7227                                                                            -  fgkEndCapSideCoverThickness
7228                                                                            +  endcapassemblycenter[0],
7229                                                                            -  0.5*fgkEndCapCoverPlateThickness
7230                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7231                                                                            +  2.0*endcapassemblycenter[2]
7232                                                                            +  0.5*fgkEndCapSupportLength[i]
7233                                                                            /  TanD(0.5*upedgeangle[i]),
7234                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7235                                                                            -  fgkEndCapCoverPlateWidth[2]
7236                                                                            - (kendcapcoverplatesmallholenumber-1)
7237                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7238   TGeoRotation** endcapassemblyrot[klayernumber];
7239   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7240   for(Int_t i=0; i<klayernumber; i++){
7241    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7242    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7243    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7244    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7245    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7246    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7247    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7248    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7249         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7250         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7251    }
7252   }
7253   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7254                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7255   for(Int_t i=0; i<2*klayernumber; i++){
7256         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7257                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7258                                                                                                                                            endcapassemblymatrix[1][j+2]);
7259         }
7260         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7261   }
7262    /////////////////////////////////////////////////////////////
7263   // Deallocating memory
7264   /////////////////////////////////////////////////////////////
7265   for(Int_t i=0; i<klayernumber; i++){
7266         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7267                 delete endcapassemblyrot[i][j];
7268         }
7269         delete endcapassemblyrot[i];
7270         delete endcapassemblymatrix[i][0];
7271         delete endcapassemblymatrix[i][1];
7272   }
7273   /////////////////////////////////////////////////////////////
7274   }
7275   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7276   /////////////////////////////////////////////////////////////
7277   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7278   /////////////////////////////////////////////////////////////
7279   if (! moth) {
7280     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer5, mother is null!\n");
7281     return;
7282   };
7283   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7284   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7285   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7286                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7287                                                                            +            fgkEndCapSupportCenterLay5Position
7288                                                                            -            fgkEndCapSideCoverLength[2]);
7289   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7290                                                                                                 fgkEndCapSideCoverLength[2]
7291                                                                            -        fgkEndCapSupportCenterLay5Position
7292                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7293   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7294   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7295   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7296         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7297   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7298   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7299    /////////////////////////////////////////////////////////////
7300   // Deallocating memory
7301   /////////////////////////////////////////////////////////////
7302   delete endcapsupportsystemrot;
7303   delete endcapsupportsystemITSCentertrans[1];
7304  }
7305   /////////////////////////////////////////////////////////////
7306   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7307   /////////////////////////////////////////////////////////////
7308   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7309   /////////////////////////////////////////////////////////////
7310   if (! moth) {
7311     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer6, mother is null!\n");
7312     return;
7313   };
7314   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7315   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7316   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7317                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7318                                                                            +            fgkEndCapSupportCenterLay6Position
7319                                                                            -            fgkEndCapSideCoverLength[2]);
7320   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7321                                                                                                 fgkEndCapSideCoverLength[2]
7322                                                                            -        fgkEndCapSupportCenterLay6Position
7323                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7324   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7325   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7326   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7327         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7328   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7329   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7330    /////////////////////////////////////////////////////////////
7331   // Deallocating memory
7332   /////////////////////////////////////////////////////////////
7333   delete endcapsupportsystemrot;
7334   delete endcapsupportsystemITSCentertrans[1];
7335  }
7336  ////////////////////////////////////////////////////////////////////////////////
7337  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7338   /////////////////////////////////////////////////////////////
7339   // Setting Ladder Support of Layer 5. 
7340   /////////////////////////////////////////////////////////////
7341   if (! moth) {
7342     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer5, mother is null!\n");
7343     return;
7344   };
7345   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7346   fMotherVol = moth;
7347   TGeoTranslation* centerITSRingSupportLay5trans[2];
7348   for(Int_t i=0; i<2; i++){
7349         centerITSRingSupportLay5trans[i] = 
7350                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7351     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7352   }
7353  }
7354  ////////////////////////////////////////////////////////////////////////////////
7355  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7356   /////////////////////////////////////////////////////////////
7357   // Setting Ladder Support of Layer 6. 
7358   /////////////////////////////////////////////////////////////
7359   if (! moth) {
7360     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer6, mother is null!\n");
7361     return;
7362   };
7363   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7364   fMotherVol = moth;
7365   TGeoTranslation* centerITSRingSupportLay6trans[2];
7366   for(Int_t i=0; i<2; i++){
7367         centerITSRingSupportLay6trans[i] = 
7368                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7369     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7370   }
7371  }
7372  ////////////////////////////////////////////////////////////////////////////////
7373  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7374   /////////////////////////////////////////////////////////////
7375   // Setting Ladder Support of Layer 6. 
7376   /////////////////////////////////////////////////////////////
7377   if (! moth) {
7378     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cone, mother is null!\n");
7379     return;
7380   };
7381   if(!fSSDCone) SetSSDCone();
7382   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7383                                                                 +                                         fgkSSDCentralAL3SupportLength);
7384     moth->AddNode(fSSDCone,1,ssdconetrans);
7385 }
7386  ////////////////////////////////////////////////////////////////////////////////
7387  void AliITSv11GeometrySSD::SetSSDCone(){
7388   /////////////////////////////////////////////////////////////
7389   // Method generating SSDCone 
7390   /////////////////////////////////////////////////////////////
7391   if(!fCreateMaterials) CreateMaterials();
7392   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7393   Double_t ssdpconesectionradiusmax[16];
7394   Double_t ssdpconesectionradiusmin[16];
7395   Double_t ssdpconezsection[16];
7396   TGeoPcon* ssdpconelittleholeshape[8];
7397   TGeoVolume* ssdpconelittlehole[8];
7398   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7399   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7400   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7401                                                       / SinD(fgkSSDPConeAngle)
7402                                                           + ssdpconesectionradiusmin[0];
7403   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7404                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7405                                                           / SinD(fgkSSDPConeAngle);
7406   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7407   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7408                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7409   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7410   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7411                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7412   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7413   ssdpconelittlehole[0]->SetLineColor(4);
7414   /////////////////////////////////////////////////////////////
7415   ssdpconezsection[2] = ssdpconezsection[1];  
7416   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7417   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7418   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7419                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7420                                                           / SinD(fgkSSDPConeAngle);
7421   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7422                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7423   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7424                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7425   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7426                                                                    * TMath::RadToDeg();
7427   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7428                                                                                                           60.-ssdpconelittleholeangle,2);    
7429   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7430                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7431   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7432   ssdpconelittlehole[1]->SetLineColor(4);
7433   TGeoRotation* ssdconelittleholerot[6];
7434   for(Int_t i=0; i<6; i++){
7435         ssdconelittleholerot[i] = new TGeoRotation();
7436     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7437   }
7438   /////////////////////////////////////////////////////////////
7439   ssdpconezsection[4] = ssdpconezsection[3];  
7440   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7441   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7442   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7443                                                           * CosD(fgkSSDPConeAngle)
7444                                                           / SinD(fgkSSDPConeAngle);
7445   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7446   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7447                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7448   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7449   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7450                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7451   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7452   ssdpconelittlehole[2]->SetLineColor(4);
7453   ///////////////////////////////////////////////////
7454   ssdpconezsection[6] = ssdpconezsection[5];  
7455   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7456   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7457   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7458                                                           -ssdpconezsection[0]
7459                                                           * CosD(fgkSSDPConeAngle)
7460                                                           / SinD(fgkSSDPConeAngle);
7461   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7462   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7463                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7464   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7465                                                                    * TMath::RadToDeg();
7466   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7467                                                                                                           45.-ssdpconemiddleholeangle,2);    
7468   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7469                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7470   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7471   ssdpconelittlehole[3]->SetLineColor(4);
7472   TGeoRotation* ssdconemiddleholerot[8];
7473   for(Int_t i=0; i<8; i++){
7474         ssdconemiddleholerot[i] = new TGeoRotation();
7475     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7476   }
7477   /////////////////////////////////////////////////////////////
7478   ssdpconezsection[8] = ssdpconezsection[7];  
7479   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7480   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7481   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7482                                                           * CosD(fgkSSDPConeAngle)
7483                                                           / SinD(fgkSSDPConeAngle);
7484   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7485   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7486                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7487   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7488   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7489                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7490   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7491   ssdpconelittlehole[4]->SetLineColor(4);
7492   /////////////////////////////////////////////////////////////
7493   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7494   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7495                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7496                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7497                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7498                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7499   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7500   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7501                                                                                  * TMath::RadToDeg();
7502   ssdpconezsection[10] = ssdpconezsection[9];
7503   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7504   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7505   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7506                                                           * CosD(fgkSSDPConeAngle)
7507                                                           / SinD(fgkSSDPConeAngle);
7508   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7509   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7510                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7511   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7512                                                                                         ssdpconetrapezoidsectionangle,2);    
7513   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7514                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7515   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7516   ssdpconelittlehole[5]->SetLineColor(4);
7517   TGeoRotation* ssdconeupradiusrot[8];
7518   for(Int_t i=0; i<8; i++){
7519         ssdconeupradiusrot[i] = new TGeoRotation();
7520     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7521   }
7522   /////////////////////////////////////////////////////////////
7523   ssdpconezsection[12] = ssdpconezsection[11];
7524   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7525   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7526   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7527   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7528   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7529   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7530   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7531                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7532   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7533   ssdpconelittlehole[6]->SetLineColor(4);
7534   /////////////////////////////////////////////////////////////
7535   ssdpconezsection[14] = 0.0;
7536   ssdpconezsection[15] = ssdpconezsection[0];
7537   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7538   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7539   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7540   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7541   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7542   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7543                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7544   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7545   ssdpconelittlehole[7]->SetLineColor(4);
7546   /////////////////////////////////////////////////////////////
7547   TGeoTube* ssdtubeconeshape[2];
7548   TGeoVolume* ssdtubecone[2];
7549   TGeoTranslation* ssdtubeconetrans[2];
7550   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7551                                                                            fgkSSDPConeExternalRadius,
7552                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7553   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7554                                                                            0.5*ssdpconezsection[0]); 
7555   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7556   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7557   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7558                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7559                                           + ssdpconezsection[13]);
7560   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7561   ssdtubecone[0]->SetLineColor(4);
7562   ssdtubecone[1]->SetLineColor(4);
7563   /////////////////////////////////////////////////////////////
7564   // Mother Volume Container
7565   /////////////////////////////////////////////////////////////
7566   Double_t ssdconemotherradiusmin[8];
7567   Double_t ssdconemotherradiusmax[8];
7568   Double_t ssdconemothersection[8]; 
7569   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7570   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7571   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7572   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7573   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7574   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7575   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7576   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7577   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7578   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7579   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7580   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7581   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7582   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7583   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7584   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7585   ssdconemothersection[0] = 0.0;
7586   ssdconemothersection[1] = ssdpconezsection[0];
7587   ssdconemothersection[2] = ssdpconezsection[0];
7588   ssdconemothersection[3] = ssdpconezsection[11];
7589   ssdconemothersection[4] = ssdpconezsection[11];
7590   ssdconemothersection[5] = ssdpconezsection[13];
7591   ssdconemothersection[6] = ssdpconezsection[13];
7592   ssdconemothersection[7] = fgkSSDPConeLength;
7593   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7594   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7595                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7596   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7597   /////////////////////////////////////////////////////////////
7598   //Placing the Volumes into Mother 
7599   /////////////////////////////////////////////////////////////
7600   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7601   for(Int_t i=0; i<6; i++){
7602         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7603   }
7604   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7605   for(Int_t i=0; i<8; i++){
7606     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7607   }
7608   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7609   for(Int_t i=0; i<8; i++){
7610     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7611   }
7612   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7613   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7614   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7615   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7616   /////////////////////////////////////////////////////////////
7617   // ITS General Support
7618   /////////////////////////////////////////////////////////////
7619   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7620                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7621   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7622   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7623                                                                              - fgkSSDCentralAL3SupportLength);
7624   ssdcentralsupport->SetLineColor(4);
7625   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7626   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7627                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7628   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7629   TGeoTranslation* ssdcentralal3supportrans[3]; 
7630   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7631   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7632                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7633   ssdcentralal3support->SetLineColor(4);
7634   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7635   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7636   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7637   Double_t ssdpconcentralradiusmin[2];
7638   Double_t ssdpconcentralradiusmax[2];
7639   Double_t ssdpconcentralsection[2];
7640   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7641   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7642   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7643   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7644   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7645   ssdpconcentralsection[1] = 0.;
7646   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7647                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7648   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7649   ssdpconcentralal3->SetLineColor(4);
7650   fSSDCone->AddNode(ssdpconcentralal3,1);
7651   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7652   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7653   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7654                                                                 -2.*fgkSSDCentralAL3SupportLength);
7655   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7656                                                                                                                      *ssdcentralal3supportrot);
7657   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7658   TGeoRotation* ssdconemotherot = new TGeoRotation();
7659   ssdconemotherot->SetAngles(90.,180.,-90.);
7660   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7661                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7662   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7663   fSSDCone->AddNode(ssdconemother,1);
7664   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7665   /////////////////////////////////////////////////////////////
7666   // Deallocating memory
7667   /////////////////////////////////////////////////////////////
7668   delete ssdcentralal3supportrot;
7669   delete ssdcentralal3supportrans[2];
7670   delete ssdconemotherot;
7671   delete ssdconemothertrans;
7672   /////////////////////////////////////////////////////////////
7673  }
7674  ////////////////////////////////////////////////////////////////////////////////
7675  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7676   /////////////////////////////////////////////////////////////
7677   // Setting SSD Cables
7678   /////////////////////////////////////////////////////////////
7679   if (! moth) {
7680     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cables, mother is null!\n");
7681     return;
7682   };
7683   TGeoVolume* ssdcables = SetSSDCables();
7684   moth->AddNode(ssdcables,1);
7685 }
7686  ////////////////////////////////////////////////////////////////////////////////
7687  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7688   /////////////////////////////////////////////////////////////
7689   // Method generating SSDCables
7690   /////////////////////////////////////////////////////////////
7691   // SSD Layer 5 Cables
7692   //////////////////////////////////////////////////////////////////////////////////////////////////
7693   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7694   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7695   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7696   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7697   //////////////////////////////////////////////////////////////////////////////////////////////////
7698   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7699   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7700                                                                             -  fgkSSDLowerPConeRadius)
7701                                                                             * TanD(fgkSSDPConeAngle);
7702   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7703                                                                               + fgkEndCapSupportCenterLay5Position
7704                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7705   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7706                                                                            - ssdcableslay5startconedistance; 
7707   ssdcablelay5rightsidelength *= ssdcablesfactor;
7708   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7709   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7710                                                                                                 ssdcableslay5rightsideradiusmax,
7711                                                                                                 0.5*ssdcablelay5rightsidelength); 
7712   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7713                                                                                                          ssdcablelay5rightubeshape,
7714                                                                                                          fSSDCopper);
7715   ssdcablelay5righttube->SetLineColor(9);
7716   TGeoTranslation* ssdcablelay5rightrans = 
7717                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7718                                                                                  +              fgkEndCapSupportCenterLay5Position
7719                                                                                  +      0.5*ssdcablelay5rightsidelength);
7720   ////////////////////////////////////
7721   //  Double_t cablescapacity[20];
7722   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7723   ////////////////////////////////////
7724   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7725   ////////////////////////////////////
7726   // TGeoPCone Volumes
7727   ///////////////////////////////////
7728   TGeoPcon* ssdcableslay5pconshape[3];
7729   TGeoVolume* ssdcableslay5pcon[3]; 
7730   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7731   Double_t ssdcableslay5pconzsection[6];
7732   Double_t ssdcableslay5pconrmin[6];
7733   Double_t ssdcableslay5pconrmax[6];
7734   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7735   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7736   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7737   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7738   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7739                                                            + fgkEndCapSupportCenterLay5Position
7740                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7741   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7742                                                            + fgkSSDCentralAL3SupportLength
7743                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7744                                                            * TanD(fgkSSDPConeAngle);      
7745   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7746                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7747   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7748                                                            ssdcableslay5pconshape[0],fSSDCopper);
7749   ssdcableslay5pcon[0]->SetLineColor(9);
7750   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7751 ////////////////////////////////////
7752 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7753 ////////////////////////////////////
7754   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7755   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7756                                                            + fgkSSDCentralAL3SupportLength
7757                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7758                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7759   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7760                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7761                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7762   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7763                                                                                    ssdcableangle,2);   
7764   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7765   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7766   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7767                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7768   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7769   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7770   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7771                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7772   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7773   ssdcableslay5pcon[1]->SetLineColor(9);
7774   ////////////////////////////////////
7775   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7776                                                                                    ssdcableangle,2);   
7777   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7778   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7779   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7780   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7781   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7782   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7783                                                            * TanD(fgkSSDPConeAngle)
7784                                                            + 0.5*fgkSSDCentralSupportLength
7785                                                            + fgkSSDCentralAL3SupportLength;
7786   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7787   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7788                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7789   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7790   ssdcableslay5pcon[2]->SetLineColor(9);
7791 ////////////////////////////////////
7792   TGeoRotation* ssdcableslay5pconrot[4];        
7793   for(Int_t i=0; i<4; i++){
7794    ssdcableslay5pconrot[i] = new TGeoRotation();
7795    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7796    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7797    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7798   }
7799   ////////////////////////////////////
7800   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7801   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7802   ////////////////////////////////////
7803   // Positioning Left SSD Cables Part
7804   ////////////////////////////////////
7805   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7806                                                                                                         - 0.5*ssdcablelay5rightsidelength
7807                                                                                                         - fgkEndCapSupportCenterLay5Position
7808                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7809   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7810   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7811   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7812   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7813   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7814   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7815         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7816         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7817     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7818   }
7819   ////////////////////////////////////
7820   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7821   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7822   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7823   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7824   /////////////////////////////////////////////////////////////
7825   // Water Tubes Layer 5
7826   /////////////////////////
7827   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7828                                                                                      ssdcableslay5rightsideradiusmax
7829                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7830                                                                                      0.5*ssdcablelay5rightsidelength); 
7831   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7832                                                                                                          ssdcablelay5rightubewatershape,
7833                                                                                                          fSSDCoolingTubeWater);
7834   ssdcablelay5rightwatertube->SetLineColor(7);
7835   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7836   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7837   ////////////////////////////////////
7838   // TGeoPCone Water Volumes Layer 
7839   ///////////////////////////////////
7840   TGeoPcon* ssdcableslay5pconwatershape[3];
7841   TGeoVolume* ssdcableslay5pconwater[3]; 
7842   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7843   Double_t ssdcableslay5pconwaterzsection[6];
7844   Double_t ssdcableslay5pcwateronrmin[6];
7845   Double_t ssdcableslay5pconwaterrmax[6];
7846   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7847   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7848                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7849   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7850   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7851                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7852   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7853   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7854   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7855                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7856   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7857                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7858   ssdcableslay5pconwater[0]->SetLineColor(7);
7859   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7860   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7861 ////////////////////////////////////
7862   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7863   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7864   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7865                                                                                                 ssdcableangle,2);   
7866   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7867   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7868                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7869   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7870   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7871                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7872   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7873                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7874   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7875                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7876   ssdcableslay5pconwater[1]->SetLineColor(7);
7877 ////////////////////////////////////
7878   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7879                                                                                                 ssdcableangle,2);   
7880   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7881   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7882                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7883   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7884   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7885                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7886   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7887   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7888   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7889                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7890   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7891                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7892   ssdcableslay5pconwater[2]->SetLineColor(7);
7893 ////////////////////////////////////
7894   TGeoRotation* ssdcableslay5pconwaterot[4];    
7895   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7896   for(Int_t i=0; i<4; i++){
7897    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7898    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7899    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7900         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7901         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7902         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7903         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7904         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7905   }
7906   /////////////////////////
7907   // SSD Layer 6 Cables
7908   /////////////////////////
7909   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7910   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7911   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7912   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7913                                                                                                 ssdcableslay6rightsideradiusmax,
7914                                                                                                 0.5*ssdcablelay6rightsidelength); 
7915   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7916                                                                                                          ssdcablelay6rightubeshape,
7917                                                                                                          fSSDCopper);
7918   ssdcablelay6righttube->SetLineColor(9);
7919   TGeoTranslation* ssdcablelay6rightrans = 
7920                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7921                                                                                  +              fgkEndCapSupportCenterLay6Position
7922                                                                                  +      0.5*ssdcablelay6rightsidelength);
7923   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7924                                                                                                         - 0.5*ssdcablelay6rightsidelength
7925                                                                                                         - fgkEndCapSupportCenterLay6Position
7926                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7927   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7928   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7929   ////////////////////////////////////
7930   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7931   ////////////////////////////////////
7932   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7933                                                                                    ssdcableangle,2);   
7934   TGeoVolume* ssdcableslay6pcon;
7935   Double_t ssdcableslay6pconrmin[2];
7936   Double_t ssdcableslay6pconrmax[2];
7937   Double_t ssdcableslay6pconzsection[2];
7938   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7939   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7940   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7941   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7942   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7943                                                            + fgkEndCapSupportCenterLay6Position
7944                                                            + ssdcablelay6rightsidelength;
7945   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7946   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7947                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7948   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7949                                                            ssdcableslay6pconshape,fSSDCopper);
7950   ssdcableslay6pcon->SetLineColor(9);
7951   for(Int_t i=0; i<4; i++){
7952    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7953    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7954   }
7955   ////////////////////////////////////
7956   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7957   /////////////////////////
7958   // Water Tubes Layer 6
7959   /////////////////////////
7960   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7961                                                                                                                   ssdcableslay6rightsideradiusmax
7962                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7963                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7964   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7965                                                                                                          ssdcablelay6righwatertubeshape,
7966                                                                                                          fSSDCoolingTubeWater);
7967   ssdcablelay6rightwatertube->SetLineColor(7);
7968   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7969   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7970   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7971                                                                                    ssdcableangle,2);   
7972   TGeoVolume* ssdcableslay6waterpcon;
7973   Double_t ssdcableslay6waterpconrmin[2];
7974   Double_t ssdcableslay6waterpconrmax[2];
7975   Double_t ssdcableslay6waterpconzsection[2];
7976   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7977   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7978                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7979   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7980   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7981   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7982                                                            + fgkEndCapSupportCenterLay6Position
7983                                                            + ssdcablelay6rightsidelength;
7984   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7985   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7986                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7987   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7988                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7989   ssdcableslay6waterpcon->SetLineColor(7);
7990   TGeoRotation* ssdcableslay6pconwaterot[4];    
7991   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7992   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7993   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7994   for(Int_t i=0; i<4; i++){
7995    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7996    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7997    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7998                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7999    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
8000    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
8001   }
8002   ////////////////////////////////////////
8003   // From ITS Ring to Patch Panel3-RB26
8004   ////////////////////////////////////////
8005   Double_t ssdcablepatchpanel3BB26radiusmin[2];
8006   Double_t ssdcablepatchpanel3BB26radiusmax[2];
8007   Double_t ssdcablepatchpanel3RB26zsection[2];
8008   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
8009   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
8010                                                                           + fgkSSDCablesLay5RightSideHeight
8011                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8012   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
8013   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
8014                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8015                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8016   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
8017                                                                                  + fgkSSDCentralAL3SupportLength
8018                                                                                  + fgkSSDPConeZLength[0];
8019   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
8020   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
8021                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8022                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8023   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
8024                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
8025   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
8026                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
8027   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
8028   TGeoRotation* ssdcablepatchpanel3B26rot[3];
8029   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
8030   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
8031   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
8032                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
8033   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
8034   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
8035                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
8036   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
8037   ////////////////////////////////////
8038   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
8039   ////////////////////////////////////////
8040   //  ITS Ring Cables RB26 Part
8041   ////////////////////////////////////////
8042   Double_t ssdcableitsring3BB26pconzsection[2];
8043   Double_t ssdcableitsring3BB26pconrmin[2];
8044   Double_t ssdcableitsring3BB26pconrmax[2];
8045   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
8046                                                                           + fgkSSDCentralAL3SupportLength
8047                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
8048   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
8049   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8050   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
8051                                                                   + fgkSSDCablesLay5RightSideHeight
8052                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8053   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
8054   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
8055   TGeoPcon* ssdcableitsring3BB26pconshape[4];
8056   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8057                                                                    -              0.5*ssdcableangle,ssdcableangle
8058                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
8059                                                                    -                             fgkSSDCableAngle),2);
8060   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8061                                                                    -              0.5*ssdcableangle,ssdcableangle
8062                                                                    +                      3.0*fgkSSDCableAngle
8063                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8064   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
8065                                                                    -              0.5*ssdcableangle,ssdcableangle
8066                                                                    -                      fgkSSDCableAngle
8067                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
8068   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8069                                                                    -              0.5*ssdcableangle,ssdcableangle
8070                                                                    +                      3.0*fgkSSDCableAngle
8071                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8072   for(Int_t i=0;i<4;i++)
8073         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
8074                                                          ssdcableitsring3BB26pconrmin[j],
8075                                                          ssdcableitsring3BB26pconrmax[j]); 
8076   TGeoVolume* ssdcableitsring3BB26pcon[4];
8077   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
8078                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
8079   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
8080                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
8081   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
8082                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
8083   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
8084                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
8085   for(Int_t i=0;i<4;i++){
8086         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
8087         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
8088 }
8089   ////////////////////////////////////
8090   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
8091   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
8092   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
8093   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
8094   ////////////////////////////////////////
8095   // From ITS Ring to Patch Panel2-RB24
8096   ////////////////////////////////////////
8097   Double_t ssdcablepatchpanel3BB24radiusmin[2];
8098   Double_t ssdcablepatchpanel3BB24radiusmax[2];
8099   Double_t ssdcablepatchpanel3RB24zsection[2];
8100   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
8101   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
8102   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
8103   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
8104                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8105                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
8106                                                                           + 0.5*fgkSSDPatchPanelHeigth;
8107   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
8108                                                                          -  fgkSSDCentralAL3SupportLength
8109                                                                          -  fgkSSDPConeZLength[0];
8110   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8111   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8112                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8113                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8114   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8115                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8116   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8117                                                                                                 ssdcablepatchpanel3RB24pconshape,
8118                                                                                                 fSSDCopper);
8119   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8120   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8121   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8122   ssdcablepatchpanel3B24rot[0]->SetAngles(0.0,0.0,0.0);
8123   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8124                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8125   ssdcablepatchpanel3B24rot[2]->SetAngles(180.0,0.0,0.0);
8126   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8127                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8128   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8129   ////////////////////////////////////
8130   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8131   ////////////////////////////////////////
8132   //  ITS Ring Cables RB24 Part
8133   ////////////////////////////////////////
8134   Double_t ssdcableitsring3BB24pconzsection[2];
8135   Double_t ssdcableitsring3BB24pconrmin[2];
8136   Double_t ssdcableitsring3BB24pconrmax[2];
8137   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8138   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8139   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8140   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8141                                                                   + fgkSSDCablesLay5RightSideHeight
8142                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8143   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8144   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8145   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8146   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8147                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8148                                                                    -                             fgkSSDCableAngle),2);
8149   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8150                                                                      ssdcableangle-fgkSSDCableAngle
8151                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8152   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8153                                                                    -                      fgkSSDCableAngle
8154                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8155   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8156                                                                                                   ssdcableangle-fgkSSDCableAngle
8157                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8158   for(Int_t i=0;i<4;i++)
8159         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8160                                                          ssdcableitsring3BB24pconrmin[j],
8161                                                          ssdcableitsring3BB24pconrmax[j]); 
8162   TGeoVolume* ssdcableitsring3BB24pcon[4];
8163   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8164                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8165   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8166                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8167   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8168                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8169   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8170                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8171   for(Int_t i=0;i<4;i++){
8172         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8173         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8174 }
8175   ////////////////////////////////////
8176   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8177   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8178   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8179   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8180   ////////////////////////////////////
8181   // Volumes for Material Budget 
8182   ////////////////////////////////////
8183   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8184                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8185                                                                                                          ssdcableslay6rightsideradiusmax
8186                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8187                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8188   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8189                                                                                                          ssdcablelay6materialbudgetubeshape,
8190                                                                                                          fSSDCopper);
8191   ssdcablelay6materialbudgetube->SetLineColor(9);
8192   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8193   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8194
8195   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8196                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8197   TGeoVolume* ssdcablelay6materialbudgetpcon;
8198   Double_t ssdcablelay6materialbudgetpconrmin[2];
8199   Double_t ssdcablelay6materialbudgetpconrmax[2];
8200   Double_t ssdcablelay6materialbudgetpconzsection[2];
8201   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8202                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8203   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8204                                                                                 + fgkSSDCableMaterialBudgetHeight;
8205   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8206   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8207   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8208                                                                                         + fgkEndCapSupportCenterLay6Position
8209                                                                                         + ssdcablelay6rightsidelength;
8210   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8211   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8212                                                   ssdcablelay6materialbudgetpconzsection[i],
8213                                                   ssdcablelay6materialbudgetpconrmin[i],
8214                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8215   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8216                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8217   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8218   for(Int_t i=0; i<4; i++){
8219    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8220    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8221   }
8222 ////////////////////////////////////
8223  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8224   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8225   Double_t ssdcablesvolume = 0.0;
8226   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8227   std::cout << ssdcablesvolume << std::endl;*/
8228   return ssdcablesmother;
8229  }
8230  ////////////////////////////////////////////////////////////////////////////////
8231 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8232                                                                         Double_t height, char* shapename, Int_t isign) const{
8233   /////////////////////////////////////////////////////////////
8234   // Method generating an Arb shape 
8235   /////////////////////////////////////////////////////////////
8236   const Int_t kvertexnumber = 8;
8237   const Int_t ktransvectnumber = 2;
8238   TVector3* vertex[kvertexnumber];
8239   TVector3* transvector[2];
8240   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i] = new TVector3(0.,width[i]);
8241   /////////////////////////////////////////////////////////////
8242   //Setting the vertices for TGeoArb8
8243   /////////////////////////////////////////////////////////////
8244   vertex[0] = new TVector3(*vertexpos[0]);
8245   vertex[1] = new TVector3(*vertexpos[1]);
8246   vertex[2] = new TVector3(*vertex[1]+isign*(*transvector[0]));
8247   vertex[3] = new TVector3(*vertex[0]+isign*(*transvector[0]));
8248   vertex[4] = new TVector3(*vertexpos[2]);
8249   vertex[5] = new TVector3(*vertexpos[3]);
8250   vertex[6] = new TVector3(*vertex[5]+isign*(*transvector[1]));
8251   vertex[7] = new TVector3(*vertex[4]+isign*(*transvector[1]));
8252   /////////////////////////////////////////////////////////////
8253   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8254   for(Int_t i = 0; i<kvertexnumber;i++) 
8255                                                         arbshape->SetVertex(i,vertex[i]->X(),vertex[i]->Y());
8256   /////////////////////////////////////////////////////////////
8257   // Deallocating memory
8258   /////////////////////////////////////////////////////////////
8259   for(Int_t i=0; i< kvertexnumber; i++) delete vertex[i];  
8260   for(Int_t i=0; i< ktransvectnumber; i++) delete transvector[i];  
8261   /////////////////////////////////////////////////////////////
8262   return arbshape;
8263
8264 ///////////////////////////////////////////////////////////////////////////////
8265 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8266                                                                 Double_t rmax, Int_t nedges, Double_t height){
8267   /////////////////////////////////////////////////////////////
8268   // Method generating Arc shape 
8269   /////////////////////////////////////////////////////////////
8270         const Int_t kvertexnumber = 2*nedges+2;
8271         TGeoXtru* arcshape = new TGeoXtru(2);   
8272         TVector3** vertexposition[2];
8273         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8274         Double_t angle = 0.;
8275     for(Int_t i=0; i<nedges+1; i++){ 
8276                 angle = 90.+0.5*phi-i*(phi/nedges);
8277                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8278                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8279         }
8280         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8281         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8282         for(Int_t i=0; i<kvertexnumber; i++){ 
8283                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8284                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8285                 }
8286                 else if(i>=1&&i<nedges+2)
8287                 {
8288                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8289                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8290                 }
8291         else
8292                 {
8293                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8294                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8295                 }
8296     }
8297   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8298   arcshape->DefineSection(0,-0.5*height);
8299   arcshape->DefineSection(1,0.5*height);
8300   /////////////////////////////////////////////////////////////
8301   // Deallocating memory
8302   /////////////////////////////////////////////////////////////
8303   for(Int_t i=0; i<2; i++){
8304         for(Int_t j=0; j<nedges+1; j++)
8305                 delete vertexposition[i][j];
8306         delete [] vertexposition[i];
8307   }
8308   delete [] xvertexpoints;
8309   delete [] yvertexpoints;
8310   /////////////////////////////////////////////////////////////
8311         return arcshape;
8312 }
8313 ////////////////////////////////////////////////////////////////////////////////
8314 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8315   ///////////////////////////////////////////////////////////////////////
8316   // Method Generating the Screw Shape  
8317   // radius[0]: outer radius
8318   // radius[1]: inner radius
8319   // edgesnumber[0]: outer number of edges
8320   // edgesnumber[1]: inner number of edges
8321   // section[0]: lower section position
8322   // section[1]: higher section position
8323   ///////////////////////////////////////////////////////////////////////
8324   Double_t outradius = radius[0];
8325   Double_t inradius = radius[1];
8326   Int_t outvertexnumber = edgesnumber[0];
8327   Int_t invertexnumber = edgesnumber[1];
8328   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8329   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8330   for(Int_t i=0; i<outvertexnumber; i++){
8331         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8332         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8333   }
8334   for(Int_t i=0; i<invertexnumber; i++){
8335         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8336         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8337   }
8338   TGeoXtru* screwshapeout = new TGeoXtru(2);
8339   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8340   screwshapeout->DefineSection(0,section[0]);
8341   screwshapeout->DefineSection(1,section[1]);
8342   TGeoXtru* screwshapein = new TGeoXtru(2);
8343   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8344   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8345   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8346   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8347   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8348   
8349   delete [] xscrewvertex;
8350   delete [] yscrewvertex;
8351   return screwshape;
8352 }
8353 ////////////////////////////////////////////////////////////////////////////////
8354 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8355   ///////////////////////////////////////////////////////////////////////
8356   // Method Generating the Hole Shape  
8357   // radius of the Hole
8358   // nedges: number of edges to approximate the circle
8359   ///////////////////////////////////////////////////////////////////////
8360   Double_t* xholevertex = new Double_t[nedges];
8361   Double_t* yholevertex = new Double_t[nedges];
8362   Double_t z  = 0.5*(section[0]+section[1]);
8363   Double_t dz = 0.5*(section[1]-section[0]);
8364   TGeoTranslation *tr = 0;
8365   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8366      tr = new TGeoTranslation(0.,0.,z);
8367      tr->RegisterYourself();
8368   }   
8369   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8370   for(Int_t i=0; i<nedges; i++){
8371         xholevertex[i] = radius*CosD(i*360./nedges);
8372         yholevertex[i] = radius*SinD(i*360./nedges);
8373   }
8374   TGeoXtru* holeshapeout = new TGeoXtru(2);
8375   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8376   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8377   holeshapeout->DefineSection(1,section[1]+0.01);
8378   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8379   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8380   
8381   delete [] xholevertex;
8382   delete [] yholevertex;
8383   return holeshape;
8384 }
8385 ////////////////////////////////////////////////////////////////////////////////
8386 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8387   /////////////////////////////////////////////////////////////
8388   // Given an axis specified by param, it gives the reflection of the point
8389   // respect to the axis
8390   /////////////////////////////////////////////////////////////
8391   TVector3* n = new TVector3(param[0],param[1],param[2]);
8392   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8393   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8394   /////////////////////////////////////////////////////////////
8395   // Deallocating memory
8396   /////////////////////////////////////////////////////////////
8397   delete n;
8398   /////////////////////////////////////////////////////////////
8399   return reflectedvector;
8400 }
8401 ////////////////////////////////////////////////////////////////////////////////
8402 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8403                                                        Double_t dx,
8404                                                        Double_t dy,
8405                                                        Double_t dz) const{
8406   /////////////////////////////////////////////////////////////
8407   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8408   /////////////////////////////////////////////////////////////
8409   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8410   const Double_t *vect = hmatrix->GetTranslation();
8411   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8412   hmatrix->SetTranslation(newvect);
8413   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8414   delete hmatrix;
8415   return matrix;
8416 }
8417 ////////////////////////////////////////////////////////////////////////////////
8418 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8419   /////////////////////////////////////////////////////////////
8420   // Method returning the Medium type 
8421   /////////////////////////////////////////////////////////////
8422   char ch[30];
8423   sprintf(ch, "ITS_%s",mediumName);
8424   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8425   if (! medium)
8426     printf("Error(AliITSv11GeometrySSD)::medium %s not found !\n", mediumName);
8427   return medium;
8428 }
8429 ////////////////////////////////////////////////////////////////////////////////
8430 void AliITSv11GeometrySSD::CreateMaterials(){
8431 ///////////////////////////////////
8432 // This part has to be modified
8433 ///////////////////////////////////
8434   ///////////////////////////////////
8435   // Silicon for Sensor
8436   /////////////////////////////////// 
8437   fSSDSensorMedium = GetMedium("SI$");
8438   ///////////////////////////////////
8439   // Silicon Mixture for Sensor
8440   /////////////////////////////////// 
8441   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8442   fSSDChipGlueMedium = GetMedium("EPOXY$");
8443   ///////////////////////////////////
8444   // Stiffener Components Materials
8445   /////////////////////////////////// 
8446   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8447   ///////////////////////////  
8448   // Stiffener Connectors 
8449   ///////////////////////////  
8450   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8451   ////////////////////////////////  
8452   // Stiffener 0603-1812 Capacitor
8453   ////////////////////////////////  
8454   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8455   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8456   ///////////////////////////  
8457   // Stiffener Hybrid Wire 
8458   ///////////////////////////  
8459   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8460   ///////////////////////////  
8461   // Al for Cooling Block
8462   ///////////////////////////  
8463   fSSDAlCoolBlockMedium = GetMedium("AL$");
8464   //////////////////////////////////////////////////////  
8465   // Kapton and Al for Chip Cable Flex and Ladder Cables
8466   //////////////////////////////////////////////////////  
8467   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8468   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8469   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8470   fSSDAlTraceFlexMedium = GetMedium("AL$");
8471   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8472   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8473   /////////////////////////////////////////////////////////////////  
8474   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8475   //////////////////////////////////////////////////////////////////  
8476   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8477   /////////////////////////////////////////////////////////////////  
8478   // G10 for Detector Leg, TubeHolder
8479   //////////////////////////////////////////////////////////////////  
8480   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8481   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8482   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8483   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8484   /////////////////////////////////////////////////////////////////  
8485   // Water and Phynox for Cooling Tube
8486   //////////////////////////////////////////////////////////////////  
8487   fSSDCoolingTubeWater = GetMedium("WATER$");
8488   fSSDCoolingTubePhynox = GetMedium("INOX$");
8489   /////////////////////////////////////////////////////////////////////
8490   // Material for Support Rings
8491   /////////////////////////////////////////////////////////////////////
8492   fSSDSupportRingAl = GetMedium("AL$");
8493   fSSDRohaCellCone = GetMedium("ROHACELL$");
8494   /////////////////////////////////////////////////////////////////////
8495   fSSDAir = GetMedium("SDD AIR$");
8496   fSSDCopper = GetMedium("COPPER$");
8497   fCreateMaterials = kTRUE;
8498 }
8499 /////////////////////////////////////////////////////////////////////
8500