]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Bug fix concerning TGeoXtru volumes (A. Gheata)
[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.180*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::fgkCarbonFiberLowerSupportWidth             
263                                                                                                                                           =  0.950*fgkmm;
264 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
265                                                                                                                                           =  1.600*fgkmm;
266 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
267                                                                                                                                           =  0.830*fgkmm;
268 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
269                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
270 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
271                                                                         = fgkCarbonFiberJunctionWidth
272                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
273                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
274 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
275                                                                         = {fgkCarbonFiberLowerSupportWidth
276                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
277                                                                            fgkCarbonFiberLowerSupportWidth
278                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
279                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
280 /////////////////////////////////////////////////////////////////////////////////
281 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
282 /////////////////////////////////////////////////////////////////////////////////
283 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
284                                                            {0.5 * (fgkSSDLay5LadderLength
285                                                                         -  fgkSSDLay5SensorsNumber
286                                                                         *  fgkCarbonFiberJunctionWidth
287                                                                         -  fgkCarbonFiberLowerSupportWidth),
288                                                                 0.5 * (fgkSSDLay5LadderLength
289                                                                         -  fgkSSDLay5SensorsNumber
290                                                                         *  fgkCarbonFiberJunctionWidth
291                                                                         +  fgkCarbonFiberLowerSupportWidth)};
292 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
293                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
294                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
295 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
296                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
297                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
298 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
299                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
300 /////////////////////////////////////////////////////////////////////////////////
301 // Cooling Tube Support (lengths are in mm and angles in degrees)
302 /////////////////////////////////////////////////////////////////////////////////
303 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
304 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
305                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
306 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
309 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
310                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
312                                                                                                                                           11.70*fgkmm;
313 /////////////////////////////////////////////////////////////////////////////////
314 // Cooling Tube (lengths are in mm and angles in degrees)
315 /////////////////////////////////////////////////////////////////////////////////
316 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
317 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
318 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
319                                                                                                         fgkCarbonFiberJunctionWidth;
320 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
321                                                                          fgkSSDModuleSensorSupportDistance
322                                                                   +      fgkSSDCoolingBlockLength;
323 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
324 /////////////////////////////////////////////////////////////////////////////////
325 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
326 /////////////////////////////////////////////////////////////////////////////////
327 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
328                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
329 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
330                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
331 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
332                                                                                                                                           20.0*fgkmm;
333 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
334                                                                                                                                                     40.0;
335 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
336                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
337 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
338                                                                                                                                           2.5*fgkmm;
339 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
340                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
341 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
342                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
343 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
344                                                                                                                                           1.0*fgkmm;
345 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
346                                                                                                                                           6.0*fgkmm;
347 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
348                                                                                                                                           4.0*fgkmm;
349 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
350                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
351 /////////////////////////////////////////////////////////////////////////////////
352 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
353 /////////////////////////////////////////////////////////////////////////////////
354 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
355 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
356 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
357 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
359 /////////////////////////////////////////////////////////////////////////////////
360 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
361 /////////////////////////////////////////////////////////////////////////////////
362 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
363 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
364 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
365                                                                                                   -  fgkSSDMountingBlockHeight[1]
366                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
367                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
368                                                                                                   +  fgkSSDModuleVerticalDisalignment
369                                                                                                   -      fgkMountingBlockSupportDownHeight,
370                                                                                                          fgkSSDLay6RadiusMin
371                                                                                                   -  fgkSSDMountingBlockHeight[1]
372                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
373                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
374                                                                                                   +  fgkSSDModuleVerticalDisalignment
375                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
376 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
377                                                                                                     -  fgkSSDMountingBlockHeight[1]
378                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
379                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
380                                                                                                         +  fgkSSDModuleVerticalDisalignment
381                                                                                                         -  fgkMountingBlockSupportRadius[0],
382                                                                                                            fgkSSDLay6RadiusMax
383                                                                                                     -  fgkSSDMountingBlockHeight[1]
384                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
385                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
386                                                                                                         +  fgkSSDModuleVerticalDisalignment
387                                                                                                         -  fgkMountingBlockSupportRadius[1]};
388 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
390 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
391 /////////////////////////////////////////////////////////////////////////////////
392 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
393 /////////////////////////////////////////////////////////////////////////////////
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
398                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
399 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
400                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
401 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
402                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
408 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
409 /////////////////////////////////////////////////////////////////////////////////
410 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
411 /////////////////////////////////////////////////////////////////////////////////
412 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
414 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
415 /////////////////////////////////////////////////////////////////////////////////
416 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
417 /////////////////////////////////////////////////////////////////////////////////
418 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
419                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
422 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
423                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
424 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
425                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
426 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
427 /////////////////////////////////////////////////////////////////////////////////
428 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
429 /////////////////////////////////////////////////////////////////////////////////
430 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
431                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
432 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
433                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
434                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
435 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
436 /////////////////////////////////////////////////////////////////////////////////
437 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
438 /////////////////////////////////////////////////////////////////////////////////
439 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
440                                                                                                            {62.0*fgkmm,21.87*fgkmm};
441 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
442                                                                                                             {47.0*fgkmm,0.35*fgkmm};
443 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
444                                                                                                                                           1.0*fgkmm;
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
446 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
447                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
448 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
449                                                                                                                                          0.15*fgkmm;
450 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
451                                                                                                                                          19.0*fgkmm;
452 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
453                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
454 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
455                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
456 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
457                                                                                                                                           2.1*fgkmm;
458 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
459                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
460 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
461                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
462 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
463                                                                                                                                            19*fgkmm; 
464 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
465                                                                                                                                           1.0*fgkmm;
466 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
467                                                                                                                                           3.6*fgkmm;
468 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
469                                                                                                                                          61.0*fgkmm; 
470 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
471                                                                                                                                          5.97*fgkmm; 
472 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
473 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
474                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
475                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
476 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
477                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
478 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
479                                                                                                                                           1.0*fgkmm; 
480 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
481                                                                                                                                    = 0.15*fgkmm; 
482 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
483                                                                                                                                          20.0*fgkmm;
484 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
487 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
488 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
489 /////////////////////////////////////////////////////////////////////////////////
490 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
491 /////////////////////////////////////////////////////////////////////////////////
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
500 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
501 /////////////////////////////////////////////////////////////////////////////////
502 // SSD Cone Parameters (lengths are in mm and angles in degrees)
503 /////////////////////////////////////////////////////////////////////////////////
504 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
509 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
525 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
526 /////////////////////////////////////////////////////////////////////////////////
527 // SSD Cables Parameters (lengths are in mm and angles in degrees)
528 /////////////////////////////////////////////////////////////////////////////////
529 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
532 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
533 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
534 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
536 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
541 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
542 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
543 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
544 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
545 /////////////////////////////////////////////////////////////////////////////////
546 ClassImp(AliITSv11GeometrySSD)
547 /////////////////////////////////////////////////////////////////////////////////
548 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
549   AliITSv11Geometry(),
550   fSSDChipMedium(),
551   fSSDChipGlueMedium(),
552   fSSDStiffenerMedium(),
553   fSSDStiffenerConnectorMedium(),
554   fSSDStiffener0603CapacitorMedium(),
555   fSSDStiffener1812CapacitorMedium(),
556   fSSDStiffenerHybridWireMedium(),
557   fSSDKaptonFlexMedium(),
558   fSSDAlTraceFlexMedium(),
559   fSSDAlTraceLadderCableMedium(),
560   fSSDKaptonLadderCableMedium(),
561   fSSDKaptonChipCableMedium(),
562   fSSDAlTraceChipCableMedium(),
563   fSSDAlCoolBlockMedium(),
564   fSSDSensorMedium(),
565   fSSDSensorSupportMedium(),
566   fSSDCarbonFiberMedium(),
567   fSSDTubeHolderMedium(),
568   fSSDCoolingTubeWater(),
569   fSSDCoolingTubePhynox(),
570   fSSDSupportRingAl(),
571   fSSDMountingBlockMedium(),
572   fSSDRohaCellCone(),
573   fSSDAir(),
574   fSSDCopper(),
575   fCreateMaterials(kFALSE),
576   fTransformationMatrices(kFALSE),
577   fBasicObjects(kFALSE),
578   fcarbonfiberjunction(),
579   fcoolingtubesupport(),
580   fhybridmatrix(),
581   fssdcoolingblocksystem(),
582   fcoolingblocksystematrix(),
583   fssdstiffenerflex(),
584   fssdendflex(),
585   fendladdercoolingtubesupportmatrix(),
586   fendladdermountingblock(),
587   fendladdermountingblockclip(),
588   fSSDSensor5(),
589   fSSDSensor6(),
590   fSSDLayer5(), 
591   fSSDLayer6(),
592   fMotherVol(),
593   fLay5LadderSupportRing(),
594   fLay6LadderSupportRing(),
595   fgkEndCapSupportSystem(),
596   fSSDCone(),
597   fColorCarbonFiber(4),
598   fColorRyton(5),
599   fColorPhynox(14),
600   fColorSilicon(3),
601   fColorAl(38),
602   fColorKapton(6),
603   fColorPolyhamide(5),
604   fColorStiffener(9),
605   fColorEpoxy(30),
606   fColorWater(7),
607   fColorG10(41)
608 {
609   ////////////////////////
610   // Standard constructor
611   ////////////////////////
612 }
613 /////////////////////////////////////////////////////////////////////////////////
614 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
615   AliITSv11Geometry(s.GetDebug()),
616   fSSDChipMedium(s.fSSDChipMedium),
617   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
618   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
619   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
620   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
621   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
622   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
623   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
624   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
625   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
626   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
627   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
628   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
629   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
630   fSSDSensorMedium(s.fSSDSensorMedium),
631   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
632   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
633   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
634   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
635   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
636   fSSDSupportRingAl(s.fSSDSupportRingAl),
637   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
638   fSSDRohaCellCone(s.fSSDRohaCellCone),
639   fSSDAir(s.fSSDAir),
640   fSSDCopper(s.fSSDCopper),
641   fCreateMaterials(s.fCreateMaterials),
642   fTransformationMatrices(s.fTransformationMatrices),
643   fBasicObjects(s.fBasicObjects),
644   fcarbonfiberjunction(s.fcarbonfiberjunction),
645   fcoolingtubesupport(s.fcoolingtubesupport),
646   fhybridmatrix(s.fhybridmatrix),
647   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
648   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
649   fssdstiffenerflex(s.fssdstiffenerflex),
650   fssdendflex(s.fssdendflex),
651   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
652   fendladdermountingblock(s.fendladdermountingblock),
653   fendladdermountingblockclip(s.fendladdermountingblockclip),
654   fSSDSensor5(s.fSSDSensor5),
655   fSSDSensor6(s.fSSDSensor6),
656   fSSDLayer5(s.fSSDLayer5),     
657   fSSDLayer6(s.fSSDLayer6),
658   fMotherVol(s.fMotherVol),
659   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
660   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
661   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
662   fSSDCone(s.fSSDCone),
663   fColorCarbonFiber(s.fColorCarbonFiber),
664   fColorRyton(s.fColorRyton),
665   fColorPhynox(s.fColorPhynox),
666   fColorSilicon(s.fColorSilicon),
667   fColorAl(s.fColorAl),
668   fColorKapton(s.fColorKapton),
669   fColorPolyhamide(s.fColorPolyhamide),
670   fColorStiffener(s.fColorStiffener),
671   fColorEpoxy(s.fColorEpoxy),
672   fColorWater(s.fColorWater),
673   fColorG10(s.fColorG10)
674 {
675   ////////////////////////
676   // Copy Constructor
677   ////////////////////////
678 }
679 /////////////////////////////////////////////////////////////////////////////////
680 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
681 operator=(const AliITSv11GeometrySSD &s){
682   ////////////////////////
683   // Assignment operator
684   ////////////////////////
685   this->~AliITSv11GeometrySSD();
686   new(this) AliITSv11GeometrySSD(s); 
687   return *this;
688 /*      
689   if(&s == this) return *this;
690   fMotherVol = s.fMotherVol;
691   return *this;
692  */
693 }
694 ///////////////////////////////////////////////////////////////////////////////
695 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
696   ///////////////////////////////////////////////////////////////////////  
697   // Method generating the trasformation matrix for the whole SSD Geometry   
698   ///////////////////////////////////////////////////////////////////////  
699   // Setting some variables for Carbon Fiber Supportmatrix creation
700   //////////////////////////////////////////////////////////////////////
701   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
702                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
703   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
704                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
705                                                                  +      fgkCarbonFiberSupportWidth);
706   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
707                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
708   TGeoRotation* carbonfiberot[3];
709   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
710   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
711   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
712   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
713   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
714                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
715                                                   -  fgkCarbonFiberTriangleLength
716                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
717   ///////////////////////////////////////////
718   //Setting Local Translations and Rotations: 
719   ///////////////////////////////////////////
720   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
721   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
722                                                                          0.5*carbonfibersupportheight,NULL);    
723   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
724                                                                          2.*symmetryplaneposition+transvector[1],
725                                                                          transvector[2], carbonfiberot[2]);
726   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
727   /////////////////////////////////////////////////////////////
728   // Carbon Fiber Support Transformations
729   /////////////////////////////////////////////////////////////
730   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
731   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
732                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
733                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
734                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
735   }             
736   /////////////////////////////////////////////////////////////
737   // Carbon Fiber Junction Transformation
738   /////////////////////////////////////////////////////////////
739   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
740   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
741   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
742   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
743   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
744         localcarbonfiberjunctionmatrix[i] = 
745                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
746         localcarbonfiberjunctionrot[i] = 
747                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
748         localcarbonfiberjunctiontrans[i] = 
749                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
750   }
751   ///////////////////////
752   // Setting Translations
753   ///////////////////////
754   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
755   localcarbonfiberjunctiontrans[1][0] = 
756                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
757   localcarbonfiberjunctiontrans[2][0] = 
758                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
759                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
760                                  fgkCarbonFiberTriangleLength
761                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
762   localcarbonfiberjunctiontrans[0][1] = 
763                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
764   localcarbonfiberjunctiontrans[1][1] = 
765                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
766   localcarbonfiberjunctiontrans[2][1] = 
767                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
768   ////////////////////
769   // Setting Rotations
770   ////////////////////
771   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
772                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
773                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
774   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
775         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
776   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
777   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
778   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
779   ////////////////////////////////////////
780   // Setting Carbon Fiber Junction matrix 
781   ////////////////////////////////////////
782   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
783                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
784                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
785                         localcarbonfiberjunctionmatrix[i][j] = 
786                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
787                                                            *localcarbonfiberjunctionrot[i][j]);
788                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
789          }
790   }
791   /////////////////////////////////////////////////////////////
792   // Carbon Fiber Lower Support Transformations
793   /////////////////////////////////////////////////////////////
794   TGeoTranslation* localcarbonfiberlowersupportrans[2];
795   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
796                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
797                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
798                                                                          0.0);
799   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
800                                                                          fgkCarbonFiberJunctionWidth
801                                                                 -    fgkCarbonFiberLowerSupportWidth
802                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
803                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
804                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
805    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
806    fcarbonfiberlowersupportrans[0] = 
807                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
808    fcarbonfiberlowersupportrans[1] = 
809                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
810   /////////////////////////////////////////////////////////////
811   // SSD Sensor Support Transformations
812   /////////////////////////////////////////////////////////////
813   const Int_t kssdsensorsupportmatrixnumber = 3;
814   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
815   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
816   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
817   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
818         localssdsensorsupportmatrix[i] = 
819                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
820         localssdsensorsupportrot[i] = 
821                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
822         localssdsensorsupportrans[i] = 
823                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
824   }
825   ///////////////////////
826   // Setting Translations
827   ///////////////////////
828   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
829                                                                           0.5*fgkSSDSensorSideSupportWidth,
830                                                                           0.0);
831   localssdsensorsupportrans[1][0] = 
832                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
833   localssdsensorsupportrans[2][0] = 
834                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
835   localssdsensorsupportrans[0][1] = 
836                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
837                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
838                                                                                 0.0);
839   localssdsensorsupportrans[1][1] = 
840                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
841                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
842                                                                     -   fgkSSDModuleSensorSupportDistance,
843                                                                                 0.0);
844   localssdsensorsupportrans[2][1] = 
845                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
846                                                                         -    fgkSSDSensorCenterSupportPosition,
847                                                                                  0.5*fgkSSDSensorCenterSupportWidth
848                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
849                                                                                  fgkSSDSensorCenterSupportThickness[0]);
850   localssdsensorsupportrans[0][2] = 
851                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
852                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
853                                                                                  fgkCarbonFiberJunctionWidth
854                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
855                                                                         +    fgkSSDSensorCenterSupportLength
856                                                                         -    fgkSSDSensorCenterSupportThickness[0])
857                                                                         -    fgkSSDSensorCenterSupportPosition,
858                                                                              0.0);
859   localssdsensorsupportrans[1][2] = 
860                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
861   localssdsensorsupportrans[2][2] = 
862                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
863   ////////////////////
864   // Setting Rotations
865   ////////////////////
866   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
867                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
868                         localssdsensorsupportrot[i][j] = new TGeoRotation();
869   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
870         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
871         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
872   }
873   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
874   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
875   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
876   ////////////////////////////////////////
877   // SSD Sensor Support matrix 
878   ////////////////////////////////////////
879   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
880                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
881                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
882                         localssdsensorsupportmatrix[i][j] = 
883                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
884                                                            *localssdsensorsupportrot[i][j]);
885                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
886          }
887   }
888   /////////////////////////////////////////////////////////////
889   // SSD Cooling Tube Support Transformations
890   /////////////////////////////////////////////////////////////
891   const Int_t kcoolingtubesupportmatrixnumber = 2;
892   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
893   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
894   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
895   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
896                                                                                                         /fgkCoolingTubeSupportRmax);
897   localcoolingtubesupportrans[0] = 
898                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
899                                                 +  2.*(fgkCoolingTubeSupportLength
900                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
901                                                 +  fgkCarbonFiberTriangleLength
902                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
903   localcoolingtubesupportrans[1] = 
904                         new TGeoTranslation(fgkCarbonFiberJunctionLength
905                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
906                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
907                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
908                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
909                     -  0.5*(fgkCarbonFiberLowerSupportWidth
910                                         +          fgkSSDSensorCenterSupportLength
911                     -      fgkSSDSensorCenterSupportThickness[0])
912                                         +  0.5*fgkSSDSensorLength,
913                                         -  0.5*fgkCoolingTubeSupportHeight);  
914   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
915   localcoolingtubesupportrot[i] = new TGeoRotation();
916   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
917   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
918   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
919         localcoolingtubesupportmatrix[i] = 
920                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
921                                                    *localcoolingtubesupportrot[i]);
922   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
923   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
924                                                                 (*localcoolingtubesupportmatrix[0]));
925   /////////////////////////////////////////////////////////////
926   // End Ladder SSD Cooling Tube Support Transformations
927   /////////////////////////////////////////////////////////////
928   TGeoTranslation** localendladdercooltubetrans[2];
929   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
930   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
931   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
932   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
933                                                                                         -          (fgkCoolingTubeSupportLength
934                                                                                         -               fgkCoolingTubeSupportRmax),
935                                                                                                         fgkEndLadderMountingBlockPosition[0]
936                                                                                         -               fgkendladdercoolingsupportdistance[0]
937                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
938                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
939   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
940                                                                                         -          (fgkCoolingTubeSupportLength
941                                                                                         -               fgkCoolingTubeSupportRmax),
942                                                                                                         fgkEndLadderMountingBlockPosition[0]
943                                                                                         +               fgkendladdercoolingsupportdistance[1]
944                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
945                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
946   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
947                                                                                         -       fgkCoolingTubeSupportRmax)
948                                                                                         +               fgkCarbonFiberTriangleLength
949                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
950                                                                                                 0.0,
951                                                                                                 0.0);
952   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
953                                                                                                         fgkendladdercoolingsupportdistance[0]
954                                                                                         +               fgkendladdercoolingsupportdistance[1],
955                                                                                                         0.0);
956   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
957   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
958                                                                                         +               fgkCarbonFiberJunctionLength
959                                                                                         -               fgkCoolingTubeSupportLength,
960                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
961                                                                                         -       0.5*fgkCoolingTubeSupportWidth
962                                                                                                    -fgkendladdercoolingsupportdistance[2],
963                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
964   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
965                                                                                         +               fgkCoolingTubeSupportLength
966                                                                                         -               fgkCoolingTubeSupportRmax
967                                                                                         -               fgkCarbonFiberJunctionLength,
968                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
969                                                                                         -       0.5*fgkCoolingTubeSupportWidth
970                                                                                         -               fgkendladdercoolingsupportdistance[2],
971                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
972   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
973   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
974   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
975   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
976   (*localcoolingtubesupportrot[1]));
977   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
978   (*localcoolingtubesupportrot[1]));
979   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
980   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
981   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
982   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
983   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
984
985   fendladdercoolingtubesupportmatrix[1][0] =    
986                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
987                                                                                    *(*localcoolingtubesupportrot[1]));
988   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
989   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
990   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
991   /////////////////////////////////////////////////////////////
992   // SSD Cooling Tube Transformations
993   /////////////////////////////////////////////////////////////
994   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
995   localcoolingtuberot->SetAngles(0.,90.,0.);
996   TGeoTranslation** localcoolingtubetrans[4];
997   TVector3** localcoolingtubevect[4];
998   for(Int_t i=0; i<4; i++){
999         localcoolingtubevect[i] = new TVector3*[2];
1000         localcoolingtubetrans[i] = new TGeoTranslation*[2];
1001         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
1002   }
1003   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1004                                                   -fgkCarbonFiberTriangleLength),
1005                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1006                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1007                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1008                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1009                                                   +      fgkSSDSensorCenterSupportLength
1010                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1011                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1012                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1013                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1014                                                   -  0.5*fgkCoolingTubeSupportWidth,
1015                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1016   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1017                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1018                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1019                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1020                                                   +  fgkCoolingTubeSupportWidth,
1021                                                   localcoolingtubevect[0][0]->Z());     
1022   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1023                                                          +                               fgkCarbonFiberTriangleLength,
1024                                                                                          localcoolingtubevect[0][0]->Y(),
1025                                                                                          localcoolingtubevect[0][0]->Z());
1026   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1027                                                          +                               fgkCarbonFiberTriangleLength,
1028                                                                                          localcoolingtubevect[0][1]->Y(),
1029                                                                                          localcoolingtubevect[0][1]->Z());
1030   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1031                                                   -     fgkCarbonFiberTriangleLength),
1032                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1033                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1034                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1035                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1036                                                   +      fgkSSDSensorCenterSupportLength
1037                                                   -      fgkSSDSensorCenterSupportThickness[0])
1038                                                   +  fgkSSDModuleStiffenerPosition[1]
1039                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1040                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1041   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1042                                                          +                               fgkCarbonFiberTriangleLength,
1043                                                                                          localcoolingtubevect[2][0]->Y(),
1044                                                                                          localcoolingtubevect[2][0]->Z());      
1045   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1046                                                   -     fgkCarbonFiberTriangleLength),
1047                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1048                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1049                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1050                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1051                                                   +      fgkSSDSensorCenterSupportLength
1052                                                   -      fgkSSDSensorCenterSupportThickness[0])
1053                                                   +      fgkSSDSensorLength
1054                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1055                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1056   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1057                                                   + fgkCarbonFiberTriangleLength,
1058                                                         localcoolingtubevect[3][0]->Y(),
1059                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1060   for(Int_t i=0; i<4; i++) 
1061         for(Int_t j=0; j<2; j++){
1062                 localcoolingtubetrans[i][j] = 
1063                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1064                                                                 localcoolingtubevect[i][j]->Y(),
1065                                                                 localcoolingtubevect[i][j]->Z());
1066                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1067                                                           *                                     (*localcoolingtuberot));
1068         }
1069   /////////////////////////////////////////////////////////////
1070   // SSD End Ladder Cooling Tube Transformations
1071   /////////////////////////////////////////////////////////////
1072   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1073   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1074   TGeoTranslation** localendlladdercoolingtubetrans[2];
1075   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1076   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1077   for(Int_t i=0; i<2; i++)      
1078         for(Int_t j=0; j<(i==0?6:4); j++)       
1079                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1080   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1081                                                                         -        fgkCoolingTubeSupportRmax)
1082                                                                         +        fgkCarbonFiberJunctionLength,
1083                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1084                                                                         -    fgkendladdercoolingsupportdistance[0]),
1085                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1086   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1087                                                                         -        fgkCoolingTubeSupportRmax)
1088                                                                         -        fgkCarbonFiberJunctionLength
1089                                                                         +    fgkCarbonFiberTriangleLength,
1090                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1091                                                                         -    fgkendladdercoolingsupportdistance[0]),
1092                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1093   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1094                                                                         -   fgkCoolingTubeSupportRmax)
1095                                                                         +       fgkCarbonFiberJunctionLength,
1096                                                                            fgkEndLadderMountingBlockPosition[0]
1097                                                                         -   fgkendladdercoolingsupportdistance[0]
1098                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1099                                                   +                             fgkendladdercoolingsupportdistance[1]
1100                                                   +                             fgkCoolingTubeSupportWidth),
1101                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1102   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1103                                                                         -        fgkCoolingTubeSupportRmax)
1104                                                                         -        fgkCarbonFiberJunctionLength
1105                                                                         +    fgkCarbonFiberTriangleLength,
1106                                                                            fgkEndLadderMountingBlockPosition[0]
1107                                                                         -   fgkendladdercoolingsupportdistance[0]
1108                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1109                                                   +                             fgkendladdercoolingsupportdistance[1]
1110                                                   +                             fgkCoolingTubeSupportWidth),
1111                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1112   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1113                                                                         -   fgkCoolingTubeSupportRmax)
1114                                                                         +       fgkCarbonFiberJunctionLength,
1115                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1116                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1117                                                   -                     fgkEndLadderMountingBlockPosition[0]
1118                                                   -                     fgkendladdercoolingsupportdistance[1]           
1119                                                   -                     fgkCoolingTubeSupportWidth),
1120                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1121   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1122                                                                         -        fgkCoolingTubeSupportRmax)
1123                                                                         -        fgkCarbonFiberJunctionLength
1124                                                                         +    fgkCarbonFiberTriangleLength,
1125                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1126                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1127                                                   -                     fgkEndLadderMountingBlockPosition[0]
1128                                                   -                     fgkendladdercoolingsupportdistance[1]           
1129                                                   -                     fgkCoolingTubeSupportWidth),
1130                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1131   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1132                                                                         -   fgkCoolingTubeSupportRmax)
1133                                                                         +       fgkCarbonFiberJunctionLength,
1134                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1135                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1136                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1137                                                         +                 fgkSSDSensorOverlap
1138                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1139                                                         -                 fgkendladdercoolingsupportdistance[2]
1140                                                         -                 fgkEndLadderMountingBlockPosition[1]
1141                                                         -                 fgkCoolingTubeSupportWidth)
1142                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1143                                                         -                 fgkendladdercoolingsupportdistance[2]
1144                                                         -                 fgkCoolingTubeSupportWidth,
1145                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1146   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1147                                                   -      fgkCoolingTubeSupportRmax)
1148                                                   -      fgkCarbonFiberJunctionLength
1149                                                   +    fgkCarbonFiberTriangleLength,
1150                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1151                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1152                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1153                                                         +                 fgkSSDSensorOverlap
1154                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1155                                                         -                 fgkendladdercoolingsupportdistance[2]
1156                                                         -                 fgkEndLadderMountingBlockPosition[1]
1157                                                         -                 fgkCoolingTubeSupportWidth)
1158                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1159                                                         -                 fgkendladdercoolingsupportdistance[2]
1160                                                         -                 fgkCoolingTubeSupportWidth,
1161                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1162   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1163                                                                         -   fgkCoolingTubeSupportRmax)
1164                                                                         +       fgkCarbonFiberJunctionLength,
1165                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1166                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1167                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1168   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1169                                                                         -        fgkCoolingTubeSupportRmax)
1170                                                                         -        fgkCarbonFiberJunctionLength
1171                                                                         +    fgkCarbonFiberTriangleLength,
1172                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1173                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1174                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1175   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1176   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1177   for(Int_t i=0; i<2; i++)
1178         for(Int_t j=0; j<(i==0?6:4); j++){
1179                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1180                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1181         }
1182   /////////////////////////////////////////////////////////////
1183   // SSD Hybrid Components Transformations
1184   /////////////////////////////////////////////////////////////
1185   const Int_t khybridmatrixnumber = 3;
1186   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1187   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1188                                             0.5*fgkSSDStiffenerWidth,
1189                                             0.5*fgkSSDStiffenerHeight);
1190   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1191                                             fgkSSDModuleStiffenerPosition[1],0.0);
1192
1193   localhybridtrans[2] = new TGeoTranslation(
1194                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1195                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1196                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1197                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1198                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1199                       -       fgkSSDSensorCenterSupportThickness[0]),
1200                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1201                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1202                                           -       fgkSSDModuleVerticalDisalignment2)); 
1203   fhybridmatrix = new TGeoHMatrix();
1204   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1205   /////////////////////////////////////////////////////////////
1206   // SSD Cooling Block Transformations
1207   /////////////////////////////////////////////////////////////
1208   const Int_t kcoolingblockmatrixnumber = 4;    
1209   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1210   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1211                             -  fgkCoolingTubeSupportRmin),0.0,
1212                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1213   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1214                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1215                                0.0,fgkSSDStiffenerHeight);
1216   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1217   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1218   fcoolingblocksystematrix = new TGeoHMatrix();
1219   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1220       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1221   /////////////////////////////////////////////////////////////
1222   // SSD Stiffener Flex Transformations
1223   /////////////////////////////////////////////////////////////
1224   const Int_t klocalflexmatrixnumber = 4;
1225   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1226   for(Int_t i=0; i<fgkflexnumber; i++)    
1227       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1228   for(Int_t i=0; i<fgkflexnumber; i++)
1229       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1230             localflexmatrix[i][j] = new TGeoCombiTrans();
1231   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1232                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1233                                                                   -    fgkSSDStiffenerWidth;
1234   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1235                                         +0.5*fgkSSDStiffenerLength,
1236                                          0.5*fgkSSDStiffenerWidth,
1237                                         -0.5*fgkSSDStiffenerHeight
1238                                         -0.5*fgkSSDFlexHeight[0]);
1239   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1240                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1241                                         -0.5*fgkSSDStiffenerWidth,
1242                                         -0.5*fgkSSDStiffenerHeight
1243                                         -0.5*fgkSSDFlexHeight[0]);
1244   TGeoRotation* localflexrot = new TGeoRotation();
1245   localflexrot->SetAngles(180.,0.,0.);    
1246   localflexmatrix[1][0]->SetRotation(localflexrot);
1247   for(Int_t i=0; i<fgkflexnumber; i++)
1248       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1249             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1250   for(Int_t i=0; i<fgkflexnumber; i++){
1251       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1252       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1253             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1254   }
1255   /////////////////////////////////////////////////////////////
1256   // SSD End Flex Transformations
1257   /////////////////////////////////////////////////////////////
1258   TGeoRotation* localendflexrot = new TGeoRotation();
1259   localendflexrot->SetAngles(0.0,90.0,0.0);
1260   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1261   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1262                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1263   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1264                             * TMath::DegToRad()*ssdflexradiusmax
1265                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1266                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
1267   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1268                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1269                             +      fgkSSDFlexLength[2];
1270   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1271                               0.5*fgkSSDFlexWidth[0],
1272                               2.*fgkSSDStiffenerHeight
1273                             + 0.5*fgkSSDFlexHeight[0]);      
1274   localendflexmatrix->SetRotation(localendflexrot);
1275   for(Int_t i=0; i<fgkflexnumber; i++) 
1276       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1277   /////////////////////////////////////////////////////////////
1278   // End Ladder Carbon Fiber Junction
1279   /////////////////////////////////////////////////////////////
1280   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1281   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1282   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1283   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1284       localendladdercarbonfiberjunctionmatrix[i] 
1285             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1286       localendladdercarbonfiberjunctionrot[i] 
1287             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1288       localendladdercarbonfiberjunctiontrans[i] 
1289             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1290       fendladdercarbonfiberjunctionmatrix[i]
1291             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1292   }
1293   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1294       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1295             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1296             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1297       }
1298   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1299       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1300           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1301   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1302       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1303                               0.0,0.0);
1304       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1305                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1306                 *                     SinD(fgkCarbonFiberTriangleAngle),
1307                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1308   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1309   }
1310   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1311   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1312   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1313   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1314       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1315       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1316       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1317       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1318             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1319       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1320             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1321                                *localendladdercarbonfiberjunctionglobalrot[i]);
1322   }
1323   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1324       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1325             localendladdercarbonfiberjunctionmatrix[i][j] = 
1326                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1327                                      *localendladdercarbonfiberjunctionrot[i][j]);
1328            fendladdercarbonfiberjunctionmatrix[i][j] =
1329             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1330             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1331       }  
1332   /////////////////////////////////////////////////////////////
1333   // End Ladder Carbon Fiber Support
1334   /////////////////////////////////////////////////////////////
1335   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1336   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1337       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1338       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1339             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1340       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1341   }
1342   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1343       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1344             fendladdercarbonfibermatrix[i][j] = 
1345             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1346             *(*fcarbonfibersupportmatrix[j]));
1347   /////////////////////////////////////////////////////////////
1348   // End Ladder SSD Mounting Block
1349   /////////////////////////////////////////////////////////////
1350   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1351       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1352   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1353       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1354                                 +        fgkSSDMountingBlockLength[1])
1355                                 +  0.5*fgkCarbonFiberTriangleLength,
1356                                 fgkEndLadderMountingBlockPosition[i],
1357                                 -  fgkSSDMountingBlockHeight[1]
1358                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1359   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1360   endladdermountingblockrot->SetAngles(0.,90.,0.);
1361   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1362         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1363   /////////////////////////////////////////////////////////////
1364   // End Ladder SSD Mounting Block Clip Matrix 
1365   /////////////////////////////////////////////////////////////
1366   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1367         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1368   
1369   TGeoRotation* localendladdercliprot = new TGeoRotation();
1370   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1371   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1372                                                                                   -     fgkSSDMountingBlockLength[1])
1373                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1374   localendladdercliprot->SetAngles(90.,180.,-90.);
1375   TGeoCombiTrans* localendladderclipcombitrans = 
1376                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1377   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1378         for(Int_t j=0; j<2; j++){
1379                 fendladdermountingblockclipmatrix[i][j] = 
1380                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1381                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1382         }
1383   /////////////////////////////////////////////////////////////
1384   // End Ladder Carbon Fiber Lower Support
1385   /////////////////////////////////////////////////////////////
1386   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1387       fendladderlowersupptrans[i] = 
1388             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1389                         +  0.5*fgkSSDMountingBlockWidth),
1390                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1391   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1392                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1393                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1394                                                                          0.0);
1395   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1396  /////////////////////////////////////////////////////////////
1397   // Matrix for positioning Ladder into mother volume
1398   /////////////////////////////////////////////////////////////
1399   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1400   for(Int_t i=0; i<fgkladdernumber; i++) 
1401         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1402   TGeoRotation* localladdermotherrot = new TGeoRotation();
1403   localladdermotherrot->SetAngles(0.,90.,0.);  
1404   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1405   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1406   for(Int_t i=0; i<fgkladdernumber; i++){
1407         localladdermothertrans[i] = new TGeoTranslation(0.,
1408                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1409                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1410                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1411                                                           * fgkCarbonFiberJunctionWidth,0.);
1412         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1413                                                                                                                 *localladdermotherrot);
1414         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1415         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1416   }
1417   /////////////////////////////////////////////////////////////
1418   // Ladder Cables Matrices
1419   /////////////////////////////////////////////////////////////
1420   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1421                                              + fgkSSDFlexHeight[1];  
1422   Double_t ssdladdercabletransx[3];
1423   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1424                                                   *   SinD(2.*fgkSSDFlexAngle)
1425                                                   *       CosD(2.*fgkSSDFlexAngle);
1426   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1427                                                   -     ssdladdercabletransx[0]
1428                                                   /     SinD(2.*fgkSSDFlexAngle))
1429                                                   *     CosD(fgkSSDFlexAngle);                                          
1430   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1431                                                   *       TMath::DegToRad()*ssdflexradiusmax
1432                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1433                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1434                                                   -       fgkSSDLadderCableWidth)
1435                                                   *       CosD(2.*fgkSSDFlexAngle);
1436   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1437                                                   *     TanD(2.*fgkSSDFlexAngle),
1438                                                         ssdladdercabletransx[1]
1439                                                   *     TanD(fgkSSDFlexAngle),
1440                                                         ssdladdercabletransx[2]
1441                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1442   TGeoRotation* localladdercablerot[3]; 
1443   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1444   localladdercablerot[0]->SetAngles(90.,0.,0.);
1445   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1446   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1447                                                  *                        (*localladdercablerot[0]));
1448   ////////////////////////////////////////////
1449   // LocalLadderCableCombiTransMatrix
1450   ////////////////////////////////////////////
1451   const Int_t klocalladdersidecablesnumber = 2;
1452   const Int_t klocalladdercombitransnumber = 5;
1453   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1454   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1455          localladdercablecombitransmatrix[i] = 
1456                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1457   ///////////////////////////////////////////
1458   // Left Side Ladder Cables Transformations
1459   ///////////////////////////////////////////
1460   localladdercablecombitransmatrix[0][0]  =
1461                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1462                                                 0.,0.,NULL);
1463   localladdercablecombitransmatrix[0][1] = 
1464         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1465                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1466                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1467                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1468                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1469                                            + fgkSSDSensorCenterSupportLength
1470                                            - fgkSSDSensorCenterSupportThickness[0]),
1471                                            - (fgkSSDModuleCoolingBlockToSensor
1472                                            + 0.5*fgkCoolingTubeSupportHeight
1473                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1474                                            - fgkSSDChipHeight),NULL);
1475   localladdercablecombitransmatrix[0][2] = 
1476                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1477                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1478   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1479                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1480                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1481                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1482                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1483                                                                                                 new TGeoRotation("",180.,0.,0.));
1484   localladdercablecombitransmatrix[0][4] = 
1485                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1486                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1487                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1488                                                           0.,
1489                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1490                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1491                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1492                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1493   ///////////////////////////////////////////
1494   // Rigth Side Ladder Cables Transformations
1495   ///////////////////////////////////////////
1496   TGeoCombiTrans* localladdercablessdmodulematrix = 
1497         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1498                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1499                                                                          fgkSSDStiffenerWidth,
1500                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1501   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1502    localladdercablecombitransmatrix[1][i] = 
1503                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1504                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1505   ///////////////////////////////////////////
1506   // Setting LadderCableHMatrix
1507   ///////////////////////////////////////////
1508   Int_t beamaxistrans[2][3];
1509   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1510   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1511   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1512   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1513   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1514   beamaxistrans[1][2] = beamaxistrans[1][0];
1515   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1516   TGeoRotation* laddercablerot = new TGeoRotation();
1517   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1518   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1519   Double_t* laddercabletransvector;     
1520   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1521         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1522         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1523   }
1524   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1525         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1526                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1527                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1528                         localladdercablehmatrix[i][j]->MultiplyLeft(
1529                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1530         }
1531                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1532                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1533                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1534                                                                          laddercabletransvector[1]
1535                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1536                                         *                                fgkCarbonFiberJunctionWidth,
1537                                                                          laddercabletransvector[2]);
1538                 laddercablecombitrans->SetRotation(*laddercablerot);
1539                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1540                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1541         }
1542     fladdercablematrix[i][2] = 
1543                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1544                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1545         fladdercablematrix[i][3] = 
1546                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1547                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1548   }
1549   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1550         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1551                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1552   ///////////////////////////////////////////
1553   // Setting Ladder HMatrix
1554   ///////////////////////////////////////////
1555   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1556                                                                                                 fgkSSDLay6SensorsNumber};
1557   for(Int_t i=0; i<fgkladdernumber; i++){
1558         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1559         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1560                 fladdermatrix[i][j] = new TGeoHMatrix();
1561                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1562                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1563                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1564         }
1565   }
1566   ///////////////////////////////////////////
1567   // Setting SSD Sensor Matrix 
1568   ///////////////////////////////////////////
1569   TGeoCombiTrans* localssdsensorcombitrans[2];
1570   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1571   localssdsensorrot->SetAngles(0.,90.,0.);      
1572   TGeoTranslation* localssdsensortrans[2];
1573   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1574   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1575                                           -             (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1576                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1577                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1578                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1579                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1580                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1581                                           -             fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1582                                           +    (fgkSSDSensorSideSupportHeight[1]
1583                                           -             fgkSSDSensorSideSupportHeight[0])
1584                                           +     0.5*fgkSSDModuleVerticalDisalignment2);
1585   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1586                                           -        (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1587                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1588                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1589                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1590                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1591                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1592                                                         -fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1593                                                 +       0.5*fgkSSDModuleVerticalDisalignment2);
1594   for(Int_t i=0; i<2; i++) 
1595         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1596                                                                                                          *localssdsensorrot);   
1597     for(Int_t i=0; i<fgkladdernumber; i++){
1598         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1599         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1600                 switch(i){
1601                         case 0: //Ladder of Layer5  
1602                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1603                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1604                                                                                                 *localssdsensorcombitrans[1])));
1605                         break;
1606                         case 1: //Ladder of Layer6 
1607                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1608                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1609                                                                                                 *localssdsensorcombitrans[0])));
1610                 break;
1611                 }
1612           }
1613   }     
1614   //////////////////////////
1615   // Setting SSD End Ladder  
1616   //////////////////////////
1617   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1618   for(Int_t i=0; i<2; i++){
1619         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1620         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1621         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1622         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1623         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1624         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1625         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1626         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1627    }
1628   /////////////////////////////////////////////////////
1629   // Setting the CombiTransformation to pass ITS center 
1630   /////////////////////////////////////////////////////
1631   Double_t itscentertransz[fgklayernumber];
1632   itscentertransz[0] = fgkSSDLay5LadderLength
1633                                          - fgkLay5CenterITSPosition;
1634   itscentertransz[1] = fgkSSDLay6LadderLength
1635                                          - fgkLay6CenterITSPosition;
1636   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1637                                                    + 0.5*fgkCoolingTubeSupportHeight;
1638   TGeoRotation* itscenterrot[3];
1639   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1640   itscenterrot[0]->SetAngles(90.,180.,-90.);
1641   itscenterrot[1]->SetAngles(0.,90.,0.);
1642   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1643   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1644   for(Int_t i=0; i<fgklayernumber; i++) 
1645         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1646                                                          itssensortransy,
1647                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1648                                                    - itscentertransz[i],itscenterrot[2]);
1649   TGeoRotation** locallayerrot[fgklayernumber];
1650   TGeoTranslation** locallayertrans[fgklayernumber];    
1651   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1652   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1653   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1654                                          - fgkLay5CenterITSPosition);
1655   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1656                                          - fgkLay6CenterITSPosition);
1657   const Int_t kssdlayladdernumber[fgklayernumber] = 
1658                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1659   for(Int_t i=0; i<fgklayernumber; i++){
1660     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1661     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1662         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1663         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1664   }
1665   Double_t layerladderangleposition[fgklayernumber] = 
1666                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1667   Double_t layerradius = 0.;
1668   for(Int_t i=0; i<fgklayernumber; i++){        
1669         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1670                 switch(i){
1671                         case 0: //Ladder of Layer5  
1672                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1673                         break;
1674                         case 1: //Ladder of Layer6 
1675                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1676                 break;
1677                 }
1678                 locallayerrot[i][j] = new TGeoRotation();
1679                 locallayertrans[i][j] = new TGeoTranslation();
1680                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1681                 locallayertrans[i][j]->SetTranslation(layerradius 
1682                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1683                                                             layerradius 
1684                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1685                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1686                                                                          *locallayerrot[i][j]);
1687                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1688                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1689                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1690         }
1691   }
1692   /////////////////////////////////////////////////////////////
1693   // Deallocating memory
1694   /////////////////////////////////////////////////////////////
1695   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1696         delete carbonfiberot[i];
1697         delete localcarbonfibersupportmatrix[i];
1698   }
1699   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1700      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1701        delete localcarbonfiberjunctionmatrix[i][j];
1702            delete localcarbonfiberjunctionrot[i][j];
1703            delete localcarbonfiberjunctiontrans[i][j];
1704            }
1705        delete [] localcarbonfiberjunctionmatrix[i];
1706        delete [] localcarbonfiberjunctionrot[i];
1707        delete [] localcarbonfiberjunctiontrans[i];
1708   }
1709   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1710            delete localcarbonfiberlowersupportrans[i];
1711   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1712      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1713        delete localssdsensorsupportmatrix[i][j];
1714            delete localssdsensorsupportrot[i][j];
1715            delete localssdsensorsupportrans[i][j];
1716            }
1717        delete [] localssdsensorsupportmatrix[i];
1718        delete [] localssdsensorsupportrot[i];
1719        delete [] localssdsensorsupportrans[i];
1720   }
1721   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1722         delete localcoolingtubesupportmatrix[i];
1723         delete localcoolingtubesupportrot[i];
1724         delete localcoolingtubesupportrans[i];
1725   }
1726   for(Int_t i=0; i<4; i++){
1727         for(Int_t j=0; j<2; j++){
1728                 delete localcoolingtubevect[i][j];
1729                 delete localcoolingtubetrans[i][j];
1730         }
1731         delete [] localcoolingtubevect[i];
1732         delete [] localcoolingtubetrans[i];
1733   }
1734  delete endladdermountingblockrot;
1735  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1736  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1737  for(Int_t i=0; i<fgkflexnumber; i++){
1738       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1739             delete localflexmatrix[i][j];
1740       delete [] localflexmatrix[i];
1741  }
1742  delete localendlladdercoolingtuberot;
1743  for(Int_t i=0; i<2; i++){
1744         for(Int_t j=0; j<(i==0?6:4); j++)
1745                 delete localendlladdercoolingtubetrans[i][j];
1746         delete [] localendlladdercoolingtubetrans[i];
1747   }
1748
1749  delete localflexrot;
1750  delete localendflexrot;
1751  delete localendflexmatrix;
1752  for(Int_t i=0; i<fgkladdernumber; i++){ 
1753         delete localladdermothertrans[i];
1754         delete localladdermothercombitrans[i];
1755   }
1756  delete localladdermotherrot;
1757  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1758       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1759             delete localendladdercarbonfiberjunctionmatrix[i][j];
1760             delete localendladdercarbonfiberjunctionrot[i][j];
1761             delete localendladdercarbonfiberjunctiontrans[i][j];
1762       }
1763       delete [] localendladdercarbonfiberjunctionmatrix[i];
1764       delete [] localendladdercarbonfiberjunctionrot[i];
1765       delete [] localendladdercarbonfiberjunctiontrans[i];
1766       delete localendladdercarbonfiberjunctionglobalrot[i];
1767       delete localendladdercarbonfiberjunctionglobaltrans[i];
1768       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1769  }
1770   for(Int_t i=0; i<2; i++){
1771         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1772         delete [] localendladdercooltubetrans[i];
1773   }
1774   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1775       delete localendladdercarbonfibertrans[i];
1776   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1777   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1778         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1779                 delete localladdercablecombitransmatrix[i][j];
1780                 delete []localladdercablecombitransmatrix[i];
1781   }
1782   delete localendladdercliprot;
1783   delete localendladdercliptrans;
1784   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1785         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1786                 delete localladdercablehmatrix[i][j];
1787         delete []localladdercablehmatrix[i];
1788   }
1789   delete laddercablerot;
1790   delete laddercabletrans;
1791   delete laddercablecombitrans;
1792   delete localladdercablessdmodulematrix;
1793   delete localssdsensorrot;     
1794   for(Int_t i=0; i<2; i++){
1795         delete localssdsensortrans[i];
1796         delete localssdsensorcombitrans[i];
1797   }
1798   for(Int_t i=0; i<fgklayernumber; i++){
1799         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1800                 delete locallayerrot[i][j];
1801                 delete locallayertrans[i][j];
1802                 delete locallayercombitrans[i][j];
1803     }
1804         delete [] locallayerrot[i];
1805         delete [] locallayertrans[i];
1806         delete [] locallayercombitrans[i];
1807         delete localbeamaxistrans[i];
1808   }
1809   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1810   for(Int_t i=0; i<fgkladdernumber; i++){
1811         for(Int_t j=0; j<fgkladdernumber; j++)
1812                 delete ladderglobalmatrix[i][j];
1813         delete [] ladderglobalmatrix[i];
1814   }
1815   /////////////////////////////////////////////////////////////
1816   fTransformationMatrices = kTRUE;      
1817 }
1818 ///////////////////////////////////////////////////////////////////////////////
1819 void AliITSv11GeometrySSD::CreateBasicObjects(){
1820   /////////////////////////////////////////////////////////////  
1821   // Method generating the Objects of SSD Geometry    
1822   /////////////////////////////////////////////////////////////
1823   // SSD Sensor
1824   ///////////////////////////////////
1825   SetSSDSensor();
1826   /////////////////////////////////////////////////////////////  
1827   // Carbon Fiber Support    
1828   /////////////////////////////////////////////////////////////  
1829   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1830   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1831       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1832   /////////////////////////////////////////////////////////////
1833   // Carbon Fiber Junction 
1834   /////////////////////////////////////////////////////////////
1835   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1836   /////////////////////////////////////////////////////////////
1837   // Carbon Fiber Lower Support
1838   /////////////////////////////////////////////////////////////
1839   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1840   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1841         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1842   /////////////////////////////
1843   // SSD Sensor Support
1844   /////////////////////////////
1845   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1846                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1847   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1848                                                                          fgkSSDSensorSideSupportThickness[1]};
1849   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1850         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1851                                                                                            fgkSSDSensorSideSupportHeight[i],
1852                                                                                            fgkSSDSensorSideSupportWidth,
1853                                                                                            sidesupporthickness);  
1854         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1855                                                                                            fgkSSDSensorCenterSupportHeight[i],
1856                                                                                            fgkSSDSensorCenterSupportWidth,
1857                                                                                            sidesupporthickness);
1858   }
1859   /////////////////////////////////////////////////////////////
1860   // SSD Cooling Tube Support
1861   /////////////////////////////////////////////////////////////
1862   Int_t edgesnumber = 16;
1863   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1864   /////////////////////////////////////////////////////////////
1865   // SSD Hybrid
1866   /////////////////////////////////////////////////////////////
1867   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1868   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1869         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1870   /////////////////////////////////////////////////////////////
1871   // SSD Cooling Block System
1872   /////////////////////////////////////////////////////////////
1873   fssdcoolingblocksystem = GetCoolingBlockSystem();
1874    /////////////////////////////////////////////////////////////
1875   // SSD Cooling Tube
1876   /////////////////////////////////////////////////////////////
1877   TList* coolingtubelist = GetCoolingTubeList();        
1878   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1879         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1880   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1881         fendladdercoolingtube[i] = 
1882                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1883   /////////////////////////////////////////////////////////////
1884   // SSD Flex  
1885   /////////////////////////////////////////////////////////////
1886   fssdstiffenerflex = GetSSDStiffenerFlex();
1887   fssdendflex = GetSSDEndFlex();
1888   ///////////////////////////////////
1889   // End Ladder Carbon Fiber Junction
1890   ///////////////////////////////////
1891   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1892                                                    fendladdercarbonfiberjunction[i] = 
1893                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1894   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1895     fendladdercarbonfiberjunction[i][0] = 
1896                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1897     fendladdercarbonfiberjunction[i][1] = 
1898                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1899   }
1900   ///////////////////////////////////
1901   // End Ladder Mounting Block
1902   ///////////////////////////////////
1903   fendladdermountingblock = GetSSDMountingBlock();
1904   ///////////////////////////////////
1905   // End Ladder Mounting Block
1906   ///////////////////////////////////
1907   fendladdermountingblockclip = GetMountingBlockClip();
1908   ///////////////////////////////////
1909   // Ladder Support 
1910   ///////////////////////////////////
1911   TList* laddersupportlist = GetMountingBlockSupport(20);
1912   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1913   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1914   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1915   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1916   /////////////////////////////////////////////////////////////
1917   // Deallocating memory
1918   /////////////////////////////////////////////////////////////
1919   delete carbonfibersupportlist;
1920   delete carbonfiberlowersupportlist;
1921   delete ssdhybridcomponentslist;
1922   delete laddersupportlist;
1923   /////////////////////////////////////////////////////////////
1924   fBasicObjects = kTRUE;
1925 }
1926 /////////////////////////////////////////////////////////////////////////////////
1927 void AliITSv11GeometrySSD::SetSSDSensor(){
1928   ////////////////////////////////////////////////////////////////
1929   // Method generating SSD Sensors: it sets the private variables
1930   // fSSDSensor5, fSSDSensor6  
1931   ////////////////////////////////////////////////////////////////
1932   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1933   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1934   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1935                                                 0.5*ssdsensitivewidth,
1936                                                 0.5*fgkSSDSensorHeight,
1937                                                 0.5*ssdsensitivelength);
1938   TGeoVolume* ssdsensorsensitiveLay5 = 
1939         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1940   TGeoVolume* ssdsensorsensitiveLay6 = 
1941         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1942   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1943   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1944   TGeoBBox* ssdsensorinsensitiveshape[2];
1945   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1946                                                 0.5*fgkSSDSensorInsensitiveWidth,
1947                                                 0.5*fgkSSDSensorHeight,
1948                                                 0.5*fgkSSDSensorLength);
1949   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1950                                                 0.5*ssdsensitivewidth,
1951                                                 0.5*fgkSSDSensorHeight,
1952                                                 0.5*fgkSSDSensorInsensitiveWidth);
1953   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1954                                              "SSDSensorInsensitive2"};
1955   TGeoVolume* ssdsensorinsensitive[2];
1956   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1957       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1958                      fSSDSensorMedium);
1959       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1960   }
1961   /////////////////////////////////////////////////////////////
1962   // Virtual Volume containing SSD Sensor  
1963   /////////////////////////////////////////////////////////////
1964   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1965                                                                                              0.5*fgkSSDSensorWidth,
1966                                                                                              0.5*fgkSSDSensorHeight,
1967                                                                                              0.5*fgkSSDSensorLength);
1968   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1969                                                                                  fSSDAir);      
1970   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1971                                                                                  fSSDAir);      
1972   /////////////////////////////////////////////////////////////
1973   for(Int_t i=0; i<4; i++){ 
1974             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1975             ssdsensorinsensitive[1],i<2?1:2,
1976                         new TGeoTranslation(
1977                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1978       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1979                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1980       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1981             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1982             ssdsensorinsensitive[1],i<2?1:2,
1983                         new TGeoTranslation(
1984                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1985       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1986                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1987       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1988   }
1989     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1990     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1991 }
1992 ///////////////////////////////////////////////////////////////////////////////
1993 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1994   /////////////////////////////////////////////////////////////  
1995   // Method generating the Carbon Fiber Support   
1996   /////////////////////////////////////////////////////////////  
1997   const Int_t kvertexnumber = 4;
1998   const Int_t kshapesnumber = 2;
1999   TVector3** vertexposition[kshapesnumber];
2000   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
2001   Double_t carbonfibersupportxaxisEdgeproj = 
2002                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2003         *       TMath::DegToRad());
2004   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
2005                                  /                         fgkCarbonFiberSupportXAxisLength);
2006   /////////////////////
2007   //Vertex Positioning
2008   ////////////////////
2009   vertexposition[0][0] = new TVector3();
2010   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
2011                                                                           fgkCarbonFiberSupportYAxisLength);
2012   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2013                                                                           carbonfibersupportxaxisEdgeproj
2014                                            *                      TMath::Tan(theta));
2015   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2016                                            -                      carbonfibersupportxaxisEdgeproj,
2017                                                                           fgkCarbonFiberSupportYAxisLength
2018                                            -                      vertexposition[0][2]->Y());
2019   ////////////////////////////////////////////////////
2020   //Setting the parameters for Isometry Transformation
2021   ////////////////////////////////////////////////////
2022   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2023                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2024                                                                  +      fgkCarbonFiberSupportWidth);
2025   Double_t* param = new Double_t[4]; 
2026   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2027   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2028                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2029                                                           (GetReflection(vertexposition[0][j],param))->Y());
2030   char* carbonfibersupportshapename[kshapesnumber] = 
2031                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2032   char* carbonfibersupportname[kshapesnumber] = 
2033                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2034   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2035   TGeoVolume* carbonfibersupport[kshapesnumber];
2036   TList* carbonfibersupportlist = new TList();
2037   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2038   Double_t carbonfibersupportheight = 
2039           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2040           *TMath::DegToRad());
2041   for(Int_t i = 0; i< kshapesnumber; i++){
2042    carbonfibersupportshape[i] = 
2043                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2044                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2045    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2046                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2047    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2048    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2049    }
2050   /////////////////////////////////////////////////////////////
2051   // Deallocating memory
2052   /////////////////////////////////////////////////////////////
2053   for(Int_t i=0; i< kshapesnumber; i++){
2054      for(Int_t j=0; j< kvertexnumber; j++)
2055            delete vertexposition[i][j];
2056        delete [] vertexposition[i];
2057   }
2058   delete [] param;
2059   /////////////////////////////////////////////////////////////
2060    return carbonfibersupportlist;
2061 }
2062 /////////////////////////////////////////////////////////////////////////////////
2063 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2064   /////////////////////////////////////////////////////////////
2065   // Method generating SSD Carbon Fiber Junction
2066   /////////////////////////////////////////////////////////////
2067   const Int_t kvertexnumber = 6;
2068   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2069   Double_t reflectionparam[3] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2070                                                           *  TMath::DegToRad()),-1.,0.};
2071   TVector3* vertex[kvertexnumber];
2072   vertex[0] = new TVector3();
2073   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2074                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2075                         *                         TMath::DegToRad()),
2076                                                   fgkCarbonFiberJunctionEdge[0]
2077                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2078                         *                         TMath::DegToRad()));
2079   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2080                                                    fgkCarbonFiberJunctionEdge[1]);
2081   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2082   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2083   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2084   Double_t xvertexpoints[6], yvertexpoints[6];
2085   for(Int_t i=0; i<kvertexnumber; i++) 
2086           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2087   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2088   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2089   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2090   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2091                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2092   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2093   /////////////////////////////////////////////////////////////
2094   // Deallocating memory
2095   /////////////////////////////////////////////////////////////
2096   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2097   ///////////////////////////////////////////////////////////// 
2098   return carbonfiberjunction;
2099 }
2100 ////////////////////////////////////////////////////////////////////////////////
2101 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2102   /////////////////////////////////////////////////////////////
2103   // Method generating the Carbon Fiber Lower Support   
2104   /////////////////////////////////////////////////////////////  
2105   const Int_t kvertexnumber = 4;
2106   const Int_t kshapesnumber = 2;
2107   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2108                                                                 fgkCarbonFiberLowerSupportWidth};
2109   TVector3** vertexposition[kshapesnumber];
2110   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2111                                                  new TVector3*[kvertexnumber];
2112   //First Shape Vertex Positioning
2113   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2114   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2115                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2116   vertexposition[0][2] = new TVector3();
2117   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2118   //Second Shape Vertex Positioning
2119   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2120                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2121                                  /                              fgkCarbonFiberTriangleLength);
2122   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2123                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2124                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2125   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2126                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2127                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2128   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2129   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2130                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2131   char* carbonfiberlowersupportshapename[kshapesnumber] = 
2132                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2133   char* carbonfiberlowersupportname[kshapesnumber] = 
2134                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2135   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2136   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2137   TList* carbonfiberlowersupportlist = new TList();
2138   for(Int_t i = 0; i< kshapesnumber; i++){ 
2139         carbonfiberlowersupportshape[i] = 
2140                                                                 GetArbShape(vertexposition[i],width,
2141                                                                                         fgkCarbonFiberLowerSupportHeight,
2142                                                                                         carbonfiberlowersupportshapename[i]);
2143     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2144                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2145         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2146     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2147   }
2148   /////////////////////////////////////////////////////////////
2149   // Deallocating memory
2150   /////////////////////////////////////////////////////////////
2151   for(Int_t i=0; i< kshapesnumber; i++){
2152      for(Int_t j=0; j< kvertexnumber; j++)
2153            delete vertexposition[i][j];
2154        delete [] vertexposition[i];
2155   }
2156   /////////////////////////////////////////////////////////////
2157   return carbonfiberlowersupportlist;
2158 }
2159 ///////////////////////////////////////////////////////////////////////////////
2160 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2161                                                                  Double_t width, Double_t* thickness)const{
2162   /////////////////////////////////////////////////////////////
2163   // Method generating the Sensor Support   
2164   /////////////////////////////////////////////////////////////  
2165         const Int_t kvertexnumber = 6;
2166         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2167     TVector3* vertexposition[kvertexnumber];
2168         vertexposition[0] = new TVector3();     
2169         vertexposition[1] = new TVector3(0.0,length);   
2170         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2171         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2172         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2173         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2174         Double_t xvertexpoints[6], yvertexpoints[6];
2175         for(Int_t i=0; i<kvertexnumber; i++) 
2176                 xvertexpoints[i] = vertexposition[i]->X(), 
2177                 yvertexpoints[i] = vertexposition[i]->Y();
2178     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2179     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2180     ssdsensorsupportshape->DefineSection(1,0.5*width);
2181     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2182                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2183   /////////////////////////////////////////////////////////////
2184   // Deallocating memory
2185   /////////////////////////////////////////////////////////////
2186         for (Int_t i=0; i<kvertexnumber; i++)
2187                 delete vertexposition[i];
2188   /////////////////////////////////////////////////////////////
2189     return ssdsensorsupport;
2190 }
2191 ////////////////////////////////////////////////////////////////////////////////
2192 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2193   /////////////////////////////////////////////////////////////
2194   // Method generating the Cooling Tube Support
2195   /////////////////////////////////////////////////////////////
2196   if(nedges%2!=0) nedges--;     
2197   const Int_t kvertexnumber = nedges+5;
2198   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2199                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2200   Double_t angle = 90.+phi;
2201   Double_t psi = 90.-phi;
2202   ///////////////////////////////////////
2203   // Vertex Positioning for TGeoXTru
2204   ///////////////////////////////////////
2205   TVector3** vertexposition = new TVector3*[kvertexnumber];
2206   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2207                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2208   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2209                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2210   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2211                                                                    fgkCoolingTubeSupportRmax);
2212   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2213                                                                    fgkCoolingTubeSupportRmax);
2214   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2215                                                                     vertexposition[1]->Y());
2216   for(Int_t i=0; i<nedges; i++)
2217         vertexposition[i+5] = 
2218                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2219                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2220   ///////////////////////////////////////////////////////////////////////
2221   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2222   ///////////////////////////////////////////////////////////////////////
2223   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2224   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2225   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2226   for(Int_t i=0; i<kvertexnumber; i++){
2227         xvertexpoints[i] = vertexposition[i]->X();
2228         yvertexpoints[i] = vertexposition[i]->Y();
2229   } 
2230   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2231                                                                                         yvertexpoints);
2232   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2233   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2234   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2235                                                                           coolingtubesupportarcshape,
2236                                                                                   fSSDTubeHolderMedium);
2237   coolingtubesupportarc->SetLineColor(fColorG10);
2238   //////////////////////////////////////////////////////////////////////////
2239   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2240   //////////////////////////////////////////////////////////////////////////
2241   TGeoTubeSeg* coolingtubesupportsegshape = 
2242                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2243                                                                                         fgkCoolingTubeSupportRmax,
2244                                                                                         0.5*fgkCoolingTubeSupportWidth,
2245                                                                                         phi,360-phi);
2246   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2247                                                                                         coolingtubesupportsegshape,
2248                                                                                         fSSDTubeHolderMedium);
2249   coolingtubesupportseg->SetLineColor(fColorG10);
2250   //////////////////////////////////////////////////////////////////////////
2251   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2252   //////////////////////////////////////////////////////////////////////////
2253   Double_t* boxorigin = new Double_t[3];
2254   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2255   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2256   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2257                                                                                  0.5*fgkCoolingTubeSupportHeight,
2258                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2259   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2260                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2261   coolingtubesupportbox->SetLineColor(fColorG10);
2262   //////////////////////////////////////////////////////////////////////////
2263   // Cooling Tube for Cooling Tube Support 
2264   //////////////////////////////////////////////////////////////////////////
2265   TGeoXtru* coolingtubearcshape[2];
2266   coolingtubearcshape[0] = new TGeoXtru(2);     
2267   Double_t* xvert = new Double_t[nedges+2];
2268   Double_t* yvert = new Double_t[nedges+2];
2269   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2270   ////////////////////////////////////////
2271   // Positioning the vertices for TGeoXTru
2272   ////////////////////////////////////////
2273   xvert[0] = 0., yvert[0] = 0.;
2274   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2275   for(Int_t i=0; i< nedges; i++)
2276                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2277                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2278   ////////////////////////////////////////
2279   // Defining TGeoXTru PolyGone
2280   ////////////////////////////////////////
2281   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2282   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2283   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2284   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2285                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2286   TGeoVolume* coolingtubearc[2];
2287   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2288                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2289   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2290                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2291   coolingtubearc[0]->SetLineColor(fColorWater);
2292   coolingtubearc[1]->SetLineColor(fColorPhynox);
2293   ////////////////////////////////////////////
2294   // Defining TGeoTubeSeg Part of Cooling Tube
2295   ////////////////////////////////////////////
2296   TGeoTubeSeg* coolingtubesegshape[2];
2297   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2298                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2299   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2300                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2301   TGeoVolume* coolingtubeseg[2];
2302   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2303                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2304   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2305                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2306   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2307   coolingtubeseg[1]->SetLineColor(fColorWater);
2308   /////////////////////////////////////////////////////////////
2309   // Virtual Volume containing Cooling Tube Support  
2310   /////////////////////////////////////////////////////////////
2311   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2312   const Int_t kvirtualvertexnumber = 8;
2313   TVector3* virtualvertex[kvirtualvertexnumber];
2314    ////////////////////////////////////////
2315   // Positioning the vertices for TGeoXTru
2316   ////////////////////////////////////////
2317   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2318   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2319   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2320   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2321   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2322   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2323   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2324   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2325   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2326   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2327         xmothervertex[i] = virtualvertex[i]->X(),
2328         ymothervertex[i] = virtualvertex[i]->Y();
2329   ////////////////////////////////////////
2330   // Defining TGeoXTru PolyGone
2331   ////////////////////////////////////////
2332   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2333                                                                                                                                          ymothervertex);
2334   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2335   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2336   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2337                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2338   ////////////////////////////////////////
2339   // Positioning Volumes in Virtual Volume
2340   ////////////////////////////////////////
2341   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2342   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2343   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2344   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2345   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2346   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2347   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2348   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2349   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2350   /////////////////////////////////////////////////////////////
2351   // Deallocating memory
2352   /////////////////////////////////////////////////////////////
2353   delete [] vertexposition;
2354   delete xvertexpoints;
2355   delete yvertexpoints;
2356   delete xvert;
2357   delete yvert;
2358   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2359         delete virtualvertex[i];
2360   /////////////////////////////////////////////////////////////
2361         return virtualcoolingtubesupport;
2362 }
2363 /////////////////////////////////////////////////////////////////////////////////
2364 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2365   /////////////////////////////////////////////////////////////
2366   // Method generating List containing SSD Hybrid Components   
2367   /////////////////////////////////////////////////////////////
2368   TList* ssdhybridlist = new TList();
2369   const Int_t kssdstiffenernumber = 2;
2370   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2371                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2372                                                                   -    fgkSSDStiffenerWidth;
2373   Double_t ssdchipcablesradius[kssdstiffenernumber];
2374   for(Int_t i=0; i<kssdstiffenernumber; i++)
2375           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2376                                -  fgkSSDChipCablesHeight[0]
2377                                -  fgkSSDChipCablesHeight[1]);
2378   /////////////////////////////////////////////////////////////
2379   // Mother Volumes Containers 
2380   /////////////////////////////////////////////////////////////
2381   const Int_t kmothernumber = 2;
2382   const Int_t kmothervertexnumber = 12;
2383   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2384   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2385   ///////////////////////
2386   // Setting the vertices 
2387   ///////////////////////
2388   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2389   xmothervertex[0][1]  = xmothervertex[0][0]; 
2390   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2391   xmothervertex[0][3]  = xmothervertex[0][2];
2392   xmothervertex[0][4]  = xmothervertex[0][0];
2393   xmothervertex[0][5]  = xmothervertex[0][4];
2394   xmothervertex[0][6]  = -xmothervertex[0][0];
2395   xmothervertex[0][7]  = xmothervertex[0][6];
2396   xmothervertex[0][8]  = -xmothervertex[0][2];
2397   xmothervertex[0][9]  = xmothervertex[0][8];
2398   xmothervertex[0][10] = xmothervertex[0][7];
2399   xmothervertex[0][11] = xmothervertex[0][10];
2400   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2401   for(Int_t i = 0; i<kmothernumber; i++){
2402       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2403                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2404       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2405       ymothervertex[i][2]  = ymothervertex[i][1];
2406       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2407       ymothervertex[i][4]  = ymothervertex[i][3];
2408       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2409       ymothervertex[i][6]  = ymothervertex[i][5];
2410       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2411       ymothervertex[i][8]  = ymothervertex[i][7];
2412       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2413       ymothervertex[i][10] = ymothervertex[i][9];
2414       ymothervertex[i][11] = ymothervertex[i][0];
2415   }
2416   TGeoXtru* ssdhybridmothershape[kmothernumber];
2417 //  TGeoVolume* ssdhybridmother[kmothernumber];
2418   TGeoVolumeAssembly* ssdhybridmother[kmothernumber];
2419   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2420   for(Int_t i=0; i<kmothernumber; i++){
2421       ssdhybridmothershape[i] = new TGeoXtru(2);
2422       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2423                                           ymothervertex[i]);
2424       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2425                                                -fgkSSDChipCablesHeight[i+2]);
2426       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2427 //      ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2428 //                                          fSSDAir);
2429       ssdhybridmother[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2430    }   
2431   /////////////////////////////////////////////////////////////
2432   // SSD Stiffener   
2433   /////////////////////////////////////////////////////////////
2434   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2435                                              0.5*fgkSSDStiffenerLength,
2436                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2437                                              0.5*fgkSSDStiffenerHeight);
2438   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2439                                             fSSDStiffenerMedium);  
2440   ssdstiffener->SetLineColor(fColorStiffener); 
2441   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2442   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2443       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2444   /////////////////////////////////////////////////////////////
2445   // SSD Chip System    
2446   /////////////////////////////////////////////////////////////
2447   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2448   Double_t ssdchipseparation = fgkSSDSensorLength
2449                              - 2.*fgkSSDModuleStiffenerPosition[1]
2450                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2451                              - 0.5*fgkSSDChipWidth);
2452   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2453                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2454   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2455                                       - 0.5*ssdchipsystemlength,
2456                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2457                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2458 ////////////////////////////
2459 // Capacitor 0603-2200 nF
2460 ///////////////////////////
2461   const Int_t knapacitor0603number = 5;
2462   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2463                                                                                          0.5*fgkSSDCapacitor0603Length,
2464                                                                                          0.5*(fgkSSDCapacitor0603Width),
2465                                                                                          0.5*fgkSSDCapacitor0603Height);
2466   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2467                                              fSSDStiffener0603CapacitorMedium); 
2468   capacitor0603->SetLineColor(fColorAl);
2469   for(Int_t i=0; i<kmothernumber; i++){
2470       for(Int_t j=0; j<kssdstiffenernumber; j++){
2471             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2472             for(Int_t k=1; k<knapacitor0603number+1; k++){
2473                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2474                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2475                                            j*ssdstiffenerseparation
2476                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2477                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2478                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2479             }
2480       } 
2481       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2482       ssdhybridlist->Add(ssdhybridmother[i]);
2483   }    
2484 /////////////////////////////////////////////////////////////
2485 // Mother Volume Containing Capacitor Part 
2486 /////////////////////////////////////////////////////////////
2487   const Int_t kcapacitormothernumber = 8;
2488   Double_t xcapacitorvertex[kcapacitormothernumber];
2489   Double_t ycapacitorvertex[kcapacitormothernumber];  
2490   ///////////////////////
2491   // Setting the vertices 
2492   ///////////////////////
2493   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2494   xcapacitorvertex[1] = xcapacitorvertex[0];   
2495   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2496   xcapacitorvertex[3] = xcapacitorvertex[2];   
2497   xcapacitorvertex[4] = xcapacitorvertex[0];   
2498   xcapacitorvertex[5] = xcapacitorvertex[0];   
2499   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2500   xcapacitorvertex[7] = xcapacitorvertex[6];   
2501   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2502   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2503   ycapacitorvertex[2] = ycapacitorvertex[1];   
2504   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2505   ycapacitorvertex[4] = ycapacitorvertex[3];   
2506   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2507   ycapacitorvertex[6] = ycapacitorvertex[5];   
2508   ycapacitorvertex[7] = ycapacitorvertex[0];   
2509   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2510   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2511                                               ycapacitorvertex);
2512   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2513   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2514 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2515 //                                          fSSDAir);
2516   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2517 ////////////////////////////
2518 // Connector 
2519 ///////////////////////////
2520   const Int_t kssdconnectornumber = 2;
2521   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2522   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2523   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2524                                    +  fgkSSDConnectorAlHeight};  
2525   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2526   TGeoVolume* ssdconnector[kssdconnectornumber];
2527   for(Int_t i=0; i<kssdconnectornumber; i++){
2528       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2529                                           0.5*fgkSSDConnectorWidth,
2530                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2531                            +              i*fgkSSDConnectorNiHeight),
2532                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2533       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2534                                        i==0 ? fSSDAlTraceFlexMedium 
2535                                             : fSSDStiffenerConnectorMedium);      
2536       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2537   }
2538   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2539   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2540                        +  fgkSSDConnectorPosition[0]
2541                        -  fgkSSDConnectorSeparation
2542                        -  1.5*fgkSSDConnectorLength,
2543                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2544                        -  fgkSSDConnectorPosition[1]
2545                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2546   ssdconnectortrans[1] = new TGeoTranslation(
2547                        -  ssdstiffenershape->GetDX()
2548                        +  fgkSSDConnectorPosition[0]
2549                        -  0.5*fgkSSDConnectorLength,
2550                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2551                        -  fgkSSDConnectorPosition[1]
2552                        -  ssdconnectorshape[0]->GetDY(),0.0);
2553   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2554                        -  fgkSSDConnectorPosition[0]
2555                        +  fgkSSDConnectorSeparation
2556                        +  1.5*fgkSSDConnectorLength,
2557                           -(ssdstiffenershape->GetDY()
2558                        -  fgkSSDConnectorPosition[1]
2559                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2560   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2561                        -  fgkSSDConnectorPosition[0]
2562                        +  0.5*fgkSSDConnectorLength,
2563                           -(ssdstiffenershape->GetDY()
2564                        -  fgkSSDConnectorPosition[1]
2565                        -  ssdconnectorshape[0]->GetDY()),0.0);
2566   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2567       for(Int_t j=0; j<kssdconnectornumber; j++)
2568             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2569 ////////////////////////////
2570 // Capacitor 1812-330 nF
2571 /////////////////////////// 
2572   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2573   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2574                                                                                          0.5*fgkSSDCapacitor1812Length,
2575                                                                                          0.5*fgkSSDCapacitor1812Width,
2576                                                                                          0.5*fgkSSDCapacitor1812Height,
2577             ssdcapacitor1812origin);
2578   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2579                                              fSSDStiffener1812CapacitorMedium); 
2580   capacitor1812->SetLineColor(fColorAl);
2581   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2582                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2583                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2584   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2585 ////////////////////////////
2586 //Hybrid Wire
2587 ////////////////////////////
2588   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2589                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2590                                  - fgkSSDConnectorSeparation;
2591   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2592                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2593   Double_t ssdwireradius = TMath::Sqrt(TMath::Power(wirex,2.)
2594                                          + TMath::Power(wirey,2));
2595   Double_t wireangle = TMath::ATan(wirex/wirey);
2596   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2597                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2598   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2599                                              fSSDStiffenerHybridWireMedium); 
2600   hybridwire->SetLineColor(fColorPhynox);
2601   TGeoCombiTrans* hybridwirecombitrans[2];
2602   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2603                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2604                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2605                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2606                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2607                                    ssdstiffenershape->GetDZ()
2608                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2609                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2610   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2611                             0.0,
2612                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2613                             0.0,        
2614                             new TGeoRotation("HybridWireRot2",
2615                           - wireangle*TMath::RadToDeg(),0.,0.));
2616   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2617   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2618   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2619   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2620   ssdhybridlist->Add(ssdhybridcapacitormother);
2621   /////////////////////////////////////////////////////////////
2622   // Deallocating memory
2623   /////////////////////////////////////////////////////////////
2624   delete hybridwirecombitrans[0];
2625   delete hybridwirecombitrans[1];
2626   delete ssdchipsystemlist;
2627   return ssdhybridlist;
2628   /////////////////////////////////////////////////////////////
2629 }
2630 ///////////////////////////////////////////////////////////////////////////////
2631 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2632   /////////////////////////////////////////////////////////////
2633   // SSD Cooling Block System
2634   /////////////////////////////////////////////////////////////
2635   // SSD Cooling Block and Cooling Tube Transformations
2636   /////////////////////////////////////////////////////////////
2637   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2638   localcoolingblockrot->SetAngles(0.,90.,0.);
2639   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2640   TVector3* coolingblocktransvector;
2641   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2642                                                                 + fgkSSDCoolingBlockLength,
2643                                                                   fgkSSDSensorLength
2644                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2645                                                                 - fgkSSDCoolingBlockWidth);
2646   const Int_t kcoolingblocktransnumber = 2;
2647   const Int_t kcoolingblocknumber = 4;
2648   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2649   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2650   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2651   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2652   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2653   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2654                                         0.5*fgkSSDCoolingBlockWidth,
2655                                         fgkSSDCoolingBlockHoleCenter);
2656   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2657   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2658   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2659     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2660       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2661                                              j*coolingblocktransvector->Y(),
2662                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2663                                                     + fgkCoolingTubeRmax));
2664       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2665       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2666     }
2667   }
2668   /////////////////////////////////////////////////////////////
2669   // Virtual Volume containing CoolingBlock System   
2670   /////////////////////////////////////////////////////////////
2671   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2672   const Int_t kmothervertexnumber = 16;  
2673   Double_t xmothervertex[kmothervertexnumber];
2674   Double_t ymothervertex[kmothervertexnumber];
2675   ///////////////////////
2676   // Setting the vertices 
2677   ///////////////////////fgkCoolingTubeSupportRmax
2678   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2679   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2680                                    + fgkSSDCoolingBlockWidth;
2681   xmothervertex[2] = coolingblocktransvector->X()
2682                                    + fgkSSDCoolingBlockLength
2683                                    + 4*coolingtubedistance;
2684   ymothervertex[2] = ymothervertex[1];
2685   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2686   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2687   ymothervertex[4] = ymothervertex[0];
2688   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2689   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2690   ymothervertex[6] = ymothervertex[5]; 
2691   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2692                                    - fgkSSDCoolingBlockWidth; 
2693   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2694   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2695                                    - coolingtubedistance;
2696   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2697   ymothervertex[10] = ymothervertex[9];
2698   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2699   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2700   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2701   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2702   ymothervertex[14] = ymothervertex[13];
2703   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2704   //////////////////////////////////////////////////////////
2705   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2706                                                                         xmothervertex,ymothervertex);
2707   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2708                                                                                            + fgkCoolingTubeRmax));
2709   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2710                                                                                            + fgkCoolingTubeRmax));
2711   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2712 //  TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2713 //                                                        coolingsystemothershape,fSSDAir);
2714   /////////////////////////////////////////////////////////////
2715   // SSD Cooling Tube Part 
2716   /////////////////////////////////////////////////////////////
2717   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2718   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2719                                                                                  0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance)); 
2720   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2721                                                                          0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance));
2722   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2723   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2724                                                                         fSSDCoolingTubePhynox);
2725   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2726                                                                         fSSDCoolingTubeWater);
2727   coolingtube[0]->SetLineColor(fColorPhynox);
2728   coolingtube[1]->SetLineColor(fColorWater);
2729   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2730   /////////////////////////////////////////////////////////////
2731   // Adding Cooling block to mother volume
2732   /////////////////////////////////////////////////////////////
2733    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2734         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2735         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2736         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2737   }
2738   /////////////////////////////////////////////////////////////
2739   // Deallocating memory
2740   /////////////////////////////////////////////////////////////
2741         delete coolingblocktransvector;
2742         delete localcoolingblockrot;
2743         delete localcoolingtubetrans;
2744         delete localcoolingtuberot;
2745   /////////////////////////////////////////////////////////////
2746   // Checking overlaps  
2747   /////////////////////////////////////////////////////////////
2748         //coolingsystemother->CheckOverlaps(0.01);
2749   /////////////////////////////////////////////////////////////
2750         return coolingsystemother;
2751 }
2752 /////////////////////////////////////////////////////////////////////////////////
2753 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2754   /////////////////////////////////////////////////////////////
2755   // SSD Flex
2756   /////////////////////////////////////////////////////////////
2757   const Int_t kssdflexlayernumber = 2;
2758   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2759   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2760   const Int_t kmothervertexnumber = 17; 
2761   Double_t xmothervertex[kmothervertexnumber];
2762   Double_t ymothervertex[kmothervertexnumber];
2763   /////////////////////////////////////////////
2764   // Auxiliary variables for vertex positioning
2765   /////////////////////////////////////////////
2766   const Int_t kssdflexboxnumber = 5;
2767   Double_t ssdflexboxlength[kssdflexboxnumber];
2768   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2769                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2770                                           *     fgkSSDChipSeparationLength
2771                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2772                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2773   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2774   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2775                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2776   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2777   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2778                                           -     ssdflexboxlength[1];
2779   Double_t ssdflexboxwidth[kssdflexboxnumber];
2780   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2781   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2782   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2783   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2784   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2785   ///////////////////////
2786   // Setting the vertices 
2787   ///////////////////////
2788   xmothervertex[0]  = 0.0;
2789   xmothervertex[1]  = xmothervertex[0];
2790   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2791   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2792                                         + ssdflexboxlength[4];
2793   xmothervertex[4]  = xmothervertex[3];
2794   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2795   xmothervertex[6]  = xmothervertex[5];
2796   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2797   xmothervertex[8]  = xmothervertex[7];
2798   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2799   xmothervertex[10] = xmothervertex[9]; 
2800   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2801   xmothervertex[12] = xmothervertex[11];
2802   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2803   xmothervertex[14] = xmothervertex[13];
2804   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2805   xmothervertex[16] = xmothervertex[15];
2806   ymothervertex[0]  = 0.0;
2807   ymothervertex[1]  = fgkSSDFlexWidth[1];
2808   ymothervertex[2]  = fgkSSDFlexWidth[0];
2809   ymothervertex[3]  = ymothervertex[2];
2810   ymothervertex[4]  = ymothervertex[0];
2811   ymothervertex[5]  = ymothervertex[4];
2812   ymothervertex[6]  = ssdflexboxwidth[2];
2813   ymothervertex[7]  = ymothervertex[6];
2814   ymothervertex[8]  = ymothervertex[0];
2815   ymothervertex[9]  = ymothervertex[8];
2816   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2817   ymothervertex[11] = ymothervertex[10];
2818   ymothervertex[12] = ymothervertex[0];
2819   ymothervertex[13] = ymothervertex[12];
2820   ymothervertex[14] = ymothervertex[7];
2821   ymothervertex[15] = ymothervertex[14];
2822   ymothervertex[16] = ymothervertex[0];
2823   /////////////////////////////////////////////////////////////
2824   // First Mother Volume containing SSDFlex
2825   /////////////////////////////////////////////////////////////
2826   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2827   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2828                                                                     ymothervertex);
2829   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2830   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2831   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2832 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2833 //                                                                                       fSSDAir);
2834   /////////////////////////////////////////////////////////////
2835   // SSDFlex Layer Shapes
2836   /////////////////////////////////////////////////////////////
2837   for(Int_t i=0; i<kssdflexlayernumber; i++){
2838         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2839                                                                    ymothervertex);
2840     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2841         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2842   }
2843   /////////////////////////////////////
2844   // Setting Layers into Mother Volume
2845   /////////////////////////////////////
2846   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2847   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2848                                                                                                  fSSDKaptonFlexMedium};
2849   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2850                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2851   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2852   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2853   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2854         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2855                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2856                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2857         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2858     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2859                                          +                                         fgkSSDFlexHeight[1])); 
2860     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2861   }
2862   return ssdflexmother;
2863 }
2864 /////////////////////////////////////////////////////////////////////////////////
2865 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2866   /////////////////////////////////////////////////////////////
2867   // Method generating SSD End Flex   
2868   /////////////////////////////////////////
2869   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2870                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2871   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2872                                                 * TMath::DegToRad()*ssdflexradiusmax
2873                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2874                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
2875   const Int_t knedges = 20;  
2876   const Int_t karcnumber = 2;
2877   TVector3* vertexposition[karcnumber*(knedges+1)];
2878   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2879   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2880   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2881   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2882                                                                                  - 90.0*TMath::DegToRad()};
2883   TVector3* referencetrans[karcnumber];
2884   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2885                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2886                                                                    radius[0]);
2887   referencetrans[1] = new TVector3(referencetrans[0]->X()
2888                                         +              fgkSSDFlexLength[2],
2889      -              fgkSSDStiffenerHeight);
2890 for(Int_t i=0; i<karcnumber; i++){
2891         for(Int_t j=0; j<knedges+1; j++){
2892                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2893                                                                                                radius[i]*SinD(angle[i]));
2894                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2895         }       
2896   }
2897   ///////////////////////
2898   // Setting the vertices 
2899   ///////////////////////
2900   const Int_t kendflexlayernumber = 4;
2901   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2902   TVector3** vertex[kendflexlayernumber];
2903   for(Int_t i=0; i<kendflexlayernumber; i++) 
2904                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2905   TVector3* transvector[kendflexlayernumber+1];
2906   TVector3* deltatransvector = new TVector3();  
2907   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2908   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2909                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2910   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2911         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2912                                         *                 CosD(fgkSSDFlexAngle),
2913                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2914                                         *         SinD(fgkSSDFlexAngle),0.0);   
2915         *transvector[i] = *transvector[i-1]+*deltatransvector;
2916   }
2917   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2918   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2919   for(Int_t i=0; i<karcnumber; i++){
2920         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2921                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2922                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2923                                               /radius[i];
2924         }
2925   }
2926   for(Int_t i=0; i<kendflexlayernumber; i++){
2927         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2928         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2929         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2930                 if(j<(knedges+1)){
2931                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2932                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2933                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2934                         *vertex[i][j+2] += *referencetrans[0];
2935                         vertex[i][4*(knedges+1)-j+1] = 
2936                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2937                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2938                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2939                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2940                 }
2941                 else{
2942                 
2943                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2944                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2945                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2946                         *vertex[i][j+2] += *referencetrans[1];
2947                         vertex[i][4*(knedges+1)-j+1] = 
2948                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2949                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2950                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2951                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2952            }
2953         }
2954   }
2955   /////////////////////////////////////////////////////////////
2956   // First Mother Volume containing SSDEndFlex
2957   /////////////////////////////////////////////////////////////
2958   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2959   Double_t xmothervertex[kendflexvertexnumber];
2960   Double_t ymothervertex[kendflexvertexnumber];
2961   xmothervertex[0] = vertex[0][0]->X(); 
2962   ymothervertex[0] = vertex[0][0]->Y();
2963   for(Int_t i=1; i<kendflexvertexnumber; i++){
2964         if(i<2*(knedges+1)+2){
2965                 xmothervertex[i] = vertex[3][i]->X();
2966                 ymothervertex[i] = vertex[3][i]->Y();
2967         }
2968         else{
2969                 xmothervertex[i] = vertex[0][i]->X();
2970                 ymothervertex[i] = vertex[0][i]->Y();
2971         }
2972   }
2973   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2974                                                                            xmothervertex,ymothervertex);
2975   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2976   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2977   TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2978                                                                  ssdendflexmothershape,fSSDAir);        
2979   //////////////////////////////////////
2980   // End Flex TGeoXtru Layer Definition 
2981   //////////////////////////////////////
2982   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2983   TGeoVolume* ssdendflex[kendflexlayernumber];
2984   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2985   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2986   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2987   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2988   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2989                                                                                                         fSSDKaptonFlexMedium};
2990   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2991                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2992   for(Int_t i=0; i<kendflexlayernumber; i++){
2993         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2994                 xvertex[i][j] = vertex[i][j]->X();
2995                 yvertex[i][j] = vertex[i][j]->Y();
2996         }
2997   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2998   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2999   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
3000   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
3001                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
3002   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
3003   ssdendflexmother->AddNode(ssdendflex[i],1);
3004   }
3005   /////////////////////////////////////////////////////////////
3006   // Deallocating memory
3007   /////////////////////////////////////////////////////////////
3008   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
3009   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
3010   for(Int_t i=0; i<kendflexlayernumber; i++){
3011         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
3012         delete [] vertex[i];
3013   }
3014   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
3015   delete deltatransvector;
3016   /////////////////////////////////////////////////////////////
3017   //ssdendflexmother->CheckOverlaps(0.01);
3018   return ssdendflexmother;
3019 }
3020 ///////////////////////////////////////////////////////////////////////////////
3021 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3022   /////////////////////////////////////////////////////////////
3023   // Method generating the Mounting Block
3024   /////////////////////////////////////////////////////////////  
3025   const Int_t kvertexnumber = 8;
3026   Double_t xvertex[kvertexnumber];
3027   Double_t yvertex[kvertexnumber];
3028   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3029   xvertex[1] = xvertex[0];
3030   xvertex[2] = -xvertex[0];
3031   xvertex[3] = xvertex[2];
3032   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3033                          -                                 fgkSSDMountingBlockLength[2]);
3034   xvertex[5] = xvertex[4];
3035   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3036                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3037                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3038   xvertex[7] = xvertex[6];
3039   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3040                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3041                          -  fgkSSDModuleVerticalDisalignment;
3042   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3043   yvertex[2] = yvertex[1]; 
3044   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3045   yvertex[4] = yvertex[3];
3046   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3047                          - fgkSSDMountingBlockHeight[0];
3048   yvertex[6] = yvertex[5];
3049   yvertex[7] = yvertex[0];
3050   ///////////////////////////////////////////////////////////////////////
3051   // TGeoXTru Volume definition for Mounting Block Part
3052   ///////////////////////////////////////////////////////////////////////
3053   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3054   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3055   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3056   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3057   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3058                                                                           ssdmountingblockshape,
3059                                                                                   fSSDMountingBlockMedium);
3060   ssdmountingblock->SetLineColor(fColorG10);
3061   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3062   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3063   TGeoRotation* mountingblockrot = new TGeoRotation();
3064   mountingblockrot->SetAngles(90.,180.,-90.);
3065   mountingblockcombitrans->SetRotation(*mountingblockrot);
3066   /////////////////////////////////////////////////////////////
3067   // Generating the Mounting Block Screw Vertices 
3068   /////////////////////////////////////////////////////////////  
3069   const Int_t kscrewvertexnumber = 15;
3070   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3071                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3072                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3073                                  * TMath::RadToDeg();
3074   Double_t phi0 = 90.+alpha;
3075   Double_t phi = 270.-2*alpha;
3076   Double_t deltaphi = phi/kscrewvertexnumber;   
3077   TVector3* screwvertex[kscrewvertexnumber+1];
3078   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3079         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3080                                    *CosD(phi0+i*deltaphi),
3081                                    fgkSSDMountingBlockScrewHoleRadius[0]
3082                                    *SinD(phi0+i*deltaphi));
3083   Double_t xscrewvertex[kscrewvertexnumber+6];
3084   Double_t yscrewvertex[kscrewvertexnumber+6];
3085   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3086   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3087                                   -               fgkSSDMountingBlockScrewHoleEdge);
3088   xscrewvertex[1] = xscrewvertex[0];
3089   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3090   xscrewvertex[2] = screwvertex[0]->X();
3091   yscrewvertex[2] = yscrewvertex[1];
3092   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3093         xscrewvertex[i+3] = screwvertex[i]->X();        
3094         yscrewvertex[i+3] = screwvertex[i]->Y();        
3095   } 
3096   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3097   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3098   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3099   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3100   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3101   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3102   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3103   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3104                                                         +                                  fgkSSDMountingBlockHeight[2]);
3105   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3106                                                                                 ssdmountingblockscrewshape,
3107                                                                                             fSSDMountingBlockMedium);
3108   ssdmountingblockscrew->SetLineColor(fColorG10);
3109   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3110   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3111   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3112                                                                         -                                yscrewvertex[1],
3113                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3114                                                                         -                                fgkSSDMountingBlockHeight[2]
3115                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3116                                                                         +                                fgkSSDMountingBlockHeight[2]
3117                                                                         -                                yvertex[0]));
3118   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3119                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3120                                                                                                                  yscrewvertex[1]
3121                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3122                                                                                                          +fgkSSDMountingBlockHeight[2]
3123                                                                                                          -yvertex[0]));
3124   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3125                                                                                                           yscrewvertex[1],
3126                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3127                                                                         +                                 fgkSSDMountingBlockHeight[2]
3128                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3129                                                                         +                                 fgkSSDMountingBlockHeight[2]
3130                                                                         -                                 yvertex[0]));
3131   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3132                                                                                                          yscrewvertex[1],
3133                                                                         -                                yscrewvertex[1]
3134                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3135                                                                         +                                fgkSSDMountingBlockHeight[2]
3136                                                                         -                                yvertex[0]));
3137   TGeoRotation* ssdmountingblockscrewrot[4];
3138   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3139         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3140     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3141     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3142   for(Int_t i=1; i<4; i++) 
3143         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3144   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3145   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3146   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3147   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3148                                                          +                                xvertex[0],yscrewvertex[1]
3149                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3150                                                          +                                fgkSSDMountingBlockHeight[2]
3151                                                          -                                yvertex[0]),0.);      
3152   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3153   for(Int_t i=0; i<4; i++){
3154         ssdmountingblockscrewmatrix[i] = 
3155                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3156         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3157   }
3158   ///////////////////////////////////////////////////////////////////////
3159   // TGeoXtru for Mother Volume 
3160   ///////////////////////////////////////////////////////////////////////
3161   const Int_t kvertexmothernumber = 12;
3162   Double_t xmothervertex[kvertexmothernumber];
3163   Double_t ymothervertex[kvertexmothernumber];
3164   for(Int_t i=0; i<6; i++){
3165         xmothervertex[i] = xvertex[i];
3166         ymothervertex[i] = yvertex[i];
3167   } 
3168   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3169   ymothervertex[6]  = ymothervertex[5];
3170   xmothervertex[7]  = xmothervertex[6];
3171   ymothervertex[7]  = ymothervertex[4];
3172   xmothervertex[8]  = xmothervertex[7]
3173                                         + 0.5*(fgkSSDMountingBlockLength[1]
3174                                         -          fgkSSDMountingBlockLength[2]);
3175   ymothervertex[8]  = ymothervertex[4];
3176   xmothervertex[9]  = xmothervertex[8];
3177   ymothervertex[9]  = ymothervertex[2];
3178   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3179   ymothervertex[10] = ymothervertex[1];
3180   xmothervertex[11] = xmothervertex[10];
3181   ymothervertex[11] = ymothervertex[0];  
3182   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3183   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3184   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3185   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3186   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3187                                                                           ssdmountingblockmothershape,
3188                                                                                   fSSDAir);
3189   /////////////////////////////////////////////////////////////
3190   // Placing the Volumes into Mother Volume 
3191   /////////////////////////////////////////////////////////////
3192   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3193   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3194   for(Int_t i=0; i<4; i++) 
3195         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3196                                                                         ssdmountingblockscrewmatrix[i]);
3197   /////////////////////////////////////////////////////////////
3198   // Deallocating memory
3199   /////////////////////////////////////////////////////////////
3200   delete mountingblockrot;
3201   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3202   delete ssdmountingblockglobalrot; 
3203   delete ssdmountingblockglobaltrans; 
3204   /////////////////////////////////////////////////////////////
3205   return ssdmountingblockmother;
3206 }
3207 ///////////////////////////////////////////////////////////////////////////////
3208  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3209   /////////////////////////////////////////////////////////////
3210   // Method generating the Mounting Block Clip 
3211   /////////////////////////////////////////////////////////////  
3212   const Int_t kmothervertexnumber = 10;
3213   Double_t xmothervertex[kmothervertexnumber];
3214   Double_t ymothervertex[kmothervertexnumber];
3215   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3216                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3217   xmothervertex[1] = xmothervertex[0];
3218   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3219                                    - fgkMountingBlockClibScrewRadius);
3220   xmothervertex[3] = xmothervertex[2]; 
3221   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3222   xmothervertex[5] = xmothervertex[4]; 
3223   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3224   xmothervertex[7] = xmothervertex[6]; 
3225   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3226   xmothervertex[9] = xmothervertex[8]; 
3227   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3228                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3229                                    - fgkSSDModuleVerticalDisalignment;
3230   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3231   ymothervertex[2] = ymothervertex[1];
3232   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3233                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3234                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3235   ymothervertex[4] = ymothervertex[3];
3236   ymothervertex[5] = ymothervertex[2];
3237   ymothervertex[6] = ymothervertex[5];
3238   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3239   ymothervertex[8] = ymothervertex[7];
3240   ymothervertex[9] = ymothervertex[0];
3241   ///////////////////////////////////////////////////////////////////////
3242   // TGeoXTru Volume definition for Mounting Block Clip Part
3243   ///////////////////////////////////////////////////////////////////////
3244   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3245   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3246   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3247   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3248   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3249                                                                           ssdmountingblockclipshape,fSSDAir);
3250   ssdmountingblockclip->SetLineColor(4);
3251   ///////////////////////////////////////////////////////////////////////
3252   // TGeoXTru Volume definition for Clip 
3253   ///////////////////////////////////////////////////////////////////////
3254   const Int_t kclipvertexnumber = 6;
3255   Double_t xclipvertex[kclipvertexnumber];
3256   Double_t yclipvertex[kclipvertexnumber];
3257   xclipvertex[0] = xmothervertex[0];
3258   xclipvertex[1] = xclipvertex[0];
3259   xclipvertex[2] = xmothervertex[6];
3260   xclipvertex[3] = xclipvertex[2];
3261   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3262   xclipvertex[5] = xclipvertex[4];
3263   yclipvertex[0] = ymothervertex[0];
3264   yclipvertex[1] = ymothervertex[1];
3265   yclipvertex[2] = yclipvertex[1];
3266   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3267   yclipvertex[4] = yclipvertex[3];
3268   yclipvertex[5] = yclipvertex[0];
3269   TGeoXtru* clipshape = new TGeoXtru(2);
3270   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3271   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3272   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3273                                                          +   fgkMountingBlockClibWidth);
3274   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3275   clip->SetLineColor(18);
3276   ///////////////////////////////////////////////////////////////////////
3277   // Ladder Support Piece  
3278   ///////////////////////////////////////////////////////////////////////
3279   const Int_t ksupportvertexnumber = 4;
3280   Double_t xsupportvertex[ksupportvertexnumber];
3281   Double_t ysupportvertex[ksupportvertexnumber];
3282   xsupportvertex[0] = xclipvertex[5];
3283   xsupportvertex[1] = xsupportvertex[0];
3284   xsupportvertex[2] = xmothervertex[9];
3285   xsupportvertex[3] = xsupportvertex[2];
3286   ysupportvertex[0] = yclipvertex[0];
3287   ysupportvertex[1] = yclipvertex[3];
3288   ysupportvertex[2] = ysupportvertex[1];
3289   ysupportvertex[3] = ysupportvertex[0];
3290   TGeoXtru* supportshape = new TGeoXtru(2);
3291   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3292   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3293   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3294   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3295   support->SetLineColor(9);
3296   ///////////////////////////////////////////////////////////////////////
3297   // TGeoXTru Volume definition for Screw   
3298   ///////////////////////////////////////////////////////////////////////
3299   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3300                                                 0.5*fgkMountingBlockClibScrewRadius};
3301   Int_t edgesnumber[2] = {50,6};
3302   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3303                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3304   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3305   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3306   clipscrew->SetLineColor(12);
3307   TGeoRotation* screwrot = new TGeoRotation();
3308   screwrot->SetAngles(0.,90.,0.);
3309   TGeoTranslation* screwtrans = new TGeoTranslation();
3310   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3311                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3312                                                          0.5*fgkSSDMountingBlockWidth+
3313                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3314   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3315   ///////////////////////////////////////////////////////////////////////
3316   // Placing the Volumes
3317   ///////////////////////////////////////////////////////////////////////
3318   ssdmountingblockclip->AddNode(clip,1);
3319   ssdmountingblockclip->AddNode(support,1);
3320   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3321   /////////////////////////////////////////////////////////////
3322   // Deallocating memory
3323   /////////////////////////////////////////////////////////////  
3324   delete screwtrans;
3325   delete screwrot;
3326   /////////////////////////////////////////////////////////////
3327   return ssdmountingblockclip;
3328 }
3329 ///////////////////////////////////////////////////////////////////////////////
3330 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3331   /////////////////////////////////////////////////////////////
3332   // Method generating the Cooling Tube 
3333   /////////////////////////////////////////////////////////////  
3334    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3335    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3336                                                                                                 new     TGeoTube*[2];
3337    // Ladder Cooling Tubes
3338    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3339                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3340                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth));
3341    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3342                                                                                  coolingtubeshape[0][0]->GetDz());
3343    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3344                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3345                                                   -                                       fgkSSDSensorOverlap));
3346    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3347                                                                                  coolingtubeshape[1][0]->GetDz());
3348    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3349                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]));
3350    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3351                                                                                  coolingtubeshape[2][0]->GetDz());
3352    // End Ladder Cooling Tubes  
3353    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3354    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3355    endladdercoolingtubeshape[i] = new   TGeoTube*[2];
3356    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3357                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3358                                                   -                     fgkendladdercoolingsupportdistance[0]-fgkSSDTolerance));
3359    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3360                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3361    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3362                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3363                                                   +                     fgkendladdercoolingsupportdistance[1]
3364                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3365    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3366                                                                         endladdercoolingtubeshape[1][0]->GetDz());
3367    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3368                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3369                                                   -                     fgkEndLadderMountingBlockPosition[0]
3370                                                   -                     fgkendladdercoolingsupportdistance[1]           
3371                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3372    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3373                                                                         endladdercoolingtubeshape[2][0]->GetDz());
3374    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3375                                                           0.50 * (fgkMountingBlockToSensorSupport
3376                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3377                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3378                                                         +                 fgkSSDSensorOverlap
3379                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3380                                                         -                 fgkendladdercoolingsupportdistance[2]
3381                                                         -                 fgkEndLadderMountingBlockPosition[1]
3382                                                         -                 fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3383    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3384                                                                         endladdercoolingtubeshape[3][0]->GetDz());
3385    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3386                                                           0.50 * (fgkendladdercoolingsupportdistance[2]-fgkSSDTolerance));
3387    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3388                                                                         endladdercoolingtubeshape[4][0]->GetDz());
3389    // Ladder Cooling Tubes
3390    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3391    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3392                                                                                          new TGeoVolume*[2];
3393    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3394                                                                           fSSDCoolingTubePhynox);
3395    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3396                                                                           fSSDCoolingTubeWater);
3397    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3398                                                                           fSSDCoolingTubePhynox);
3399    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3400                                                                           fSSDCoolingTubeWater);
3401    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3402                                                                           fSSDCoolingTubePhynox);
3403    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3404                                                                           fSSDCoolingTubeWater);
3405    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3406         coolingtube[i][0]->SetLineColor(fColorPhynox);
3407         coolingtube[i][1]->SetLineColor(fColorWater);
3408    }
3409    // End Ladder Cooling Tubes  
3410    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3411    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3412    endladdercoolingtube[i] = new TGeoVolume*[2];
3413    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3414                                                                 endladdercoolingtubeshape[0][0],
3415                                                                 fSSDCoolingTubePhynox);
3416    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3417                                                                 endladdercoolingtubeshape[0][1],
3418                                                                 fSSDCoolingTubeWater);
3419    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3420                                                                 endladdercoolingtubeshape[1][0],
3421                                                                 fSSDCoolingTubePhynox);
3422    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3423                                                                 endladdercoolingtubeshape[1][1],
3424                                                                 fSSDCoolingTubeWater);
3425    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3426                                                                 endladdercoolingtubeshape[2][0],
3427                                                                 fSSDCoolingTubePhynox);
3428    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3429                                                                 endladdercoolingtubeshape[2][1],
3430                                                                 fSSDCoolingTubeWater);
3431    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3432                                                                 endladdercoolingtubeshape[3][0],
3433                                                                 fSSDCoolingTubePhynox);
3434    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3435                                                                 endladdercoolingtubeshape[3][1],
3436                                                                 fSSDCoolingTubeWater);
3437    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3438                                                                 endladdercoolingtubeshape[4][0],
3439                                                                 fSSDCoolingTubePhynox);
3440    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3441                                                                 endladdercoolingtubeshape[4][1],
3442                                                                 fSSDCoolingTubeWater);
3443    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3444                 endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3445                 endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3446    }
3447   /////////////////////////////////////////////////////////////
3448   // Virtual Volume containing Cooling Tubes
3449   /////////////////////////////////////////////////////////////
3450   // Ladder Cooling Tubes
3451   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3452   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3453   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3454                                                                                         coolingtubeshape[i][0]->GetRmax(),
3455                                                                                         coolingtubeshape[i][0]->GetDz());
3456   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3457   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3458                                                                           fSSDAir);
3459   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3460                                                                           fSSDAir);
3461   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3462                                                                           fSSDAir);
3463   // End Ladder Cooling Tubes
3464   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3465   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3466   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3467                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3468                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3469   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3470   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3471                                                                           endladdervirtualcoolingtubeshape[0],
3472                                                                           fSSDAir);
3473   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3474                                                                           endladdervirtualcoolingtubeshape[1],
3475                                                                           fSSDAir);
3476   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3477                                                                           endladdervirtualcoolingtubeshape[2],
3478                                                                           fSSDAir);
3479   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3480                                                                           endladdervirtualcoolingtubeshape[3],
3481                                                                           fSSDAir);
3482   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3483                                                                           endladdervirtualcoolingtubeshape[4],
3484                                                                           fSSDAir);
3485   TList* coolingtubelist = new TList();
3486   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3487         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3488         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3489     coolingtubelist->Add(virtualcoolingtube[i]);
3490   }
3491         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3492         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3493     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3494         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3495         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3496     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3497         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3498         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3499     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3500         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3501         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3502     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3503         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3504         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3505     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3506   return coolingtubelist;
3507 }
3508 ///////////////////////////////////////////////////////////////////////////////
3509 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3510   /////////////////////////////////////////////////////////////
3511   // Method generating SSD Cooling Block    
3512   /////////////////////////////////////////////////////////////
3513   const Int_t kvertexnumber = 8;
3514   ///////////////////////////////////////
3515   // Vertex Positioning for TGeoXTru
3516   ///////////////////////////////////////
3517   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3518   vertexposition[0] = new TVector3(0.0,0.0);
3519   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3520   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3521                                           vertexposition[1]->Y());
3522   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3523                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3524   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3525   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3526                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3527   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3528                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3529                                         - fgkSSDCoolingBlockHoleLength[0]
3530                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3531                                           fgkSSDCoolingBlockHeight[0]
3532                                         - fgkSSDCoolingBlockHoleRadius[1],
3533                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3534   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3535                                         - fgkSSDCoolingBlockHoleLength[0]),
3536                                           vertexposition[6]->Y());
3537   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3538                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3539   Double_t phi = 180.-alpha;
3540   Double_t psi = 180.+2.*alpha;
3541   Double_t deltapsi = psi/nedges;
3542   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3543   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3544                                                   fgkSSDCoolingBlockHoleCenter);
3545   for(Int_t i=0; i<nedges+1; i++){
3546         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3547                                                                                                radius*SinD(phi+i*deltapsi));
3548    *vertexposition[kvertexnumber+i] += (*transvector);
3549   }
3550   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3551   for(Int_t i=0; i<kvertexnumber; i++)
3552     vertexposition[kvertexnumber+nedges+1+i] = 
3553                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3554   ///////////////////////////////////////////////////////////////////////
3555   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3556   ///////////////////////////////////////////////////////////////////////
3557   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3558   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3559   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3560   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3561         xvertexpoints[i] = vertexposition[i]->X();
3562         yvertexpoints[i] = vertexposition[i]->Y();
3563   } 
3564   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3565                                                                                         yvertexpoints);
3566   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3567   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3568   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3569                                                                           ssdcoolingblockshape,
3570                                                                                   fSSDAlCoolBlockMedium);
3571   ssdcoolingblock->SetLineColor(fColorAl);
3572   /////////////////////////////////////////////////////////////
3573   // Deallocating memory
3574   /////////////////////////////////////////////////////////////
3575   delete [] vertexposition;
3576   delete xvertexpoints;
3577   delete yvertexpoints;
3578   /////////////////////////////////////////////////////////////
3579   return ssdcoolingblock;
3580 }
3581 /////////////////////////////////////////////////////////////////////////////////
3582 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3583   ///////////////////////////////////////////////////////
3584   const Int_t kssdchipcablesnumber    = 2;
3585   const Int_t kssdchipcableslaynumber = 2;
3586   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3587   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3588   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3589   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3590                                                  -  fgkSSDChipCablesHeight[0]
3591                                                  -  fgkSSDChipCablesHeight[1]);
3592   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3593   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3594   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3595                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3596                                                           - ssdchipcablesradius[0]
3597                                                           - fgkSSDChipCablesWidth[1]
3598                                                           - fgkSSDChipCablesWidth[2]);
3599   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3600                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3601                                                           +      fgkSSDChipCablesHeight[1]
3602                                                           +      fgkSSDSensorHeight);
3603   ///////////////////////////////////////////////////////
3604   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3605   ///////////////////////////////////////////////////////
3606   TVector3** vertexposition[kssdchipcableslaynumber];
3607   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3608                                                                                                   new TVector3*[4*(nedges+1)+4];
3609   Double_t ratio[4];
3610   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3611   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3612                    /  ssdchipcablesradius[0]; 
3613   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3614                    /  ssdchipcablesradius[0];
3615   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3616                    +  fgkSSDChipCablesHeight[1])
3617                    /  ssdchipcablesradius[0];
3618   Double_t phi = 180.;
3619   Double_t deltaphi = 180./nedges;
3620   Double_t angle = 0.0;
3621   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3622   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3623   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3624         xvertexpoints[i] = new Double_t[kvertexnumber];
3625         yvertexpoints[i] = new Double_t[kvertexnumber];
3626   }  
3627   TVector3* vertex = new TVector3();
3628   TVector3* transvector[kssdchipcableslaynumber];
3629   transvector[0] = new TVector3(fgkSSDChipWidth,
3630                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3631   transvector[1] = new TVector3();
3632   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3633   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3634   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3635                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3636                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3637   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3638         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3639         transvector[1]->SetY(ssdchipcablesradius[0]
3640                                  +               fgkSSDChipCablesHeight[0]
3641                                  +               fgkSSDChipCablesHeight[1]);  
3642         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3643                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3644                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3645                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3646                                                          - i*fgkSSDChipCablesHeight[0]);
3647                 vertexposition[i][2*(nedges+1)+2] = 
3648                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3649                                 +                                fgkSSDChipCablesWidth[1]
3650                                 +                                fgkSSDChipCablesWidth[2],
3651                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3652                                 +                                fgkSSDChipCablesHeight[1]));
3653         vertexposition[i][2*(nedges+1)+3] = 
3654                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3655                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3656                                 -                                fgkSSDChipCablesHeight[i]);
3657             for(Int_t j=0; j<nedges+1; j++){            
3658                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3659                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3660                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3661                         vertexposition[0][(nedges+1)*i+j+2] = 
3662                                                 new TVector3(*vertex+*transvector[i]);
3663                         vertexposition[1][(nedges+1)*i+j+2] = 
3664                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3665                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3666                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3667                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3668                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3669                                                 new TVector3(vertex->X()*ratio[2*i+1]
3670                                                         +                        transvector[i]->X(),
3671                                                                                  vertex->Y()*ratio[2*i+1]
3672                                                         +                transvector[i]->Y());
3673                 }
3674         }
3675         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3676                 for(Int_t j=0; j<kvertexnumber; j++){   
3677                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3678                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3679                 }
3680                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3681                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3682                                                                                 xvertexpoints[i],yvertexpoints[i]);
3683                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3684                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3685                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3686                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3687                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3688                                                           (kssdchipcablesnumber*k+i)%2==0?
3689                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3690                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3691         }
3692         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3693                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3694   }
3695   /////////////////////////////////////////////////////////////
3696   // Mother Volume definition 
3697   /////////////////////////////////////////////////////////////
3698   Double_t ssdchipseparation = fgkSSDSensorLength
3699                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3700                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3701                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3702   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3703   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3704                                                           +fgkSSDChipCablesWidth[1]
3705                                                           +fgkSSDChipCablesWidth[2]);
3706   Double_t dy = fgkSSDChipCablesLength[1];
3707   Double_t dz = SSDChipCablesHeigth;
3708   new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3709   TGeoVolumeAssembly* ssdchipcablesmother = new TGeoVolumeAssembly("SSDChipCablesMother");
3710 //  TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3711 //                        ssdchipcablesmotherbox,fSSDAir);
3712   /////////////////////////////////////////////////////////////
3713   // Rotation and Translation Definition for positioning 
3714   /////////////////////////////////////////////////////////////
3715   TGeoRotation* ssdchipcablesrot[5];
3716   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3717   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3718   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3719   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3720   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3721   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3722                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3723   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3724   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3725   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3726   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3727   /////////////////////////////////////////////////////////////
3728   // Deallocating memory
3729   /////////////////////////////////////////////////////////////
3730   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3731         delete [] xvertexpoints[i];
3732         delete [] yvertexpoints[i];
3733   }
3734   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3735   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3736   delete vertex; 
3737   delete ssdchipcablesrot[0];
3738   delete ssdchipcablesrot[1];
3739   delete ssdchipcablesrot[3];
3740   /////////////////////////////////////////////////////////////
3741   return ssdchipcablesmother;
3742 }
3743 ///////////////////////////////////////////////////////////////////////////////
3744 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3745   /////////////////////////////////////////////////////////////
3746   // SSD Chip Assembly
3747   /////////////////////////////////////////////////////////////
3748   TGeoVolume* ssdchipassembly = GetSSDChips();
3749   TList* ssdchipsystemlist = new TList();
3750 //  const Int_t knedges = 20;
3751   const Int_t knedges = 5;
3752   const Int_t kchipsystemnumber = 2;
3753   /////////////////////////////////////////////////////////////
3754   // Mother Volume containing SSDChipSystem
3755   /////////////////////////////////////////////////////////////
3756   TGeoXtru* chipsystemothershape[kchipsystemnumber];
3757   for(Int_t i=0; i<kchipsystemnumber; i++) chipsystemothershape[i] = new TGeoXtru(2);
3758   const Int_t kmothervertexnumber = 12;  
3759   Double_t xmothervertex[kchipsystemnumber][kmothervertexnumber];
3760   Double_t ymothervertex[kchipsystemnumber][kmothervertexnumber];
3761   Double_t ssdchipcablesradius[kchipsystemnumber];
3762   Double_t ssdchipseparation = fgkSSDSensorLength
3763                              - 2.*fgkSSDModuleStiffenerPosition[1]
3764                              - 2.*(fgkSSDStiffenerWidth
3765                              - fgkSSDStiffenerToChipDist-0.5*fgkSSDChipWidth);
3766   for(Int_t i=0; i<kchipsystemnumber; i++)
3767         ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
3768                                                    -  fgkSSDChipCablesHeight[0]
3769                                                    -  fgkSSDChipCablesHeight[1]);
3770   ///////////////////////
3771   // Setting the vertices 
3772   ///////////////////////
3773   xmothervertex[0][0]  = -0.5*fgkSSDChipCablesLength[1];  
3774   xmothervertex[0][1]  = xmothervertex[0][0];  
3775   xmothervertex[0][2]  = (fgkSSDChipNumber-1)*(fgkSSDChipLength
3776                                            + fgkSSDChipSeparationLength)+0.5*fgkSSDChipCablesLength[1];  
3777   xmothervertex[0][3]  = xmothervertex[0][2];  
3778   xmothervertex[0][4]  = 0.5*fgkSSDChipCablesLength[1];  
3779   xmothervertex[0][5]  = xmothervertex[0][4];  
3780   xmothervertex[0][6]  = xmothervertex[0][2]-0.5*fgkSSDChipCablesLength[1];  
3781   xmothervertex[0][7]  = xmothervertex[0][6]; 
3782   xmothervertex[0][8]  = 0.0;  
3783   xmothervertex[0][9]  = xmothervertex[0][8];  
3784   xmothervertex[0][10] = xmothervertex[0][4];  
3785   xmothervertex[0][11] = xmothervertex[0][10];  
3786   for(Int_t i=0; i<kmothervertexnumber; i++) 
3787         xmothervertex[1][i] = xmothervertex[0][i]; 
3788   for(Int_t i=0; i<kchipsystemnumber; i++){
3789         ymothervertex[i][0]  = -0.5*fgkSSDChipWidth-ssdchipcablesradius[i]
3790                                                  - fgkSSDChipCablesWidth[1]-fgkSSDChipCablesWidth[2];
3791         ymothervertex[i][1]  = ssdchipseparation-ymothervertex[i][0];
3792         ymothervertex[i][2]  = ymothervertex[i][1];
3793         ymothervertex[i][3]  = ymothervertex[i][0];
3794         ymothervertex[i][4]  = ymothervertex[i][0];
3795         ymothervertex[i][5]  = 0.5*fgkSSDChipWidth;
3796         ymothervertex[i][6]  = ymothervertex[i][5];
3797         ymothervertex[i][7]  = ssdchipseparation-0.5*fgkSSDChipWidth;
3798         ymothervertex[i][8]  = ymothervertex[i][7];
3799         ymothervertex[i][9]  = ymothervertex[i][5];
3800         ymothervertex[i][10] = ymothervertex[i][5];
3801         ymothervertex[i][11] = ymothervertex[i][4];
3802   }
3803   //////////////////////////////////////////////////////////
3804 //  TGeoVolume* chipsystemother[kchipsystemnumber];
3805   TGeoVolumeAssembly* chipsystemother[kchipsystemnumber];
3806   const char* chipsytemothername[kchipsystemnumber] = 
3807                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3808   for(Int_t i=0; i<kchipsystemnumber; i++){
3809     chipsystemothershape[i]->DefinePolygon(kmothervertexnumber,
3810                                                                         xmothervertex[i],ymothervertex[i]);
3811     chipsystemothershape[i]->DefineSection(0,-fgkSSDChipCablesHeight[i+2]
3812                                                                                   -0.5*fgkSSDChipHeight);
3813     chipsystemothershape[i]->DefineSection(1,0.5*fgkSSDChipHeight);
3814 //    chipsystemother[i] = new TGeoVolume(chipsytemothername[i],
3815 //                                                        chipsystemothershape[i],fSSDAir);
3816     chipsystemother[i] = new TGeoVolumeAssembly(chipsytemothername[i]);
3817   }
3818   /////////////////////////////////////////////////////////////
3819   // SSD Chip Cables
3820   /////////////////////////////////////////////////////////////
3821   TGeoVolume* ssdchipcables[kchipsystemnumber];
3822   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3823   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3824   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3825   //////////////////
3826   for(Int_t i=0; i<kchipsystemnumber; i++){
3827                 ssdchipcables[i] = 
3828                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3829                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3830                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3831                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3832   }
3833   for(Int_t i=0; i<kchipsystemnumber; i++){
3834         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3835                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3836                 ssdchipcablesrot[i][j] = new TGeoRotation();
3837                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3838                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3839                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3840                                                   +                fgkSSDChipSeparationLength),
3841                                                                                         0.5*fgkSSDChipWidth,
3842                                                   -                                     0.5*fgkSSDChipHeight
3843                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3844                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3845                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3846                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3847         }
3848         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3849         ssdchipsystemlist->Add(chipsystemother[i]);     
3850   }
3851   /////////////////////////////////////////////////////////////
3852   // Deallocating memory
3853   /////////////////////////////////////////////////////////////
3854   for(Int_t i=0; i<kchipsystemnumber; i++){
3855         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3856                 delete ssdchipcablesrot[i][j];
3857                 delete ssdchipcablestrans[i][j];
3858         }
3859         delete ssdchipcablesrot[i];
3860         delete ssdchipcablestrans[i];
3861   }
3862   /////////////////////////////////////////////////////////////
3863   return ssdchipsystemlist;
3864 }
3865 ///////////////////////////////////////////////////////////////////////////////
3866 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3867   /////////////////////////////////////////////////////////////
3868   // SSD Chip Assembly Generation    
3869   /////////////////////////////////////////////////////////////
3870   const Int_t kssdchiprownumber = 2;
3871   TGeoBBox* ssdchipcompshape[2];
3872   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3873                                                                                 0.5*fgkSSDChipLength,
3874                                                                                 0.5*fgkSSDChipWidth,
3875                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3876   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3877                                                                                 0.5*fgkSSDChipLength,
3878                                                                                 0.5*fgkSSDChipWidth,
3879                                                                                 0.5*fgkSSDChipGlueHeight);
3880   TGeoVolume* ssdchipcomp[2];
3881   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3882   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3883                                                                   fSSDChipGlueMedium);
3884   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3885   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3886   TGeoTranslation* ssdchipcomptrans[2];
3887   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3888   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3889   /////////////////////////////////////////////////////////////
3890   // Virtual Volume containing SSDChip   
3891   /////////////////////////////////////////////////////////////
3892   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3893                                                                                                                  0.5*fgkSSDChipWidth,
3894                                                                                                                  0.5*fgkSSDChipHeight);
3895   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3896   /////////////////////////////////////////////////////////////
3897   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3898   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3899                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3900                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3901                                    -  0.5*fgkSSDChipWidth)};
3902   /////////////////////////////////////////////////////////////
3903   // Virtual Volume containing SSDChipAssembly   
3904   /////////////////////////////////////////////////////////////
3905   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3906   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3907   Double_t xmothervertex[kssdmothervertexnumber];
3908   Double_t ymothervertex[kssdmothervertexnumber];
3909   ///////////////////////
3910   // Setting the vertices 
3911   ///////////////////////
3912   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3913   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3914                                    - ymothervertex[0];
3915   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3916   ymothervertex[2] = ymothervertex[1];
3917   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3918   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3919   ymothervertex[4] = ymothervertex[0];
3920   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3921   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3922                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3923   ymothervertex[6] = ymothervertex[5];
3924   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3925                                    - fgkSSDChipWidth;
3926   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3927   ymothervertex[8] = ymothervertex[7];
3928   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3929   ymothervertex[9] = ymothervertex[6];
3930   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3931   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3932   //////////////////////////////////////////////////////////
3933   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3934                                                                         xmothervertex,ymothervertex);
3935   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3936   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3937 //  TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3938 //                                                        ssdchipmothershape,fSSDAir);
3939   TGeoVolumeAssembly* ssdchipmother = new TGeoVolumeAssembly("SSDChipContainer");
3940    /////////////////////////////////////////////////////////////
3941   for(Int_t i=0; i<kssdchiprownumber; i++)
3942     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3943                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3944                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3945   return ssdchipmother;
3946 }
3947 /////////////////////////////////////////////////////////////////////////////////
3948 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3949   /////////////////////////////////////////////////////////////
3950   // Method returning a List containing pointers to Ladder Cable Volumes    
3951   /////////////////////////////////////////////////////////////
3952   const Int_t kladdercablesegmentnumber = 2;
3953   /////////////////////////////////////////
3954   // LadderSegmentBBox Volume
3955   /////////////////////////////////////////
3956   TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber];
3957   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3958                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3959   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3960                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3961                                                                            0.5*fgkSSDFlexWidth[0],
3962                                                                            0.5*fgkSSDLadderCableWidth,
3963                                                                            0.5*fgkSSDFlexHeight[i]); 
3964   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3965                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3966   TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3967   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3968                         laddercablesegmentbbox[i] =
3969                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3970                                                                                  laddercablesegmentbboxshape[i],
3971                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3972             fSSDKaptonLadderCableMedium));
3973                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3974                                                                                                                    fColorPolyhamide);
3975   }
3976   TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber];                                                                                
3977   laddercablesegmentbboxtrans[0] = 
3978                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3979                                                                                            0.5*fgkSSDFlexWidth[0],
3980                                                                                            0.5*fgkSSDLadderCableWidth,
3981                                                                                            0.5*fgkSSDFlexHeight[0]);
3982   laddercablesegmentbboxtrans[1] = 
3983                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3984                                                                                            0.5*fgkSSDFlexWidth[0],
3985                                                                                            0.5*fgkSSDLadderCableWidth,
3986                                                                                            fgkSSDFlexHeight[0]
3987                                                                                            +0.5*fgkSSDFlexHeight[1]);
3988   TGeoVolume* laddercablesegmentbboxassembly = 
3989                                                    new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly"); 
3990   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3991                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3992                                                                                             laddercablesegmentbboxtrans[i]);
3993 /////////////////////////////////////////
3994 // LadderSegmentArb8 Volume
3995 /////////////////////////////////////////
3996   const Int_t kvertexnumber = 4;
3997   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3998   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3999                                                                                                   new TVector3*[kvertexnumber];
4000 //Shape Vertex Positioning
4001   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4002         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
4003         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
4004                                                                                                                   i*fgkSSDFlexHeight[0]);
4005         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
4006                                                                                    +                         fgkSSDFlexHeight[1]
4007                                                                                    +                      i*fgkSSDFlexHeight[0]);
4008         laddercablesegmentvertexposition[i][3] = 
4009                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
4010                                                                                 laddercablesegmentvertexposition[i][2]->Y());
4011   }
4012   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
4013                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
4014   char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
4015                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
4016   TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
4017   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
4018                                         GetArbShape(laddercablesegmentvertexposition[i],
4019                                                                 laddercablesegmentwidth[i],
4020                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
4021                                                                 laddercablesegmentarbshapename[i]);
4022   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
4023                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
4024   TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
4025   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4026                          laddercablesegmentarb[i] =
4027                                                    new TGeoVolume(laddercablesegmentarbname[i],
4028                                                                                   laddercablesegmentarbshape[i],
4029                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
4030             fSSDKaptonLadderCableMedium)); 
4031                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
4032                                                                                                                    fColorPolyhamide);
4033 }
4034   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
4035   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
4036                                                                                                  90.,90,-90.);   
4037   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
4038                                                                                                   0.,90.,0.);    
4039   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
4040                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
4041                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
4042                                                          + fgkSSDFlexWidth[0],0.,0.,
4043                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
4044                                                      *(*laddercablesegmentarbrot[0])));
4045   TGeoVolume* laddercablesegmentarbassembly = 
4046                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
4047   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
4048   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
4049                                                                                    laddercablesegmentarbcombitrans);
4050 /////////////////////////////////////////
4051 // End Ladder Cable Volume
4052 /////////////////////////////////////////
4053   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4054   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4055                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4056   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4057                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4058                                                                            0.5*ssdendladdercablelength,
4059                                                                            0.5*fgkSSDLadderCableWidth,
4060                                                                            0.5*fgkSSDFlexHeight[i]);
4061   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4062                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4063   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4064   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4065                         ladderendcablesegmentbbox[i] =
4066                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4067                                                                                  ladderendcablesegmentbboxshape[i],
4068                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4069             fSSDKaptonLadderCableMedium));
4070                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4071                                                                                                                    fColorPolyhamide);
4072   }
4073   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4074   ladderendcablesegmentbboxtrans[0] = 
4075                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4076                                                                                            0.5*ssdendladdercablelength,
4077                                                                                            0.5*fgkSSDLadderCableWidth,
4078                                                                                            0.5*fgkSSDFlexHeight[0]);
4079   ladderendcablesegmentbboxtrans[1] = 
4080                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4081                                                                                            0.5*ssdendladdercablelength,
4082                                                                                            0.5*fgkSSDLadderCableWidth,
4083                                                                                            fgkSSDFlexHeight[0]
4084                                                                                            +0.5*fgkSSDFlexHeight[1]);
4085   TGeoVolume* ladderendcablesegmentbboxassembly = 
4086                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4087   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4088                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4089                                                                                             ladderendcablesegmentbboxtrans[i]);
4090 /////////////////////////////////////////
4091   TList* laddercablesegmentlist = new TList();
4092   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4093   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4094   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4095   return laddercablesegmentlist;
4096   }
4097 /////////////////////////////////////////////////////////////////////////////////
4098 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4099   /////////////////////////////////////////////////////////////
4100   // Method generating Ladder Cable Volumes Assemblies    
4101   /////////////////////////////////////////////////////////////
4102   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4103   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4104   for(Int_t i=0; i<n; i++){
4105          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4106                                                         i*(fgkCarbonFiberJunctionWidth),
4107                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4108                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4109     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4110         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4111   }
4112   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4113                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4114                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4115                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4116   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4117   return laddercable;
4118 }
4119 /////////////////////////////////////////////////////////////////////////////////
4120 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4121   /////////////////////////////////////////////////////////////
4122   // Method generating Ladder Cable Volumes Assembly   
4123   /////////////////////////////////////////////////////////////
4124   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4125   char laddercabletransname[30];
4126   for(Int_t i=0; i<n; i++){ 
4127         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4128     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4129         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4130   }
4131   return laddercableassembly;
4132 }
4133 /////////////////////////////////////////////////////////////////////////////////
4134 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4135   /////////////////////////////////////////////////////////////
4136   // Method generating Ladder Cable List Assemblies  
4137   /////////////////////////////////////////////////////////////  
4138   const Int_t kladdercableassemblynumber = 2;
4139   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4140   TGeoVolume* ladderCable[kladdercableassemblynumber];
4141   char laddercableassemblyname[30];
4142   TList* laddercableassemblylist = new TList();
4143   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4144         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4145         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4146         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4147                                          new TGeoCombiTrans((n-1)
4148                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4149                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4150                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4151         laddercableassemblylist->Add(ladderCable[i]);
4152 }
4153   return laddercableassemblylist;
4154 }
4155 ///////////////////////////////////////////////////////////////////////////////
4156 void AliITSv11GeometrySSD::SetLadderSegment(){
4157   /////////////////////////////////////////////////////////////
4158   // Method Generating Ladder Segment Array
4159   /////////////////////////////////////////////////////////////
4160   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4161   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4162   if(!fCreateMaterials) CreateMaterials();
4163   if(!fTransformationMatrices) CreateTransformationMatrices();
4164   if(!fBasicObjects) CreateBasicObjects();
4165   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4166   // Placing Carbon Fiber Support       
4167         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4168                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4169                                                                                         fcarbonfibersupportmatrix[j]);  
4170                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4171                                                                                         fcarbonfibersupportmatrix[j]);
4172   }
4173   // Placing Carbon Fiber Junction
4174     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4175         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4176                                                                    fcarbonfiberjunctionmatrix[j]);
4177   // Placing Carbon Fiber Lower Support
4178         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4179                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4180                                                            fcarbonfiberlowersupportrans[j]);    
4181   // Placing SSD Sensor Support
4182     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4183         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4184                                                                      fssdsensorsupport[1][i],
4185                                                            j+1,fssdsensorsupportmatrix[j]);
4186   // Placing SSD Cooling Tube Support 
4187         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4188                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4189                                                                    fcoolingtubesupportmatrix[j]);
4190   // Placing SSD Cooling Tube  
4191         for(Int_t j=0; j<2; j++)
4192                 for(Int_t k=0; k<2; k++){
4193                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4194                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4195                 }
4196   // Placing SSD Hybrid
4197     switch(i){
4198         case 0: 
4199                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4200                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4201                 break;
4202     case 1:
4203                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4204                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4205                 break;
4206         }
4207         // Placing Cooling Block System
4208     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4209         // Placing SSD Flex
4210         for(Int_t j=0; j<fgkflexnumber; j++){
4211       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4212       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4213         }
4214    }
4215 }
4216 ///////////////////////////////////////////////////////////////////////////////
4217 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4218   /////////////////////////////////////////////////////////////
4219   // Method Generating End Ladder
4220   /////////////////////////////////////////////////////////////
4221   // End Ladder Carbon Fiber Junction 
4222   /////////////////////////////////////////////////////////////
4223   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4224   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4225   if(!fCreateMaterials) CreateMaterials();
4226   if(!fTransformationMatrices) CreateTransformationMatrices();
4227   if(!fBasicObjects) CreateBasicObjects();
4228   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4229         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4230                 fendladdersegment[i]->AddNode(j==2 ? 
4231                                                         fendladdercarbonfiberjunction[i][1] : 
4232                                                         fendladdercarbonfiberjunction[i][0],
4233                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4234   }
4235   /////////////////////////////////////////////////////////////
4236   // End Ladder Carbon Fiber Support 
4237   /////////////////////////////////////////////////////////////
4238   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4239       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4240                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4241                   fendladdercarbonfibermatrix[i][j]);   
4242           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4243                   fendladdercarbonfibermatrix[i][j]);   
4244       }
4245   /////////////////////////////////////////////////////////////
4246   // End Ladder Mounting Block
4247   /////////////////////////////////////////////////////////////
4248   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4249        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4250                                      fendladdermountingblockcombitrans[i]);
4251   /////////////////////////////////////////////////////////////
4252   // End Ladder Mounting Block Clip
4253   /////////////////////////////////////////////////////////////
4254   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4255         for(Int_t j=0; j<2; j++)
4256                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4257                                               fendladdermountingblockclipmatrix[i][j]);
4258   /////////////////////////////////////////////////////////////
4259   // End Ladder Lower Supports
4260   /////////////////////////////////////////////////////////////
4261   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4262                                 fendladderlowersupptrans[0]);
4263   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4264                                 fendladderlowersupptrans[1]);
4265   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4266                                 fendladderlowersupptrans[2]);
4267   /////////////////////////////////////////////////////////////
4268   // End Ladder Cooling Tube Support
4269   /////////////////////////////////////////////////////////////
4270   for(Int_t i=0; i<2; i++) 
4271         for(Int_t j=0; j<(i==0?4:2); j++)   
4272                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4273                                               fendladdercoolingtubesupportmatrix[i][j]);
4274   /////////////////////////////////////////////////////////////
4275   // End Ladder Cooling Tube Support
4276   /////////////////////////////////////////////////////////////
4277 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                          
4278 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                          
4279   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4280   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4281   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4282   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4283   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4284   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4285   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4286   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                            
4287 }
4288 ///////////////////////////////////////////////////////////////////////////////
4289 void AliITSv11GeometrySSD::SetLadder(){
4290   /////////////////////////////////////////////////////////////
4291   // Method Generating Ladder of Layer 5 and 6
4292   /////////////////////////////////////////////////////////////  
4293   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4294                                                                                                 fgkSSDLay6SensorsNumber};
4295   /////////////////////////////////////////////////////////////////////////////                                         
4296   /// Generating Ladder Mother Volume Containing Ladder 
4297   /////////////////////////////////////////////////////////////////////////////          
4298   TGeoXtru* laddershape[fgkladdernumber];       
4299   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4300   const Int_t kmothervertexnumber = 8;  
4301   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4302   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4303   ///////////////////////
4304   // Setting the vertices 
4305   ///////////////////////
4306   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4307                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4308   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4309   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
4310                                           -  fgkSSDModuleVerticalDisalignment;
4311   xmothervertex[0][1] = xmothervertex[0][0];
4312   ymothervertex[0][1] = 0.0;
4313   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4314                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4315   ymothervertex[0][2] = ymothervertex[0][1];
4316   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4317   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4318   xmothervertex[0][4] = -xmothervertex[0][3];
4319   ymothervertex[0][4] = ymothervertex[0][3];
4320   xmothervertex[0][5] = -xmothervertex[0][2];
4321   ymothervertex[0][5] = ymothervertex[0][2];
4322   xmothervertex[0][6] = -xmothervertex[0][1];
4323   ymothervertex[0][6] = ymothervertex[0][1];
4324   xmothervertex[0][7] = -xmothervertex[0][0];
4325   ymothervertex[0][7] = ymothervertex[0][0];
4326   for(Int_t i=0; i<kmothervertexnumber; i++){
4327         xmothervertex[1][i] = xmothervertex[0][i];
4328         ymothervertex[1][i] = ymothervertex[0][i];
4329   }
4330   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4331   for(Int_t i=0; i<fgkladdernumber; i++){
4332         laddershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
4333                                                                     ymothervertex[i]);
4334     laddershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4335     laddershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4336                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4337     fladder[i] = new TGeoVolume(laddername[i],laddershape[i],fSSDAir);
4338         fladder[i]->SetLineColor(4);
4339  }
4340 ///////////////////////////////////////////////////////////////////////////
4341  if(!fCreateMaterials) CreateMaterials();
4342  if(!fTransformationMatrices) CreateTransformationMatrices();
4343  if(!fBasicObjects) CreateBasicObjects();
4344  SetLadderSegment(); 
4345  SetEndLadderSegment();
4346   for(Int_t i=0; i<fgkladdernumber; i++){
4347         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4348         //////////////////////////                                              
4349         /// Placing Ladder Segment
4350         //////////////////////////              
4351                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4352                                                                      fladdersegment[i==0 ? 1 : 0],
4353                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4354         //////////////////////////                                              
4355         /// Placing SSD Sensor
4356         //////////////////////////              
4357         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4358                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4359                                                         fssdsensormatrix[i][j]);
4360         }
4361         ///////////////////////////////                                         
4362         /// Placing End Ladder Segment
4363         ///////////////////////////////         
4364     fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4365         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4366    }
4367 /////////////////////////////////////////////////////////////////////////////                                           
4368 /// Placing Ladder Cables
4369 /////////////////////////////////////////////////////////////////////////////           
4370   Int_t sidecablenumber[2][2];
4371   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4372   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4373   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4374   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4375   Double_t carbonfibertomoduleposition[3];
4376   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4377   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4378                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4379          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4380          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4381          -            fgkSSDSensorCenterSupportThickness[0]);
4382   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4383                                                                  +   0.5*fgkCoolingTubeSupportHeight
4384          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4385   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4386   Double_t ssdendladdercablelength[4];
4387   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4388                                                          + fgkSSDSensorLength
4389                                                          - fgkSSDModuleStiffenerPosition[1]
4390                                                          - fgkSSDStiffenerWidth 
4391                                                          - fgkSSDFlexWidth[0]
4392                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4393   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4394                                                          + fgkSSDModuleStiffenerPosition[1]
4395                                                          + fgkSSDStiffenerWidth
4396                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4397   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4398                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4399                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4400                                                          - kendladdercablecorrection;
4401   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4402                                                          + carbonfibertomoduleposition[1]
4403                                                          - fgkSSDModuleStiffenerPosition[1]
4404                                                          - fgkSSDStiffenerWidth)
4405                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4406   TList* laddercableassemblylist[4];
4407   const Int_t kendladdercablesnumber = 4;
4408   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4409         for(Int_t j=0; j<kendladdercablesnumber; j++){
4410                 laddercableassemblylist[j] = 
4411                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4412                                                                    ssdendladdercablelength[j]);
4413 //          fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4414 //                                                                      j<2?1:2,fladdercablematrix[i][j]);
4415   }
4416 }
4417 ////////////////////////////////////////////////////////////////////////////////
4418 void AliITSv11GeometrySSD::SetLayer(){
4419 ////////////////////////////////////////////////////////////////////////////////
4420   // Creating Ladder of Layer 5 and Layer 6
4421   /////////////////////////////////////////////////////////////
4422   if(!fCreateMaterials) CreateMaterials();
4423   if(!fTransformationMatrices) CreateTransformationMatrices();
4424   if(!fBasicObjects) CreateBasicObjects();
4425   SetLadder(); // Generating the ladder of Layer5 and Layer6
4426   const Int_t kssdlayladdernumber[fgklayernumber] = 
4427                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4428   /////////////////////////////////////////////////////////////
4429   // Generating mother volumes for Layer5 and Layer6
4430   /////////////////////////////////////////////////////////////
4431   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4432   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4433   Int_t *ladderindex[fgklayernumber];
4434   Int_t index[fgklayernumber] = {8,9};
4435   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4436   for(Int_t i=0; i<fgklayernumber; i++) 
4437         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4438                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4439                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4440                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4441                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4442         }
4443   /////////////////////////////////////////////////////////////
4444   // Deallocating memory
4445   /////////////////////////////////////////////////////////////
4446   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4447 }
4448 ////////////////////////////////////////////////////////////////////////////////
4449 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4450   /////////////////////////////////////////////////////////////
4451   // Insert the layer 5 in the mother volume. 
4452   /////////////////////////////////////////////////////////////
4453   if (! moth) {
4454     printf("Error::AliITSv11GeometrySSD: Can't insert layer5, mother is null!\n");
4455     return;
4456   };
4457   if(!fSSDLayer5) SetLayer();
4458   fMotherVol = moth;
4459   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4460                                                                                 + fgkLay5CenterITSPosition);
4461   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4462  }
4463 ////////////////////////////////////////////////////////////////////////////////
4464 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4465   /////////////////////////////////////////////////////////////
4466   // Insert the layer 6 in the mother volume. 
4467   /////////////////////////////////////////////////////////////
4468   if (! moth) {
4469     printf("Error::AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4470     return;
4471   };
4472   if(!fSSDLayer6) SetLayer();
4473   fMotherVol = moth;
4474   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4475                                                                                 + fgkLay6CenterITSPosition);
4476   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4477  }
4478  ////////////////////////////////////////////////////////////////////////////////
4479  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4480   /////////////////////////////////////////////////////////////
4481   // Method generating the Arc structure of Ladder Support 
4482   /////////////////////////////////////////////////////////////
4483   const Int_t kssdlayladdernumber[fgklayernumber] = 
4484                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4485   Double_t mountingsupportedge[fgklayernumber];
4486   Double_t mountingblockratio[fgklayernumber];
4487   Double_t theta[fgklayernumber];
4488   Double_t phi[fgklayernumber];
4489   Double_t psi0[fgklayernumber];
4490   Double_t deltapsi[fgklayernumber];
4491   TVector3* mountingsupportedgevector[fgklayernumber];
4492   for(Int_t i=0; i<fgklayernumber; i++){
4493         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4494     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4495                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4496                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4497                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4498                                                           / kssdlayladdernumber[i])));
4499     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4500     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4501         mountingsupportedgevector[i] = new TVector3();
4502     mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4503         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(1.
4504                                                                  -TMath::Power(mountingsupportedgevector[i]->X()
4505                                                                  /                         fgkMountingBlockSupportRadius[i],2)));
4506     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4507     deltapsi[i] = (theta[i]+phi[i])/nedges;
4508   }
4509   TVector3** vertex[fgklayernumber];
4510   TList* vertexlist[fgklayernumber];
4511   Int_t indexedge[fgklayernumber] = {0,0};
4512   for(Int_t i=0; i<fgklayernumber; i++){
4513         vertex[i] = new TVector3*[nedges+1];
4514         vertexlist[i] = new TList();
4515   } 
4516   for(Int_t i=0; i<fgklayernumber; i++){
4517         for(Int_t j=0; j<nedges+1; j++){
4518                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4519                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4520                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4521                 vertexlist[i]->Add(vertex[i][j]);
4522         }
4523         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4524   }
4525   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4526   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4527   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4528   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4529   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4530   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4531   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4532   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4533   for(Int_t i=0; i<fgklayernumber; i++){
4534     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4535     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4536     xcentervertex[i] = new Double_t[indexedge[i]+3];
4537     ycentervertex[i] = new Double_t[indexedge[i]+3];
4538         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4539         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4540         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4541         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4542         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4543                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4544                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4545                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4546                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4547                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4548                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4549                 if(j<indexedge[i]+1){
4550                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4551                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4552                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4553                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4554                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4555                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4556                 }
4557         }
4558         xsidevertex[i][1] = xsidevertex[i][0]; 
4559         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4560         xsidevertex[i][2] = xsidevertex[i][3]; 
4561         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4562         xcentervertex[i][1] = xcentervertex[i][0]; 
4563         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4564         xcentervertex[i][2] = xcentervertex[i][3]; 
4565         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4566         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4567         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4568         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4569         ycenterlowervertex[i][0] = ysidevertex[i][0];
4570         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4571         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4572   }
4573   /////////////////////////////////////////////////////////////
4574   // Building the Arc Structure of Ladder Supports 
4575   /////////////////////////////////////////////////////////////
4576   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4577   TGeoXtru* centermountingsupportshape[fgklayernumber];
4578   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4579   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4580   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4581   TGeoVolume* centermountingblocksupport[fgklayernumber];
4582   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4583   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4584   char sidemountingblockname[40];
4585   char centermountingblockname[40];
4586   char sideladdersupportpiecename[40];
4587   char centerladdersupportpiecename[40];
4588   for(Int_t i=0; i<fgklayernumber; i++){ 
4589         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4590         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4591         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4592         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4593         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4594     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4595                                                                                                 xsidevertex[i],ysidevertex[i]);
4596     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4597                                                                                                          -fgkMountingBlockSupportWidth[0]);
4598     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4599     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4600                                                                           sidemountingblocksupportshape[i],
4601                                                                                   fSSDAlCoolBlockMedium);
4602         sidemountingblocksupport[i]->SetLineColor(9);
4603         centermountingsupportshape[i] = new TGeoXtru(2);
4604     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4605                                                                                                 xcentervertex[i],ycentervertex[i]);
4606         centermountingsupportshape[i]->DefineSection(0,0.);
4607     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4608                                                                                                   -fgkMountingBlockSupportWidth[0]);
4609     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4610                                                                           centermountingsupportshape[i],
4611                                                                                   fSSDAlCoolBlockMedium);
4612         centermountingblocksupport[i]->SetLineColor(9);
4613         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4614     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4615                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4616         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4617                                                                                                          -fgkMountingBlockSupportWidth[0]);
4618     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4619     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4620                                                                           sideladdersupportpieceshape[i],
4621                                                                                   fSSDCarbonFiberMedium);
4622         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4623         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4624     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4625                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4626         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4627     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4628                                                                                                   -fgkMountingBlockSupportWidth[0]);
4629     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4630                                                                           centerladdersupportpieceshape[i],
4631                                                                                   fSSDCarbonFiberMedium);
4632         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4633   }
4634   /////////////////////////////////////////////////////////////
4635   // Building the Up Structure of Ladder Supports 
4636   /////////////////////////////////////////////////////////////
4637   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4638   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4639   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4640   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4641   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4642   //////////////////////////////////////////////////////////
4643   // Setting the volume for TGeoXtru Mounting Block Piece  
4644   //////////////////////////////////////////////////////////
4645   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4646   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4647   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4648   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4649   TGeoVolume* mountingblockpieceup[fgklayernumber];
4650   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4651   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4652   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4653   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4654   char mountingblockpiecedownname[34];
4655   char mountingblockpieceupname[34];
4656   for(Int_t i=0; i<fgklayernumber; i++){
4657     ///////////////////////////
4658     // Mounting Block Down Vertex
4659     ///////////////////////////
4660         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4661     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4662         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4663         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4664                                                                                 + fgkMountingBlockSupportDownHeight;
4665         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4666         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4667                                                                                 + fgkSSDMountingBlockHeight[1]
4668                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4669                                                                                 - fgkSSDModuleCoolingBlockToSensor
4670                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4671         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4672         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4673         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4674         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4675         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4676         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4677         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4678         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4679                                                                                 + fgkSSDMountingBlockHeight[2]
4680                                                                                 - fgkSSDMountingBlockHeight[0];
4681         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4682         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4683         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4684         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4685         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4686                                                                                                          mountingblockpiecedownyvertex[i]);
4687         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4688         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4689         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4690                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4691         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4692     ///////////////////////////
4693     // Mounting Block Up Vertex
4694     ///////////////////////////
4695         mountingblockpieceupshape[i] = new TGeoXtru(2);
4696         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4697         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4698         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4699                                                                                 + fgkMountingBlockSupportUpHeight[i];
4700         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4701         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4702                                                                                 + fgkSSDMountingBlockHeight[1]
4703                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4704                                                                                 - fgkSSDModuleCoolingBlockToSensor
4705                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4706         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4707         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4708         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4709         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4710         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4711         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4712         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4713         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4714                                                                                 + fgkSSDMountingBlockHeight[2]
4715                                                                                 - fgkSSDMountingBlockHeight[0];
4716         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4717         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4718         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4719         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4720         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4721                                                                                                          mountingblockpieceupyvertex[i]);
4722         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4723         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4724         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4725                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4726         mountingblockpieceup[i]->SetLineColor(fColorG10);
4727  }
4728   ///////////////////////////////////////////////////////////////////
4729   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4730   ///////////////////////////////////////////////////////////////////
4731   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4732   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4733   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4734   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4735   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4736   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4737   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4738   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4739   char mountingblocksupportrapezoidowname[40];
4740   char mountingblocksupportrapezoidupname[40];
4741   Double_t scalefactor = 3./4.;
4742   for(Int_t i=0; i<fgklayernumber; i++){
4743   ////////////////////////////////////////////
4744   // Mounting Block Support Down Trapezoid Vertex 
4745   ////////////////////////////////////////////
4746         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4747         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4748                                                                                                  - mountingsupportedge[i];
4749         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4750         mountingblocksupportrapezoidownxvertex[i][1] = 
4751                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4752         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4753                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4754                                                                                              - mountingblockpiecedownyvertex[i][0]);
4755         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4756         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4757         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4758         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4759         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4760         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4761         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4762                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4763         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4764                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4765         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4766         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4767         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4768                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4769         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4770   ////////////////////////////////////////////
4771   // Mounting Block Support Up Trapezoid Vertex 
4772   ////////////////////////////////////////////
4773         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4774         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4775                                                                                                  - mountingsupportedge[i];
4776         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4777         mountingblocksupportrapezoidupxvertex[i][1] = 
4778                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4779         mountingblocksupportrapezoidupyvertex[i][1] = 
4780                                                                                                mountingblockpieceupyvertex[i][0]
4781                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4782                                                                                              - mountingblockpieceupyvertex[i][0]);
4783         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4784         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4785         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4786         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4787         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4788         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4789         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4790                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4791         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4792                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4793         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4794         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4795         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4796                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4797         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4798   }
4799   ///////////////////////////////////////////////////////////////////
4800   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4801   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4802   Double_t boxoriginup[fgklayernumber][2][3];
4803   Double_t boxorigindown[fgklayernumber][2][3];
4804   char mountingblocksupportboxdownname[34];
4805   char mountingblocksupportboxupname[34];
4806   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4807   mountingblocksupportrot->SetAngles(90.,180.,-90);
4808   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4809   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4810   TGeoHMatrix* laddersupportmatrix[2];
4811   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4812   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4813   /////////////////////////////////////////////////////////////
4814   // Creating Mother Volume for Containment
4815   /////////////////////////////////////////////////////////////
4816   Double_t *xmothervertex[fgklayernumber];
4817   Double_t *ymothervertex[fgklayernumber];
4818   for(Int_t i=0; i<fgklayernumber; i++){
4819         xmothervertex[i] = new Double_t[8];
4820         ymothervertex[i] = new Double_t[8];
4821   }  
4822   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4823   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4824   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4825 //  TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4826   TGeoVolumeAssembly* upmotherladdersupport[fgklayernumber];   
4827   char upmotheladdersupportname[30];
4828   char downmotheladdersupportname[30];
4829   for(Int_t i=0; i<fgklayernumber; i++){
4830         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4831                                                     -  mountingsupportedge[i];
4832         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4833         xmothervertex[i][1] = xmothervertex[i][0];
4834         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4835                                                         + fgkMountingBlockSupportWidth[0];
4836         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4837         ymothervertex[i][2] = ymothervertex[i][1];
4838         xmothervertex[i][3] = xmothervertex[i][2];
4839         ymothervertex[i][3] = -ymothervertex[i][0];
4840         xmothervertex[i][4] = -xmothervertex[i][0];
4841         ymothervertex[i][4] = ymothervertex[i][3];
4842         xmothervertex[i][5] = xmothervertex[i][4];
4843         ymothervertex[i][5] = -ymothervertex[i][1];
4844         xmothervertex[i][6] = -xmothervertex[i][2];
4845         ymothervertex[i][6] = ymothervertex[i][5];
4846         xmothervertex[i][7] = xmothervertex[i][6];
4847         ymothervertex[i][7] = ymothervertex[i][0];
4848         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4849         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4850     downmotherladdersupportshape[i] = new TGeoXtru(2);
4851         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4852         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4853     downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4854                                                                    +                       fgkMountingBlockSupportDownHeight
4855                                                                    +                       fgkSSDMountingBlockHeight[1]
4856                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4857                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4858                                                                    -                       2.*fgkSSDModuleVerticalDisalignment);
4859     downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4860                                                                           downmotherladdersupportshape[i],fSSDAir);
4861     upmotherladdersupportshape[i] = new TGeoXtru(2);
4862         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4863         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4864     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4865                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4866                                                                    +                       fgkSSDMountingBlockHeight[1]
4867                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4868                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4869                                                                    -               2.*fgkSSDModuleVerticalDisalignment);
4870         upmotherladdersupport[i] = new TGeoVolumeAssembly(upmotheladdersupportname);
4871 //    upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4872 //                                                                                        upmotherladdersupportshape[i],fSSDAir);
4873   }
4874   for(Int_t i=0; i<fgklayernumber; i++){
4875         /////////////////////////
4876         // Setting the box origin
4877         /////////////////////////
4878         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4879         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4880                                                    +  0.5*fgkMountingBlockSupportDownHeight;
4881         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4882                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4883   
4884         boxorigindown[i][1][0] = 0.0;
4885         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4886         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4887                                                    -      fgkMountingBlockSupportWidth[0]);
4888                                                    
4889         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4890         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4891                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4892         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4893                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4894   
4895         boxoriginup[i][1][0] = 0.0;
4896         boxoriginup[i][1][1] = fgkMountingBlockSupportRadius[i]
4897                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4898         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4899                                                  - fgkMountingBlockSupportWidth[0]);
4900   
4901         /////////////////////////
4902     // Setting the boxes    
4903         /////////////////////////
4904         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4905                                                                                  +  fgkSSDMountingBlockLength[0]),
4906                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4907                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4908                                                                                         boxorigindown[i][0]);
4909     mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4910                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4911                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4912                                                                                  -  fgkMountingBlockSupportWidth[0]),
4913                                                                                         boxorigindown[i][1]);
4914                                                                                         
4915         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4916                                                                                  +  fgkSSDMountingBlockLength[0]),
4917                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4918                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4919                                                                                         boxoriginup[i][0]);
4920                                                                                         
4921         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4922                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4923                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4924                                                                      -  fgkMountingBlockSupportWidth[0]),
4925                                                                                         boxoriginup[i][1]);
4926         ///////////////////////////////////////
4927     // Adding the Volumes to Mother Volume    
4928         ///////////////////////////////////////
4929         for(Int_t j=0; j<2; j++){
4930                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4931                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4932                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4933                                                                                   mountingblocksupportboxdownshape[i][j],
4934                                                                                   fSSDCarbonFiberMedium);
4935                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4936                                                                                   mountingblocksupportboxupshape[i][j],
4937                                                                                   fSSDCarbonFiberMedium);
4938                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4939                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4940                 for(Int_t k=0; k<2; k++){
4941                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4942 //                      upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4943                 }
4944         }
4945         for(Int_t k=0; k<2; k++){
4946                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4947                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4948                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4949                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4950             downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4951                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4952                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4953 //              upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4954 //              upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4955 //              upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4956 //              upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4957 //              upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4958         }
4959   }
4960   TList* laddersupportlist = new TList();
4961   laddersupportlist->Add(downmotherladdersupport[0]); 
4962   laddersupportlist->Add(upmotherladdersupport[0]); 
4963   laddersupportlist->Add(downmotherladdersupport[1]); 
4964   laddersupportlist->Add(upmotherladdersupport[1]); 
4965   /////////////////////////////////////////////////////////////
4966   // Deallocating memory
4967   /////////////////////////////////////////////////////////////
4968   for(Int_t i=0; i<fgklayernumber; i++){
4969         for(Int_t j=0; j<nedges+1; j++)
4970                 delete vertex[i][j];
4971         delete mountingsupportedgevector[i];
4972         delete [] vertex[i];
4973         delete vertexlist[i];
4974         delete [] xsidevertex[i];
4975         delete [] ysidevertex[i];
4976         delete [] xcentervertex[i];
4977         delete [] ycentervertex[i];
4978         delete [] xsidelowervertex[i];
4979         delete [] ysidelowervertex[i];
4980         delete [] xcenterlowervertex[i];
4981         delete [] ycenterlowervertex[i];
4982   }
4983   delete xsidevertex;
4984   delete ysidevertex;
4985   delete xcentervertex;
4986   delete ycentervertex;
4987   delete xsidelowervertex;
4988   delete ysidelowervertex;
4989   delete xcenterlowervertex;
4990   delete ycenterlowervertex;
4991   delete globalrefladdersupportrot;
4992   delete mountingblocksupportrot;
4993   /////////////////////
4994   return laddersupportlist;     
4995 }
4996  ////////////////////////////////////////////////////////////////////////////////
4997 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4998 //////////////////////////////////////////
4999 // Method Generating Ladder Support Ring
5000 //////////////////////////////////////////
5001   if(!fCreateMaterials) CreateMaterials();
5002   if(!fTransformationMatrices) CreateTransformationMatrices();
5003   if(!fBasicObjects) CreateBasicObjects();
5004   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
5005   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
5006     const Int_t kssdlayladdernumber[fgklayernumber] = 
5007                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
5008   Double_t mountingsupportedge[fgklayernumber];
5009   Double_t mountingblockratio[fgklayernumber];
5010   Double_t theta[fgklayernumber];
5011   Double_t phi[fgklayernumber];
5012   for(Int_t i=0; i<fgklayernumber; i++){
5013         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
5014     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
5015                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
5016                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
5017                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
5018                                                           / kssdlayladdernumber[i])));
5019     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
5020                          / fgkMountingBlockSupportRadius[i]);
5021     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
5022   }
5023   TGeoRotation* globalrot = new TGeoRotation();
5024   globalrot->SetAngles(0.,-90.,0.); 
5025   TGeoRotation** laddersupportrot[fgklayernumber];
5026   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5027   for(Int_t i=0; i<fgklayernumber; i++){                
5028         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5029         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5030         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5031                 laddersupportrot[i][j] = new TGeoRotation();
5032                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5033                 switch(i){
5034                         case 0: //Ladder of Layer5  
5035                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5036                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5037                                                                             laddersupportmatrix[i][j]); 
5038                         break;
5039                         case 1: //Ladder of Layer6 
5040                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5041                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5042                                                                               laddersupportmatrix[i][j]); 
5043                         break;
5044                 }
5045     }
5046   }
5047   /////////////////////////////////////////////////////////////
5048   // Creating Lower Ladder Support 
5049   /////////////////////////////////////////////////////////////
5050   TVector3** ringsupportvertex[fgklayernumber];         
5051   Double_t angle = 360./nedges;
5052   for(Int_t i=0; i<fgklayernumber; i++){
5053     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5054         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5055                                                         *                          TMath::Cos(theta[i]));
5056         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5057                                                         -                          mountingsupportedge[i],
5058                                                                                    ringsupportvertex[i][0]->Y());
5059         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5060                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5061     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5062         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5063            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5064            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5065            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5066            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5067         }
5068         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5069     for(Int_t j=0; j<nedges+1; j++){
5070                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5071                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5072                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5073         }
5074   }
5075   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5076   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5077   for(Int_t i=0; i<fgklayernumber; i++){
5078         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5079         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5080         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5081                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5082                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5083         }
5084   }
5085 ////////////////////////////////////////////////////////////////////////////////
5086 // Start Corrections 13/06/08
5087 ////////////////////////////////////////////////////////////////////////////////
5088   char lowerladderpconsupportname[30];
5089   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5090   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5091   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5092   Double_t lowerladderpconradiusmax[fgklayernumber];
5093   Double_t lowerladderpconradiusmin[fgklayernumber];
5094   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5095   lowerladdersupportrot->SetAngles(90.,180.,-90);
5096   for(Int_t i=0; i<fgklayernumber; i++){
5097         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5098                                                                 *                          TMath::Cos(theta[i]);
5099     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5100   } 
5101   for(Int_t i=0; i<fgklayernumber; i++){
5102 ///////////////////////////  Modified Version ?///////////////////
5103     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5104         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5105                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5106                                                          lowerladderpconradiusmax[i]);
5107         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5108         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5109     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5110         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5111         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5112  }
5113 ////////////////////////////////////////////////////////////////////////////////
5114 // End Corrections 13/06/08
5115 ////////////////////////////////////////////////////////////////////////////////
5116   /*char lowerladdersupportname[30];
5117   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5118   TGeoVolume* lowerladdersupport[fgklayernumber];
5119   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5120   lowerladdersupportrot->SetAngles(90.,180.,-90);
5121   for(Int_t i=0; i<fgklayernumber; i++){
5122         lowerladdersupportshape[i] = new TGeoXtru(2);
5123         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5124                                                                                           xmothervertex[i],ymothervertex[i]);
5125         lowerladdersupportshape[i]->DefineSection(0,0.);
5126     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5127         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5128     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5129                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5130         lowerladdersupport[i]->SetLineColor(fColorAl);
5131         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5132         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5133   }*/
5134   /////////////////////////////////////////////////////////////
5135   // Deallocating memory
5136   /////////////////////////////////////////////////////////////
5137   for(Int_t i=0; i<fgklayernumber; i++){
5138         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5139                 delete ringsupportvertex[i][j];
5140         delete [] ringsupportvertex[i];
5141   }
5142   for(Int_t i=0; i<fgklayernumber; i++){
5143         delete [] xmothervertex[i];
5144         delete [] ymothervertex[i];
5145   }
5146   delete xmothervertex;
5147   delete ymothervertex; 
5148   delete globalrot;
5149   for(Int_t i=0; i<fgklayernumber; i++){
5150         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5151                 delete laddersupportrot[i][j];
5152         delete [] laddersupportrot[i];
5153   }
5154  }  
5155  ////////////////////////////////////////////////////////////////////////////////
5156  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5157   /////////////////////////////////////////////////////////////
5158   // Method generating Endcap CoverPlate
5159   /////////////////////////////////////////////////////////////
5160   // Holes Definition 
5161   ///////////////////
5162   Int_t nendcapcoverplateholedges = 30;
5163   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5164   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5165                                                           0.5*fgkEndCapCoverPlateThickness};
5166   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5167                                                                                                               nendcapcoverplateholedges,holesection);
5168   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5169                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5170   endcapcoverplatesmallhole->SetLineColor(6);
5171   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5172                                                                                                               nendcapcoverplateholedges,holesection);
5173   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5174                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5175   endcapcoverplatebighole->SetLineColor(6);
5176   //////////////////////////
5177   // Screw Piece Definition 
5178   //////////////////////////
5179   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5180   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5181                                                                                                       CosD(0.5*smallscrewangle),
5182                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5183   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5184                                                                                                 endcapsmallscrewpieceshape,
5185                                                                                                 fSSDCoolingTubePhynox);
5186   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5187   ///////////////////
5188   // Box Definition 
5189   ///////////////////
5190   TGeoBBox* endcapcoverplateboxshape[4];
5191   TGeoVolume* endcapcoverplatebox[4];
5192   Double_t boxorigin[5][3];
5193   boxorigin[0][0] = 0.;
5194   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5195   boxorigin[0][2] = 0.;
5196
5197   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5198   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5199   boxorigin[1][2] = 0.;
5200
5201   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5202                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5203   boxorigin[2][1] = boxorigin[1][1];
5204   boxorigin[2][2] = 0.;
5205
5206   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5207                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5208   boxorigin[3][1] = boxorigin[1][1];
5209   boxorigin[3][2] = 0.;
5210
5211   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5212                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5213                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5214                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5215
5216   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5217                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5218                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5219                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5220                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5221
5222   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5223                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5224                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5225                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5226                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5227
5228   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5229                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5230                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5231                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5232                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5233   
5234   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5235                                                                            fSSDAlCoolBlockMedium);
5236   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5237                                                                            fSSDAlCoolBlockMedium);
5238   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5239                                                                            fSSDAlCoolBlockMedium);
5240   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5241                                                                            fSSDAlCoolBlockMedium);
5242   endcapcoverplatebox[0]->SetLineColor(6);
5243   endcapcoverplatebox[1]->SetLineColor(6);
5244   endcapcoverplatebox[2]->SetLineColor(6);
5245   endcapcoverplatebox[3]->SetLineColor(6);
5246   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5247   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5248                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5249                                                                                         0.5*fgkEndCapCoverPlateThickness,
5250                                                                                         endcapfillingboxorigin);
5251   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5252                                                                            fSSDAlCoolBlockMedium);
5253   endcapfillingbox->SetLineColor(6);
5254   ////////////////////////////
5255   // Contour shape Definition 
5256   ////////////////////////////
5257   const Int_t kcontourvertexnumber = 10;
5258   Double_t xcontourvertex[kcontourvertexnumber];
5259   Double_t ycontourvertex[kcontourvertexnumber];
5260   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5261   xcontourvertex[1] = xcontourvertex[0];
5262   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5263   xcontourvertex[3] = xcontourvertex[2];
5264   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5265   xcontourvertex[5] = xcontourvertex[4];
5266   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5267   xcontourvertex[7] = xcontourvertex[6];
5268   xcontourvertex[8] = xcontourvertex[4];
5269   xcontourvertex[9] = xcontourvertex[8];
5270   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5271                                         - (kendcapcoverplatesmallholenumber[1]-1)
5272                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5273   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5274                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5275   ycontourvertex[2] = ycontourvertex[1];
5276   ycontourvertex[3] = ycontourvertex[0];
5277   ycontourvertex[4] = ycontourvertex[3];
5278   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5279   ycontourvertex[6] = ycontourvertex[5];
5280   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5281                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5282                                         + fgkEndCapCoverPlateSmallHoleRadius;
5283   ycontourvertex[8] = ycontourvertex[7];
5284   ycontourvertex[9] = ycontourvertex[0];
5285
5286   Double_t xboxin, dxboxin, yboxin, dyboxin;
5287   Double_t xboxout, dxboxout, yboxout, dyboxout;
5288   Double_t coordmin, coordmax;
5289   coordmin = -fgkEndCapCoverPlateLength[0];
5290   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5291   xboxout = 0.5*(coordmin+coordmax);
5292   dxboxout = 0.5*(coordmax-coordmin);
5293   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5294                                         - (kendcapcoverplatesmallholenumber[1]-1)
5295                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5296   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5297                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5298   yboxout = 0.5*(coordmin+coordmax);
5299   dyboxout = 0.5*(coordmax-coordmin);
5300   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5301   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5302   xboxin = 0.5*(coordmin+coordmax);
5303   dxboxin = 0.5*(coordmax-coordmin);
5304   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5305   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5306                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5307                                         + fgkEndCapCoverPlateSmallHoleRadius;
5308   yboxin = 0.5*(coordmin+coordmax);
5309   dyboxin = 0.5*(coordmax-coordmin);
5310   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5311   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5312                                                          xboxout, yboxout, 0.);
5313   trendCapCoverPlateContourboxout->RegisterYourself();
5314   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5315   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5316                                                          xboxin, yboxin, 0.);
5317   trendCapCoverPlateContourboxin->RegisterYourself();
5318   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5319         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5320
5321   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5322                                                                            fSSDAlCoolBlockMedium);
5323   contour->SetLineColor(6);
5324   /////////////////////////////
5325   // Hole Contour Shape Definition 
5326   ////////////////////////////
5327   coordmin = xcontourvertex[0];
5328   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5329   xboxout = 0.5*(coordmin+coordmax);
5330   dxboxout = 0.5*(coordmax-coordmin);
5331   coordmin = ycontourvertex[1];
5332   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5333   yboxout = 0.5*(coordmin+coordmax);
5334   dyboxout = 0.5*(coordmax-coordmin);
5335   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5336                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5337   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5338   xboxin = 0.5*(coordmin+coordmax);
5339   dxboxin = 0.5*(coordmax-coordmin);
5340   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5341                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5342   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5343   yboxin = 0.5*(coordmin+coordmax);
5344   dyboxin = 0.5*(coordmax-coordmin);
5345   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5346   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5347                                                          xboxout, yboxout, 0.);
5348   trendCapCoverPlateContourboxout1->RegisterYourself();
5349   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5350   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5351                                                          xboxin, yboxin, 0.);
5352   trendCapCoverPlateContourboxin1->RegisterYourself();
5353   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5354         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5355
5356
5357   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5358   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5359   xboxout = 0.5*(coordmin+coordmax);
5360   dxboxout = 0.5*(coordmax-coordmin);
5361   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5362                                                    - fgkEndCapCoverPlateWidth[0]);
5363   coordmax = ycontourvertex[0];
5364   yboxout = 0.5*(coordmin+coordmax);
5365   dyboxout = 0.5*(coordmax-coordmin);
5366   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5367                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5368   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5369   xboxin = 0.5*(coordmin+coordmax);
5370   dxboxin = 0.5*(coordmax-coordmin);
5371   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5372                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5373                                                    - fgkEndCapCoverPlateWidth[0]
5374                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5375   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5376   yboxin = 0.5*(coordmin+coordmax);
5377   dyboxin = 0.5*(coordmax-coordmin);
5378   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5379   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5380                                                          xboxout, yboxout, 0.);
5381   trendCapCoverPlateContourboxout2->RegisterYourself();
5382   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5383   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5384                                                          xboxin, yboxin, 0.);
5385   trendCapCoverPlateContourboxin2->RegisterYourself();
5386   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5387         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5388   
5389 //  const Int_t kholecontourvertexnumber = 10;
5390
5391   Double_t xholecontourvertex[2][kcontourvertexnumber];
5392   Double_t yholecontourvertex[2][kcontourvertexnumber];
5393   xholecontourvertex[0][0] = xcontourvertex[0];
5394   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5395   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5396   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5397   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5398                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5399                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5400   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5401   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5402                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5403   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5404   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5405   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5406   
5407   yholecontourvertex[0][0] = ycontourvertex[1];
5408   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5409   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5410   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5411   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5412   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5413                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5414   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5415   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5416   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5417   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5418
5419   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5420   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5421   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5422   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5423   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5424                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5425                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5426   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5427   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5428                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5429   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5430   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5431   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5432   
5433   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5434                                                    - fgkEndCapCoverPlateWidth[0]);
5435   yholecontourvertex[1][1] = ycontourvertex[0];
5436   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5437   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5438   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5439   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5440                                                    - fgkEndCapCoverPlateWidth[0]
5441                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5442   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5443   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5444   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5445   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5446
5447   TGeoVolume* holecontour[2];
5448   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5449                                                                   fSSDAlCoolBlockMedium);
5450   holecontour[0]->SetLineColor(6);
5451   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5452                                                                   fSSDAlCoolBlockMedium);
5453   holecontour[1]->SetLineColor(6);
5454   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5455                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5456   TGeoTranslation*  bigholetrans[3];
5457   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5458                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5459   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5460                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5461                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5462   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5463                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5464   /////////////////////////////////
5465   // Mother Volume Xtru Definition 
5466   /////////////////////////////////
5467   const Int_t kmothervertexnumber = 12;
5468   Double_t xmothervertex[kmothervertexnumber];  
5469   Double_t ymothervertex[kmothervertexnumber];  
5470   xmothervertex[0]  = xcontourvertex[0];
5471   xmothervertex[1]  = xmothervertex[0];
5472   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5473   xmothervertex[3]  = xmothervertex[2];
5474   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5475   xmothervertex[5]  = xmothervertex[4];
5476   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5477   xmothervertex[7]  = xmothervertex[6];
5478   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5479                                         + fgkEndCapCoverPlateLength[2]; 
5480   xmothervertex[9]  = xmothervertex[8];
5481   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5482   xmothervertex[11] = xmothervertex[10];
5483   
5484   ymothervertex[0]  = ycontourvertex[0];
5485   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5486   ymothervertex[2]  = ymothervertex[1];
5487   ymothervertex[3]  = ycontourvertex[1];
5488   ymothervertex[4]  = ymothervertex[3];
5489   ymothervertex[5]  = ymothervertex[1];
5490   ymothervertex[6]  = ymothervertex[5];
5491   ymothervertex[7]  = ymothervertex[0];
5492   ymothervertex[8]  = ymothervertex[7];
5493   ymothervertex[9]  = ymothervertex[8]
5494                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5495   ymothervertex[10] = ymothervertex[9];
5496   ymothervertex[11] = ymothervertex[8];
5497   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5498   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5499   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5500   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5501   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5502   ////////////////////////////////////////
5503   // Adding Nodes
5504   ////////////////////////////////////////
5505 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5506   TGeoTranslation*** endcapcoverplatesmallholetrans;
5507   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5508   Double_t transx[4] = {0,
5509                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5510                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5511                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5512                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5513                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5514   Int_t index = 0;
5515   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5516         endcapcoverplatesmallholetrans[i] = 
5517                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5518     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5519                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5520             endcapcoverplatesmallholetrans[i][j] = 
5521                 new TGeoTranslation(transx[i],
5522                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5523             if(index!=10){ 
5524                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5525                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5526                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5527                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5528                 }
5529                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5530                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5531                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5532     }
5533   }
5534   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5535   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5536   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5537   mothercoverplate->AddNode(endcapfillingbox,1);
5538   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5539   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5540   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5541   mothercoverplate->AddNode(holecontour[0],1);
5542   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5543   mothercoverplate->AddNode(holecontour[1],1);  
5544   mothercoverplate->AddNode(contour,1);
5545   /////////////////////////////////
5546   return mothercoverplate;      
5547  }
5548  ////////////////////////////////////////////////////////////////////////////////
5549  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5550   /////////////////////////////////////////////////////////////
5551   // Getting EndCap Cooling Tube 
5552   /////////////////////////////////////////////////////////////
5553   TGeoTorus* endcapcoolingtubetorushape[5];
5554   TGeoVolume* endcapcoolingtubetorus[5];
5555   TGeoTube* endcapcoolingtubeshape[4];
5556   TGeoVolume* endcapcoolingtube[4];
5557   char endcapcoolingtubetorusname[30];
5558   char endcapcoolingtubename[30];
5559   TGeoTorus* endcapcoolingwatertubetorushape[5];
5560   TGeoVolume* endcapcoolingwatertubetorus[5];
5561   TGeoTube* endcapcoolingwatertubeshape[4];
5562   TGeoVolume* endcapcoolingwatertube[4];
5563   char endcapcoolingwatertubetorusname[30];
5564   char endcapcoolingwatertubename[30];
5565   for(Int_t i=0; i<5; i++){
5566         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5567         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5568         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5569         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5570         if(i==3){
5571                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5572                                                                                 fgkEndCapCoolingTubeRadiusMin,
5573                                                                                 fgkEndCapCoolingTubeRadiusMax,
5574                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5575                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5576                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5577                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5578     }
5579         else{
5580                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5581                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5582                                                                            fgkEndCapCoolingTubeRadiusMin,
5583                                                                            fgkEndCapCoolingTubeRadiusMax,
5584                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5585                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5586                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5587                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5588                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5589         }
5590         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5591                                                                                            endcapcoolingtubetorushape[i],
5592                                                                                            fSSDCoolingTubePhynox);
5593         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5594                                                                                                         endcapcoolingwatertubetorushape[i],
5595                                                                                                         fSSDCoolingTubeWater);
5596     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5597     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5598     if(i<4){
5599                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5600                                                                   fgkEndCapCoolingTubeRadiusMax,
5601                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5602                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5603                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5604         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5605                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5606         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5607                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5608                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5609                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5610         }
5611   }
5612   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5613   /////////////////////////////////////////
5614   // Transformation for Volume Positioning 
5615   /////////////////////////////////////////
5616   TGeoCombiTrans* coolingtubecombitrans[6];
5617   TGeoRotation* coolingtuberot[8];
5618   TGeoTranslation* coolingtubetrans[6];
5619   TGeoHMatrix* coolingtubematrix[4];
5620   TGeoCombiTrans* torustubecombitrans[4];
5621   TGeoRotation* torustuberot[7];
5622   TGeoTranslation* torustubetrans[4];
5623   TGeoHMatrix* torustubematrix[5];
5624   TGeoCombiTrans* coolingwatertubecombitrans[6];
5625   TGeoRotation* coolingwatertuberot[8];
5626   TGeoTranslation* coolingwatertubetrans[6];
5627   TGeoHMatrix* coolingwatertubematrix[4];
5628   TGeoCombiTrans* toruswatertubecombitrans[4];
5629   TGeoRotation* toruswatertuberot[7];
5630   TGeoTranslation* toruswatertubetrans[4];
5631   TGeoHMatrix* toruswatertubematrix[5];
5632   for(Int_t i=0; i<8; i++){
5633     if(i<6){
5634          coolingtubetrans[i] = new TGeoTranslation();
5635          coolingwatertubetrans[i] = new TGeoTranslation();
5636     }
5637     if(i<8){
5638          coolingtuberot[i] = new TGeoRotation();
5639          coolingwatertuberot[i] = new TGeoRotation();
5640     }
5641     if(i<4){
5642          torustubetrans[i] = new TGeoTranslation();
5643          toruswatertubetrans[i] = new TGeoTranslation();
5644     }
5645     if(i<7){
5646          torustuberot[i] = new TGeoRotation();
5647          toruswatertuberot[i] = new TGeoRotation();
5648         }
5649   }
5650   /////////////////////////////////////////
5651   // Transformation for Inox Volume Positioning 
5652   /////////////////////////////////////////
5653   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5654                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5655   coolingtuberot[0]->SetAngles(0.,90.,0.);
5656   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5657                                                                                                 *coolingtuberot[0]);
5658                                                                                                 
5659   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5660   coolingtuberot[1]->SetAngles(0.,90.,0.);
5661   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5662                                                                                                 *coolingtuberot[1]);
5663
5664   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5665                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5666                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5667                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5668                                                                           0.);
5669   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5670   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5671                                                                                                 *coolingtuberot[2]);
5672
5673   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5674                                            *                             (*coolingtubecombitrans[1]));
5675
5676   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5677                                                                          endcapcoolingtubeshape[1]->GetDz());
5678   torustuberot[0]->SetAngles(0.,90.,0.); 
5679   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5680
5681   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5682
5683   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5684                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5685   coolingtuberot[3]->SetAngles(0.,90.,0.);
5686   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5687                                                                                                 *coolingtuberot[3]);
5688   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5689   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5690   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5691   
5692   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5693                                                                         endcapcoolingtubeshape[2]->GetDz());
5694   torustuberot[1]->SetAngles(0.,90.,0.); 
5695   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5696   torustuberot[2]->SetAngles(180.,0.,0.); 
5697   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5698   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5699
5700   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5701                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5702   torustuberot[3]->SetAngles(0.,90.,0.); 
5703   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5704   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5705   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5706   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5707
5708   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5709                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5710   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5711   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5712                                                                                                 *coolingtuberot[5]);
5713   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5714   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5715   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5716   
5717   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5718                                                                         endcapcoolingtubeshape[0]->GetDz());
5719   torustuberot[5]->SetAngles(0.,90.,0.); 
5720   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5721   torustuberot[6]->SetAngles(-90.,0.,0.); 
5722   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5723   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5724   
5725   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5726                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5727   coolingtuberot[6]->SetAngles(0.,90.,0.);
5728   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5729                                                                                                 *coolingtuberot[6]);
5730   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5731   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5732   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5733     /////////////////////////////////////////
5734   // Transformation for Water Volume Positioning 
5735   /////////////////////////////////////////
5736   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5737                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5738   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5739   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5740                                                                                                      *coolingwatertuberot[0]);
5741
5742   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5743   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5744   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5745                                                                                                      *coolingwatertuberot[1]);
5746
5747   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5748                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5749                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5750                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5751                                                                               0.);
5752   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5753   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5754                                                                                                     *coolingwatertuberot[2]);
5755
5756   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5757                                            *                                 (*coolingwatertubecombitrans[1]));
5758                                            
5759   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5760                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5761   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5762   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5763                                                                                                    *toruswatertuberot[0]);
5764
5765   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5766                                                   *                                     (*toruswatertubecombitrans[0]));
5767
5768   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5769                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5770   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5771   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5772                                                                                                      *coolingwatertuberot[3]);
5773   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5774   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5775                                                         *                                 (*coolingwatertubecombitrans[3]));
5776   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5777
5778   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5779                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5780   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5781   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5782                                                                                                    *toruswatertuberot[1]);
5783   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5784   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5785                                                   *                 (*toruswatertubecombitrans[1]));
5786   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5787   
5788   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5789                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5790   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5791   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5792                                                                                                    *toruswatertuberot[3]);
5793   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5794   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5795                                                   *                                     (*toruswatertubecombitrans[2]));
5796   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5797
5798   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5799                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5800   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5801   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5802                                                                                                      *coolingwatertuberot[5]);
5803   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5804   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5805                                                         *                                 (*coolingwatertubecombitrans[4]));
5806   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5807   
5808   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5809                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5810   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5811   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5812                                                                                                    *toruswatertuberot[5]);
5813   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5814   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5815                                                   *                 (*toruswatertubecombitrans[3]));
5816   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5817   
5818   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5819                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5820   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5821   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5822                                                                                                      *coolingwatertuberot[6]);
5823   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5824   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5825                                                         *                                 (*coolingwatertubecombitrans[5]));
5826   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5827   /////////////////////////////////////////
5828   // Positioning Volumes
5829   /////////////////////////////////////////
5830   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5831   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5832   
5833   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5834   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5835
5836   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5837   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5838  
5839   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5840   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5841
5842   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5843   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5844
5845   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5846   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5847
5848   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5849   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5850
5851   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5852   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5853   
5854   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5855   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5856  
5857   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5858   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5859   /////////////////////////////////////////////////////////////
5860   // Deallocating memory
5861   /////////////////////////////////////////////////////////////
5862   for(Int_t i=0; i<8; i++){
5863     if(i<6){
5864          delete coolingtubetrans[i];
5865          delete coolingwatertubetrans[i];
5866          if(i!=0){
5867           delete coolingtubecombitrans[i];
5868           delete coolingwatertubecombitrans[i];
5869          }
5870         }
5871     if(i<8){
5872           delete coolingtuberot[i];
5873           delete coolingwatertuberot[i];
5874     }
5875     if(i<4){
5876                 delete torustubetrans[i];
5877                 delete toruswatertubetrans[i];
5878                 delete torustubecombitrans[i];
5879                 delete toruswatertubecombitrans[i];
5880         } 
5881     if(i<7){
5882          delete torustuberot[i];
5883          delete toruswatertuberot[i];
5884         }
5885   }
5886   /////////////////////////////////////////////////////////////
5887   return endcapcoolingtubemother;
5888  }
5889  ////////////////////////////////////////////////////////////////////////////////
5890  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5891   /////////////////////////////////////////////////////////////
5892   // Getting EndCap Cover Side 
5893   /////////////////////////////////////////////////////////////
5894   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5895   const Int_t kvertexnumber = 15; 
5896   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5897   xvertex[0]  = 0.0;
5898   xvertex[1]  = xvertex[0];
5899   xvertex[2]  = fgkEndCapSideCoverLength[0];
5900   xvertex[3]  = fgkEndCapSideCoverLength[1];
5901   xvertex[4]  = xvertex[3];
5902   xvertex[5]  = fgkEndCapSideCoverLength[2];
5903   xvertex[6]  = xvertex[5];
5904   xvertex[7]  = xvertex[2];
5905   xvertex[8]  = xvertex[7];
5906   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5907   xvertex[10] = xvertex[9];
5908   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5909                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5910                           * fgkEndCapSideCoverLength[4];
5911   xvertex[12] = xvertex[11];
5912   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5913                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5914                           * fgkEndCapSideCoverLength[4];
5915   xvertex[14] = xvertex[13];
5916   yvertex[0]  = 0.0;
5917   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5918   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5919   yvertex[3]  = yvertex[2];
5920   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5921   yvertex[5]  = yvertex[4];
5922   yvertex[6]  = yvertex[0];
5923   yvertex[7]  = yvertex[6];
5924   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5925   yvertex[9]  = yvertex[8];
5926   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5927   yvertex[11] = yvertex[10];
5928   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5929   yvertex[13] = yvertex[12];
5930   yvertex[14] = yvertex[6];
5931   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5932   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5933   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5934   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5935   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5936   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
5937   endcapsidecovershapein->SetName("endcapsidecovershapein");
5938   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
5939   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
5940   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
5941
5942
5943   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
5944   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5945                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5946   endcapsidecover->SetLineColor(fColorPhynox);
5947   ////////////////////////////////////////////
5948   // Defininition of Mother Volume
5949   ////////////////////////////////////////////
5950   const Int_t kmothervertexnumber = 7;
5951   Double_t xmothervertex[kmothervertexnumber]; 
5952   Double_t ymothervertex[kmothervertexnumber]; 
5953   for(Int_t i=0; i<kmothervertexnumber; i++){
5954         xmothervertex[i] = xvertex[i];
5955         ymothervertex[i] = yvertex[i];
5956   }
5957   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5958   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5959   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5960   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5961   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5962                                                                 endcapsidecovermothershape,fSSDAir);
5963   ////////////////////////////////////////////
5964   endcapsidecovermother->AddNode(endcapsidecover,1);
5965   TGeoBBox* endcapsidecoverboxshape[4];
5966   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5967                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5968                                                                0.5*fgkEndCapSideCoverLength[4],
5969                                                                    0.5*fgkEndCapSideCoverThickness); 
5970   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5971                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5972                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5973                                                          -     fgkEndCapSideCoverLength[4]),
5974                                                                    0.5*fgkEndCapSideCoverThickness); 
5975   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5976                                                                0.5*fgkEndCapSideCoverLength[4],
5977                                                                    0.5*fgkEndCapSideCoverThickness); 
5978   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5979                                                                0.5*fgkEndCapSideCoverWidth[5],
5980                                                                    0.5*fgkEndCapSideCoverThickness); 
5981   TGeoVolume* endcapsidecoverbox[4];
5982   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5983   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5984   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5985   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5986   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5987 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5988   TGeoTranslation** endcapsidecoverboxtrans;
5989   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5990   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5991                                                          +                                         fgkEndCapSideCoverLength[0],
5992                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5993                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5994   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5995                                                          +                     xvertex[11],
5996                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5997                                                          +                     yvertex[12],0.);
5998   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5999                                                          +                     xvertex[11],
6000                                                                                                    endcapsidecoverboxshape[2]->GetDY()
6001                                                          +                     yvertex[12]
6002                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
6003                                                          +                     fgkEndCapSideCoverWidth[5],0.);
6004   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
6005   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
6006   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
6007   for(Int_t i=0; i<2; i++)
6008         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
6009                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
6010                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
6011                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6012                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6013                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
6014                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
6015                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
6016         }
6017   for(Int_t i=0; i<2; i++)
6018         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
6019                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
6020                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
6021                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6022                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6023                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
6024                                                         +fgkEndCapSideCoverLength[4]),0.0);
6025                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
6026                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
6027                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
6028                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
6029         }
6030         return endcapsidecovermother;
6031  } 
6032  ////////////////////////////////////////////////////////////////////////////////
6033  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
6034  ////////////////////////////////////////////////////////////////////////////////
6035  // Method returning Interface Card A, Interface Card B, Supply Card 
6036  ////////////////////////////////////////////////////////////////////////////////
6037  /////////////////////
6038  // Supply Card
6039  /////////////////////
6040  // Electronic Board Back Al Plane
6041  const Int_t kelectboardbackvertexnumber = 8;
6042  Double_t xelectboardback[kelectboardbackvertexnumber];
6043  Double_t yelectboardback[kelectboardbackvertexnumber];
6044  xelectboardback[0] = 0.0;
6045  xelectboardback[1] = xelectboardback[0];
6046  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
6047  xelectboardback[3] = xelectboardback[2];
6048  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
6049  xelectboardback[5] = xelectboardback[4];
6050  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
6051  xelectboardback[7] = xelectboardback[6];
6052  
6053  yelectboardback[0] = 0.0;
6054  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
6055  yelectboardback[2] = yelectboardback[1];
6056  yelectboardback[3] = yelectboardback[0];
6057  yelectboardback[4] = yelectboardback[3];
6058  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
6059  yelectboardback[6] = yelectboardback[5];
6060  yelectboardback[7] = yelectboardback[4];
6061  TGeoXtru* electboardbackshape = new TGeoXtru(2);
6062  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
6063                                                                         xelectboardback,yelectboardback); 
6064  electboardbackshape->DefineSection(0,0.0);
6065  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
6066  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
6067                                                                                          electboardbackshape,fSSDSupportRingAl);
6068  electboardback->SetLineColor(fColorAl);
6069  // Electronic Board Kapton Layer
6070  const Int_t kelectlayervertexnumber = 8;
6071  Double_t xelectlayer[kelectlayervertexnumber];
6072  Double_t yelectlayer[kelectlayervertexnumber];
6073  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
6074  xelectlayer[1] = xelectlayer[0];
6075  xelectlayer[2] = fgkEndCapCardElectBoardLength;
6076  xelectlayer[3] = xelectlayer[2];
6077  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
6078      
6079  yelectlayer[0] = 0.0;
6080  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
6081  yelectlayer[2] = yelectlayer[1];
6082  yelectlayer[3] = yelectlayer[0];
6083  yelectlayer[4] = yelectlayer[3];
6084  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
6085  yelectlayer[6] = yelectlayer[5];
6086  yelectlayer[7] = yelectlayer[4];
6087  TGeoXtru* electlayershape = new TGeoXtru(2);
6088  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
6089  electlayershape->DefineSection(0,0.0);
6090  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
6091  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
6092                                                                                          electlayershape,fSSDKaptonFlexMedium);
6093  electlayer->SetLineColor(fColorKapton);
6094  // JMD Connector Female
6095  const Int_t kjmdconnectorvertexnumber = 6;
6096  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6097  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6098  xjmdconnectorvertex[0] = 0.0; 
6099  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
6100  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
6101  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
6102  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
6103  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
6104
6105  yjmdconnectorvertex[0] = 0.0; 
6106  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
6107  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
6108  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
6109  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
6110  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
6111  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
6112  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
6113                                                                   yjmdconnectorvertex); 
6114  jmdconnectorshape->DefineSection(0,0.0);
6115  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6116  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6117                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6118  jmdconnector->SetLineColor(fColorG10);
6119  // Top Cable Connector
6120  const Int_t kcableconnectorvertexnumber = 8;
6121  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6122  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6123  xconnectorvertex[0] = 0.0;
6124  xconnectorvertex[1] = xconnectorvertex[0];
6125  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6126  xconnectorvertex[3] = xconnectorvertex[2];
6127  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6128                                          - fgkEndCapCardCableConnectorLength[2];
6129  xconnectorvertex[5] = xconnectorvertex[4];
6130  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6131  xconnectorvertex[7] = xconnectorvertex[6];
6132
6133  yconnectorvertex[0] = 0.0;
6134  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6135  yconnectorvertex[2] = yconnectorvertex[1];
6136  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6137  yconnectorvertex[4] = yconnectorvertex[3];
6138  yconnectorvertex[5] = yconnectorvertex[1];
6139  yconnectorvertex[6] = yconnectorvertex[5];
6140  yconnectorvertex[7] = yconnectorvertex[0];
6141  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6142  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6143                                                                     yconnectorvertex); 
6144  cableconnectorshape->DefineSection(0,0.0);
6145  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6146  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6147                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6148  cableconnector->SetLineColor(fColorG10);
6149  // Strip Connection
6150  TGeoBBox* endcapstripconnectionshape = 
6151                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6152                                                                                          0.5*fgkEndCapStripConnectionThickness,
6153                                                                                          0.5*fgkEndCapStripConnectionWidth);
6154  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6155                                                                                                         endcapstripconnectionshape,
6156                                                                                                         fSSDSupportRingAl);
6157  endcapstripconnection->SetLineColor(fColorAl);
6158  // Interface Card B
6159  const Int_t kcardBvertexnumber = 12; 
6160  Double_t xcardBvertexnumber[kcardBvertexnumber];
6161  Double_t ycardBvertexnumber[kcardBvertexnumber];
6162
6163  xcardBvertexnumber[0]  = 0.0;
6164  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6165  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6166  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6167  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6168  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6169  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6170  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6171  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6172  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6173  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6174  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6175  
6176  ycardBvertexnumber[0]  = 0.0;
6177  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6178  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6179  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6180  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6181  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6182  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6183  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6184  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6185  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6186  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6187  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6188
6189  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6190  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6191  interfacecardBshape->DefineSection(0,0.);
6192  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6193  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6194                                                                                          fSSDMountingBlockMedium);
6195  interfacecardB->SetLineColor(46);
6196  // Interface Card B Electronic Board
6197  const Int_t kelectboardcardBvertexnumber = 14; 
6198  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6199  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6200
6201  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6202  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6203  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6204  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6205  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6206  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6207  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6208  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6209  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6210  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6211  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6212  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6213  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6214  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6215
6216  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6217  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6218  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6219  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6220  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6221  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6222  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6223  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6224  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6225  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6226  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6227  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6228  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6229  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6230
6231  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6232  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6233                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6234  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6235  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6236                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6237  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6238                                                                                           fSSDSupportRingAl);
6239  electboardcardB->SetLineColor(fColorAl);
6240  // Generating Stiffener 2
6241  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6242                                                                                            0.5*fgkEndCapStiffenerThickness,
6243                                                                                            0.5*fgkEndCapStiffenerLength);
6244  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6245  endcapstiffener->SetLineColor(fColorAl);   
6246  // Generating Mother Interface Card B Container
6247  const Int_t kinterfacecardBmothervertexnumber = 10;
6248  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6249  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6250
6251  xinterfacecardBmothervertex[0] = 0.0;
6252  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6253  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6254                                                                 + fgkEndCapInterfaceCardBThickness;
6255  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6256  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6257                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6258  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6259  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6260  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6261  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6262                                                                 + fgkEndCapCardJMDConnectorLength[0];
6263  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6264
6265  yinterfacecardBmothervertex[0] = 0.0;
6266  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6267                                                                 + fgkEndCapInterfaceCardBWidth[1]
6268                                                                 + fgkEndCapInterfaceCardBWidth[2];
6269  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6270  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6271  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6272  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6273  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6274  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6275                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6276                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6277  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6278  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6279  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6280  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6281                                                                                   xinterfacecardBmothervertex,
6282                                                                                   yinterfacecardBmothervertex);
6283  interfacecardBmothershape->DefineSection(0,-1.e-15);
6284  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6285  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6286                                                                                                    interfacecardBmothershape,fSSDAir);
6287  electboardcardB->SetLineColor(fColorAl);
6288  // Positioning Volumes Mother Interface Card B Container 
6289  TGeoRotation* interfacecardBrot = new TGeoRotation();
6290  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6291  interfacecardBrot->SetAngles(90.,-90.,-90.);
6292  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6293  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6294  TGeoRotation* electboardcardBrot = new TGeoRotation();
6295  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6296  electboardcardBrot->SetAngles(90.,90.,-90.);
6297  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6298  TGeoCombiTrans* electboardcardBcombitrans = 
6299                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6300  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6301  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6302  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6303  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6304  TGeoTranslation* jmdconnectorcardBtrans[3];
6305  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6306  for(Int_t i=0; i<3; i++){
6307    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6308                                                          + fgkEndCapCardJMDConnectorLength[0], 
6309                                                            fgkEndCapCardElectBoardLayerWidth[1],
6310                                                            0.5*fgkEndCapCardJMDConnectorThickness
6311                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6312                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6313                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6314    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6315                                                                                                            *jmdconnectorcardBrot);
6316    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6317  }
6318  // Mother Supply Card Container 
6319  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6320  // Interface Card Container
6321  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6322  // Placing Volumes in Mother Supply Card Container
6323  // JMD Connector Positioning
6324  TGeoTranslation* jmdconnectortrans[2];
6325  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6326  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6327                                                                                         fgkEndCapCardElectBoardBackLength[0]
6328                                           -                                             fgkEndCapCardJMDConnectorThickness
6329                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6330  TGeoRotation* jmdconnectorot = new TGeoRotation();
6331  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6332                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6333                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6334                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6335                                                                       fgkEndCapCardJMDConnectorThickness
6336                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6337  jmdconnectorot->SetAngles(90.,180.,-90);
6338  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6339                                                                                 * jmdconnectorot);
6340  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6341  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6342  // Top Cable Connector Placing
6343  TGeoRotation* cableconnectorot[2];
6344  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6345  TGeoTranslation* cableconnectortrans[3];
6346  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6347  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6348  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6349  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6350  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6351                                                                                                                            *cableconnectorot[0]);
6352  TGeoHMatrix* cableconnectormatrix[2];
6353  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6354                                                         new TGeoHMatrix((*cableconnectorot[1])
6355                                                                                    *(*cableconnectorcombitrans));
6356  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6357                                            -                               fgkEndCapCardCableConnectorThickness,
6358                                                                                 fgkEndCapCardCableConnectorLength[0]
6359                                            +                            fgkEndCapCardCableConnectorToLayer);
6360  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6361                                            -                2.*fgkEndCapCardCableConnectorThickness
6362                                            -                            fgkEndCapCardCableConnectorDistance,
6363                                                                                 fgkEndCapCardCableConnectorLength[0]
6364                                            +                            fgkEndCapCardCableConnectorToLayer);
6365  for(Int_t i=0; i<2; i++){
6366         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6367     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6368  }
6369  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6370  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6371  electboardbackrot->SetAngles(90.,-90.,-90.);
6372  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6373                                                         +                fgkEndCapCardJMDConnectorLength[0]
6374                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6375  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6376                                                                                                                            *electboardbackrot);
6377  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6378  // Electronic Board Kapton Layer Positioning
6379  TGeoRotation* electlayerrot = new TGeoRotation();
6380  TGeoTranslation* electlayertrans[2];
6381  TGeoCombiTrans* electlayercombitrans[2];
6382  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6383  electlayerrot->SetAngles(90.,-90.,-90.);
6384  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6385                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6386  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6387                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6388                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6389  for(Int_t i=0; i<2; i++){
6390         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6391         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6392  }
6393  // Placing Volumes in Mother Interface Card Container
6394  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6395  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6396  for(Int_t i=0; i<2; i++){
6397         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6398  }
6399  /////////////////////////////////////////////////////////////
6400  // Generation of Card Interface Container
6401  /////////////////////////////////////////////////////////////
6402  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6403                                                   - fgkEndCapCardJMDConnectorLength[0]
6404                                                   - fgkEndCapInterfaceCardBThickness
6405                                                   - 9.*fgkEndCapStripConnectionThickness
6406                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6407  const Int_t kcardinterfacecontainervertexnumber = 14;
6408  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6409  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6410  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6411                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6412  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6413  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6414                                                                    + fgkEndCapStripConnectionThickness
6415                                                                    - fgkEndCapCardElectBoardLayerThickness
6416                                                                    - fgkEndCapCardCableConnectorWidth[0];
6417  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6418  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6419  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6420  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6421                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6422  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6423  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6424                                                                    + fgkEndCapInterfaceCardBThickness;
6425  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6426  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6427                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6428  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6429  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6430                                    - fgkEndCapInterfaceElectBoardCardBThickness
6431                                                                    + fgkEndCapCardJMDConnectorLength[0]
6432                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6433  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6434
6435  ycardinterfacecontainervertex[0]  = 0.;
6436  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6437                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6438                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6439  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6440  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6441                                                                    - fgkEndCapStripConnectionWidth;
6442  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6443  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6444  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6445  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6446                                                                    + fgkEndCapInterfaceCardBWidth[1]
6447                                                                    + fgkEndCapInterfaceCardBWidth[2];
6448  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6449  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6450  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6451  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6452  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6453  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6454  
6455  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6456  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6457                                                                                   xcardinterfacecontainervertex,
6458                                                                                   ycardinterfacecontainervertex);
6459  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6460                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6461  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6462                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6463  TGeoVolume** cardinterfacecontainer;
6464  cardinterfacecontainer = new TGeoVolume*[4];
6465  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6466                                                                                         interfacecardmothershape,fSSDAir); 
6467  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6468                                                                                         interfacecardmothershape,fSSDAir); 
6469  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6470                                                                                         interfacecardmothershape,fSSDAir); 
6471  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6472                                                                                         interfacecardmothershape,fSSDAir); 
6473  /////////////////////////////////
6474  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6475  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6476  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6477  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6478  /////////////////////////////////
6479  TGeoRotation* endcapstripconnectionrot[2];
6480  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6481  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6482  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6483  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6484                                                                         *                                 (*endcapstripconnectionrot[0]));
6485  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6486  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6487                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6488                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6489                                                                                         -endcapstripconnectionshape->GetDZ(),
6490                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6491  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6492  TGeoTranslation* cardinterfacetrans[9];
6493  TGeoHMatrix* cardinterfacematrix[9]; 
6494  for(Int_t i=0; i<7; i++){ 
6495         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6496                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6497                                                                                                 0.0,0.0);  
6498         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6499                                                    *                             (*endcapstripconnectionmatrix));
6500  }
6501  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6502                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6503                                                                                                 0.0,0.0);  
6504  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6505                                                 *                                 (*endcapstripconnectionmatrix));
6506  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6507                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6508                                                                                                 0.0,0.0);  
6509  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6510                                                 *                                 (*endcapstripconnectionmatrix));
6511
6512  for(Int_t i=0; i<4; i++){
6513         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6514                                                                            cardinterfacematrix[7]);                             
6515         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6516                                                                            cardinterfacematrix[8]);                             
6517  }
6518  TGeoTranslation* mothersupplycardtrans = 
6519                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6520                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6521                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6522  TGeoHMatrix* mothersupplycardmatrix[7];
6523  Int_t index[4] = {1,1,1,1};
6524  for(Int_t i=0; i<7; i++){
6525         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6526                                                         *                                 (*mothersupplycardtrans));
6527         for(Int_t j=0; j<4; j++){
6528                 switch(j){
6529                         case 0: //Layer5 EndCap Left Side  
6530                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6531                                                                                                    cardinterfacematrix[i]);                             
6532                                 if(i!=0){
6533                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6534                                                                                                            mothersupplycardmatrix[i]);                  
6535                                         index[j]++;
6536
6537                                 }
6538                         break;
6539                         case 1: //Layer5 EndCap Rigth Side  
6540                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6541                                                                                                    cardinterfacematrix[i]);                     
6542                                 if(i>0&&i<6){
6543                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6544                                                                                                            mothersupplycardmatrix[i]);                  
6545                                         index[j]++;
6546                                 }
6547                         break;
6548                         case 2: //Layer6 EndCap Left Side  
6549                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6550                                                                                                    cardinterfacematrix[i]);                             
6551                                 if(i!=6){
6552                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6553                                                                                                            mothersupplycardmatrix[i]);                  
6554                                         index[j]++;
6555                                 }
6556                         break;
6557                         case 3: //Layer6 EndCap Right Side  
6558                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6559                                                                                                    cardinterfacematrix[i]);                             
6560                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6561                                                                                                    mothersupplycardmatrix[i]);                  
6562                                 index[j]++;
6563                         break;
6564                 }
6565         }
6566  }
6567  // Positioning Interface 
6568  TGeoTranslation* motherinterfacecardtrans = 
6569                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6570                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6571                                                          -fgkEndCapCardElectBoardLayerThickness
6572                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6573  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6574                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6575  // Positioning Interface Card B 
6576  TGeoTranslation* interfacecardBmothertrans = 
6577                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6578                                                                                 + 2.*fgkEndCapStripConnectionThickness
6579                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6580                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6581                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6582  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6583                                                                                                                          interfacecardBmothertrans);
6584  // Positioning Stiffener 
6585  TGeoTranslation* endcapstiffenertrans = 
6586                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6587                                                                            +    2.0*fgkEndCapStripConnectionThickness
6588                                                                            +    fgkEndCapInterfaceCardBThickness
6589                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6590                                                                            +    stiffenertransx
6591                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6592                                                                                         endcapstiffenershape->GetDZ()
6593                                                                            -    0.5*(fgkEndCapStiffenerLength
6594                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6595  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6596  /////////////////////////////////////////////////////////////
6597  // Deallocating memory
6598  /////////////////////////////////////////////////////////////
6599  delete interfacecardBrot;
6600  delete interfacecardBtrans;
6601  delete electboardcardBtrans;
6602  delete electboardcardBrot; 
6603  delete jmdconnectorcardBrot;
6604  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6605  delete jmdconnectorot;
6606  delete jmdconnectortrans[1];
6607  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6608  delete cableconnectorcombitrans;
6609  delete electboardbacktrans;
6610  delete electboardbackrot;
6611  delete electlayerrot;
6612  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6613  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6614  delete mothersupplycardtrans;
6615  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6616  /////////////////////////////////////////////////////////////
6617  return cardinterfacecontainer;
6618  }
6619  ////////////////////////////////////////////////////////////////////////////////
6620  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6621   /////////////////////////////////////////////////////////////
6622   // Method returning EndCap Mother Volume
6623   /////////////////////////////////////////////////////////////
6624   const Int_t kendcapcoverplatesmallholenumber = 9;
6625   Double_t endcapmotherorigin[3];
6626   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6627                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6628                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6629   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6630                                           -                      fgkEndCapCoverPlateWidth[2]
6631                                           -       (kendcapcoverplatesmallholenumber-1)
6632                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6633                                           +  0.5*(fgkEndCapSideCoverLength[2]
6634                                           +               fgkEndCapCoverPlateWidth[1]
6635                                           -       fgkEndCapCoverPlateWidth[0])
6636                                           -      (fgkEndCapCoverPlateWidth[1]
6637                                           -       fgkEndCapCoverPlateWidth[0]);
6638   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6639                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6640                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6641                                                 +      fgkEndCapSideCoverWidth[1]
6642                                                 +      fgkEndCapSideCoverThickness
6643                                                 +      fgkEndCapKaptonFoilThickness);
6644   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6645                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6646                                                           +              2.0* fgkEndCapSideCoverThickness),
6647                                                                          0.5* (fgkEndCapSideCoverLength[2]
6648                                                           +                    fgkEndCapCoverPlateWidth[1]
6649                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6650                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6651                                                       +                                    fgkEndCapSideCoverWidth[1]
6652                                                           +                                       fgkEndCapSideCoverThickness
6653                                                       +                                   fgkEndCapKaptonFoilThickness),
6654                                                                                          endcapmotherorigin);
6655   TGeoVolume** endcapassembly;  
6656   endcapassembly = new TGeoVolume*[4];
6657   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6658                                                                                         endcapmothershape,fSSDAir); 
6659   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6660                                                                                         endcapmothershape,fSSDAir); 
6661   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6662                                                                                         endcapmothershape,fSSDAir); 
6663   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6664                                                                                         endcapmothershape,fSSDAir); 
6665  /////////////////////////////////
6666  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6667  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6668  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6669  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6670  /////////////////////////////////
6671   /////////////////////////////////////////////////////
6672   // Placing Endcap Cover Plate
6673   /////////////////////////////////////////////////////
6674   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6675   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6676   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6677   TGeoCombiTrans* endcapcoverplatecombitrans = 
6678                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6679                                                                                          endcapcoverplaterot);
6680   TGeoTranslation* endcapcoverplatetrans = 
6681                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6682   TGeoHMatrix* endcapcoverplatematrix = 
6683                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6684                                                                           *       (*endcapcoverplatecombitrans));
6685   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6686   /////////////////////////////////////////////////////
6687   // Placing Endcap Side Cover
6688   /////////////////////////////////////////////////////
6689   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6690   TGeoRotation* endcapsidecoverot[2];
6691   TGeoCombiTrans* endcapsidecovercombitrans[3];
6692   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6693   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6694   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6695                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6696                                                                                         - fgkEndCapCoverPlateWidth[2]
6697                                                                                     - (kendcapcoverplatesmallholenumber-1)
6698                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6699                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6700                                                                                         + fgkEndCapSideCoverLength[2],
6701                                                                                           0.5*(fgkEndCapSideCoverThickness
6702                                                                                         + fgkEndCapCoverPlateThickness)
6703                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6704                                                                                           endcapsidecoverot[0]);
6705   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6706   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6707                                                                                                         0.5*fgkEndCapCoverPlateThickness
6708                                                                                                         -fgkEndCapSideCoverWidth[1],
6709                                                                                                         endcapsidecoverot[1]);
6710   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6711                                                                                                         +fgkEndCapCoverPlateLength[3]
6712                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6713                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6714                                                                                                         0.5*fgkEndCapCoverPlateThickness
6715                                                                                                         -fgkEndCapSideCoverWidth[1],
6716                                                                                                         endcapsidecoverot[1]);
6717   TGeoHMatrix* endcapsidecovermatrix[2];
6718   for(Int_t i=0; i<2; i++){
6719    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6720                                                         *                                 (*endcapsidecovercombitrans[0]));
6721         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6722                                                                                                                 endcapsidecovermatrix[i]);
6723   }
6724   /////////////////////////////////////////////////////
6725   // Placing Endcap Cooling Tube
6726   /////////////////////////////////////////////////////
6727   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6728   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6729   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6730   TGeoCombiTrans* endcapccolingtubecombitrans 
6731                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6732                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6733                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6734                                                 - fgkEndCapCoolingTubeToCoverSide,
6735                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6736                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6737   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6738                                                                                                           endcapccolingtubecombitrans);
6739   /////////////////////////////////////////////////////
6740   // Placing Screws 
6741   /////////////////////////////////////////////////////
6742   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6743                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6744   Int_t screwcoverplatedgesnumber[2] = {20,20};
6745   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6746                                                                                 fgkEndCapCoverPlateThickness
6747                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6748   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6749                                                                                                  screwcoverplatedgesnumber,
6750                                                                                                  screwcoverplatesection);
6751   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6752                                                                                            screwcoverplateshape,
6753                                                                                            fSSDCoolingTubePhynox); 
6754   screwcoverplate->SetLineColor(12);
6755   Double_t transx[4] = {0,
6756                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6757                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6758                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6759                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6760                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6761   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6762 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6763   TGeoTranslation*** endcapcoverplatescrewtrans;
6764   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6765   Int_t index = 0;
6766   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6767         endcapcoverplatescrewtrans[i] = 
6768                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6769     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6770                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6771         if(index==1||index==9||index==28||index==36){
6772                         endcapcoverplatescrewtrans[i][j] = 
6773                                 new TGeoTranslation(transx[i],
6774                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6775                                                                         fgkEndCapSideCoverThickness);
6776                 }
6777                 else{
6778                         endcapcoverplatescrewtrans[i][j] = 
6779                                 new TGeoTranslation(transx[i],
6780                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6781                                                                         0.);
6782                 }
6783             if(index!=19) 
6784                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6785                                                                                           endcapcoverplatescrewtrans[i][j]);
6786         }
6787   }
6788   /////////////////////////////////////////////////////
6789   // Placing Cover Plate Clips 
6790   /////////////////////////////////////////////////////
6791   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6792                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6793                                                                                                          0.5*fgkEndCapSideCoverThickness);
6794   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6795                                                                                                         endcapcoverplateclipshape,
6796                                                                                                         fSSDCoolingTubePhynox);
6797   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6798                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6799                                                                                                          0.5*fgkEndCapSideCoverThickness);
6800   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6801                                                                                                         endcapcoverplatedownclipshape,
6802                                                                                                         fSSDCoolingTubePhynox);
6803   TGeoTranslation* endcapcoverplatecliptrans[4];
6804   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6805                                                            -                     fgkEndCapCoverPlateLength[0]
6806                                                            -                     fgkEndCapSideCoverThickness,
6807                                                                                                          0.0,
6808                                                                                                  0.5*(fgkEndCapSideCoverThickness
6809                                                            +                                              fgkEndCapCoverPlateThickness));
6810   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6811                                                            -                     fgkEndCapCoverPlateLength[0]
6812                                                            -                     fgkEndCapSideCoverThickness,
6813                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6814                                                            *                                     fgkEndCapSideCoverWidth[5],
6815                                                                                                  0.5*(fgkEndCapSideCoverThickness
6816                                                            +                                              fgkEndCapCoverPlateThickness));
6817   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6818                                                            -                     fgkEndCapCoverPlateLength[0]
6819                                                            +                                     fgkEndCapCoverPlateLength[1]
6820                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6821                                                            -                                     fgkEndCapCoverPlateClipLength
6822                                                            +                                 fgkEndCapSideCoverThickness,
6823                                                                                                          0.0,
6824                                                                                                  0.5*(fgkEndCapSideCoverThickness
6825                                                            +                                              fgkEndCapCoverPlateThickness));
6826   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6827                                                            -                     fgkEndCapCoverPlateLength[0]
6828                                                            +                                     fgkEndCapCoverPlateLength[1]
6829                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6830                                                            -                                     fgkEndCapCoverPlateClipLength
6831                                                            +                                 fgkEndCapSideCoverThickness,
6832                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6833                                                            *                                     fgkEndCapSideCoverWidth[5],
6834                                                                                                  0.5*(fgkEndCapSideCoverThickness
6835                                                            +                                              fgkEndCapCoverPlateThickness));
6836   endcapcoverplateclip->SetLineColor(fColorPhynox);
6837   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6838   for(Int_t i=0; i<4; i++) 
6839         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6840                                                                                                    endcapcoverplatecliptrans[i]);  
6841   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6842   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6843                                                                    -                     fgkEndCapCoverPlateLength[0]
6844                                                                    -                     fgkEndCapSideCoverThickness,
6845                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6846                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6847                                                                                                         0.5*(fgkEndCapSideCoverThickness
6848                                                                +                                         fgkEndCapCoverPlateThickness)
6849                                                                    -                     fgkEndCapSideCoverWidth[1]
6850                                                                    -                                     fgkEndCapSideCoverThickness);
6851   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6852                                                                    -                     fgkEndCapCoverPlateLength[0]
6853                                                                    -                     fgkEndCapSideCoverThickness,
6854                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6855                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6856                                                                    +                            fgkEndCapSideCoverLength[2]
6857                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6858                                                                                                         0.5*(fgkEndCapSideCoverThickness
6859                                                                +                                         fgkEndCapCoverPlateThickness)
6860                                                                    -                     fgkEndCapSideCoverWidth[1]
6861                                                                    -                                     fgkEndCapSideCoverThickness);
6862   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6863                                                                    -                     fgkEndCapCoverPlateLength[0]
6864                                                                    +                     fgkEndCapSideCoverThickness
6865                                                                    +                     fgkEndCapCoverPlateLength[1]
6866                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6867                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6868                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6869                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6870                                                                                                         0.5*(fgkEndCapSideCoverThickness
6871                                                                +                                         fgkEndCapCoverPlateThickness)
6872                                                                    -                     fgkEndCapSideCoverWidth[1]
6873                                                                    -                                     fgkEndCapSideCoverThickness);
6874   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6875                                                                    -                     fgkEndCapCoverPlateLength[0]
6876                                                                    +                     fgkEndCapSideCoverThickness
6877                                                                    +                     fgkEndCapCoverPlateLength[1]
6878                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6879                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6880                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6881                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6882                                                                    +                                 fgkEndCapSideCoverLength[2]
6883                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6884                                                                                                         0.5*(fgkEndCapSideCoverThickness
6885                                                                +                                         fgkEndCapCoverPlateThickness)
6886                                                                    -                     fgkEndCapSideCoverWidth[1]
6887                                                                    -                                     fgkEndCapSideCoverThickness);
6888   for(Int_t i=0; i<4; i++)
6889         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6890                                                                                                    endcapcoverplatedowncliptrans[i]);
6891   /////////////////////////////////////////////////////
6892   // Placing Kapton Foil
6893   /////////////////////////////////////////////////////
6894   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6895                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6896                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6897   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6898                                                                                                 endcapkaptonfoilshape,
6899                                                                                                 fSSDKaptonFlexMedium);
6900   endcapkaptonfoil->SetLineColor(8);
6901   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6902                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6903                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6904                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6905                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6906                                                                              -                     fgkEndCapSideCoverWidth[1]
6907                                                                                  -                     fgkEndCapSideCoverThickness);
6908   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6909   /////////////////////////////////////////////////////////////
6910   // Placing Electronic Tubes
6911   /////////////////////////////////////////////////////////////
6912   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6913                                                                              - fgkEndCapInterfaceCardBThickness
6914                                                                              - 9.*fgkEndCapStripConnectionThickness
6915                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6916                                                                                fgkEndCapKaptonFoilWidth
6917                                                                              - fgkEndCapInterfaceCardBThickness
6918                                                                              - 9.*fgkEndCapStripConnectionThickness
6919                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6920                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6921   TGeoVolume* endcapeffectivecables[2];
6922   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6923                                                                                          fgkEndCapEffectiveCableRadiusMax,
6924                                                                                          endcapeffectivecableswidth[0],
6925                                                                                          10,"EndCapEffectiveCables1"); 
6926   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6927                                                                                          fgkEndCapEffectiveCableRadiusMax,
6928                                                                                          endcapeffectivecableswidth[1],
6929                                                                                          25,"EndCapEffectiveCables2"); 
6930   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6931   TGeoTranslation* endcapeffectivecablestrans[2];
6932   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6933                                           -                                                        0.5*endcapeffectivecableswidth[0]
6934                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6935                                           -                                                               fgkEndCapCoverPlateWidth[2]
6936                                           -                                             (kendcapcoverplatesmallholenumber-1)
6937                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6938                                           +                                             fgkEndCapSideCoverLength[2],
6939                                           -                     0.5*fgkEndCapCoverPlateThickness
6940                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6941                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6942                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6943   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6944                                           -                                                        0.5*endcapeffectivecableswidth[1]
6945                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6946                                           -                                                               fgkEndCapCoverPlateWidth[2]
6947                                           -                                             (kendcapcoverplatesmallholenumber-1)
6948                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6949                                           +                                         fgkEndCapSideCoverLength[2],
6950                                           -                     0.5*fgkEndCapCoverPlateThickness
6951                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6952                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6953                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6954   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6955   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6956   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6957                                                                                                                    *endcapeffectivecablesrot);
6958   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6959                                                                                                                    *endcapeffectivecablesrot);
6960 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6961 //                                                                                                        endcapeffectivecablescombitrans[0]);
6962   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6963                                                                                                           endcapeffectivecablescombitrans[1]);
6964   /////////////////////////////////////////////////////////////
6965   // Placing End Cap Cards
6966   /////////////////////////////////////////////////////////////
6967   TGeoVolume** endcapcards = GetEndCapCards();
6968   TGeoRotation* endcapcardsrot[2];
6969   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6970   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6971   TGeoTranslation* endcapcardstrans[2]; 
6972   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6973                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6974   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6975   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6976   TGeoHMatrix* endcapcardsmatrix[2];
6977   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6978   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6979                                                   - fgkEndCapCardJMDConnectorLength[0]
6980                                                   - fgkEndCapInterfaceCardBThickness
6981                                                   - 9.*fgkEndCapStripConnectionThickness
6982                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6983   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6984                                           -                                             fgkEndCapCoverPlateLength[0]
6985                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6986                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6987                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6988                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6989                                           -                                                               fgkEndCapInterfaceCardBThickness
6990                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6991                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6992                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6993                                           -                                                               fgkEndCapCoverPlateWidth[2]
6994                                           -                                             (kendcapcoverplatesmallholenumber-1)
6995                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6996                                           +                     fgkEndCapKaptonFoilWidth,
6997                                                                                           0.5*fgkEndCapCoverPlateThickness
6998                                           -                                                     fgkEndCapSideCoverWidth[1]);
6999   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
7000   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
7001    /////////////////////////////////////////////////////////////
7002   // Deallocating memory
7003   /////////////////////////////////////////////////////////////
7004   delete endcapcoverplaterot;
7005   delete endcapcoverplatecombitrans;
7006   delete endcapcoverplatetrans;
7007   for(Int_t i=0; i<3; i++){
7008    delete endcapsidecovercombitrans[i];
7009    if(i<2) delete endcapsidecoverot[i]; 
7010   }
7011   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
7012   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
7013   delete endcapcardsmatrix[0];
7014   return endcapassembly;
7015  } 
7016  ////////////////////////////////////////////////////////////////////////////////
7017  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
7018                                                                                                                         Double_t radiusmax, 
7019                                                                                                                         Double_t width, 
7020                                                                                                                         Int_t ncables,
7021                                                                                                                         char* volname){
7022   /////////////////////////////////////////////////////////////
7023   // Generating EndCap High Voltage Tubes 
7024   /////////////////////////////////////////////////////////////
7025   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
7026   Double_t effectiveouteradius = TMath::Sqrt(TMath::Power(effectiveinneradius,2.)
7027                                                            +             TMath::Power(radiusmax,2.)
7028                                -             TMath::Power(radiusmin,2.));
7029   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
7030   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
7031                                                                                                    effectiveouteradius,0.5*width);
7032   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
7033                                                                                                 effectiveinnertubeshape,
7034                                                                                                 fSSDStiffenerConnectorMedium);
7035   effectiveinnertube->SetLineColor(41);
7036   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
7037                                                                                                 effectiveoutertubeshape,
7038                                                                                                 fSSDKaptonChipCableMedium);
7039   effectiveoutertube->SetLineColor(39);
7040   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
7041   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
7042   effectivemothertube->AddNode(effectiveinnertube,1);
7043   effectivemothertube->AddNode(effectiveoutertube,1);
7044   return effectivemothertube;
7045  } 
7046  ////////////////////////////////////////////////////////////////////////////////
7047  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
7048   /////////////////////////////////////////////////////////////
7049   // Generating EndCap Support Layer 5 and Layer 6 
7050   /////////////////////////////////////////////////////////////
7051   const Int_t knedges = 5;
7052   ///////////////////////////////////////////////
7053   // Setting the vertices for TGeoXtru Up Volume
7054   ///////////////////////////////////////////////
7055   const Int_t klayernumber = 2;
7056   Double_t xupvertex[klayernumber][knedges+3];
7057   Double_t yupvertex[klayernumber][knedges+3];
7058   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
7059   Double_t middledgeangle[klayernumber] = {0.0,0.0};
7060   Double_t middlepsi[klayernumber] = {0.0,0.0};
7061   for(Int_t i=0; i<klayernumber; i++){
7062         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
7063         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
7064         xupvertex[i][2] = -xupvertex[i][1];
7065         xupvertex[i][3] = -xupvertex[i][0];
7066
7067         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
7068         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
7069         yupvertex[i][2] =  yupvertex[i][1];
7070         yupvertex[i][3] =  yupvertex[i][0];
7071         
7072     middledgeangle[i] = upedgeangle[i]/knedges;
7073     middlepsi[i] = 90.0-0.5*upedgeangle[i];
7074     for(Int_t j=1; j<knedges; j++){
7075                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
7076                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
7077         }
7078   }
7079   ////////////////////////////////////
7080   // Generating Up TGeoXtru
7081   ////////////////////////////////////
7082   TGeoXtru* upendcapsupportshape[klayernumber];
7083   TGeoVolume* upendcapsupport[klayernumber]; 
7084   char upendcapsupportname[30]; 
7085   for(Int_t i=0; i<klayernumber; i++){
7086    upendcapsupportshape[i] = new TGeoXtru(2);
7087    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
7088    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
7089    upendcapsupportshape[i]->DefineSection(0,0.);
7090    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7091    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
7092                                                                         fSSDSupportRingAl);
7093    upendcapsupport[i]->SetLineColor(5);
7094   }
7095   ///////////////////////////////////////////////
7096   // Setting the vertices for TGeoXtru Down Volume
7097   ///////////////////////////////////////////////
7098   Double_t xdownvertex[klayernumber][2*(knedges+1)];
7099   Double_t ydownvertex[klayernumber][2*(knedges+1)];
7100   for(Int_t i=0; i<klayernumber; i++){
7101         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
7102         xdownvertex[i][1] =  xupvertex[i][0];
7103         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
7104         ydownvertex[i][1] =  yupvertex[i][0];
7105         for(Int_t j=0; j<knedges; j++){
7106                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
7107                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
7108         } 
7109         for(Int_t j=0; j<knedges; j++){
7110                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7111                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
7112                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7113                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7114         }
7115   }
7116   ////////////////////////////////////
7117   // Generating Down TGeoXtru
7118   ////////////////////////////////////  
7119   TGeoXtru* downendcapsupportshape[klayernumber];
7120   TGeoVolume* downendcapsupport[klayernumber]; 
7121   char downendcapsupportname[30]; 
7122   for(Int_t i=0; i<klayernumber; i++){
7123         downendcapsupportshape[i] = new TGeoXtru(2);
7124     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7125         downendcapsupportshape[i] = new TGeoXtru(2);
7126         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7127     if(i==0){
7128                 downendcapsupportshape[i]->DefineSection(0,0.);
7129                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7130     }
7131         else{
7132                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7133                                                                  -                 fgkEndCapSupportLowWidth[i]);
7134                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7135         }
7136     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7137                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7138         downendcapsupport[i]->SetLineColor(5);
7139   }
7140   ///////////////////////////////////////////////
7141   // Setting TGeoPgon Volume
7142   ///////////////////////////////////////////////
7143   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7144                                                                                                    fgkSSDLay6LadderNumber};
7145   TGeoPgon* endcapsupportmothershape[klayernumber];
7146   TGeoVolume** endcapsupportmother;
7147   endcapsupportmother = new TGeoVolume*[klayernumber];
7148   char endcapsupportmothername[30];
7149   for(Int_t i=0; i<klayernumber; i++){
7150         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7151     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7152         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7153     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7154                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7155     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7156                                                                                         fSSDAir);       
7157   }
7158   ////////////////////////////////////
7159   TGeoRotation** endcapsupportrot[klayernumber];
7160   for(Int_t i=0; i<2; i++){
7161         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7162         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7163            endcapsupportrot[i][j] = new TGeoRotation();
7164            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7165        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7166        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7167         }
7168   }
7169   return endcapsupportmother;
7170  } 
7171  ////////////////////////////////////////////////////////////////////////////////
7172  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7173   /////////////////////////////////////////////////////////////
7174   // Setting End Cap Support Layer 5 and 6. 
7175   /////////////////////////////////////////////////////////////
7176   const Int_t kendcapcoverplatesmallholenumber = 9;
7177   const Int_t klayernumber = 2;
7178   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7179                                                                                                    fgkSSDLay6LadderNumber};
7180   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7181                                                                                 360.0/kssdlayladdernumber[1]};
7182   TGeoVolume** endcapsupport = EndCapSupport();
7183   TGeoVolume** endcapassembly = GetEndCapAssembly();
7184   TGeoPgon* endcapsupportshape[klayernumber];
7185   Double_t* radiusmin[klayernumber];
7186   Double_t* radiusmax[klayernumber];
7187   for(Int_t i=0; i<klayernumber; i++){
7188     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7189         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7190         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7191   }  
7192   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7193   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7194                                                                           endcapassemblyshape->GetDY(),
7195                                                                           endcapassemblyshape->GetDZ()};
7196   ///////////////////////////////////////////////
7197   // Setting TGeoPgon Volume for Mother Container
7198   ///////////////////////////////////////////////
7199   TGeoPgon* endcapsupportsystemshape[klayernumber];
7200   char endcapsupportsystemothername[30];
7201   for(Int_t i=0; i<klayernumber; i++){
7202         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7203     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7204         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7205                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7206                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7207                                                                                            +2.*endcapassemblycenter[2])
7208                                                                                            /CosD(0.5*upedgeangle[i]));  
7209     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7210                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7211                                                                                              - fgkEndCapCoverPlateWidth[0]),
7212                                                                                            *radiusmin[i],
7213                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7214                                                                                            +2.*endcapassemblycenter[2])
7215                                                                                            /CosD(0.5*upedgeangle[i]));
7216   }
7217   fgkEndCapSupportSystem = new TGeoVolume*[4];
7218   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7219                                                                           endcapsupportsystemshape[0],fSSDAir); 
7220   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7221                                                                           endcapsupportsystemshape[0],fSSDAir); 
7222   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7223                                                                           endcapsupportsystemshape[1],fSSDAir); 
7224   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7225                                                                           endcapsupportsystemshape[1],fSSDAir); 
7226   ///////////////////////////////////////////////
7227   TGeoTranslation* endcapassemblytrans[klayernumber];
7228   for(Int_t i=0; i<klayernumber; i++)
7229         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7230                                                                            -  fgkEndCapSideCoverThickness
7231                                                                            +  endcapassemblycenter[0],
7232                                                                            -  0.5*fgkEndCapCoverPlateThickness
7233                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7234                                                                            +  2.0*endcapassemblycenter[2]
7235                                                                            +  0.5*fgkEndCapSupportLength[i]
7236                                                                            /  TanD(0.5*upedgeangle[i]),
7237                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7238                                                                            -  fgkEndCapCoverPlateWidth[2]
7239                                                                            - (kendcapcoverplatesmallholenumber-1)
7240                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7241   TGeoRotation** endcapassemblyrot[klayernumber];
7242   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7243   for(Int_t i=0; i<klayernumber; i++){
7244    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7245    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7246    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7247    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7248    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7249    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7250    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7251    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7252         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7253         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7254    }
7255   }
7256   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7257                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7258   for(Int_t i=0; i<2*klayernumber; i++){
7259         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7260                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7261                                                                                                                                            endcapassemblymatrix[1][j+2]);
7262         }
7263         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7264   }
7265    /////////////////////////////////////////////////////////////
7266   // Deallocating memory
7267   /////////////////////////////////////////////////////////////
7268   for(Int_t i=0; i<klayernumber; i++){
7269         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7270                 delete endcapassemblyrot[i][j];
7271         }
7272         delete endcapassemblyrot[i];
7273         delete endcapassemblymatrix[i][0];
7274         delete endcapassemblymatrix[i][1];
7275   }
7276   /////////////////////////////////////////////////////////////
7277   }
7278   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7279   /////////////////////////////////////////////////////////////
7280   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7281   /////////////////////////////////////////////////////////////
7282   if (! moth) {
7283     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer5, mother is null!\n");
7284     return;
7285   };
7286   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7287   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7288   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7289                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7290                                                                            +            fgkEndCapSupportCenterLay5Position
7291                                                                            -            fgkEndCapSideCoverLength[2]);
7292   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7293                                                                                                 fgkEndCapSideCoverLength[2]
7294                                                                            -        fgkEndCapSupportCenterLay5Position
7295                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7296   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7297   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7298   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7299         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7300   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7301   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7302    /////////////////////////////////////////////////////////////
7303   // Deallocating memory
7304   /////////////////////////////////////////////////////////////
7305   delete endcapsupportsystemrot;
7306   delete endcapsupportsystemITSCentertrans[1];
7307  }
7308   /////////////////////////////////////////////////////////////
7309   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7310   /////////////////////////////////////////////////////////////
7311   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7312   /////////////////////////////////////////////////////////////
7313   if (! moth) {
7314     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer6, mother is null!\n");
7315     return;
7316   };
7317   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7318   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7319   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7320                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7321                                                                            +            fgkEndCapSupportCenterLay6Position
7322                                                                            -            fgkEndCapSideCoverLength[2]);
7323   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7324                                                                                                 fgkEndCapSideCoverLength[2]
7325                                                                            -        fgkEndCapSupportCenterLay6Position
7326                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7327   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7328   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7329   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7330         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7331   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7332   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7333    /////////////////////////////////////////////////////////////
7334   // Deallocating memory
7335   /////////////////////////////////////////////////////////////
7336   delete endcapsupportsystemrot;
7337   delete endcapsupportsystemITSCentertrans[1];
7338  }
7339  ////////////////////////////////////////////////////////////////////////////////
7340  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7341   /////////////////////////////////////////////////////////////
7342   // Setting Ladder Support of Layer 5. 
7343   /////////////////////////////////////////////////////////////
7344   if (! moth) {
7345     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer5, mother is null!\n");
7346     return;
7347   };
7348   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7349   fMotherVol = moth;
7350   TGeoTranslation* centerITSRingSupportLay5trans[2];
7351   for(Int_t i=0; i<2; i++){
7352         centerITSRingSupportLay5trans[i] = 
7353                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7354     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7355   }
7356  }
7357  ////////////////////////////////////////////////////////////////////////////////
7358  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7359   /////////////////////////////////////////////////////////////
7360   // Setting Ladder Support of Layer 6. 
7361   /////////////////////////////////////////////////////////////
7362   if (! moth) {
7363     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer6, mother is null!\n");
7364     return;
7365   };
7366   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7367   fMotherVol = moth;
7368   TGeoTranslation* centerITSRingSupportLay6trans[2];
7369   for(Int_t i=0; i<2; i++){
7370         centerITSRingSupportLay6trans[i] = 
7371                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7372     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7373   }
7374  }
7375  ////////////////////////////////////////////////////////////////////////////////
7376  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7377   /////////////////////////////////////////////////////////////
7378   // Setting Ladder Support of Layer 6. 
7379   /////////////////////////////////////////////////////////////
7380   if (! moth) {
7381     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cone, mother is null!\n");
7382     return;
7383   };
7384   if(!fSSDCone) SetSSDCone();
7385   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7386                                                                 +                                         fgkSSDCentralAL3SupportLength);
7387     moth->AddNode(fSSDCone,1,ssdconetrans);
7388 }
7389  ////////////////////////////////////////////////////////////////////////////////
7390  void AliITSv11GeometrySSD::SetSSDCone(){
7391   /////////////////////////////////////////////////////////////
7392   // Method generating SSDCone 
7393   /////////////////////////////////////////////////////////////
7394   if(!fCreateMaterials) CreateMaterials();
7395   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7396   Double_t ssdpconesectionradiusmax[16];
7397   Double_t ssdpconesectionradiusmin[16];
7398   Double_t ssdpconezsection[16];
7399   TGeoPcon* ssdpconelittleholeshape[8];
7400   TGeoVolume* ssdpconelittlehole[8];
7401   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7402   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7403   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7404                                                       / SinD(fgkSSDPConeAngle)
7405                                                           + ssdpconesectionradiusmin[0];
7406   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7407                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7408                                                           / SinD(fgkSSDPConeAngle);
7409   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7410   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7411                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7412   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7413   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7414                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7415   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7416   ssdpconelittlehole[0]->SetLineColor(4);
7417   /////////////////////////////////////////////////////////////
7418   ssdpconezsection[2] = ssdpconezsection[1];  
7419   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7420   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7421   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7422                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7423                                                           / SinD(fgkSSDPConeAngle);
7424   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7425                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7426   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7427                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7428   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7429                                                                    * TMath::RadToDeg();
7430   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7431                                                                                                           60.-ssdpconelittleholeangle,2);    
7432   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7433                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7434   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7435   ssdpconelittlehole[1]->SetLineColor(4);
7436   TGeoRotation* ssdconelittleholerot[6];
7437   for(Int_t i=0; i<6; i++){
7438         ssdconelittleholerot[i] = new TGeoRotation();
7439     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7440   }
7441   /////////////////////////////////////////////////////////////
7442   ssdpconezsection[4] = ssdpconezsection[3];  
7443   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7444   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7445   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7446                                                           * CosD(fgkSSDPConeAngle)
7447                                                           / SinD(fgkSSDPConeAngle);
7448   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7449   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7450                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7451   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7452   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7453                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7454   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7455   ssdpconelittlehole[2]->SetLineColor(4);
7456   ///////////////////////////////////////////////////
7457   ssdpconezsection[6] = ssdpconezsection[5];  
7458   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7459   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7460   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7461                                                           -ssdpconezsection[0]
7462                                                           * CosD(fgkSSDPConeAngle)
7463                                                           / SinD(fgkSSDPConeAngle);
7464   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7465   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7466                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7467   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7468                                                                    * TMath::RadToDeg();
7469   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7470                                                                                                           45.-ssdpconemiddleholeangle,2);    
7471   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7472                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7473   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7474   ssdpconelittlehole[3]->SetLineColor(4);
7475   TGeoRotation* ssdconemiddleholerot[8];
7476   for(Int_t i=0; i<8; i++){
7477         ssdconemiddleholerot[i] = new TGeoRotation();
7478     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7479   }
7480   /////////////////////////////////////////////////////////////
7481   ssdpconezsection[8] = ssdpconezsection[7];  
7482   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7483   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7484   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7485                                                           * CosD(fgkSSDPConeAngle)
7486                                                           / SinD(fgkSSDPConeAngle);
7487   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7488   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7489                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7490   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7491   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7492                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7493   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7494   ssdpconelittlehole[4]->SetLineColor(4);
7495   /////////////////////////////////////////////////////////////
7496   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7497   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7498                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7499                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7500                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7501                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7502   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7503   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7504                                                                                  * TMath::RadToDeg();
7505   ssdpconezsection[10] = ssdpconezsection[9];
7506   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7507   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7508   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7509                                                           * CosD(fgkSSDPConeAngle)
7510                                                           / SinD(fgkSSDPConeAngle);
7511   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7512   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7513                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7514   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7515                                                                                         ssdpconetrapezoidsectionangle,2);    
7516   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7517                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7518   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7519   ssdpconelittlehole[5]->SetLineColor(4);
7520   TGeoRotation* ssdconeupradiusrot[8];
7521   for(Int_t i=0; i<8; i++){
7522         ssdconeupradiusrot[i] = new TGeoRotation();
7523     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7524   }
7525   /////////////////////////////////////////////////////////////
7526   ssdpconezsection[12] = ssdpconezsection[11];
7527   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7528   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7529   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7530   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7531   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7532   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7533   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7534                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7535   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7536   ssdpconelittlehole[6]->SetLineColor(4);
7537   /////////////////////////////////////////////////////////////
7538   ssdpconezsection[14] = 0.0;
7539   ssdpconezsection[15] = ssdpconezsection[0];
7540   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7541   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7542   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7543   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7544   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7545   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7546                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7547   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7548   ssdpconelittlehole[7]->SetLineColor(4);
7549   /////////////////////////////////////////////////////////////
7550   TGeoTube* ssdtubeconeshape[2];
7551   TGeoVolume* ssdtubecone[2];
7552   TGeoTranslation* ssdtubeconetrans[2];
7553   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7554                                                                            fgkSSDPConeExternalRadius,
7555                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7556   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7557                                                                            0.5*ssdpconezsection[0]); 
7558   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7559   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7560   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7561                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7562                                           + ssdpconezsection[13]);
7563   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7564   ssdtubecone[0]->SetLineColor(4);
7565   ssdtubecone[1]->SetLineColor(4);
7566   /////////////////////////////////////////////////////////////
7567   // Mother Volume Container
7568   /////////////////////////////////////////////////////////////
7569   Double_t ssdconemotherradiusmin[8];
7570   Double_t ssdconemotherradiusmax[8];
7571   Double_t ssdconemothersection[8]; 
7572   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7573   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7574   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7575   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7576   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7577   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7578   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7579   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7580   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7581   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7582   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7583   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7584   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7585   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7586   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7587   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7588   ssdconemothersection[0] = 0.0;
7589   ssdconemothersection[1] = ssdpconezsection[0];
7590   ssdconemothersection[2] = ssdpconezsection[0];
7591   ssdconemothersection[3] = ssdpconezsection[11];
7592   ssdconemothersection[4] = ssdpconezsection[11];
7593   ssdconemothersection[5] = ssdpconezsection[13];
7594   ssdconemothersection[6] = ssdpconezsection[13];
7595   ssdconemothersection[7] = fgkSSDPConeLength;
7596   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7597   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7598                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7599   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7600   /////////////////////////////////////////////////////////////
7601   //Placing the Volumes into Mother 
7602   /////////////////////////////////////////////////////////////
7603   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7604   for(Int_t i=0; i<6; i++){
7605         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7606   }
7607   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7608   for(Int_t i=0; i<8; i++){
7609     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7610   }
7611   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7612   for(Int_t i=0; i<8; i++){
7613     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7614   }
7615   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7616   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7617   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7618   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7619   /////////////////////////////////////////////////////////////
7620   // ITS General Support
7621   /////////////////////////////////////////////////////////////
7622   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7623                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7624   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7625   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7626                                                                              - fgkSSDCentralAL3SupportLength);
7627   ssdcentralsupport->SetLineColor(4);
7628   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7629   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7630                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7631   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7632   TGeoTranslation* ssdcentralal3supportrans[3]; 
7633   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7634   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7635                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7636   ssdcentralal3support->SetLineColor(4);
7637   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7638   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7639   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7640   Double_t ssdpconcentralradiusmin[2];
7641   Double_t ssdpconcentralradiusmax[2];
7642   Double_t ssdpconcentralsection[2];
7643   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7644   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7645   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7646   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7647   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7648   ssdpconcentralsection[1] = 0.;
7649   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7650                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7651   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7652   ssdpconcentralal3->SetLineColor(4);
7653   fSSDCone->AddNode(ssdpconcentralal3,1);
7654   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7655   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7656   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7657                                                                 -2.*fgkSSDCentralAL3SupportLength);
7658   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7659                                                                                                                      *ssdcentralal3supportrot);
7660   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7661   TGeoRotation* ssdconemotherot = new TGeoRotation();
7662   ssdconemotherot->SetAngles(90.,180.,-90.);
7663   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7664                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7665   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7666   fSSDCone->AddNode(ssdconemother,1);
7667   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7668   /////////////////////////////////////////////////////////////
7669   // Deallocating memory
7670   /////////////////////////////////////////////////////////////
7671   delete ssdcentralal3supportrot;
7672   delete ssdcentralal3supportrans[2];
7673   delete ssdconemotherot;
7674   delete ssdconemothertrans;
7675   /////////////////////////////////////////////////////////////
7676  }
7677  ////////////////////////////////////////////////////////////////////////////////
7678  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7679   /////////////////////////////////////////////////////////////
7680   // Setting SSD Cables
7681   /////////////////////////////////////////////////////////////
7682   if (! moth) {
7683     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cables, mother is null!\n");
7684     return;
7685   };
7686   TGeoVolume* ssdcables = SetSSDCables();
7687   moth->AddNode(ssdcables,1);
7688 }
7689  ////////////////////////////////////////////////////////////////////////////////
7690  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7691   /////////////////////////////////////////////////////////////
7692   // Method generating SSDCables
7693   /////////////////////////////////////////////////////////////
7694   // SSD Layer 5 Cables
7695   //////////////////////////////////////////////////////////////////////////////////////////////////
7696   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7697   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7698   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7699   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7700   //////////////////////////////////////////////////////////////////////////////////////////////////
7701   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7702   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7703                                                                             -  fgkSSDLowerPConeRadius)
7704                                                                             * TanD(fgkSSDPConeAngle);
7705   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7706                                                                               + fgkEndCapSupportCenterLay5Position
7707                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7708   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7709                                                                            - ssdcableslay5startconedistance; 
7710   ssdcablelay5rightsidelength *= ssdcablesfactor;
7711   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7712   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7713                                                                                                 ssdcableslay5rightsideradiusmax,
7714                                                                                                 0.5*ssdcablelay5rightsidelength); 
7715   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7716                                                                                                          ssdcablelay5rightubeshape,
7717                                                                                                          fSSDCopper);
7718   ssdcablelay5righttube->SetLineColor(9);
7719   TGeoTranslation* ssdcablelay5rightrans = 
7720                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7721                                                                                  +              fgkEndCapSupportCenterLay5Position
7722                                                                                  +      0.5*ssdcablelay5rightsidelength);
7723   ////////////////////////////////////
7724   //  Double_t cablescapacity[20];
7725   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7726   ////////////////////////////////////
7727   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7728   ////////////////////////////////////
7729   // TGeoPCone Volumes
7730   ///////////////////////////////////
7731   TGeoPcon* ssdcableslay5pconshape[3];
7732   TGeoVolume* ssdcableslay5pcon[3]; 
7733   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7734   Double_t ssdcableslay5pconzsection[6];
7735   Double_t ssdcableslay5pconrmin[6];
7736   Double_t ssdcableslay5pconrmax[6];
7737   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7738   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7739   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7740   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7741   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7742                                                            + fgkEndCapSupportCenterLay5Position
7743                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7744   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7745                                                            + fgkSSDCentralAL3SupportLength
7746                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7747                                                            * TanD(fgkSSDPConeAngle);      
7748   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7749                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7750   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7751                                                            ssdcableslay5pconshape[0],fSSDCopper);
7752   ssdcableslay5pcon[0]->SetLineColor(9);
7753   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7754 ////////////////////////////////////
7755 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7756 ////////////////////////////////////
7757   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7758   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7759                                                            + fgkSSDCentralAL3SupportLength
7760                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7761                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7762   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7763                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7764                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7765   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7766                                                                                    ssdcableangle,2);   
7767   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7768   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7769   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7770                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7771   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7772   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7773   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7774                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7775   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7776   ssdcableslay5pcon[1]->SetLineColor(9);
7777   ////////////////////////////////////
7778   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7779                                                                                    ssdcableangle,2);   
7780   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7781   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7782   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7783   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7784   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7785   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7786                                                            * TanD(fgkSSDPConeAngle)
7787                                                            + 0.5*fgkSSDCentralSupportLength
7788                                                            + fgkSSDCentralAL3SupportLength;
7789   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7790   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7791                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7792   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7793   ssdcableslay5pcon[2]->SetLineColor(9);
7794 ////////////////////////////////////
7795   TGeoRotation* ssdcableslay5pconrot[4];        
7796   for(Int_t i=0; i<4; i++){
7797    ssdcableslay5pconrot[i] = new TGeoRotation();
7798    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7799    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7800    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7801   }
7802   ////////////////////////////////////
7803   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7804   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7805   ////////////////////////////////////
7806   // Positioning Left SSD Cables Part
7807   ////////////////////////////////////
7808   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7809                                                                                                         - 0.5*ssdcablelay5rightsidelength
7810                                                                                                         - fgkEndCapSupportCenterLay5Position
7811                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7812   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7813   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7814   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7815   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7816   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7817   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7818         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7819         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7820     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7821   }
7822   ////////////////////////////////////
7823   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7824   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7825   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7826   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7827   /////////////////////////////////////////////////////////////
7828   // Water Tubes Layer 5
7829   /////////////////////////
7830   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7831                                                                                      ssdcableslay5rightsideradiusmax
7832                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7833                                                                                      0.5*ssdcablelay5rightsidelength); 
7834   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7835                                                                                                          ssdcablelay5rightubewatershape,
7836                                                                                                          fSSDCoolingTubeWater);
7837   ssdcablelay5rightwatertube->SetLineColor(7);
7838   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7839   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7840   ////////////////////////////////////
7841   // TGeoPCone Water Volumes Layer 
7842   ///////////////////////////////////
7843   TGeoPcon* ssdcableslay5pconwatershape[3];
7844   TGeoVolume* ssdcableslay5pconwater[3]; 
7845   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7846   Double_t ssdcableslay5pconwaterzsection[6];
7847   Double_t ssdcableslay5pcwateronrmin[6];
7848   Double_t ssdcableslay5pconwaterrmax[6];
7849   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7850   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7851                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7852   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7853   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7854                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7855   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7856   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7857   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7858                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7859   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7860                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7861   ssdcableslay5pconwater[0]->SetLineColor(7);
7862   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7863   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7864 ////////////////////////////////////
7865   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7866   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7867   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7868                                                                                                 ssdcableangle,2);   
7869   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7870   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7871                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7872   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7873   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7874                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7875   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7876                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7877   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7878                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7879   ssdcableslay5pconwater[1]->SetLineColor(7);
7880 ////////////////////////////////////
7881   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7882                                                                                                 ssdcableangle,2);   
7883   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7884   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7885                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7886   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7887   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7888                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7889   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7890   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7891   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7892                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7893   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7894                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7895   ssdcableslay5pconwater[2]->SetLineColor(7);
7896 ////////////////////////////////////
7897   TGeoRotation* ssdcableslay5pconwaterot[4];    
7898   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7899   for(Int_t i=0; i<4; i++){
7900    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7901    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7902    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7903         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7904         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7905         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7906         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7907         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7908   }
7909   /////////////////////////
7910   // SSD Layer 6 Cables
7911   /////////////////////////
7912   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7913   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7914   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7915   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7916                                                                                                 ssdcableslay6rightsideradiusmax,
7917                                                                                                 0.5*ssdcablelay6rightsidelength); 
7918   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7919                                                                                                          ssdcablelay6rightubeshape,
7920                                                                                                          fSSDCopper);
7921   ssdcablelay6righttube->SetLineColor(9);
7922   TGeoTranslation* ssdcablelay6rightrans = 
7923                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7924                                                                                  +              fgkEndCapSupportCenterLay6Position
7925                                                                                  +      0.5*ssdcablelay6rightsidelength);
7926   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7927                                                                                                         - 0.5*ssdcablelay6rightsidelength
7928                                                                                                         - fgkEndCapSupportCenterLay6Position
7929                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7930   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7931   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7932   ////////////////////////////////////
7933   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7934   ////////////////////////////////////
7935   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7936                                                                                    ssdcableangle,2);   
7937   TGeoVolume* ssdcableslay6pcon;
7938   Double_t ssdcableslay6pconrmin[2];
7939   Double_t ssdcableslay6pconrmax[2];
7940   Double_t ssdcableslay6pconzsection[2];
7941   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7942   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7943   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7944   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7945   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7946                                                            + fgkEndCapSupportCenterLay6Position
7947                                                            + ssdcablelay6rightsidelength;
7948   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7949   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7950                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7951   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7952                                                            ssdcableslay6pconshape,fSSDCopper);
7953   ssdcableslay6pcon->SetLineColor(9);
7954   for(Int_t i=0; i<4; i++){
7955    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7956    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7957   }
7958   ////////////////////////////////////
7959   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7960   /////////////////////////
7961   // Water Tubes Layer 6
7962   /////////////////////////
7963   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7964                                                                                                                   ssdcableslay6rightsideradiusmax
7965                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7966                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7967   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7968                                                                                                          ssdcablelay6righwatertubeshape,
7969                                                                                                          fSSDCoolingTubeWater);
7970   ssdcablelay6rightwatertube->SetLineColor(7);
7971   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7972   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7973   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7974                                                                                    ssdcableangle,2);   
7975   TGeoVolume* ssdcableslay6waterpcon;
7976   Double_t ssdcableslay6waterpconrmin[2];
7977   Double_t ssdcableslay6waterpconrmax[2];
7978   Double_t ssdcableslay6waterpconzsection[2];
7979   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7980   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7981                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7982   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7983   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7984   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7985                                                            + fgkEndCapSupportCenterLay6Position
7986                                                            + ssdcablelay6rightsidelength;
7987   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7988   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7989                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7990   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7991                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7992   ssdcableslay6waterpcon->SetLineColor(7);
7993   TGeoRotation* ssdcableslay6pconwaterot[4];    
7994   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7995   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7996   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7997   for(Int_t i=0; i<4; i++){
7998    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7999    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
8000    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
8001                                                                                  * (*ssdcableslay6pconwaterot[i]));   
8002    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
8003    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
8004   }
8005   ////////////////////////////////////////
8006   // From ITS Ring to Patch Panel3-RB26
8007   ////////////////////////////////////////
8008   Double_t ssdcablepatchpanel3BB26radiusmin[2];
8009   Double_t ssdcablepatchpanel3BB26radiusmax[2];
8010   Double_t ssdcablepatchpanel3RB26zsection[2];
8011   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
8012   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
8013                                                                           + fgkSSDCablesLay5RightSideHeight
8014                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8015   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
8016   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
8017                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8018                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8019   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
8020                                                                                  + fgkSSDCentralAL3SupportLength
8021                                                                                  + fgkSSDPConeZLength[0];
8022   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
8023   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
8024                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8025                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8026   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
8027                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
8028   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
8029                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
8030   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
8031   TGeoRotation* ssdcablepatchpanel3B26rot[3];
8032   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
8033   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
8034   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
8035                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
8036   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
8037   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
8038                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
8039   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
8040   ////////////////////////////////////
8041   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
8042   ////////////////////////////////////////
8043   //  ITS Ring Cables RB26 Part
8044   ////////////////////////////////////////
8045   Double_t ssdcableitsring3BB26pconzsection[2];
8046   Double_t ssdcableitsring3BB26pconrmin[2];
8047   Double_t ssdcableitsring3BB26pconrmax[2];
8048   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
8049                                                                           + fgkSSDCentralAL3SupportLength
8050                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
8051   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
8052   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8053   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
8054                                                                   + fgkSSDCablesLay5RightSideHeight
8055                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8056   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
8057   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
8058   TGeoPcon* ssdcableitsring3BB26pconshape[4];
8059   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8060                                                                    -              0.5*ssdcableangle,ssdcableangle
8061                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
8062                                                                    -                             fgkSSDCableAngle),2);
8063   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8064                                                                    -              0.5*ssdcableangle,ssdcableangle
8065                                                                    +                      3.0*fgkSSDCableAngle
8066                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8067   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
8068                                                                    -              0.5*ssdcableangle,ssdcableangle
8069                                                                    -                      fgkSSDCableAngle
8070                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
8071   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8072                                                                    -              0.5*ssdcableangle,ssdcableangle
8073                                                                    +                      3.0*fgkSSDCableAngle
8074                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8075   for(Int_t i=0;i<4;i++)
8076         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
8077                                                          ssdcableitsring3BB26pconrmin[j],
8078                                                          ssdcableitsring3BB26pconrmax[j]); 
8079   TGeoVolume* ssdcableitsring3BB26pcon[4];
8080   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
8081                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
8082   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
8083                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
8084   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
8085                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
8086   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
8087                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
8088   for(Int_t i=0;i<4;i++){
8089         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
8090         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
8091 }
8092   ////////////////////////////////////
8093   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
8094   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
8095   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
8096   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
8097   ////////////////////////////////////////
8098   // From ITS Ring to Patch Panel2-RB24
8099   ////////////////////////////////////////
8100   Double_t ssdcablepatchpanel3BB24radiusmin[2];
8101   Double_t ssdcablepatchpanel3BB24radiusmax[2];
8102   Double_t ssdcablepatchpanel3RB24zsection[2];
8103   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
8104   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
8105   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
8106   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
8107                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8108                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
8109                                                                           + 0.5*fgkSSDPatchPanelHeigth;
8110   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
8111                                                                          -  fgkSSDCentralAL3SupportLength
8112                                                                          -  fgkSSDPConeZLength[0];
8113   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8114   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8115                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8116                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8117   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8118                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8119   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8120                                                                                                 ssdcablepatchpanel3RB24pconshape,
8121                                                                                                 fSSDCopper);
8122   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8123   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8124   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8125   ssdcablepatchpanel3B24rot[0]->SetAngles(0.0,0.0,0.0);
8126   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8127                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8128   ssdcablepatchpanel3B24rot[2]->SetAngles(180.0,0.0,0.0);
8129   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8130                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8131   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8132   ////////////////////////////////////
8133   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8134   ////////////////////////////////////////
8135   //  ITS Ring Cables RB24 Part
8136   ////////////////////////////////////////
8137   Double_t ssdcableitsring3BB24pconzsection[2];
8138   Double_t ssdcableitsring3BB24pconrmin[2];
8139   Double_t ssdcableitsring3BB24pconrmax[2];
8140   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8141   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8142   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8143   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8144                                                                   + fgkSSDCablesLay5RightSideHeight
8145                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8146   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8147   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8148   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8149   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8150                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8151                                                                    -                             fgkSSDCableAngle),2);
8152   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8153                                                                      ssdcableangle-fgkSSDCableAngle
8154                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8155   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8156                                                                    -                      fgkSSDCableAngle
8157                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8158   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8159                                                                                                   ssdcableangle-fgkSSDCableAngle
8160                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8161   for(Int_t i=0;i<4;i++)
8162         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8163                                                          ssdcableitsring3BB24pconrmin[j],
8164                                                          ssdcableitsring3BB24pconrmax[j]); 
8165   TGeoVolume* ssdcableitsring3BB24pcon[4];
8166   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8167                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8168   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8169                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8170   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8171                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8172   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8173                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8174   for(Int_t i=0;i<4;i++){
8175         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8176         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8177 }
8178   ////////////////////////////////////
8179   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8180   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8181   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8182   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8183   ////////////////////////////////////
8184   // Volumes for Material Budget 
8185   ////////////////////////////////////
8186   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8187                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8188                                                                                                          ssdcableslay6rightsideradiusmax
8189                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8190                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8191   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8192                                                                                                          ssdcablelay6materialbudgetubeshape,
8193                                                                                                          fSSDCopper);
8194   ssdcablelay6materialbudgetube->SetLineColor(9);
8195   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8196   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8197
8198   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8199                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8200   TGeoVolume* ssdcablelay6materialbudgetpcon;
8201   Double_t ssdcablelay6materialbudgetpconrmin[2];
8202   Double_t ssdcablelay6materialbudgetpconrmax[2];
8203   Double_t ssdcablelay6materialbudgetpconzsection[2];
8204   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8205                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8206   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8207                                                                                 + fgkSSDCableMaterialBudgetHeight;
8208   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8209   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8210   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8211                                                                                         + fgkEndCapSupportCenterLay6Position
8212                                                                                         + ssdcablelay6rightsidelength;
8213   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8214   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8215                                                   ssdcablelay6materialbudgetpconzsection[i],
8216                                                   ssdcablelay6materialbudgetpconrmin[i],
8217                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8218   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8219                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8220   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8221   for(Int_t i=0; i<4; i++){
8222    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8223    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8224   }
8225 ////////////////////////////////////
8226  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8227   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8228   Double_t ssdcablesvolume = 0.0;
8229   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8230   std::cout << ssdcablesvolume << std::endl;*/
8231   return ssdcablesmother;
8232  }
8233  ////////////////////////////////////////////////////////////////////////////////
8234 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8235                                                                         Double_t height, char* shapename, Int_t isign) const{
8236   /////////////////////////////////////////////////////////////
8237   // Method generating an Arb shape 
8238   /////////////////////////////////////////////////////////////
8239   const Int_t kvertexnumber = 8;
8240   const Int_t ktransvectnumber = 2;
8241   TVector3* vertex[kvertexnumber];
8242   TVector3* transvector[2];
8243   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i] = new TVector3(0.,width[i]);
8244   /////////////////////////////////////////////////////////////
8245   //Setting the vertices for TGeoArb8
8246   /////////////////////////////////////////////////////////////
8247   vertex[0] = new TVector3(*vertexpos[0]);
8248   vertex[1] = new TVector3(*vertexpos[1]);
8249   vertex[2] = new TVector3(*vertex[1]+isign*(*transvector[0]));
8250   vertex[3] = new TVector3(*vertex[0]+isign*(*transvector[0]));
8251   vertex[4] = new TVector3(*vertexpos[2]);
8252   vertex[5] = new TVector3(*vertexpos[3]);
8253   vertex[6] = new TVector3(*vertex[5]+isign*(*transvector[1]));
8254   vertex[7] = new TVector3(*vertex[4]+isign*(*transvector[1]));
8255   /////////////////////////////////////////////////////////////
8256   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8257   for(Int_t i = 0; i<kvertexnumber;i++) 
8258                                                         arbshape->SetVertex(i,vertex[i]->X(),vertex[i]->Y());
8259   /////////////////////////////////////////////////////////////
8260   // Deallocating memory
8261   /////////////////////////////////////////////////////////////
8262   for(Int_t i=0; i< kvertexnumber; i++) delete vertex[i];  
8263   for(Int_t i=0; i< ktransvectnumber; i++) delete transvector[i];  
8264   /////////////////////////////////////////////////////////////
8265   return arbshape;
8266
8267 ///////////////////////////////////////////////////////////////////////////////
8268 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8269                                                                 Double_t rmax, Int_t nedges, Double_t height){
8270   /////////////////////////////////////////////////////////////
8271   // Method generating Arc shape 
8272   /////////////////////////////////////////////////////////////
8273         const Int_t kvertexnumber = 2*nedges+2;
8274         TGeoXtru* arcshape = new TGeoXtru(2);   
8275         TVector3** vertexposition[2];
8276         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8277         Double_t angle = 0.;
8278     for(Int_t i=0; i<nedges+1; i++){ 
8279                 angle = 90.+0.5*phi-i*(phi/nedges);
8280                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8281                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8282         }
8283         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8284         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8285         for(Int_t i=0; i<kvertexnumber; i++){ 
8286                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8287                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8288                 }
8289                 else if(i>=1&&i<nedges+2)
8290                 {
8291                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8292                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8293                 }
8294         else
8295                 {
8296                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8297                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8298                 }
8299     }
8300   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8301   arcshape->DefineSection(0,-0.5*height);
8302   arcshape->DefineSection(1,0.5*height);
8303   /////////////////////////////////////////////////////////////
8304   // Deallocating memory
8305   /////////////////////////////////////////////////////////////
8306   for(Int_t i=0; i<2; i++){
8307         for(Int_t j=0; j<nedges+1; j++)
8308                 delete vertexposition[i][j];
8309         delete [] vertexposition[i];
8310   }
8311   delete [] xvertexpoints;
8312   delete [] yvertexpoints;
8313   /////////////////////////////////////////////////////////////
8314         return arcshape;
8315 }
8316 ////////////////////////////////////////////////////////////////////////////////
8317 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8318   ///////////////////////////////////////////////////////////////////////
8319   // Method Generating the Screw Shape  
8320   // radius[0]: outer radius
8321   // radius[1]: inner radius
8322   // edgesnumber[0]: outer number of edges
8323   // edgesnumber[1]: inner number of edges
8324   // section[0]: lower section position
8325   // section[1]: higher section position
8326   ///////////////////////////////////////////////////////////////////////
8327   Double_t outradius = radius[0];
8328   Double_t inradius = radius[1];
8329   Int_t outvertexnumber = edgesnumber[0];
8330   Int_t invertexnumber = edgesnumber[1];
8331   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8332   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8333   for(Int_t i=0; i<outvertexnumber; i++){
8334         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8335         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8336   }
8337   for(Int_t i=0; i<invertexnumber; i++){
8338         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8339         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8340   }
8341   TGeoXtru* screwshapeout = new TGeoXtru(2);
8342   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8343   screwshapeout->DefineSection(0,section[0]);
8344   screwshapeout->DefineSection(1,section[1]);
8345   TGeoXtru* screwshapein = new TGeoXtru(2);
8346   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8347   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8348   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8349   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8350   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8351   
8352   delete [] xscrewvertex;
8353   delete [] yscrewvertex;
8354   return screwshape;
8355 }
8356 ////////////////////////////////////////////////////////////////////////////////
8357 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8358   ///////////////////////////////////////////////////////////////////////
8359   // Method Generating the Hole Shape  
8360   // radius of the Hole
8361   // nedges: number of edges to approximate the circle
8362   ///////////////////////////////////////////////////////////////////////
8363   Double_t* xholevertex = new Double_t[nedges];
8364   Double_t* yholevertex = new Double_t[nedges];
8365   Double_t z  = 0.5*(section[0]+section[1]);
8366   Double_t dz = 0.5*(section[1]-section[0]);
8367   TGeoTranslation *tr = 0;
8368   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8369      tr = new TGeoTranslation(0.,0.,z);
8370      tr->RegisterYourself();
8371   }   
8372   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8373   for(Int_t i=0; i<nedges; i++){
8374         xholevertex[i] = radius*CosD(i*360./nedges);
8375         yholevertex[i] = radius*SinD(i*360./nedges);
8376   }
8377   TGeoXtru* holeshapeout = new TGeoXtru(2);
8378   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8379   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8380   holeshapeout->DefineSection(1,section[1]+0.01);
8381   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8382   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8383   
8384   delete [] xholevertex;
8385   delete [] yholevertex;
8386   return holeshape;
8387 }
8388 ////////////////////////////////////////////////////////////////////////////////
8389 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8390   /////////////////////////////////////////////////////////////
8391   // Given an axis specified by param, it gives the reflection of the point
8392   // respect to the axis
8393   /////////////////////////////////////////////////////////////
8394   TVector3* n = new TVector3(param[0],param[1],param[2]);
8395   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8396   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8397   /////////////////////////////////////////////////////////////
8398   // Deallocating memory
8399   /////////////////////////////////////////////////////////////
8400   delete n;
8401   /////////////////////////////////////////////////////////////
8402   return reflectedvector;
8403 }
8404 ////////////////////////////////////////////////////////////////////////////////
8405 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8406                                                        Double_t dx,
8407                                                        Double_t dy,
8408                                                        Double_t dz) const{
8409   /////////////////////////////////////////////////////////////
8410   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8411   /////////////////////////////////////////////////////////////
8412   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8413   const Double_t *vect = hmatrix->GetTranslation();
8414   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8415   hmatrix->SetTranslation(newvect);
8416   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8417   delete hmatrix;
8418   return matrix;
8419 }
8420 ////////////////////////////////////////////////////////////////////////////////
8421 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8422   /////////////////////////////////////////////////////////////
8423   // Method returning the Medium type 
8424   /////////////////////////////////////////////////////////////
8425   char ch[30];
8426   sprintf(ch, "ITS_%s",mediumName);
8427   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8428   if (! medium)
8429     printf("Error(AliITSv11GeometrySSD)::medium %s not found !\n", mediumName);
8430   return medium;
8431 }
8432 ////////////////////////////////////////////////////////////////////////////////
8433 void AliITSv11GeometrySSD::CreateMaterials(){
8434 ///////////////////////////////////
8435 // This part has to be modified
8436 ///////////////////////////////////
8437   ///////////////////////////////////
8438   // Silicon for Sensor
8439   /////////////////////////////////// 
8440   fSSDSensorMedium = GetMedium("SI$");
8441   ///////////////////////////////////
8442   // Silicon Mixture for Sensor
8443   /////////////////////////////////// 
8444   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8445   fSSDChipGlueMedium = GetMedium("EPOXY$");
8446   ///////////////////////////////////
8447   // Stiffener Components Materials
8448   /////////////////////////////////// 
8449   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8450   ///////////////////////////  
8451   // Stiffener Connectors 
8452   ///////////////////////////  
8453   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8454   ////////////////////////////////  
8455   // Stiffener 0603-1812 Capacitor
8456   ////////////////////////////////  
8457   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8458   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8459   ///////////////////////////  
8460   // Stiffener Hybrid Wire 
8461   ///////////////////////////  
8462   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8463   ///////////////////////////  
8464   // Al for Cooling Block
8465   ///////////////////////////  
8466   fSSDAlCoolBlockMedium = GetMedium("AL$");
8467   //////////////////////////////////////////////////////  
8468   // Kapton and Al for Chip Cable Flex and Ladder Cables
8469   //////////////////////////////////////////////////////  
8470   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8471   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8472   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8473   fSSDAlTraceFlexMedium = GetMedium("AL$");
8474   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8475   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8476   /////////////////////////////////////////////////////////////////  
8477   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8478   //////////////////////////////////////////////////////////////////  
8479   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8480   /////////////////////////////////////////////////////////////////  
8481   // G10 for Detector Leg, TubeHolder
8482   //////////////////////////////////////////////////////////////////  
8483   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8484   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8485   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8486   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8487   /////////////////////////////////////////////////////////////////  
8488   // Water and Phynox for Cooling Tube
8489   //////////////////////////////////////////////////////////////////  
8490   fSSDCoolingTubeWater = GetMedium("WATER$");
8491   fSSDCoolingTubePhynox = GetMedium("INOX$");
8492   /////////////////////////////////////////////////////////////////////
8493   // Material for Support Rings
8494   /////////////////////////////////////////////////////////////////////
8495   fSSDSupportRingAl = GetMedium("AL$");
8496   fSSDRohaCellCone = GetMedium("ROHACELL$");
8497   /////////////////////////////////////////////////////////////////////
8498   fSSDAir = GetMedium("SDD AIR$");
8499   fSSDCopper = GetMedium("COPPER$");
8500   fCreateMaterials = kTRUE;
8501 }
8502 /////////////////////////////////////////////////////////////////////
8503